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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}

void mul_self(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a *= b;
        a %= mod;
}

void add_self(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a += b;
        a %= mod;
}

void sub_self(ll & a, ll b) {
        a %= mod;
        b %= mod;
        a -= b;
        if(a < 0) {
                a += mod;
        }
        a %= mod;
}

ll pow1(ll a, ll n) {
        ll res = 1LL;
        
        while(n) {
                if(n % 2) {
                        mul_self(res, a); 
                }
                mul_self(a, a);
                n /= 2;
        }
        return res;
}

ll Fact[1000005];
ll invFact[1000005];

void cal() {
        
        Fact[0] = 1;
        Fact[1] = 1;
        invFact[0] = 1;
        invFact[1] = 1;
        
        for(ll i = 2; i <= 1000000; i++) {
               Fact[i] = i;
               mul_self(Fact[i], Fact[i - 1]);
               invFact[i] = pow1(Fact[i], mod - 2);
        }
}

ll comb(ll n, ll r) {
        ll ans = Fact[n];
        mul_self(ans, invFact[n - r]);
        mul_self(ans, invFact[r]);
        return ans;
}

void solve() {
        
       ll S;
       cin >> S;
       
       if(S < 3) {
            cout << 0 << endl;
            return;
       }
       
       ll tot = (S / 3);
       
       if(tot == 1) {
            cout << 1 << endl;
            return;
       }
       
       ll ans = 1;
       
       for(ll i = 2; i <= tot; i++) {
                add_self(ans, comb((S - (i * 3) + i - 1), (i - 1)));
       }
       
       cout << ans << endl;
       
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 19260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << #x << "]: " << (x) << endl;

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

    int n, w;
    cin >> n >> w;

    vector<ll> dp(1e5+1, 1e18);
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        int x, y;
        cin >> x >> y;
        for (int j=1e5; j>=y; j--) {
            dp[j] = min(dp[j-y]+x, dp[j]);
        }
    }
    for (int i=1e5; i>-1; i--) {
        if (dp[i] <= w) {
            cout << i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> edge[n];
  for (i64 i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    for (i64 j = 0; j < n; j++)
      if (s[j] == '1')
        edge[i].push_back(j);
  }
  bool ok = true;
  queue<i64> que;
  vector<i64> c(n, -1);
  que.push(0);
  c[0] = 0;
  while (que.size())
  {
    i64 p = que.front();
    que.pop();
    for (i64 i : edge[p])
    {
      if (c[i] == -1)
      {
        c[i] = c[p] ^ 1;
        que.push(i);
      }
      else if (c[p] != (c[i] ^ 1))
        ok = false;
    }
  }
  if (!ok)
  {
    cout << -1 << endl;
    return 0;
  }
  i64 ans = 0;
  for (i64 i = 0; i < n; i++)
  {
    while (!que.empty())
      que.pop();
    vector<i64> far(n, 1e9);
    que.push(i);
    far[i] = 0;
    while (que.size())
    {
      i64 p = que.front();
      que.pop();
      for (i64 i : edge[p])
        if (far[p] + 1 < far[i])
        {
          far[i] = far[p] + 1;
          que.push(i);
        }
    }
    i64 m = 0;
    for (i64 i = 0; i < n; i++)
      m = max(m, far[i]);
    ans = max(ans, m);
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int a[N], n, l, r;

bool check(int pos) {
	LL siz = 0;
	rep(i, 1, pos)
	    siz += a[i];
	rep(i, pos + 1, n) {
		if(siz*2 < a[i]) return false;
		siz += a[i];
	}
	return true;
}

int main() {
	cin>>n;
	rep(i, 1, n) 
	    cin>>a[i];
	sort(a + 1, a + n + 1);
	l = 1, r = n;
	while(l < r) {
		int mid = (l + r)>>1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout<<n - l + 1<<endl;
}

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

using lint = long long int;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)

bool modx(lint l,lint r,lint x){
    if (l%x + (r - l) >= x||l%x==0||r%x==0){
        return true;
    }
    return false;
}

int main()
{
    int l,r;
    cin >> l >> r;
    int lm, rm;
    lm = l % 2019;
    rm = r % 2019;

    int ans = 2019;
    if (modx(l,r,2019)){
        ans = 0;
    }
    else if (modx(l, r, 673) && modx(l, r, 3))
    {
        ans = 0;
    }
    else {
        FOR(i,lm,rm+1){
            FOR(j,i+1,rm+1){
                ans = min((i * j) % 2019, ans);
            }
        }
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
n,m = map(int,input().split())
s = 0
if n > 1:
	s += combinations_count(n, 2)
if m > 1:
    s += combinations_count(m, 2)

print(s)

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

ll H, W;
int a[100][100] = {};

bool is_col_empty(ll h) {
  rep(i, W) {
    if (a[h][i]) {
      return 0;
    }
  }
  return 1;
}

bool is_row_empty(ll w) {
  rep(i, H) {
    if (a[i][w]) {
      return 0;
    }
  }
  return 1;
}

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

  cin >> H >> W;

  rep(h, H) {
    rep(w, W) {
      char c;
      cin >> c;
      if (c == '#') {
        a[h][w] = 1;
      }
    }
  }

  rep(h, H) {
    if (is_col_empty(h)) {
      continue;
    }
    rep(w, W) {
      if (!is_row_empty(w)) {
        if (a[h][w]) {
          cout << '#';
        } else {
          cout << '.';
        }
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
#define TRUE 1
#define FALSE 0
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];

void initialize(){
  int i;
  for(i=0 ; i< N ; i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]= FREE;
    dneg[i]= FREE;
  }
}

void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(row[i] != j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j){
        printf("Q");
    }
else{ printf(".");
}
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j] == NOT_FREE ||
       dpos[j + i] == NOT_FREE ||
       dneg[i - j + N - 1] == NOT_FREE) continue;
    row[i] =j;
    col[j] =dpos[i+j] = dneg[i-j+N-1] =NOT_FREE;
    recursive(i+1);
    row[i]=col[j] = dpos[i+j]= dneg[i-j+N-1]=FREE;
  }
}


int main(){
  int i,j,k,r,c;
  initialize();

  for(i=0;i<N;i++)
    for(j=0;j<N;j++)X[i][j]=FALSE;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c] =TRUE;
  }
  recursive(0);
  return 0;
}





Measured memory_bytes: 2148
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int mod = 1000003;

int main() {
	int bowl, color;
	cin >> bowl >> color;
	int ans = color;
	rep(i, 1, bowl) {
		ans *= (color - 1);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,b;
    scanf("%d",&N);
    int a[N];
    for(int i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+N);
     b=a[N-1]-a[0];
     printf("%d\n",b);



}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = r;
	while (r > 0) {
		sum -= BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, B);
		if (sum_BIT(BIT, A - 1) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		if (s[B+1] < 0) {
			L = A;
			R = B;
			while (L != R) {
				M = (L + R) / 2;
				if (sum_BIT(BIT, M) != tmp) L = M + 1;
				else R = M;
			}
			s[B+1] = s[L];
			right[B+1] = right[L];
			left[right[L]] = B + 1;
			
			if (B != W) {
				d.key = B + 1 - s[B+1];
				d.id = B + 1;
				push(d, &h);
				add_BIT(W, BIT, B + 1, -1);
			}
		} else L = left[B+1];
		
		for (j = L; j >= A; j = left[j]) {
			s[j] = -1;
			add_BIT(W, BIT, j, 1);
		}
		left[B+1] = j;
		right[j] = B + 1;
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6484
NM = input()
NM = "".join(NM).rstrip("\n").split(" ")
lis = [1 for s in range(int(NM[0]))]
lis2 =[0 for s in range(int(NM[0]))]
lis2[0]+=1
#print(lis)
for s in range(int(NM[1])):
	temp=input()
	temp = "".join(temp).rstrip("\n").split(" ")
	#print(lis2)
	t0 = int(temp[0])
	t1 = int(temp[1])
	lis[t1-1]+=1
	if lis2[t0-1]==1:
		lis2[t1-1]=1
	lis[t0-1]-=1
	if lis[t0-1] ==0:
		if lis2[t0-1]>0:
			lis2[t0-1]=0
#print(lis)
#print(lis2)
ans=0
for s in range(int(NM[0])):
	if lis2[s]==1:
		ans+=1
print(ans)

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
int psum[505][505];
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	while(m--){
		int l,r;
		cin>>l>>r;
		psum[r][l]++;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++) psum[i][j]+=psum[i][j-1];
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++) psum[i][j]+=psum[i-1][j];
	}
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<psum[r][n]-psum[r][l-1]<<'\n';
	}
}

Measured memory_bytes: 4544
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
ll k,a[999];
int main(){
read(k);
int i,j,l,n=50;
write(n),pl;
ll now=k/n;
for (i=0;i<n;++i){
  if (now==k/n+50-k%n) ++now;
  write(now++),p32;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int K = in.nextInt();
        int x[] = new int[N];
        for(int i=0; i<N; i++){
            x[i] = in.nextInt();
        }
        int ans = 1<<30;
        for (int i = 0; i <= N-K; i++) {
            ans = Math.min(ans, x[K-1+i]-x[i]+Math.min(Math.abs(x[K-1+i]), Math.abs(x[i])));
        }
        out.println(ans);
       
    }

}
}



Measured memory_bytes: 47912
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>

#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

/*------------------------------------------
	関数名：gcd
	機　能：a/b の最大公約数を求める
	引　数：a b
	戻り値：T
-------------------------------------------*/
template<class T> inline T gcd(T a, T b) {
	T candidate = a;
	while (b % a != 0) {
		candidate = b % a;
		b = a;
		a = candidate;
	}
	return candidate;
}
/*------------------------------------------
	関数名：lcm
	機　能：a b の最大公倍数を求める
	引　数：a b
	戻り値：T
-------------------------------------------*/
template<class T> inline T lcm(T a, T b) {
	return (a * b) / gcd(a, b);
}

ll i, j, k, tmp, ans, cnt, N, A, B, C, D, bi;
string s;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;
ll f(ll a) {
	return a - (a / C + a / D) + a/lcm(C,D);
}

int main(void) {
	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
	
	cout << f(B) - f(A - 1);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int N;
	cin >> N;
	map<long long, long long> A;
	int answer = 0;
	int inputMax = 0;
	for(int cnt = 0; cnt < N; cnt++){
		long long a;
		cin >> a;
		A[a] ++;
		if(inputMax < a){
			inputMax = a;
		}
	}
	int index = log2(inputMax) + 2;
	
	while(true){
		map<long long, long long> pairCount;
		for(auto itr = A.begin(); itr != A.end(); itr++){
			bool isExist = false;
			if(0 == itr->second) continue;
			for(int cnt = 1; cnt <= index; cnt++){
				long long pair = pow(2, cnt) - itr->first;
				if(pair < 1 || A[pair] == 0) continue;
				if((pair == itr->first && itr->second > 1) 
						|| (pair != itr->first && itr->second > 0)){
					//cout << itr->first << " - " << pair << endl;
					pairCount[itr->first]++;
					pairCount[pair]++;
					isExist = true;
				}
			}
		}
		if(pairCount.size() == 0) break;
		for(auto itr = pairCount.begin(); itr != pairCount.end(); itr++){
			//cout << itr->first << " " << itr->second << endl;
			if(itr->second != 2) continue;
			for(int cnt = 1; cnt <= index; cnt++){
				long long pair = pow(2, cnt) - itr->first;
				if(pair < 1 || A[pair] == 0) continue;
				if((pair == itr->first && A[pair] > 1) 
						|| (pair != itr->first && A[itr->first] > 0)){
					++answer;
					A[itr->first]--;
					A[pair]--;
					itr->second -= 2;
					pairCount[pair] -= 2;
					break;
				}
			}
		}
	}
	cout << answer << endl;
	
	return 0;
}



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

struct Playlist {
  string S;
  int T;
  };


int main() {
  
  int N;
  cin >> N; 
  Playlist playlist[N];

  
 for (int i = 0; i < N; i++) {

 cin >> playlist[i].S;

 cin >> playlist[i].T;


 }
  
  string X;
  cin >> X;
  int y = 0;
  
 for (int j = 0; j < N; j++){
    
    if (playlist[j].S == X){
      
      for (int k = j + 1; k < N; k++){
        
        y = y + playlist[k].T;
      }
      break;
    }
    
  }
   cout << y << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main()
{
  multiset<int> mst;
  multiset<int> ans;
  ans.insert(5);
  ans.insert(5);
  ans.insert(7);
  for(int i=0;i<3;i++){
    int j;
    cin>>j;
    mst.insert(j);
  }
  if(mst==ans){
    cout<<"YES";
  }
  else cout<<"NO";
}
  

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

int main(){
	int N,X,T;
	cin>>N;
	cin>>X;
	cin>>T;
	
	int ans,Number;
	ans=0;
	Number=0;
	for(;;){
		if(Number>=N){break;}
		Number=Number+X;
		ans=ans+T;
		
	}
	
	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a[100001], f[100001]={0};
int main()
{
	int n,m,k,i,j;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=2;i<=n;i++)
	{
		f[i]=0x7fffffff;
		for(j=1;j<=min(i-1,k);j++)
		{
			f[i]=min(abs(a[i-j]-a[i])+f[i-j],f[i]);
		}
	}
	printf("%d",f[n]);
	return 0;
}

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

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

    bool flag = false;
    vector<int> visited(n);
    visited[0] = 1;
    vector<int> ball(n,1);
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x -= 1;
        y -= 1;

        ball[x] -= 1;
        ball[y] += 1;
        if((flag == false && x == 0) || visited[x] == 1){
            visited[y] = 1;
            flag = true;
        }
        if(ball[x] == 0) visited[x] = 0;
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        ans += visited[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3992
#include <stdio.h>
#include <math.h>

int main(void) {
	int i,j,t,e,y;
	double x;
	int san[3];
	
	scanf("%d",&t);

	for(e=0;e<t;e++){
		for(i=0;i<3;i++){
			scanf("%d",&san[i]);
		}
		for(i=0;i<3;i++){
			for(j=i+1;j<3;j++){
				if(san[i]<san[j]){
					y=san[i];
					san[i]=san[j];
					san[j]=y;
				}
			}
		}
		x=sqrt(pow(san[1],2)+pow(san[2],2));
		if(san[0]==x)
		puts("YES");
		else
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 580
#include <queue>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

#define MAX_V (10010)

class Edge {
public:
    int f, s, w;
    Edge( int f = 0, int s = 0, int w = 0 ):
	f( f ), s( s ), w( w ) {}
    bool operator < ( const Edge &e ) const {
	return w < e.w;
    }
};

int V, E;
int parent[MAX_V];

vector<Edge> edge_array;

void init_union(int v) {
    for ( int i = 0; i < v; i++ ){
	parent[i] = i;
    }
}

int find_root( int a ) {
    if ( parent[a] == a ) return a;
    else return parent[a] = find_root( parent[a] );
}

bool is_same( int a, int b ) {
    int r_a = find_root( a );
    int r_b = find_root( b );

    return ( r_a == r_b );
}

void combine( int a, int b ) {
    int r_a = find_root( a );
    int r_b = find_root( b );
    parent[r_b] = r_a;
}


int main()
{
    int ans = 0;
    scanf("%d %d", &V, &E);

    for ( int i = 0; i < E; i++ ) {
	Edge e;
	scanf( "%d %d %d", &(e.f), &(e.s), &(e.w) );
	edge_array.push_back( e );
    }

    sort( edge_array.begin(), edge_array.end() );

    init_union( V );

    for ( int i = 0; i < edge_array.size(); i++ ) {
	Edge e = edge_array[i];
	if ( !is_same( e.f, e.s ) ) {
	    ans += e.w;
	    combine( e.f, e.s );
	}
    }
    
    printf("%d\n", ans);
    return 0;
}

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

int main(){
	int n,m;
	int target[102];
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> target[i];
	}
	int score[102]={0};
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			int a; cin >> a;
			if(a == target[i]){
				score[j]++;
			}
			else score[target[i]-1]++;
		}
	}
	for(int i=0;i<n;i++){
		cout << score[i] << endl;
	}
}

Measured memory_bytes: 1160
/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 

class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
	public static void main (String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt();
		int arr[] = new int[n];
		for (int i=0;i<n ;i++ ) {
		    arr[i] = ob.nextInt();
		    //System.out.println(arr[i]);
		}
		int count=1;
		int min=arr[0];
		for (int i=1;i<n ;i++ ) {
		    //System.out.println(arr[i]);
		    if(min>=arr[i]){
		        count++;
		        min=arr[i];
		        
		    }
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 43728
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;

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

    int N, A;
    cin >> N >> A;

    N %= 500;

    if(N <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
package main

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

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	d := scanInt()
	a := scanInt()

	m := make(mons, n)

	for i := 0; i < n; i++ {
		m[i] = mon{scanInt(), scanInt()}
	}

	sort.Sort(m)

	sum0 := make(bit, n+1)
	sum1 := make(bit, n+1)

	l,r := 0, 1
	ans := 0

	for l < n {
		for r < n && m[r].x <= m[l].x+2*d {
			r++
		}

		damaged := sum1.sum(l)*l+sum0.sum(l) - (sum1.sum(l-1)*(l-1)+sum0.sum(l-1))
		if m[l].h > damaged*a {
			damage := (m[l].h-damaged*a+a-1)/a
			ans += damage
			sum0.add(l, -damage*(l-1))
			sum1.add(l, damage)
			sum0.add(r, damage*(r-1))
			sum1.add(r, -damage)
		}
		// fmt.Println(l,r,damaged*a)
		l++
	}

	fmt.Println(ans)
}

type mon struct {
	x int
	h int
}

type mons []mon

func (a mons) Len() int           { return len(a) }
func (a mons) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a mons) Less(i, j int) bool { return a[i].x < a[j].x }

type bit []int

func (t bit) sum(i int) int {
	s := 0
	for i++; i > 0; i -= i & -i { s += t[i] }
	return s
}

func (t bit) add(i, x int) {
	for i++; i < len(t); i += i & -i { t[i] += x }
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BPopularVote {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;

        vector<int> A(N);
        int sum = 0;
        REP(i, N) {
            cin >> A[i];
            sum += A[i];
        }

        int num = 0;
        REP(i, N) {
            if (A[i] * 4 * M >= sum) {
                num++;
            }
        }

        cout << (num >= M ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BPopularVote solver;
    solver.solve(in, out);
    return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    reverse(ALL(s));
    int n = s.size();
    VVL dp(n + 1, VL(13, 0));
    VL pow10(n);
    pow10[0] = 1;
    FOR(i, 1, n - 1) pow10[i] = pow10[i - 1] * 10 % 13;
    dp[0][0] = 1;

    FOR(i, 1, n) FOR(m, 0, 12) {
        if (s[i - 1] == '?') {
            FOR(x, 0, 9) {
                dp[i][(pow10[i - 1] * x % 13 + m) % 13] =
                    (dp[i][(pow10[i - 1] * x % 13 + m) % 13] + dp[i - 1][m]) %
                    MOD;
            }
        } else {
            int x = s[i - 1] - '0';
            dp[i][(pow10[i - 1] * x % 13 + m) % 13] = dp[i - 1][m];
        }
    }

    cout << dp[n][5] << ln;
    return 0;
}


Measured memory_bytes: 17400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  ll sum=0;
  ll ans=0;
  rep(i,N){
    if(A[i]) sum+=A[i];
    else{
      ans+=sum/2;
      sum=0;
    }
  }
  ans+=sum/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
 
int main() {
	int a,b,d,r;
	double f;
	cin >> a >> b;
	d = a/b;
	r = a%b;
	f = double(a)/double(b);
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 3140
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
//		new A().doIt();
		new B().doIt();
//		new C().doIt();
//		new D().doIt();
	}
	class A{
		void doIt(){
			int A[] = new int[3];
			for(int i = 0;i < 3;i++)A[i] = Integer.parseInt(sc.next());
			int five = 0;
			int seven = 0;
			for(int i = 0;i < 3;i++) {
				if(A[i] == 5)five++;
				else if(A[i] == 7)seven++;
			}
			if(five == 2 && seven == 1)System.out.print("YES");
			else System.out.println("NO");
		}
	}
	class B{
		void doIt(){
			int N = sc.nextInt();
			int L = sc.nextInt();
			String str[] = new String[N];
			for(int i = 0;i < N;i++) {
				str[i] = sc.next();
			}
			Arrays.sort(str);
			for(int i = 0;i < N;i++) {
				System.out.print(str[i]);
			}
			System.out.println();
		}
	}
	class C{
		void doIt(){
			
		}
	}
	class D{
		void doIt(){
			
		}
	}
}


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

int main()
{
    long long j,k=100,x;
    long double g;
    cin>>x;
    long i;
    for( i=1;;i++){
        k=k+(k/100);
        if(k>=x)
            break;
    }
    cout<<i<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n;
    cin >> n;
    
    vector<int> a(n+10);
    REP(i, n+1) cin >> a[i];
    vector<int> b(n+10);
    REP(i, n) cin >> b[i];

    ll cnt = 0;
    
    for (int i = 0; i < n; i++) {

        if(i == n-1) {
            cnt += min(b[i], (a[i] + a[i+1]));
            break;
        }

        if(b[i] >= a[i] + a[i+1]) {
            cnt += (a[i] + a[i+1]);
            a[i+1] = 0;
        } else if (b[i] >= a[i]) {
            cnt += b[i];
            a[i+1] -= b[i] - a[i];
        } else if (b[i] < a[i]) {
            cnt += b[i];
        }
    }
        
        

    cout << cnt << endl;
    
    

    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int a = 0;
  for (int k = 0; k < N; k++) {
    for (int j = k + 1; j < N; j++) {
      for (int i = j + 1; i < N; i++) {
        if(L.at(i) == L.at(j) || L.at(j) == L.at(k) || L.at(k) == L.at(i)) {
        } else {
          if(L.at(i) + L.at(j) > L.at(k) && L.at(j) + L.at(k) > L.at(i) && L.at(k) + L.at(i) > L.at(j)) {
            a++;
          }
        }
      }
    }
  }
  cout << a << endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X, Y;
    cin >> X >> Y;
    if (Y > X * 4 || Y < X * 2) {
        cout << "No\n";
        return 0;
    }
    if (Y % 2 != 0) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3648
# ABC173a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n = int(input())
    import math
    print(math.ceil(n/1000)*1000-n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61968
#include<map>
#include<set>
#include<ctime>
#include<queue>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mp(x,y) make_pair(x,y)
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=(ans<<1)+(ans<<3)+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=2000;
int n,a[maxn],ans[maxn];
int main(){
//	freopen("nh.in","r",stdin);
	//freopen("zhy.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		int mx=0;
		for(int j=1;j<=n-i+1;j++)
			if(a[j]==j&&j>mx) mx=j;
		if(!mx){
			printf("-1\n");
			return 0;
		}
		for(int j=mx;j<=n-i;j++)
			a[j]=a[j+1];
		ans[i]=mx;
	}
	for(int i=n;i>=1;i--) printf("%d\n",ans[i]); 
	return 0;
}










Measured memory_bytes: 128
N, A, B = [int(x) for x in input().split()]
S = list(input())
go = 0
go_abroad = 0
for i in range(N):
  if(go)<(A+B):
    if(S[i]=='a'):
      print('Yes')
      go += 1
    elif(S[i]=='b') and (go_abroad<B):
      print('Yes')
      go += 1
      go_abroad += 1
    else:
      print('No')
  else:
    print('No')

Measured memory_bytes: 9840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(5e5+5)

void solve()
{
    ll n,ans = 0;
    cin>>n;

    for(ll i=2;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            ll cnt = 0;
            while(n%i == 0)
                cnt++ , n/=i;

            for(ll j=1;;j++)
            {
                ll sum = (j*(j+1))/2;
                if(sum > cnt)
                {
                    ans += j-1;
                    break;
                }
            }
        }

    }

    if(n > 1)
        ans++;
    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	long long int a,b,c;
    long long int r,x;
	
	while (scanf("%lld %lld",&a,&b) != EOF){
		if(a < b){  // ??´??°?????§??????????¢?????????\?????????
			c = a;
			a = b;
			b = c;
		}
		x = a * b;
		r = a % b;
		while(r != 0){
			a = b;
			b = r;
			r = a % b;
		}
		printf("%lld %lld\n",b,x/b);
		
	}
	
	return(0);
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main()
{
    int x;
    int a,b,c,d;
    while(cin>>x)
    {
    a=x/1000;
    b=(x/100)%10;
    c=(x/10)%10;
    d=x%10;
    if(a+b+c+d==7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<<endl;break;}
    if(a+b+c-d==7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<"7"<<endl;break;}
    if(a+b-c+d==7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<"7"<<endl;break;}
    if(a+b-c-d==7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<"7"<<endl;break;}
    if(a-b+c+d==7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<<endl;break;}
    if(a-b+c-d==7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<"7"<<endl;break;}
    if(a-b-c+d==7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<"7"<<endl;break;}
    if(a-b-c-d==7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<"7"<<endl;break;}
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int sign(double x);

int main(void)
{
    double x1, y1, x2, y2, x3, y3;
    double xp, yp;

    double judge1, judge2, judge3;
    int sign_total;

    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
                &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
        judge1 = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
        judge2 = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
        judge3 = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
        sign_total = sign(judge1) + sign(judge2) + sign(judge3);

        if (sign_total == 1 + 1 + 1 || sign_total == -1 - 1 - 1) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}

int sign(double x)
{
    if (x >= 0) {
        return 1;
    } else {
        return -1;
    }
}

Measured memory_bytes: 612
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

template<class T>T gcd(T a, T b){if(a<b){a^=b;b^=a;a^=b;}return b?gcd(b,a%b):a;}
template<class T>T lcm(T a, T b){return a*b/gcd(a,b);}
static vector<int> P={2};
template<class T>T next_prime(T x){
    int size=P.size();
    
    if(x<P[size-1]){
        int begin=0,end=size;
        while(end-begin>1){
            int c=(begin+end)/2;
            if(x<P[c]){
                end=c;
            }else{
                begin=c;
            }
        }
        return P[begin];
    }

    T res=P[size-1];
    while(true){
        res++;
        bool prime=true;
        for(int i=0;i<size;i++){
            if(P[i]<=sqrt((double)res)){
                if(res%P[i]==0){
                    prime=false;
                    break;
                }
            }else{
                break;
            }
        }

        if(prime){
            P.push_back(res);
            size++;
            if(res>x){
                break;
            }
        }
    }

    return res;
}

ll A,B;

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

    ll g=gcd(A,B);
    ll sg=sqrt(g);
    ll div=1;
    ll ans=1;
    bool b;
    while(div<sg){
        div=next_prime(div);
        if(g%div==0){
            ans++;
            while(g%div==0) g/=div;
        }
    }
    if(g!=1) ans++;

    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>t(N), x(N), y(N);
	rep(i, N)cin >> t[i] >> x[i] >> y[i];
	int X = 0, Y = 0, T = 0;
	rep(i, N) {
		int dis = abs(X - x[i]) + abs(Y - y[i]);
		if (t[i] - T < dis) {
			cout << "No" << endl;
			return 0;
		}
		if (dis % 2 != (t[i] - T) % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<string>
#include<map>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> v_str(n);
  for(int i = 0; i < n; i++) {
    cin >> v_str[i];
  }


  string pat = "abcdefghijklmnopqrstuvwxyz";
  int v_cnt[100][100];

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < v_str[i].size(); j++) {
      for(int k = 0; k < pat.size(); k++) {
        if(pat[k] == v_str[i][j]) {
          v_cnt[i][k]++;
        }
      }
    }
  }


//  int cnt = 0;
  bool flg = false;
  //int min_f = 9999999;
  string ans;
  for(int i = 0; i < pat.size(); i++) {
    int min_f = 999999;
    for(int j = 0; j < n; j++) {
      if(v_cnt[j][i] < min_f) {
        min_f = v_cnt[j][i];
      }
    }
    for(int j = 0; j < min_f; j++) {
      ans.push_back(pat[i]);
    }
  }

  cout << ans  << endl;

}


Measured memory_bytes: 256
#!/usr/bin/python3

a = []

for i in range(3):
    a.append(tuple(map(int, input().split())))

n = int(input())

tbl = [ [0 for i in range(3)] for j in range(3) ]

for i in range(n):
    b = int(input())
    for y in range(3):
        for x in range(3):
            if a[y][x] == b:
                tbl[y][x] = 1

if tbl[0][0] * tbl[0][1] * tbl[0][2] == 1:
    print('Yes')
elif tbl[1][0] * tbl[1][1] * tbl[1][2] == 1:
    print('Yes')
elif tbl[2][0] * tbl[2][1] * tbl[2][2] == 1:
    print('Yes')
elif tbl[0][0] * tbl[1][0] * tbl[2][0] == 1:
    print('Yes')
elif tbl[0][1] * tbl[1][1] * tbl[2][1] == 1:
    print('Yes')
elif tbl[0][2] * tbl[1][2] * tbl[2][2] == 1:
    print('Yes')
elif tbl[0][0] * tbl[1][1] * tbl[2][2] == 1:
    print('Yes')
elif tbl[0][2] * tbl[1][1] * tbl[2][0] == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
import numpy as np
h,w=input().split()
h,w=int(h),int(w)
t1=[]
for i in range(h):
    s1=list(input())
    t1.append(s1)

t2=[[0 for i in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        if t1[i][j]=="#":
            for k in range(3):
                for l in range(3):
                    if k==1 and l==1:
                        continue
                    if i+k-1>=0 and j+l-1>=0 and i+k-1<h and j+l-1<w and t1[i+k-1][j+l-1]!="#":
                        t2[i+k-1][j+l-1]+=1
            t2[i][j]="#"
for i in range(h):
    for j in range(w):
        print(t2[i][j],end="")
    print("")


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

using i64 = long long;

const int N = 1e5 + 5;

vector<int> g[N];
i64 val[N];

int n, root;

void dfs(int u, int far = -1) {
	i64 sum(0), mx(0);
	for (auto v: g[u]) if (v != far) {
		dfs(v, u);
		mx = max(mx, val[v]);
		sum+= val[v]; }

	if (g[u].size() == 1)
		return;

	i64 up, down;
	down = sum - val[u];
	up = val[u] - down;

	if (down > min(sum / 2, sum - mx)) throw 0;
	if (up < 0 || down < 0 || val[u] < up || val[u] < down || sum != 2 * down + up) throw 0;
	val[u] = up; }

int main() {
#ifdef HOME
	freopen("agc6c.in", "r", stdin);
	freopen("agc6c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> val[i];

	for (int a, b, i = 1; i < n; ++i) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a); }

	if (n == 2) {
		cout << (val[1] == val[2] ? "YES" : "NO") << endl;
		return 0; }

	for (int i = 1; i <= n; ++i) if (g[i].size() > 1) {
		root = i;
		break; }

	try {
		dfs(root); }
	catch (int e) {
		cout << "NO" << endl;
		return 0; }

	cout << (!val[root] ? "YES" : "NO") << endl;

	return 0; }


Measured memory_bytes: 13184
#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;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890




vector<ll> inv,fact,invfact;
void Mod_build(int n=201010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%Mod;
		if(i>0)inv[i+1]=Mod-inv[Mod%(i+1)]*(Mod/(i+1))%Mod;
		invfact[i+1]=invfact[i]*inv[i+1]%Mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%Mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%Mod)*invfact[k]%Mod;
}
ll powMod(ll n,ll k){
	k%=Mod-1;
	if(k<0)k+=Mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%Mod;
		n=n*n%Mod;
		k>>=1;
	}
	return ret;
}



int main(){
    ll i,j;
    Mod_build();

    ll n,m,k;
    cin>>n>>m>>k;

    ll ans1=(n-1)*n*(n+1)/6;
    ans1%=Mod;
    ans1*=(m*m);
    ans1%=Mod;

    ll ans2=(m-1)*m*(m+1)/6;
    ans2%=Mod;
    ans2*=(n*n);
    ans2%=Mod;

    ll ans=(ans1+ans2)%Mod;
    
    ans*=comb(n*m-2,k-2);
    ans%=Mod;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

bool check(string line)
{
    if (line[0] != 'A')
    {
        return false;
    }
    bool success = false;
    int index = -1;
    for (int i = 2; i < line.size() - 1; i++)
    {
        if (line[i] == 'C')
        {
            success = true;
            index = i;
            break;
        }
    }
    if (!success)
    {
        return false;
    }
    success = true;
    for (int i = 1; i < line.size(); i++)
    {
        if (i != index)
        {
            if ('A' <= line[i] && line[i] <= 'Z')
            {
                success = false;
            }
        }
    }
    return success;
}

int main()
{
    string line;
    cin >> line;
    cout << (check(line) ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
/* ex5_3
   cy_an  */

#include <stdio.h>

int main(void){

    // 変数宣言
    int num_r, num_c, i, j, r_flag, c_flag, printflag;
    // numの入力
    scanf("%d %d", &num_r, &num_c);
    // 変数宣言
    char matrix[num_r+1][num_c+1];
    // raw,colの入力
    for(i=0; i<num_r; i++){
        scanf("%s", &matrix[i]);
    }

    // 行の削除
    for(i=0; i<num_r; i++){
        r_flag = 1;
        for(j=0; j<num_c; j++){
            if(matrix[i][j] == '#'){
                r_flag = 0;
                break;
            }
        }
        // 全て'.'のとき
        if(r_flag){
            for(j=0; j<num_c; j++){
                matrix[i][j] = '\0';
            }
        }
    }
    // 列の削除
    for(j=0; j<num_c; j++){
        c_flag = 1;
        for(i=0; i<num_r; i++){
            if(matrix[i][j] == '#'){
                c_flag = 0;
                break;
            }
        }
        // 全て'.'のとき
        if(c_flag){
            for(i=0; i<num_r; i++){
                matrix[i][j] = '\0';
            }
        }
    }
    // for(i=0; i<num_r; i++){
    //     for(j=0; j<num_c; j++){
    //         printf("%c", matrix[i][j]);
    //     }
    //     printf("\n");
    // }

    // matrixの出力
    for(i=0; i<num_r; i++){
        printflag = 0;
        for(j=0; j<num_c; j++){
            if(matrix[i][j] != '\0'){
                printf("%c", matrix[i][j]);
                printflag = 1;
            }
        }
        if(printflag){
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    public static void main (String[] arg) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int R, G, B, N;
    		R = sc.nextInt();
    		G = sc.nextInt();
    		B = sc.nextInt();
    		N = sc.nextInt();
    		
    		int counter = 0;
    		
    		for (int redSize = 0; R*redSize <= N; redSize++) {
    			for (int greSize = 0; G*greSize <= N; greSize++){
    				int tmpBuleSize = N - R*redSize - G*greSize;
    				if (0 <= tmpBuleSize && tmpBuleSize % B == 0) {
    					counter++;
    				}
    				
    			}
    		}
    		
    		System.out.println(counter);
    		
    	}
    	
    } 
}

Measured memory_bytes: 22996
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<string>
using namespace std;
typedef long long ll;
int main(void)
{
    string s;
    while(cin>>s)
    {
        for(int i=0;s[i];i++)
            if(i%2==0)
               printf("%c",s[i]);
        cout<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    string arr[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    string a;
    cin >> a;
    for( int i = 0; i < 7; i++ ){
        if( arr[i] == a ){
            cout << 7-i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 256