akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
//const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1001001001001;

int main(){
    int n,x,t;
    cin >> n>>x>>t;
    
    cout<<(n+x-1)/x * t<<endl;
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
template<class T> void vout(vector<T> A) {rep(i, A.size()) cout << A[i] << endl;}
template<class T> void vout_(vector<T> A) { rep(i, A.size()) cout << A[i] << (i == A.size() ? "\n" : " "); }
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	cin >> a;
	ll ans = 0;
	for (int i = 0; i < 60; ++i) {
		int cnt1 = 0, cnt0 = 0;
		rep(j, n) {
			if (a[j] & (1LL << i)) cnt1++;
			else cnt0++;
		}
		ll tmp = (1LL << i);
		tmp %= mod;
		tmp *= cnt1;
		tmp %= mod;
		tmp *= cnt0;
		tmp %= mod;
		ans += tmp;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5576
def sol(ans, case):
    points = [0 for _ in range(M)]
    tmp_cost = 0
    for i, flag in enumerate(case):
        if flag == '1':
            for j in range(M):
                points[j] += A[i][j]
            tmp_cost += C[i]

    for point in points:
        if point < X:
            return float('inf')
    return tmp_cost


if __name__ == '__main__':
    N, M, X = map(int, input().split())
    C = []
    A = []
    for _ in range(N):
        tmp_input = list(map(int, input().split()))
        C.append(tmp_input[0])
        A.append(tmp_input[1:])

    ans = float('inf')
    for i in range(2 ** N):
        case = bin(i)[2:].zfill(N)
        ans = min(ans, sol(ans, case))

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 9240
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    # s = input()
    # a, b = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    # a = [int(input()) for i in range(N)]

    ans = 0
    for i in range(N):
        tmp = min(a[i], b[i])
        ans += tmp
        b[i] -= tmp
        tmp = min(a[i+1], b[i])
        ans += tmp
        a[i+1] -= tmp
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 19228
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    int n,m;cin>>n>>m;
    int sum=0;
    for(int i=0;i<m;i++)
    {
        int x;cin>>x;
        sum+=x;
    }
    if(n-sum>=0)cout<<n-sum;
    else cout<<-1;
}

Measured memory_bytes: 3652
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;



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

  int N;
  cin >> N;
  map<int, int> counter;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;

    if (counter.count(a)) {
      counter[a]++;
    } else {
      counter[a] = 1;
    }
  }

  ll first = 0;
  ll second = 0;

  for (map<int, int>::reverse_iterator i = counter.rbegin();
       i != counter.rend(); ++i) {

    if (i->second >= 2) {
      if (first == 0) {
        first = i->first;
        if (i->second >= 4) {
          second = i->first;
          break;
        }
      } else if (second == 0) {
        second = i->first;
        break;
      }
    }
  }

  cout << first * second << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;

int main(void){
    int x[100];
    int n=0;
    char c[100];
    
    while(scanf("%s",c)!=-1){
        if(c[0]=='+'){
            x[n-2]=x[n-2]+x[n-1];
            n--;
        }
        else if(c[0]=='-'){
            x[n-2]=x[n-2]-x[n-1];
            n--;
        }
        else if(c[0]=='*'){
            x[n-2]=x[n-2]*x[n-1];
            n--;
        }
        else{
            x[n]=atoi(c);
            n++;
        }
    }
    cout<<x[0]<<endl;
    return 0;
}


Measured memory_bytes: 3212
//数学問題っぽい

#include <iostream>
#include <algorithm> 
#include <vector>


using namespace std;

int main () {
    int N, A, B;
    cin >> N;
    vector<pair <long, long> >s;
    for (int i = 0; i < N; i++)
    {
        cin >> A >> B;
        s.emplace_back(B, A);
    }

    bool isClosed = true;
    int sum = 0;
    sort(s.begin(), s.end());
    for (int i = 0; i < s.size() ; i++)
    {
        sum += s[i].second;
        if (sum > s[i].first) {
            isClosed = !isClosed;
            break;
        }
    }
    cout<< (isClosed ? "Yes" : "No") <<endl;
    
}


Measured memory_bytes: 6256
#include<cstdio>
long long qwe(long long e){
	long long k=1;
	long long r=2;
	while(e)
	{
		if(e%2==0){
			r=r*r%1000000007;
			e/=2;
		}
		k*=r;
		k=k%1000000007;
		e--;
	}
	return k;
}
int main(){
	int n;
	while(~scanf("%d",&n))
	{
		int i;
		int a[100050]={0};
		int b[100050]={0};
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			b[a[i]]++;
		}
		if(n%2){
			if(b[0]!=1){
				b[0]=3;
			}
			for(i=1;i<=n;i++)
			{
				if(i%2){
					if(b[i]!=0)
					{
						b[0]=3;
						break;
					}
				}else {
					if(b[i]>2){
						b[0]=3;
						break;
					}
				}
			}
			if(b[0]==3){
				printf("0\n");
			}else {
				long long q=qwe(n/2);
				printf("%d\n",q);
			}
		}else{
			if(b[0]!=0){
				b[0]=3;
			}
			for(i=1;i<=n;i++)
			{
				if(i%2==0){
					if(b[i]!=0)
					{
						b[0]=3;
						break;
					}
				}else {
					if(b[i]>2){
						b[0]=3;
						break;
					}
				}
			}
			if(b[0]==3){
				printf("0\n");
			}else {
				long long q=qwe(n/2);
				printf("%d\n",q);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    int tsuru, kame, x, y;

    scanf("%d %d", &x, &y);

    kame = (y - (2 * x)) / 2;
    tsuru = x - kame;

    if (tsuru >= 0 && kame >= 0 && ((2 * tsuru) + (4 * kame) == y) && tsuru + kame == x) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}



Measured memory_bytes: 1648
#include <stdio.h>
#include <string.h>
int main(void)
{
  char s[30];
  int i, j;
  scanf("%s", s);

  for(i = 0; i < strlen(s); i++){
    for(j = i+1; j <= strlen(s); j++){
      if(s[i] == s[j]){
	printf("no\n");
	return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int n = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
        int man = 0;
        int go = 0;
        int sen = 0;
        boolean hantei = false;
        if((double)y/10000 > n) {
            man = -1;
            go = -1;
            sen = -1;
        }else {
            for(int i=(y/10000)+1;i>=0;i--){
                if(hantei) {
                    break;
                }
                if(10000*i+1000*(n-i) > y) {
                    continue;
                }
                for(int j=n-i; j>=0; j--) {
                    int k = n-i-j;
                    long sum = 10000*i+5000*j+1000*k;
                    //System.out.println(i+" "+j+" "+k+" "+sum);
                    if(10000*i+5000*j+1000*k == y) {
                        man = i;
                        go = j;
                        sen = k;
                        hantei = true;
                        break;
                    }
                }
            }
        }
        if(hantei) System.out.println(man+" "+go+" "+sen);
        else System.out.println(-1+" "+-1+" "+-1);
	}
}

Measured memory_bytes: 23892
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Team> t = new ArrayList<>();
        while (true) {
            Integer[] list = Arrays.stream(sc.nextLine().split(",")).map(Integer::parseInt).toArray(Integer[]::new);
            if (list[0] == 0 && list[1] == 0) {
                break;
            }
            t.add(new Team(list[0], list[1]));
        }
        Team[] tt = t.stream().sorted(Comparator.comparing(Team::getSocre, Comparator.reverseOrder())).toArray(Team[]::new);
        tt[0].rank = 1;
        for (int i = 1; i < tt.length; i++) {
            if (tt[i - 1].getSocre() == tt[i].getSocre()) {
                tt[i].rank = tt[i-1].rank;
            } else {
                tt[i].rank = tt[i-1].rank + 1;
            }
        }
        tt = t.stream().sorted(Comparator.comparing(Team::getNumber)).toArray(Team[]::new);
        while (sc.hasNext()) {
            int n = sc.nextInt()-1;
            System.out.println(tt[n].rank);
        }
    }

    static class Team {
        int number;
        int score;
        int rank;
        Team(int number, int score) {
            this.number = number;
            this.score = score;
        }
        int getSocre() {
            return score;
        }
        int getNumber() {
            return number;
        }
    }
}



Measured memory_bytes: 32896
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = 0
a = tuple(a); b = tuple(b); c = tuple(c)
a = sorted(a)
b = sorted(b,reverse=True)
c = sorted(c)

import bisect
chk_b = [0]*n
for i,bi in enumerate(b):
  y = bisect.bisect_right(c, bi)
  chk_b[i] = max(0,n-y) + chk_b[i-1]
  
chk_b = tuple(chk_b)
b = sorted(b)
for i in a:
  x = bisect.bisect_right(b, i)
  if x <= n-1:
    ans += chk_b[n-1-x]
print(ans)

Measured memory_bytes: 23344
#include<bits/stdc++.h>
using namespace std;
string S;
int K;
int main(){
  cin >> S;
  cin >> K;

  int n = S.size();
  for(int i=0;i<n;i++){
    if( S[i] == 'a' ) continue;
    if( 'z'+1 - S[i] <= K ) {
      int c = 'z'+1 - S[i];
      K -= c;
      S[i] = 'a';
    }
  }

  if( K ){
    K%=26;
    S[n-1] += K;
  }
  cout << S << endl;
}


Measured memory_bytes: 512
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

void saiki(int nowi, int nowj, long long &black, long long &white, vector<string> &data, vector<vector<bool>> &searched) {
    if (searched[nowi][nowj])
        return;
    searched[nowi][nowj] = true;
    if (data[nowi][nowj] == '#') {
        black++;
    }
    else
        white++;
    int kumi[][2] = { {-1, 0}, {1,0}, {0, -1}, {0, 1} };
    for (int k = 0; k < 4; k++) {
        int y = kumi[k][0], x = kumi[k][1];
        int ti = nowi + y, tj = nowj + x;
        if (ti < 0 || ti >= data.size() || tj < 0 || tj >= data[0].size()) {
            continue;
        }
        if (data[ti][tj] == data[nowi][nowj])
            continue;
        saiki(ti, tj, black, white, data, searched);
    }


}
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> data(h);

    for (int i = 0; i < h; i++) {
        cin >> data[i];
    }

    vector<vector<bool>> searched(h, vector<bool>(w, false));
    long long ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            long long black = 0, white = 0;
            if (searched[i][j]) {
                continue;
            }
            saiki(i, j, black, white, data, searched);
            ans += black * white;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25472
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 55, M = 22;
set <int> st[M];
vector <pair <int, int> > v[N];
vector <int> path;
int a[N], b[N], n, m, rstrct, u1[M], u2[M];

void dfs(int x, int par) {
	if (x == u2[rstrct]) {
		for (int y : path) {
			st[rstrct].insert(y);
		}
		return;
	}
	for (auto y : v[x]) {
		if (y.fi != par) {
			path.pb(y.se);
			dfs(y.fi, x);
			path.pop_back();
		}
	}
}

bool vis[N];

ll rec(int x, int mask) {
	if (x == m) {
		memset(vis, 0, sizeof vis);
		int cnt = __builtin_popcount(mask), tot = n - 1;
		for (int i = 0; i < m; i++) {
			if ((1 << i) & mask) {
				for (int j : st[i]) {
					if (!vis[j]) {
						vis[j] = true;
						tot--;
					}
				}
			}
		}
		return (1LL << tot) * ((cnt & 1) ? -1 : 1);
	}
	return rec(x + 1, mask) + rec(x + 1, mask | (1 << x));
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
		scanf("%d %d\n", &a[i], &b[i]);
		v[a[i]].pb({b[i], i});
		v[b[i]].pb({a[i], i});
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &u1[i], &u2[i]);
		rstrct = i;
		dfs(u1[i], u1[i]);
	}
	printf("%lld", rec(0, 0));
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 10;

int p[N], q[N];
int dp[N];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> p[i];
		q[p[i]] = i;
	}

	int ans = n - 1;
	for (int i=1; i<=n; i++)
	{
		if(i > 1 && q[i] > q[i - 1]) dp[i] = dp[i - 1] + 1;
		else dp[i] = 1;
		ans = min(ans, n - dp[i]);
	}

	for (int i=n; i>=1; i--)
	{
		if(i + 1 <= n && q[i] < q[i + 1]) dp[i] = dp[i + 1] + 1;
		else dp[i] = 1;
		ans = min(ans, n - dp[i]);
	}

	cout << ans << endl;
}


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

int extgcd(int a,int b,int& x,int& y)
{
  int d=a;
  if(b!=0)
  {
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else x=1,y=0;
  return d;
}

int main()
{
  int a,b,x,y;scanf("%d %d",&a,&b);
  extgcd(a,b,x,y);
  printf("%d %d\n",x,y);
}


Measured memory_bytes: 3216
n,q = map(int, input().split())
lines = [list(map(int, input().split())) for i in range(q)]
set = []
c = 0
index = [-i-1 for i in range(n)]
for line in lines:
	if line.pop(0) == 0:#or
		index_a = index[line[0]]
		index_b = index[line[1]]
		if index_a < 0 and index_b < 0:
			set += [line]
			index[line[0]] = c
			index[line[1]] = c
			c += 1
		elif index_a < 0:
			set[index_b] += [line[0]]
			index[line[0]] = index_b
		elif index_b < 0:
			set[index_a] += [line[1]]
			index[line[1]] = index_a
		elif index_a == index_b:
			continue
		else:
			set[index_a] += set[index_b]
			for i in set[index_b]:
				index[i] = index_a
		
	else:#check
		if index[line[0]] == index[line[1]]:
			print(1)
		else:
			print(0)


Measured memory_bytes: 56424
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  printf("%s\n",abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>

using namespace std;

int main(){
	
	string s;
	int ans = 0;
	
	cin >> s;
	
	for (int i = 0; i < s.length()/2; i++){
		if (s[i] != s[s.length()-1-i]){
			ans++;
		}
	}
	
	cout << ans;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll S[101010];

const int prime_max = 100000;
int NP,prime[100000],divp[prime_max];
map<int,int> M;

map<ll,int> PV;
set<ll> did;

void cprime() {
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		//M[i]=NP;
		prime[NP++]=i;
		for(ll j=1LL*i*i;j>i&&j<prime_max;j+=i) divp[j]=i;
	}
}


ll hoge(ll n) {
	int i;
	FOR(i,NP) {
		ll a=prime[i];
		if(a>1000) break;
		
		while(n % (a*a*a)==0) n /= a*a*a;
	}
	return n;
}

ll rev(ll n) {
	ll nn=n*n;
	int i;
	FOR(i,NP) {
		ll a=prime[i];
		if(a>1000) break;
		
		while(nn % (a*a*a)==0) nn /= a*a*a;
	}
	return nn;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cprime();
	int cube=0;
	FOR(i,N) {
		cin>>S[i];
		ll v=hoge(S[i]);
		if(v==1) cube++;
		else PV[v]++;
	}
	
	int ret=N;
	if(cube) ret -= (cube-1);
	FORR(r,PV) {
		if(did.count(r.first)) continue;
		ll rr=rev(r.first);
		
		if(PV.count(rr)) ret -= min(r.second,PV[rr]);
		did.insert(rr);
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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


int main()
{
  int N;
  cin>>N;
  int h[N+1];
  for(int i=1; i<=N; i++)
    cin>>h[i];
  long long mincost[N+1];
  mincost[1]=0;
  mincost[2]=abs(h[2]-h[1]);
  for(int i=3; i<=N; i++)
  {
    mincost[i]=min( abs(h[i]-h[i-2])+ mincost[i-2], abs(h[i]-h[i-1])+mincost[i-1]);

  }
  cout<<mincost[N];

}


Measured memory_bytes: 4732
void main() {
	auto N = ri;
	auto ip = readAs!(int[]), T = ip[0], A = ip[1];
	auto H = readAs!(int[]);
	real tmp = 128912098;
	ulong res;
	foreach(v, i; H) {
		auto t = T - (0.006*i);
		if(tmp > abs(t - A)) {
			tmp = abs(t - A);
			res = v;
		}
	}
	(res+1).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 380
#include <stdio.h>

int main()
{
 long long int n,a[100000],even=0,flag=0,count=0,i;
  scanf("%lld",&n);
  for(i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
      while(a[i]%2==0)
      {
         a[i]/=2;
         count++;
      }
      
  }
  printf("%lld",count);
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n, m;
vint s, d;
int dp[111][1<<15];
int table[111][1<<15];

int cost(int bit, int idx) {
  int sum = 0;
  rep(i, n) if((bit>>i)&1) sum += s[i];
  return abs(sum-d[idx]);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> n >> m, n+m) {
    resz(s, n);
    rep(i, n) cin >> s[i];
    resz(d, m);
    rep(i, m) cin >> d[i];
    sort(all(d));
    rep(i, m) {
      rep(bit, 1<<n) table[i][bit] = cost(bit, i);
    }
    fill(dp[0], dp[111], inf);
    dp[0][0] = 0;
    rep(i, m) {
      rep(bit, 1<<n) {
	if(dp[i][bit] == inf) continue;
	dp[i+1][bit] = dp[i][bit] + table[i][bit];
      }
      rep(bit, 1<<n) {
	if(dp[i+1][bit] == inf) continue;
	//cout << i << " " << static_cast<bitset<8>>(bit) << endl;
	rep(j, n) {
	  if((bit>>j)&1) continue;
	  chmin(dp[i+1][bit|1<<j], dp[i+1][bit]-table[i][bit]+table[i][bit|1<<j]);
	  //cout<<dp[i+1][bit|1<<j]<<endl;
	}
      }
    }
    /*
    rep(i, m+1) {
      rep(j, 1<<n) cout << dp[i][j] << " ";
      cout << endl;
    }
    //*/
    int ans = inf;
    rep(bit, 1<<n) chmin(ans, dp[m][bit]);
    cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 57168
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	ll N, W;
	ll w[101];
	ll v[101];
	cin >> N >> W;
	for(int i = 1; i <= N; i++){
		cin >> w[i] >> v[i];
	}
	
	const int NMax = 100;
	const int VMax = 1000*NMax;
	static ll DP[NMax+1][VMax+1];
	
	for(int i = 0; i < NMax+1; i++){
		for(int j = 0; j < VMax+1; j++){
			DP[i][j] =  j > 0 ? LLONG_MAX/2 : 0;
		}
	}
	
	for(int i = 1; i < N+1; i++){
		for(int j = 0; j < VMax+1; j++){
			if(j-v[i] >= 0){
				DP[i][j] = DP[i-1][j-v[i]] + w[i];
			}
			DP[i][j] = min(DP[i][j], DP[i-1][j]);
		}
	}
	
	ll ans = 0;
	for(int i = 1; i < VMax+1; i++){
		if(DP[N][i] <= W){
			ans = i;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 79104
# include <bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
    cin>>k>>n;
    int sum=0;
    for(register int i=0;i<=k;i++)
        for(register int j=0;j<=k;j++)
            {
                int m=n-i-j;
                if(m>k||m<0)continue;
                if(i+j+m==n)sum++;
            }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x,h,m,s;
	
	scanf("%d",&x);
	
	h=x/3600;
	m=(x%3600)/60;
	s=(x%3600)%60;
	
	printf("%d:%d:%d\n",h,m,s);
		
	return 0;
}


Measured memory_bytes: 2744
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include <iomanip>
#include <assert.h>

#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll a,b,c;

  cin >> a >> b >> c;
  ll x = c-a-b;
  if (x < 0) {
    cout << "No" << endl;
    return 0;
  }
  if (4*a*b < x*x) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
using namespace std;

int main (void)
{
	int i, h, x, n, j;
	char a[201], b[201];

	while (scanf("%s", a) != EOF && a[0] != '-'){
		scanf("%d", &h);
		for (i=0; i<h; i++){
			x=0;
			scanf("%d", &n);
			for (j=n; a[j] != '\0'; j++)
				b[x++] = a[j];
			for (j=0; j<n; j++)
				b[x++] = a[j];

			strcpy (a, b);
			a[x] = '\0';
		}
		printf("%s\n", a);
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int N =200010;

vector<int> G[N];
int color[N];
int ans[2];
bool f;
void dfs(int x){
  if(!f) return;
  int c=color[x];
  for (int k = G[x].back(); k;G[x].pop_back(),k=G[x].back()) {
    if(!f) return;
    if(color[k]==-1){color[k]=c^1;ans[c^1]++;dfs(k);}
    else if(color[k]==c){f=0;}
  }
}



int main(int argc, char *argv[])
{
  int n,m;
  int u,v;
  f=1;
  scanf("%d %d",&n,&m);
  
  for (int i = 1; i <= m; i++) {
    scanf("%d%d",&u,&v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  memset(color,-1,sizeof(color));
  color[1]=0;ans[0]++;

  dfs(1);

  if(!f) printf("%lld\n",(long long)n*(n-1)/2-m);
  else printf("%lld\n",(long long)ans[0]*ans[1]-m);
  return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main()
{
    double d,s,t; cin>>d>>t>>s;
    if(double(d/s)<=t)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3716
package main

import "fmt"

func main() {
	var b, result string
	_, _ = fmt.Scanf("%s", &b)
	switch b {
	case "A":
		result = "T"
	case "T":
		result = "A"
	case "C":
		result = "G"
	case "G":
		result = "C"
	}
	fmt.Printf("%s", result)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int i=1;
  int a,b,temp;

  while(1){
    scanf("%d%d",&a,&b);
    if(b < a){
      temp = b; b = a; a = temp;
    }
    if(a == 0 && b == 0)break;
    printf("%d %d\n",a,b);
  }

  return 0;
}



Measured memory_bytes: 1756
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int A, B;
    cin >> A >> B;

    int gap = abs(A - B);
    if (gap % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
// const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;
 
    int sz;
    vector<Monoid> seg;
 
    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;
 
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }
 
    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }
 
    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }
 
    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }
 
    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }
 
    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};
 
 
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int INF = 1;
  rep(i,31){
    INF *= 2;
  }
  --INF;
  int n, q;
  cin >> n >> q;
  SegmentTree<int> seg(n, [](int a, int b){return min(a, b);}, INF);
  int query, a, b;
  rep(i,q){
    cin >> query >> a >> b;
    if(query == 0){
      seg.update(a, b);
    }
    else{
      cout << seg.query(a, b+1) << endl;
    }
  }

  
}


Measured memory_bytes: 4884
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return (a/lcm(a,b)*b); }

int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];

  ll L[N+1]={}, R[N+1]={};
  rep(i,N) L[i+1] = gcd(L[i],A[i]);
  rep(i,N) R[(N-1)-i] = gcd(R[N-i],A[(N-1)-i]);

  ll result = 0;
  rep(i,N) result = max(result, gcd(L[i],R[i+1]));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long long f(long long x){
    if (x == 1) return 1;
    
    long long a = f(x / 2);
    return 2 * a + 1;
}

int main(void){
    long long n;
    cin >> n;
    
    cout << f(n) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int r = scan.nextInt()*100;
        int g = scan.nextInt()*10;
        int b = scan.nextInt();
        
        int n = r+g+b;
        
        if((n & 3) > 0) System.out.println("NO");
        else System.out.println("YES");

        
    }
}



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

long long int dp[105][100005];

int main() {
	int n,w;
	cin>>n>>w;
	int ar[n][2];
	for(int i=0;i<n;i++)
		cin>>ar[i][0]>>ar[i][1];
	
	for(int i=0;i<105;i++)
		for(int j=0;j<100005;j++)
			dp[i][j]=1e9+7;
	
	dp[0][ar[0][1]]=(ar[0][0]<=w)*ar[0][0];
	dp[0][0]=0;
	for(int i=0;i<n-1;i++)
		for(int j=0;j<100005-ar[i+1][1];j++){
			if(w>=ar[i+1][0]+dp[i][j]) dp[i+1][j+ar[i+1][1]]=min(dp[i+1][j+ar[i+1][1]],dp[i][j]+ar[i+1][0]);
			dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
		}
		
	/*for(int i=0;i<n;cout<<'\n',i++)
		for(int j=0;j<18;j++)
			cout<<dp[i][j]<<' ';*/
	
	long long minn=1e9;	
	for(int i=100004;i>-1;i--)
		if(dp[n-1][i]!=1e9+7){
			cout<<i<<'\n';
			return 0;
		}
		
}

Measured memory_bytes: 82304
// qdd on Jan 19, 2019

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    long long t, sum = 0, mx = 0;
    for (int i = 0; i < n; i++) {
        cin >> t;
        sum += t;
        mx = max(mx, t);
    }
    sum -= mx / 2;
    cout << sum << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,m=map(int,input().split())
    A=[int(_) for _ in input().split()]
    B=[int(_) for _ in input().split()]
    ans=min(A)+min(B)
    for i in range(m):
        x,y,c=map(int,input().split())
        ans=min(ans,A[x-1]+B[y-1]-c)
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 18488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

constexpr int dy[] = { -1,0,0,1 }, dx[] = { 0,-1,1,0 };
int main() {
    init();

    int h, w, k; cin >> h >> w >> k;
    VS s(h); cin >> s;

    int sy, sx;
    FOR(y, 0, h)FOR(x, 0, w) {
        if (s[y][x] == 'S') {
            tie(sy, sx) = tie(y, x);
            goto gotstart;
        }
    }
gotstart:

    auto dis = defvec<int>(INF, h, w);
    dis[sy][sx] = 0;
    queue<pair<int, int>> bfs;
    bfs.emplace(sy, sx);
    while (!bfs.empty()) {
        int y, x;
        tie(y, x) = bfs.front();
        bfs.pop();
        FOR(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx))continue;
            if (s[ny][nx] == '#')continue;
            if (!chmin(dis[ny][nx], dis[y][x] + 1))continue;
            bfs.emplace(ny, nx);
        }
    }

    int ans = INF;
    FOR(y, 0, h)FOR(x, 0, w) {
        if (dis[y][x] <= k) {
            int m = min({ y,x,h - y - 1,w - x - 1 });
            chmin(ans, (m + k - 1) / k + 1);
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long h[] = new long[n];
		for(int i=0; i<n; i++) {
			h[i]=sc.nextLong();
		}

		int l = -1;//できない
		int r = (int)1e9+1;//できる
		while(l+1<r) {
			int m = (l+r)/2;
			int cnt=0;
			for(int i=0; i<n; i++) {
				if(h[i]>b*m) {
					cnt += Math.ceil((double)(h[i]-(b*m))/(double)(a-b));
				}
			}
			if(cnt<=m) {
				r=m;
			}else {
				l=m;
			}
		}
		int ans = l+1;
		System.out.println(ans);
		sc.close();
	}


}




Measured memory_bytes: 49760
#include <iostream>
#include <math.h> 
#include <vector> 

using namespace std;

bool CheckPrmNum(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
   int N,i,num;
   vector<int> v;
   cin >> N;
    for(i=0;i<N;i++)
    {
        cin >> num;
        v.push_back(num);
    }
    
    i = 0;
    for(vector<int>::iterator iter=v.begin() ; iter != v.end() ; iter++)
    {
        if(CheckPrmNum(*iter))
            i++;
    }
    
    cout<<i<<endl;
        
   
}



Measured memory_bytes: 3156
input_list=[input() for i in range(5)]
dishes = [int(n) for n in input_list]
s = 0
for n in dishes:
    if n%10 == 0:
        s += n

dishes = [n for n in dishes if n%10 != 0]
if dishes:
    minmod = min([n%10 for n in dishes])

    for n in dishes:
        s += n + 10 - n%10

    s -= 10
    s += minmod
print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n;
  cin >> n;

  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    auto itr = mp.find(s);
    if (itr != mp.end()) {
      mp[s]++;
    } else {
      mp[s] = 1;
    }
  }

  int a = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second > a) {
      a = itr->second;
    }
  }

  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second == a) {
      cout << itr->first << endl;
    }
  }

}

Measured memory_bytes: 25216
using System;

namespace ConsoleApp1
{
    class ALDS1_9_A
    {
        //Complete Binary Tree
        public static void Main() 
        {
            int n = int.Parse(Console.ReadLine());

            int[] tree = Array.ConvertAll(("0 "+  Console.ReadLine()).Split(' '), int.Parse);
            string answ = PrintNode(1, 1, tree);

            for (int i = 1; i <= n; i++) {
                answ +=
                    PrintNode(i, i * 2, tree) +
                    PrintNode(i, i * 2+1, tree);
            }
            Console.Write(answ);
        }

        private static string PrintNode(int Parent, int node, int[] tree) 
        {
            if (tree.Length <= node) return "";
            string answ = "node " + node + ": key = " + tree[node] + ", ";
            if (node > 1) answ += "parent key = " + tree[Parent] + ", ";
            if (tree.Length > node * 2)
            { 
                answ += "left key = " + tree[node * 2] + ", ";
                if (tree.Length > node * 2 + 1) answ += "right key = " + tree[node * 2 + 1] + ", ";
            }
            return answ + "\n";
        }
    }
}



Measured memory_bytes: 18792
#include <unordered_map>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

unordered_map<int,int> mp;
int tt[100010];

int main()
{
	int n;
	cin>>n;
	mp.clear();
	memset(tt,0,sizeof(tt));
	for(int i=1;i<=n;i++)
	{
		cin>>tt[i];
		mp[tt[i]]=i;
	}
	sort(tt+1,tt+n+1);
	for(int i=1;i<=n;i++)
	{
		cout<<mp[tt[i]]<<" ";
	}
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 5284
#include <bits/stdc++.h>
#define L long long

using namespace std;

L n;
L a[222];

L operation(L x){
	L i;
	for(i=x+1;i<=n;i++)
	{
		swap(a[i],a[i-x]);
	}
}

L fin(L x){
	L i;
	for(i=1;i<=n;i++)
	{
		if(a[i]==x) return i;
	}
}

int main()
{
	scanf("%lld",&n);
	L i;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]++;
	}
	vector<L>ans;
	for(i=n;i>1;i--)
	{
		while(fin(i-1)!=1)
		{
			ans.push_back(1);
			operation(1);
		}
		while(fin(i)!=2)
		{
			ans.push_back(1);
			operation(1);
			ans.push_back(n-1);
			operation(n-1);
		}
	}
	printf("%lld\n",ans.size());
	for(i=0;i<ans.size();i++)
	{
		printf("%lld\n",ans[i]);
	}
	/*for(i=1;i<=n;i++)
	{
		printf("%lld ",a[i]);
	}*/
}

Measured memory_bytes: 1016
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        a: [usize;n],
    }

    let mut dic = HashSet::new();

    for e in a {
        if dic.contains(&e) {
            dic.remove(&e);
        } else {
            dic.insert(e);
        }
    }

    println!("{}", dic.iter().count());
}


Measured memory_bytes: 8444
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

void no() { cout << -1; exit(0); }

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vvl a(n);
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < n - 1; ++j) {
            ll u;
            cin >> u;
            --u;
            a[i].pb(u);
        }
    }

    for (ll i = 0; i < n; ++i) {
        reverse(a[i].begin(), a[i].end());
    }

    ll ans = 0;
    ll cnt = n * (n - 1) / 2;

    vb used(n);
    vl keks;
    for (ll i = 0; i < n; ++i) keks.pb(i);
    for (ll j = 0; j < n * (n - 1) / 2; ++j) {
        ++ans;
        used.assign(n, false);
        bool ok = false;
        vl lols;
        for (ll i : keks) {
            if (used[i] || a[i].empty()) continue;
            ll u = a[i].back();
            if (used[u]) continue;
            ll v = a[u].back();
            if (v != i) continue;
            cnt -= 1;
            ok = true;
            a[v].pop_back();
            a[u].pop_back();
            lols.pb(v), lols.pb(u);
            used[v] = used[u] = true;
        }
        swap(keks, lols);
        if (!ok) no();
        if (cnt == 0) break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8320
#include <cstdio>
#include <algorithm>
using namespace std;

double t;
double maxm, minm=10e9;

int main() {
  while (1) {
    if (scanf("%lf", &t) != 1) break;
    maxm = max(maxm, t);
    minm = min(minm, t);
  }
  printf("%f\n", maxm - minm);
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n*3];
        for (int i = 0; i < n * 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[n+i*2];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 92140
#include<bits/stdc++.h>
using namespace std;
int n,w[103],s[103],ans=1e9;
int main(){
    int i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        s[i]=s[i-1]+w[i];
    }
    for(i=1;i<=n;i++){
        ans=min(ans,abs(s[n]-s[i]-s[i]));
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


n = int(input())
X = [int(x) for x in input().split()]
X_sorted = sorted(X)

med_l = X_sorted[n // 2 - 1]
med_u = X_sorted[n // 2]
med = (med_l + med_u) / 2

for x in X:
    if x < med:
        print(med_u)
    else:
        print(med_l)


Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
int a,b,n,x,y;
int memo[19][19]={0},check[19][19]={0};
int saiki(int x,int y){
  if(check[x][y]==1)return(memo[x][y]);
  else{
      memo[x][y]=saiki(x,y-1)+saiki(x-1,y);
      check[x][y]=1;
      return memo[x][y];
  }
}
int main(){
  while(1){
    cin>>a>>b;
    if(a==0 && b==0)break;
    cin>>n;
    for(int i=0;i<=a;i++){
      for(int j=0;j<=b;j++){
	memo[i][j]=0;
	check[i][j]=0;
      }
    }
    for(int i=0;i<=a;i++){
      check[i][0]=1;
    }
    for(int i=0;i<=b;i++){
      check[0][i]=1;
    }
    memo[0][1]=1;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      check[x][y]=1;
    }
    memo[0][1]=1;
    saiki(a,b);
    cout<<memo[a][b]<<endl;
  }
}

Measured memory_bytes: 1164
#include<iostream>
int search(int s[],int& n,int& t){
	int i=0;
	s[n]=t;
	while(s[i]!=t)
		i++;
		return i!=n;
}
	
int main()
{
	int n,q,t;
	int c=0,sum=0;
	std::cin>>n;
	int s[n];
	for(int i=0;i<n;i++){
		std::cin>>s[i];
	}
	std::cin>>q;
	for(int i=0;i<q;i++){
		std::cin>>t;
		if(search(s,n,t))
		sum++;
	}
	std::cout<<sum<<"\n";
	return 0;
	}



Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	long long int sum=0;
	sum+=a[n-1];
	rep(i,n-2){
		sum+=a[n-2-(i/2)];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = 100000000;

class Edge{
public:
  int u, v, cost;
  Edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
  bool operator < (const Edge& s) const {
    return cost < s.cost;
  }
};

vector<Edge> es;
int V, E;
int par[101];
int rank[101];

void init(int n){
  for(int i=0;i<=n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int kruskal(){
  init(V);
  int tmp = (int)es.size()-1;
  int cnt = 0;
  for(int i=0;i<es.size();i++){
    Edge e = es[i];
    if(!same(e.u, e.v)){
      unite(e.u, e.v);
      tmp = i;
      cnt++;
    }
  }
  return (cnt != V-1 ? INF : es[tmp].cost - es[0].cost);
}

main(){
  while(cin >> V >> E && (V|E)){
    es.clear();
    for(int i=0;i<E;i++){
      int a, b, c;
      cin >> a >> b >> c;
      es.push_back(Edge(a, b, c));
    }
    int ans = INF;
    sort(es.begin(), es.end());
    while(es.size() >= V-1){
      int tmp = kruskal();
      ans = min(ans, tmp);
      es.erase(es.begin());
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 1068