akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("04.txt","r",stdin);
    int mod,n,i,a[100001]={0},b[100001]={0};
    long long tim[100001]={0};
    long long mul,done=0;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(i=0;i<n;i++)
    {
        mod=a[i]%b[i];
        if(mod)
            tim[i]=b[i]-mod;
    }
    for(i=n-2;i>=0;i--)
    {
        if(tim[i]>=tim[i+1])
            continue;
        mul=(tim[i+1]-tim[i])/b[i];
        tim[i]+=mul*b[i];
        if(tim[i]<tim[i+1])
            tim[i]+=b[i];
    }
    done=tim[n-1];
    for(i=n-2;i>=0;i--)
    {
        done+=(long long)(tim[i]-tim[i+1]);
    }
    cout<<done;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int main() {
   int a,b,c;
	cin >> a >> b >> c;
   bool ans=false;
   for(int i=1; i<=b; i++){
      if(a*i%b==c)
      ans=true;
   }
   cout << (ans==true ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
def sort(x, y) 
	if x > y then
		return y,x
	else
		return x,y
	end
end

def check_sort(x, y, z) 
	if x > y then
		return false
	elsif y > z then
	    return false
	else
		return true
	end
end

input = STDIN.gets
a,b,c = input.split(" ")
a = a.to_i
b = b.to_i
c = c.to_i

while !check_sort(a,b,c) do
	a,b = sort(a,b)
	b,c = sort(b,c)
end

print a, " ", b," ", c,"\n"



Measured memory_bytes: 6872
k = input()
k = str(k)

ans = 'No'

# print(k[-1])

if int(k[-1]) == 7 :
    ans = 'Yes'

# print(k[-2])

if int(k[-2]) == 7 :
    ans = 'Yes'

# print(k[-3])

if int(k[-3]) == 7 :
    ans = 'Yes'


print(ans)

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

public class Main {

	//ツ　2204 Problem A: ツ甘コツ鳴鳴篠篠個ア!
	public static void main(String[] args) throws IOException {
		
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		for(;;) {
		
			String s = reader.readLine();
			int n = Integer.parseInt(s);
			if (n == 0)
				break;
			int max = 0;
			int min = 9999;
			
			for(int i = 0; i < n; i++) {
				s = reader.readLine();
				String[] sp = s.split(" ");
				int sum = 0;
				for(int j = 0; j < 5; j++) {
					sum += Integer.parseInt(sp[j]);
				}
				max = Math.max(max, sum);
				min = Math.min(min, sum);
			}
			System.out.printf("%d %d\n", max, min);
		}		
		
		reader.close();
		
	}

}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;


int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = k + 1;
    ll u = k - (a - 1);
    if (u >= 0) {
        ans = max(ans, a + u % 2 + u / 2 * (b - a));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int mod = 1000000000 + 7;

        long[] d = new long[k + 1];
        for (int i = 1; i <= k; i++) {
            int count = k / i;
            d[i] = modPow(count, n, mod);
        }

        for (int i = k; i > 0; i--) {
            int a = 2;
            while (i * a <= k) {
                if (d[i] >= d[i * a]) {
                    d[i] -= d[i * a];
                } else {
                    d[i] = d[i] + mod - d[i * a];
                }
                a++;
            }
        }

        long ans = 0;
        for (int i = 1; i <= k; i++) {
            ans += i * d[i];
            ans %= mod;
        }

        System.out.println(ans);

    }

    private static long modPow(long a, long b, long mod) {
        if (b == 0) {
            return 1;
        }

        if (b % 2 == 0) {
            return modPow((a * a) % mod, b / 2, mod);
        } else {
            return modPow((a * a) % mod, b / 2, mod) * a % mod;
        }
    }

}


Measured memory_bytes: 36380
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		
		int time = (int)(t+0.5)/a;
		System.out.println(time*b);
	}
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];

    vector<int> per(N);
    per = Q;
    sort(all(per));
    int s, e;
    int num = 0;
    do
    {
        num++;
        if (per == P)
            s = num;
        if (per == Q)
            e = num;
    } while (next_permutation(all(per)));

    cout << abs(s - e) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = int.Parse(Console.ReadLine());
            var his = new HashSet<int>();
            var ai = s;
            his.Add(ai);
            var i = 2;
            while (true)
            {
                if(ai%2==0)
                {
                    ai = ai / 2;
                }
                else
                {
                    ai = ai * 3 + 1;
                }
                if (!his.Contains(ai)) his.Add(ai);
                else break;
                i++;
            }
            Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 13280
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll a,b;
    cin>>a>>b;
    if(a+b==15)cout<<'+';
    else if(a*b==15)cout<<'*';
    else cout<<'x';
    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++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
q=gets.to_i
bc=(0...q).map{gets.split.map(&:to_i)}


ah=a.each_with_object({}){|x,memo| memo[x]||=0;memo[x]+=1 }
s=a.sum


bc.each{|qb,qc|
    ah[qb]||=0
    ah[qc]||=0
    s+= (ah[qb]*(qc-qb))
    ah[qc]+=ah[qb]
    ah[qb]=0
    print s,"\n"
}



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

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    int sum = a[2] + a[1] + a[0];
    int ans = a[2] * 2 - a[0] - a[1];
    if (sum % 2 != a[2] % 2) ans += 3;
    ans /= 2;
    cout << ans << endl;
}

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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*funcs*/

/*input*/

int a[5];
int k;

/*main*/
int main(){
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    sort(a,a+5);
    if(a[4]-a[0]>k){
        cout<<":(";
    }else{
        cout<<"Yay!";
    }
}


Measured memory_bytes: 256
<?php
  $a = trim(fgets(STDIN));
  $b = trim(fgets(STDIN));
  $same = false;
  for($i =  0; $i < 100 ;$i++){
    if($a == $b)$same = true;
    $a = substr($a,1). $a[0];
  }
echo $same ? "Yes" : "No";

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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int leftb=0;
  int rightw=0;
  int minc=200000;
  int cntw=0;
  int cntb=0;
  int W[N+1];
  int B[N+1];
  W[0]=0;
  B[0]=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='#'){
      cntb++;
    }
    B[i+1]=cntb;
  }
  for(int i=0;i<N;i++){
    if(S.at(N-i-1)=='.'){
      cntw++;
    }
    W[N-i-1]=cntw;
  }
  for(int i=0;i<N+1;i++){
    //cout<<i<<" "<<W[i]<<" "<<B[i]<<endl;
    minc=min(minc,W[i]+B[i]);
  }
  
  cout<<minc<<endl;
  
  
  return 0;
}

  

Measured memory_bytes: 2180
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int h,w,i,j;
	cin >> h >> w;
	int squares[h][w];
	for(i=0; i<h; i++){
		string s;
		cin >> s;
		for(j=0; j<w; j++){
			if(s[j]=='#'){
				squares[i][j]=1; //障害物有り
			}else{
				squares[i][j]=0; //障害物無し
			}
		}
	}

	int	L[h][w],R[h][w],U[h][w],D[h][w];

	for(i=0; i<h; i++){
			int k;
			k=h-1-i;
		for(j=0; j<w; j++){
			int l;
			l=w-1-j;
			if(squares[i][j]==1){
				L[i][j]=0;
				U[i][j]=0;
			}else{
				if(j==0){
					L[i][j]=1;
				}else{
					L[i][j]=L[i][j-1]+1;
				}
				if(i==0){
					U[i][j]=1;
				}else{
					U[i][j]=U[i-1][j]+1;
				}
			}
			if(squares[k][l]==1){
				R[k][l]=0;
				D[k][l]=0;
			}else{
				if(l==w-1){
					R[k][l]=1;
				}else{
					R[k][l]=R[k][l+1]+1;
				}
				if(k==h-1){
					D[k][l]=1;
				}else{
					D[k][l]=D[k+1][l]+1;
				}
			}
		}
	}

	int ans=0;
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			int n;
			n=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
			if(n>ans){
				ans=n;
			}
		}
	}

	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
int a[MAXN];

int n;

vector< vector<int> > wins;

int solve(int x) {
    vector<int> s;

    for (auto y : wins[x]) {
        s.PB(solve(y));
    }

    sort(s.rbegin(), s.rend());

    int res = 0;

    FOR1(i, s.size()) {
        res = max(res, s[i-1] + i);
    }

//    DEBUG(x);
//    DEBUG(res);

    return res;
}

int main() {
    GI(n); wins.resize(n+1);

    for (int i = 2; i <= n; i++) {
        GI(a[i]);
        wins[a[i]].PB(i);
    }

    cout << solve(1) << "\n";

    return 0;
}

Measured memory_bytes: 15488
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll a[55];
ll ans2 = 4e18;

ll f(ll p)
{
    ll cnt = 0;
    for(ll i = 0; i < n; i++)
    {
        cnt += (a[i] + p - (n - 1) + n) / (n + 1);
    }
    return cnt <= p;
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < n; i++)
    {
        ll lt = 0, rt = 4e18, mid, ans;
        while(lt <= rt)
        {
            mid = (lt + rt) / 2;
            if(f(mid / n * n + i)) ans = mid / n * n + i, rt = mid - 1;
            else lt = mid + 1;
        }
        ans2 = min(ans2, ans);
    }
    cout<<ans2<<endl;
    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

vll M;

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

ll dfs(ll v){
	if(M[v]>=0) return M[v];

	ll B=0,V=v;
	while(V){
		if(V&1) B++;
		V/=2;
	}

	if(!B){
		M[v]=0;
		return 0;
	}
	if(!(v%B)){
		M[v] = 1;
		return 1;
	}

	ll C = dfs(v%B)+1;
	M[v] = C;
	return C;
}

ll safemod(ll a,ll m){
	return (a%m+m)%m;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	string X=in<string>();
	M.resize(N+1,-1);
	ll C=0;
	REP(i,N){
		if(X[i]=='1'){
			C++;
		}
	}
	ll modP=0,modD=0;
	if(C<N){
		REP(j,N){
			if(X[N-1-j]=='1'){
				modP += powermod(2,j,C+1);
				modP %= (C+1);
			}
		}
	}
	if(C>1){
		REP(j,N){
			if(X[N-1-j]=='1'){
				modD += powermod(2,j,C-1);
				modD %= (C-1);
			}
		}
	}

	ll K[2]={C-1,C+1};
	REP(i,N){
		ll B;
		auto T=X;
		ll mod=0;
		if(T[i]=='0'){
			T[i] = '1';
			B = 1;
			mod = modP;
			mod += powermod(2,N-1-i,K[B]);
			mod %= K[B];
		}
		else{
			T[i] = '0';
			B = 0;
			if(K[B]==0){
				out(0);
				continue;
			}
			mod = modD;
			mod -= powermod(2,N-1-i,K[B]);
			mod = safemod(mod,K[B]);
		}

		ll Z=dfs(mod)+1;
		out(Z);
	}


	return 0;
}


Measured memory_bytes: 5224
n = int(input())
a = [int(i) for i in input().split()]

a = sorted(list(filter(lambda x : (x % 2) == 0, a)), reverse=True)
ans = 0
for i in a:
    while i % 2 == 0:
        i //= 2
        ans += 1
print(int(ans))

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

bool palindrome(string s) {
    bool ans = true;
    if (s.size() % 2 == 0) {
        rep(i,s.size()/2) { 
            if (s[i] != s[s.size()-i-1]) {
                ans = false;
                break;
            }
        }
    } else {
        rep(i,(s.size()-1)/2) {
            if (s[i] != s[s.size()-i-1]) {
                ans = false;
                break;
            }
        }
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    if (palindrome(s) && palindrome(s.substr(0, (s.size()-1)/2)) && palindrome(s.substr((s.size()+1)/2))) cout << "Yes" << endl;
    else cout << "No" << endl; 
    
    return 0;
}

Measured memory_bytes: 256
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b;
  c = a * b;
  for(int i = 1; i <= 3; i++){
    if(c * i % 2 != 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a,b,k;
int main()
{
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	if(i%k==0)
	{
		cout<<"OK";
		return 0;
	}
	cout<<"NG";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int TopIndex = 1;
const int DummySize = 1;

void Exchange(vector<int>& Heap, int InsertIndex)
{
	int ParentIndex = InsertIndex / 2;
	while(InsertIndex > TopIndex && Heap[InsertIndex] > Heap[ParentIndex]){
		swap(Heap[InsertIndex], Heap[ParentIndex]);
		InsertIndex = ParentIndex;
		ParentIndex = InsertIndex / 2;
	}
}

void Insert(vector<int>& Heap, int k)
{
	Heap.push_back(k);
	int InsertIndex = Heap.size() - 1;
	Exchange(Heap, InsertIndex);
}

void maxHeapify(vector<int>& A, int i)
{
	int H = A.size() - 1;
	int l = 2 * i;
	int r = 2 * i + 1;
	//????????????????????????????????§???????????§????????????????????¶
	int largest;
	if(l <= H && A[l] > A[i]){
		largest = l;
	}else{
		largest = i;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	//i???????????????????????§????????´???
	if(largest != i){
		swap(A[i], A[largest]);
		//?????°??????????????????
		maxHeapify(A, largest);
	}
}

void ExtractMax(vector<int>& Heap)
{
	int TailIndex = Heap.size() - 1;
	cout << Heap[TopIndex] << endl;
	swap(Heap[TailIndex], Heap[TopIndex]);
	Heap.pop_back();
	maxHeapify(Heap, TopIndex);
}

int main()
{
	vector<int> Heap(DummySize);
	while(true){
		string Command;
		cin >> Command;
		if(Command == "insert"){
			int k;
			cin >> k;
			Insert(Heap, k);
		}else if(Command == "extract"){
			ExtractMax(Heap);
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 7044
//Problem 1102F DP+Bitmasking
#include<bits/stdc++.h>

#define hell                         1000000007
#define __lcm(a,b)                   (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cerr << #x << " is " << x << endl;
#define endl                           '\n'

#define MAX 100005
using namespace std;

ll h,n;
ll a[1001],b[1001];
ll dp[10001][1001];

ll f(ll hh, ll pos) {
	if(hh<=0) return 0;
	if(pos==n) {
		if(hh<=0) return 0;
		return 1e15;
	}
	if(dp[hh][pos]!=-1) return dp[hh][pos];
	ll ans=f(hh,pos+1);
	ans=min(ans,b[pos]+f(hh-a[pos],pos));
	return dp[hh][pos]=ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    cin >> h >> n;
    rep(i,0,n) cin >> a[i] >> b[i];
    memset(dp,-1,sizeof(dp));
    cout << f(h,0);
}

Measured memory_bytes: 78976
k, n = map(int,input().split())
a = list(map(int,input().split()))
amax = 0

la = len(a)
for i in range(la):
    d = a[(i+1)%la] - a[i]
    if amax < a[(i+1)%la] - a[i]:
        amax = a[(i+1)%la] - a[i]
if amax < k - a[-1] + a[0] :
    amax = k - a[-1] + a[0]

print(k - amax)

Measured memory_bytes: 26444
from collections import deque,Counter

N,K = map(int,input().split())
cnt = Counter()
for _ in range(N):
    A,B = map(int,input().split())
    cnt[A] += B

sortedKeys = sorted(list(cnt.keys()))

tmp = K
for k in sortedKeys:
    tmp -= cnt[k]
    if tmp <= 0:
        print(k)
        exit()


Measured memory_bytes: 11356
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
using namespace std;

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

int main()
{
    int n,k,q,index;
    int a[100001]={};
    cin>>n>>k>>q;
    rep(i,q){
        cin>>index;
        a[index-1]++;
    }
    rep(i,n){
        if(k-(q-a[i])>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
    static long[][] dp;
    static int[][] wv;
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), w=in.nextInt();
        dp=new long[w+1][n+1];

        for(int i=0;i<=w;i++){
            for(int j=0;j<=n;j++){
                if(i==0)
                    dp[i][j]=0;
                else
                    dp[i][j]=-1;
            }
        }

        wv = new int[n][2];

        for(int i=0;i<n;i++){
            wv[i][0] = in.nextInt();
            wv[i][1] = in.nextInt();
        }
        System.out.println(maxValue(w, 0));

    }

    public static long maxValue(int w, int ind){
        if(dp[w][ind]!=-1)
            return dp[w][ind];
        if(ind>wv.length-1)
            return 0;
        if(w<wv[ind][0])
            return dp[w][ind] = maxValue(w,ind+1);
        return (dp[w][ind] = (Math.max(wv[ind][1]+maxValue(w-wv[ind][0],ind+1), maxValue(w,ind+1))));

    }
}

Measured memory_bytes: 145572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pl = pair<ll, ll>;
using Tl = tuple<ll, ll, ll>;

const ll INF = 1e15;
const ld eps = 1e-6;

int main(){
  ll N;
  cin >> N;
  vector<ll> x(N);
  for(int i=0;i<N;i++){
    ll a;
    cin >> a;
    x[a - 1] = i;
  }
  ll ans = 1;
  ll now = -1;
  ll cnt = 0;
  for(int i=0;i<N;i++){
    if(now < x[i]){
      cnt++;
      now = x[i];
      ans = max(ans, cnt);
    }else{
      cnt = 1;
      now = x[i];
    }
  }
  cout << N - ans << endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    long long a[200004], b[200004];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i] - i;
    }
    sort(b, b + n);
    long long k = 0, l = 0;
    for(int i = 0; i < n; i++){
        k += abs(b[i] - b[n/2]);
    }
    for(int i = 0; i < n; i++){
        l += abs(b[i] - b[n/2 + 1]);
    }
    cout << min(k, l) << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
 int num[3]={-1,-1,-1},s[5],c[5];
 int n,m,temp=1;
 cin>>n;cin>>m;
 if(m!=0)
 {
 for(int i=0;i<m;i++)
 {
     cin>>s[i];
     cin>>c[i];
}

 for(int i=0;i<m;i++)
 {
     if(num[s[i]-1]==-1 || num[s[i]-1]==c[i])
     num[s[i]-1]=c[i];
     else
     {temp=0;
     break;}
 }
 if(n==1 && num[0]==0)
 temp=1;
 else if(num[0]==0)
 temp=0;
 
 if(!temp)
 {
     cout<<-1;
 }
 else
 {
    if((n==1 && num[0]<1) || m==0 )
    cout<<0;
    else
    {
    if(num[0]==-1)
    num[0]=1;
    for(int i=0;i<n;i++)
    {
        if(num[i]!=-1)
        cout<<num[i];
        else
        cout<<0;
     }}
 }}
 else
 {
    if(n==1)
    cout<<0;
    else if(n==1)
    cout<<10;
    else if(n==3)
    cout<<100;
 }
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>

using namespace std;

int main(){
  string S;
  cin >> S;
  char s1,s2;
  s1 = S[0];
  s2 = S[1];
  int count1=1;
  int count2=1;
  if(S[2]==s1) count1++;
  if(S[2]==s2) count2++;
  if(S[3]==s1) count1++;
  if(S[3]==s2) count2++;
  if(count1==2 && count2==2) cout << "Yes" << endl;
  else if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	ll k;
	cin >> s >> k;
	ll index = 0;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] == s[i + 1]) {
			index++;
		}
	}
	if (index == s.size() - 1) {
		cout << s.size() * k / 2 << endl;
		return 0;
	}

	else {
		if (s[0] != s[s.size() - 1]) {
			ll index = 1;
			ll count = 0;
			for (int i = 0; i < s.size()-1; i++) {
				if (s[i] == s[i + 1]) {
					index++;
				}
				else {
					count += index / 2;
					index = 1;
				}
			}
			count += index / 2;
			cout << count * k << endl;
		}
		else {
			ll a = 1;
			for (int i = 0; i < s.size(); i++) {
				if (s[i] != s[i + 1]) {
					break;
				}
				a++;
			}
			
			ll b = 1;
			for (int j = s.size() - 1; j > 0; j--) {
				if (s[j] != s[j - 1]) {
					break;
				}
				b++;
			}
			ll count = 0;
			ll index = 1;
			for (int i = a; i <s.size()-b; i++) {
				if (s[i] == s[i + 1]) {
					index++;
				}
				else {
					count += index / 2;
					index = 1;
				}
			}
			count += index / 2;
			

			cout << a/2 + b/2  + (a+b)/2*(k-1) + count*k<< endl;
		}
	}
	return 0;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void READ() {
#define R READ();
#define INFI 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MEMX(x,num) memset(x,num,sizeof(x))
#define prln(x) cout<<#x<<"="<<x<<endl
#define sz(x) int(x.size())
#define PB(x) push_back(x)
#define LINK(x,y) G[x].PB(y),G[y].PB(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#ifndef ONLINE_JUDGE
    freopen ( "A.in", "r", stdin );
#endif
    std::ios::sync_with_stdio ( 0 );
    cin.tie ( 0 );
    cout << fixed << setprecision ( 6 );
}
//////////////////////////////////////////
const int N = 5 + 1e1;
string s;
int t;
int main() {
    cin>>s>>t;
    for(int i=0;i<sz(s);i+=t)
    {
        cout<<s[i];
    }
    return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
warlist=[list(map(int,input().split())) for _ in range(m)]

warlist.sort(key = lambda x:x[1])

kijun=warlist[0][0]-1
bukkowashi=0

for war in warlist:
	if war[0] >= kijun:
		bukkowashi += 1
		kijun = war[1]

print(bukkowashi)


Measured memory_bytes: 29084
#include<stdio.h>
#include<stdlib.h>
int main(void) {
	int i, n, l, sum = 0, sa = 2147483647;
	scanf("%d %d", &n, &l);
	for (i = 1; i <= n; i++)
		if (abs(sa) > abs(i + l - 1)) sa = (i + l - 1);
	for (i = 1; i <= n; i++) sum += (i + l - 1);
	printf("%d", sum - sa);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    const int MAX = (1e5)+1;
     
    int n;
    long long E, T, x[MAX], dp[MAX], f[MAX];
    multiset<long long> l, m;
    int main() {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cin >> n >> E >> T;
    	l.insert(f[0] = T);
    	for(int i = 1, j = 0; i <= n; i++) {
    		cin >> x[i];
    		while(j < i && 2*(x[i]-x[j+1]) >= T) {
    			l.erase(l.find(f[j]));
    			f[j] = f[j]-T-2*(x[j+1]);
    			m.insert(f[j]);
    			j++;
    		}
    		dp[i] = LLONG_MAX;
    		if(!l.empty()) dp[i] = min(x[i]+*l.begin(), dp[i]);
    		if(!m.empty()) dp[i] = min(3*x[i]+*m.begin(), dp[i]);
    		l.insert(f[i] = dp[i]-x[i]+T);
    	}
    	cout << dp[n]+E-x[n];
    }

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<ll> a(N);
    map<ll,ll> mp;
    
    REP(i,N){
        cin>>a[i];
        mp[a[i]]+=1;
         
    }
    ll ans=0;
    for (auto iter=mp.begin();iter!=mp.end();iter++){
        ll v=iter->second;
        ans+=v*(v-1)/2;
    }
    REP(i,N){
        if(mp[a[i]]>1){
            cout<<ans-(mp[a[i]]-1)<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 11136
from itertools import combinations_with_replacement as comb

def f(n, h):
    for i in comb(range(6), n):
        if sum(i) == h:
            return 1
    return 0

if __name__ == '__main__':
    x = int(input())
    n = x // 100
    h = x - 100 * n
    print(f(n, h))

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

#define PI acos(-1)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int INF = 100500;
const int MAXN = 1e5 + 9;

string s;

void input() {                  
	cin >> s;
}

void solve() {
	string t = "";
	for(int i = 0; i < sz(s); i++) {
		if(s[i] == ',') {
			cout << t << ' ';
			t = "";
		}
		else t += s[i];
	}
	cout << t << endl;
}

int main() {     
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int N = sc.nextInt();
		int h[] = new int[N];
		for(int i = 0; i < N; i++) 
			h[i] = sc.nextInt();
		int dp[] = new int[N];
		Arrays.fill(dp, MAX);
		dp[0] = 0;
		for(int i = 0; i < N; i++) {
			if(i + 1 < N) 
				dp[i + 1] = Math.min(dp[i + 1], dp[i] + diff(h[i], h[i + 1]));
			if(i + 2 < N)
				dp[i + 2] = Math.min(dp[i + 2], dp[i] + diff(h[i], h[i + 2]));
		}
		System.out.println(dp[N - 1]);
	}
	int diff(int a, int b) {
		return Math.abs(a - b);
	}
	
	
	

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


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;


unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 3001;

vi A;

vi solve(vi & B){
    if(sz(B) == 1)return {B[0]};
    vi B1,B2;
    vi ANS;
    rep(c1,0,sz(B)/2){
        B1.push_back(B[c1]);
        B2.push_back(max(B[c1], B[c1+sz(B)/2]));
    }
    vi A1,A2;
    A1 = solve(B1);
    A2 = solve(B2);
    int ma = 0;
    rep(c1,0,sz(B)/2){
        ANS.push_back(A1[c1]);
        ma = max(ma, A1[c1]);
    }
    rep(c1,0,sz(B)/2){
        ANS.push_back(max(max(ma,A2[c1]), B[c1] + B[c1+sz(B)/2]));
        ma = max(ma, ANS[c1+sz(B)/2]);
    }
    return ANS;
}



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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> n;
    rep(c1,0,1<<n){
        cin >> a;
        A.push_back(a);
    }
    vi ANS = solve(A);
    rep(c1,1,1<<n){
        cout << ANS[c1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 5876
import java.util.*;
public class Main {
  public static void main(String[] args) {
  	Scanner s = new Scanner(System.in);
    StringBuilder st = new StringBuilder(s.next());
    int sum = 0;
    for(int i=0;i<st.length();i++) {
      sum += st.charAt(i) - 48;
    }
    if(sum%9 == 0)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 40700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N; cin>>N;
  ll a[N],b[N];
  REP(i,N){ cin>>a[i]>>b[i];}
  ll cumu = 0;
  REPR(i,N-1){
    ll need = (b[i]-(a[i]+cumu)%b[i])%b[i];
    cumu += need;
  }
  cout << cumu<<"\n";
}

Measured memory_bytes: 1792
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

string s;
ll res=0;

int main(){
	cin.sync_with_stdio(false);
	cin>>s;
	rep(i,1<<(s.length()-1)){
		ll l=0;
		rep(j,s.length()-1){
			//dbg(i);dbg(j);
			if(i>>j&1){
				res+=stod(s.substr(l,j-l+1));
				l=j+1;
			}
		}
		res+=stod(s.substr(l,s.length()-l));
		//dbg(res);
	}
	cout<<res<<endl;
	return 0;
}





Measured memory_bytes: 256
def check_prime(m):
  prime_flag = 1
  counter = 2
  while counter **2 <= m:
    if not m%counter:
      prime_flag = 0
      break
    counter += 1
  return prime_flag


n = int(input())

for i in range(n, 10**6):
  if check_prime(i):
    print(i)
    break

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * What Color?
 */
public class Main {

	static final String[] names = {
			"black",
			"blue",
			"lime",
			"aqua",
			"red",
			"fuchsia",
			"yellow",
			"white",
	};

	static final int[][] colors = {
			{0, 0, 0},
			{0, 0, 255},
			{0, 255, 0},
			{0, 255, 255},
			{255, 0, 0},
			{255, 0, 255},
			{255, 255, 0},
			{255, 255, 255},
	};

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			if (line.equals("0")) break;

			int r, g, b;
			r = parseInt(line.substring(1, 3), 16);
			g = parseInt(line.substring(3, 5), 16);
			b = parseInt(line.substring(5, 7), 16);

			int min = 1 << 29, name = -1;
			for (int i = 0; i < colors.length; i++) {
				int color = (int) Math.pow(r - colors[i][0], 2)
						+ (int) Math.pow(g - colors[i][1], 2)
						+ (int) Math.pow(b - colors[i][2], 2);
				if (color < min) {
					min = color;
					name = i;
				}
			}
			System.out.println(names[name]);
		}
	}
}

Measured memory_bytes: 25700
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  set<ll> S;
  ll tmp;
  REP(i, N) {
    cin >> tmp;
    if (S.count(tmp))
      S.erase(tmp);
    else
      S.insert(tmp);
    }

  cout << S.size() << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
vector<int> prefix_function_kmp(vector<int> s){
    int n=s.size();
    vector<int> pi(n,0);
    for(int i=1;i<n;i++){
        int j=pi[i-1];
        while(j>0&&s[i]!=s[j]){
            j=pi[j-1];
        }
        if(s[i]==s[j]){
            j++;
        }
        pi[i]=j;
    }
    
    return pi;
}

vector<int> search_substring_kmp(vector<int> ns,vector<int> s){
    vector<int> pi=prefix_function_kmp(ns);
    vector<int> result;
    for(int i=2*s.size();i<ns.size()-1;i++){
        if(pi[i]==s.size()){
            result.push_back(i-2*s.size());
        }
    }
    return result;
}

int main(){
    int N;
    cin>>N;
    vi a(N),b(N),A(N),B(N);
    vi vt(3*N+1);
    F0R(i,N){
        cin>>a[i];
    }
    F0R(i,N){
        cin>>b[i];
    }
    vt[N]=-1;
    F0R(i,N){
        A[i]=(a[i]^a[(i+1)%N]);
        vt[N+i+1]=A[i];
        vt[2*N+i+1]=A[i];
        B[i]=(b[i]^b[(i+1)%N]);
        vt[i]=B[i];
    }
    vi ans=search_substring_kmp(vt,A);
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" "<<(b[0]^a[ans[i]])<<endl;
    }



    return 0;
}


Measured memory_bytes: 13568
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int main()
{
    int K, S, length, max;
    cin >> K >> S;
    int x, y, z;
    int ans = 0;

    for (int a = 0; a <= K; a++)
    {
        for (int b = 0; b <= K; b++)
        {
            z = S - a - b;
            if (z >= 0 && z <= K)
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string t;
	cin>>t;
	int ans=INF;
	rep(i,26){
		char c = 'a'+i;
		int x=0;
		int p = t.size();
		for (int j=t.size()-1;j>=0;j--){
			if (t[j]==c){
				x = max(x, p-j-1);
				p=j;
			}
		}
		x = max(x, p);
		ans = min(ans,x);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
    string s1, s2, s3;

    cin>>s1>>s2>>s3;
    s1=toupper(s1[0]);
    s2=toupper(s2[0]);
    s3=toupper(s3[0]);
    cout<<s1<<s2<<s3<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const long long INF = 1LL<<60;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

int main(){
    int r;  cin >> r;
    cout << r*r;
    

    return 0;
}




Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for x in B:
    # 小さい
    sm = bisect.bisect_left(A,x)
    # 大きい
    bi = len(C) - bisect.bisect_right(C,x)
    ans += sm*bi
print(ans)

Measured memory_bytes: 23360
A = [
    [
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0]
    ],
    [
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0]
    ],
    [
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0]
    ],
    [
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0],
      [0,0,0,0,0,0,0,0,0,0]
    ]
  ]

n = gets.chomp.to_i
input_values = []
n.times do
  input_value  = gets.chomp.split.map(&:to_i)
  input_values.push(input_value)
end
for i in 0..(n-1)
  b = input_values[i][0].to_i
  f = input_values[i][1].to_i
  r = input_values[i][2].to_i
  v = input_values[i][3].to_i
  A[b-1][f-1][r-1] += v
end

for i in 0..2
  for j in 0..2
    print " "
    print A[i][j].join(' ')
    print"\n"
  end
  print "####################\n"
end

for i in 0..2
  print " "
  print A[3][i].join(' ')
  print"\n"
end

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

using namespace std;

int main()
{
    /*
    int n;
    cin >> n;
    int h[n] , ans[n];
    for (int i=0; i<n; i++)
        cin >> h[i];
    ans[0]=0 , ans[1]=abs(h[1]-h[0]);
    for (int i=2; i<n; i++)
    {
        ans[i] = min(abs(h[i]-h[i-1])+ans[i-1] , abs(h[i]-h[i-2])+h[i-2]);
    }
    cout << ans[n-1] << "\n";
    */

    int n,k;
    cin >> n >> k;
    int h[n] , ans[n];
    for (int i=0; i<n; i++)
        cin >> h[i];
    ans[0]=0 , ans[1]=abs(h[1]-h[0]);
    for (int i=2; i<n; i++)
    {
        ans[i]=1e9;
        for (int j=i-1; j>=max(0,i-k); j--)
            ans[i] = min(ans[i] , abs(h[i]-h[j])+ans[j]);
    }
    cout << ans[n-1] << "\n";

    return 0;
}


Measured memory_bytes: 1024