akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

ll calc(ll num, ll k){
  if(num%k==0) return num/k;
  ll t = num%k;
  ll s = num/k+1;
  if(t<=s) return calc(num-(num/k+1), k);
  ll x = (t/s)*s;
  return calc(num - x, k);
}
int main(int argc, char const *argv[]) {
  ll a, b, n;std::cin >> n;
  ll ans = 0;
  re(i, n){
    std::cin >> a >> b;
    ans ^= calc(a, b);
  }
  std::cout << (ans==0?"Aoki":"Takahashi") << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    ll ai;
    cin >> ai;
    a[i] = ai - i - 1;
  }

  sort(all(a));
  ll c = a[n/2];

  ll ans = 0;
  rep(i, n) {
    ans += abs(a[i] - c);
  }
  cout << ans << endl;

  return 0;
}

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

const string EMPTY = "";

const string X[] = { EMPTY, "One ", "Two ", "Three ", "Four "};
				
string convert2digit(int n, string change)
{
	if (n == 0) {
		return EMPTY;
	}
	if (n > 5) {
		return  X[n % 10] + change;
	}
	else {
		return X[n] + change;
	}
}

string numberToWords(unsigned long int n)
{
	string res;
	res = convert2digit((n % 10), "");

	if (n > 10 && n % 10) {
		res = "and " + res;
	}
	res = convert2digit(((n / 10)), "Hundred ") + res;
		return res;
}
int main()
{
	int N,count=0,W=0,Y=0,P=0,G=0;
	cin>>N;
	char n[N];
	for(int i=0;i<N;i++)
	{
		cin>>n[i];
	}
	for(int i=0;i<N;i++)
	{
		if(n[i]=='G')
		{
			G++;
			if(G>1)
			{
				G=1;
			}
			else
			{
				count++;
			}
		}
		if(n[i]=='W')
		{
			W++;
			if(W>1)
			{
				W=1;
			}
		    else
			{
				count++;
			}
		}
		if(n[i]=='P')
		{
			P++;
				if(P>1)
			{
				P=1;
			}
			else
			{
				count++;
			}
		}
		if(n[i]=='Y')
		{
			Y++;
				if(Y>1)
			{
				Y=1;
			}
			else
			{
				count++;
			}
		}
	}
	cout << numberToWords(count) << '\n';
	
	
}

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

int main(void){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i{0}; i<N; ++i)
        cin >> H[i];

    int result{1};

    for(int i{1}; i<N; ++i){
        bool flag = true;
        for(int j{0}; j<i; ++j){
            if(H[i]<H[j]){
                flag = false;
                break;
            }
        }
        if(flag)
            ++result;
    }

    cout << result << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  ll a,b;
  tuple<ll, ll, ll> d[n];
  rep(i,n){
    cin >> a >> b;
    d[i]= mt(a+b,a,b);
  }
  sort(d, d+n);
  ll ans=0;
  ll pm=1;
  for(int i=n-1; i>=0; i--){
    if(i%2==(n-1)%2){
      ans+=get<1>(d[i]);
    }
    else{
      ans-=get<2>(d[i]);
    }
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 2560
#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 <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll n = gcd(C, D);
    ll lcm = C / n * D;
    ll kosu = lcm - lcm / C - lcm / D + 1;
    ll a = (A - 1) / lcm * kosu + ((A - 1) % lcm -((A - 1) % lcm) / C - ((A - 1) % lcm) / D);
    ll b = (B) / lcm * kosu + ((B%lcm) - ((B) % lcm) / C - ((B) % lcm) / D);//54
    cout << b - a << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int K;
  cin >> K;
  int d[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << d[K] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, x;
	int i, j, k;
	int a = 0;

	while(1)
	{
		scanf("%d%d", &n, &x);
		if (n + x == 0)
		{
			return 0;
		}
		for (i = 1; i <= n - 2; i++)
		{
			for (j = i + 1; j <= n - 1; j++) 
			{
				for (k = j + 1; k <= n; k++) 
				{
					if (i + j + k == x) a++;
				}
			}
		}

		printf("%d\n", a);

		a = 0;
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sorti(vi &a) {sort(a.begin(), a.end());}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll m = s.size();
  if (m < k) {
    cout << 0 << endl;
    return 0;
  }
  string ss;
  for (ll i = 0; i < m; i++) ss.push_back('0');
  if (k == 1) {
    ll ans = s[0] - '0';
    ans += 9 * (m - 1);
    cout << ans << endl;
  }
  else if (k == 2) {
    ll ans = (m - 1) * (m - 2) / 2 * 81;
    for (ll a = 1; a <= s[0] - '0'; a++) {
      for (ll b = 1; b < 10; b++) {
        for (ll x = 1; x < m; x++) {
          string sss = ss;
          sss[0] = a + '0';
          sss[x] = b + '0';
          if (sss <= s) ans++;
        }
      }
    }
    cout << ans << endl;
  }
  else {
    ll ans = 243 * (m - 3) * (m - 2) / 2 * (m - 1);
    for (ll a = 1; a <= s[0] - '0'; a++) {
      for (ll b = 1; b < 10; b++) {
        for (ll c = 1; c < 10; c++) {
          for (ll y = 1; y < m - 1; y++) {
            for (ll z = y + 1; z < m; z++) {
              string sss = ss;
              sss[0] = a + '0';
              sss[y] = b + '0';
              sss[z] = c + '0';
              if (sss <= s) ans++;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back
#define FILE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1000001;
const int mod = 1000000007;

ll fac[MAXN];
ll inv[MAXN];

ll modPower(ll x,ll y){
    x%=mod;
    ll res = 1;
    while(y){
        if(y&1)res= (res*x)%mod;
        x = (x*x)%mod;
        y>>=1;
    }
    return res;
}

void pre(){
    fac[0] = 1;
    for(ll i = 1; i < MAXN; i++)fac[i] = (i * fac[i-1])%mod;
    inv[MAXN-1] = modPower(fac[MAXN-1] , mod-2);
    for(ll i = MAXN-2; i >= 0; i--)inv[i] = (inv[i+1] * (i+1))%mod;
}

ll nCr(ll n, ll r){
    if(r > n)return 0;
    return fac[n] * (inv[r] * inv[n-r] % mod) % mod;
}


int main(){
    pre();

    int n, k;
    cin>>n>>k;

    int a[n];
    fr(i,n)cin>>a[i];

    if(k == 1){
        cout<< 0 << endl;
        return 0;
    }

    sort(a, a+n);

    ll ans = 0;

    fr(i,n){
        int sm = i;
        int gr = n-1-i;
        ans = (ans + nCr(sm, k-1)*a[i]%mod )%mod;
        ans = (ans + mod - nCr(gr, k-1)*a[i]%mod )%mod;
        //debug(ans);
    }

    cout<< ans << endl;

}


Measured memory_bytes: 16256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
 
using namespace std;
 
bool f(int x) {
	return x == 4 || x == 6 || x == 9 || x == 11;		
}
 
bool f2(int x) {
	return x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12;
}
int main() {
 
	int x, y;
 
	cin >> x >> y;
 
	if ((f(x) && f(y)) || (f2(x) && f2(y)) || (x == 2 && y == 2)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

t = H*60 + M

deg1 = t * 0.5 * math.pi / 180
deg2 = t * 6 * math.pi / 180

ans2 = A**2 + B**2 - 2*A*B*math.cos(deg1-deg2)
print(ans2**0.5)

Measured memory_bytes: 9496
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    set<int> st;
    rep(i,n){
        int x;
        cin >> x;
        st.insert(x);
    }
    if(st.size()==n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

void sieve(int n,vector<int>&pr){
	vector<bool>v(n+1,true);
	for(int i=2;i*i<=n;++i){
		if(!v.at(i))continue;
		for(int j=i*i;j<=n;j+=i){
			v.at(j)=false;
		}
	}
	for(int i=2;i<=n;++i)if(v.at(i))pr.emplace_back(i);
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>pr;
	sieve(n,pr);
	unordered_map<int,int>pc;
	for(int i=2;i<=n;++i){
		int j=i;
		for(int k=0;j&&k<pr.size();++k){
			while(j%pr.at(k)==0){
				j/=pr.at(k);
				++pc[pr.at(k)];
			}
		}
	}
	int ans=1;
	for(auto&&i:pc)ans=1L*ans*(i.second+1)%mod;
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3560
n = int(input())
A = list(map(int,input().split()))
a = [0]
for i in range(n):
  a.append(a[i]+A[i])
ans = 0
mod = 10**9+7
for i in range(1,n):
  ans += a[i]*A[i]%mod
print(ans%mod)

Measured memory_bytes: 31624
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> cnt(200'000 + 1, 0);
    repeat(i, n) {
        int t;
        cin >> t;
        ++cnt[t];
    }
    sort(cnt.begin(), cnt.end(), greater<int>());
    repeat(i, k) {
        cnt[i] = 0;
    }
    cout << accumulate(cnt.begin(), cnt.end(), 0) << endl;
}

Measured memory_bytes: 1024
def main():
    s = input()
    d = ""
    
    for i in s:
        if i == "0":
            d += "0"
        elif i == "1":
            d += "1"
        else:
            d = d[:-1]
            
    print(d)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define lli long long int  

using namespace std;

int main() {
    lli n;
    cin>>n;
    lli a,b;
    cin>>a>>b;
    lli temp=1;
    for(lli i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            
            temp=0;
            break;
        }
    }
    if(temp)cout<<"NG";
    else cout<<"OK";
}

Measured memory_bytes: 3620
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key = lambda x:x[1])
lis.sort(key = lambda x:x[0])
ans = 10 ** 8
for i in range(n):
    for j in range(i,n):
        p = lis[j][0]-lis[i][0]
        q = lis[j][1]-lis[i][1]
        li = lis.copy()
        cnt = 0
        while li:
            a = li.pop(0)
            while [a[0]+p,a[1]+q] in li:
                a = li.pop(li.index([a[0]+p,a[1]+q]))
            cnt += 1
        ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int MAXN = 2004;
char grid[MAXN][MAXN];
int _left[MAXN][MAXN], _right[MAXN][MAXN], _up[MAXN][MAXN], _down[MAXN][MAXN];

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

	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) scanf("%s", grid[i]);

	for (int i = 0; i < h; i++) {
		_left[i][0] = (grid[i][0] == '#')? 0 : -1;
		for (int j = 1; j < w; j++)
			_left[i][j] = (grid[i][j] == '#')? j : _left[i][j-1];
		_right[i][w-1] = (grid[i][w-1] == '#')? w-1 : w;
		for (int j = w-2; j >= 0; j--)
			_right[i][j] = (grid[i][j] == '#')? j : _right[i][j+1];
	}

	for (int j = 0; j < w; j++) {
		_up[0][j] = (grid[0][j] == '#')? 0 : -1;
		for (int i = 1; i < h; i++)
			_up[i][j] = (grid[i][j] == '#')? i : _up[i-1][j];
		_down[h-1][j] = (grid[h-1][j] == '#')? h-1 : h;
		for (int i = h-2; i >= 0; i--)
			_down[i][j] = (grid[i][j] == '#')? i : _down[i+1][j];
	}

	int ans = 0;
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
		if (grid[i][j] == '#') continue;
		int tmp = (_right[i][j] - _left[i][j] - 1) + (_down[i][j] - _up[i][j] - 1) - 1;
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100009, MOD = 1000000007;

struct mint {
    int val;
 
    mint(int v = 0) {
        val = v % MOD;
        if(val < 0) val += MOD;
    }
 
    static int mod_inv(int a, int m = MOD) {
        int g = m, r = a, x = 0, y = 1;
 
        while (r != 0) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }
 
        return x < 0 ? x + m : x;
    }
 
    explicit operator int() const {
        return val;
    }
 
    mint& operator+=(const mint &other) {
        val += other.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
 
    mint& operator-=(const mint &other) {
        val -= other.val;
        if (val < 0) val += MOD;
        return *this;
    }
 
    mint& operator*=(const mint &other) {
        val = ((uint64_t) val*other.val)%MOD;
        return *this;
    }
 
    mint& operator/=(const mint &other) {
        return *this *= other.inv();
    }
 
    friend mint operator+(const mint &a, const mint &b) { return mint(a) += b; }
    friend mint operator-(const mint &a, const mint &b) { return mint(a) -= b; }
    friend mint operator*(const mint &a, const mint &b) { return mint(a) *= b; }
    friend mint operator/(const mint &a, const mint &b) { return mint(a) /= b; }
 
    mint& operator++() {
        val = val == MOD - 1 ? 0 : val + 1;
        return *this;
    }
 
    mint& operator--() {
        val = val == 0 ? MOD - 1 : val - 1;
        return *this;
    }
 
    mint operator++(int32_t) { mint before = *this; ++*this; return before; }
    mint operator--(int32_t) { mint before = *this; --*this; return before; }
 
    mint operator-() const {
        return val == 0 ? 0 : MOD - val;
    }
 
    bool operator==(const mint &other) const { return val == other.val; }
    bool operator!=(const mint &other) const { return val != other.val; }
 
    mint inv() const {
        return mod_inv(val);
    }
 
    mint pow(int p) const {
        mint a = *this, result = 1;
 
        while (p > 0) {
            if (p & 1)
                result *= a;
 
            a *= a;
            p >>= 1;
        }
 
        return result;
    }
 
    friend ostream& operator<<(ostream &stream, const mint &m) {
        return stream << m.val;
    }
};

int n, k;
mint ans;
int mt[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;
    
    for(int i = 1; i <= k; ++i) {
        int cur = k/i;
        
        int mult = i;
        if(i > 1) {
            mult--;
        }
        for(int j = 2; j*j <= i; ++j) {
            if(i%j == 0) {
                mult -= mt[j];
                if(i/j != j) {
                    mult -= mt[i/j];
                }
            }
        }
        mt[i] = mult;

        mint cand(cur);
        mint combs = cand.pow(n);
        ans += combs*mult;
    }

    cout << ans << '\n';
    
    return 0;
}


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

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<String> s = new ArrayList<>();
		String[][] sp = new String[N][2];
		sc.nextLine();

		for(int i=0;i<N;i++) {
			String[] line = sc.nextLine().split(" ");
			sp[i][0] = line[0];
			sp[i][1] = String.format("%03d", Integer.parseInt(line[1]));
			s.add(sp[i][0] + "_" + sp[i][1]);
		}
		Arrays.sort(sp,(a,b)-> (a[0].equals(b[0])) ?  b[1].compareTo(a[1]) : a[0].compareTo(b[0]));
		for(int i=0;i<N;i++) {
			System.out.println(s.indexOf(sp[i][0] + "_" + sp[i][1]) + 1);
		}
	}
}


Measured memory_bytes: 26960
import java.util.LinkedList;
import java.util.Scanner;

class Main {
	int a,b,c,d,e,f;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		e = sc.nextInt();
		f = sc.nextInt();
	}

	void solve() {
		double max = 0;
		int water = 100 * a;
		int sugar = 0;
		for(int i=1;100*a*i<=f;i++){
			for(int j=0;100*b*j+100*a*i<=f;j++){
				for(int k=0;k*c<=(b*j+a*i)*e&&100*b*j+100*a*i+k*c<=f;k++){
					int l = Math.min((f-(100*b*j+100*a*i+k*c))/d, ((b*j+a*i)*e-k*c)/d);
					double n = 100.0*(k*c+l*d) / (k*c+l*d+100*b*j+100*a*i);
					//System.out.printf("水:%d 砂糖：%d 濃度:%f\n",100*b*j+100*a*i,k*c+l*d,n);
					if(n > max){
						max = n;
						water = 100*b*j+100*a*i;
						sugar = k*c+l*d;
					}
				}
			}
		}
		System.out.println((sugar+water)+" "+sugar);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int n;
    while(cin>>n,n){
        vi v(n+1,0); rep(i,n)cin>>v[i+1];
        sort(all(v)); ll hoge=0;
        for(int i=1;i<=n-1;i++){v[i]=v[i]+v[i-1];hoge+=v[i];}
        cout<<hoge<<endl;
    }
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int k, t;
    cin >> k >> t;
    int a[t];
    int sum = 0;
    for( int i = 0; i < t; ++i ) {
        cin >> a[i];
        sum += a[i];
    }
    if( t == 1 ) cout << a[0] - 1;
    else {
        sort( a, a + t );
        sum -= a[t - 1];
        if( sum >= a[t - 1] ) cout << 0;
        else cout << a[t - 1] - sum - 1;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
from itertools import islice


def resolve(in_):
    H, N = map(int, next(in_).split())
    AB = tuple(tuple(map(int, line.split())) for line in islice(in_, N))
    
    dp = [1 << 31] * (H + 1)
    dp[0] = 0

    for i in range(H):
        for a, b in AB:
            ia = min(H, i + a)
            dp[ia] = min(dp[ia], dp[i] + b)

    return dp[H]


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84776
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()


signed main(){
  int n,m;
  cin>>n>>m;
  V<string> a(n);
  fo(i,n){
    cin>>a[i];
  }
  V<string> b(m);
  fo(i,m){
    cin>>b[i];
  }

  bool can=0;

  for(int x=0; x<n-m+1; x++){
    for(int y=0; y<n-m+1; y++){
      bool c=1;
      fo(i,m){
        fo(j,m){
          if(a[x+i][y+j]!=b[i][j])
            c=0;
        }
      }
      if(c)
        can=1;
    }
  }

  if(can)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    string S, T; cin >> S >> T;
    ll ans = 0;
    rep(i, S.size()){
        if(S[i] != T[i]) ans++;
    }    
    pt(ans);
    return 0;
}

Measured memory_bytes: 3880
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n, m;
	cin >> n >> m;
	if (n >= m) {
		cout << m / 2 << endl;
	}
	else {
		ll ans = 0;
		ans += min(n, m / 2);
		if (ans == n) {
			m -= n * 2;
			ans += m / 4;
		}
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    rep(i,N){
        cin>>a[i];
    }
    int min_distance = 20021003;
    int max_distance = 0;
    rep(i,N){
        min_distance = min(min_distance, a[i]);
        max_distance = max(max_distance, a[i]);
    }
    int ans=max_distance - min_distance;
    cout<<ans<<endl; 
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
a = int(input())
print(a+a*a+a*a*a)

Measured memory_bytes: 10592
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
#define int long long
#define double long double
#define fst first
#define snd second
#define fr(s,n,i) for(int i=s;i<n;i++)
#define times(n) for(int i=0;i<n;i++)
#define fr_(s,n,i) for(int i=s;i>=n;i--)
#define srt(v) sort(v.begin(), v.end());
#define upr(v, aim, ind) int ind; ind=(int)distance(v.begin(), upper_bound(v.begin(),v.end(), aim))
#define sz(v) (int)v.size()
#define ers(v, i) v.erase(v.begin() + i)
#define last(v) v[sz(v) - 1]
#define swp(v, i, j) int buf = v[j]; v[j] = v[i]; v[i] = buf
#define shout(a) cout << a << endl
#define dshout(a) printf("%.16Lf\n", a)
#define pr pair<int, int>
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vd vector<double>
#define vdd vector<vd>
#define mx(a, b) a = max(a, b)
#define mn(a, b) a = min(a, b)
#define mulM(a,b,c) a = a * b % c
#define squM(a,b) a = a * a % b
#define mpr(a,b) make_pair(a,b)
#define iinp(a) int a; cin >> a
#define sinp(a) string a; cin >> a
#define dinp(a) double a; cin >> a
#define ios() ios_base::sync_with_stdio(0);cin.tie(0)

int MOD = 998244353;
int INF = ~(1LL << 63);

int powM(int base, int exp){
    int ret = 1;
    int buf = base;
    while(exp > 0){
        if(exp & 1){
            ret *= buf;
        }
        squM(buf, MOD);
        exp >>= 1;
    }
    return ret;
}
int combM(int a, int b){
    if(b == 0){
        return 1;
    }
    if(a-b < b){
        return combM(a, a-b);
    }
    int ans = 1;
    fr(1,b+1,i){
        ans *= a + 1 - i;
        ans /= i;
    }
    return ans;
}
void solve();
signed main() {
    ios();
    solve();
    return 0;
}

void solve(){
    int in;
    string a;
    cin >> in >> a;
    int allwht = 0;
    map <int,int> wht;
    map <int,int> blk;
    fr(0,a.length(),i){
        if(a[i] == '.'){
            allwht++;
        }
        wht[i] = allwht;
    }
    int ans = min(allwht, (int)a.length() - allwht);
    fr(0,a.length(),i){
        int leftb = (i+1 - wht[i]);
        int rightw =(allwht - wht[i]);
        int buf = leftb + rightw;
        // cout << leftb << "," << rightw << "," <<buf << endl;
        ans = min(ans, buf);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14996
n = int(input())
for _ in range(n):
    l = list(map(int,input().split()))
    idx = l.index(max(l))
    c = l[idx]
    a, b  = [x for i,x in enumerate(l) if i != idx] 
    if a**2 + b**2 == c**2:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll inf = 1000000001;

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

    int n; cin>>n;
    vector<int>a;
    rep(i,n){
        int b; cin>>b;
        a.push_back(b);
    }
    
    int ma = 0, ma2 = 0;
    rep(i,n){
        if(a[i] > ma){
            ma2 = ma;
            ma = a[i];
        }
        else if(a[i] > ma2){
            ma2 = a[i];
        }
    }
    rep(i,n){
        if(a[i] != ma){
            cout << ma << ln;
        }
        else{
            cout << ma2 << ln;
        }
    }
    return 0;
}

Measured memory_bytes: 2548
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    int n = gi();
    int k = gi();

    int r = (n-1)*(n-2)/2 - k;
    if (r < 0) {
        printf("-1\n");
        return 0;
    }

    printf("%d\n", n-1 + r);
    for (int i = 1; i < n; i++)
        printf("%d %d\n", i, n);

    for (int i = 1; i < n && r; i++)
        for (int j = i+1; j < n && r; j++) {
            printf("%d %d\n", i, j);
            r--;
        }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = (double)h * w / (double)2;
    ll s1 = min(x * h, (w - x) * h);
    ll s2 = min(y * w, (h - y) * w);

    if ((double)(-h * x / (double)w) + h == (double)y && (double) (h * x / (double) w) == (double)y) {
        cout << s << ' ' << 1 << endl;
    }else{
        cout << s << ' ' << 0 << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100050];
int ans;
int main(){
	scanf("%s",s);
	int n=strlen(s);
	ans=n;
	for (int i=1;i<n;++i)
		if (s[i]!=s[i-1]) {
			ans=min(ans,max(i,n-i));
		}
	
	printf("%d\n",ans);
} 

Measured memory_bytes: 3872
n,_,*a=`dd`.split.map &:to_i
dp=[0]+[-Float::INFINITY]*(n+10)
u=[nil,2,5,5,4,5,6,3,7,6]
0.upto(n){|i|
  a.map{|x|
    dp[i+u[x]]=[dp[i]*10+x,dp[i+u[x]]].max
  }
}
p dp[n]

Measured memory_bytes: 29316
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a


def lcm(a, b):
  return a * b // gcd(a, b)


A, B, C, D = map(int, input().strip().split())

CD = lcm(C, D)
count = B - A
count -= (B // C) - ((A - 1) // C + 1)
count -= (B // D) - ((A - 1) // D + 1)
count += (B // CD) - ((A - 1) // CD + 1)

print(count)


Measured memory_bytes: 3064
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [h,w] <- map (read::String->Int) . words <$> getLine
  s <- lines <$> getContents
  let frame1 = (replicate w '#') : s ++ [replicate w '#']
  putStrLn $ unlines $map ((++"#").('#':)) frame1

Measured memory_bytes: 4880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		//キーボード入力
		int n=Integer.parseInt(br.readLine());

		//配列宣言
		int[] ary=new int[n];

		int count=0;

		StringTokenizer st=new StringTokenizer(br.readLine());
		while(n>count){
			int a=Integer.parseInt(st.nextToken());
			ary[count]=a;
			count++;
		}
		while(count>0){
			count--;
			if(count==0){
				System.out.println(ary[count]);
			}else{
				System.out.print(ary[count]);
			}
			if(count>0){
				System.out.print(" ");
			}
		}
	}

}



Measured memory_bytes: 24408
#include <iostream>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){
  int n,a,b;

  cin >> n >> a >> b;

  int rest = n-a;
  int num = rest / b;
  int ans = rest - (num*b);
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

bool is_prime[1000010];
int cnt[1000010];
int main() {
    int N; scanf("%d", &N);
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        scanf("%d", &A[i]);
        cnt[ A[i] ]++;
    }

    fill(is_prime, is_prime + 1000005, true);
    for(int i=2; i<=1000000; i++) {
        if(!is_prime[i]) continue;
        for(int k=1; i*k<=1000000; k++) {
            is_prime[i*k] = false;
            cnt[i*k] += cnt[k];
        }
    }

    int ans = 0;
    for(int i=0; i<N; i++) {
        if(cnt[ A[i] ] == 1) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }

    int res = INF;
    for (int i = 0; i < (1 << n); ++i) {
        vector<int> sum(m, 0);
        int cost = 0;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)){
                for (int k = 0; k < m; ++k) {
                    sum[k] += a[j][k];
                }
                cost += c[j];
            }
        }

        bool flag = true;
        for (int j = 0; j < m; ++j) {
            if (sum[j] < x) flag = false;
        }

        if (flag) res = min(res, cost);
    }
    cout << (res == INF ? -1 : res) << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MEM 105
#define sanic ios_base::sync_with_stdio(0)
#define MOD 1000000
using namespace std;
string s;
int main()
{
    cin >> s;
    if(s=="AAA" || s=="BBB") cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

  /* 配列の要素を交換する */
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

  /* クイックソートを行う */
void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

int main(void){
    // Your code here!
    int A[100000], B[100000], diff[100000], N, i, count=0, negacount=0;
    long negasum = 0, posisum = 0;
    scanf("%d\n",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d\n",&A[i]);
    }
    for(int i = 0; i < N; i++)
    {
        scanf("%d\n",&B[i]);
        diff[i] = A[i]-B[i];
        if(diff[i] < 0)
        {
            negasum += -diff[i];
            negacount++;
        }
    }
    QSort(diff,0,N-1);
    //printf("%d %d\n",negasum,posisum);
    for(i = N-1; i >= 0 && posisum < negasum && diff[i] > 0; i--)
    {
        posisum += diff[i];
        count++;
    }
    printf("%d\n",(posisum >= negasum)? (negacount+(N-1-i)):-1);
}

Measured memory_bytes: 1280
package main

import(
	. "fmt"	
)
func main(){
	N:=0
	ct:=0
	var K string
	m:=make(map[string]int)
	Scan(&N)
	for i:=0;i<N;i++{
		Scan(&K)
		if m[K]==1{
			delete(m,K)
			ct--
		}else{
			m[K]=1
			ct++
		}
		
	}
	
	Println(ct)

}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  int pay = 0;
  while (pay < n) {
    pay += 1000;
  }
  out(pay - n);
}


Measured memory_bytes: 3620
# coding: utf-8

ts = []
for _ in range(5):
    ts.append(int(input()))

mini = 0

for i in range(5):
    if ts[i] % 10 < ts[mini] % 10 and ts[i] % 10 != 0:
        mini = i

result = 0
for i in range(5):
    if i != mini:
        if ts[i] % 10 == 0:
            result += ts[i]
        else:
            result += (ts[i] // 10 + 1) * 10

result += ts[mini]

print(result)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String n;
        n = in.nextLine();
        StringBuilder result =new StringBuilder();
//        System.out.println(result.length());
        for(int i = 0 ;i<n.length();i++){
            if(n.charAt(i) == '0'){
                result.append(0);
            } else if(n.charAt(i) == '1'){
                result.append(1);
            }
            else{
                if(result.length() == 0){
                    continue;
                }else{
                    result.deleteCharAt(result.length() - 1);
                }
            }
        }
        System.out.println(result);


    }
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int h, w;

int x[Sz], y[Sz];

int n;
               
set <pii> s;

set <pii> p;

ll cnt[Sz];

int calc (int x, int y) {
  if (p.count ({x, y}) || x + 1 > h || y + 1 > w || x - 1 < 1 || y - 1 < 1)
    return -1;
  p.insert ({x, y});
  int cnt = 0;
  for (int i = x-1; i <= x+1; i++)
    for (int j = y-1; j <= y+1; j++)
      cnt += s.count (mp (i, j));
  return cnt;
}

int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();    
  cin >> h >> w >> n;              
  for (int i = 1; i <= n; i++) {
    int x, y; cin >> x >> y;

    s.insert (mp (x, y));
    ::x[i] = x;
    ::y[i] = y;
  }         
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int nx = x[i]-1; nx <= x[i]+1; nx++) {
      for (int ny = y[i]-1; ny <= y[i]+1; ny++) {
        int C = calc (nx, ny);
        if (~C)
          cnt[C]++;     
      }
    }
  }    
  cnt[0] += (h - 2) * 1ll * (w - 2) - sz(p);

  for (int i = 0; i < 10; i++)
    cout << cnt[i] << endl;

  return 0;
}






// Coded by Z..



Measured memory_bytes: 51200
fun main(args : Array<String>) {
    val S = readLine()!!.toMutableList()
    val T = readLine()!!.toMutableList()
    val length = S.size
    val start = mutableMapOf<Char, Char>()
    val goal = mutableMapOf<Char, Char>()
    (0..(length-1)).forEach {index ->
        val s = S[index]
        val t = T[index]

        if (start.contains(s) && start.get(s)!! != t || goal.contains(t) && goal.get(t)!! != s) {
            println("No")
            return
        }
        start.put(s, t)
        goal.put(t, s)
    }
    println("Yes")
}

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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0; i<N-1; i++) cin >> B[i];
  
  int sum=B[0]+B[N-2];
  for(int i=0; i<=N-3; i++) sum+=min(B[i], B[i+1]);
  cout << sum <<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main(){
        int N;
        string S;
        cin >> N >> S;
        for(auto x: S) {
                printf("%c",((x + N - 65) % 26) + 65);
        }
        cout << endl;

}


Measured memory_bytes: 256