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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_V 1000

int m, n, v;
vector<int> g[MAX_V];
int match[MAX_V];
bool used[MAX_V];

int euclidean(int a, int b) {
  if (a == 0) return b;
  else euclidean(b % a, a);
}

bool dfs(int i) {
  used[i] = true;
  rep(j, g[i].size()) {
    int u = g[i][j], w = match[u];
    if (w < 0 || !used[w] && dfs(w)) {
      match[i] = u;
      match[u] = i;
      return true;
    }
  }
  return false;
}

int bipartiteMatching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  rep(i, v) {
    if (match[i] < 0) {
      memset(used, 0, sizeof(used));
      if (dfs(i)) res++;
    }
  }
  return res;
}

int main(){
  cin.sync_with_stdio(false);
  while(cin >> m >> n, m | n) {
    v = m + n;
    rep(i, v) g[i].clear();

    vector<int> b(m), r(n);
    rep(i, m) cin >> b[i];
    rep(i, n) cin >> r[i];
    rep(i, m)rep(j, n) if (euclidean(b[i], r[j]) > 1) g[i].pb(m + j), g[m + j].pb(i);

    cout << bipartiteMatching() << endl;
  }

  return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll a, b, c;
    cin>>a>>b>>c;

    ll ans = 0;
    if(a % 2 == 1 or b % 2 == 1 or c % 2 == 1){
        ans = 0;
    }else if(a == b and b == c){
        ans = -1;
    }else{
        while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0){
            ll ax = a / 2;
            ll bx = b / 2;
            ll cx = c / 2;
            a = bx + cx;
            b = ax + cx;
            c = ax + bx;
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    int k;
    cin >> k;
    vector<int> s={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};

    cout<<s[k-1]<<endl;

 return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,a[200005];
long long ans;
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;++i) scanf("%d",&a[i]);a[0]=-1;
	for(int i=1;i<=n+1;++i) {
		if(a[i]==a[i-1]+1) continue;
		else if(a[i]>a[i-1]+1) {printf("-1\n");return 0;}
		else ans+=(long long)a[i-1];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int v[101][101];
int a[101][101];
int d[101];
int pi[101];
char color[101];
int n,mincost,sumcost=0;

void dijkstra(void);

int main(){
  int i,j,u,k,s;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d" ,&u,&k);      
  for(j=1;j<=k;j++){
     scanf("%d",&v[u][j]);
     scanf("%d",&a[u][v[u][j]]);
     /*printf("%d %d\n",v[u][j],a[u][v[u][j]]);*/
  }
  /* printf("%d\n",u);*/
  }
  /*for(i=0;i<n;i++){
   for(j=0;j<n;j++){
     printf("%d ",a[i][j]);
   } printf("\n");
  }*/

  dijkstra();

  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}

void dijkstra(void){
  int i,j,u;
  for(i=0;i<n;i++){
    d[i]=1000000;
    pi[i] = -1;
    color[i]='W';
  }
  d[0]=0;
  while(1){
    mincost = 2000000;
    for(i=0;i<n;i++){
      if(color[i]!='B' && d[i] < mincost){
	mincost = d[i];
        u = i;
      }
    }
    if(mincost==2000000) break;
    color[u]='B';
  
  for(i=0;i<n;i++){
    if(color[i]!='B' && a[u][i]!=0  && d[u]+a[u][i]<d[i]){
      pi[i] = u;
      d[i]=d[u]+a[u][i];
     }
  }
  }
}

Measured memory_bytes: 680
def print_ab(s, a, b):
    print(s[a:b+1])

def reverse_ab(s, a, b):
    s_f = s[:a]
    s_m = s[a:b+1]
    s_l = s[b+1:]
    return s_f+s_m[::-1]+s_l
def replace_ab(s, a, b, p):
    s_f = s[:a]
    s_l = s[b+1:]
    return s_f+p+s_l

s = input()
q = int(input())
for i in range(q):
    option = input().split()
    if option[0] == "print":
        print_ab(s,int(option[1]),int(option[2]))
    elif option[0] == "reverse":
        s = reverse_ab(s, int(option[1]), int(option[2]))
    elif option[0] == "replace":
        s = replace_ab(s, int(option[1]), int(option[2]), option[3])

Measured memory_bytes: 7684
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DSummerVacation {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m,t=0;
        in>>n>>m;
        vector<pair<int,int>> ab(n);
        fr(i,n) in>>ab[i].first>>ab[i].second,ab[i].second*=-1;
        sort(ab.begin(),ab.end());
        priority_queue<int> pq;
        ll ans=0;
        int i=0;
        Fr(j,m){
            while(ab[i].first<=j) pq.push(-ab[i].second),++i;
            if(!pq.empty()) ans+=pq.top(),pq.pop();
        }
        out<<ans<<endl;
    }
};

int main() {
    DSummerVacation solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1660
import sys

input = sys.stdin.readline

H, W, A, B = list(map(int,input().split()))

out = [[0]*W for i in range(H)]

for y in range(B):
	for x in range(A):
		out[y][x] = 1

for y in range(B,H):
	for x in range(A,W):
		out[y][x] = 1

for i in out: print(*i, sep='') 

Measured memory_bytes: 78172
H, W = map(int, input().split())

mi = min(H, W)
if H % 3 == 0 or W % 3 == 0:
    mi = 0

for i in range(H):
    a, b, c = W * i, W//2 * (H-i), (W - W//2) * (H-i)
    mi = min(mi, max(a, b, c) - min(a, b, c))

for i in range(W):
    a, b, c = H * i, H//2 * (W-i), (H - H//2) * (W-i)
    mi = min(mi, max(a, b, c) - min(a, b, c))

print(mi)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n, maxi = -1000005, mini=1000005, max_idx=0, min_idx=0;
  cin >> n;
  vector<int> data(n);

  for(int i = 0; i < n; i++){
    cin >> data[i];
    if(maxi < data[i]){
      maxi = data[i];
      max_idx = i;
    }
    if(data[i] < mini){
      mini = data[i];
      min_idx = i;
    }
  }

  vector<int> DEBUG = data;
  
  int add, add_idx;
  if(abs(mini) < abs(maxi)){
    add = maxi;
    add_idx = max_idx + 1;
  }else{
    add = mini;
    add_idx = min_idx + 1;
  }

  // cout << "add_idx: " << add_idx << endl;
  
  vector<pair<int,int>> ans;
  for(int i = 0; i< n; i++){
    ans.pb(mp(add_idx, i + 1));
    DEBUG[i] += add; 
  }

  if(add>=0){
    for(int i = 1; i < n; i++){
      DEBUG[i] += DEBUG[i-1];
      ans.pb(mp(i, i + 1));
    }
  }else{
    for(int i = n - 1; i > 0; i--){
      DEBUG[i - 1] += DEBUG[i];
      ans.pb(mp(i + 1, i));
    }
  }

  
  /*for(auto x : DEBUG)cout << x << " ";
  cout << endl;
  */
  cout << ans.size() << endl;
  
  for(auto x : ans){
    cout << x.first << " " << x.second << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static int N;
    private static int M;
    private static int[][] s;
    private static int[] p;

    private static void read() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        s = new int[M][];
        for (int m = 0; m < M; m += 1) {
            int k = sc.nextInt();
            int[] sm = new int[k];
            for (int ki = 0; ki < k; ki += 1) {
                sm[ki] = sc.nextInt();
            }
            s[m] = sm;
        }
        p = new int[M];
        for (int m = 0; m < M; m += 1) {
            p[m] = sc.nextInt();
        }
    }

    public static void main(String[] args) {
        read();

        int cnt = 0;
        for (int bit = 0; bit < (1 << N); bit += 1) {
            List<Integer> switches = new LinkedList<>();
            for (int s = 0; s < N; s += 1) {
                if ((bit & (1 << s)) != 0) {
                    switches.add(s + 1);
                }
            }
            cnt += isOn(switches);
        }

        System.out.println(cnt);
    }

    private static int isOn(List<Integer> switches) {
        for (int m = 0; m < M; m += 1) {
            int cnt = 0;
            for (int s : s[m]) {
                cnt += switches.contains(s) ? 1 : 0;
            }
            if (cnt % 2 != p[m]) {
                return 0;
            }
        }
        return 1;
    }

}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int d, g; cin >> d >> g;
    vector<Pll> p(d);
    rep(i, d)
    {
        ll a, b; cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    ll ans = INF;
    rep(i, 1 << d)
    {
        ll tot = 0, cnt = 0;
        rep(j, d)
        {
            if (i >> j & 1)
            {
                tot += p[j].first * (j + 1) * 100 + p[j].second;
                cnt += p[j].first;
            }
        }
        if (tot >= g)
            ans = min(ans, cnt);
        else
        {
            for (int j = d - 1; j >= 0; --j)
            {
                if (i >> j & 1)
                    continue;
                rep(k, p[j].first)
                {
                    if (tot >= g)
                        break;
                    tot += 100 * (j + 1);
                    cnt++;
                }
            }
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,n;
	while(scanf("%d",&n)!=EOF) {
		if(n%39==0) cout<<"3C39"<<endl;
		else if(n%39<10)cout<<"3C0"<<n%39<<endl;
		else cout<<"3C"<<n%39<<endl;
	}
}

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

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    int n=Integer.parseInt(reader.readLine());
	    int result=0;
	    
		result=n/25;
		n=n%25;
		result+=n/10;
		n=n%10;
		result+=n/5;
		n=n%5;
	    
		
	    System.out.println(result+n);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}



Measured memory_bytes: 24472
import java.util.*;
class Main{
	public static void main(String[]args){
		Scanner cin=new Scanner(System.in);
		int i,n;
		int[] a=new int[31];
		a[0]=a[1]=1;a[2]=2;
		for(i=3;i<31;i++)a[i]=a[i-1]+a[i-2]+a[i-3];
		for(;(n=cin.nextInt())>0;System.out.println((a[n]+3649)/3650));
	}
}

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

namespace ABC068A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            Console.WriteLine("ABC" + n);

            Console.ReadKey();
        }
    }
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

vvll p(100001,vll(0,0));
vpl4 o(100001,mp(0,0));

pair<ll,ll> solve(ll t){
    if(o[t].fi>0) return o[t];
    pair<ll,ll> q=mp(0,0);
    ll d=0;
    ll r=0;
    for(auto l:p[t]){
        q=solve(l);
        if(q.se>=d){
            d=q.se+1;
            r=l;
        }
    }
    return o[t]=mp(r,d);
}

signed main()
{
    llin(n);
    llin(m);
    ll a,b=0;
    FOR(i,0,n-2+m){
        cin >>a>>b;
        p[b].pb(a);
    }
    FOR(i,1,n){
        sal(solve(i).fi)
    }
}

Measured memory_bytes: 11776
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
ll __lcm(ll a,ll b){
	return a/__gcd(a,b)*b;
}
void mainmain(){
	int n;
	while(cin>>n,n){
		vector<pll> v(n);
		rep(i,n) scanf("%lld %lld",&v[i].F,&v[i].S);
		ll g=v[0].F;
		reep(i,1,n){
			g=__lcm(v[i].F,g);
			// g=v[i+1].S/__gcd(g,v[i+1].S)*g;
		}
		// cout<<"g "<<g<<endl;
		rep(i,n){
			// ll t=g/v[i].S;
			v[i].S=g*v[i].S/v[i].F;
		}
		ll e=v[0].S;
		reep(i,1,n){
			e=__gcd(e,v[i].S);
		}
		rep(i,n){
			printf("%lld\n",v[i].S/e);
		}
		continue;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1208
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
  long A = getLong();
          long B = getLong();
  if(A == B){
     myout(A);
    return;
  }
  if(A % 2 == 1 && B % 2 == 0){
     long center = (B - A - 1) / 2;
    myout(A ^ B ^ (center % 2));
  }else if(A % 2 == 1 && B % 2 == 1){
     long center = (B - A) / 2;
    myout(A ^ (center % 2));
  }else if(A % 2 == 0 && B % 2 == 0){
    long center = (B - A) / 2;
    myout(B ^ (center % 2));
  }else{
    long center = (B - A + 1) / 2;
    myout(center % 2);
  }
        }
        //Method addition frame start

        //Method addition frame end
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(void)
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(a >= b){
        printf("delicious");
    }
    else if(a+x >= b){
        printf("safe");
    }
    else{
        printf("dangerous");
    }
    return 0;
}

Measured memory_bytes: 128
n=int(input())
a=sorted(list(map(int,input().split())))
a.append(0)
ans,x,count=0,a[0],0
for i in a:
  if x==i:
    count+=1
  else:
    ans+=count if count<x else count-x
    count=1
    x=i
print(ans)

Measured memory_bytes: 14268
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, a, b; cin >> n >> a >> b;
  a -= b;
  vector<long long> h(n); REP(i, n) cin >> h[i];
  long long lb = 0, ub = 1e9;
  while (ub - lb > 1) {
    long long mid = (lb + ub) / 2, cnt = 0;
    REP(i, n) {
      long long tmp = h[i] - b * mid;
      if (tmp > 0) cnt += (tmp + a - 1) / a;
    }
    (cnt <= mid ? ub : lb) = mid;
  }
  cout << ub << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		
		if(S.charAt(K - 1) == 'A') {
			S = S.substring(0, K - 1) + "a" + S.substring(K, S.length());
		} else if(S.charAt(K - 1) == 'B') {
			S = S.substring(0, K - 1) + "b" + S.substring(K, S.length());
		} else if(S.charAt(K - 1) == 'C') {
			S = S.substring(0, K - 1) + "c" + S.substring(K, S.length());
		}
		System.out.println(S);
	
	}
}


Measured memory_bytes: 21716
s = input()

pre = int(s[:2])
post = int(s[2:])

na = False

if 0<pre and pre < 13:
    pre_able_month = True
elif pre == 0:
    na = True
    pre_able_month = False
else:
    pre_able_month = False

if 0<post and post<13:
    post_able_month = True
elif post == 0:
    na = True
    post_able_month = False
else:
    post_able_month = False

if na:
    if pre_able_month:
        print("MMYY")
    elif post_able_month:
        print("YYMM")
    else:
        print("NA")
else:
    if pre_able_month and post_able_month:
        print("AMBIGUOUS")
    elif pre_able_month and not(post_able_month):
        print("MMYY")
    elif not(pre_able_month) and post_able_month:
        print("YYMM")
    else:
        print("NA")
    

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

void solve(){
  int n, cnt = 0; cin >> n;
  long long x = 1000000000, sum = 0;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] < 0) cnt++;
    sum += abs(a[i]);
    x = min(x, abs(a[i]));
  }
  if(cnt % 2 == 0){
    cout << sum << endl;
  }
  else{
    cout << sum - x * 2 << endl;
  }

  return;
}

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


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String w = scanner.next();
		boolean c = true;
		for(int i=0;i<w.length();i++){
			if(check(w,w.charAt(i))){
				c = true;
			}else{
				c = false;
				break;
			}
		}
		if(c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	public static boolean check(String s,char c){
		int count = 0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i) == c){
				count++;
			}
		}
		if(count%2 == 0){
			return true;
		}else{
			return false;
		}
	}
}


Measured memory_bytes: 21076
def check(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            return True
    return False


N, A, B, C, D = map(int, input().split(" "))
S = input()
A -= 1; B -= 1; C -= 1; D -= 1;

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B-1:D+2]) and check(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 40432
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,t;
  cin >> n >> t;
  int a[n];
  rep(i,n)cin >> a[i];
  vector<int> v;
  int m=a[0],M=a[0];
  int temp=0;
  rep(i,n){
    if(m>a[i]){
      v.push_back(M-m);
      m=a[i];
      M=a[i];
    }
    if(M<a[i]){
      M=a[i];
    }
    if(i==n-1)v.push_back(M-m);
  }
  sort(v.begin(),v.end());
  int it=upper_bound(v.begin(),v.end(),v[v.size()-1])-lower_bound(v.begin(),v.end(),v[v.size()-1]);
  cout << it << endl;
return 0;}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, a;
	ll ans = 1;
	cin >> num;
	vector<int> d(num, 0);
	for (i = 0; i < num; i++) {
		cin >> a;
		if (a > 0) {
			ans *= d[a - 1] - d[a];
			ans %= MOD;
		}
		d[a]++;
	}
	for (i = 0; i < d[0]; i++) {
		ans *= 3 - i;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;

int main(void){
  unsigned long N;
  cin >> N;
  string s;
  cin >> s;
  string clone = s;
  vector<int> W;
  vector<int> R;
  int w_cnt = 0, r_cnt = 0;

  for(int i =0; i < N; i++){
    if(s[i] == 'W'){
      w_cnt++;
    }
    W.push_back(w_cnt);
    if(s[(N-1)-i] == 'R'){
      r_cnt++;
    }
    R.push_back(r_cnt);
  }
  reverse(R.begin(), R.end());

  int te = 0;
  
  for(int i =0; i < N ; i++){
    //cout << W[i] << ":" << R[i+1] << endl;
    if(R[i+1] == W[i]){
      te = W[i];
      break;
    }
  }
  cout << te << endl;
}

Measured memory_bytes: 5564
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, M, A[112345];

int main() {

	scanf("%d%d", &N,&M);
	rep(i, N) scanf("%d", &A[i]);

	priority_queue<int> pq;
	rep(i, N) pq.push(A[i]);

	rep(i, M) {
		int c = pq.top();
		pq.pop();
		pq.push(c / 2);
	}

	ll ans = 0;

	rep(i, N) {
		ans += pq.top();
		pq.pop();
	}

	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 1276
n = int(input())
xys = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        xys[i].append((x-1, y))

ans = 0
for i in range(1<<n):
    ok = True
    for j in range(n):
        # if jth person may be honest, verify testimony of him.
        if (i>>j) & 1 == 1:
            for xy in xys[j]:
                x, y = xy
                if (i>>x) & 1 != y:
                    ok = False
                    break
        if not ok:
            break
    if ok:
        ans = max(ans, bin(i).count('1'))
print(ans)


Measured memory_bytes: 42992
open Printf
open Scanf

let id x = x
let pair x y = x, y

let vs = scanf "%d %d %d" (fun x y z -> [|x; y; z|])

let () = Array.sort compare vs

let () =
  let x = vs.(2) * 10 + vs.(1) + vs.(0) in
  printf "%d\n" x


Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "APPROVED\n";
#define no cout << "DENIED\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n;
    cin >> n;
    v a = ga(n);

    for (auto x : a) {
        if (!(x & 1)) {
            if (x % 3 != 0 && x % 5 != 0)
                noo;
        }
    }

    yes;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
    int a,b,c,n;
    cin>>n;
    a=n%10;
    n=n/10;
    b=n%10;
    n=n/10;
    c=n;
    if(a==7 || b==7 || c==7){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a;
  cin >> a;
  if (a >= 30) puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3592
N, M = map(int, input().split())

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
            if not flag:
                break
        
        if flag:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(N: int, H: "List[int]"):
    ans = 1
    h = H[0]
    for i in range(1, len(H)):
        if(H[i] >= h):
            ans += 1
            h = H[i]

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#define inf 1e9

using namespace std;

int N;
int a[105];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> a[i];
	
	int ans = inf, cost;
	for(int c = -100; c <= 100; c++){
		cost = 0;
		for(int i = 0; i < N; i++){
			cost += (a[i] - c)*(a[i] - c);
		}
		ans = min(ans, cost);
	}
	
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int n;

	while(true){
		std::cin >> n;
		if ( n == 0 ) break;

		std::vector<int> v(n,0);

		for ( int i = 0; i < n; ++i ) {
			std::cin >> v[i];
		}

		std::sort(v.begin(), v.end());

		int sum = 0;
		for ( int i = 1; i < n-1; ++i ) {
			sum += v[i];
		}
		std::cout << sum / (n-2) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3136
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k;
string s,ss;
vector<int> v;

inline int solve(){
	cin>>s>>ss;
	if(s.size()==ss.size()){
		for(int i=0;i<(int)ss.size();i++){
			cout<<s[i]<<ss[i];
		}
		return 0;
	}
	else{
		for(int i=0;i<(int)ss.size();i++){
			cout<<s[i]<<ss[i];
		}
		cout<<s[s.size()-1];
	}
	return 0;
}

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


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N, S):
    if N % 2 != 0:
        return False

    for i in range(N // 2):
        if S[i] != S[i + N // 2]:
            return False
    return True


def main():
    N = int(input())
    S = input()


    if solve(N, S):
        print(YES)
    else:
        print(NO)

if __name__ == '__main__':
    main()


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

int main() {
  int a,b;
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  a = s1.size();
  b = s2.size();
  if(s1[a-1] == s2[0] && s2[b-1] == s3[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int N;
long long h[100010];
long long dp[100010];
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
  cin >> h[i];
  }
  for(int i=0;i<100010;i++){
  dp[i]=1000000000;
  }
  dp[0]=0;
  for(int i=0;i<N;i++){
  chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
  chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[N-1] << endl;
}
  
  
  
  

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define puba push_back
#define ff first
#define ss second
#define bend(_x) begin(_x), end(_x)
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);

mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }

const ll MOD = 998244353;
const int MAXN = 1e6 + 5;

ll fact[MAXN];

ll mpow(ll a, ll b) {
    if (!b) {
        return 1;
    }
    ll tmp = mpow(a, b / 2);
    tmp = tmp * tmp % MOD;
    if (b & 1) {
        tmp = tmp * a % MOD;
    }
    return tmp;
}

ll inv(ll a) {
    return mpow(a, MOD - 2);
}

ll cnk(int n, int k) {
    return fact[n] * inv(fact[k]) % MOD * inv(fact[n - k]) % MOD;
}

ll buckets(int a, int b) {
    return cnk(a + b - 1, b - 1);
}

char buf[MAXN];
int a[MAXN], b[MAXN];

const int SZ = 10005;
ll d[SZ][SZ];

void add(ll& a, ll b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
}

int main() {
    //freopen(TASK_NAME ".in", "r", stdin);
    //freopen(TASK_NAME ".out", "w", stdout);
    cerr << fixed << setprecision(15);
    cout << fixed << setprecision(15);
    
    scanf("%s", buf);

    int n = strlen(buf);
    for (int i = 0; i < n; ++i) {
        a[i] = buf[i] - '0';
    }

    scanf("%s", buf);

    for (int i = 0; i < n; ++i) {
        b[i] = buf[i] - '0';
    }

    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
    }

    int t[3] = {0, 0, 0};
    int tot = 0;
    for (int i = 0; i < n; ++i) {
        tot += a[i];
        if (a[i] == 1 && b[i] == 1) {
            ++t[0];
        } else if (a[i] == 1 && b[i] == 0) {
            ++t[1];
        } else if (a[i] == 0 && b[i] == 1) {
            ++t[2];
        }
    }

    if (t[1] != t[2]) {
        cout << "0\n";
        return 0;
    }

    ll ans = fact[t[1]];

    d[0][0] = 1;
    for (int i = 0; i <= t[1]; ++i) {
        //for (int j = 0; j <= t[1] && i + j <= t[1]; ++j) {
            for (int k = 0; k <= t[0]; ++k) {
                if (i < t[1]) {
                    add(d[i + 1][k], d[i][k] * (t[1] - i) % MOD);
                }
                if (i > 0 && k < t[0]) {
                    add(d[i][k + 1], d[i][k] * (t[0] - k) % MOD * i % MOD);
                }
            }
        //}
    }

    ll val = 0;
    for (int i = 0; i <= t[0]; ++i) {
        //cerr << cnk(t[0], i) << " " << fact[i] << " " << buckets(i, t[1]) << " " << fact[t[0] - i] << endl;
        //ll sum = 0;
        //cerr << d[t[1]][i] << endl;
        ll now = d[t[1]][i] * cnk(tot, t[1] + i) % MOD * fact[t[0] - i] % MOD * fact[t[0] - i] % MOD;
        //cerr << i << " " << now << endl;
        val = (val + now) % MOD;
    }

    ans = ans * val % MOD;

    cout << ans << "\n";
    
    #ifdef LOCAL
        cerr << "time: " << clock() << endl;
    #endif
    return 0;
}

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

int n;
string s[55];

int main() {
  // 入力
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  // aから順に全部の文字列に共通してある個数を数えて、それを結合したものが答え
  string ans = "";
  for (char c = 'a'; c <= 'z'; c++) {
    int mini = 100;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == c) cnt++;
      }
      mini = min(mini, cnt);
    }
    // 共通する個数分文字を後ろに追加（後ろに追加することで自然に辞書順になる）
    for (int i = 0; i < mini; i++) {
      ans += c;
    }
  }
  // 解答
  cout << ans << endl;
  return 0;
}


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

using namespace std;

vector<pair<char, int> > seq;

void initSeq(string &s)
{
    char current = s[0];
    int len = 0;
    for(int i = 0 ; i < s.size(); i++){
        if(s[i] == current){
            len++;
        }else{
            seq.push_back(make_pair(current, len));
            len = 1;
            current = s[i];
        }
    }
    seq.push_back(make_pair(current, len));
    /*
    for(int i = 0 ; i < seq.size(); i++){
        printf("%c %d\n", seq[i].first, seq[i].second);
    }
    */
}

int main(void)
{
    int n, k;
    cin >>n >>k;

    string s;
    cin >>s;

    initSeq(s);

    bool first = true;
    int r = 0, l = 0, ignore = 0;
    int maxScore = 0;
    int currentScore = 0;
    for(int i = 0; i < seq.size(); i++ ){
        if(seq[i].first == '0'){
            currentScore += seq[i].second;
            ignore++;
            if(ignore > k){
                if(seq[l].first == '1'){
                    currentScore -= seq[l].second;
                    l++;
                }
                if(seq[l].first == '0'){
                    currentScore -= seq[l].second;
                    l++;
                }
                ignore--;
            }
            maxScore = max(maxScore, currentScore);
        }else{
            currentScore += seq[i].second;
            maxScore = max(maxScore, currentScore);
        }
        //printf("DDD %d %d\n", i, maxScore);

    }
    printf("%d\n", maxScore);
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
	int n;cin>>n;
	ll ma=pow(10,6)+10;
	vector<ll>cnt(ma,0);
	vector<ll>p(n);
	rep(i,n){
		cin>>p[i];
		cnt[p[i]]++;
	}
	
	sort(all(p));
	int ans=0;
	rep(i,n){
		if(cnt[p[i]]==1)ans++;
		if(cnt[p[i]]==0)continue;
		cnt[p[i]]=0;
		for(ll j=p[i]+p[i];j<ma;j+=p[i]){
			cnt[j]=0;
		}
	}
	cout<<ans<<endl;
	/*multiset<ll>a;
	rep(i,n){
		int x;a.insert(x);
	}
	int ans=0;
	while(!a.empty()){
		ll p=*a.begin();
		//cout<<1<<endl;
		a.erase(a.begin());
		int is=1;
		while(a.size()!=0 and *a.begin()==p){
			is=0;
			//cout<<2<<endl;
			a.erase(a.begin());
		}
		ans+=is;
		ll x=p+p;
		while(x<pow(10,6)){
			//cout<<3<<endl;
			if(a.find(x)!=a.end())a.erase(x);
			x+=p;
		}
	}
	cout<<ans<<endl;*/
  	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(15);
  solve();
}


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);

    if(a[0]==5 && a[1]==5 && a[2]==7)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())

abc = np.array([list(map(int, input().split())) for i in range(N)])

dp = [[0]*3 for i in range(N+1)]

for i in range(1, N+1):
    dp[i][0] = max(dp[i - 1][1] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][2])
    dp[i][1] = max(dp[i - 1][0] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][2])
    dp[i][2] = max(dp[i - 1][1] + abc[i - 1][1], dp[i - 1][0] + abc[i - 1][0])

print(max(max(dp)))

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

struct Point{
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    
    Point operator + (Point p) const {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) const {return Point(x-p.x,y-p.y);}
    Point operator * (double d) const {return Point(x*d,y*d);}
    
    double SqrLength() const{
        return x*x+y*y;
    }
    
    void Read(){
        scanf("%lf%lf",&x,&y);
    }
    
    void Write(){
        printf("%.10f %.10f\n",x,y);
    }
    
    double x,y;  

    friend double Dot(Point p1,Point p2){
        return p1.x*p2.x+p1.y*p2.y;
    }
};

struct Line{
    Line(){}
    Point s,t;
    
    friend Point Project(Point p,Line l){
        Point dir=l.t-l.s;
        return l.s+dir*(Dot(dir,p-l.s)/dir.SqrLength());
    }
    
    friend Point Reflect(Point p,Line l){
        Point q=Project(p,l);
        Point ret=q*2-p;
        return ret;
    }
};

int main(){
    Line l;
    l.s.Read(); l.t.Read();
    int n; scanf("%d",&n);
    while(n--){
        Point p,q;
        p.Read();
        q=Reflect(p,l);
        q.Write();
    }
    return 0;
}


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

int main(){
    string S,T;
    int sum=0;
    cin >> S >> T;
    for(int i=0;i<3;i++){
        if(S[i]==T[i]) sum += 1;
    }
    cout << sum;
    return 0;
}

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

#define Max 50000
bool IsPrime[Max];

int main()
{
	for (int i = 2; i < Max; i++) IsPrime[i] = true;
	for (int i = 2; i < Max; i++)
	{
		if (!IsPrime[i]) continue;
		for (int j = i + i; j < Max; j += i)
		{
			IsPrime[j] = false;
		}
	}

	int n;
	while (cin >> n, n)
	{
		int count = 0;
		for (int i = 0; i <= n / 2; i++)
		{
			if (IsPrime[i] && IsPrime[n - i]) count++;
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n - 1) {
		if(s[i] == s[i + 1]) {
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}
	}
	rep(i, n - 2) {
		if(s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
X, N = (int(i) for i in input().split())  
p = list(int(i) for i in input().split())  
cnt = 1000
res = 0
for i in range(110):
  if i in p :
    cnt = cnt
  else:
    if abs(X-i) < cnt :
      cnt = abs(X-i)
      res  = i
print(res)

Measured memory_bytes: 9204