akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;

const int t[6][4] = {
	{1, 2, 4, 3},
	{0, 3, 5, 2},
	{0, 1, 5, 4},
	{0, 4, 5, 1},
	{0, 2, 5, 3},
	{1, 3, 4, 2},
};

P north(const P& p){
	int a = p.first;
	int b = p.second;
	int c = t[a][b];
	int d = find(t[c], t[c] + 4, 5 - a) - t[c];
	return P(c, d);
}

P east(const P& p){
	int a = p.first;
	int b = p.second;
	int c = t[a][(b + 3) % 4];
	int d = find(t[c], t[c] + 4, t[a][b]) - t[c];
	return P(c, d);
}

P west(const P& p){
	int a = p.first;
	int b = p.second;
	int c = t[a][(b + 1) % 4];
	int d = find(t[c], t[c] + 4, t[a][b]) - t[c];
	return P(c, d);
}

P south(const P& p){
	int a = p.first;
	int b = p.second;
	int c = t[a][(b + 2) % 4];
	int d = find(t[c], t[c] + 4, a) - t[c];
	return P(c, d);
}

P right(const P& p){
	int a = p.first;
	int b = p.second;
	return P(a, (b + 1) % 4);
}

P left(const P& p){
	int a = p.first;
	int b = p.second;
	return P(a, (b + 3) % 4);
}

map<char, P (*)(const P&)> f = {
	{'N', north},
	{'E', east},
	{'W', west},
	{'S', south},
	{'R', right},
	{'L', left}
};

int n;

int main(){
	while(1){
		cin >> n;
		if(!n){
			break;
		}

		P p(0, 0);
		int ans = 1;
		rep(i, n){
			string s;
			cin >> s;
			p = f[s[0]](p);
			ans += p.first + 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
package main

import "fmt"

func main() {
	var m, f, r int
	var a string
	for {
		fmt.Scan(&m, &f, &r)

		if m == -1 && f == -1 && r == -1 {
			return
		}

		if m == -1 || f == -1 {
			a = "F"
		} else {
			sum := m + f
			if 80 <= sum {
				a = "A"
			} else if 65 <= sum && sum < 80 {
				a = "B"
			} else if 50 <= sum && sum < 65 {
				a = "C"
			} else if 30 <= sum && sum < 50 {
				if 50 <= r {
					a = "C"
				} else {
					a = "D"
				}
			} else if sum < 30 {
				a = "F"
			}
		}

		fmt.Println(a)
	}
}



Measured memory_bytes: 1120
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		string mes;
		cin >> mes;
		rep(i,mes.length()) mes[i] -= 'a';
		vector<P> proc(N);
		rep(i,N) cin >> proc[i].first >> proc[i].second;
		reverse(all(proc));
		rep(i,N) {
			int a = proc[i].first;
			int b = proc[i].second;
			int diff = abs(a-b);
			mes[a-1] = (mes[a-1] + diff ) % (26);
			mes[b-1] = (mes[b-1] + diff ) % (26);
			//cerr << char(mes[a-1] + 'a' ) << "&" << char(mes[b-1] + 'a' ) << endl;

			swap(mes[a-1], mes[b-1]);
		}
		rep(i,mes.length()) mes[i] += 'a';
		cout << mes << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 
using namespace std;
int main()
 
{
    int a,b;
    cin>>a>>b;
    
    if(  a % 3 == 0 or  b % 3 == 0 or (a+b) % 3 == 0 ){
        cout<<"Possible"<<endl;
    }
    
    else cout<<"Impossible"<<endl;
    
  return 0;
}

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

int main() {
int n,m;
  cin>>n>>m;
  if(n%2==1){
  for(int i=0;i<m;i++){
  cout<<i+1<<" "<<n-i-1<<endl;
  }}
    else{
    vector<int> one((n-2)/2);
    vector<int> two((n-2)/2);
      int a=(n/4)*2;
      for(int i=0;i<a/2;i++){one.at(i)=i+1;}
      for(int i=0;i<a/2;i++){two.at(i)=a-i;}
      for(int i=a/2;i<(n-2)/2;i++){one.at(i)=i+(a/2)+1;}
      for(int i=a/2;i<(n-2)/2;i++){two.at(i)=n+(a/2)-i-1;}
      for(int i=0;i<m;i++){
      cout<<one.at(i)<<" "<<two.at(i)<<endl;}
    }
  
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      Int n = ss.size();
      Int t = 0;
      if( n % 2 == 1 ) t += 1;
      for(Int i = n / 2 - 1; i >= 0; --i) {
         if( ss[i] == ss[n-i-1] and ss[i] == ss[n/2] ) t += 2;
         else break;
      }
      dumpl(t);
      Int res1 = (n + t) / 2;
      // Int res2 = -1;
      // for(Int i = 1; i < n; ++i) {
      //    if( ss[i-1] != ss[i] ) {
      //       res2 = i;
      //       break;
      //    }
      // }
      // Int res3 = -1;
      // for(Int i = n - 1; i >= 1; --i) {
      //    if( ss[i-1] != ss[i] ) {
      //       res3 = n - i;
      //    }
      // }
      // Int res = std::max(std::max(res1, res2), res3);
      Int res = res1;
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 512
import sys
sdin = sys.stdin.readline

from collections import defaultdict, Counter

h, w, n = map(int, sdin().split())
ab = []
for _ in range(n):
    ab.append(tuple(map(int, sdin().split())))
    
# フィールドを作って塗る
field = defaultdict(int)
grid_num = (h-2)*(w-2)

x = [-1,-1,-1, 0, 0, 0, 1, 1, 1]
y = [-1, 0, 1,-1, 0, 1,-1, 0, 1]

for a, b in ab:
    for dx,dy in zip(x, y):
        if a+dx > 1 and a+dx < h and b+dy > 1 and b+dy < w:
            field[(a+dx, b+dy)] += 1


# 数え上げる
cnt = Counter(field.values())

for j in range(10):
    if j == 0:
        print(grid_num - sum(cnt.values()))
    else:
        print(cnt[j])    

Measured memory_bytes: 180400
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int h,w;
  while(cin>>h>>w,h,w){
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if((i%2==1 && j%2==1) || (i%2==0 && j%2==0)){
	  cout<<'#';
	}
	else{
	  cout<<'.';
	}
	if(j==w-1){
	  cout<<'\n';
	}
      }
    }
    cout<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int  main()
{
    int k,x;
    cin>>k>>x;
    int p=k-1;
    int e=p;
    int r=x-p;
    while(p--)
    {
        cout<<r++<<" ";
    }
    cout<<x<<" ";
    int d=x+1;
   while(e--)
    {
        cout<<d++<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m,c = input().split()
b = input().split()
n = int(n)
m = int(m)
c = int(c)
for i in range(m):
    b[i] = int(b[i])
count = 0
for i in range(n):
    a = input().split()
    ans = 0
    for j in range(m):
        a[j] = int(a[j])
        ans += a[j] * b[j]
    ans += c
    if ans > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll w,h,x,y;
    std::cin >> w>>h>>x>>y;
    double s = 1.0*w*h/2.0;
    if(w%2==0 && h%2==0 && x == w/2 && y == h/2){
        std::cout << setprecision(10)<<s<<" "<<1<< std::endl;
    }else{
        std::cout << setprecision(10);
        std::cout << s<<" "<<0<< std::endl;
    }
    
}


Measured memory_bytes: 384
c = []
for i in range(3):
    c.append([int(i) for i in input().split()])

ans = True
for i in range(2):
    if c[0][i] - c[0][i + 1] == c[1][i] - c[1][i + 1] == c[2][i] - c[2][i + 1]:
        pass
    else:
        ans = False
for j in range(2):
    if c[j][0] - c[j][0] == c[j][1] - c[j][1] == c[j][2] - c[j][2]:
        pass
    else:
        ans = False
if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){




     int d,t,s;
     cin>>d>>t>>s;

     if (s*t>=d){
         cout<<"Yes"<<endl;
     }
    else {
        cout<<"No"<<endl;
    }





}

Measured memory_bytes: 3620
N = int(input())

def luka(n):
    luka_memo = [-1 for i in range(87)]
    luka_memo[0] = 2
    luka_memo[1] = 1
    for i in range(2,n+1):
        luka_memo[i] = luka_memo[i-1] + luka_memo[i-2]
    return luka_memo[n]

print(luka(N))

Measured memory_bytes: 3060
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		a: isize,
		b: isize,
		c: isize,
		d: isize,
	}

	let a1 = a*c;
	let a2 = a*d;
	let a3 = b*c;
	let a4 = b*d;

	println!("{}", max(max(a1,a2), max(a3, a4)));
}


Measured memory_bytes: 2200
import collections
n = int(input())
a = list(map(int, input().split()))
dd = collections.defaultdict(int)
correct = []
if n % 2 == 1:
    correct.append(0)
    for i in range((n - 1) // 2):
        correct.append(2 * i + 2)
        correct.append(2 * i + 2)
else:
    correct.append(1)
    correct.append(1)
    for i in range(n // 2):
        correct.append(2 * i + 3)
        correct.append(2 * i + 3)
a.sort()
correct.sort()
for i in range(n):
    if a[i] != correct[i]:
        print(0)
        exit()
for i in range(n):
    dd[str(a[i])] += 1
ans = 1
for k in dd.keys():
    if dd[k] >= 2:
        ans *= 2
        ans %= 10 ** 9 + 7
print(ans)

Measured memory_bytes: 20028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,M;
  cin>>N>>M;
  
  vector<ll>A(N);
  
  ll sum=0;
  
  rep(i,N){
    cin>>A[i];
    sum+=A[i];
  }

  double num=(sum*1.0)/(4*M);
  ll ans=0;
 
  rep(i,N){
   
    if(num<=A[i]){
      ans++;
    }
  }

  if(ans>=M){
    cout<<"Yes"<<endl;
  }
else{
cout<<"No"<<endl;
}

  
}


Measured memory_bytes: 256
# Solved by QBnewb
# Discretization
# off-line

q = int(input())
s = []
rs = [] # for discretization

# download the input
for i in range(q):
    s.append(input().split())
    if s[i][0] == '3':
        rs.append(s[i][1])
        rs.append(s[i][2])
    else:
        rs.append(s[i][1])

rs = sorted(list(set(rs)))
index = {rs[i]:i for i in range(len(rs))} # discretization
d = [None for i in range(len(rs))] # discrete dictionary
for i in range(q):
    op, key = int(s[i][0]), s[i][1]
    idx = index[key]
    if op == 0:
        d[idx] = s[i][2]
    elif op == 1:
        if d[idx] ==None:
            print(0)
        else:
            print(d[idx])
    elif op == 2:
        d[idx] = None
    else:
        l = idx
        r = index[s[i][2]]
        for j in range(l, r+1):
            if d[j] != None:
                print(rs[j], d[j])


Measured memory_bytes: 91240
#define alphanso                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL)
#include <bits/stdc++.h>
using namespace std;
int main()
{
	alphanso;
	string s;
	cin >> s;
	int i, flag = 0;
	for (i = 1; i < s.size(); i++)
	{
		if (s[i] == s[i - 1])
		{
			(s[i] == '1') ? s[i] = '0' : s[i] = '1';
			flag++;
		}
	}
	cout << flag;
	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include<iomanip>

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	cout << a/b << " " << a%b << " " << fixed << setprecision(6) <<  (double)a/b << endl;

	return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-3;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define CHECK cout<<"arrived"<<endl

vec d;
ll N,Q;
vector<P> x;

ll Solve(ll a, ll i){
    if(i==Q) return a;
    if(a==0) return 0;
    if(a==N+1) return N+1;
    if(d[a]!=x[i].first) return Solve(a,i+1);
    return Solve(a+x[i].second,i+1);
}

int main(){
    cin>>N>>Q;
    string S; cin>>S;
    d.pb(26);
    rep(i,N) d.pb(S[i]-'A');
    d.pb(26);
    ll ans=0;
    rep(i,Q){
        char a,b; cin>>a>>b;
        if(b=='R') x.pb(mp(a-'A',1));
        else x.pb(mp(a-'A',-1));
    }
    //CHECK;

    ll OK=0, NG=N+1;
    while(NG>OK+1){
        ll MID=(NG+OK)/2;
        if(Solve(MID,0)==0) OK=MID;
        else NG=MID;
    }
    ans+=OK;
    //cout<<OK<<endl;
    OK=N+1, NG=0;
    while(OK>NG+1){
        ll MID=(NG+OK)/2;
        if(Solve(MID,0)==N+1) OK=MID;
        else NG=MID;
    }
    //cout<<(N+1-OK)<<endl;
    ans+=(N+1-OK);
    cout<<N-ans<<endl;


    

}

Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

int main()
{
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    long long sum = 0;
    RREP(i, s.size())
    {
        sum *= 2;
        long tmp = s[i] - '0';
        int ite = 1;
        int end = s.size() - i -1;
        REP(j, end)
        {
            /* cerr << "j:" << j << ' ' << tmp << '\n'; */
            tmp *= 10;
            tmp += (s[i] - '0') * ite;
            ite *= 2;
        }
        /* cerr << tmp << '\n'; */
        sum += tmp;
    }
    cout << sum << '\n';

}


Measured memory_bytes: 256
N = int(input())
list1 = list(map(int,input().split()))		
no1 = 0
no2 = 0
no3 = 0
for z in range(N):
  if list1[z] % 4 == 0:
    no1 += 1
  elif list1[z] % 2 == 0:
    no2 += 1
  else:
    no3 += 1


if no2 >= 1:
  no3 += 1

if (no1 + 1) >= no3:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 15020
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.ByteString.Char8 as B
import Data.Char
import Control.Monad

put :: VUM.IOVector Int -> Int -> IO ()
put vec i = VUM.read vec i >>= \r -> Prelude.putStr $ show r ++ " "

solve vec n 
    | even n = do
        VU.forM_ (VU.reverse $ VU.fromList [1,3..n-1]) $ put vec
        VU.forM_ (VU.fromList [0,2..n-2]) $ put vec
        Prelude.putStrLn ""
    | otherwise = do
        VU.forM_ (VU.reverse $ VU.fromList [0,2..n-1]) $ put vec
        VU.forM_ (VU.fromList [1,3..n-2]) $ put vec
        Prelude.putStrLn ""

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    xs' <- VU.unsafeThaw xs
    solve xs' n

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

using namespace std;

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

	int n;
	cin >> n;

	set<int> s;

	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		--x;
		
		s.emplace(x);
	}

	int ans = s.size() - (s.size() + 1 & 1);

	cout << ans << '\n';

	return 0;

}


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

int main() {
	std::string s;
	std::cin >> s;
	int a = 0;

	for (int i = 0; i <= 3; i++) {
		if (s.at(i) == '+') {
			a += 1;
		} else if (s.at(i) == '-') {
			a -= 1;
		}
	}

	std::cout << a << std::endl;

	return 0;
}

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

int main(){
  int max=0,min=1000000001,r1,r2,r,dif,n;
  cin>>n>>r1>>r2;
  if(r1>r2){
    max=r1;
    min=r2;
    dif=min-max;
    max=0;
  }
  else{
    max=r2;
    min=r1;
    dif=max-min;
  }

  for(int i=0;i<n-2;i++){
    cin>>r;
    if(r<min){
      min=r;
      max=0;
      goto begin;
    }
    else if(r>max)max=r;
    begin:
    if(dif<max-min)dif=max-min;
  }
  cout<<dif<<endl;
return 0;
}

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

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){ if(a>b) a = b; }
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


// 素因数分解 pair
vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

//  二項係数の計算nCk セット
//  https://drken1215.hatenablog.com/entry/2018/06/08/210000
//  使い方としては、最初に一度前処理として COMinit() をしておけば、あとは COM(n, k) 関数を呼べばよい
//  前処理 COMinit(): O(n)
//　クエリ処理 COM(n, k): O(1)
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    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;
    }
}
// 二項係数計算
long long 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;
}


/*

 *
 * */

int main() {

    int K, A, B;
    cin >> K >> A >> B;

    int ok = 0;
    for (int i = A; i <= B; ++i) {
        if(i % K == 0){
            ok =1;
        }
    }

    string ans;
    if(ok){
        ans = "OK";
    }else{
        ans = "NG";
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long LL;
const int N=2005;
const int MOD=1e9+7;

int n,k,f[N][N],fac[N*N],inv[N*N];

inline int fast_pow(int x,int y){
	int ret=1;
	for(;y;y>>=1){
		if(y&1) ret=(LL)ret*x%MOD;
		x=(LL)x*x%MOD;
	}	
	return ret;
}

inline int C(int x,int y){
	return 1ll*fac[x]*inv[y]%MOD*inv[x-y]%MOD;	
}

int main(){
	scanf("%d%d",&n,&k); if(k==1) {puts("1"); return 0;}
	f[0][0]=1; fac[0]=1;
	for(int i=1;i<=n*k;i++) fac[i]=1ll*fac[i-1]*i%MOD;
	inv[n*k]=fast_pow(fac[n*k],MOD-2);
	for(int i=n*k-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%MOD;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++){
			if(j!=i) f[i][j]=1ll*f[i-1][j]*(n-i+1)%MOD;
			if(j!=0) (f[i][j]+=1ll*f[i][j-1]*C(n*k-(i+(j-1)*(k-1))-1,k-2)%MOD)%=MOD;
		}
	printf("%d\n",f[n][n]);
	return 0;
}	

Measured memory_bytes: 47360
/* 2020/04/09 Atcoder Beginner Contest 077 C - Snuke Festival */

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

using namespace std;

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long cnt = 0;
    for(int i = 0; i < n; i++) {
        int val = b[i];
        long long cnta = lower_bound(a.begin(), a.end(), val) - a.begin();
        long long cntc = n - (upper_bound(c.begin(), c.end(), val) - c.begin());
        cnt += cnta * cntc;
    }

    cout << cnt << endl;

    return 0;
}


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

#define fi first
#define se second
#define CLR(A, X) memset(A, X, sizeof(A))
typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int N = 2e5+5;

int k;
PII b[N], s, t;

double solve() {
    vector<int> g, h;
    for(int i = 0; i < k; i++) {
        int id = lower_bound(g.begin(), g.end(), b[i].se)-g.begin();
        if(id == g.size()) g.push_back(b[i].se), h.push_back(b[i].fi);
        else g[id] = b[i].se, h[id] = b[i].se;
    }
    int n = g.size();
    if(n==t.fi-s.fi+1 || n==t.se-s.se+1) {
        double ans = 100.0*(t.fi-s.fi+t.se-s.se);
        ans += 1.0*(n-1)*(PI/2*10-20.0);
        ans += 1.0*(PI*10-20.0);
        return ans;
    }
    double ans = 100.0*(t.se-s.se+t.fi-s.fi)+1.0*n*(PI/2*10-20.0);
    return ans;
}

int main() {
    scanf("%d%d%d%d", &s.fi, &s.se, &t.fi, &t.se);
    if(t.fi < s.fi) swap(t, s);
    bool f = 1;
    if(t.se < s.se) {
        f = 0;
        s.se = -s.se;
        t.se = -t.se;
    }
    int n; PII x;
    scanf("%d", &n);
    k = 0;
    for(int i = 0; i < n; i++) {
        scanf("%d%d", &x.fi, &x.se);
        if(!f) x.se = -x.se;
        if(x.fi<=t.fi && x.se<=t.se && x.fi>=s.fi && x.se>=s.se)
            b[k++] = x;
    }
    sort(b, b+k);
    double ans = 100.0*(t.fi-s.fi+t.se-s.se);
    if(s.fi==t.fi || s.se==t.se) {
        if(k) ans += 1.0*k*(PI*10-20.0);
        printf("%.15f\n", ans);
        return 0;
    }
    printf("%.15f\n", solve());
    return 0;
}


Measured memory_bytes: 3572
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[5011];
bitset<5011> dp[5011];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int lo=0; int hi=n-1;
	int ans=n;
	while(lo<=hi)
	{
		int mid=(lo+hi)>>1;
		//check if a[mid] is neccesary
		dp[0].reset();
		dp[0].set(0,1);
		for(int i=1;i<=n;i++)
		{
			dp[i]=dp[i-1];
			if(i-1!=mid&&a[i-1]<=k) dp[i]|=(dp[i-1]<<a[i-1]);
		}
		bool pos=0;
		for(int i=max(0,k-a[mid]); i < k; i++)
		{
			pos|=dp[n][i];
		}
		if(pos)
		{
			ans=mid;
			hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
long long gcd(long long a, long long b)
{
    long long r=0, t=0;

    while(b!=0){
        r=a%b;
        a=b;
        b=r;
    }

    return a;
}
long long lcm(long long a, long long b)
{
    return a/gcd(a, b)*b;
}
int main(void)
{
    long long a, b, c, d, ans;
    long long bc, ac, bd, ad, acd, bcd;
    cin >> a >> b >> c >> d;

    bc=b/c;
    ac=(a-1)/c;
    bd=b/d;
    ad=(a-1)/d;
    acd=(a-1)/lcm(c, d);
    bcd=b/lcm(c,d);
    ans=b-bc-bd+bcd-(a-1-ac-ad+acd);
    cout << ans <<endl;
        
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] aArr = new int[n];

        for (int i = 0; i < n; i++) {
            aArr[i] = sc.nextInt();
        }

        Arrays.sort(aArr);

        int children = 0;
        for (int i = 0; i < n; i++) {
            x -= aArr[i];
            if (x < 0) break; // 子供がもらう飴の数の方が多い場合

            children++;
        }

        System.out.println(x > 0 ? children-1 : children);// 配る飴の数が余っている場合は最後の子供に全て渡す
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n],b[n+1]={};
  map<long long, long long> mp;
  mp[b[0]]++;
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i+1]=a[i]+b[i];
    mp[b[i+1]]++;
  }
  for(int i=0;i<=n;i++){
    ans+=(mp[b[i]]*(mp[b[i]]-1))/2;
    mp[b[i]]=0;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
using namespace std;
int n,e,s[14],h[14],c[14],d[14];
char m;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf(" %c%d",&m,&e);
		if(m=='S') s[e]++;
		else if(m=='H') h[e]++;
		else if(m=='C') c[e]++;
		else if(m=='D') d[e]++;
	}
	for(int i=1;i<=13;i++){
		if(s[i]==0) printf("S %d\n",i);
	}
	for(int i=1;i<=13;i++){
		if(h[i]==0) printf("H %d\n",i);
	}
	for(int i=1;i<=13;i++){
		if(c[i]==0) printf("C %d\n",i);
	}
	for(int i=1;i<=13;i++){
		if(d[i]==0) printf("D %d\n",i);
	}
	return 0;
}


Measured memory_bytes: 3200
N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]
TD += [[0, 0]]
TD.sort(key = lambda x: x[1], reverse = True)
TD.sort(key = lambda x: x[0]) #ネタの種類、おいしさを、ネタの種類でソート

lst = []
for i in range(1, N + 1):
    if TD[i-1][0] != TD[i][0]:
        lst += [[TD[i][1], 1]]
    else:
        lst += [[TD[i][1], 0]]

lst.sort(key = lambda x: x[1], reverse = True)
lst.sort(key = lambda x: x[0], reverse = True)
# print (lst)

total = 0
kind = 0
lst2 = []
for i in range(K):
    total += lst[i][0]
    if lst[i][1] == 1:
        kind += 1
    else:
        lst2 += [lst[i][0]]

ans = total + kind * kind
# print (total, ans)
# print (lst2)
n = len(lst2)
j = K
for i in range(n):
    flag = True
    while flag:
        if j >= N:
            print (ans)
            exit()
        if lst[j][1] == 1: #ネタの種類が増えるものだけ考える
            # print (lst[j])
            total += lst[j][0]
            kind += 1
            # print (lst2[n-1-i])
            total -= lst2[n-1-i]
            ans = max(ans, total + kind * kind)
            flag = False
            j += 1
        else:
            j += 1
print (ans)


Measured memory_bytes: 36408
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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 (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

struct Node
{
    int num;
    Node *left, *right, *parent;
    Node(int _num) : num(_num){
        left = nullptr;
        right = nullptr;
        parent = nullptr;
    }
    int construct(vector<int> &pre, vector<int> &mid, int le, int ri, int cnt) {
        if(le <= mid[pre[cnt+1]] && mid[pre[cnt+1]] < mid[num]) {
            left = new Node(pre[cnt+1]);
            ++cnt;
            cnt = left->construct(pre, mid, le, mid[num], cnt);
        }
        if(mid[num]+1 <= mid[pre[cnt+1]] && mid[pre[cnt+1]] < ri) {
            right = new Node(pre[cnt+1]);
            ++cnt;
            cnt = right->construct(pre, mid, mid[num]+1, ri, cnt);
        }
        return cnt;
    }
    void postoder(vector<int> &ret) {
        if(left) left->postoder(ret);
        if(right) right->postoder(ret);
        ret.push_back(num+1);
    }
};


int main() {
    int n; cin >> n;;
    vector<int> pre(n);
    rip(i,n,0) {
        cin >> pre[i];
        --pre[i];
    }
    vector<int> mid(n);
    rip(i,n,0) {
        int tmp;
        cin >> tmp;
        mid[tmp-1] = i;
    }
    Node root(pre[0]);
    pre.push_back(n);
    mid.push_back(-1);
    root.construct(pre, mid, 0, n, 0);
    vector<int> ans(0);
    root.postoder(ans);
    vdeb(ans);
}


Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<vector>

using namespace std;

struct teme {
	int num;
	int caPro;
	int sumtime;
	int pro[11];
};

void temeset(teme* t, int yoso) {
	for (int i = 1; i <= yoso; i++) {
		t[i].num = i;
		t[i].caPro = 0;
		t[i].sumtime = 0;
		for (int j = 1; j <= 10; j++) {
			t[i].pro[j] = 0;
		}
	}
}

int comp(const void*  A,const void* B) {
	const teme* a = (const teme*)A;
	const teme* b = (const teme*)B;

	if (b->caPro == a->caPro)
	{
		if (b->sumtime == a->sumtime) {
			return b->num - a->num;
		}
		return a->sumtime - b->sumtime;
	}
	return b->caPro - a->caPro;
}

int main() {
	int w, t, p, r;
	vector<string>v;
	while (cin >> w >> t >> p >> r, w || t || p || r) {
		teme te[51];
		temeset(te, t);
		for (int i = 0; i < r; i++) {
			int mk, tk, pk, jk;
			cin >> mk >> tk >> pk >> jk;
			if (jk == 0) {
				te[tk].caPro++;
				te[tk].sumtime += mk + te[tk].pro[pk];
			}
			else {
				te[tk].pro[pk] += 20;
			}
		}
		qsort(te+1, t, sizeof(teme), comp);
		string s = "";
		for (int i = 1; i <= t; i++) {
			//cout << te[i].num << "???:" << te[i].caPro << " " << te[i].sumtime << endl;
			s += to_string(te[i].num);
			if (i != t) {
				if (te[i].caPro == te[i + 1].caPro && te[i].sumtime == te[i + 1].sumtime) {
					s += "=";
				}
				else {
					s += ",";
				}
			}
		}
		cout << s << endl;
	}

	/*for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}*/
}

Measured memory_bytes: 3212
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(input())
S = input()
result=[]
for i in list(S):
    result.append(alphabet[alphabet.index(i)+N])
mojiretsu = ''.join(result)
print(mojiretsu)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,ll> pii;
const int max_N=1e5+10;
const int inf=1e9+5;
vector<int> g[100005];
int n,m;
int ans=0;
vector<int> dp(100005,-1);
int dfs(int s)
{
  if(dp[s]!=-1) return dp[s];
  int ret=0;
  for(int i=0;i<int(g[s].size());i++)
    {
      ret=max(ret,dfs(g[s][i])+1);
    }
  return dp[s]=ret;
}
int main()
{
  cin >> n >> m;
  for(int i=0;i<m;i++)
    {
      int x,y;
      cin >> x >> y;
      x--;
      y--;
      g[x].push_back(y);
    }
  for(int i=0;i<n;i++)
    {
      ans=max(ans,dfs(i));
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8832
//# define FLAG
///delet....................................
# include <bits/stdc++.h>
using namespace std;
# define eps 1e-8
# define VI vector<int>
# define pb push_back
# define mp make_pair
# define pi acos(-1.0)
# define bug puts("H")
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false)
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define MAX 0x7fffffffffffff
# define INF 0x3f3f3f3f
# define MOD 1e9+7
# define Template int   ///          <-------------变量类型
# define hr putchar('\n')
# define pc putchar
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;
inline char gtc() {
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline Template Scan() {
    int flag=1;
    char ch=gtc();
    if(ch==EOF)return EOF;   ///EOF的值是-1
    Template sum=0;
    while(!((ch>='0'&&ch<='9')||ch=='-'))ch=gtc();
    if(ch=='-')flag=-1,ch=gtc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-'0',ch=gtc();
    return sum*flag;
}
inline int Scan(Template &sum) {
    int flag=1;
    char ch=gtc();
    if(ch==EOF)return EOF;   ///EOF的值是-1
    sum=0;
    while(!((ch>='0'&&ch<='9')||ch=='-'))ch=gtc();
    if(ch=='-')flag=-1,ch=gtc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-'0',ch=gtc();
    sum*=flag;
    return 1;
}
inline void Out(Template x) {
    if(x<0)putchar('-'),x=-x;
    if(x>9)Out(x/10);
    putchar(x%10+'0');
}
///coding...................................

char a[200005];
LL b[28];

LL C(LL x){
    return x*(x-1)/2;
}

int main() {
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    cin>>a;
    LL len=strlen(a),ans=0;
    LL sum=1+(len-1)*len/2;//cout<<sum<<endl;
    FOR(i,0,len-1)b[a[i]-'a']++;
    //FOR(i,0,25)cout<<b[i]<<endl;
    FOR(i,0,25)if(b[i]>=2)ans+=b[i]*(b[i]-1)/2;
    cout<<sum-ans<<endl;
    return 0;
}











///delete FLAG..............................






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

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if (A + B > C * 2) {
		if (X > Y) {
			if (C * 2 > A) {
				cout << C * Y * 2 + A * (X - Y);
			}
			else {
				cout << C * X * 2;
			}
		}
		else {
			if (C * 2 > B) {
				cout << C * X * 2 + B * (Y - X);
			}
			else {
				cout << C * Y * 2;
			}
		}
	}
	else {
	cout << A * X + B * Y;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int findGCD(int arr[], int n) { 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
    return result; 
}
int main(){
	int x;
  int suma=0;
  int orden[3];
	cin>>x;
	for (int i=1;i<=x;i++){
		for(int a=1;a<=x;a++){
			for (int b=1;b<=x;b++){
        orden[0]=i,orden[1]=a,orden[2]=b;
        int n = sizeof(orden)/sizeof(orden[0]);
        suma=suma+findGCD(orden,n);
      }
		}
	}
cout<<suma;
return 0;
}

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

int main(){
	int r, g;
	cin >> r >> g;
	cout << 2*g - r << endl;
}

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

ll m[100];

int main(){
    ll n, x, a = 0;
    cin >> n >> x;
    rep(i, n){
        cin >> m[i];
        a += m[i];
    }
    ll am = x - a;
    sort(m,m+n);
    ll ans = am / m[0];
    ans += n;
    cout << ans << endl;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int N;
map<int,int> M;
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		M[x]^=1;
	}
	int ret=0;
	FORR(r,M) ret+=r.second;
	cout<<ret<<endl;
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

const int INF = 1 << 30;

int main() {
  int N, M, X;
  std::cin >> N >> M >> X;
  std::vector<int> C(N);
  std::vector<std::vector<int>> A(N, std::vector<int>(M));

  rep(i, N) {
    std::cin >> C[i];
    rep(j, M) {
      std::cin >> A[i][j];
    }
  }

  bool ok = false;
  int ans = INF;
  for(int b = 0; b < (1 << N); ++b) {
    int sum = 0;
    std::vector<int> rikai(M);
    rep(i, N) {
      if(! ((b >> i) & 1)) continue;
      sum += C[i];
      rep(j, M) {
        rikai[j] += A[i][j];
      }
    }

    bool flg = true;
    rep(i, M) {
      if(rikai[i] < X) {
        flg = false;
        break;
      }
    }
    if(! flg) continue;
    
    ans = std::min(ans, sum);
    ok = true;
  }

  if(! ok) {
    std::cout << "-1" << '\n';
  } else {
    std::cout << ans << '\n';
  }
}

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

int main() {
	int n,i=0,count1=0,count2=0;
	bool find=true;
	string s,temp,temp2,result;
	cin>>n;
	cin>>s;
	temp=s;
	result.clear();
	temp2.clear();
	while (find){
		i=0;
		find=false;
		temp2.clear();
	while (i<temp.length()){
		if (!((temp[i]=='(')&&(temp[i+1]==')'))){
			temp2=temp2+temp[i];
			//cout<<"temp2="<<temp2<<endl;
			i++;
		}
		else {
		i+=2; 
		find=true;
		}
	}
	//cout<<"temp2="<<temp2<<endl;
	temp=temp2;
	}
	for (int x=0;x<temp.length();x++){
		if (temp[x]=='(') count1++;
		else count2++;
	}
	for (int x=1;x<=count2;x++){
		result=result+'(';
	}
	result=result+s;
	for (int x=1;x<=count1;x++){
		result=result+')';
	}
	//cout<<"temp="<<temp<<endl;
	cout<<result;
	return 0;
}


Measured memory_bytes: 256
// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;
int fac[2000006], ifac[2000006], inv[2000006];

int ncr(int n, int r) {
	return 1ll * fac[n] * ifac[r] % MOD * ifac[n-r] % MOD;
}

int qpow(int b, int e) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = 1ll * ans * b % MOD;
		b = 1ll * b * b % MOD;
		e >>= 1;
	}
	return ans;
}

int dp[20][20];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    fac[0] = ifac[0] = fac[1] = ifac[1] = inv[0] = inv[1] = 1;
    iter(i, 2, 2000004) {
    	inv[i]=1ll*(MOD-MOD/i)*inv[MOD%i]%MOD;
    	fac[i] = 1ll * fac[i-1] * i % MOD;
    	ifac[i] = 1ll * ifac[i-1] * inv[i] % MOD;
    }
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    iter(i, s.length(), n+s.length()+1) ans = (ans + 1ll * qpow(25, n+s.length()-i) * ncr(n+s.length(),i)) % MOD;
    cout << ans << endl;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


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

  ll now = 0;
  for (int i = 1; i <= int(1e8); i++){
    now *= 10; now += 7; now %= K;
    if (now == 0){
      cout << i << endl;
      return 0;
    }
  }
  cout <<-1 << endl;

  return 0;
}


Measured memory_bytes: 3648
N,K = map(int,input().split())
A = list(map(int,input().split()))

A.append(0)

for j in range(min(50,K)):
    B = [0] * (N+1)
    for i in range(N):
        B[max(i - A[i],0)] += 1
        B[min(i + A[i] + 1,N)] -= 1
    A = [0] * (N+1)
    a = 0
    for i in range(N):
        a += B[i]
        A[i] = a

print(*A[:-1])

Measured memory_bytes: 170708
def __min_cost(idx, cost, studied, costs):
    if idx >= n:
        return
    __min_cost(idx+1, cost, studied, costs)
    cost += cs[idx]
    studied = [s+i for s, i in zip(studied, mat[idx])]
    if all(s >= x for s in studied):
        costs.add(cost)
    else:
        __min_cost(idx+1, cost, studied, costs)

def min_cost():
    costs = set()
    __min_cost(0, 0, [0]*m , costs)
    if len(costs) > 0:
        return min(costs)
    else:
        return -1

n, m, x = map(int, input().split())
mat = []
cs = []
for _ in range(n):
    data = list(map(int, input().split()))
    cs.append(data[0])
    mat.append(data[1:])
print(min_cost())

Measured memory_bytes: 9260
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
void visit(int);
int time = 0;
int d[200],f[200];
int n, u[100], k[100], v[100][100];
int color[100];
int main(void){
int n, i, j;

scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&u[i]);
    color[u[i]] = WHITE;
    scanf("%d",&k[u[i]]);
    for(j = 0;j< k[u[i]]; j++ ){
        scanf("%d",&v[u[i]][j]);
    }
}
for(i = 1;i<=n;i++){
    if(color[i] == WHITE){
        visit(i);
    }
}
for(i = 1; i<=n; i++){
    printf("%d %d %d\n",i,d[i],f[i] );
}
return 0;
}

void visit(int u){
    int i = 0; 
    color[u] = GRAY;
    d[u] = ++time;
    for(i = 0;i < k[u]; i++){
        if(color[v[u][i]] == WHITE){
        visit(v[u][i]);    
        }
    }
    color[u] = BLACK;
    f[u] = ++time;
}

Measured memory_bytes: 636
#include <cstdio>

typedef long long ll;

ll n;
int k[100];

ll abs(ll a){
	if(a<0)return -a;
	return a;
}

int main(void){
	while(1){
		scanf("%lld",&n);
		if(n==0)break;

		int i=0;
		while(n!=0){
			if(i%2==0){
				if(n>0)k[i]=abs(n)%10;
				else{
					k[i]=10-abs(n)%10;
					if(abs(n)%10==0)k[i]=0;
				}
				n-=k[i];
			}else{
				if(n<0)k[i]=abs(n)%10;
				else{
					k[i]=10-abs(n%10);
					if(abs(n)%10==0)k[i]=0;
				}
				n+=k[i];
			}
			i++;
			n/=10;
		}
		for(int j=i-1;j>=0;j--){
			printf("%d",k[j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1032
// https://atcoder.jp/contests/agc002/tasks/agc002_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, L;
  cin >> N >> L;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll max_diff_i = -1;
  ll max_diff = 0;

  rep(i, N - 1) {
    if (chmax(max_diff, as[i] + as[i + 1])) {
      max_diff_i = i;
    }
  }

  unless(max_diff >= L) drop("Impossible");

  cout << "Possible" << endl;

  rep(i, max_diff_i) cout << i + 1 << endl;

  repr(i, N - 1) {
    if (i == max_diff_i) break;
    cout << i + 1 << endl;
  }

  cout << max_diff_i + 1 << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1664
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==1&&b==0&&c==0)cout<<"Close"<<endl;
	if(a==0&&b==1&&c==0)cout<<"Close"<<endl;
	if(a==1&&b==1&&c==0)cout<<"Open"<<endl;
	if(a==0&&b==0&&c==1)cout<<"Open"<<endl;
	if(a==0&&b==0&&c==0)cout<<"Close"<<endl;

	return 0;
}

Measured memory_bytes: 3096