akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define ll long long
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    string s;
    ll k;
    cin >> s >> k;

    ll cnt = 1;
    vector<ll> v;
    int slen = s.length();
    reps(i, 1, slen-1){
        if(s[i] == s[i-1])cnt++;
        else{
            if(cnt > 1){
                v.push_back(cnt);
                cnt = 1;
            }
        }
    }
    if(cnt > 1) v.push_back(cnt);

    ll res = 0;
    if(cnt == slen) res = slen*k/2;
    else{
        for(auto const& vv : v) res += vv/2;
        res *= k;
        if(s[0] == s[slen-1]){
            res -= (v[0]/2 + v[sz(v)-1]/2 - (v[0] + v[sz(v)-1])/2) * (k-1);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#define FOR(i, min, max) for(int (i) = (min); (i) < (max); (i)++)
#define MAX(a,b) ((a) > (b) ? (a) : (b)) 
#define SWAP(a,b) { int r = a; a = b; b = r; }

#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int stable(string c[], string z[], int n)
{
	bool order = true;
	FOR(i, 0, n - 1)
	{
		cout << c[i] << " ";
	}
	cout << c[n - 1] << endl;
	FOR(i, 1, n)
	{
		if (c[i][1] == c[i - 1][1])
		{
			bool ch = false;
			FOR(j, 0, n)
			{
				if (c[i] == z[j])
					ch = true;
				if (z[j] == c[i - 1])
				{
					if (ch)
						order = false;
					else
						break;
				}
			}
			if(!order)
				break;
		}
	}
	if (order)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	return 0;
}
int main()
{
	int n;
	string a[100], c[100], z[100];
	cin >> n;
	FOR(i, 0, n)
	{
		string s;
		cin >> s;
		a[i] = s;
		c[i] = s;
		z[i] = s;
	}
	FOR(i, 0, n) //bubble
	{
		for (int j = n - 1; j > i; j--)
		{
			if (a[j][1] < a[j - 1][1])
			{
				string str = a[j];
				a[j] = a[j - 1];
				a[j - 1] = str;
			}
		}
	}
	stable(a, z, n);
	FOR(i, 0, n) //select
	{
		int minj = i;
		FOR(j, i, n)
		{
			if (c[j][1] < c[minj][1])
				minj = j;
		}
		if (c[i][1] != c[minj][1])
		{
			string str = c[i];
			c[i] = c[minj];
			c[minj] = str;
		}
	}
	stable(c, z, n);
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
	    
	    
	    using namespace std;
	
	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod  1000000007
	    #define PI 3.141592653589793238462643383279
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	    

	ll d,x,y;
	void extendedEuclid(ll A, ll B) 
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p) 
	{ 
	    ll res = 1; 
	    x = x % p;
	    while (y > 0) 
	    {  // If y is odd, multiply x with result 
	        if (y & 1) 
	            res = (res*x) % p;
	            
	        y = y>>1; 
	        x = (x*x) % p;   
	    } 
	    return res; 
	} 



map<ll,ll> par,val;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;
		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
		par[y]=par[x];
}

int gcdExtended(int a, int b, int *x, int *y) 
{ 

    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    int x1, y1;
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1;
    return gcd; 
}  
int modInverse(int b, int m) 
{ 
    int x, y; 
    int g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
}
ll isPrime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}

int main()
{
	FAST;
	ll n,i,j,k;
	ll l;
	ll m =inf;
	cin>>n>>l;
	ll ans=0;
	ll f=1;
	for(i=0;i<n;i++)
	{	
		//cout<<l+i<<endl;
		if(m>abs(l+i))
		{
			m=abs(l+i);
			if(l+i>0)
				f=-1;
		}
		ans+=l+i;
	}
	//cout<<f<<" ";
	cout<<ans+f*m;
}

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


int main(){
	int N;
	int array[100010]={};
//	bool check[100010]={};
	int answer=0;
	
	cin >> N;
	
	for(int i=1;i<=N;i++){
		cin >> array[i];
	}
	/*
	for(int i=1;i<=N-1;i++){
		if(array[i]==i&&array[i+1]==i+1){
			int memo=array[i];
			array[i]=array[i+1];
			array[i+1]=memo;
			answer++;
			i++;
		}
	}*/
	
	for(int i=1;i<=N-1;i++){
		if(array[i]==i){
			int memo=array[i];
			array[i]=array[i+1];
			array[i+1]=memo;
			answer++;
		}
	}
	
	if(array[N]==N){
		answer++;
	}

	
	cout << answer << endl;
	return 0;
}

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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
using ll = long long;
using pii =  pair<int, int>;
 
const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;
 
#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
 
#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)
 
#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second
 
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))
 
#define endl '\n'
 
const int limit = 100007;
int Q,H,S,D,N;
 
 
signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
 
  cin>>Q>>H>>S>>D>>N;
 
  int a=min(4*Q,min(2*H,S));
  int b=min(2*a,D);
  int c,d;
  c=N/2;
  d=N%2;
  
  cout<<b*c+a*d<<endl;
  
 
  return 0;
}
 

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int Q = stdIn.nextInt();
		while(Q-- != 0)
		{
			int N = stdIn.nextInt();
			int count = 0;
			TreeSet<Integer> isExist = new TreeSet<Integer>();
			while(true)
			{
				if(N < 10)
				{
					System.out.println(count);
					break;
				}
				int digit = 0;
				int NBuf = N;
				while(NBuf != 0)
				{
					NBuf /= 10;
					++digit;
				}
				int max = 0;
				int a = 10;
				for(int i = 1; i < digit; ++i)
				{
					int left = N / a;
					int right = N % a;
					if(left * right > max)
					{
						max = left * right;
					}
					a *= 10;
				}
				if(isExist.contains(max))
				{
					System.out.println(-1);
					break;
				}
				else
				{
					isExist.add(max);
				}
				N = max;
				++count;
			}
		}
	}
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        g: [(String, i64); n],
    }

    let mut g: Vec<_> = g.into_iter().enumerate().collect();
    g.sort_by_key(|&(_, (ref a, b))| (a.clone(), -b));
    for (i, _) in g {
        println!("{}", i + 1);
    }
}


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

namespace A___ABC_Swap
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var temp = input[0];
            input[0] = input[1];
            input[1] = temp;

            var temp2 = input[0];
            input[0] = input[2];
            input[2] = temp2;

            Console.WriteLine( string.Join(" ", input));
        }
    }
}


Measured memory_bytes: 11348
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var ans = new int[S.Length];
            var sta = 0;
            var idx = 0;
            while (idx < S.Length)
            {
                var cntR = 0;
                var cntL = 0;
                var staL = -1;
                while (true)
                {
                    if (S[idx] == 'R') cntR++;
                    else
                    {
                        staL = idx;
                        break;
                    }
                    idx++;
                }
                while (idx < S.Length)
                {
                    if (S[idx] == 'L') cntL++;
                    else
                    {
                        sta = idx;
                        break;
                    }
                    idx++;
                }
                if (cntR % 2 == 0)
                {
                    ans[staL - 1] += cntR / 2;
                    ans[staL] += cntR / 2;
                }
                else
                {
                    ans[staL - 1] += (cntR + 1) / 2;
                    ans[staL] += cntR / 2;
                }
                if (cntL % 2 == 0)
                {
                    ans[staL - 1] += cntL / 2;
                    ans[staL] += cntL / 2;
                }
                else
                {
                    ans[staL - 1] += cntL / 2;
                    ans[staL] += (cntL + 1) / 2;
                }
            }

            Console.WriteLine(string.Join(" ", ans));
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
import java.util.StringTokenizer;
 
public class Main {
 
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		DreamTask solver = new DreamTask();
		solver.solve(1, in, out);
		out.close();
 
	}
	static class DreamTask{
		
		public void solve(int testcaseNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt(), k= in.nextInt(), l = in.nextInt();
			UF road = new UF(n);
			UF rail = new UF(n);
			int x,y;
			for(int i = -1; ++i < k;) {
				x = in.nextInt(); y = in.nextInt();
				road.union(x,y);
			}
			for(int i = -1; ++i < l;) {
				x = in.nextInt(); y = in.nextInt();
				rail.union(x,y);
			}
			
			HashMap<pair, Integer> map = new HashMap<pair, Integer>();
			pair[] vp = new pair[n+1];
			for(int i = 0; ++i <= n;) {
				pair p = new pair(road.root(i), rail.root(i));
				vp[i] = p;
				if(map.containsKey(p)) map.put(p, map.get(p)+1);
				else map.put(p, 1);
			}
			
			for(int i = 0; ++i <= n;) {
				out.print(map.get(vp[i])+" ");
				
			}
			
			
		}
		
	}
	
/*
4
3
6
9
10
 */
	static class pair{
		int f,s;
 
		public pair(int f, int s) {
			this.f = f;
			this.s = s;
		}
		
		@Override
		public boolean equals(Object o) {
			if(o==null||getClass()!=o.getClass()) return false;
			if(this == o) return true;
			pair p = (pair) o;
			return f == p.f && s == p.s;
			
		}
		
		@Override
		public int hashCode() {
			return Objects.hash(f,s);
		}
	}
	static class UF{
		int[] u;
 
		public UF(int n) {
			u = new int[n+5];
			Arrays.fill(u,-1);
		}
		
		public int root(int x) {return u[x] <0?x:(u[x] = root(u[x]));}
		public void union(int x, int y) {
			x = root(x); y=root(y);
			if(x!=y) {u[x]+=u[y];u[y] = x;}
		}
		
	}
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		public String next() {
			while(tokenizer==null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
 
}

Measured memory_bytes: 77228
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans=0;
string s;
int32_t main(){
CODE_START;
cin >> s;
n=s.size();
ll last=s[0];
for(ll i=1;i<n;i++){
    if(s[i]!=last){
        ans++;
    }
    last=s[i];
}
cout<<ans;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100000;
int a[MAXN+5],x[MAXN+5];
int n,sum,s;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
		if(i%2==0)
			s+=a[i];
	}
	x[1]=sum-2*s;
	for(int i=1;i<=n-1;i++)
		x[i+1]=2*a[i]-x[i];
	for(int i=1;i<=n;i++)
		if(i==n)
			printf("%d\n",x[i]);
		else
			printf("%d ",x[i]);
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
char s[max_n];
int main(){
    scanf(" %s",s+1);
    int n=strlen(s+1);
    string pre="";
    int ans=0;
    for(int i=1;i<=n;i++){
        string now="";
        now+=s[i];
        if(now==pre){
            if(i==n)continue;
            else{
                i++;
                now+=s[i];
                ans++;
            }
        }
        else ans++;
        pre=now;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using ld = long double;
using namespace std;

const ld pi = acos(-1);

int main(){
	int n, l; cin >> n >> l;
	vector<int> t(n);
	for( auto &k : t ) cin >> k;
	ld ccx = 0; 
	ld ccy = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = i+1; j < n; ++j ){
			ld theta = pi*(t[i]+t[j])/l;
			int an = j-i-1;
			ccx += cos(theta)*(n-2-an);
			ccy += sin(theta)*(n-2-an);
			ccx -= cos(theta)*an;
			ccy -= sin(theta)*an;
		}
	}
	cout << fixed << setprecision(21) << ccx*6/n/(n-1)/(n-2) << ' ' << ccy*6/n/(n-1)/(n-2) << endl;
}

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



int main() {
    int a,b;
    cin >> a >> b;
    int x = a/b;
    int y = a%b;
    double z = (double)a/b;
    printf("%d %d %f", x, y, z);
    
    return 0;
}


Measured memory_bytes: 3192
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s;
    char now;

    now = 'A';
    for(;sc.hasNext();){
      s = sc.next();
      if(s.charAt(0) == now)now = s.charAt(2);
      else if(s.charAt(2) == now)now = s.charAt(0);
    }
    out.println(now);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17324
#include<bits/stdc++.h>
#define N 200005
#define M 4005
#define mod 1000000007
#define ll long long
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n,f[M][M],a[N],b[N];
ll ans=0,ifac[8005],fac[8005];
inline ll calc(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;}
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read(),b[i]=read(),++f[2001-a[i]][2001-b[i]];
	for(int i=1;i<=4001;++i)for(int j=1;j<=4001;++j)f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	fac[0]=1,ifac[1]=1;
	for(int i=1;i<=8002;++i)fac[i]=fac[i-1]*1ll*i%mod;
	for(int i=2;i<=8002;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;
	for(int i=2;i<=8002;++i)(ifac[i]*=ifac[i-1])%=mod;
	for(int i=1;i<=n;++i)(ans+=f[2001+a[i]][2001+b[i]])%=mod;
	for(int i=1;i<=n;++i)ans=((ans-calc((a[i]+b[i])<<1,b[i]<<1))%mod+mod)%mod;
	ans=ifac[2]*ans%mod;
	cout<<ans;
	return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int T; cin >> T;
   while (T--) {
      int N; cin >> N;
      vector<int64_t> A(N);
      for (int i = 0; i < N; ++i) cin >> A[i];
      string S; cin >> S;
      vector<int64_t> basis(60);
      for (int i = N - 1; i >= 0; --i) {
         int64_t v = A[i];
         while (v) {
            int lg = __lg(v);
            if (basis[lg]) {
               v ^= basis[lg];
            } else {
               if (S[i] == '1') {
                  cout << "1\n";
                  goto next_test;
               } else {
                  basis[lg] = v;
                  break;
               }
            }
         }
      }
      cout << "0\n";
      next_test:;
   }
}


Measured memory_bytes: 3592
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine().toLowerCase();
		int count=0;
		
		while(true){
			String[] line = sc.nextLine().split(" ");
			if(line[0].equals("END_OF_TEXT")){
				break;
			}
			for(int i=0;i<line.length;i++){
				if(w.equals(line[i].toLowerCase())){
					count+=1;
				}
			}
		}
		System.out.println(count);
	}
}	

Measured memory_bytes: 26088
#include <bits/stdc++.h>
//#include <ext/rope>

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[int((s).size())-1]
#define prelast(s) (s)[int((s).size())-2]
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define elif else if
#define left asdasd
#define next zaza

#define cclear cout<<flush;
#define x0 kerker
#define time chas
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define files freopen("a.in", "r", stdin);freopen("a.out", "w", stdout);
#define ref svyazi
#define int long long
#define ii pair<int, int>
#define ld long double
#define list spisok


using namespace std;
//using namespace __gnu_cxx;

int n,k;
main(){
    kchay;
    cin >> n >>k;
    cout<<(n-1)*(k-1);
}


Measured memory_bytes: 256
#include<iostream>//Disjoint Set:Union Find Tree
#include <vector>
using namespace std;

class DisjointSet{
public:
  vector<int> rank,p;

  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }

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

  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }

  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }

  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n,m;

  cin>>n>>m;
  int q[n+1]={};
  DisjointSet ds(n+1);

  for(int i=1;i<=n;i++) cin>>q[i];
  for(int i=1;i<=m;i++){
    int x,y;
    cin>>x>>y;
    ds.unite(x,y);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(i==q[i]||ds.same(i,q[i])){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int  a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d)cout<<"Right"<<endl;
	if(a+b==c+d)cout<<"Balanced"<<endl;
	if(a+b>c+d)cout<<"Left"<<endl;
	return 0;
	}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

VV<int> e;
V<ll> v;

bool dfs(int now,int pre){
  if(siz(e[now])==1)return true;

  ll sum=0,nex,rem;
  V<ll> c(0);
  for(auto&& to:e[now]){
    if(to==pre)continue;
    if(!dfs(to,now))return false;

    c.pb(v[to]);
    sum+=v[to];
  }
  if(sum<v[now])return false;

  nex=2*v[now]-sum;
  if(pre==-1 && nex!=0)return false;  
  
  rem=(sum-nex);
  v[now]=nex;

  rep(i,0,siz(c)){
    if(c[i]>rem/2)nex-=c[i]-(rem/2);
  }

  if(nex<0)return false;
  else return true;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  e.assign(n,V<int>(0));
  v.resize(n);

  rep(i,0,n)cin>>v[i];
  rep(i,0,n-1){
    int a,b;cin>>a>>b;
    a--;b--;
    e[a].pb(b);
    e[b].pb(a);
  }

  if(n==2){
    if(v[0]==v[1])cout<<"YES"<<ENDL;
    else cout<<"NO"<<ENDL;
    return 0;
  }

  rep(i,0,n){
    if(siz(e[i])>1){
      if(dfs(i,-1))cout<<"YES"<<ENDL;
      else cout<<"NO"<<ENDL;
      return 0;
    }
  }

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?


Measured memory_bytes: 18720
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        StringBuilder sb = new StringBuilder();
        HashSet<Integer> hashSet = new HashSet<>();
        final char[] key = new char[128];
        key['A'] = 0;
        key['C'] = 1;
        key['G'] = 2;
        key['T'] = 3;
        for (int i = 0; i < n; i++) {
            String sp = bf.readLine();
            if (sp.charAt(0) == 'i') {
                int hash = 1;
                for (int j = 7; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                hashSet.add(hash);
            } else {
                int hash = 1;
                for (int j = 5; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                sb.append(hashSet.contains(hash) ? "yes\n" : "no\n");
            }
        }
        bf.close();
        System.out.print(sb.toString());
    }
}



Measured memory_bytes: 85388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
int main(){
	int N;
	string s,t;
	cin >> N >> s >> t;
	FOR(i,N,2*N+1){
		int j = i-N;
		string ans = s.substr(0,j) + t;
		if(ans.substr(0,N)==s){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
ll count_val[base10_5]={};


ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;

    ll max_ind = 110;
    for( ll xi = 1 ; xi <=max_ind ; xi++ ){
        for( ll yi = 1 ; yi <=max_ind ; yi++ ){
            for( ll zi = 1 ; zi <=max_ind ; zi++ ){
                ll func = xi*xi+yi*yi+zi*zi + xi*yi + yi*zi + xi*zi;
                if(func < base10_5) count_val[func]++;
            }
        }
    }

    for( ll ni = 1 ; ni <=N ; ni++ ){
        cout << count_val[ni] << endl;
    }

    

}

Measured memory_bytes: 4136
sl=list(input())
tl=list(input())
chara="abcdefghijklmnopqrstuvwxyz"
chl=list(chara)
sl.sort()
tl.sort(reverse=True)
s="".join(sl)
t="".join(tl)

if s<t :
  print("Yes")
else :
  print("No")

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

int main(void) {

  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if ((abs(a-c) <= d)||((abs(a-b)<=d)&&(abs(b-c)<=d))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var temp = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int hp = temp[0];
        int nSkill = temp[1];
        int[] skills = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        Console.WriteLine(skills.Sum() >= hp ? "Yes" : "No");
    }
}

Measured memory_bytes: 20192
#include <stdio.h>

#define INT_MIN 1
#define INT_MAX 1000000000

int gcd(int x, int y);
void swap(int *x, int *y);
int judge_constraint(int test_num, int min, int max);

int main(void){
    int x;
    int y;
    
    scanf("%d%d", &x, &y);
    
    if(judge_constraint(x, INT_MIN, INT_MAX) == -1)
    {
        return -1;
    }
    
    if(judge_constraint(y, INT_MIN, INT_MAX) == -1)
    {
        return -1;
    }
    
    printf("%d\n", gcd(x,y));
    
    return 0;
}

int gcd(int x, int y)
{
    int r;
    
    if(x < y)
    {
        swap(&x, &y);
    }
    
    while(y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    
    return x;
}


void swap(int *x, int *y)
{
    int tmp = *x;
    *x = *y;
    *y = tmp;
    
    return;
}

int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return -1;
    }
    
    return 0;
}

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

int main()
{
    std::string s, t;
    std::cin >> s >> t;
    int ans = 0;
    for (auto i = 0; i < s.size(); ++i)
    {
        if (s[i] != t[i])
        {
            ++ans;
        }
    }

    std::cout << ans;
}

Measured memory_bytes: 3928
using System;
using System;
using System.Collections.Generic;
using System.Linq;


    class Solver5
    {
        /*
         * 
         * https://atcoder.jp/contests/abc115/tasks/abc115_d
         * 
         */
        public void Solve5()
        {
            var nx = u.readUlongArrayBySplit();
            ulong n = (ulong)nx[0];
            ulong x = (ulong)nx[1];
            ulong ans = 0;


            while (true)
            {
                ulong[] thk = new ulong[5]{ 1, (ulong)Math.Pow(2, (n + 1)) - 3, 1, (ulong)Math.Pow(2, (n + 1)) - 3, 1 };
                ulong[] pc = new ulong[5] { 0, (ulong)Math.Pow(2, n) - 1 , 1, (ulong)Math.Pow(2,n) - 1, 0 };
                for (int i = 0; i < 5; i++)
                {
                    if (x>thk[i])
                    {
                     	x-=thk[i];
                        ans += pc[i];
                    }
                    else if (x<thk[i])
                    {
                        n--;
                      	
                        break;
                    }
                    else
                    {
                        ans += pc[i];
                        Console.WriteLine(ans.ToString());
                        return;
                    }
                }

            }

        }
        static void Main()
        {
            var solver = new Solver5();
            solver.Solve5();
        }
    }
    static class u
    {
        public static void outA(int[] A) { Console.WriteLine(string.Join(" ", A)); }
        public static void outInt(int i) { Console.WriteLine(i.ToString()); }
        public static void outLong(long i) { Console.WriteLine(i.ToString()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        public static int readInt() { return int.Parse(Console.ReadLine()); }
        public static  string readStr() { return Console.ReadLine(); }
        public static int[] readIntArrayBySplit() { return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        public static int[] readIntArrayZeroIchiRenzoku() { return Console.ReadLine().Select(s => int.Parse(s.ToString())).ToArray(); }
      　public static ulong[] readUlongArrayBySplit() { return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray(); }

    }

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

public class Main {

	public static void main(String[] args) throws IOException{
		
		InputStreamReader isr= new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		List<Integer>intList = new ArrayList<Integer>();
		String[] strList;
		
		do {
			String strINputNum = br.readLine();
			strList = strINputNum.split(" ");
			
			int intNumX = Integer.parseInt(strList[0]);
			int intNumY = Integer.parseInt(strList[1]);
			
			intList.add(intNumX);
			intList.add(intNumY);
			
		}while(!(strList[0].equals("0") && strList[1].equals("0")));
		
		 int intEndCount = intList.size()-2;
		
		for(int i = 0; i < intEndCount; i = i + 2) {
			int intX= intList.get(i);
			int intY= intList.get(i +1);
			
			if(intX < intY) {
				System.out.println(intX + " " + intY);
			}else {
				System.out.println(intY + " " + intX);
			}
		}
	}
}


Measured memory_bytes: 27416
#include <stdio.h>
#include <string.h>
int main()
{
	int i, j;
	int vis[26] = {0};
	char s[100005];
	char a[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	while(scanf("%s", s)!=EOF)
	{
		memset(vis , 0 ,sizeof(vis));
		int len = strlen(s);
		for(i = 0 ; i < len ; i++)
		{
			for(j = 0 ; j < 26 ;j++)
			{
				if(s[i] == a[j])
				{
					vis[j]++;
				}
			}
		}
		int vis2 = 0;
		for(i = 0 ; i < 26 ;i++)
		{
			if(vis[i] == 0)
			{
				vis2 = 1;
				printf("%c\n", a[i]);
				break;
			}
		}
		if(vis2 == 0)
		{
			printf("None\n");
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  cout<<A.at(N-1)-A.at(0)<<endl;
}

Measured memory_bytes: 256
// B - Golden Apple
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, d;
	cin >> n >> d;
	int ans = n / (d + d + 1) + (n % (d + d + 1) ? 1 : 0);
	cout << ans << endl;

	return 0;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int s;
    cin >> s;

    int upper = s / 100;
    int lower = s % 100;

    bool is_yymm = true;
    bool is_mmyy = true;
    if (upper == 0 || upper > 12) {
        is_mmyy = false;
    }
    if (lower == 0 || lower > 12) {
        is_yymm = false;
    }

    if (is_yymm) {
        if (is_mmyy) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "YYMM" << endl;
        }
    } else {
        if (is_mmyy) {
            cout << "MMYY" << endl;
        } else {
            cout << "NA" << endl;
        }

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

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

const ll mod = 1e9 + 7;
ll find(vector<ll> &root,ll x){
    if (root[x]>=0){
        root[x] = find(root, root[x]);
        return root[x];
    }
    return x;
}
void unit(vector<ll> &root,ll a,ll b){
    ll ra, rb;
    ra = find(root, a);
    rb = find(root, b);
    if (ra==rb){
        return;
    }
    else if (root[ra]<=root[rb]){
        root[ra] += root[rb];
        root[rb] = ra;
    }
    else {
        root[rb] += root[ra];
        root[ra] = rb;
    }
    return;
}
void UnionFind(vector<ll> &root,ll m){
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        unit(root, a, b);
    }
    return;
}

int main(){
    ll N, K, L;
    cin >> N >> K >> L;
    vector<ll> road(N,-1);
    vector<ll> metro(N,-1);
    UnionFind(road, K);
    UnionFind(metro, L);
    vector<pll> idx(N);
    map<pll, int> cnt;
    rep(i,N){
        idx[i] = mp(find(road, i), find(metro, i));
        cnt[idx[i]]++;
    }
    cout << cnt[idx[0]];
    repf(i,1,N){
        cout << " " << cnt[idx[i]];
    }
    cout << endl;
}


Measured memory_bytes: 18048
N,Q=map(int,input().split())
S=input()
l=[0]*Q
r=[0]*Q
for i in range(Q):
  l[i],r[i]=map(int,input().split())

Sac=[0]*N
num=0
for i in range(1,N):
  if S[i]=="C" and S[i-1]=="A":
    num+=1
  Sac[i]=num
#print(Sac)

for i in range(Q):
  print(Sac[r[i]-1]-Sac[l[i]-1])

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for( int i=0 ; i<n ; i++ )
    {
        cin>>a[i];
    }
    int v[ 200001 ]={0};
    int c=1 , C=0;
    for(int i=0 ; i<n ; i++)
    {
        if( a[i] == c && v[ c ]==0 )
            v[c++]=1;
        else
            C++;
    }
    if( C< n )
        cout<<C<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


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

typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007

void solve(){
  int s,w;cin>>s>>w;
  if(s>w)cout<<"safe";
  else cout<<"unsafe";


return ;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
   int t=1;
   //cin>>t;
   rep(i,0,t){
     solve();
  }
return 0;
}

Measured memory_bytes: 3648
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
using namespace std;
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{
	int n,k;
	cin>>n>>k;
	cout<<min(n%k,k-n%k);
}
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int h, a;
  scanf("%d%d", &h, &a);
  printf("%d\n", (h-1)/a+1);
  return 0;
}


Measured memory_bytes: 128
from itertools import product

K = int(input())

def gcd_ab(a, b):
    # print(a, b)
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd_ab(b, a%b)

def gcd(*args):
    r = args[0]
    for arg in args[1:]:
        r = gcd_ab(r, arg)
    return r

sum_num = 0
for a, b, c in product(range(1, K+1), repeat=3):
    sum_num += gcd(a, b, c)

print(sum_num)

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

int main() {
    int N,turn,Apoint=0,Bpoint=0;
    cin>>N;

    vector<int> Card(N);
    vector<int> Alice(N);
    vector<int> Bob(N);

    for(int i=0;i<N;i++){
        cin >>Card.at(i);
    }
    //ここで大きい順にソート
    sort(Card.begin(),Card.end());
    reverse(Card.begin(),Card.end());

    

    for(int k=0;k<N;k++){
        if (turn%2==0){
            //Aliceのターン
            Alice.at(k)=Card.at(k);
            Apoint+=Alice.at(k);
        }

        else if (turn%2==1){
            //Bobのターン
            Bob.at(k)=Card.at(k);
            Bpoint+=Bob.at(k);
        }
        
        turn++;
    }

    if (Bpoint-Apoint<0){
        cout << Apoint-Bpoint << endl;
        }

    else{
        cout << Bpoint-Apoint << endl;
    }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
int a[100010];
int two(int n){
  if(n==0)return -1;
  if(n%2)return 0;
  return 1+two(n/2);
}
signed main(){
  int n,m;cin>>n>>m;
  
  rep(i,n)cin>>a[i];
  int po=0;
  rep(i,n){
    if(a[i]%2){
      cout<<0<<endl;
      return 0;
    }
    if(po!=0 && po!=two(a[i])){
      cout<<0<<endl;
      return 0;
    }
    po=two(a[i]);
    a[i]/=2;
  }
  int L=1;
  rep(i,n){
    if(L>m){
      cout<<0<<endl;
      return 0;
    }
    L*=(a[i]/__gcd(L,a[i]));
  }
  cout<<m/L-m/(2*L)<<endl;
  
  return 0;
}

Measured memory_bytes: 4360
#include <iostream>
#include<vector>
#include<map>
using namespace std;
int main(void){
 
#define ll long long
 
 ll n,m,k;
 cin>>n>>m>>k;
 
 vector<ll> A(n+1),B(m+1);
 A[0]=0;
 B[0]=0;
 int a;
 for(int i=1;i<=n;i++){
    cin>>a;
    A[i]=A[i-1]+a;
 }

for(int i=1;i<=m;i++){
    cin>>a;
    B[i]=B[i-1]+a;
}

int j=m, answer=0;
for (int i = 0; i <=n; i++)
    {
        if (A[i] > k)
        {
            break;
        }
        while (B[j] > k - A[i])
        {
            j--;
        }
        answer = answer > (i + j) ? answer : (i + j);
    }
    

cout<<answer;
}

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

int main() {
  string s;
  cin >> s;
  
  bool check = false;
  while(0<s.size()) {
    //cout << s << endl;
    
    if(s.size()<5) {
      check = true;
      break;
    }
    
    if(s[4]=='m') {
      if(s.size()>7) {
        if(s.substr(0,7)=="dreamer" && s[7]=='a') {s = s.substr(5); continue;}
        else if(s.substr(0,7)=="dreamer" && s[7]!='a') {s = s.substr(7); continue;}
        else if(s.substr(0,5)=="dream") {s = s.substr(5); continue;}
        else check = true;
      }
      else if(s=="dream") {s = ""; continue;}
      else if(s=="dreamer") {s = ""; continue;}
      else check = true;
    }
    
    else {
      if(s.size()>6) {
        if(s.substr(0,6)=="eraser") {s = s.substr(6); continue;}
        else if(s.substr(0,5)=="erase") {s = s.substr(5); continue;}
        else check = true;
      }
      else if(s=="erase") {s = ""; continue;}
      else if(s=="eraser") {s = ""; continue;}
      else check = true;
    }
    
    if(check) break;
  }
  
  if(check) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

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

struct UnionFind {
  vector<int> par;
  
  UnionFind(int N) : par(N){
    for(int i = 0; i < N; i++) par[i] = i;
  }
  
  int root(int x){
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  bool unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return false;
    par[rx] = ry;
    return true;
  }
  
  bool same(int x, int y){
    return root(x) == root(y);
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  int ans = 0;
  rep(i, m){
    UnionFind tree(n);
    rep(j, m) if (i != j) tree.unite(a[j], b[j]);
    rep(j, n){
      if (!tree.same(0, j)){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
   
    int n;
    int t,a;
    cin >> n >> t >> a;
    vector <long long> h;
    for (int i=0;i<n;i++){
        long long q;
        cin >> q;
        h.push_back(q);
    }
    long ans;
    double mindif;
    mindif = 1000000;
    ans = 0;
    for (int i=0;i<n;i++){
        double check = abs(a-(t-0.006*h[i]));
        if(check < mindif){
            mindif = check;
            ans = i+1;
        }

    }
    cout << ans << endl;


}

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

#define ll          long long

#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
ll ans(ll n,ll m) 
{ 
    ll bN[32],bM[32]; 
    ll i = 0; 
    while (n > 0) { 
        bN[i] = n % 2; 
        n = n / 2; 
        i++; 
    } 
    ll k = 0; 
    while (m > 0) { 
        bM[k] = m % 2; 
        m = m / 2; 
        k++; 
    } 
    ll num=0;
    for (int j=0;j<=k-1&&j<=i-1;j++) 
       {
           if(bN[j]==1&&bM[j]==1) num+=pow(2,j);
       }
       return num;
} 
int solve(){
    string s,t;
    cin>>s>>t;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i]) return 0;
        
    }
    return 1;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        if(solve()) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3680