akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

#define MAXN 100000
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<ll, int>> adj[MAXN];
ll d[MAXN];

void dijkstra(int a) {
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> PQ;
    int color[n];
    rep(i, n) {
        color[i] = WHITE;
        d[i] = LINF;
    }

    d[a] = 0;
    PQ.push(make_pair(d[a], a));
    color[a] = GRAY;

    while(!PQ.empty()) {
        pair<ll, int> f = PQ.top();
        PQ.pop();
        ll cst = f.first;
        int u = f.second;
        color[u] = BLACK;
        if (d[u] < cst) continue;

        for (int i = 0; i < (int)adj[u].size(); ++i) {
            int v = adj[u][i].second;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][i].first) {
                d[v] = d[u] + adj[u][i].first;
                PQ.push(make_pair(d[v], v));
                color[v] = GRAY;
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a, --b;
        adj[a].push_back(make_pair(c, b));
        adj[b].push_back(make_pair(c, a));
    }

    int q, k;
    cin >> q >> k;
    --k;
    dijkstra(k);

    rep(i, q) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        cout << d[x] + d[y] << endl;

    }
    


    return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int s, t;
    cin >> s;
    bool a[1000000] = {};
    a[s] = true;
    t = s;
    for (int i = 2;;i++) {
        if (t%2 == 0) t = t/2;
        else t = 3 * t + 1;

        if (a[t] == false) a[t] = true;
        else {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(void){
    int d=0,n=0;
    int i,a=1;
    int b=0;
  
    scanf("%d %d",&d,&n);
    
    for(i=0; i<d; i++)
    a = a*100;
    
    b = a*n;
    if(d == 0 && n==100)
    b = 101;
    if(d == 1 && n==100)
    b = b + 100;
    if(d == 2 && n==100)
    b = b + 10000;
    
    printf("%d\n",b);
      
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	if(a==25)
	{
		cout << "Christmas";
	}
	
	if(a==24)
	{
		cout << "Christmas Eve";
	}
	
	if(a==23)
	{
		cout << "Christmas Eve Eve";
	}
	
	if(a==22)
	{
		cout << "Christmas Eve Eve Eve";
	}
	
	return 0;
}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int d, t, s;
    cin >> d >> t >> s;

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

    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<cctype>
using namespace std;

int main(){ 
    char a;

    while(1){
        scanf("%c", &a);
        if(a == '\n'){
            break;
        }
        if(a >= 'A' && a <= 'Z'){
            a = a + 32;
        }    
        else if(a >= 'a' && a <= 'z'){
            a = a - 32;
        }
    
        printf("%c",a);
    }
    printf("\n");

}


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

int a[505][505];
int n;

void solve(int now, int l, int r)
{
	if (l == r) return;
	
	int mid = (l + r) >> 1;
	for(int i = l; i <= mid; i++)
		for(int j = mid + 1; j <= r; j++)
			a[i][j] = now;
	
	solve(now + 1, l, mid);
	solve(now + 1, mid + 1, r);
}

int main()
{
	scanf("%d", &n);
	solve(1, 1, n);
	for(int i = 1; i < n; i++)
	{ 
		printf("%d", a[i][i + 1]);
		for(int j = i + 2; j <= n; j++)
			printf(" %d", a[i][j]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
int main(){
    int n,c;cin>>n>>c;
    vector<vector<int>>D(c,vector<int>(c));
    rep(i,c){
        rep(j,c)cin>>D[i][j];
    }
    vector<vector<int>>V(3,vector<int>(c,0));
    int x;
    rep(i,n){
        rep(j,n){
            cin>>x;
            V[(i+j)%3][x-1]++;
        }
    }
    ll ans=INF;ll com=0;
    rep(i,c){
        rep(j,c){
            rep(k,c){
                com=0;
                if(i==j||j==k||i==k)continue;
                rep(m,c){
                    com+=D[m][i]*V[0][m];
                    com+=D[m][j]*V[1][m];
                    com+=D[m][k]*V[2][m];
                }
                ans=min(ans,com);
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b,c,d;
    scanf("%ld%ld%ld%ld", &a, &b, &c, &d);

    printf("%ld\n", MAX(MIN(d,b)-MAX(a,c), 0) );

    return 0;
}


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

int n, k;

int main() {
	cin >> n >> k;
	
	int ans = 1145141919;
	for (int i = 0; i <= n; i++) {
		int v = 1;
		for (int j = 0; j < n; j++) {
			if (j < i) v *= 2;
			else v += k;
		}
		ans = min(ans, v);
	}
	cout << ans << endl;
	return 0;
}

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

#define INTINF 2147483647
#define LLINF 9223372036854775807
using ll = long long;
typedef pair<int, int> P;

int main() {
	ll n, s; cin >> n >> s;
	ll anscan = 2;
	for (ll i = 2; i * i <= n; i++) {
		anscan = i;
		ll x = log2(n) / log2(i);
		ll tempans = 0;
		ll tempn = n;
		while (x >= 0) {
			ll sho = tempn / pow(i, x);
			tempans += sho;
			tempn = tempn - sho * pow(i, x);
			x--;
		}
		if (tempans == s) {
			cout << i << endl;
			return 0;
		}
	}

	ll start = n / anscan + 1;
	for (ll i = start; i > 0; i--) {
		if (s - i < 0) {
			continue;
		}
		ll b = (n - (s - i)) / i;
		if (b > s - i && b * i + (s - i) == n && b >= 2 && b > i) {
			cout << b << endl;
			return 0;
		}
	}

	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int K = 0, U = 0, P = 0, C = 0, m = 0;
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); ++i) {
		if (str[i] == 'K') {
			++K;
		}
		if (str[i] == 'U') {
			++U;
		}
		if (str[i] == 'P') {
			++P;
		}
		if (str[i] == 'C') {
			++C;
		}
	}
	m = min(min(K, U), min(P, C));
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int s1 =s.nextInt();
        if(s1>=30)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 27084
import bisect
n = int(input())
A = [int(input()) for j in range(n)]
dp = [A[0]]
for i in range(1, n):
    if dp[-1] < A[i]:
        dp.append(A[i])
    else:
        dp[bisect.bisect_left(dp, A[i])] = A[i]
print(len(dp))

Measured memory_bytes: 12304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int n;
vector<P> E[101010];
VI v(101010);
VI done(101010,0);
VI po(101010,INF);
VI ne(101010,INF);
bool ng=0;

void dfs(int cu, int pa = -1) {
  // v[cu]=0;
  if(done[cu]==1) return;
  done[cu]=1;
  for(P to:E[cu]) {
    if(po[cu]!=INF){
      if(ne[to.fi]==INF) ne[to.fi]=to.se-po[cu];
      else {
        if(ne[to.fi]!=to.se-po[cu]){
          ng=1;
          return;
        }
      }
    }
    else {
      if(po[to.fi]==INF) po[to.fi]=to.se-ne[cu];
      else {
        if(po[to.fi]!=to.se-ne[cu]){
          ng=1;
          return;
        }
      }
    }
    dfs(to.fi);
  }
}

int main(){
  int i,j;
  int m;
  cin>>n>>m;
  int a,b;
  ll r;
  for(i=0;i<m;i++) {
    cin>>a>>b>>r;
    a--; b--;
    E[a].pb(P(b,r-2));
    E[b].pb(P(a,r-2));
  }
  po[0]=0;
  dfs(0);
  if(ng){
    cout<<0<<endl;
    return 0;
  }

  ll tl=-INF;
  ll tr=INF;
  for(i=0;i<n;i++){
    if(po[i]!=INF&&ne[i]!=INF){
      ll w=ne[i]-po[i];
      if(w%2==1){
        cout<<0<<endl;
        return 0;
      }
      else {
        tl=max(tl,w/2);
        tr=min(tr,w/2);
      }
    }
    else if(po[i]!=INF){
      tl=max(tl,-po[i]);
    }
    else if(ne[i]!=INF){
      tr=min(tr,ne[i]);
    }
  }
  cout<<max(0ll,tr-tl+1)<<endl;
  return 0;
}




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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{
		int N = nextInt();
		int M = nextInt();

		int[][] x = new int[M+1][2];
		ArrayList<Integer> from1 = new ArrayList<>();
		ArrayList<Integer> toN = new ArrayList<>();
		for(int i=1;i<x.length;i++){
			x[i][0]=nextInt();
			x[i][1]=nextInt();
			if(x[i][0]==1){
				from1.add(x[i][1]);
			}
			if(x[i][1]==N){
				toN.add(x[i][0]);
			}
		}
		String ans = "IMPOSSIBLE";
		Collections.sort(toN);
		for(int from:from1){
			if(Collections.binarySearch(toN, from)>=0){
				ans="POSSIBLE";
				break;
			}
		}
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 68956
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int a,b;
    cin>>a>>b;
    if(a == 1 || b == 1)    cout<<1;
    else    cout<<fixed<<setprecision(0)<<ceil((a*b*1.0)/2.0);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    
    vector<P> vote(n);
    rep(i, n) vote[i].second = i+1;
    rep(i, m) {
        rep(j, n) {
            if(a[j] <= b[i]) {
                vote[j].first++;
                break;
            }
        }
    }
    sort(vote.begin(), vote.end());
    reverse(vote.begin(), vote.end());
    cout << vote[0].second << '\n';
    return 0;
}


Measured memory_bytes: 3220
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;

const int MOD = (int)1e9 + 7;
struct mint { int n; mint(int n = -1) : n(n) { } };     // default: -1
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
bool operator!=(mint a, mint b) { return a.n != b.n; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }

map<pair<ll, ll>, mint> memo;

mint func(ll s, ll x) {
    if (s == 0) return 1;
    if (memo[{s, x}] != -1) return memo[{s, x}];
    mint res = func(s / 2, x / 2);
    if (s && x) res += func((s - 1) / 2, (x - 1) / 2);
    if (s > 1) res += func((s - 2) / 2, x / 2);
    return memo[{s, x}] = res;
}

int main() {
    ll n; cin >> n;
    cout << func(n, n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define pi acos(-1)
    #define ll long long
    #define pii pair<ll,ll>
    #define debug(a) cout<<a<<'\n'
    #define maxn 100009 /// leave to tomorrow anything that can be done today
    #define MOD 1000000007
    #define F first
    #define S second
    #define rep(i, a, b) for(ll i = a; i < (b); ++i)
    #define per(i, b, a) for(ll i = b-1; i>=a ; i--)
    #define trav(a, x) for(auto& a : x)
    #define allin(a , x) for(auto a : x)
    #define all(x) begin(x), end(x)
    #define sz(x) (ll)(x).size()
    using namespace std;
    const ll INF = 1e17 + 9;
    int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        ll x,n;
        cin>>x>>n;
        if(n==0){
            cout<<x<<'\n';
            return 0;
        }
        ll vet[n+2];
        rep(i,0,n){
            cin>>vet[i];
        }
        sort(vet,vet+n);
        ll ans=0;
        ll sumi=x;
        rep(i,1,vet[0]){
            if(abs(i-x)<sumi){
                ans=i;
                sumi=abs(i-x);
            }
        }
        rep(i,0,n-1){
            rep(j,vet[i]+1,vet[i+1]){
                if(abs(j-x)<sumi){
                    ans=j;
                    sumi=abs(j-x);
                }
            }
        }
        rep(i,vet[n-1]+1,x+1){
            if(abs(i-x)<sumi){
                ans=i;
                sumi=abs(i-x);
            }
        }
        if(abs(vet[n-1]+1-x)<sumi){
            ans=vet[n-1]+1;
        }
        cout<<ans<<"\n";
        return 0;   
    }   

Measured memory_bytes: 3668
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/agc036/tasks/agc036_a
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

LL S;

LL ans[6];//(X1,Y1),(X2,Y2),(X3,Y3)の順

void solve(){
	//原点を固定
	ans[0] = ans[1] = 0;
	//三角形の面積*2 = Y2*X3 - X2*Y3

	//S = 10^9*X3 - Y3
	//と固定してしまっても残りのX3,Y3で
	//1<=S<=10^18の全てを表現可能

	//さらにこれはSを10^9で割った商とあまりを使えば表せる

	ans[2] = 1;//X2 = 1に固定
	ans[3] = 1e9;//Y2 = 10^9に固定

	ans[4] = S/1e9;//X3
	ans[5] = S%((LL)1e9);//Y3

	if(ans[5]!=0){
		ans[4]++;
		ans[5] = 1e9 - ans[5];
	}
}
 
int main(){
	cin >> S;
 
	solve();
 
	for(int i=0;i<6;i++) cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }

struct query {
	char c;
	ll x, y, z;
};

int solve(vector<query> q, int s, int t) {
	vector<ll> a(70000);
	a[0] = s, a[1] = t;
	for (auto i : q) {
		if (i.c == '<') {
			if (a[i.x] < a[i.y]) a[i.z] = 1;
			else a[i.z] = 0;
		}
		else {
			a[i.z] = a[i.x] + a[i.y];
		}
	}
	return a[2];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	vector<query> a;
	a.pb({ '<',2,0,3000 });
	a.pb({ '<',2,1,3001 });
	a.pb({ '+',3000,3001,3002 });
	a.pb({ '<',2,3002,3 });
	a.pb({ '<',2,3002,4 });
	a.pb({ '<',3003,3002,3003 });
	a.pb({ '+',0,3003,0 });
	a.pb({ '+',1,3003,1 });
	for (int i = 4; i < 40; i++) a.pb({ '+',i,i,i + 1 });
	for (int i = 37; i >= 4; i--) {
		a.pb({ '+',998,2,999 });
		a.pb({ '+',999,i,999 });
		a.pb({ '<', 999,0,i + 996 });
		a.pb({ '<',2,i + 996,i + 1996 });
		for (int j = i + 1996; j > 2000; j--) {
			a.pb({ '+',j,j,j - 1 });
		}
		a.pb({ '+',998,2000,998 });
		for (int j = 2000; j < 2037; j++) {
			a.pb({ '<',6000,6001,j });
		}
	}
	for (int i = 37; i >= 4; i--) {
		a.pb({ '+',10998,2,10999 });
		a.pb({ '+',10999,i,10999 });
		a.pb({ '<', 10999,1,i + 10996 });
		a.pb({ '<',2,i + 10996,i + 11996 });
		for (int j = i + 11996; j > 12000; j--) {
			a.pb({ '+',j,j,j - 1 });
		}
		a.pb({ '+',10998,12000,10998 });
		for (int j = 12000; j < 12037; j++) {
			a.pb({ '<',16000,16001,j });
		}
	}
	rep(i, 32) {
		rep(j, 32) {
			int idx = 20000 + i + j;
			a.pb({ '+',i + 1000,j + 11000,idx });
			int f = 40000 + i + j;
			a.pb({ '<', 4, idx, f });
			for (int k = f; k > 40000; k--) {
				a.pb({ '+',k,k,k - 1 });
			}
			a.pb({ '+', 2, 40000, 2 });
			for (int k = 20000; k < 20065; k++) {
				a.pb({ '<',50000,50001,k });
			}
			for (int k = 40000; k < 40065; k++) {
				a.pb({ '<',50000,50001,k });
			}
		}
	}
	cout << a.size() << '\n';
	for (auto i : a) cout << i.c << ' ' << i.x << ' ' << i.y << ' ' << i.z << '\n';
	/*rep(i, 10) {
		rep(j, 10) {
			int m = solve(a, i, j);
			cerr << i << ' ' << j << ' ' << m << '\n';
		}
	}*/
}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
 
//0 1->codeforces
#define LL "%lld"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007
#define MAXN 100007
 
typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf(LL,&a);return a;}
 
int main() {
  char *s;
  s = new char[MAXN];
  scanf("%s", s);
  int n=strlen(s);
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i]){
      printf("%d %d\n",i,i+1);
      return 0;
    }
    if(i>1 && s[i-2]==s[i]){
      printf("%d %d\n",i-1,i+1);
      return 0;
    }
  }
  printf("-1 -1\n");
  return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;


public class  Main{
    public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("reduce.in");
        PrintWriter pw=new PrintWriter(System.out);
        //int n=sc.nextInt();
        //Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
        long a=sc.nextLong()-1;long b=sc.nextLong();
        long c=sc.nextLong();long d=sc.nextLong();
        long l=(lcm(c,d));
        long ans=b/c+b/d-b/l;
        ans=ans-(a/c+a/d-a/l);
        pw.println(b-a-ans);
        pw.flush();
    }
    static long lcm(long a,long b) {
    	return (a/gcd(a,b))*b;
    }
    static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
    static StringBuilder tosb(int[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    static StringBuilder tosb(long[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

#define ll long long int
#define endl "\n"
#define mod 1000000007

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	string s, t;
	cin >> s;
	cin >> t;
	if (s == t.substr(0, s.size())) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;

}

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

int main(){
	int n,num;
	while(cin >> n){
		num = 0;
		for(int a = 0; a < 10; ++a){
			for(int b = 0; b < 10; ++b){
				for(int c = 0; c < 10; ++c){
					for(int d = 0; d < 10; ++d){
						if(a + b + c + d == n)++num;
					}
				}
			}
		}
		cout << num << '\n';
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<bool> A(1000010, false);
    Vec<i32> C(1000010, 0);
    for (i32 i = 0; i < N; i++) {
        i32 a;
        cin >> a;
        A[a] = true;
        C[a]++;
    }
    for (i32 i = 1; i <= 1000000; i++) {
        if (!A[i]) continue;
        for (i32 j = 2; i * j <= 1000000; j++) {
            if (A[i * j]){
                A[i * j] = false;
            }
        }
    }
    i32 sum = 0;
    for (i32 i = 1; i <= 1000000; i++) {
        if (A[i] && C[i] == 1) {
            sum++;
        }
    }
    cout << sum << endl;
}


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

int main()
{
	int N, A[100010];
	cin >> N;
	int d = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) {
			d++;
		}
	}
	cout << (d % 2 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var inputs = mutableListOf<String>()
    for (i in 0..2) {
        var input = readLine()!!
        inputs.add(input)
    }
    var total = 0
    for (i in 0..(n-1)) {
        val a = inputs[0][i]
        val b = inputs[1][i]
        val c = inputs[2][i]

        if (a==b && a==c) {
            continue
        } else if(a==b || a==c || b==c){
            total += 1
        } else {
            total += 2
        }
    }
    print(total)
}

Measured memory_bytes: 31864
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, W;
    cin >> N >> W;
    ll dp[N+1][W+1];
    dp[0][0] = 0;
    vector<ll> v(N);
    vector<ll> w(N);
    REP(ll,i,0,N) cin >> w.at(i) >> v.at(i);
    REP(ll,i,0,N+1){
        REP(ll,j,0,W+1) dp[i][j] = 0;
    }
    REP(ll,i,0,N){
        REP(ll,weight,0,W+1){
            if ( weight >= w.at(i) ){
                dp[i+1][weight] = 
                max(dp[i][weight-w.at(i)]+v.at(i),dp[i][weight]);
            }
            else{
                dp[i+1][weight] = dp[i][weight];
            }
            
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    ++N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    if (N == 1) {
        if (A[0] == 1) {
            cout << "1\n";
            return 0;
        } else {
            cout << "-1\n";
            return 0;
        }
    }
    if (A[0] != 0) {
        cout << "-1\n";
        return 0;
    }
    vector<long long> max_non_leaf(N);
    max_non_leaf[N - 1] = 0;
    for (int i = N - 2; i >= 0; --i) {
        max_non_leaf[i] = max_non_leaf[i + 1] + A[i + 1];
    }
    long long sum = 1;
    long long non_leaf = 1;
    for (int i = 1; i < N; ++i) {
        if (non_leaf * 2 < A[i]) {
            cout << "-1\n";
            return 0;
        }
        non_leaf = min(non_leaf * 2 - A[i], max_non_leaf[i]);
        sum += (non_leaf + A[i]);
    }
    cout << sum << '\n';
    return 0;
}

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

int main() {
    string s, t, u;
    std::cin >> s >> t;
    int a, b;
    std::cin >> a >> b;
    std::cin >> u;
    if(s == u){
        a--;
    }
    else{
        b--;
    }
    std::cout << a << " " << b << std::endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi = vector<int>;

int f_dir[2][4] = {{-1, 0, 0, 1}, {0, -1, 1, 0}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int h, w, c;
vector<vector<int> > p(8, vector<int>(8));

bool is_sc(int y, int x, vvi& orig){
  if(!is_in_field(y, x, h, w)) return false;
  if(orig[0][0] == orig[y][x]) return true;
  return false;
}

int color(int n_c, vvi& field){
  vvi orig = field;
  queue<pii> q;
  q.push({0, 0});
  vvi used(h, vi(w, 0));
  field[0][0] = n_c;
  used[0][0] = 1;
  while(!q.empty()){
    pii now = q.front(); q.pop();
    for(int i = 0; i < 4; i++){
      if(is_sc(now.first+f_dir[0][i], now.second+f_dir[1][i], orig)
        && !used[now.first+f_dir[0][i]][now.second+f_dir[1][i]]){
        q.push({now.first+f_dir[0][i], now.second+f_dir[1][i]});
        field[now.first+f_dir[0][i]][now.second+f_dir[1][i]] = n_c;
        used[now.first+f_dir[0][i]][now.second+f_dir[1][i]] = 1;
      }
    }
  }
  return 0;
}

int cnt(vvi& field){
  int ret = 0;
  queue<pii> q;
  q.push({0, 0});
  vvi used(h, vi(w, 0));
  used[0][0] = 1;
  while(!q.empty()){
    pii now = q.front(); q.pop();
    ret++;
    for(int i = 0; i < 4; i++){
      if(is_sc(now.first+f_dir[0][i], now.second+f_dir[1][i], field)
        && !used[now.first+f_dir[0][i]][now.second+f_dir[1][i]]){
        q.push({now.first+f_dir[0][i], now.second+f_dir[1][i]});
        used[now.first+f_dir[0][i]][now.second+f_dir[1][i]] = 1;
      }
    }
  }
  return ret;
}

int dfs(int k, vvi field){
  int ret = 0;
  if(k == 4){
    color(c, field);
    return cnt(field);
  }
  for(int i = 0; i < 6; i++){
    vvi tmp_f = field;
    color(i, tmp_f);
    ret = max(ret, dfs(k+1, tmp_f));
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  while(cin >> h >> w >> c && h){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cin >> p[i][j];
        p[i][j]--;
      }
    }
    c--;
    cout << dfs(0, p) << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

using namespace std;

int main()
{
	string str;
	cin >> str;
	string str2 = str;

	int q;
	cin >> q;

	int start, end;
	string command;

	for (int i = 0; i < q; i++) {
		cin >> command;
		if (command == "print") {
			cin >> start >> end;
			for (int i = start; i <= end; i++) {
				cout << str[i];
			}
			cout << "\n";
		}
		else if (command == "reverse") {
			cin >> start >> end;
			int end2 = end;
			for (int j = start; j <= end; j++) {
				str[j] = str2[end2--];
			}
			str2 = str;
		}
		else if (command == "replace") {
			string rstr;
			cin >> start >> end >> rstr;
			int ri = 0;
			for (int j = start; j <= end; j++) {
				str[j] = rstr[ri++];
			}
			str2 = str;
		}
	}
}

Measured memory_bytes: 1212
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n;
  i64 k;
  scanf ("%" SCNi32 "%" SCNi64, &n, &k);
  i32 *a = ALLOC (2 * n, i32);
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
    a[n + i] = a[i];
  }
  const i32 m = 200000;
  i64 *next = ALLOC (2 * n, i64);
  i64 *memo = ALLOC (m + 1, i64);
  for (i32 i = 2 * n - 1; i >= 0; --i) {
    next[i] = memo[a[i]] - i + 1;
    memo[a[i]] = i;
  }
  i64 **dp = ALLOC (65, i64 *);
  dp[0] = next;
  for (i32 i = 0; dp[i][0] < n * k; ++i) {
    dp[i + 1] = ALLOC (n, i64);
    for (i32 j = 0; j < n; ++j) {
      dp[i + 1][j] = dp[i][j] + dp[i][(j + dp[i][j]) % n];
    }
  }
  i64 now = 0;
  i32 d = 0;
  while (dp[d][now] < n * k) ++d;
  while (d >= 0) {
    if (now + dp[d][now % n] < n * k) {
      now += dp[d][now % n];
    } else {
      d--;
    }
  }
  uint8_t *elem = ALLOC (m + 1, uint8_t);
  i32 *ans = ALLOC (n, i32);
  i32 len = 0;
  for (i64 i = now; i < n * k; ++i) {
    i32 x = i % n;
    if (elem[a[x]]) {
      while (ans[len - 1] != a[x]) {
        elem[ans[--len]] = 0;
      }
      elem[ans[--len]] = 0;
    } else {
      ans[len++] = a[x];
      elem[a[x]] = 1;
    }
  }
  for (i32 i = 0; i < len; ++i) {
    printf ("%" PRIi32, ans[i]);
    putchar (i == len - 1 ? '\n' : ' ');
  }
}

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


Measured memory_bytes: 94848
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion

// ABC 058 C-怪文書
static int a[50][26];
static int cnt[26];
int main(void) {
	int n, i;
	char c;


	scanf("%d", &n);
	scanf("%c", &c);
	
	for (i = 0; i < n; i++) {
		while (1) {
			scanf("%c", &c);
			if (c == '\n') break;
			a[i][(int)(c - 'a')]++;
		}
	}

	int j;
	for (i = 0; i < 26; i++) {
		cnt[i] = 100;
		for (j = 0; j < n; j++) 
			cnt[i] = _min(a[j][i], cnt[i]);
	}

//	printf("\ncnt:");
//	for (i = 0; i < 26; i++)
//		printf("%d ", cnt[i]);
//	printf("\n");

	for (i = 0; i < 26; i++) {
		if (cnt[i] == 100)continue;
		for(j=0;j<cnt[i];j++)
		   printf("%c", i+'a');
	}
	printf("\n");

	
   return 0;
}







Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> S[i][j];
    }
  }
  int m = 1000000;
  for (int i = 0; i < (1 << (H - 1)); i++){
    int hor = __builtin_popcount(i);
    vector<int> G(H, 0);
    for (int j = 1; j < H; j++){
      if ((i >> (j - 1)) & 1){
        G[j] = G[j - 1] + 1;
      } else {
        G[j] = G[j - 1];
      }
    }
    /*
    for (int j = 0; j < H; j++){
      cout << G[j];
    }
    cout << endl;
    */
    int groupcount = G[H - 1] + 1;
    int vert = 0;
    
//    cout << "gc=" << groupcount << endl;
    
    vector<int> group(groupcount, 0);
    for (int j = 0; j < W; j++){
      bool flg = false;
      for (int k = 0; k < H; k++){
        group[G[k]] += S[k][j] - '0';
        if (group[G[k]] > K){
          flg = true;
//          cout << "group[G[k] = " << G[k] << "] = " << group[G[k]] << endl;
        }
      }
      if (flg){
        vert++;
        for (int k = 0; k < groupcount; k++){
          group[k] = 0;
        }
        for (int k = 0; k < H; k++){
          group[G[k]] += S[k][j] - '0';
          if (group[G[k]] > K){
            vert = 100000;
          }
        }
      }
    }
    m = min(m, hor + vert);
//    cout << hor + vert << endl;
  }
  cout << m << endl;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
s=input()
t=input()
#l=n*m//
import fractions

def agc(n,m,s,t):
    if s[0]!=t[0]:
        return -1
    g=fractions.gcd(n,m)
    if g==1:
        return  n*m
    l=n*m//g
    i=1
    while l*i<m*n:
        if s[int(l*i//m)]!=t[int(l*i//n)]:
            return -1
        i+=1
    return  int(l)
print(agc(n,m,s,t))

Measured memory_bytes: 5304
from string import *
h,w=map(int,input().split())

s = [input().split() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if(s[i][j]=='snuke'):
            idx1=ascii_lowercase[j].swapcase()
            idx2=str(i+1)
            print(idx1+idx2)
            exit()

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define INF (1e9)
#define TOP 0
#define FRONT 1 
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
#define N 30
using namespace std;

//TOP,FRONT,LEFT,RIGHT,BACK,BOTTOM
char dice[6];
char clist[6]={'r','m','y','b','g','c'};

void init(){
  for(int i=0;i<6;i++)
    dice[i]=clist[i];
}

//?\\?????¢??????
void rotN(){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);
}

//???????????¢??????
void rotS(){
  //rotN(),rotN(),rotN();
  swap(dice[TOP],dice[BACK]);
  swap(dice[BACK],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[FRONT]);
}

//????????¢??????
void rotE(){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}

//????????¢??????
void rotW(){
  //rotE(),rotE(),rotE();
  swap(dice[TOP],dice[RIGHT]);
  swap(dice[RIGHT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[LEFT]);
}


string s[N],t;
int h,w;
int ctoi[300];

int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

int check(int ny,int nx,int p){
  
  char c=s[ny][nx];
  
  if(c=='k')return 2;
  
  if(c=='w')return 0;
  
  if(c==t[p]&&c==dice[TOP])return 1;
  
  return 2;
}

void Rot(int dir){
  if(dir==0)rotN();
  if(dir==1)rotE();
  if(dir==2)rotS();
  if(dir==3)rotW();
}

struct dat{
  int cost,y,x,p;
  char dice[6];
  dat(){};
  dat(int a,int b,int c,int d){cost=a,y=b,x=c,p=d;};
};

int d[N][N][7][6][6];

int bfs(int sy,int sx){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      for(int k=0;k<7;k++)
	for(int l=0;l<6;l++)
	  for(int m=0;m<6;m++)
	    d[i][j][k][l][m]=INF;
  
  d[sy][sx][0][ctoi[dice[TOP]]][ctoi[dice[FRONT]]]=0;
  
  queue<dat> q;
  
  dat A=dat(0,sy,sx,0);
  for(int i=0;i<6;i++)A.dice[i]=dice[i];
  
  q.push(A);
  
  while(!q.empty()){
    dat u=q.front(); q.pop();
    
    if(u.p==6)return u.cost;
    
    for(int i=0;i<4;i++){
      int ny=u.y+dy[i],nx=u.x+dx[i],ncost=u.cost+1;
      
      if(ny<0||nx<0||h<=ny||w<=nx)continue;
      
      for(int j=0;j<6;j++)dice[j]=u.dice[j];
      
      Rot(i);
      
      int r=check(ny,nx,u.p);
      
      if(r==2)continue;
      
      if(d[ny][nx][u.p+r][ctoi[dice[TOP]]][ctoi[dice[FRONT]]]>ncost){
	d[ny][nx][u.p+r][ctoi[dice[TOP]]][ctoi[dice[FRONT]]]=ncost;
	dat A=dat(ncost,ny,nx,u.p+r);
	for(int j=0;j<6;j++)A.dice[j]=dice[j];
	q.push(A);
      }
      
    }

  }
  
  return INF;
}

int main(){
  ctoi['r']=0;  ctoi['m']=1;
  ctoi['y']=2;  ctoi['b']=3;
  ctoi['g']=4;  ctoi['c']=5;
  
  while(1){
    
    cin>>w>>h;
    if(!h&&!w)break;
    
    int sy,sx;
    for(int i=0;i<h;i++){
      cin>>s[i];
      
      for(int j=0;j<w;j++)
	if(s[i][j]=='#'){
	  sy=i,sx=j;
	  s[i][j]='w';
	}
      
    }
    cin>>t;
    
    init();
    int ans=bfs(sy,sx);
    
    if(ans==INF) cout<<"unreachable"<<endl;
    else cout<<ans<<endl;
    
  }
  return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
  
   sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(s<t) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
   int a; // Your code here!
    while(true){
        cin >> a;
        if(cin.eof())break;
        if(a==0)continue;
        for(int i = 0;i<9;i++){
            int b;
            cin >> b;
        a=a-b;
        }
        cout << a << endl;
    }
    
}




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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[125];
char t[] = "keyence";

int main(){
  scanf("%s",s);
  int n = strlen(s);
  REP(i,7+1){
    bool ok = true;
    REP(j,i)ok = ok && s[j]==t[j];
    REP(j,7-i)ok = ok && s[n-1-j]==t[7-1-j];
    if(ok){
      puts("YES");return 0;
    }
  }
  puts("NO");
  return 0;
}


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

int main(){
  const long long Max = 1000000000000001;
  std::vector<char> alphabet = {'a', 'b', 'c', 'd', 'e',
				'f', 'g', 'h', 'i', 'j',
				'k', 'l', 'm', 'n', 'o',
				'p', 'q', 'r', 's', 't',
				'u', 'v', 'w', 'x', 'y', 'z'};
  long long N;
  std::cin >> N;

  std::string resa;
  for(int i = 0 ; i < 100 ; i++){
    N--;
    int resi = N % 26;
    resa += alphabet[resi];
    N -= resi;
    N /= 26;
    if(N <= 0) break;
  }
  for(auto it = resa.end(); it != resa.begin() ;it--){
    std::cout << *(it - 1);
  }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 3592