akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string S;
        cin >> S;

        string ans;
        for (int i = 0; i < S.size(); i++)
        {
                if (S[i] == '1')
                {
                        S[i] = '9';
                }
                else
                {
                        S[i] = '1';
                }
        }

        cout << S << endl;

        return 0;
}


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

using namespace std;

char str[1000 + 1] = { 0 };

void print(int a, int b)
{
	for (; a <= b; a++)
		cout << str[a];
	cout << endl;
}
void reverse(int a, int b)
{
	char temp = '\0';
	while (a < b) {
		temp = str[a];
		str[a] = str[b];
		str[b] = temp;
		a++;
		b--;
	}
}
void replace(int a, int b, const char *p)
{
	for (int i = 0; i < b - a + 1; i++)
		str[i + a] = p[i];
}

int main()
{
	char command[7 + 1] = { 0 },
		p[1000 + 1] = { 0 };

	int q = 0, a = 0, b = 0;

	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> command >> a >> b;
		if (command[0] == 'p') {
			print(a, b);
		}
		else if (command[2] =='v') {
			reverse(a, b);
		}
		else {
			cin >> p;
			replace(a, b, p);
		}
	}
	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> num(n);
    rep(i,n) num[i]=i+1;
    for(int i = 1; i < n; ++i) num[i]+=num[i-1];
    ll x;
    rep(i,n){
        if(num[i]>=n){
            x = num[i];
            if(num[i]==n)rep(j,i+1) cout << j+1 << endl;
            else{
                ll d = x-n;
                rep(j,i+1) if(j+1!=d)cout << j+1 << endl;
            }
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 81408
#include<bits/stdc++.h>
using ll = long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/


/*....................................DEFINE GLOBAL VARIABLES .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int N, M;
	cin >> N >> M;
	vector<pair<ll,ll>> p(N);

	REP(i, N)cin >> p[i].first >> p[i].second;

	sort(ALL(p));

	ll num = 0;
	ll money = 0;

	for (auto pp : p) {
		if (num == M)break;
		else if (num + pp.second <= M) {money += (pp.first * pp.second); num += pp.second; }
		else if (num + pp.second > M) {money += (M - num) * pp.first; num = M;}
	}

	cout<<money<<endl;













	return 0;
}





Measured memory_bytes: 4776
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
ll dp[10][10];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
    for(int i=1;i<=n;i++)
    {
     int last=i%10;
     int j=i;
     while(i>9)
     {
         i/=10;
     }
     int first=i;
     dp[first][last]++;
     i=j;
    }
    ll ans=0;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        ans+=(dp[i][j]*dp[j][i]);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int N, p;
    cin >> N;
    
    vector<string> S(N);
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> S[i] >> A[i];
    }
    vector<int> ans(N);
    iota(ans.begin(), ans.end(), 0);
    sort(ans.begin(), ans.end(),
        [&](int x, int y){
            if(S[x] == S[y]) return A[x] > A[y];
            return S[x] < S[y];
    });
    for(auto a : ans){
        cout << a+1 << endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	210
#define	MAXS	100010
#define	mod	1000000007
using namespace std;
int n, x, ans;
int w[MAXN], f[MAXN][MAXS];

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

void update(int &x, const int &y){x = (x + y >= mod) ? (x + y - mod) : (x + y);}
int mul(const int &x, const int &y){return 1ll * x * y % mod;}
int inc(const int &x, const int &y){return (x + y >= mod) ? (x + y - mod) : (x + y);}

int main(){
	read(n), read(x);
	for (int i = 1; i <= n; ++i)
		read(w[i]);
	sort(w + 1, w + 1 + n);
	reverse(w + 1, w + 1 + n);
	f[0][x] = 1;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j <= x; ++j){
			if (!f[i][j]) continue;
			update(f[i + 1][j], mul(f[i][j], n - i - 1));
			update(f[i + 1][j % w[i + 1]], f[i][j]);
		}
	}
	for (int i = 1; i <= x; ++i)
		update(ans, mul(i, f[n][i]));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 78208
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n;
	cin >> n;
	vector<vector<int>>f(n, vector<int>(10));
	vector<vector<int>>p(n, vector<int>(11));
	rep(i, n)rep(j, 10)cin>>f[i][j];
	rep(i, n)rep(j, 11)cin >> p[i][j];
	int res = -(1 << 30);
	for (int b = 1; b < (1 << 10); b++) {
		int cc = 0;
		rep(i, n) {
			int c = 0;
			rep(j, 10) {
				if ((b >> j & 1) && f[i][j])c++;
			}
			cc += p[i][c];
		}
		if (res < cc)res = cc;
	}
	cout << res << endl;

	return 0;
}





Measured memory_bytes: 256
# coding : utf-8

N, K = map(int, input().split())
A = list(map(int, input().split()))

# 全部を最小値1にする必要がある
# 1回の操作で最小値を含めるようにして、残りのK-1個の数を変換するようにするのが一番効率が良い
# 最小値を除いたN-1個を(K-1)個ずつ変換していった回数は、割り算して小数点以下を切り上げる
print( -(-(N-1) // (K-1)) )


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

const int kMod = 1000000007;

int solution(const string &s) {
    //TODO: check if s is valid
    int n = s.length();
    vector<int> f(4, 0);
    f[0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 2; j >= 0; --j) {
            if (s[i] == '?') {
                f[j + 1] = (f[j + 1] * 3LL + f[j]) % kMod;
            } else if (s[i] == 'A' + j) {
                f[j + 1] = (f[j + 1] + f[j]) % kMod;
            }
        }
        if (s[i] == '?') f[0] = f[0] * 3LL % kMod;
    }
    return f[3];
}

int main() {
    string s;
    cin >> s;
    cout << solution(s) <<endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
ans = pow(10, 15)
for a in range(1, n):
  b = n - a
  adg, bdg = 0, 0
  while a != 0:
    adg += a % 10
    a //= 10
  while b != 0:
    bdg += b % 10
    b //= 10
  if ans > adg + bdg:
    ans = adg + bdg
print(ans)


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

int main(){
    int n,m,x,y;
    cin >> n >> m  >> x >> y;
  
    bool flag = false;
  	vector<int> X;
  	vector<int> Y;
  	
  	rep(i,n){
      int a;
      cin>>a;
      X.push_back(a);
    }
    rep(i,m){
      int a;
      cin>>a;
      Y.push_back(a);
    }
  	//sort(X.begin(),X.end());
  	//sort(Y.begin(),Y.end());
  
  	int xmax=*(max_element(X.cbegin(),X.cend()));
  int ymin=*(min_element(Y.cbegin(),Y.cend()));
	for(int i=x+1;i<=y;i++){
    	if(i>xmax&&i<=ymin){
        flag=true;
        }
    }
  if(flag){
  cout << "No War"<<endl;
  }else{
  cout << "War"<<endl;
  }
  

}

Measured memory_bytes: 256
x = input()
y = x.split(" ")
map = [int(i) for i in y]
x = input()
y = x.split(" ")
cell = [int(i) for i in y]
map[0] = map[0] - cell[0]
map[1] = map[1] - cell[1]
print(map[0]*map[1])

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const long long MOD_NUM = 1000000007LL;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int A, B;
	get2int(A, B);

	if ((A <= 9) && (B <= 9)) {
		printf("%d\n", A * B);
	}
	else {
		printf("-1\n");
	}
}


Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input())

a = (n // 2 * d) + n % 2 * min(s, 2 * h, 4 * q)
b = n * min(s, 2 * h, 4 * q)
ans = min(a, b)
print(int(ans))


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> v(100001);
	for (int i = 0; i < n;i++) {
		int a, b;
		cin >> a >> b;
		v[a] += b;
	}
	ll sum = 0;
	for (int i = 0; i < 100001; i++) {
		sum += v[i];
		if (sum >= k) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
ans = 0
n = [0] * N
for i in range(N):
  n[i] = int(input())
n.sort()
i=0
cnt = 1
while(i<N-1):
  if n[i] == n[i+1]:
    cnt += 1

  else:
    if cnt % 2 == 1:
      ans += 1
    cnt = 1

  i += 1

if cnt % 2 == 1:
  ans += 1
 
print(ans)

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionB2
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var c = new ConsoleInput(Console.In);
            var S = c.Read;
            var T = c.Read;

            long count = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i]) count++;
            }
            sw.WriteLine(count);

            Console.Out.Flush();
        }
        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }


}


Measured memory_bytes: 27884
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve = foldl' (\a x -> if x == '+' then (a + 1) else (a - 1)) 0

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 380
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
int N;
P A[100002];
int main(){
  while(1){
    scanf("%d",&N);
    if(!N) break;
    int id=0;
    int a;
    scanf("%d",&a);
    A[id].F = 1;
    A[id].S = a;
    for(int i=2;i<=N;i++){
      scanf("%d",&a);
      if(a == (A[id].S)){
	A[id].F++;
      } else {
	if(i%2==0){
	  for(int k=id;k>-1;k--){
	    if(A[k].S==a) break;
	    A[k].S=a;
	  }
	  A[id].F++;
	} else {
	  id++;
	  A[id].F=0;
	  A[id].S=a;
	  A[id].F++;
	}
      }
      //  printf("%d %d %d\n",id,A[id].F,A[id].S);
    }
    int res=0;
    for(int i=0;i<=id;i++){
      //      printf("%d %d\n",A[i].F,A[i].S);
      if(A[i].S==0) res+=A[i].F;
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1964
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
int arr[105], ans[105];
int main()
{
	// freopen("AGC032-A.in", "r", stdin);
	int n, len = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		if (--arr[i] > i)
		{
			puts("-1");
			return 0;
		}
	}
	while (n)
	{
		for (int j = n - 1; j >= 0; j--)
		{
			if (arr[j] != j)
				continue;
			ans[len++] = j;
			for (int k = j; k + 1 < n; k++)
				arr[k] = arr[k + 1];
			n--;
			break;
		}
	}
	for (int i = len - 1; i >= 0; i--)
		printf("%d\n", ans[i] + 1);
	return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans;
	ans = 100 * a + b * 10 + c;
	if (ans % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <ctime>
#include <random>
#include <algorithm>

using namespace std;

#define repeat(n) for(register int _______ = (n); _______ > 0; --_______)
#define loop(i, l, r) for(register auto i = (l), __r = decltype(i)(r); i <= __r; ++i)
#define iloop(i, l, r) for(register auto i = (l), __r = decltype(i)(r); i < __r; ++i)
#define rloop(i, r, l) for(register auto i = (r), __l = decltype(i)(l); i >= __l; --i)

using LL = long long;

template<typename Container>
inline
int ssize(Container& x)
{ return x.size(); }

#ifdef CAI_WEI_HAN
#include "my_print.h"
#include "LOG.h"
#else
#define LOG(...)
#endif

signed main()
{
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
	#define cout cerr
#else
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	constexpr char endl = '\n';
#endif
	
	int n, m, a, b;
	cin >> n >> m >> b >> a;
	
	if(n < 2*a || m < 2*b)
		cout << -1;
	
	else {
		repeat(a) {
			repeat(b)
				cout << '0';
			repeat(m-b)
				cout << '1';
			
			cout << endl;
		}
		repeat(n-a) {
			repeat(b)
				cout << '1';
			repeat(m-b)
				cout << '0';
			
			cout << endl;
		}
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll a,b;
   cin>>a>>b;
   ll i;
   for(i=1;i<=10000;i++)
   {
       ll no = i*(8);
       no/=100;
       ll no2 = i*(10);
       no2/=100;
       if(no>0&&no2>0)
       {
           if(no==a&&no2==b)
           {
               cout<<i<<"\n";
               return;
           }

       }
   }
   cout<<"-1\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

void swapp(int *a, int *b) {
	if (*a > *b) {
		int temp = *a;
		*a = *b;
		*b = temp;
	}
}
int main() {
	int a[4];
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			swapp(&a[j], &a[j + 1]);
		}
	}
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n,y;
    scanf("%d",&n);
    int t[n];
    char s[n][1001];
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
        scanf("%d",&t[i]);
    }
    char x[1001];
    scanf("%s",x);
    int flag=0,ans=0;
    for(int i=0;i<n;i++){
        if(flag){
            ans+=t[i];
        }
        if(strcmp(x,s[i])==0){
            flag=1;
        }
        
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
#define forn(i,n) for (int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()

int main() {
    cxxio();
    int k;
    cin >> k;
    vi xs(k);
    forn(i, k) cin>>xs[i];
    reverse(all(xs));
    ll lo=2, hi=2;
    for (int x:xs) {
        ll a=(lo+x-1)/x*x;
        ll b=hi/x*x;
        if (a>b) return cout<<"-1\n", 0;
        lo=a, hi=b+x-1;
    }
    cout<<lo<<' '<<hi<<'\n';
}


Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * 2847.cc: Ninja Map
 */

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

/* constant */

const int MAX_N = 100;
const int MAX_NN = MAX_N * MAX_N;

/* typedef */

typedef vector<int> vi;

/* global variables */

vi nbrs[MAX_NN];
int xs[MAX_NN], ys[MAX_NN], flds[MAX_N][MAX_N];

/* subroutines */

void printflds(int n) {
  for (int y = 0; y < n; y++) {
    for (int x = 0; x < n; x++) {
      if (x) putchar(' ');
      printf("%d", flds[y][x] + 1);
    }
    putchar('\n');
  }
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int nn = n * n;
  int m = 2 * nn - 2 * n;

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  memset(xs, -1, sizeof(xs));
  memset(ys, -1, sizeof(ys));
  memset(flds, -1, sizeof(flds));

  int st = -1;
  for (int i = 0; st < 0 && i < nn; i++)
    if (nbrs[i].size() == 2) st = i;
  xs[st] = ys[st] = 0;
  flds[0][0] = st;
  //printf("st=%d\n", st);

  for (int i = nbrs[st][0], x = 1;; x++) {
    xs[i] = x, ys[i] = 0;
    flds[0][x] = i;
    vi &nbri = nbrs[i];
    if (nbri.size() < 3) break;

    int j = -1;
    for (vi::iterator vit = nbri.begin(); vit != nbri.end(); vit++)
      if (xs[*vit] < 0 && nbrs[*vit].size() < 4) {
	j = *vit;
	break;
      }
    i = j;
  }

  for (int y = 1; y < n; y++)
    for (int x = 0; x < n; x++) {
      int u = flds[y - 1][x];
      vi &nbru = nbrs[u];
      int v = -1;
      for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++)
	if (xs[*vit] < 0) {
	  v = *vit;
	  break;
	}

      xs[v] = x, ys[v] = y;
      flds[y][x] = v;
    }
  printflds(n);
  
  return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 051 A / Link: http://abc051.contest.atcoder.jp/tasks/abc051_a  ----- */


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

	string s; cin >> s;
	FOR(i, 0, SZ(s)) {
		if (s[i] == ',')s[i] = ' ';
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
function main()
  
  (x,y) = map(x -> parse(Int,x), split(readline()))
  
  A = [1,3,5,7,8,10,12]
  B = [4,6,9,11]
  C = [2]
  
  if in(x,A) == true && in(y,A) == true
    println("Yes")
  elseif in(x,B) == true && in(y,B) == true
    println("Yes")
  elseif in(x,C) == true && in(y,C) == true
    println("Yes") 
  else
    println("No")
  end
  
end

main()

Measured memory_bytes: 167540
#include <stdio.h>


int main ()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=13)
    {
        printf("%d\n",b);
    }
    else if(a>=6 && a<=12)
    {
        printf("%d\n",b/2);
    }
    else
    {
        printf("%d\n",b*0);
    }


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, A, B;
  cin >> N >> A >> B;
  vll h(N);
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
  }
  ll ok = 1000000000LL;
  ll ng = 0LL;
  while(ok - ng > 1){
    ll mid = (ok + ng) / 2;
    ll minimum = B * mid;
    ll Acount = 0;
    for(int i = 0; i < N; i++){
      if(h.at(i) > minimum){
        ll sa = h.at(i) - minimum;
        ll add = (sa + (A-B) - 1) / (A-B);
        Acount += add;
        if(Acount > mid) break;
      }
    }
    if(Acount > mid) ng = mid;
    else ok = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int D, L, k, a;
	scanf("%d %d", &D, &L);
	if (D < L)
	printf("%d\n", D);
	else
	{
		a = D / L + D%L;
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define int LL
#define LL long long
#define N 100005
using namespace std;
LL ans;
int n,x[N],y[N];
vector<int>g[N];
int fa[N],cnt[N],sz[N];
bool mark[N],mark2[N];
int gf(int k) {
	return fa[k]==k?fa[k]:fa[k]=gf(fa[k]);
}
signed main() {
	scanf("%lld",&n);
	for(int i=1; i<N; i++)fa[i]=i;
	for(int i=1; i<=n; i++)scanf("%lld%lld",&x[i],&y[i]),g[x[i]].push_back(y[i]);
	for(int i=1; i<N; i++) {
		int a;
		if(!g[i].empty())a=g[i][0];
		for(int j=1; j<g[i].size(); j++) {
			int b=g[i][j];
			fa[gf(b)]=gf(a);
		}
	}
	for(int i=1;i<=n;i++){
		sz[gf(y[i])]+=!mark2[y[i]];
		mark2[y[i]]=1;
		cnt[gf(y[i])]+=!mark[x[i]];
		mark[x[i]]=1;
	}
	for(int i=1;i<=n;i++){
		int f=gf(y[i]);
		ans+=1ll*sz[f]*cnt[f];
//		printf("%d %d\n",sz[f],cnt[f]);
		sz[f]=0;
	}
	printf("%lld\n",ans-n);
	return 0;
}



Measured memory_bytes: 7296
#include<stdio.h>
int main(){
  int n;

  while ( scanf("%d",&n) != EOF ){
    n %= 39;
    if ( n == 0 ){                  /*あまりが出なかったら*/
      printf("3C39\n");
    }
    else if ( n < 10 ){            /*あまりが10以下なら*/
      printf("3C0%d\n",n);
    }
    else if ( n >= 10 ){          /*あまりが10異常なら*/
      printf("3C%d\n",n);
    }
  }

  return 0;
}

Measured memory_bytes: 608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		ps[i] = nextInt()
	}

	//fmt.Println(solve(n, ps))
	fmt.Println(answer(n, ps))
}

func answer(N int, Ps []int) string {
	c := 0
	for i := range Ps[:len(Ps)-1] {
		if Ps[i] != i+1 {
			c++
		}
	}
	if c <= 2 {
		return "YES"
	} else {
		return "NO"
	}
}

Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    print(n*800-200*(n//15))

#B
def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)

#C
def C():
    x,t = LI()
    print(max(0,x-t))

#D
def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)

#E
def E():
    x,y,s,t = LI()
    return

#F
def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])

#G
def G():
    n,m = LI()
    if m <= 2*n:print(m//2)
    else:
        ans = n
        m -= 2*n
        ans += m//4
        print(ans)

#H
def H():
    n,k = LI()
    ans = 0
    fact
    for i in range(1,3*n+1):
        if i%k == 0:
            return

def J():
    n = I()
    d = defaultdict(int)
    for i in range(n):
        a = I()
        if d[a]:
            d[a] -= 1
        else:
            d[a] += 1
    print(sum(d.values()))
def K():
    return

#Solve
if __name__ == "__main__":
    J()


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int x;
  while(cin>>x) {
    int a=0;
    for (int i=0; x>>i; i++) {
      if (1&(x>>i)) {
        if (a) cout << " ";
        cout << (1<<i);
        a=1;
      }
    }
    cout << endl;
  }
}

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

public class Main {
	public static void main(String args[]) throws IOException {
	// 2020/1/30 No.150
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str[] = br.readLine().split(" ");
	int n = Integer.parseInt(str[0]);
	int m = Integer.parseInt(str[1]);

	if (500 * n >= m)
		System.out.println("Yes");
	else
		System.out.println("No");
	}
}

Measured memory_bytes: 22356
// C - One-stroke Path

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

struct Node {
	vector<int> neighbor;
};

int N, M;
int ans = 0;
vector<Node> nodes;

void search(int node_idx, unordered_set<int> visited) {
	visited.insert(node_idx);

	if (visited.size() == N) {
		ans++;
		return;
	}

	for (int next_node_idx : nodes[node_idx].neighbor) {
		if (visited.find(next_node_idx) == visited.end()) {
			// 未訪問なら探索
			search(next_node_idx, visited);
		}
	}
}

int main() {
	cin >> N >> M;

	nodes = vector<Node>(N);

	int a, b;
	for (int i=0; i<M; i++) {
		cin >> a >> b;
		a--;
		b--;
		nodes[a].neighbor.push_back(b);
		nodes[b].neighbor.push_back(a);
	}

	unordered_set<int> visited;
	search(0, visited);

	cout << ans << endl;

	return 0;
}

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

int main(){
    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;

    string t;
    cin >> t;
    string w="";

    ll ans =0;

    for(ll i=0; i<k; i++){
        if(t[i] == 'r'){
            ans += p;
            w.push_back('r');
        }
        if(t[i] == 's'){
            ans += r;
            w.push_back('s');
        }
         if(t[i] == 'p'){
            ans += s;
            w.push_back('p');
        }
    }

    for(ll j=k; j<n; j++){

        if(t[j] == w[j-k]){
            if(t[j] == 'r'){
            w.push_back('!');
        }
        if(t[j] == 's'){
             w.push_back('!');
        }
         if(t[j] == 'p'){
             w.push_back('!');
        }
        }

        else{
           if(t[j] == 'r'){
            ans += p;
            w.push_back('r');
        }
        if(t[j] == 's'){
            ans += r;
            w.push_back('s');
        }
         if(t[j] == 'p'){
            ans += s;
            w.push_back('p');
        }
        }

    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a[15][15]; 
bool pf(int n){
	if ((int)sqrt(n)==sqrt(n)){
		return true;
	}
	return false;
}
int main(){
	int n,d;
	cin>>n>>d;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=d;j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) {
	    for(int j=i+1;j<=n;j++) {
	    	int s=0;
	    	for(int k=1;k<=d;k++) {
	    		s+=pow(a[i][k]-a[j][k],2);
	    	}
	    	if (pf(s)){
	    		ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}


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

#define ll long long int
#define pb emplace_back

int main() {
    ios_base::sync_with_stdio(false);
    
    ll x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    
    vector<ll> red(a), green(b), noColor(c);
    for(ll i=0; i<a; i++){
        cin>>red[i];
    }
    for(ll i=0; i<b; i++){
        cin>>green[i];
    }
    for(ll i=0; i<c; i++){
        cin>>noColor[i];
    }
    sort(red.begin(), red.end(), greater<ll> ());
    sort(green.begin(), green.end(), greater<ll> ());
    sort(noColor.begin(), noColor.end(), greater<ll> ());
    ll r=0, g=0, n=0, max_sum=0;
    while(n<c && r<x && g<y && r+g+n<x+y){
        if(red[r]>=max(green[g], noColor[n])){
            max_sum+=red[r++];
        }
        else if(green[g]>=max(red[r], noColor[n])){
            max_sum+=green[g++];
        }
        else{
            max_sum+=noColor[n++];
        }
    }
    if(r+g+n<x+y){
        if(n>=c){
            while(r+g+n<x+y){
                if(r>=x || green[g]>=red[r]){
                    max_sum+=green[g++];
                }
                else{
                    max_sum+=red[r++];
                }
            }
        }
        else if(r>=x){
            while(r+g+n<x+y){
                if(n>=c || green[g]>=noColor[n]){
                    max_sum+=green[g++];
                }
                else{
                    max_sum+=noColor[n++];
                }
            }
        }
        else{
            while(r+g+n<x+y){
                if(n>=c || red[r]>=noColor[n]){
                    max_sum+=red[r++];
                }
                else{
                    max_sum+=noColor[n++];
                }
            }
        }
    }
    cout<<max_sum<<"\n";
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int i=0;i<300;i++){
        if(i&1){
            a-=d;
        }
        else{
            c-=b;
        }
        if(a<=0){
            cout<<"No"<<endl;
            return;
        }
        if(c<=0){
            cout<<"Yes"<<endl;
            return;
        }
    }
}
signed main(){
    fastio; 
    // int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

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

void solve()
{
    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;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef unsigned long long ll;
using namespace std;
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);
    ll n,i,j,ans=0;
    cin>>n;
    vector<ll>a(n+2),b(n);
    for(i=1;i<n;i++)
    {
        cin>>b[i];
    }
    ll prv=LONG_MAX;
    for(i=1;i<n;i++)
    {
        a[i]=min(b[i],prv);
        a[i+1]=b[i];
        prv=b[i];
    }
    for(i=1;i<=n;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	set<ll> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout<<s.size();
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		String[] s = new String[n];
		
		for(int i = 0; i < n; i++){
			s[i] = in.next();
		}
		int freq[] = new int[26];
		
		for(int i =0;i<26;i++){
			boolean check =true;
			int min=1222;

			for(int j=0;j<s.length;j++){
				freq[i] = 0;
				for(int k=0;k<s[j].length();k++){
					if(s[j].charAt(k)-'a'==i){
						freq[i]++;
					}
				}
				min = Math.min(min,freq[i]);
				if(freq[i]==0){
					check=false;
					break;
				}

			}
			if(check){
				for(int j=0;j<min;j++)
					out.print((char)('a'+i));		
			}
		}
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}





int main(){//
	int N, M;
	cin >> N >> M;
	vector<int> k(M), p(M);
	vector<vector<int>> s(M, vector<int>());
	for(int i=0; i<M; i++){
		cin >> k[i];
		for(int j=0; j<k[i]; j++){
			int a;
			cin >> a;
			a--;
			s[i].push_back(a);
		}
	}
	for(int i=0; i<M; i++) cin >> p[i];
	// cout << " N: " << N << " M: " << M << endl;
	// cout << " k: "; print_vec(k);
	// cout << " p: "; print_vec(p);
	// cout << " s: " << endl; print_vec2(s);
	// cout << " 2<<N: " << (2<<N) << endl;

	//bit全探索する
	int ans = 0;
	for(int i=0; i<(2<<N-1); i++){// 2^N回試す
		vector<bool> is_on(N, false);
		
	
		for(int j=0; j<N; j++){
		
			if( (i>>j) & 1){// iの右からj番目が1なら
				is_on[j] = true;
			}

		}
		
		bool is_lighting = true;//全ての電球が点灯してるとtrueのまま
		for(int j=0; j<M; j++){
			
			int num_on = 0;
			for(int u=0; u<k[j]; u++){
				if(is_on[s[j][u]] == true) num_on++;
			}
			if(num_on%2 != p[j]){
				is_lighting = false;
				//cout << j << " is fals!! is_on: "; print_vec(is_on);
				break;
			} 
			//else cout << j <<  " is lighting  is_on: "; print_vec(is_on);
			if(is_lighting == false) break;
		}
		if(is_lighting == false) continue;
		ans++;


	}
	
	cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	ll K;
	cin >> K;
	vector<ll> ansPrev(9);
	
	REP(i, 9) {
		ansPrev[i] = i + 1;
	}

	while (ansPrev.size() < K) {
		vector<ll> ansNext;

		K -= ansPrev.size();
		for (auto ansOne : ansPrev) {
			int amari = ansOne % 10;
			ll base = 10 * ansOne + amari;
			if (amari == 0) {
				ansNext.emplace_back(base);
				ansNext.emplace_back(base + 1);
			} else if (amari == 9) {
				ansNext.emplace_back(base - 1);
				ansNext.emplace_back(base);
			} else {
				ansNext.emplace_back(base - 1);
				ansNext.emplace_back(base);
				ansNext.emplace_back(base + 1);
			}
		}
		swap(ansNext, ansPrev);
	}

	cout << ansPrev[K - 1] << endl;
	return 0;
}


Measured memory_bytes: 1712
import numpy as np
S = np.array(list(map(str, input().rstrip())))
K = int(input())

cnt = 0
ans = 1

for i, s in enumerate(S):
    if s != "1":
        cnt = i+1
        ans = s
        break

if cnt > K:
    print(1)
else:
    print(int(ans))

Measured memory_bytes: 20748
if __name__=="__main__":
    num_plus_one, num_zero, num_minus_one, total_num = map(int, input().split(' '))

    if total_num <= num_plus_one:
        counter = total_num
    elif total_num <= num_plus_one + num_zero:
        counter = num_plus_one
    elif total_num <= num_plus_one + num_zero + num_minus_one:
        counter = num_plus_one - (total_num - num_plus_one - num_zero)
    else:
        counter = num_plus_one - num_minus_one

    print(counter)

Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i <= N; ++i)
	{
		for (int j = 0; j <= M; ++j)
		{
			if (i * (M - j) + j * (N - i) == K)
			{
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,a[200005];
LL d;
struct data{
	LL h,x;
}w[200005];
LL ans;
queue<data>Q;
bool cmp(data a,data b){
	return a.x<b.x;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	LL ans=0;
	for(int i=1;i<=n;++i){
		if(!a[i])break;
		if(i>n-k) break;
		else ans+=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

ll x;
ll n;

int main(){
  scanf("%d",&x);
  n = (-1+sqrt(1+8*x))/2;
  if(x != n*(n+1)/2) n++;
  printf("%lld\n",n);
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n,m;
int cnt[20][100010],a,sum[20];
int dp[1<<20];

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

	for(int i=0;i<(1<<20);i++) dp[i]=INF;

	cin>>n>>m;
	REP(i,n) {
		cin>>a;a--;
		cnt[a][i+1]++;
		REP(j,m) cnt[j][i+1]+=cnt[j][i];
	}
	REP(i,m) sum[i]=cnt[i][n];
	dp[0]=0;
	for(int S=0;S<(1<<m);S++) {
		int nui_sum=0;
		REP(i,m) if(S&(1<<i)) nui_sum+=sum[i]; //既に並んでいるぬいぐるみの合計
		REP(i,m) {
			if(S&(1<<i)) continue;
			int move=sum[i]-cnt[i][nui_sum+sum[i]]+cnt[i][nui_sum];
			dp[S|(1<<i)]=min(dp[S|(1<<i)],dp[S]+move);
		}
	}
	cout<<dp[(1<<m)-1]<<endl;

	return 0;
}



Measured memory_bytes: 15028