akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100000

int partition(int A[], int n, int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p ; j < r ; j++ ){
    if ( A[j] <= x ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

  return i+1;
}

int main(){
  int A[MAX],n,i,k;
  scanf("%d",&n);
  for ( i = 0 ; i < n ; i++ )
    scanf("%d",&A[i]);
  k = partition(A,n,0,n-1);

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

  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i], A[i]--;
    ll ans = 0;
    ll current = 0;
    set<ll> already;
    while(true) {
        ll temp = A[current];
        if(already.find(temp) != already.end()) {
            cout << -1 << endl;
            return 0;
        }
        ans++;
        if(temp == 1) break;
        already.insert(temp);
        current = temp;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  bool flag = true;
  int N = S.size();
  for(int i=0;i<(N-1)/2;i++){
    if(S.at(i)!=S.at(N-1-i)){
      flag=false;
    }
  }
  for(int i=0;i<(N-1)/4;i++){
    if(S.at(i)!=S.at((N-3)/2-i)){
      flag=false;
    }
  }
  for(int i=0;i<(N-1)/4;i++){
    if(S.at((N+1)/2+i)!=S.at(N-1-i)){
      flag=false;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ll n,m;
    cin>>n>>m;
    if(n>m) swap(n,m);
    if(n==1)
    {
        if(m==1) print(1);
        else print(m-2);
    }
    else{
        if(n==2)
            print(0);
        else{
            print((n-2)*(m-2));
        }
    }
}

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

using namespace std;

int number_of_blacks(vector<string> grid) {
    int h = grid.size();
    int w = grid[0].size();

    int blacks = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(grid[i][j] == '#') {
                blacks += 1;
            }
        }
    }

    return blacks;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> c(h);

    for(int i = 0; i < h; i++) {
        cin >> c[i];
    }

    int ans = 0;
    for(int imask = 0; imask < (1 << h); imask++) {
        for(int jmask = 0; jmask < (1 << w); jmask++) {
            vector<string> new_grid = c;
            for(int ibit = 0; ibit < h; ibit++) {
                if(imask & (1 << ibit)) {
                    //cout << "ibit " << ibit << " prendido" << endl;
                    for(int i = 0; i < w; i++) {
                        new_grid[ibit][i] = 'x';
                    }
                }
            }
            for(int jbit = 0; jbit < w; jbit++) {
                if(jmask & (1 << jbit)) {
                    //cout << "jbit " << jbit << " prendido" << endl;
                    for(int j = 0; j < h; j++) {
                        new_grid[j][jbit] = 'x';
                    }
                }
            }
            //if(number_of_blacks(new_grid) == k and visited.count(new_grid) == 0) {
            if(number_of_blacks(new_grid) == k) {
                ans += 1;
            }
            //for(int i = 0; i < h; i++)
            //    cout << new_grid[i] << endl;
            //cout << number_of_blacks(new_grid) << endl;
            //cout << endl;
            //cout << "====" << endl;
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    long long sum = 0;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += a[i] - 1;
    }

    std::cout << sum << std::endl;

    return 0;
}


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

using namespace std;
using PIC = pair<int, char>;

const vector<int> num_match = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int inf = 1e6;

vector<PIC> nums;
string s_cand;

bool bigger(const string &s, const string &t) {
	if (s.size() == t.size()) {
		return s > t;
	} else {
		return s.size() > t.size();
	}
}

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

	vector<int> a(m, 0);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	map<int, int> tmp;
	for (auto x: a) {
		tmp[num_match[x]] = x;
	}
	for (auto p: tmp) {
		nums.emplace_back(p.first, '0' + p.second);
	}

	vector<int> dp(n + 1, -inf);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		if (dp[i] == -inf) {
			continue;
		}
		for (auto p: nums) {
			int ni = i + p.first;
			if (ni <= n) {
				dp[ni] = max(dp[ni], dp[i] + 1);
			}
		}
	}

	sort(nums.begin(), nums.end(),
		[](PIC &a, PIC &b) {
			return a.second > b.second;
		});

	string ans;
	int idx = n;
	while (ans.size() < dp[n]) {
		for (auto p: nums) {
			int ni = idx - p.first;
			if (ni >= 0 && dp[ni] == dp[idx] - 1) {
				ans += p.second;
				idx = ni;
				break;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
#define s (160*80)
typedef long long ll;
bool dp[89][89][s*2];

int main(){
  int h,w;
  int a[89][89],b[89][89];
  cin>>h>>w;
  rep(i,h)rep(j,w){
    cin>>a[i][j];
  }
  rep(i,h)rep(j,w){
    cin>>b[i][j];
  }

  dp[0][0][s]=1;
  rep(i,h){
    rep(j,w){
      rep(k,s*2){
        int d=abs(a[i][j]-b[i][j]);
        if(k+d<s*2){
          dp[i+1][j][k+d]|=dp[i][j][k];
          dp[i][j+1][k+d]|=dp[i][j][k];
        }
        if(k-d>=0){
          dp[i+1][j][k-d]|=dp[i][j][k];
          dp[i][j+1][k-d]|=dp[i][j][k];
        }
      }
    }
  }

  int ans=INF;
  rep(i,s*2){
    if(dp[h][w-1][i]==1){
      ans=min(ans,abs(i-s));
    }
  }
  cout<<ans<<endl;

  return(0);
}


Measured memory_bytes: 180480
#include<iostream>
#include<string>
#include<queue>
using namespace std;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int main()
{
	string f[12];
	while(cin>>f[0])
	{
		for(int i = 1; i < 12; ++i)
		{
			cin>>f[i];
		}
		int ans=0;
		for(int i = 0; i < 12; ++i)
		{
			for(int j = 0; j < 12; ++j)
			{
				if(f[i][j]=='1')
				{
					ans++;
					queue<int> xs,ys;
					xs.push(j); ys.push(i);
					f[i][j]='0';
					while(!xs.empty())
					{
						int x=xs.front(),y=ys.front();
						xs.pop(); ys.pop();
						for(int k = 0; k < 4; ++k)
						{
							int nx=x+dx[k],ny=y+dy[k];
							if(0<=nx&&nx<=11&&0<=ny&&ny<=11&&f[ny][nx]=='1')
							{
								f[ny][nx]='0';
								xs.push(nx); ys.push(ny);
							}
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

Measured memory_bytes: 1196
N = int(input())
A = list(map(int, input().split()))
cnt = 0
ans = 0
min_ = 10**9+1
for a in A:
    if a < 0:
        cnt += 1
    min_ = min(min_, abs(a))
    ans += abs(a)
if cnt %2 == 1:
    ans -= 2*min_
print(ans)

Measured memory_bytes: 64880
#include<bits/stdc++.h>
#define fo(x,a,b) for(register int x=a;x<=b;x++)
#define dfo(x,a,b) for(register int x=a;x>b;x--)
using namespace std;
int n,ans;
long double l1,l2,l3;
int main ()
{
	//freopen("")

	scanf("%d",&n);
	fo(i,1,n)
	{
		scanf("%Lf%Lf%Lf",&l1,&l2,&l3);		
		l1*=l1;
		l2*=l2;
		l3*=l3;
		if (l1+l2==l3||l2+l3==l1||l1+l3==l2) printf("YES\n");
		else printf("NO\n");
	}
//	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3192
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC S9(08).
       01  a2 PIC S9(08).
       01  a3 PIC S9(08).
       01  r1 PIC S9(08).
       01  r2 PIC S9(08).
       01  r3 PIC S9(08).
       01  r pic S9(08).
       01 disp pic Z(20)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2 a3.

 
        IF a2 <= a1 AND a3 <= a1 THEN
          compute r = 10 * a1 + a2 + a3
          MOVE FUNCTION TRIM(r) to disp
          DISPLAY disp
        ELSE IF a1 <= a2 AND a3 <= a2 THEN
          compute r = 10 * a2 + a1 + a3
          MOVE FUNCTION TRIM(r) to disp
          DISPLAY disp
        ELSE
          compute r = 10 * a3 + a2 + a1
          MOVE FUNCTION TRIM(r) to disp
          DISPLAY disp
        END-IF
        END-IF
 
 
       STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
int dp[1005][1005];

int main() {
  int n;
  cin>>n;
  rep(_,n){
    string s,t;
    cin>>s>>t;
    int sn=s.size(),tn=t.size();
    rep(i,sn) rep(j,tn){
      if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
    }
    cout<<dp[sn][tn]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7080
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define f(i,a,b) for(int i=a;i<b;i++)
#define in insert
#define matrix vector<vector<ll> >
#define E cout<<"\n";
#define I(x) cin>>x;
#define O(x) cout<<x;
#define all(a) a.begin(),a.end()
#define vi vector<int>
const ll M=1000000007;
const double pi=3.1415926;

using namespace std;

//ll modexpo(ll a,ll b,ll p)
//{
//    ll ans=1;
//      a=a%p;  // update a if(a>=p)
//
//        if(a==0)
//            return 0;
//
//                while(b!=0)
//                {
//                    if(b%2==1)
//                        ans=(ans*a)%p;
//
//                    a=a*a;
//                    b=b/2;
//
//                }
//                return ans;
//}

//ll countbit(ll n)
//{
//    ll c=0,x=0;
//    while(n!=0)
//    {
//        c+=n&1;
//        n>>=1;
//        x++;
//    }
//    return c==x;
//}



/*  vector<int> prime1;
  int prime[10000001];

void sieve(int n)
{
       for(long long i=2;i<=n;i++)
       {
         if(prime[i]==0)
         {  prime[i]=i;
            prime1.pb(i);
         }

            for(long long j=0;j<sz(prime1) && prime1[j]<=prime[i] && i*prime1[j]<=n;j++)
            {

                   prime[i*prime1[j]]=prime1[j];


            }


      }

 return ;
}*/

void fastio()
{
       ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

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



int main()
{
    fastio();
     int n;
     cin>>n;
     if(n>=30)
        Yes
      else
      No
    return 0;
}


Measured memory_bytes: 3648
from collections import deque

def resolve():
    H,W = map(int,input().split())
    Sy,Sx = [int(i)-1 for i in input().split()]
    Gy,Gx = [int(i)-1 for i in input().split()]

    MP = [input() for i in range(H)]
    q =[]
    mxxx = 10**10
    score=[[mxxx]*W  for i in range(H)]
    score[Sy][Sx] = 0
    deq = deque()
    deq.append((Sy,Sx))
    unvisited=set()
    for y,row in enumerate(MP):
        for x,i in enumerate(row):
            if i ==".":
                unvisited.add((y,x))

    while deq:
        y,x = deq.popleft()
        if not (y,x) in unvisited:
            continue
        unvisited.remove((y,x))

        if (y-1,x) in unvisited and score[y-1][x]>score[y][x]:
            score[y-1][x]=score[y][x]
            deq.appendleft((y-1,x))
        if (y+1,x) in unvisited and score[y+1][x]>score[y][x]:
            score[y+1][x]=score[y][x]
            deq.appendleft((y+1,x))
        if (y,x-1) in unvisited and score[y][x-1]>score[y][x]:
            score[y][x-1]=score[y][x]
            deq.appendleft((y,x-1))
        if (y,x+1) in unvisited and score[y][x+1]>score[y][x]:
            score[y][x+1]=score[y][x]
            deq.appendleft((y,x+1))

        for i in range(y-2,y+3):
            for j in range(x-2,x+3):
                if (i,j) in unvisited and score[i][j] > score[y][x]+1:
                    score[i][j] = score[y][x]+1
                    deq.append((i,j))
    
    if score[Gy][Gx] == 10**10:
        print(-1)
    else:
        print(score[Gy][Gx])




    
resolve()


Measured memory_bytes: 135380
if input() in ('KIHBR','KIHBRA','KIHBAR','KIHBARA','KIHABR','KIHABRA','KIHABAR','KIHABARA','AKIHBR','AKIHBRA','AKIHBAR','AKIHBARA','AKIHABR','AKIHABRA','AKIHABAR','AKIHABARA'):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s1[3005],s2[3005],ans[3005];
int dp[3005][3005],cnt;
int main()
{
	scanf("%s%s",s1+1,s2+1);
	int len1=strlen(s1+1),len2=strlen(s2+1);
	for(int i=1;i<=len1;i++)
	{
		for(int j=1;j<=len2;j++)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(s1[i]==s2[j]) dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j]);
		}
	}
	int n=len1,m=len2;
	while(n!=0 && m!=0)
	{
		if(dp[n][m]==dp[n-1][m-1]+1 && s1[n]==s2[m])
		{
			ans[++cnt]=s1[n];
			n--;
			m--;
			continue;
		}
		if(dp[n][m]==dp[n-1][m]) n--;
		else m--;
	}
	for(int i=cnt;i>=1;i--)
	{
		printf("%c",ans[i]);
	}
	printf("\n");
	return 0;
}

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

using namespace std;

int main() {
    string s;
    int ans = 0, cur = 0, n;
    cin >> n >> s;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == 'I')cur++;
        else cur--;
        ans = max(ans, cur);
    }
    cout << ans;

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>

typedef long long i64;

const int N = 100000 + 10, MOD = 1000000007;

int n, x[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &x[i]);
  int ans = 1;
  for (int i = 1, j = 1; i <= n; ++i) {
    while (j <= n && j - i <= (x[j - 1] + 1) / 2) ++j;
    ans = (i64)ans * (j - i) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using V = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

/* ----------- ANSWER ----------- */
/* ------------------------------ */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        string l = ins();
        int n = l.size();
        vvl dp(n + 1, vl(2, 0));
        // dp[i][j]: i桁目まで見た時の満たす物の数
        // j = 0: 桁が一致している
        // j = 1: L以下である
        dp[0][0] = 1;

        rep(i, n) {
            { // a + b = 0;
                if (l[i] == '0') {
                    dp[i + 1][0] += dp[i][0];
                    dp[i + 1][1] += dp[i][1];
                } else {         
                    dp[i + 1][1] += ((dp[i][0] + dp[i][1]) % mod);
                }
            }
            { // a + b = 1;
                if (l[i] == '0') {
                    dp[i + 1][1] += (dp[i][1] * 2 % mod);
                } else {         
                    dp[i + 1][0] += (dp[i][0] * 2 % mod);
                    dp[i + 1][1] += (dp[i][1] * 2 % mod);
                }
            }
        }

        cout << (dp[n][0] + dp[n][1]) % mod << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>

using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
#define eps 1.0e-14;

int main(){
    ll n,A[100006];
    cin >> n;
    rep(i,n) cin >> A[i];
    ll ans = 1;
    sort(A , A + n);
    rep(i,n){
        if (A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        if(ans > 1000000000000000000 / A[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){vector<ll> div;
	for(int i=1;i*i<=x;i++){if(i*i!=x && x%i==0){div.pb(i);div.pb(x/i);}else if(x%i==0) div.pb(i);}
	sort(div.bg,div.ed);return div;}
vector<ll> vectorprime(ll x){vector<bool> is_prime(x+1);vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){if(is_prime[i]){prime.pb(i);}for(int j=i*2;j<=x;j+=i) is_prime[j]=false;}
	return prime;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}

//a,b x
int main(){
	//rep1(i,50) pw2[i]=2*pw2[i-1];
	//rep1(i,18) pw10[i]=10*pw10[i-1];
    ll N,K; cin>>N>>K;
	ll ans=0;
	for(int b=K+1;b<=N;b++){
		ans+=((N+1)/b)*(b-K);//周期分
		ans+=max(0ll,(N+1)%b-K);
		if(K==0) ans--;//0
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL MOD = (LL)1e9 + 7;
const int MAXN = 234567;
int C[MAXN];
int pre[MAXN];
LL dp[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", &C[i]);
    dp[0] = 1;
    for (int i = 1; i <= N; i++) {
        dp[i] = dp[i - 1];
        int cur = C[i];
        if (pre[cur] && pre[cur] != i - 1) {
           dp[i] += dp[pre[cur]];
           dp[i] %= MOD;
        }
        pre[cur] = i;
    }
    printf("%lld\n", dp[N]);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n, c=0;
  string s;
  cin >> n >> s;
  for(int i=0; i<n-2; i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){c++; i+=2;}
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int count = 0;
  vi ans(n, 0);
  for(int i = n; i > 0; i--){
    int cnt = 0;
    for(int j = i + i; j <= n; j += i) cnt += ans[j - 1];
    int num = (a[i - 1] ^ cnt) & 1;
    ans[i - 1] = num;
    if(num) count++;
  }
  cout << count << endl;
  rep(i, n){
    if(ans[i]){
      count--;
      cout << i + 1;
      if(!count) cout << endl;
      else cout << " ";
    }
  }
}

Measured memory_bytes: 2432
W, H, x, y = map(int, input().split())
if x == W / 2 and y == H / 2:
	print((W * H) / 2, 1)
else:
	print((W * H) / 2, 0)
'''
長方形を分割するためには長方形の中心を通る必要がある
ただし、指定された座標が中心の場合は無限に直線が弾ける
'''


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=1000005;
int t[N][3],tag[N],val[N],ans[N],pw[20],n,rt,sz,cur,tot;
char opt[N];

int build(int n,int v){
	int o=++sz;
	if(!n){
		val[o]=v+1,tot++;
		return o;
	}
	REP(c,3){
		t[o][c]=build(n-1,v+c*pw[::n-n]);
	}
	return o;
}

void rever(int o){
	if(val[o]) return;
	swap(t[o][1],t[o][2]);
	tag[o]^=1;
}
void down(int o){
	if(tag[o]){
		rever(t[o][0]);
		rever(t[o][1]);
		rever(t[o][2]);
		tag[o]=0;
	}
}
void upd(int o){
	if(val[o]) return;
	down(o);
	swap(t[o][1],t[o][2]);
	swap(t[o][0],t[o][1]);
	upd(t[o][0]);
}
void solve(int n,int o,int v){
	if(val[o]){
		ans[val[o]-1]=v;
		return;
	}
	down(o);
	REP(c,3){
		solve(n-1,t[o][c],v+pw[::n-n]*c);
	}
}

int main(){
	read(n);
	pw[0]=1;
	rep(i,1,n){
		pw[i]=pw[i-1]*3;
	}
	rt=build(n,0);
	scanf("%s",opt+1);
	for(int i=1;opt[i];i++){
		if(opt[i]=='S'){
			rever(rt);
		}
		else{
			upd(rt);
		}
	}
	solve(n,rt,0);
	REP(i,tot){
		printf("%d ",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 21832
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    for(int i = 0; i < 26; i++) cin >> c[i];
    vector<vector<int>> s(D, vector<int> (26));
    for(int i = 0; i < D; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    vector<int> t(D);
    for(int i = 0; i < D; i++) {
        cin >> t[i];
        t[i]--;
    }
    int ans = 0;
    vector<int> last(26, 0);
    for(int i = 0; i < D; i++){
        ans += s[i][t[i]];
        last[t[i]] = i + 1;
        for(int j = 0; j < 26; j++){
            ans -= c[j] * (i + 1 - last[j]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define loop(i,n) for(i=0;i<n;i++)
ll power(ll x,ll y,ll md)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%md)*(x%md))%md;

        // y must be even now
        y = y>>1; // y = y/2
        x = ((x%md)*(x%md))%md;  // Change x to x^2
    }
    return res%md;
}
ll factor(ll n)
{
    ll c=0;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
            c+=2;
        if(i*i==n)
            c--;
    }
    return c;
}





/* ll arr[2000003];
 ll maxn=2000001;
 ll sieve()
 {
     arr[1]=arr[0]=0;
     for(ll i=2;i<=maxn;i++)
        arr[i]=1;
     for(ll i=2;i*i<=maxn;i++)
     {
         if(arr[i]==1)
         {
             for(ll j=i*i;j<=maxn;j+=i)
                arr[j]=0;
         }
     }

 }*/
bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     //ll t; cin>>t;
      // while(t--)
     {
        char a;
        cin>>a;
        if(islower(a))
            cout<<'a';
        else
            cout<<'A';


        cout<<endl;

     }


    return 0;

}


Measured memory_bytes: 3448
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if B>=A:
  if A + V * T >= B + W * T:
    print('YES')

  else:
    print('NO')
    
else:
  if A - V * T <= B - W * T:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 61656
/*
    A - AtCoder Beginner Contest 999
    https://atcoder.jp/contests/abc111/tasks/abc111_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    string str;
    cin >> str;
    for (size_t i = 0; i < str.size(); i++) {
        if (str[i] == '1')
            cout << 9;
        else if (str[i] == '9')
            cout << 1;
        else
            cout << str[i];
    }
    cout << endl;
}

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

int main() {
    ll a, b, k; cin >> a >> b >> k;
    if (a > k) cout << a-k << " " << b << endl;
    else if (b > k - a) cout << 0 << " " << b-k+a << endl;
    else cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k,ans=0;
	cin >>n>>k;
	string s;
	cin>>s;
	vector<int> a(1,1);
	for (int i=1;i<n;++i){
		if (s[i]==s[i - 1]) {
			a.back()+=1;
			ans+=1;
		}else {
			a.push_back(1);
		}
	}
	ans+=min((int)a.size()-1,2*k);
	cout<<ans;
	return 0;
}
 

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll n, m;
	cin >> n >> m;
	if (m <= n * 2) {
		cout << m / 2 << endl;
	} else {
		cout << n + (m - n * 2) / 4 << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>

using namespace std;

#define MAX_M 101

int day[MAX_M];

int main() {
    int N, Q;
    while (cin >> N >> Q, (N != 0 && Q != 0)) {
        memset(day, 0, sizeof(day));
        for (int i = 0; i < N; i++) {
            int M; cin >> M;
            for (int j = 0; j < M; j++) {
                int d; cin >> d;
                day[d]++;
            }
        }
        int max_ = 0;
        int meet_day = 0;
        for (int i = 0; i < MAX_M; i++) {
            if (max_ < day[i]) {
                max_ = day[i];
                meet_day = i;
            }
        }
        if (max_ < Q) meet_day = 0;
        cout << meet_day << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

     if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n){
ll ans = 1 ;
for(ll i = 1 ; i <= n ; ++i)
    ans *= i ;
return ans ;
}
int main()
{
    FastInputOutput() ;
    string s ;
    cin >> s ;
    int sz = s.length() ;
    int flag = 0;
    for(int i = 0 ; i < sz ; ++i)
      if(s[ i ] == '9'){
        flag = 1 ;
        break ;
      }
    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    int res = -1;
    rep(i, n){
        rep(j, i + 1, n){
            int cur = a[i] * a[j];
            stringstream ss; ss << cur;
            string a = ss.str();
            [&]{
                rep(i, a.size() - 1){
                    if(a[i + 1] - a[i] != 1) return;
                }
                chmax(res, cur);
            }();
        }
    }

    cout << res << endl;

    return 0;
}

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

double N;
void solve(){
    cin >> N;
    if((int)N%2 == 0){
        cout << "0.5000000000" << endl;
    }else{
        double ans = (N+1)/2.0/N;
        cout << fixed << setprecision(10) << ans << endl;
    }
}
int main(){
    solve();
}

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

using namespace std;

int main(int, char *[]) {
  int N;
  vector<pair<int, int>> r, b;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    r.push_back({x, y});
  }
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    b.push_back({x, y});
  }
  sort(r.begin(), r.end(),
       [](const pair<int, int> &lhs, const pair<int, int> &rhs) {
         if(lhs.first == rhs.first) {
           return lhs.second >= rhs.second;
         }
         return lhs.first >= rhs.first;
       });
  int count = 0;
  for(auto &re : r) {
    pair<int, int> *bp = nullptr;
    for(auto &be : b) {
      if(re.first < be.first && re.second < be.second) {
        if(!bp || (bp->second > be.second)) bp = &be;
      }
    }
    if(!bp) continue;
    count++;
    bp->first = -1;
    bp->second = -1;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int x, y;
    int t;
 
    for (;;) {
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) break;
        if (x > y) t = x, x = y, y = t;
        printf("%d %d\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[200000];
int ans;
int cnt1, cnt2;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt2 += a[i];
	}
	ans = cnt2;
	for (int i = 0; i < n; i++) {
		cnt1 += a[i];
		cnt2 -= a[i];
		ans = min(ans, abs(cnt1 - cnt2));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n,m;
    while(cin>>n>>m&&n){
        int a[n]; rep(i,n) cin>>a[i];
        int ans=0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]+a[j]<=m){
                    ans=max(ans,a[i]+a[j]);
                }
            }
        }
        if(ans) cout<<ans<<endl;
        else cout<<"NONE"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b)  (x/gcd(x,y))*y
#define inf (long long) 1e18
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cout << #x << "=" << x <<"\n";
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int pow(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }


int dp[101][100001];
void solve()
{
	int n,w;
	cin>>n>>w;
	vector<pii> v(n+1);
	rep1(i,n)
	{
		int a,b;
		cin>>a>>b;
		v[i]={a,b};
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-v[i].F>=0)
			{
				dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].F]+v[i].S);
			}
		}
	}
	// for(int i=0;i<=n;i++)
	// {
	// 	for(int j=0;j<=w;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	int ans=0;
	for(int i=1;i<=w;i++)
	{
		ans=max(ans,dp[n][i]);
	}
	cout<<ans<<"\n";
}	



int32_t main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("gymnastics.in", "r", stdin);
 //    freopen("gymnastics.out", "w", stdout);
	// #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
   int t=1;
   	// cin>>t;
   while(t--)
   	solve();
}






//code by-Roshan











//unnecessary
// bool cmp(pair<int,int> &a,pair<int,int> &b)
// {
// 	if(a.F==b.F)
// 		return (a.S<b.S);
// 	else 
// 		return (a.F<b.F);
// 	//< =chota wala pehle
// 	//> =chota wala baad me
// }


//better use this structure
// struct s{
// 	int a;
// 	bool operator <(const s &x) const
// 	{
// 		return (a>x.a);
// 	}
// };



//	priority_queue<int,vector<int>,greater<>> p;(priority queue as min heap)



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




int N;
int C[50][26];
//-----------------------------------------------------------------------------------
int main() {
    cin >> N;
    rep(i, 0, N) {
        string s; cin >> s;
        for (char c : s) C[i][c - 'a']++;
    }

    string ans = "";
    rep(i, 0, 26) {
        int mi = 101010;
        rep(j, 0, N) mi = min(C[j][i], mi);

        char c = 'a' + i;
        rep(j, 0, mi) ans += c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
class Dice
  attr_accessor :status
  def initialize(status)
    @status = status
  end

  def compareSpec(dice)
    @d2 = dice.status
    @dt = Array.new(6)
    @index = Array.new(3)
    2.times do |i|
      detectIndex(i)
    end
    checkRelate
    if (@index.select{|k| k == nil}.length == 1) && (@status[@index[0]] == @status[@index[1]]) && (@status[5-@index[0]] == @status[5-@index[1]])
      @index[0,2] = [@index[1], @index[0]]
      checkRelate
    end
    return (@index.include?(nil)) ? false : true
  end

  def detectIndex(i)
    @status.each_with_index do |dir,j|
      if ((dir == @d2[i]) && (@status[5-j] == @d2[5-i])) && !(@index.include?(j))
        @index[i] = j
        break
      end
    end
  end

  def checkRelate
    top = (@index[0]!=nil) ? @index[0] + 1 : 0
    front = (@index[1]!=nil) ? @index[1] + 1 : 0
    case top
    when 1,6
      sides = [2,3,5,4]
      idx = defineSide(sides,top,front) if (sides.include?(front))
    when 2,5
      sides = [1,4,6,3]
      idx = defineSide(sides,top,front) if (sides.include?(front))
    when 3,4
      sides = [1,2,6,5]
      idx = defineSide(sides,top,front) if (sides.include?(front))
    end
    @index[2] = idx if ( (idx != nil) && (@status[idx] == @d2[2]) && (@status[5-idx] == @d2[3]) )
  end

  def defineSide(sides,top,front)
    sides.unshift(sides.pop) while (sides[0] != front)
    return ([1,2,3].include?(top)) ? sides[1] - 1 : sides[-1] - 1
  end
end

n = gets.to_i
dices = []
n.times do
  dices<<gets.split.map(&:to_i)
end
catch(:stop) do
  dices[0..-2].each_with_index do |status,i|
    d1 = Dice.new(status)
    dices[(i+1)..-1].each do |status2|
      d2 = Dice.new(status2)
      if (d1.compareSpec(d2) == true)
        puts "No"
        throw :stop
      else
      end
      puts "Yes" if (i == (dices.length-2))&&(status2 == dices.last)
    end
  end
end

Measured memory_bytes: 8760
#include <iostream>

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    bool flag = false;

    for (int i=A; i<=(A*B); i+=A){
        if ((i%B) == C)
            flag = true;
    }

    if (flag)
        cout << "YES" << endl;

    else
        cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  set<string> se;
  int n = s.size();
  rep(i, n){
    string add;
    rep2(j, i, min(i+5, n)){
      add.push_back(s.at(j));
      se.insert(add);
    }
  }
  int co = 0;
  for(string s : se){
    co++;
    if(co == k){
      cout << s << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4812
// AC - A - Plural Form

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

int main(){
  string s; cin >> s;
  
  for(int i = 0; i < s.size(); i++) cout << s[i];
  if(s[s.size()-1] == 's') cout <<"es\n";
  else cout <<"s\n";
  
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  int N;
  vector<int> A;

  cin >> N;
  Rep(i, N) {
    int a; cin >> a;
    A.pb( a );
  }

  int cnt = 1;
  int now = -1; //0:up 1:down
  int num = A[0];
  for(int i=1; i<N; i++) {
    if( now == -1 ) {
      if( A[i] > num ) now = 0;
      else if( A[i] < num ) now = 1;
      num = A[i];
    }
    if( now == 1 ) {
      if( num < A[i] ) {
	cnt++;
	now = -1;
	num = A[i];
      }
    }
    if( now == 0 ) {
      if( num > A[i] ) {
	cnt++;
	now = -1;
	num = A[i];
      }
    }
    num = A[i];
  }

  cout << cnt << endl;
  

}


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

bool compare(pair<int, int> a, pair<int, int> b) {
  return a.first < b.first;
}

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

  vector<pair<int, int>> pairs(N);

  int A = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    pairs[i] = make_pair(A, i + 1);
  }

  sort(pairs.begin(), pairs.end(), compare);

  for (int i = 0; i < N; i++) {
    cout << pairs[i].second << ' ';
  }
  cout << endl;
} 

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 1; i <= n/2; ++i) {
    //    for (int j = 1; j < i; ++j) {
      if (n-i > n/2) {
        count++;
      }
    //}
  }
  cout << count;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;

	for(int i=0;i<=n/4;i++){
		for(int j=0;j<=n/4;j++){
			if(4*i+7*j==n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

void func(long long N, std::string S, long long Q, std::vector<long long> k){

    lli d=0,m=0,dm=0;

    REP(j,0,Q){
        lli ans = 0;
        d=0,m=0,dm=0;
        REP(i,0,N){
            if(S[i]=='D')d++;
            if(S[i]=='M'){
                m++;
                dm+= d;
            }
            if(S[i]=='C')ans += dm;

            if(i<k[j]-1)continue;
            if(S[i-k[j]+1]=='D'){
                    dm -= m;
                    d--;
            }
            if(S[i-k[j]+1]=='M'){
                    m--;
            }
        }
        cout<<ans<<endl;
    }


}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> k(Q-1-0+1);
    for(int i = 0 ; i < Q-1-0+1 ; i++){
        scanf("%lld",&k[i]);
    }
    func(N, S, Q, std::move(k));
    return 0;
}


Measured memory_bytes: 2308
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
const int MAXN=1e5;
vector<bool>isprime(MAXN+5,true);
void sieve()
{
     isprime[1]=false;
     for(int i=2;i*i<=MAXN;i++)
     {
           if(isprime[i])
           {
                for(int j=2*i;j<=MAXN;j+=i)
                  isprime[j]=false;
           }
     }
}
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);     
     sieve();
     vector<int>pre(MAXN+5,0);
     int count=0;
     for(int i=1;i<=MAXN;i++)
     {
           if(i&1)
           count+=isprime[i] and isprime[(i+1)/2];
           pre[i]=count;
     }
     int q;
     cin>>q;
     while(q--)
     {
         int l,r;
         cin>>l>>r;
         cout<<pre[r]-pre[l-1]<<endl;
     }
     time();
     return 0;
}

Measured memory_bytes: 1408