akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fr(i, a, b) for (int  i = a; i < b; ++i)
#define fr2(i, b, a) for (int i = b; i >= a; --i)
#define set0(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))
#define mod 1000000007
#define ll long long




int main()
{

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int t;
        cin>>t;
        unordered_set<string>s1;
        while(t--)
        {
                string s;
                cin>>s;
                if(s1.find(s)==s1.end())
                        s1.insert(s);
                
        }
        cout<<s1.size()<<endl;
        return 0;
}





Measured memory_bytes: 17680
#include <iostream>
#include <vector>

int main()
{
  int N, M, C;
  std::cin >> N >> M >> C;

  std::vector<int> Bs;
  for(int i=0; i<M; i++)
  {
    int B;
    std::cin >> B;
    Bs.push_back(B);
  }

  std::vector<std::vector<int>> As2;
  for(int n=0; n<N; n++)
  {
    std::vector<int> As;
    for(int m=0; m<M; m++)
    {
      int A;
      std::cin >> A;
      As.push_back(A);
    }
    As2.push_back(As);
  }

  int count=0;
  for(const auto& as : As2)
  {
    int score = C;
    for(int k=0; k<as.size(); k++)
    {
      score += as[k] * Bs[k];
    }
    if( 0 < score ) { count += 1; }
  }

  std::cout << count;
}

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

signed main(){

  int a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }
  else if(a>=6){
    cout<< b/2 <<endl;
  }
  else{
    cout<< 0 <<endl;
  }

}

Measured memory_bytes: 256
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    S = input()
    par = [0]
    cc = 0
    for i in S:
        if i == '(': cc += 1
        else: cc -= 1
        par.append(cc)

    mp = min(par)
    output = S
    if mp < 0: output = '(' * abs(mp) + output
    if abs(mp) + cc > 0: output = output + ')' * (abs(mp)+cc)
    print(output)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

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

      int q = Integer.parseInt(br.readLine());
      String[] s = new String[q+q];
      Arrays.fill(s, "");
      List<String> list  = Arrays.asList(s);
      int head = q;
      int tail = q;

      String[] query;
      int op;
      int accessWay;
      int index;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            accessWay = Integer.parseInt(query[1]);
            if ( accessWay == 0 )
              list.set(head--,query[2]);
            else
              list.set(++tail,query[2]);
            break;
          case 1 :
            index = head + 1 + Integer.parseInt(query[1]);
            System.out.println( list.get(index) );
            break;
          case 2 :
            accessWay = Integer.parseInt(query[1]);
            if ( accessWay == 0 )
              head++; // list.set(head++,"");
            else
              tail--; // list.set(tail--,"");
            break;
          default:
        }
      }
    }
  }
}


Measured memory_bytes: 124180
//A
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
const int INF=0x3f3f3f3f;

int main(){
    char a,b;
    cin>>a>>b;
    if(a<b) cout<<"<"<<endl;
    else if(a==b) cout<<"="<<endl;
    else if(a>b) cout<<">"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,m=1000;
	cin>>n;
	ll arr[n];
	for (ll i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	ll s;
	for (ll i=0; i<n-1; i++)
	{
		if (arr[i]>=arr[i+1])
		  continue;
		else
		{
			s=m/arr[i];
			m=m%arr[i];
			m=m+s*arr[i+1];
		}
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3548
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

s=get_nsp
n=s.size
s.uniq!
puts yn_judge(s.size==n,"yes","no")

Measured memory_bytes: 1916
H, W, A, B = map(int, input().split())

mod = 10**9 + 7
N = H + W - 2

# 階乗
fac = [1] * N
for i in range(1, N):
    fac[i] = (fac[i - 1] * i) % mod

# 逆元
inv = [1] * N
inv[N - 1] = pow(fac[N - 1], mod - 2, mod)
for i in range(N - 1, 0, -1):
    inv[i - 1] = (inv[i] * i) % mod


def f(x, y):
    res = fac[x + y] * inv[x] * inv[y]
    return res % mod


ans = 0
for x in range(B, W):
    ans += f(x, H - A - 1) * f(W - 1 - x, A - 1)
print(ans % mod)


Measured memory_bytes: 18804
A = list(input())
c = 0 #見分け
d = 0 #temp
m = 0 #max
i = 0
while i<len(A):
    if c == 0:
            if A[i] =="A" or A[i] == "C" or A[i] == "G" or A[i] == "T":
                c = 1
                d = 1
                #print(i,c)
    elif c == 1 and A[i] =="A" or A[i] == "C" or A[i] == "G" or A[i] == "T":
        d +=1
    elif c == 1:
        m = max(m,d)
        d = 0
    i += 1
m = max(m,d)
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e16
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    ll n;
    while(sf("%lld",&n)==1)
    {
        ll mn=INF;
        for(int i=0;i<5;i++)
        {
            ll x;
            sf("%lld",&x);
            mn=min(mn,x);
        }   
        
        ll ans=5;
        n-=mn;
        if(n>0)
        {
            ans+=(n/mn);
            if(n%mn)ans++;
        }
        pf("%lld\n",ans);
    }   
    return 0;
}
 









 




























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

typedef long long ll;
typedef complex<double> Vec;

ll N;
ll R;

int main() {
  cin >> N;
  for (ll i = 1; i <= N; ++i) {
    if ((1 <= i && i <= 9) || (100 <= i && i <= 999) ||
        (10000 <= i && i <= 99999))
      ++R;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
int main(){
	int rate;
  	int grade;
  	cin>>rate;
  	if(1800<=rate){
    grade=1;
    }
   	else if(1600<=rate){
    grade=2;
    }
  	else if(1400<=rate){
    grade=3;
    }
   	else if(1200<=rate){
    grade=4;
    }
  	else if(1000<=rate){
    grade=5;
    }
  	else if(800<=rate){
    grade=6;
    }
   	else if(600<=rate){
    grade=7;
    }
  	else if(400<=rate){
    grade=8;
    }
  	cout << grade;
  	return 0;
  
  
}

Measured memory_bytes: 3620
#include <iostream>

int main() {
    int N, K;
    std::cin >> N >> K;

    for (int b = 0; b < (1 << N); ++b) {
        if (__builtin_popcount(b) != K) continue;

        std::cout << b << ":";
        for (int i = 0; i < N; ++i) {
            if ((b >> i) & 1) std::cout << " " << i;
        }
        std::cout << std::endl;
    }
}



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

using namespace std;
#define mp make_pair 
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
struct query {
	int x,y,z,w;
};
int v[11];
int ans = 0;
vector<int> state;
vector<query> Q;
int n, m, q;
void dfs(int now, int val) {
	state.pb(val);
	if(now == n) {
		int tmp = 0;
		for(auto q : Q) {
			if(state[q.y]-state[q.x]==q.z) tmp += q.w;
		}
		ans = max(ans, tmp);
		state.pop_back();
		return;
	}
	for(int i=val;i<=m;i++){
		dfs(now+1, i);
	}
	state.pop_back();
}

int main(void)
{
	srand(time(NULL));
	cin >> n >> m >> q;
	for(int i=0;i<q;i++) {
		int x,y,z,w;
		cin >> x >> y >> z >> w;
		Q.pb({x,y,z,w});
	}
	state.pb(1);
	dfs(1, 1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Matrix;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}
map<ll, bool> mp;
// O(NloglogN)
std::vector<ll> Eratosthenes( const ll N )
{
    std::vector<bool> is_prime( N + 1 );
    for( ll i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<ll> P;
    for( ll i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( ll j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
            mp[i] = true;
        }
    }
    return P;
}

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

  ll Q;
  cin >> Q;
  
  vector<ll> v = Eratosthenes(100000);
  vector<ll> cnt_2017(100001);
  cnt_2017[0] = 0;
  cnt_2017[1] = 0;
  cnt_2017[2] = 0;
  for(int i = 3; i <= 100000; i++) {
    if (mp[i] && mp[(i+1)/2]) cnt_2017[i] = cnt_2017[i-1]+1;
    else cnt_2017[i] = cnt_2017[i-1];
  }

  vector<int> ans(Q, 0);
  rep(i, Q) {
    ll l, r;
    cin >> l >> r;
    ans[i] = cnt_2017[r] - cnt_2017[l-1];
  }
  rep(i, Q) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    sort(ALL(a), greater<int>());
    int alice, bob;
    alice = bob = 0;
    rep(i, n){
        if(i%2 == 0)alice+=a[i];
        else bob += a[i];
    }
    cout << alice-bob;
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

string str;


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>str;
    if(str.find("YAKI") == 0)	cout<<"Yes";
    else	cout<<"No";
    return 0;
}







 




Measured memory_bytes: 256
n,c,k = gets.split.map &:to_i
t = n.times.map{gets.to_i}.sort

ans = 0
idx = 0
while idx<n
  now = t[idx]
  for j in 0...c
    if t[idx]<=now+k
      idx += 1
    else
      break
    end
    if idx>=n
      break
    end
  end
  ans += 1
end

p ans


Measured memory_bytes: 4656
import sys
S = input()
a_list =["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
count = 0
m = 0
if S == "SUN":
    print(7)
    sys.exit(0)
for i in a_list:
    if m == 1:
        count += 1
    if S == i:
        m += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <cassert>
#include <time.h>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>
#define print_time()cout<<clock()/CLOCKS_PER_SEC<<" s"<<endl;

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//  std::ios::sync_with_stdio(false);
//  std::cin.tie(NULL);
//  return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << max(0, c - (a - b)) << endl;
	return 0;
}

Measured memory_bytes: 256
#ABC172 C Tsundoku 22:34
from itertools import accumulate

n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s_A = [0]+list(accumulate(A))
s_B = [0]+list(accumulate(B))

ans,j = 0, m
for i in range(n+1):
    if s_A[i] > k: break
    while s_B[j] > k - s_A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

int main()
{
    string K;
    cin >> K;
    int D;
    cin >> D;

    int N = K.size();

    // dp[i][j]: 上から i 桁目まで決めたときに D で割った余りが j になるような場合の数
    vector<vector<long long>> dp(N, vector<long long>(D)), dp_max(N, vector<long long>(D));
    // initialize
    dp_max[0][(int)(K[0]-'0')%D] = 1;
    REP(j, (int)(K[0]-'0')) dp[0][j%D] += 1;
    // dp
    FOR(i, 1, N){
        int tmp = (int)(K[i]-'0');
        REP(j, D){
            dp_max[i][(j+tmp)%D] += dp_max[i-1][j];
            REP(k, 10){
                dp[i][(j+k)%D] += dp[i-1][j];
                if(k < tmp) dp[i][(j+k)%D] += dp_max[i-1][j];
                dp[i][(j+k)%D] %= MOD;
            }
        }
    }
    cout << (dp[N-1][0]+dp_max[N-1][0]-1+MOD)%MOD << endl;  // 全部 0 を引くのを忘れずに

    return 0;
}

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

using namespace std;
#define ll long long int


int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout  << "Yes" << endl;
    }
    else{
        cout << "No" <<endl;
    }

}


Measured memory_bytes: 256
n=int(input())
s=input()

d=[0]*n
d2=[0]*n
d[0]=1 if s[0]=="#" else 0
d2[-1]=1 if s[-1]=="." else 0

for i in range(1,n):
  d[i]=d[i-1]+1 if s[i]=="#" else d[i-1]
  d2[-1-i]=d2[-i]+1 if s[-i-1]=="." else d2[-i]

m=n
for i in range(n):
  m=min(m,d[i]+d2[i])
print(m-1)

Measured memory_bytes: 18696
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;

int main()
{
    int n;
    string s, s1, s2;
    cin >> n >> s;
    if (n % 2 == 0) {
        s1 = s.substr(0, n / 2);
        s2 = s.substr(n / 2 , n / 2);
        if(s1==s2){
            cout<<"Yes";
        }else{
            cout<<"No";
        }
    }
    else {
        cout<<"No";
    }
}


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

int main(){
  string s;
  cin >> s;
  s.pop_back();
  if(s.size() % 2 == 1) s.pop_back();
  while(1){
    string fr = s.substr(0, s.size()/2);
    string re = s.substr(s.size()/2);
    if(fr == re){
      cout << s.size() << endl;
      return 0;
    }
    s.pop_back();
    s.pop_back();
  }
  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    while (true) {
      if (BigInteger.valueOf(x).isProbablePrime(100)) {
        System.out.println(x);
        return;
      }
      x++;
    }
  }
}

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

#include <algorithm>
#include <string>
#include <utility>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    ll N;
    map<pair<ll, ll>, ll> cnt;
    cin >> N;
    rep(i, N) {
        string s1 = to_string(i + 1);
        ll l = s1[0] - '0';
        ll r = s1[s1.size() - 1] - '0';

        cnt[make_pair(l, r)]++;
        // if (l != r) {
        //     cnt[make_pair(r, l)]++;
        // }
    }
    ll tot = 0;
    rep1(i, 10) {
        rep1(j, 10) {
            ll a = cnt[make_pair(i, j)];
            ll b = cnt[make_pair(j, i)];
            // cout << a << " " << b << endl;
            tot += a * b;
        }
    }
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		
		int dx = x2-x1;
		int dy = y2-y1;
		
		int x3 = x2-dy;
		int y3 = y2+dx;
		int x4 = x1-dy;
		int y4 = y1+dx;
		
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
	}
}


Measured memory_bytes: 22612
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{
    int h, w;
    while(1)
    {
        scanf("%d %d", &h, &w);
        if((h==0) && (w==0)) break;
        for(int i=0; i<h; i++)
        {
            string str(w, '#');
            printf("%s\n", str.c_str());
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2760
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int x[1200][1200], y[1200][1200][2], cx = 600, cy = 600, nums, primes[1300000], n, m, p, q;

void sets() {
	x[cx][cy] = 1; nums = 1;
	for (int i = 0; i < 2200; i++) {
		if (i % 4 == 0) {
			for (int j = 0; j <= i / 2; j++) {
				cx++;
				nums++;
				x[cy][cx] = nums;
			}
		}
		if (i % 4 == 1) {
			for (int j = 0; j <= i / 2; j++) {
				cy--;
				nums++;
				x[cy][cx] = nums;
			}
		}
		if (i % 4 == 2) {
			for (int j = 0; j <= i / 2; j++) {
				cx--;
				nums++;
				x[cy][cx] = nums;
			}
		}
		if (i % 4 == 3) {
			for (int j = 0; j <= i / 2; j++) {
				cy++;
				nums++;
				x[cy][cx] = nums;
			}
		}
	}
}

void isprime(int v) {
	for (int i = 2; i <= v; i++) {
		for (int j = 2; j <= sqrt(i); j++) {
			if (i%j == 0) { goto E; }
		}
		primes[i] = 1;
	E:;
	}
}

int main() {
	sets();
	isprime(1200000);
	while (true) {
		cin >> n >> m;
		if (!n) { break; }
		memset(y, -1, sizeof(y));
		for (int i = 0; i < 1200; i++) {
			for (int j = 0; j < 1200; j++) {
				if (x[i][j] == m) {
					y[i][j][0] = primes[m];
					y[i][j][1] = 0;
					if (y[i][j][0] == 1) { 
						y[i][j][1] = m; 
					}
				}
			}
		}
		for (int i = 0; i < 1200; i++) {
			for (int j = 0; j < 1200; j++) {
				if (y[i][j][0] >= 0) {
					//sosuuhantei-1st
					if (x[i + 1][j - 1] <= n) {
						if (primes[x[i + 1][j - 1]] == 1) {
							p = y[i][j][0] + 1;
							q = x[i + 1][j - 1];
						}
						else {
							p = y[i][j][0];
							q = y[i][j][1];
						}

						if (y[i + 1][j - 1][0] < p) {
							y[i + 1][j - 1][0] = p;
							y[i + 1][j - 1][1] = q;
						}
						else if (y[i + 1][j - 1][0] == p) {
							y[i + 1][j - 1][0] = p;
							y[i + 1][j - 1][1] = max(y[i + 1][j - 1][1], q);
						}
					}
					//2nd
					if (x[i + 1][j] <= n) {
						if (primes[x[i + 1][j]] == 1) {
							p = y[i][j][0] + 1;
							q = x[i + 1][j];
						}
						else {
							p = y[i][j][0];
							q = y[i][j][1];
						}

						if (y[i + 1][j][0] < p) {
							y[i + 1][j][0] = p;
							y[i + 1][j][1] = q;
						}
						else if (y[i + 1][j][0] == p) {
							y[i + 1][j][0] = p;
							y[i + 1][j][1] = max(y[i + 1][j][1], q);
						}
					}
					//3rd
					if (x[i + 1][j + 1] <= n) {
						if (primes[x[i + 1][j + 1]] == 1) {
							p = y[i][j][0] + 1;
							q = x[i + 1][j + 1];
						}
						else {
							p = y[i][j][0];
							q = y[i][j][1];
						}

						if (y[i + 1][j + 1][0] < p) {
							y[i + 1][j + 1][0] = p;
							y[i + 1][j + 1][1] = q;
						}
						else if (y[i + 1][j + 1][0] == p) {
							y[i + 1][j + 1][0] = p;
							y[i + 1][j + 1][1] = max(y[i + 1][j - 1][1], q);
						}
					}
				}
			}
		}
		p = 0; q = 0;
		//result.
		for (int i = 0; i < 1200; i++) {
			for (int j = 0; j < 1200; j++) {
				if (p < y[i][j][0]) {
					p = y[i][j][0];
					q = y[i][j][1];
				}
				else if (p == y[i][j][0]) {
					q = max(q, y[i][j][1]);
				}
			}
		}
		cout << p << ' ' << q << endl;
	}
	return 0;
}

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

int n;
int num;

int f(int i) {
int ans = 0;
while(i%2 == 0) i /= 2, ans++;
return ans;
}

int main() {
cin >> n;
int ans = 0;
while(n--) {
cin >> num;
ans += f(num);
}
cout << ans << endl;
return 0;
}


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

int main()
{
    ll n, v, w, d;
    string t, s;
    cin >> n;
    vector<tuple<ll, ll, string, ll, string>> point;

    rep(i, n)
    {
        cin >> v >> w >> t >> d >> s;
        point.push_back(make_tuple(v, w, t, d, s));
    }
    sort(point.begin(), point.end());

    rep(i, n) 
    {
        tie(v,w,t,d,s) = point[i];
        cout << v << " " << w << " " << t << " " << d << " " << s << endl;
    }
    return 0;
}


Measured memory_bytes: 17680
#include<iostream>
#include<string>
#include<vector>
#include<map>

using namespace std;

map<string,int> s1;
map<string,vector<string> > s2;
int INF=100000000;
int gold(string s){
	int res=0;
	int res2=INF;
	res=s1[s];
	if(s2[s].size()>0)res2=0;
	for(int i=0;i<s2[s].size();i++){
		res2+=gold(s2[s][i]);
	}
	res=min(res,res2);
	return res;
}

int main(void){
	int n,m;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		s1.clear();
		s2.clear();
		for(int i=0;i<n;i++){
			string str;
			int c;
			cin >> str >> c;
			s1[str]=c;
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			string str;
			int k;
			cin >> str >> k;
			for(int j=0;j<k;j++){
				string s;
				cin >> s;
				s2[str].push_back(s);
			}
		}
		string s3;
		cin >> s3;
		printf("%d\n",gold(s3));
	}
    return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;
static const int MAX = 50;

int main() {
    int N, p1[MAX], p2[MAX];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        p1[i] = p2[i] = p;
    }

    sort(p2, p2 + N);
    int diff = 0;
    for (int i = 0; i < N; ++i) {
        if (p1[i] != p2[i]) diff++;
    }

    cout << (diff <= 2 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h,r,a;
    cin>>h>>r;
    if(h<0){
        a=-h;
    }
    if(h<0&&r==a){
        cout<<'0'<<endl;
    }
    else if(h>=0){
        cout<<'1'<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }
}


Measured memory_bytes: 3096
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int nax=2e5+10;

void solve(){
    int n;cin>>n;
    ll xr=0;
    vector<ll> v(n);fr(i,0,n-1)cin>>v[i],xr=xr^v[i];
    for(auto x:v)
        cout<<(x^xr)<<" ";
    cout<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> par(N,0);
    for(int i = 1; i < N; ++i) {
        int a; cin >> a;
        a--;
        par[a]++;
    }
    for(int i = 0; i < N; ++i) cout << par[i] << endl;



    return 0;
}


Measured memory_bytes: 4024
#include<stdio.h>
int main()
{
	int N,i=1,q=3,reminder;
	scanf("%d",&N);
	for(i=1;i<=q;i++)
		{
			reminder=N%10;
			N=N/10;
			if(reminder==7)
				{
					printf("Yes\n");
					break;
				}
		}
		
		if(reminder!=7)
			{
				printf("No\n");
			}
	return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.length(); i++)
    {
        int a = s[i] - t[i];
        ans += (a==0);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
vector<int> G[1000];
vector<int> rG[1000];
vector<int> cG[1000];
vector<int> vs;
bool used[1000];
int cmp[1000];
int in[1000];
bool exist[1000][1000];
int N, M;
void dfs(int v) {
	used[v] = 1;
	for (int to : G[v]) {
		if (!used[to]) dfs(to);
	}
	vs.push_back(v);
}
void rdfs(int v, int k) {
	used[v] = 1;
	cmp[v] = k;
	for (int to : rG[v]) {
		if (!used[to]) rdfs(to, k);
	}
}
int scc() {
	memset(used, 0, sizeof(used));
	vs.clear();
	for (int v = 0; v < N; v++) {
		if (!used[v]) dfs(v);
	}
	memset(used, 0, sizeof(used));
	int k = 0;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
LL calc(int k) {
	LL ans = 1;
	LL tmp = 1;
	for (int to : cG[k]) {
		(tmp *= calc(to)) %= MOD;
	}
	(ans += tmp) %= MOD;
	return ans;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int S, D;
		cin >> S >> D;
		S--; D--;
		G[D].push_back(S);
		rG[S].push_back(D);
	}
	int k = scc();
	for (int v = 0; v < N; v++) {
		for (int to : G[v]) {
			if (cmp[v] == cmp[to] || exist[cmp[v]][cmp[to]]) continue;
			exist[cmp[v]][cmp[to]] = 1;
			in[cmp[to]]++;
			cG[cmp[v]].push_back(cmp[to]);
		}
	}
	memset(used, 0, sizeof(used));
	LL ans = 1;
	for (int i = 0; i < k; i++) {
		if (in[i]) continue;
		(ans *= calc(i)) %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4244
/*
B - Colorful Slimes
by.YXH_XianYu
   2018.6.17
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define rep(i,j,k) for(int i=j,lim=k;i<=lim;i++)
#define LLI long long
#define MXN 2003

int n;
LLI x,
	a[MXN],
	f[MXN][MXN];

int main(){

	scanf("%d%lld",&n,&x);
	rep(i,1,n)
		scanf("%lld",&a[i]);
	rep(i,1,n){
		f[i][0]=a[i];
		rep(j,1,n-1)
			f[i][j]=std::min(f[i][j-1],a[(i>j)?(i-j):(n+i-j)]);
	}
	LLI ans=1000000000000000000,sum;
	rep(j,0,n-1){
		sum=j*x;
		rep(i,1,n)
			sum+=f[i][j];
		ans=std::min(ans,sum);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 31616
def main(argv)
  n = gets.chomp.to_i
  a = gets.chomp.split(' ').map(&:to_i)

  avg = a.reduce(:+).to_f / n.to_f

  min_diff = 100.0
  min_index = -1
  n.times do |i|
    diff = (a[i] - avg).abs

    if min_diff > diff then
      min_diff = diff
      min_index = i
    end
  end

  puts min_index.to_i
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
from collections import Counter

N,*a = map(int,open(0).read().split())
ans = []
for i in range(N)[::-1]:
    part_rem = sum(a[i::i+1]) % 2
    if a[i] == 0:
        if part_rem == 1:
            a[i] = abs(a[i] - 1) 
    elif a[i] == 1:
        if part_rem == 0:
            a[i] = abs(a[i] - 1)
            
c = Counter(a)            
print(c[1])
for i in range(N):
    if a[i] == 1:
        print(i+1,end=" ")
print()        
      
    

Measured memory_bytes: 7132
import java.util.*;

public class Main {
    
    static Node[] nodes;
    
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Q = sc.nextInt();
        
        nodes = new Node[N];
        
        for(int i = 0; i < N; i++){
            nodes[i] = new Node();
        }
        
        for(int i = 0; i < N - 1; i++){
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            nodes[a].add(nodes[b]);
            nodes[b].add(nodes[a]);
        }
        
        // parentを設定
        dfs(nodes[0], null);
        
        for(int i = 0; i < Q; i++){
            int p = sc.nextInt() - 1;
            int x = sc.nextInt();
            nodes[p].cnt += x;
        }
        
        sum(nodes[0]);
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < N; i++){
            sb.append(nodes[i].cnt);
            if( i != N - 1) sb.append(" ");
        }
        
        System.out.println(sb);
        
    }
    
    private static void sum(Node c){
        if( c.parent != null ){
            c.cnt += c.parent.cnt;
        }
        
        for( Node cc : c ){
            if ( cc != c.parent) {
                sum(cc);
            }
        }
    }
    
    private static void dfs(Node c, Node parent){
        c.parent = parent;
        for(Node cc : c){
            if ( cc != parent) {
                dfs(cc, c);
            }
        }
    }
    
    static class Node extends ArrayList<Node>{
        Node parent;
        int cnt = 0;
    }
}


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

using namespace std;

int n,m;

struct drink
{
    int cou;
    long long mon;
}a[100001];

bool cmp(struct drink a,struct drink b){
    return a.mon < b.mon;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i = 1;i <= n;i++)
        scanf("%lld%d",&a[i].mon,&a[i].cou);
    sort(a + 1 ,a + n + 1,cmp);
    long long ans = 0;
    for(int i = 1;m >0;i++)
    {
        if(m >= a[i].cou){
            m -= a[i].cou;
            ans += a[i].cou * a[i].mon;
        }
        else{
            ans += m * a[i].mon;
            m = 0;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout <<  "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 3004;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int N,T;
pii A[MAXN];
LL dp[2*MAXN];
int D[2*MAXN];

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> T;
    int k = 0;
    fori(i,N) {
        cin >> A[i].fi >> A[i].se;
    }

    sort(A,A+N);
    D[0] = 1;
    fori(i,N) {
        ford(t,T-1) {
            if(D[t]) {
                D[t+A[i].fi] = 1;
                mmax(dp[t+A[i].fi], dp[t]+A[i].se);
            }
        }
    }

    LL ans = 0;
    for(int t = 0; t < MAXN*2; t++) ans = max(ans, dp[t]);
    cout << ans << endl;
    return 0;
}



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

struct trump{
    char mark; 
    int value;
};

void bubbleSort(trump C[], int N){
    for(int i = 0 ; i < N ; i++){
        for(int j = N-1 ; j >= i+1 ; j--){
            if(C[j].value < C[j-1].value){
                swap(C[j] , C[j-1]);
            }
        }
    }
}

void selectionSort(trump C[],int N){
    int minj;
    for(int i = 0 ; i < N ; i++){
        minj = i;
        for(int j = i ; j < N ; j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        swap(C[i] , C[minj]);
    }
}

void point(trump C[] , int N){
    for(int i = 0 ; i < N ; i++){
        if(i > 0){
            cout << " " ;
        }
        cout << C[i].mark << C[i].value;
    }
    cout << endl;
}
bool isStable(trump C1[] ,trump C2[] , int N){
    for(int i = 0 ; i < N ; i++){
        if(C1[i].mark != C2[i].mark){
            return false;
        }
    }
    return true;
}

int main(){
    trump C1[100];
    trump C2[100];
    int N;

    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> C1[i].mark >> C1[i].value;
    }

    for(int i = 0 ; i < N ; i++){
        C2[i] = C1[i];
    }

    bubbleSort(C1,N);
    selectionSort(C2,N);

    point(C1,N);
    cout << "Stable" << endl;
    point(C2,N);
    if(isStable(C1 , C2 , N)){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            Set<Integer> set = new HashSet<>();

            for (int i = 0; i < n; i++) {
                int cn = in.nextInt();
                if (set.contains(cn))
                    set.remove(cn);
                else
                    set.add(cn);
            }

            out.println(set.size());
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 33108
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(void) {
	long a[50], b[50], c[50], d[50];
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int cina, cinb;
		cin >> cina >> cinb;
		a[i] = cina; 
		b[i] = cinb;
	}
	for (int i = 0; i < m; i++) {
		int cinc, cind;
		cin >> cinc >> cind;
		c[i] = cinc;
		d[i] = cind;
	}
	for (int i = 0; i < n; i++) {
		int ans;
		long dis = 1000000000;
		for (int j = 0; j < m; j++) {
			long new_dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (dis > new_dis) {
				ans = j + 1;
				dis = new_dis;
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int main(){
  int64_t n;
  int64_t k;
  int64_t ans=0;
  cin >> n >> k;
  vector<int64_t> h(n);
  for(int64_t i=0;i<n;i++){
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  for(int64_t i=0;i<n-k;i++){
    ans=ans+h.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
 
#define MIN_N 1
#define MAX_N 200000
#define MIN_A 0
#define MAX_A 1000000000
 
int array[MAX_N];
long invcnt = 0;
 
void merge(int *array, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, k, *left_array, *right_array;
 
    left_array = malloc(sizeof(int) * n1 + 100);
    right_array = malloc(sizeof(int) * n2 + 100);
 
    for(i = 0; i < n1; i++) 
        left_array[i] = array[left + i];
    for(i = 0; i < n2; i++)
        right_array[i] = array[mid + i];
    left_array[n1] = MAX_A + 1;
    right_array[n2] = MAX_A + 1;
    i = 0;
    j = 0;
    for(k = left; k < right; k++) {
        if(left_array[i] <= right_array[j]) 
            array[k] = left_array[i++];
        else {
            invcnt += n1 - i;
            array[k] = right_array[j++];
        }
         
    }
    free(left_array);
    free(right_array);
}
 
void merge_sort(int *array, int left, int right)
{
    if(left + 1 < right) {
        int mid;
 
        mid = (left + right) / 2;
        merge_sort(array, left, mid);
        merge_sort(array, mid, right);
        merge(array, left, mid, right);
    }
 
}
 
int main(void)
{
    int i, n;
 
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        array[i] = a;
    }
    merge_sort(array, 0, n);
    printf("%ld\n", invcnt);
 
    return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  
  vector<long long> s(n);
  s[0] = a[0];
  for(int i = 1; i < n; i++) s[i] = a[i] + s[i - 1];
  
  long long t = 0;
  long long diff = 0;
  for(int i = 0; i < n; i++){
    if(i - ((i >> 1) << 1)){
      if(s[i] + diff >= 0){
        t += s[i] + diff + 1;
        diff = - s[i] - 1;
      }
    }else{
      if(s[i] + diff <= 0){
        t += 1 - s[i] - diff;
        diff = 1 - s[i];
      }
    }
  }
  
  long long u = 0;
  diff = 0;
  for(int i = 0; i < n; i++){
    if(i - ((i >> 1) << 1)){
      if(s[i] + diff <= 0){
        u += 1 - s[i] - diff;
        diff = 1 - s[i];
      }
    }else{
      if(s[i] + diff >= 0){
        u += s[i] + diff + 1;
        diff = - s[i] - 1;
      }
    }
  }
  
  cout << min(t, u) << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int a,b;cin>>a>>b;
  int s,t;
  for(int i=1;i<=10000;i++){
    s=i*0.08;
    t=i*0.1;
    if(s==a && t==b){
      cout<<i;
      break;
    }
    if(i==10000)
      cout<<-1;
  }
}
    
  


Measured memory_bytes: 256