akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vector<i64> sum(n + 1, 0);
	vi a(n), x(n + 1);
	rep(i, 0, n) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
		x[i + 1] = x[i] ^ a[i];
	}
	i64 ans = n;
	int r = 0;
	rep(i, 0, n) {
		rep(j, r, n - 1) {
			if ((x[j + 2] ^ x[i]) != sum[j + 2] - sum[i]) {
				break;
			}
			r++;
		}
		ans += r - i;
	}
	cout << ans << endl;
}


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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if (a+b==c||a+c==b||b+c==a) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
x = gets.to_i
n = 0

if x % 50 != 0
  puts "x must be a multiple of 50."
  exit
end

for a in 0..A # 500円の枚数
  for b in 0..B # 100円の枚数
    for c in 0..C # 50円の枚数
      if (500*a + 100*b + 50*c) == x
        n+=1
        break
      end
    end
  end
end

puts n

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main(){
	int A, B, C, D, E, F;
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	printf("%d\n", A + B + C + D + E + F - min(min(A, B), min(C, D)) - min(E, F));
	return 0;
}

Measured memory_bytes: 2688
import sys
import numpy as np
readline=sys.stdin.readline
read=sys.stdin.read

def main():
  n,c=map(int,readline().split())
  m=2*10**5
  stc=[list(map(int,l.split())) for l in read().splitlines()]
  cht=np.zeros((c,m+1),dtype='int64')
  for e in stc:
    cht[e[2]-1,2*e[0]-1:2*e[1]]=np.ones(2*e[1]-2*e[0]+1)
  print(max(np.sum(cht,axis=0)))

if __name__=='__main__':
  main()

Measured memory_bytes: 94488
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]

counter_a = Counter(v[0::2])
counter_b = Counter(v[1::2])

keys_a, values_a = zip(*counter_a.most_common())
keys_b, values_b = zip(*counter_b.most_common())

if keys_a[0] != keys_b[0]:
  cnt_a = n//2 - values_a[0]
  cnt_b = n//2 - values_b[0]
  ans = cnt_a + cnt_b
else:  # keys_a[0] == keys_b[0]
  if n//2 == values_a[0]:
    ans = n//2
  elif values_a[0] + values_b[1] >= values_a[1] + values_b[0]:
    cnt_a = n//2 - values_a[0]
    cnt_b = n//2 - values_b[1]
    ans = cnt_a + cnt_b
  else:
    cnt_a = n//2 - values_a[1]
    cnt_b = n//2 - values_b[0]
    ans = cnt_a + cnt_b

print(ans)


Measured memory_bytes: 21904
#include <iostream>
#include <queue>
#include <vector>

struct edge {
    typedef size_t weight_type;

    size_t m_to;

    edge(size_t to) : m_to(to) { }

    inline size_t to() const { return m_to; }

    inline weight_type weight() const { return 1; }

    friend std::ostream& operator<<(std::ostream &os, const edge &e) {
        os << "{ to: " << e.m_to << " }";
        return os;
    }
};

template <class Edge>
struct graph {
    typedef Edge edge_type;

    size_t m_n_vertices;
    std::vector<std::vector<edge_type>> m_edges;

    graph(size_t n_vertices) : m_n_vertices(n_vertices), m_edges(n_vertices) { }

    inline size_t n_vertices() const { return m_n_vertices; }

    inline void make_edge(size_t from, size_t to, typename edge_type::weight_type weight) {
        m_edges[from].emplace_back(edge_type(to, weight));
    }

    inline void make_edge(size_t from, size_t to) {
        m_edges[from].emplace_back(edge(to));
    }

    inline void make_edge(size_t from, const edge_type &e) {
        m_edges[from].emplace_back(e);
    }

    inline std::vector<edge_type> edges_from(size_t v) const {
        return m_edges[v];
    }
};

// time complexity: O(V + E)
template <class Graph>
std::vector<size_t> topological_sort(const Graph &g) {

    using Edge = typename Graph::edge_type;

    std::vector<size_t> topological_orders(g.n_vertices());
    std::vector<size_t> indegrees(g.n_vertices());

    for (size_t v = 0; v < g.n_vertices(); ++v) {
        for (const Edge &e: g.edges_from(v)) {
            ++indegrees[e.to()];
        }
    }

    std::queue<size_t> q;

    for (size_t v = 0; v < g.n_vertices(); ++v) {
        if (!indegrees[v]) {
            q.push(v);
        }
    }

    for (size_t i = 0; i < g.n_vertices(); ++i) {
        if (q.empty()) { // has cycle
            return { };
        }
        size_t u = q.front();
        q.pop();
        topological_orders[i] = u;
        for (const Edge &e: g.edges_from(u)) {
            size_t v = e.to();
            --indegrees[v];
            if (!indegrees[v]) {
                q.push(v);
            }
        }
    }

    return topological_orders;
}

int main() {
    using namespace std;

    using Graph = graph<edge>;

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

    int V, E;
    cin >> V >> E;
    Graph g(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        g.make_edge(s, t);
    }

    cout << (topological_sort(g).size() == 0) << endl;

    return 0;
}



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

const int MAXN=2e5+5;

int n;
int a[MAXN],b[2][MAXN];

int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=2;i<=n;i+=2) b[0][i/2]=a[i];
	for(i=1;i<=n;i+=2) b[1][i/2+1]=a[i];
	if(n%2==0)
	{
		for(i=n/2;i>=1;i--) printf("%d ",b[0][i]);
		for(i=1;i<=n/2;i++) printf("%d ",b[1][i]);
	}else
	{
		for(i=n/2+1;i>=1;i--) printf("%d ",b[1][i]);
		for(i=1;i<=n/2;i++) printf("%d ",b[0][i]);
	}
	return 0;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p = 0;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if((a % 2) == 1) p++;
    }
    String ans = "first";
    if(p == 0) ans = "second";
    System.out.println(ans);
  }
}

Measured memory_bytes: 47932
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

 
int main() {
 ll N,X;
  cin>>N>>X;
  vector<ll> vec(N);
  ll ans=N;
  
  for(ll i=0;i<N;i++) {
cin>>vec[i];
    X-=vec[i];
  }
  sort(all(vec));
  
  ans+=X/vec[0];
cout<<ans<<endl;
}
  

Measured memory_bytes: 3564
#include <cstdio>
#include <cmath>
using namespace std;

double a, b, x;

int main() {
	scanf("%lf %lf %lf", &a, &b, &x);
	if (a*b/2 <= x/a) { //less than half
		printf("%.10lf\n", atan(2*(a*b-x/a)/(a*a))/M_PI*180);
	} else { //more than half
		printf("%.10lf\n", atan((b*b*a)/(2*x))/M_PI*180);
	}

}

Measured memory_bytes: 128
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = parseInt(xs[0]);
   let AC = 0;
   let TLE = 0;
   let WA = 0;
   let RE = 0;
   for(let i=0; i<=N; i++){
     let tmp = xs[i];
     if(tmp=='TLE'){
       TLE++;
     }else if(tmp=='AC'){
       AC++;
     }else if(tmp=='WA'){
       WA++;
     }else if(tmp=='RE'){
       RE++;
     }
   } 
   console.log('AC x '+AC);
   console.log('WA x '+WA);
   console.log('TLE x '+TLE);
   console.log('RE x '+RE);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  int64 n, m, k;
  while (cin >> n >> m >> k && n+m+k) {
    vector<int64> dice(n * m+1, 0);
    dice[0] = 1;
    int64 al = 1;
    REP(i, n) {
      al *= m;
      vector<int64> dice2(n*m+1, 0);
      REP(j, n*m-m+1) {
        FOR(k, 1, m+1) {
          dice2[j+k] += dice[j];
        }
      }
      swap(dice, dice2);
    }
    double res = 0;
    REP(i, n*m+1) {
      res += (double)(max(i-k, (int64)1) * dice[i]) / al;
    }
    cout << fixed << setprecision(10) << res << endl;
  }
}



Measured memory_bytes: 3372
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
counter = 0
for i in range(n):
    a = list(map(int, input().split()))
    if sum([a * b for a, b in zip(a, b)]) + c > 0:
        counter += 1
print(counter)

Measured memory_bytes: 38256
n = int(input())
a = [int(i) for i in input().split()]
x = [0] * n
x[0] = sum(a) - 2*sum(a[1::2])
for i in range(1, n):
    x[i] = 2*a[i - 1] - x[i - 1]

print(*x)

Measured memory_bytes: 14092
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[210][210];//dp[i][j]:=i+2日に服jを選んだ時の最大値
int t[210]={0};
int a[210],b[210],c[210];
int D,N;
int rec(int id,int cloth){
	if(id==D)return 0;
	if(dp[id][cloth]>=0)return dp[id][cloth];
	int tmp = 0;
	for(int i =0;i <N;i++){
		if(a[i]<=t[id]&&t[id]<=b[i]){
			tmp=max(tmp,rec(id+1,i)+abs(c[i]-c[cloth]));
		}
	}
	return dp[id][cloth]=tmp;
}

int main(){
	cin>>D>>N;
	for(int i =0;i <D;i++){
		cin>>t[i];
	}
	for(int i =0;i <N;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int ans = 0;
	memset(dp, -1, sizeof(dp));
	for(int i =0;i <N;i++){
		if(a[i]<=t[0]&&t[0]<=b[i]){
			ans =max(ans,rec(1,i));
		}
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1352
n, nq = map(int, input().split())
set_list = list(range(n))

def find(n):
    global set_list
    if set_list[n] == n:
        return n
    result = set_list[n] = find(set_list[n])
    return result

def same(x, y):
    set_list[find(y)] = find(x)

def unite(x, y):
    return find(x) == find(y)

for _ in range(nq):
    com,x,y = map(int, input().split())
    if com == 0:
        same(x, y)
    else:
        if unite(x, y):
            print(1)
        else:
            print(0)



Measured memory_bytes: 5984
#include <iostream>

using namespace std;

int main() {
	bool prime[1000000];
	fill_n((bool *)prime, 1000000, true);
	prime[1]=false;
	for(int i=2; i<1000000; i++){
		if(prime[i]){
			for(int j=2; i*j<1000000; j++){
				prime[i*j] = false;
			}
		}
	}
	int a, d, n;
	while(cin >> a >> d >> n, a|d|n){
		int count = 0;
		int i;
		for(i = a; i < 1000000; i+=d){
			if(prime[i]) count++;
			if(count == n) break;
		}
		cout << i << endl;
	}

	return 0;
}

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

typedef struct{
  int huri;
  int nage;
} Data;

bool ask(Data& l,Data& r){
  return l.nage > r.nage;
}

int main(){
  int n,h;
  cin >> n >> h;
  Data data[100010];
  int idx = 0;
  for(int i = 0;i < n;i++){
    cin >> data[i].huri >> data[i].nage;
    if(data[i].huri > data[idx].huri){
      idx = i;
    }
  }

  Data ndata[100010];
  int m = 0;
  for(int i = 0;i < n;i++){
    if(data[i].nage > data[idx].huri){
      ndata[m] = data[i];
      m++;
    }
  }

  sort(ndata,ndata+m,ask);

  long long ans = 0;
  for(int i = 0;i < m;i++){
    h -= ndata[i].nage;
    ans++;
    if(h <= 0){
      cout << ans << endl;
      return 0;
    }
  }
  ans += (h+data[idx].huri-1)/data[idx].huri;
  cout << ans << endl;
  return 0;
}

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

int n,k;
int w[1000000];

bool f(ll limit){
   int cnt=0;
   // cout << "LIMIT = "<<limit<<endl;
   rep(i,k){
      ll sum = 0; 
        
      while(cnt<n){
         sum += w[cnt];
         // cout << w[cnt]<<",";
         cnt++; 
         if(cnt==n && sum+w[cnt] <= limit) return true;
         if(sum+w[cnt] > limit) break;
      }
      // cout <<" ";
   }
   return false;
}

int main(){
   cin >> n >> k;
   ll sum = 0;

   rep(i,n)
   {
      cin >> w[i];
      sum += w[i];
   }
   if(k==1){
      cout << sum << endl;
      return 0;
   }
   ll left=0,right=sum,ans; //2分探索用
   left = *max_element(w,w+n);
   while(left<=right){
      ll mid = (left+right)/2;
      if(f(mid)){
         ans = mid;
         right = mid - 1;
         
      }else{
         left = mid + 1;
      }
   }
   //ans = min(left,ans);
   cout << ans << endl;
   return 0;
}



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

#define ll long long
int main()
{
	int k; cin >> k;
	queue<ll> q;

	for(int i=1;i<=9;++i) q.push(i);

	while(true){
		ll x=q.front();
		q.pop();

		--k;
		if(!k){
			cout << x;
		       	return 0;
		}

		int last=x%10;
		if(last!=0) q.push((10*x)+(x%10)-1);
		q.push((10*x)+(x%10));
		if(last!=9) q.push((10*x)+(x%10)+1);
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    vector<int> P(N); for (auto &p : P) cin >> p;
    vector<bool> E(N);
    int eql = 0, tot = 0;
    int ans = N - K + 1;
    for (int i = 0; i < N - 1; i++) {
        if (P[i] < P[i + 1]) eql++;
        tot++;
        if (tot == K - 1 && eql == K - 1) {
            E[i + 2 - K] = 1;
        }
        if (i + 2 - K >= 0) {
            if (P[i + 2 - K] < P[i + 3 - K]) eql--;
            tot--;
        }
    }
    set<int> S;
    for (int i = 0; i < N; i++) {
        if (S.size() < K) {
            S.insert(P[i]);
        } else {
            if (P[i - K] == *begin(S) && P[i] > *prev(end(S))) {
                if (!E[i - K]) ans--;
            }
            S.insert(P[i]);
            S.erase(P[i - K]);
        }
    }
    int cnt = 0;
    for (auto e : E) if (e) cnt++;
    cout << ans - max(0, cnt - 1) << endl;
    return 0;
}


Measured memory_bytes: 10368
import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
from copy import deepcopy

INF=10**18
MOD=10**9+7
MAX=10**5+7


# N,K=map(int, input().split())
# A=list(map(int, input().split()))
if __name__=='__main__':
  a,b,h,m=map(int, input().split())

  s=h*30+30*m/60
  t=360*m/60

  th=min(abs(s-t), 360-abs(s-t))
  c=sqrt(a**2+b**2-2*a*b*math.cos(math.radians(th)))
  print(c)





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

int main(){
  int D, T, S;
  cin >> D >> T >> S;
  bool judge;
  if (D/S > T){
    judge = false;
  }else if(D/S == T){
    if(D%S > 0){
      judge = false;
    }else{
      judge = true;
    }
  }else{
    judge = true;
  }
  
  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}



Measured memory_bytes: 3604
/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,x ;
deque<int> dq ,all ;
int main(){
    cin >> n >> x ;
    if(x==1 || x==2*n-1) return cout << "No" ,0 ;
    cout << "Yes\n" ;
    dq.push_back(x) ;
    for(int i=1;i<=2*n-1;++i) if(i!=x) all.push_back(i);
    for(int i=0;all.size();i^=1){
        if(!i){
            dq.push_front(all.front());
            dq.push_back(all.back());
        }
        else{
            dq.push_back(all.front());
            dq.push_front(all.back());
        }
        all.pop_front();
        all.pop_back();
    }
    for(int go:dq) cout << go << endl ;
    return 0;
}


Measured memory_bytes: 2304
n=int(input())
A=list(map(int,input().split()))
def Dlist(BIG):
    D=[1]*(BIG+1)
    for p in range(2,BIG+1):
        if D[p]!=1:
            continue
        for i in range(p,BIG+1,p):
            if D[i]==1:
                D[i]=p
    return D

D=Dlist(max(A))
def SOINSU(num,D): #素因数だけ列挙(setしただけ)
    now=num ; ans=set()
    while now>1:
        ans.add(D[now])
        now//=D[now]
    return ans

seen=[0]*(10**6+10)
flag=1
for num in A:
    for i in SOINSU(num,D):
        if seen[i]!=0: flag=0
        seen[i]+=1
if flag:
    print("pairwise coprime")
elif max(seen)!=n:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 205268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  long double a, b, c;
  cin >> a >> b >> c;
  if (a + b + sqrt(a)*sqrt(b)*2.0 < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 100005
using namespace std;

int fac[maxn], n, m, sn, ifac[maxn], inv[maxn], f[21][maxn], ans, a[21], digit[maxn];
int C(int u, int v){
	if(u < v) return 0;
	return 1ll * fac[u] * ifac[v] % mod * ifac[u - v] % mod; 
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n; cin >> m; sn = 1 << n;
	fac[0] = 1; inv[0] = 1; ifac[0] = 1;
	for(int i = 1; i <= sn; i++) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = (i == 1) ? 1 : 1ll * inv[mod % i] * (mod - mod / i) % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod; 
	}
	for(int i = 1; i <= m; i++) cin >> a[i];
	sort(a + 1, a + m + 1);
	f[m + 1][0] = 1;
	for(int i = m; i >= 1; i--)
		for(int j = 0; j < sn; j++){
			(f[i][j] += f[i + 1][j]) %= mod;
			for(int k = 0; k < n; k++){
				if(j & (1 << k)) continue;
				int p = sn - j - a[i];
				(f[i][j + (1 << k)] += 1ll * f[i + 1][j] * C(p, (1 << k) - 1) % mod * fac[1 << k] % mod) %= mod;
			}
		}
	for(int i = 0; i < sn; i++) {
		digit[i] = digit[i >> 1] + (i & 1);
		f[1][i] = 1ll * f[1][i] * fac[sn - i - 1] % mod;
		if(digit[i] % 2 == 0) ans = (ans + f[1][i]) % mod;
		else ans = (ans + mod - f[1][i]) % mod;
	}
	cout << 1ll * ans * sn % mod<< endl;
	return 0;
}


Measured memory_bytes: 8320
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    if i % 2 == 0:
        b[n//2+i//2] = a[i]
    else:
        b[n//2-i//2-1] = a[i]

if n % 2 == 1:
    print(*b[::-1])
else:
    print(*b)

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

using namespace std;


typedef long long ll ;
const ll mk = 100055;
const ll logn  = 29;
const ll mod = 1e9 + 7;

#define endl "\n"
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU              uwu
#define UwU              Mikuwu
#define Miku             best_waifu
#define Miku_dancing     god_waving
#define Miku_singing     god_shaking
#define a_Miku           cho_doi_bot_ngu

int	main()
{
	int	N;
	cin >> N;
	int	A[2000];
	int	sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += A[i];
	}
	bitset<4000000>	dp(1);
	for (int i = 0; i < N; ++i)
		dp |= (dp << A[i]);
	for (int i = (sum + 1) / 2; i <= sum; ++i) {
		if (dp.test(i)) {
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 5080
#include <stdio.h>

#define NUM 10000

int main(void){
  char a[NUM];
  int sum = 0;
  int n = 0;
  int i;

  while(1){
    scanf("%s", &a);
    if(a[0] == '0'){
      break;
    }
    sum = 0;

    for(i = 0; a[i] != '\0'; i++){
      sum += a[i] - '0';
    }
    printf("%d\n", sum);
  }

  return 0;
}

Measured memory_bytes: 1820
N,Q=map(int,input().split())
S="*"+input()

T=[0]*(N+1)
U=[0]*(N+1)
for i in range(1,N+1):
    if S[i-1]=="A" and S[i]=="C":
        T[i]=T[i-1]+1
        U[i]=1
    else:
        T[i]=T[i-1]

H=[0]*Q
for k in range(Q):
    X,Y=map(int,input().split())
    H[k]=T[Y]-T[X-1]-U[X]
print("\n".join(map(str,H)))


Measured memory_bytes: 85604
import sys
# import heapq, functools, collections
# import math, random
# from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((i8[:], i8, i8, i8), cache=True)
def solve(items,R,C,K):  # fix inputs here
    # console("----- solving ------")
    # console(R,C)

    grid = np.zeros((R, C), np.int64)

    for i in range(0, 3 * K, 3):
        x, y, v = items[i:i + 3]
        grid[x - 1, y - 1] = v

    # console(np.array(grid))  # PLEASE SILENCE
    # console("\n\n")

    dp = np.zeros((R, C, 4), np.int64)
    maxx = np.zeros((R, C), np.int64)

    if grid[0,0] > 0:
        dp[0][0][1] = dp[0][0][0] + grid[0][0]

    for i in range(1,R):
        dp[i][0][0] = max(dp[i-1][0][0], dp[i-1][0][1])
        if grid[i][0] > 0:
            dp[i][0][1] = dp[i][0][0] + grid[i][0]
        maxx[i][0] = max(dp[i][0])

    for j in range(1,C):
        for k in range(1,4):
            dp[0][j][k] = max(dp[0][j-1][k], dp[0][j-1][k-1] + grid[0][j])
        maxx[0][j] = max(dp[0][j])

    # console(np.array(dp)[:,:,0])  # PLEASE SILENCE
    # console(np.array(dp)[:,0,:])  # PLEASE SILENCE
    # console(np.array(dp)[0,:,:])  # PLEASE SILENCE
    # console(np.array(dp))  # PLEASE SILENCE
    # console("\n\nPost")

    for i in range(1,R):
        j_1 = 0
        for j in range(1,C):
            dp[i][j][0] = max(maxx[i-1][j], dp[i][j-1][0])
            if grid[i][j] > 0:
                dp[i][j][1] = max(dp[i][j-1][1], dp[i][j][0] + grid[i][j])
                for k in range(2,4):
                    dp[i][j][k] = max(dp[i][j-1][k], dp[i][j-1][k-1] + grid[i][j])
                j_1 = j
            else:
                for k in range(1,4):
                    dp[i][j][k] = dp[i][j-1][k]
            maxx[i][j] = max(dp[i][j])

    # console(np.array(dp)[:,:,0])  # PLEASE SILENCE
    # console(np.array(dp)[:,:,1])  # PLEASE SILENCE
    # console(np.array(dp)[:,:,2])  # PLEASE SILENCE
    # console(np.array(dp)[:,:,3])  # PLEASE SILENCE
    # console(np.array(dp))  # PLEASE SILENCE

    # return a string (i.e. not a list or matrix)
    return dp.max()


def console(*args):  # the judge will not read these print statement
    # print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W, K = map(int, readline().split())
XYV = np.array(read().split(), np.int64)
 
print(solve(XYV, H, W, K))


Measured memory_bytes: 534440
#include <iostream>
using namespace std;
int main()
{
string s,t,c;
int count=0;
cin>>s>>t;

if(s==t){
    cout<<"Yes";
}
else{
for(int i=0;i<s.length();i++){
    s.insert(0, 1, s[s.length()-1]);
    s.erase(s.length()-1, 1);
    count++;
    if(s==t){
        cout<<"Yes";
        break;
    }
}
    }
if(count==s.length()){
    cout<<"No";
}
    return 0;
}


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

int main(){

    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<int> east(N, 0), west(N, 0);
    if(S[0] == 'E') east[0]++;
    else west[0]++;
    for(int i = 1; i < N; i++){
        if(S[i] == 'E'){
            east[i] = east[i - 1] + 1;
            west[i] = west[i - 1];
        }else{
            east[i] = east[i - 1];
            west[i] = west[i - 1] + 1;
        }
    }
    
    int ans = N;
    for(int i = 0; i < N; i++){
        if(S[i] == 'E') ans = min(ans, west[i] + east.back() - east[i]);
        else ans = min(ans, west[i] - 1 + east.back() - east[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//1000000000000223
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, m, vis[1009], vis2[1009],par[1009],go[1009][1009] ;
vector<int> v[1009];
vector<int> ans;
void solve()
{
    int sz=ans.size();
    for(int i=0; i<sz; i++)
    {
        for(int j=i+2; j<sz; j++)
            if(go[ans[i]][ans[j]])
            {
                ans.erase(ans.begin()+i+1,ans.begin()+j);
                solve();
                return ;
            }
        int j=0;
        if(i==sz-1)
            j=1;
        for(; j<i; j++)
            if(go[ans[i]][ans[j]])
            {
                ans.erase(ans.begin()+i+1,ans.end());
                ans.erase(ans.begin(),ans.begin()+j);
                solve();
                return ;
            }
    }
    cout<<ans.size()<<endl;
    for(auto i : ans)
        cout<<i<<"\n";
}
void dfs(int node)
{
    if(vis2[node])
    {
        int x=node;
        while(par[x]!=node)
            ans.push_back(x), x=par[x];
        ans.push_back(x);
        reverse(ans.begin(),ans.end());
        solve();
        exit(0);
    }
    if(vis[node])
        return ;
    vis2[node]++;
    vis[node]++;
    for(auto i : v[node])
    {
        par[i]=node;
        dfs(i);
    }
    vis2[node]--;
}
int main()
{
    IO
    cin>>n>>m;
    while(m--)
    {
        int x, y ;
        cin>>x>>y;
        go[x][y]=1;
        v[x].push_back(y);
    }
    for(int i=1; i<=n; i++)
        dfs(i);
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3840
#include<cstdio>
#include<vector>
#include<queue>

using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;


struct qm_t
{
	int p, c, t;
	bool operator<(const qm_t&rhs) const
	{
		return c>rhs.c;
	}
};


class pq_t
{
	priority_queue<qm_t> q;
public:
	void push(qm_t&qm)
	{
		q.push(qm);
	}
	bool pop(qm_t&qm)
	{
		if(q.empty()) return false;
		qm=q.top();
		q.pop();
		return true;
	}
};


void min_u(int&m, int v)
{
	if(m>v) m=v;
}


int solve_i(vvpii&v, vi&f, vvi&dp, int sp, int rn)
{
	pq_t q;
	qm_t qm={sp, 0, (1<<rn)-1};

	qm.t&=~(1<<f[sp]);
	dp[qm.t][qm.p]=qm.c;
	q.push(qm);
	while(q.pop(qm))
	{
		if(!qm.t) return qm.c;

		for(auto&ve:v[qm.p])
		{
			qm_t nqm;

			nqm.p=ve.first;
			nqm.c=ve.second+qm.c;
			nqm.t=qm.t;
			if(f[nqm.p]>=0) nqm.t&=~(1<<f[nqm.p]);
			if(dp[nqm.t][nqm.p]<=nqm.c) continue;
			dp[nqm.t][nqm.p]=nqm.c;
			q.push(nqm);
		}
	}
	return 100000000;
}


int solve(vvpii&v, vi&r)
{
	int ans=100000*200*2;
	vi f(v.size(), -1);
	int rn=r.size();
	int n=v.size()-1;

	for(int i=0;i<rn;i++)
	{
		f[r[i]]=i;
	}

	vvi dp(1<<rn);
	for(auto&dpe:dp) dpe.assign(n+1, ans);

	for(int i=0;i<rn;i++)
	{
		solve_i(v, f, dp, r[i], rn);
	}
	for(int i=0;i<rn;i++)
	{
		min_u(ans, dp[0][r[i]]);
	}

	return ans;
}


int main(void)
{
	int n, m, rn;

	while(scanf("%d%d%d", &n, &m, &rn)==3)
	{
		vi r(rn);
		vvpii v(n+1);

		for(int i=0;i<rn;i++)
		{
			scanf("%d", &r[i]);
		}

		for(int i=0;i<m;i++)
		{
			int a, b, c;

			scanf("%d%d%d", &a, &b, &c);
			v[a].push_back(make_pair(b, c));
			v[b].push_back(make_pair(a, c));
		}

		printf("%d\n", solve(v, r));
	}

	return 0;
}


Measured memory_bytes: 2556
import sys

N, Y = list(map(int , input().split()))
for x in range(N+1):
    for y in range(N+1):
        z = N - x-  y
        if z >=0:
            if 10000*x+5000*y+1000*z ==Y:
                print('{} {} {}'.format(x,y,z))
                sys.exit()
print('-1 -1 -1')

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

int main()
{
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    vector<int>a[505];
    for(int i=0;i<m;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        a[l].push_back(r);
    }
    for(int i=1;i<=n;i++)
        sort(a[i].begin(),a[i].end());
    while(q--)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        int ans=0;
        for(int i=p;i<=k;i++)
            ans+=(upper_bound(a[i].begin(),a[i].end(),k)-a[i].begin());
        printf("%d\n",ans);
    }
}

 


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[100005];
	map<long long int,long long int> m;
	set<long long int>b,c;
	vector<long long int>e,d;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(m.find(a[i])==m.end())
		m.insert(mp(a[i],1));
		else
		m[a[i]]++;
	}
    map<long long int,long long int>::iterator it2;
	for(it2=m.begin();it2!=m.end();it2++)
	{
		if(it2->second>=2)
		b.insert(it2->first);
		if(it2->second>=4)
		c.insert(it2->first);
	}
	
    set<long long int>::iterator it,it1;
    for(it=b.begin();it!=b.end();it++)
    {
    	d.pb(*it);
	}
	for(it1=c.begin();it1!=c.end();it1++)
    {
    	e.pb(*it1);
	}
	
	
	if(d.size()<2&&e.size()==0)
	cout<<0;
	else if(d.size()<2&&e.size()>0)
	cout<<e[e.size()-1]*e[e.size()-1];
	else if(d.size()>1&&e.size()==0)
	cout<<d[d.size()-1]*d[d.size()-2];
	else if(e.size()>0&&d.size()>1)
	cout<<max(e[e.size()-1]*e[e.size()-1],d[d.size()-1]*d[d.size()-2]);
	
	
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, C, K;
	cin >> N >> C >> K;
	vector<ll> T(N);
	REP(i, N) cin >> T[i];
	sort(T.begin(), T.end());

	ll res = 0;
	ll i = 0;
	ll j = 0;
	while(1){
		//dump(i)
		//dump(j)
		if(i==N-1){
			res++;
			break;
		}
		while(T[j+1]<=T[i]+K && (j+1)-i+1<=C){
			j++;
			if(j==N-1) break;
		}
		res++;
		if(j==N-1){
			break;
		}
		i = j+1;
		j = i;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
/**
vector<int>ar(3);
for(auto&e:ar){
    scanf("%d",&e);
        }
sort(ar.begin(),ar.end())
int sum=accumulate(ar.begin(),ar.end(),0);
**/
//memo kyuridenamida 1237918
int c[1111],w[1111];
int s[1111];
int sum(int l,int r){
    return s[r] - (l?s[l-1]:0);
}
int dp[1010][1010];
int dfs(int l,int r){
    if( r == l ) return 1;
    if( dp[l][r] != -1 ) return dp[l][r];
    int ans = 0;
    if( sum(l+1,r) <= c[l] ) ans |= dfs(l+1,r);
    if( sum(l,r-1) <= c[r] ) ans |= dfs(l,r-1);
    return dp[l][r] = ans;
}
 
int dp2[1010];
int N;
 
int dfs2(int x){
    if( x == N ) return 0;
    if( dp2[x] != -1 ) return dp2[x];
    int ans = 1e9;
    for(int i = x ; i < N ; i++)
        if( dfs(x,i) )
            ans = min(ans,dfs2(i+1)+1);
    return dp2[x] = ans;
}
int main(){
    double pai=3.141592653589;
    memset(dp2,-1,sizeof(dp2));
 
    memset(dp,-1,sizeof(dp));
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> c[i] >> w[i];
        s[i] = (i?s[i-1]:0)+w[i];
    }
    cout << dfs2(0) << endl;
}

Measured memory_bytes: 7140
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3632
A=[]
B=[]
C=[]
while True:
  try:
    A.append(int(input()))
  except EOFError:
    break
    
for i in range(len(A)):
  count=0
  for j in range(len(A)):
    if A[i]==A[j]:
      count+=1
  B.append(count)
maxb=max(B)
for i in range(len(A)):
  if B[i]==maxb:
    if A[i] in C:
      pass
    else:
      C.append(A[i])
C.sort()
for i in range(len(C)):
  print(C[i])


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

double n;

int main() {
  cin >> n;

  for (int price = 0; price < 50001; price++) {
    if (floor(price * 1.08) == n) {
      cout << price << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) throws Exception {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] str = reader.readLine().split("");
		int[] count = new int[str.length + 1];
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("A") || str[i].equals("T") || str[i].equals("C") || str[i].equals("G")) {
				count[i+1] = count[i] + 1;
				if (i == str.length-1) {
					list.add(count[i+1]);
				}
			}
			else {
				list.add(count[i]);
			}
		}
		if (list.size() == 0) {
			list.add(count[str.length]);
		}
		int max = Collections.max(list);
		System.out.println(max);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int r,g,b;
  cin >> r >> g >> b;
  int seisu=r*100+g*10+b;
  if(seisu%4==0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import           Control.Exception (assert)
import           Data.List         (sort)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  assert (length xs == m) $ print $ solve n m xs

solve :: Int -> Int -> [Int] -> Int
solve n m = sum . take (m - n) . sort . withAdjacent (flip (-)) . sort

withAdjacent :: (a -> a -> b) -> [a] -> [b]
withAdjacent _ []        = error "empty"
withAdjacent f xs@(_:ys) = zipWith f xs ys


Measured memory_bytes: 32764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	char prev_S = S[0];
	int ans = 0;
	for (int i = 1; i < (int)(S.length()); i++) {

		if (prev_S != S[i]) ans++;
		prev_S = S[i];
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
//#define int long long
#define f(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define mi map<int,int>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
#define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();--i)
#define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
#define printv(v) for(auto i: v) cout<<i<<" "; cout<<endl;
#define r(a,n) int a[n+1]; f(i,1,n) cin>>a[i];
#define pi 3.141592653589793238
const int mod=1e9+7;
const int inf=1e18;
int vis[1000][1000]={};

bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
    if(a.se==b.se)
        return a.fi<b.fi;
}

int power(int x, unsigned int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

signed main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s;
        cin.ignore();
        cin>>t;
        int l=s.length();
        f(i,0,l-1)
        {
            if(s[i]!=t[i])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
}


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

int main()
{
//	freopen("input.txt","r",stdin);
	string s;
	cin>>s;
	int ans=0;
	int sum=s[0]-'0';
	ans+=s[0]-'0'-1;
	for (int i=1;i<s.length();i++)
	 {
	 	ans+=9;
	 	sum+=s[i]-'0';
	 }
	cout<<max(ans,sum)<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7, MOD = 1000 * 1000 * 1000 + 7, INF = 2e18;
int a[N], pref[N][2], t[N << 2], d[N];
void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = d[tl]; return;
    }   
    int tm = (tl + tr) >> 1;
    build(v * 2 + 1, tl, tm); build(v * 2 + 2, tm + 1, tr);
    t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
}   
int get(int v, int tl, int tr, int l, int r) {
    if (tr < l || r < tl) return INF;
    if (l <= tl && tr <= r) return t[v];
    int tm = (tl + tr) >> 1;
    return min(get(v * 2 + 1, tl, tm, l, r), get(v * 2 + 2, tm + 1, tr, l, r));
}  
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, A, B;
    cin >> n >> A >> B;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) d[i] = INF;
    for (int i = 0; i + 1 < n; ++i) d[i] = a[i + 1] - a[i];
    build(0, 0, N - 1);
    pref[0][0] = pref[0][1] = 1;
    for (int i = 1; i < n; ++i) {        
        if (A <= a[i] - a[i - 1]) pref[i][0] = (pref[i - 1][0] + pref[i - 1][1]) % MOD;
        else {
            int l = ub(a, a + n, a[i] - A) - a;
            if (get(0, 0, N - 1, l, i - 2) >= B) pref[i][0] = pref[l][1];
        }   
        if (B <= a[i] - a[i - 1]) pref[i][1] = (pref[i - 1][0] + pref[i - 1][1]) % MOD;
        else {
            int l = ub(a, a + n, a[i] - B) - a;
            bool c = 1;
            for (int j = l; j < i - 1; ++j) c &= a[j + 1] - a[j] >= A;
            if (get(0, 0, N - 1, l, i - 2) >= A) pref[i][1] = pref[l][0];
        }   
    }   
    cout << (pref[n - 1][0] + pref[n - 1][1]) % MOD << '\n';
}

Measured memory_bytes: 7036
#include <bits/stdc++.h>
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 INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    string s;
    cin>>s;
    ll i;
    for(i=0;i<3;i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\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: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;

  priority_queue<int> Q;

  rep (i, n) {
    int a;  cin >> a;
    Q.push(a);
  }

  rep (i, m) {
    int a = Q.top();  Q.pop();
    Q.push(a/2);
  }

  ll ans = 0;
  rep (i, n) {
    ans += Q.top();  Q.pop();
  }

  // cout << ans << endl;
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 892
import sys
input=lambda: sys.stdin.readline().rstrip()
n,x,y=map(int,input().split())
x-=1
y-=1
Ans=[0]*(n-1)
for i in range(n):
  for j in range(i+1,n):
    d=j-i
    if i<=x<=j<=y:
      d=min(d,x-i+y-j+1)
    if i<=x<=y<=j:
      d=min(d,x-i+j-y+1)
    if x<=i<=j<=y:
      d=min(d,i-x+y-j+1)
    if x<=i<=y<=j:
      d=min(d,i-x+j-y+1)
    Ans[d-1]+=1
for a in Ans:
  print(a)



Measured memory_bytes: 50140
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	s := make(map[string]int)
	for i := 0; i < N; i++ {
		a := getString()
		s[a]++
	}
	out(len(s))
}


Measured memory_bytes: 18336
#!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] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    c = s.count("0")
    print(2*min(c,len(s)-c))
    return

#B
def B():
    n = I()
    h = LI()
    ans = 0
    m = min(h)
    while m:
        ans += m
        k = max(h)
        for i in range(n):
            if h[i] >= m:
                h[i] -= m
                if h[i]:k = min(k,h[i])
            else:break
        m = k
    print(ans)
    return

#C
def C():
    n,k = LI()
    x = LI()
    ans = float("inf")
    j = bisect.bisect_left(x,0)
    if n == 1:
        print(abs(x[0]))
        quit()
    if j < n:
        if x[j] == 0:
            k -= 1
            x.pop(j)
            n -= 1
    for i in range(n):
        if i < j:
            if abs(i-j) > k:continue
            elif abs(i-j) == k:ans = min(ans,abs(x[i]))
            elif k+i-1 < n:
                ans = min(ans,abs(x[i])+x[k+i-1]-x[i])
        else:
            if abs(i-j)+1 > k:continue
            elif abs(i-j)+1 == k:ans = min(ans,x[i])
            elif i-k+1 >= 0:
                ans = min(ans,abs(x[i])+x[i]-x[i-k+1])

    print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    ans = 0
    p = [1<<i for i in range(100)]
    for i in range(n):
        l = 0
        r = 100
        while r-l > 1:
            m = (l+r)//2
            if a[i]%p[m] == 0:
                l = m
            else:
                r = m
        ans += l
    print(ans)
    return

#E
def E():
    s = LI()
    s.sort()
    ans = s[2]-s[1]
    s[0] += s[2]-s[1]
    s[1] = s[2]
    if s[0]%2 != s[1]%2:
        ans += (s[1]+1-s[0])//2+1
    else:
        ans += (s[1]-s[0])//2
    print(ans)
    return

#F
def F():
    n = I()
    s = SR(n)
    for i in range(n):
        d = defaultdict(int)
        for j in range(len(s[i])):
            d[s[i][j]] += 1
            s[i][j] += str(d[s[i][j]])
    ans = set(s[0])
    for i in range(1,n):
        ans = ans&set(s[i])
    ans = list(ans)
    ans.sort()
    for i in ans:
        print(i[0],end = "")
    print()
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

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


Measured memory_bytes: 41456