akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(),a.end());

    ll ans1 = 0,ans2 = 0;

    int right = a.size() - 1;
    int left = 0;
    int i = 0;
    while(right >= left){
        if(i % 2 == 0){
            ans1 -= 2 * a[left];
            left++;
        }
        else{
            ans1 += 2 * a[right];
            right--;
        }
        i++;
    }
    if(n % 2 == 0){
        ans1 -= a[a.size()/2];
        ans1 += a[a.size()/2 - 1];
    }
    else{
        ans1 += (a[a.size()/2] + a[a.size()/2 - 1]);
    }
    right = a.size() - 1;
    left = 0;
    i = 0;
    while(right >= left){
        if(i % 2 == 0){
            ans2 += 2 * a[right];
            right--;
        }
        else{
            ans2 -= 2 * a[left];
            left++;
        }
        i++;
    }
    right++;
    left--;
    if(n % 2 == 0){
        ans2 -= a[a.size()/2];
        ans2 += a[a.size()/2 - 1];
    }
    else{
        ans2 -= a[a.size()/2];
        ans2 -= a[a.size()/2 + 1];
    }

    cout << max(ans1,ans2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) cout << (n /2)*(n/2) << endl;
    else cout << (n/2) * (n/2 + 1) << endl;
}

Measured memory_bytes: 764
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        
        int A = 0;
        int B = 0;
        for(int i=0; i<N; i+=2){
            A += a[i];
        }
        for(int i=1; i<N; i+=2){
            B += a[i];
        }
        System.out.println(A-B);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;

int main() {
    int p[3];
    cin >> p[0] >> p[1] >> p[2];

    int ans = 201;

    for(int i = 0; i < 3; ++i){
        for(int j = i + 1; j < 3; ++j){
            if(ans > p[i] + p[j]){
                ans = p[i] + p[j];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*template date:2019/12/27*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<limits.h>
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
double to_deg(double r){return r*180.0/(atan(1.0)*4.0);}
typedef struct{
    int x;
    int y;
}pair_t;
int asc_cmp_t(const void* X,const void* Y){int x=(*(pair_t*)X).x,y=(*(pair_t*)Y).y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp_t(const void* X,const void* Y){int x=(*(pair_t*)X).x,y=(*(pair_t*)Y).y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    int a[300000];for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int cnt=1,ans=0;
    for(int i=0;i<n;i++){
        if(a[i]==cnt)cnt++;
        else ans++;
    }
    printf("%d\n",ans==n?-1:ans);
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i ++){
        cin >> v[i];
    }
    sort(v.begin(),v.end(),greater<int>());
    int res = 0;
    for(int i= 0; i<n; i++){
        if(i%2 == 0){
            res += v[i];
        }else{
            res -= v[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc112


def main():
    N, T = map(int, input().split())
    c = [None] * N
    t = [None] * N
    for i in range(N):
        c[i], t[i] = map(int, input().split())

    costs = []
    for i in range(N):
        if t[i] <= T:
            costs.append(c[i])

    if len(costs) == 0:
        return "TLE"
    
    return min(costs)


print(main())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

int MOD = 1e9+7;

long power(long a, long b) {
  return b ? power(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD : 1;
}

long comb(long a, long b) {
  long x = 1, y = 1;
  for (int i = 1; i <= b; i++) {
    x = x * (a - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * power(y, MOD - 2) % MOD;
}

int main() {
  int X, Y;
  cin >> X >> Y;
  if ((X + Y) % 3) return cout << 0 << "\n", 0;
  if (X > Y * 2 || Y > X * 2) return cout << 0 << "\n", 0;
  int Z = (X + Y) / 3;
  cout << comb(Z, X - Z) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    getline(cin, s);
    cout<<s[0];
    for(int i=1; i<s.size(); i++)
    {
        if(s[i]==' ')
            cout<<s[i+1];
    }
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        string inpt = Console.ReadLine();
        //string inpt = @"\\///\_/\/\\\\/_/\\///_\\\\\/_/\";
        Stack<int> s1 = new Stack<int>();
        Stack<KeyValuePair<int, int>> s2 = new Stack<KeyValuePair<int, int>>();


        long totalMenseki = 0;
        for(int i=0; i<inpt.Length; i++)
        {
            if(inpt[i] == '\\')
            {
                s1.Push(i);
            } else if(inpt[i] == '/' && s1.Count > 0)
            {
                int from = s1.Pop();
                int menseki = i - from;
                totalMenseki += menseki;
                while (s2.Count > 0)
                {
                    KeyValuePair<int, int> tmp = s2.Peek();
                    if(tmp.Key >= from)
                    {
                        menseki += tmp.Value;
                        s2.Pop();
                    } else
                    {
                        break;
                    }
                }
                s2.Push(new KeyValuePair<int, int>(i, menseki));
            }
        }
        Console.WriteLine(totalMenseki);
        StringBuilder ans = new StringBuilder();
        ans.Append(s2.Count);
        int[] ikeList = new int[s2.Count];
        for(int i=0; i<ikeList.Length; i++)
        {
            KeyValuePair<int, int> tmp = s2.Pop();
            ikeList[ikeList.Length - 1 - i] = tmp.Value;
        }
        foreach(int menseki in ikeList)
        {
            ans.Append(" ");
            ans.Append(menseki);
        }
        Console.WriteLine(ans.ToString());
    }

    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 10380
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, K = map(int, input().split())

ans = 0
while N > 0:
    N //= K
    ans += 1
print(ans)




Measured memory_bytes: 6992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<ll> c(26);
    for(int i=0; i<26; i++) cin >> c[i];
    vector<vector<ll>> G(d,vector<ll> (26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> G[i][j];
        }
    }
    vector<int> t(d);
    for(int i=0; i<d; i++){
        t[i] = rand() % 26;
    }
    ll sum = 0;
    for(int k=0; k<10000; k++){
        int a = rand() % d;
        int b = rand() % 26;
        int pre = t[a];
        t[a] = b;
        vector<ll> now(26,0);
        vector<int> last(26,0);
        for(int i=0; i<d; i++){
            last[t[i]] = i+1;
            now[t[i]] += G[i][t[i]];
            for(int j=0; j<26; j++){
                now[t[i]] -= c[j] * (i+1 - last[j]);
            }
        }
        ll s = 0;
        for(int j=0; j<26; j++){
            s += now[j];
        }
        if(s > sum){
            sum = s;
        }else{
            t[a] = pre;
        }
    }
    for(int i=0; i<d; i++){
        cout << t[i]+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,x,a[N];

int main()
{
    n=read();x=read();
    rep(i,1,n) a[i]=read();
    sort(a+1,a+1+n);
    ll sum=0;
    rep(i,1,n) 
    {
        if (x>=a[i]) x-=a[i];
        else
        {
            printf("%d\n",i-1);
            return 0;
        }
    }
    if (x) printf("%d",n-1);
    else printf("%d\n",n);
    return 0;
}
        

Measured memory_bytes: 3700
from collections import Counter

def calculate_mode(data):
    c = Counter(data)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]

    modes = []

    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    modes.sort()
    return(modes)

N = int(input())
data = []
for _ in range(N):
    data.append(input())

modes = calculate_mode(data)

for mode in modes:
    print(mode)

Measured memory_bytes: 121680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int a,b;
cin >> a >> b;
if(a%b!=0)cout << a << endl;
else cout << -1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
 
 
void change(char *str){
  int len=strlen(str);
  int i;
  for(i=0;i<len;i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]-=32;
    }
  }
}
 
int main(){
  char t[10000];
  char key[10000];
  char eofstr[]={"END_OF_TEXT"};
  int ans=0;
 
  scanf("%s",key);
  change(key);
 
  while(1){
    scanf("%s",t);
    if(strcmp(t,eofstr)==0){
      break;
    }
    change(t);
    if(strcmp(t,key)==0){
      ans++;
    }
  }
 
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <climits>


using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a>0 && b>0 && c>0){
    if(a + b == c || a + c == b || b + c == a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long gcd(long x,long y){return (x%y==0?y:gcd(y,x%y));}
long lcm(long x,long y){return x*y/gcd(x,y);}

int main(){
  long N,M;cin>>N>>M;
  vector<long>A(N);for(int i=0;i<N;i++)cin>>A[i];

  
  long l=1,g=A[0];
  for(int i=0;i<N;i++){
    l=lcm(l,A[i]);g=gcd(g,A[i]);
    if(l>2*M){cout<<0;return 0;}
  }
  
  
  for(int i=0;i<N;i++)if(A[i]/g%2==0){cout<<0;return 0;}
  cout<<(M+l/2)/l;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  string ans; int Q;
  cin >> ans >> Q;
  bool rev = false;
  int L = ans.length();

  for (int i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
      continue;
    }

    if (t == 2) {
      if (ans.length() == L && rev == 1) {
        reverse(ans.begin(), ans.end());
        rev = 0;
      }
      int f;  string c;
      cin >> f >> c;

      if (f == 1) {
        if (rev == false) 
          ans.insert(0, c);
        else 
          ans += c;
      } else{
        if (rev == false) 
          ans += c;
        else 
          ans.insert(0, c);
      }
    }
  }

  if (ans.length() == L && rev == 1) {
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
  }

  if (!rev) {
    cout << ans << endl;
  } else if (rev == 1) {
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
    int n; cin >> n;
    double ans;
    if(n==1) ans=1;
    else if(n%2==0) ans=(double)1/2;
    else ans=(double)((n/2)+1)/n;
    printf("%.20lf",ans);
return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
KS = [list(map(int, input().split())) for i in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(1<<N):
    flag = True
    for j in range(M):
        k = KS[j][0]
        s = sorted(list(map(lambda x: x-1, KS[j][1:])))
        p = P[j]
        count = 0
        comb = 0
        for si in s:
            comb = comb | (1<<si)
        res = i & comb
        for l in range(N):
            if (res>>l)&1:
                count += 1
        if (count%2 == p):
            continue
        else:
            flag = False
    if (flag):
        ans += 1


print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r,int c){
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty()){
    int u = S.top();
    S.pop();
    for(int i = 0;i<G[u].size();i++){
      int v = G[u][i];
      if(color[v]==NIL){
	color[v] = c;
	S.push(v);
      }
    }
  }
}

void assignColor(){
  int id = 1;
  for(int i = 0; i< n; i++) color[i] = NIL;
  for(int u = 0; u<n;u++){
    if(color[u] == NIL) dfs(u,id++);
  }
}

int main(){
  int s,t,m,q;

  cin>>n>>m;

  for(int i = 0;i<m;i++){
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  assignColor();

  cin>>q;

  for(int i = 0;i<q;i++){
    cin>>s>>t;
    if(color[s] == color[t]){
      cout<<"yes"<<endl;
    }else{
      cout<<"no"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 8972
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(N):
  if A[i] <= x:
    if i == N-1:
      if x == A[i]:
        ans += 1
    else:
      x -= A[i]
      ans += 1
  else:
    break
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*約数の個数(x含む)*/ll divi(ll x){ll i,ans=0;rep(i,2,x+1){if(x%i==0){ans++;}}return ans;}
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;ll ans=0;///////////////////////////////////////////
ll x,y,n,k;
ll a[200010];
int main(){
 sc(k);sc(n);
 rep(i,0,n){sc(a[i]);}
  
 ll sum=-a[n-1]+a[0]+k,maax=sum;
 //cout<<i<<" "<<maax<<" "<<sum<<endl;
 rep(i,1,n){
  sum+=abs(a[i-1]-a[i]);
  maax=max(maax,abs(a[i-1]-a[i]));
  //cout<<i<<" "<<maax<<" "<<sum<<endl;
  }
 pr((sum-maax)%k);
  
return 0;}

Measured memory_bytes: 5184
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

bool solve(bitset<18>bs, vector<vector<int>>&dp,const vector<pair<int,int>>&vs,const int now) {
	if(dp[now][bs.to_ulong()]!=-1)return dp[now][bs.to_ulong()];

	bool ok = false;
	if(bs.count()==vs.size())ok=true;
	else {
		for (int i = 0; i < vs.size(); ++i) {
			if (bs[i]) {

			}
			else {
				if (vs[i].first == now || now == 7) {
					bs[i] = true;
					bool aok = solve(bs, dp, vs, vs[i].second);
					if (aok)ok = true;
					bs[i] = false;
				}
				if (vs[i].second == now || now == 7) {
					bs[i] = true;
					bool aok = solve(bs, dp, vs, vs[i].first);
					if(aok)ok=true;
					bs[i] = false;
				}
			}
		}
	
	}
	return dp[now][bs.to_ulong()]=ok;
}
int main()
{
	long long int N;
	while (cin >> N) {
		if(!N)break;
		N/=2;
		vector<int>v;
		v.push_back(N);
		long long int ans=N;
		long long int x=1;
		for (; x < sqrt(N); ++x) {
			v.push_back((N+x-1)/x);
			ans+=(N+x-1)/x;
		}

		for (long long int y = sqrt(N)+1; y >= 2; --y) {
			long long int l=(N+y-1)/y;
			long long int r=(N+y-2)/(y-1);
			l=max(l,x);

			ans+=static_cast<long long int>(y)*(r-l);
			/*for (int k = l; k < r; ++k) {
				v.push_back(y);
			}*/
		}
		ans*=8;
		ans+=4*N*4;
		cout<<ans<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 9680
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  cout << min(a, b) << " ";

  if(a+b-n < 0) {
    cout << 0 << endl;
  }else {
    cout << a+b-n << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  double sum=0;
  for(int i=1;i<=N;i++){
  double a=1;
    for(int  j=0; ;j++){
    if((double)i/(double)K<a)
      a/=2;
      else
         break;
  } sum+=a;
 } double ans=sum/N;
  cout<<setprecision(10)<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
n = int(input())
xy = []
for i in range(n):
    a = int(input())
    xy.append([])
    for j in range(a):
        tmp = list(map(int, input().split()))
        xy[i].append(tmp)
# bit全探索
# 範囲
ans = 0
s = 0
for i in range(2 ** n):
    # 判断用のリストを準備
    judge = []
    # 探索
    for j in range(n):
        if (i >> j) & 1:
            judge.append(1)
        else:
            judge.append(0)

    count = 0
    tmp_j = True
    for l in range(n):
        count = 1
        if judge[l] == 1:
            for a in range(len(xy[l])):
                if judge[xy[l][a][0] - 1] == xy[l][a][1]:
                    count = 1
                if judge[xy[l][a][0] - 1] != xy[l][a][1]:
                    count = 0
                    tmp_j = False
                    break
        if tmp_j == False:
            break

    if count == 1:
        s = sum(judge)
    if ans <= s:
        ans = s
print(ans)


Measured memory_bytes: 47084
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,a,b,c;
vector<int> G[55];
int dp[55][55][111];
void dfs(int r,int v,int d){
  if(dp[r][v][d]) return;
  dp[r][v][d]=1;
  if(d>100) return;
  for(int u:G[v]){
    dfs(r,u,d+1);
  }
}
signed main(){
  cin>>n>>m>>a>>b>>c;
  for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v;
    u--;v--;
    G[u].push_back(v);
  }
  memset(dp,0,sizeof(dp));
  for(int i=0;i<n;i++){
    dfs(i,i,0);
  }
  int dp2[n];
  memset(dp2,-1,sizeof(dp2));
  dp2[n-1]=0;
  while(1){
    bool flg=0;
    for(int v=0;v<n;v++){
      int x=-1,y=-1,z=-1;
      for(int i=0;i<n;i++){
	if(dp2[i]<0) continue;
	if(dp[v][i][a]) if(x<0||x>dp2[i]) x=dp2[i];
	if(dp[v][i][b]) if(y<0||y>dp2[i]) y=dp2[i];
	if(dp[v][i][c]) if(z<0||z>dp2[i]) z=dp2[i];
      }
      if(x<0||y<0||z<0) continue;
      int nd=max(x,max(y,z))+1;
      if(dp2[v]<0||dp2[v]>nd){
	dp2[v]=nd;
	flg=1;
	break;
      }
    }
    if(!flg) break;
  }
  if(dp2[0]<0) cout<<"IMPOSSIBLE"<<endl;
  else cout<<dp2[0]<<endl;
  return 0;
}

Measured memory_bytes: 5804
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

class Combination_Mod{
    public:
        Combination_Mod(long long MAX, long long MOD) : fact(MAX + 1), inv(MAX + 1), finv(MAX + 1), MAX(MAX + 1), MOD(MOD){
            init();
        }

        void init(){
            fact[0] = fact[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for(long long i = 2; i < MAX; ++i){
                fact[i] = fact[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] *  (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        long long bin(long long n, long long r){
            if(n < r || n < 0 || r < 0) return 0;
            return fact[n] * (finv[r] * finv[n - r] % MOD) % MOD;
        }

        long long perm(long long n, long long r){
            return (bin(n, r) * fact[r]) % MOD;
        }

        long long factorial(long long n){
            return fact[n];
        }

        long long modinv(long long n){
            return inv[n];
        }

        long long modfinv(long long n){
            return finv[n];
        }

    private:
        vector<long long> fact;
        vector<long long> inv;
        vector<long long> finv;
        const long long MAX;
        const long long MOD;
};

ll X, Y;
Combination_Mod c(2000010, MOD);

signed main(){
    cin >> X >> Y;
    ll ans = 0;
    REP(i, X + 1){
        if((X - i) % 2 != 0) continue;
        ll j = (X - i) / 2;
        if(j != Y - 2 * i) continue;
        ans = (ans + c.bin(i + j, i)) % MOD;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 50028
N = int(input())
a = [int(x) for x in input().split()]
ans1 = max(a)
a.remove(ans1)
b = sorted(a, reverse=True)
ans2 = b[0]
for i in range(N - 2):
    if abs((ans1 / 2) - b[i]) > abs((ans1 / 2) - b[i+1]):
        ans2 = b[i + 1]
    else:
        break

# print(b)
print(ans1, ans2)


Measured memory_bytes: 14060
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

map<int, int> factor(int n) {
  map<int, int> ret;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        ++cnt;
      }
      ret[i] = cnt;
    }
  }
  if (n > 1) ret[n] = 1;
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> p;
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ret += power_mod(x, MOD - 2);
    ret %= MOD;
    auto f = factor(x);
    for (auto& it : f) {
      p[it.first] = max(p[it.first], it.second);
    }
  }
  for (auto& it : p) {
    ret = ret * power_mod(it.first, it.second) % MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

ll fc(vector<bool> &ax, int index, ll x, vector<ll> &a){
  rep(i, index){
    if(ax.at(i) == true) x += 1LL << i;
  }
  ll res = 0;
  rep(i, a.size()){
    res += a.at(i) ^ x;
  }
  return res;
}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  vector<bool> ax(50);
  rep(i, 50){
    int c0 = 0, c1 = 0;
    rep(j, n){
      if((a.at(j) & (1LL << i)) == 0) c0++;
      else c1++;
    }
    if(c0 > c1) ax.at(i) = true;
    else ax.at(i) = false;
  }
  ll x = 0, ans = 0;
  rrep(i, 50){
    if((k & (1LL << i)) == 0){
    }else{
      ans = max(ans, fc(ax, i, x, a));
      x += 1LL << i;
    }
    if(i == 0) ans = max(ans, fc(ax, i, x, a));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,a,b; cin >> n >> m >> a >> b;
    forn(i,n) { 
        forn(j,m) {
            cout << ((j < a) ^ (i < b));
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  char a,b; cin >> a >> b;

  if(a=='H') {
    if(b=='H') {
      cout << 'H' << endl;
    } else {
      cout << 'D' << endl;
    }
  } else {
    if(b=='H') {
      cout << 'D' << endl;
    } else {
      cout << 'H' << endl;
    }
  }

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    int ans = 1;
    int cnt = 0;
    for(int i = N-1; i > 0; i--) {
        if(A[i] == A[i-1]) {
            ans*=A[i];
            i--;
            cnt++;
        }
        if(cnt == 2) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        String s = in.nextLine();

        int a = s.length();
        int z = 0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i) == 'A'){
                a= Math.min(a,i);
            }

            if(s.charAt(i)=='Z'){
                z = Math.max(z,i);
            }
        }

        out.print(z-a+1);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 25584
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        bool isBlack;
        vector<int> index(1, 1);
        int a;
        cin >> a;
        isBlack = (a == 1);
        for(int i=2; i<=n; ++i){
            cin >> a;
            if(isBlack != (a == 1)){
                isBlack = !isBlack;
                if(i % 2 == 1)
                    index.push_back(i);
                else{
                    if(index.size() > 1)
                        index.pop_back();
                }
            }
        }

        int ret1 = 0;
        int ret2 = 0;
        index.push_back(n+1);
        for(unsigned i=0; i<index.size()-1; ++i){
            if(i % 2 == 0)
                ret1 += index[i+1] - index[i];
            else
                ret2 += index[i+1] - index[i];
        }
        if(isBlack ^ (index.size() % 2 == 0))
            cout << ret1 << endl;
        else
            cout << ret2 << endl;
    }
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import numpy as np
 
n, k = map(int, input().split())
p = list(map(int, input().split()))

E = lambda x: (x + 1) / 2
p = [E(p_) for p_ in p]
q = [0] + list(np.cumsum(p))
sum_ = [q[i+k] - q[i] for i in range(n-k+1)]

print(max(sum_))


Measured memory_bytes: 35296
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	string s;
	int ans=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
		ans+=s[i]-'0';
	if(ans%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}	
signed main()
{
	int t=1; 
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3724
/*input
3000
*/

#include <bits/stdc++.h>
#include <unistd.h>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll n;
	cin>> n;
	cout<<(1000-n%1000)%1000<<endl;
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
//	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto& e : v) cin >> e;
    int maxi = *max_element(v.begin(), v.end());
    int mini = *min_element(v.begin(), v.end());
    if(maxi == mini){
        cout << (maxi * 2 <= N or maxi == N - 1? "Yes" : "No") << endl;
        return 0;
    }
    for(auto& e : v) e -= mini;
    int uniq_num = accumulate(v.begin(), v.end(),0LL,[&](auto res, auto num){return res + (num == 0);});
    int same_num = N - uniq_num;
    if(find_if(v.begin(),v.end(),[](auto e){return e > 1;}) != v.end()) return puts("No") * 0;
    int same = (maxi) - uniq_num;
    cout << (same * 2 <= same_num and same > 0 ? "Yes" : "No" ) << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int N;
int A[400010];
int bef[400010];

ll bit[400010];
ll mod = 1000000007;
int tmp[200010];

void add(int i, ll x)
{
    i++;
    while(i <= N)
    {
        bit[i] += x;
        bit[i] %= mod;
        i += i & -i;
    }
}

ll sum(int i)
{
    i++;
    ll sum = 0;
    while(i > 0)
    {
        sum += bit[i];
        sum %= mod;
        i -= i & -i;
    }
    return sum;
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++)cin >> A[i];

    for(int i = 0; i <= 200000; i++)tmp[i] = -1;
    for(int i = 0; i < N; i++)
    {
        bef[i] = tmp[A[i]];
        tmp[A[i]] = i;
    }

    add(0,1);

    for(int i = 0; i < N; i++)
    {
        if(bef[i] == -1 || bef[i] == i - 1)continue;
        add(i, sum(bef[i]));
    }

    cout << sum(N - 1) << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 4e7
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define vector<int> VI;
#define vector<long long> VII;

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    int t;
    cin >> t;

    if(t>=400 && t<=599)
        cout << "8" << nl;

    else if(t>=600 && t<=799)
        cout << "7" << nl;
        
    else if(t>=800 && t<=999)
        cout << "6" << nl;

    else if(t>=1000 && t<=1199)
        cout << "5" << nl;

    else if(t>=1200 && t<=1399)
        cout << "4" << nl;

    else if(t>=1400 && t<=1599)
        cout << "3" << nl;

    else if(t>=1600 && t<=1799)
        cout << "2" << nl;

    else if(t>=1800 && t<=1999)
        cout << "1" << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stack>
using namespace std;
#define rep(i,l,p) for(int i=l;i<=p;i++)

int n,a,b;
int main(){
    cin >> n >> a >> b;
    cout << min(a,b) << ' ' << max(0,a+b-n) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int price[] = {6, 4, 3, 2};
	int i;
	
	for (i = 0; i < 4; i++){
		int t, n;
		
		scanf("%d %d", &t, &n);
		printf("%d\n", price[t - 1] * n * 1000);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
vector<int> id(100005,-1);
vector<int> sss(100005,1);
int find(int x) {
    return id[x]<0?x:id[x]=find(id[x]);
}
void join(int x,int y) {
    int g=find(x),h=find(y);
    if(id[g]>id[h]) swap(g,h);
    sss[g]+=sss[h];
    id[g]+=id[h];
    id[h]=g;
}
int main() {
    cs
    int n,m,k,x,y;cin>>n>>m>>k;
    vector<int> v(n+1);
    rep(i,m) {
        cin>>x>>y;
        if(find(x)!=find(y)) join(x,y);
        v[x]++;v[y]++;
    }
    rep(i,k) {
        cin>>x>>y;
        if(find(x)==find(y)) {v[x]++;v[y]++;}
    }
    repp(i,1,n) {
        cout<<sss[find(i)]-v[i]-1<<' ';
    }
}

Measured memory_bytes: 2048
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], i = tmp[1];
    writeln(n - i + 1);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,m,a[100010],con=0,ans=0;
vector <LL> fol[100010],all,pass,g[100010];
bool vis[100010];

void dfs(int pos)
{
	vis[pos]=true;
	pass.pb(pos);
	rep(i,g[pos].size())
	{
		if(vis[g[pos][i]]) continue;
		dfs(g[pos][i]);
	}
}

int main()
{
	cin>>n>>m;
	rep(i,n) scanf("%I64d",&a[i]);
	rep(i,m)
	{
		LL x,y;
		scanf("%I64d%I64d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	rep(i,n)
	{
		if(!vis[i])
		{
			pass.clear();
			dfs(i);
			con++;
			rep(j,pass.size()) fol[i].pb(a[pass[j]]);
		}
	}
	if(con==1)
	{
		puts("0");
		rt0;
	}
	if(con*2-2>n)
	{
		puts("Impossible");
		rt0;
	}
	rep(i,n)
	{
		if(fol[i].size()==0) continue;
		sort(fol[i].begin(),fol[i].end());
		ans+=fol[i][0];
		repn(j,fol[i].size()-1) all.pb(fol[i][j]);
	}
	sort(all.begin(),all.end());
	rep(i,con-2) ans+=all[i];
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 12660
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin>>s;
	int cnt=0;
	REP(i,3) if(s[i]=='1') cnt++;
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  cin >> n;
  cout << n * n << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	im := IntMap{}

	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		im.increment(a / 400)
	}

	ans := 0
	master := 0
	for k, v := range im {
		if k >= 8 {
			master += v
			continue
		}
		ans++
	}
	if ans == 0 && master > 0 {
		ans = 1
		master--
	}

	fmt.Fprintf(writer, "%d %d\n", ans, ans+master)

	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-11

template<class T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<class T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<class T> inline bool semige(T x, T y){ return x - y > -EPS; }
template<class T> inline bool semile(T x, T y){ return y - x > -EPS; }

template<class Type> struct Line;

template<class Type>
struct P
{
  friend struct Line<Type>;
private:
  Type x, y;

public:
  P(const Type x = 0, const Type y = 0) : x(x), y(y) {}
  void setter(Type x, Type y) { this->x = x;  this->y = y;  return ; }
  Type getX(){ return x; }
  Type getY(){ return y; }
  inline double getSlope(){ return semieq(x, (Type)0) ? INF : 1.0 * y / x; }
  inline double getSlope(P p){ return (this - p).getSlope(); }
  P  operator +  (const P p){ return P(add(x,  p.x), add(y,  p.y)); }
  P  operator -  (const P p){ return P(add(x, -p.x), add(y, -p.y)); }
  P  operator *  (const Type d){ return P(x * d, y * d); }
  P& operator += (const P p){ x = add(x,  p.x);  y = add(y,  p.y);  return *this; }
  P& operator -= (const P p){ x = add(x, -p.x);  y = add(y, -p.y);  return *this; }
  P& operator *= (const Type d){ x *= d;  y *= d;  return *this; }
  bool operator == (const P p){ return  semieq(x, p.x) &&  semieq(y, p.y); }
  bool operator != (const P p){ return !semieq(x, p.x) || !semieq(y, p.y); }
  Type operator * (const P p){ return add(x * p.x,  y * p.y); }
  Type operator / (const P p){ return add(x * p.y, -y * p.x); }
};

template<class Type>
struct Line
{
private:
  P<Type> S, T;

public:
  Line(const Type sx, const Type sy, const Type tx, const Type ty) : S(sx, sy), T(tx, ty) {}
  Line(const P<Type> S, const P<Type> T) : S(S), T(T) {}
  inline P<Type> getS(){ return S; }
  inline P<Type> getT(){ return T; }
  inline double getSlope(){ return S.getSlope(T); }
  inline bool isParallel(Line<Type> L){ return semieq((S.x-T.x)*(L.S.y-L.T.y), (L.S.x-L.T.x)*(S.y-T.y));}
  inline bool isVertical(Line<Type> L){ return semieq((S.x-T.x)*(L.S.x-L.T.x), (L.T.y-L.S.y)*(S.y-T.y));}
};

typedef long double Point;

int n;
P<Point> A[4];
Point x, y;

int main()
{
  cin >> n;

  while(n--){
    rep(i, 4){
      cin >> x >> y;
      A[i].setter(x, y);
    }
    Line<Point> AB(A[0], A[1]);
    Line<Point> CD(A[2], A[3]);
    puts(AB.isParallel(CD) ? "YES" : "NO");
  }

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    int n;
    cin >> n;
    ve<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    for (int i = 0; i<n; i += 2) {
        if(a[i]%2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
sa=input()
sb=input()
sc=input()

x="a"

while True:
    if x=="a":
        if sa=="":
            print("A")
            break
        x=sa[0]
        sa=sa[1:]
    if x=="b":
        if sb=="":
            print("B")
            break
        x=sb[0]
        sb=sb[1:]
    if x=="c":
        if sc=="":
            print("C")
            break
        x=sc[0]
        sc=sc[1:]

Measured memory_bytes: 3064