akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int pt=0,px=0,py=0;
    int flag=1;
    while(n--)
    {
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        if(t-pt<abs(x-px)+abs(y-py))
            flag=0;
        else if((t-pt-(abs(x-px)+abs(y-py)))%2==1)
            flag=0;
        pt=t,px=x,py=y;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main(){
	int n, m;
	cin >> n >> m;
	vector<long long> input;
	REP(i, m) {
		long long a;
		cin >> a;
		input.push_back(a);
	}
	sort(input.begin(), input.end());
	vector<long long> dif;
	REP(i, input.size() - 1) {
		dif.push_back(input[i + 1] - input[i]);
	}
	long long ans = 0;
	sort(dif.begin(), dif.end());
	for (int i = 0; i < m - n; ++i) {
		ans += dif[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2548
n=int(input())
a=[];b=[]
for _ in range(n):
    ai,bi=map(int, input().split())
    a.append(ai);b.append(bi)
a.sort()
b.sort()
ma=0;mb=0
if n%2:
    ma=a[n//2]
    mb=b[n//2]
    
else:
    ma=a[n//2]+a[n//2-1]
    mb=b[n//2]+b[n//2-1]
print(mb-ma+1)


Measured memory_bytes: 25556
#include<stdio.h>

#define MAX_N 100000

int head=0, tail;
struct task{
    int time;
    char name[11];
}  que[MAX_N];


void enqueue(struct task);
struct task dequeue(void);

void enqueue(struct task q){
    que[tail] = q;
    if(tail == MAX_N -1){
        tail = 0;
    
    }else{
        tail++;
    }
}

struct task dequeue(){
    struct task t;
    t = que[head];

    if(head == MAX_N -1){
        head = 0;
    }else{
        head++;
    }

    return t;
}


int main(){
    int i, sum_time, q, n, process;
    struct task t;

    scanf("%d %d",&n ,&q);
    for(i=0; i<n; i++){
        scanf("%s %d", que[i].name, &que[i].time);
    }

    tail = n;
    while(head != tail){
        t = dequeue();
        if(t.time > q){
            process = q;
        }else{
            process = t.time;
        }

        t.time -= process;
        sum_time += process;

        if(t.time > 0){
            enqueue(t);
        }else{
            printf("%s %d\n", t.name, sum_time);
        }
    }

    return 0;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
int a[MAXN];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, ans = 0, one = 0; read(n);
  for (RI i = 1; i <= n; ++i) read(a[i]);
  for (RI i = 1; i <= n; ++i)
    ans += !(a[i] & 1), one |= (a[i] == 1);
  int sum = ans, flag = 1;
  while (sum == n - 1 && !one) {
    int g = 0; sum = one = 0;
    for (RI i = 1; i <= n; ++i)
      if (a[i] & 1) --a[i], g = __gcd(g, a[i]);
      else g = __gcd(g, a[i]);
    for (RI i = 1; i <= n; ++i)
      a[i] /= g, sum += !(a[i] & 1), one |= (a[i] == 1);
    flag ^= 1;
  }
  if ((sum & 1) == flag) puts("First");
  else if (ans & 1) puts("First");
  else puts("Second");

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    const int m = 1e9 + 7;
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    rep(i, 1, n + 1) cin >> a[i];
    vector<ll> sum(n + 1, 0);
    repd(i, n - 1, 1) sum[i] = (sum[i + 1] + a[i + 1]) % m;
    ll ans = 0;
    rep(i, 1, n + 1) ans = (ans + a[i] * sum[i] % m) % m;
    cout << ans << endl;
}


Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2; // x^kがxの逆元
    while (k) {	// 二分累乗法
        if (k & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        k /= 2;
    }
    return res;
}

int main(){
  ll N; cin >> N;
  vector<ll> X(N); rep(i,N) cin >> X[i];
  vector<ll> kaijo(100100, 1);
  rep(i,100005){
    kaijo[i+2] = kaijo[i+1] * (i+2);
    kaijo[i+2] %= mod;
  }
  ll ans = 0;
  ll now = kaijo[N-1];
  for(ll i=0; i<N-1; i++){
    ans += now*(X[i+1]-X[i]);
    ans %= mod;
    now += kaijo[N-1]*inv(i+2);
    now %= mod;
  }
  cout << ans%mod << endl;
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#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 = 1LL << 55;
const int mod = 1e9 + 7;

int n;
int bit[400];

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

map<pair<int, vector<int> >, bool> mp;

bool in(int x, int y) {
  return 0 <= x && x < 3 && 0 <= y && y < 3;
}

bool dfs(int day, vector<int> v) {
  if(mp.count(make_pair(day, v))) return mp[make_pair(day, v)];
  if(day == n) return true;
  int x = v[0]%3, y = v[0]/3;
  for(int i = 0; i < 9; i++) {
    vector<int> nv(7);
    int tmp = 0;
    int nx = x + dx[i], ny = y + dy[i];
    if(!in(nx, ny)) continue;
    tmp = 1<<(ny*4+nx) | 1<<((ny+1)*4+nx) | 1<<(ny*4+nx+1) | 1<<((ny+1)*4+nx+1);
    if(bit[day+1] & tmp) continue;
    int a[16] = {0}; 
    for(int i = 0; i < 6; i++) nv[i+1] = v[i];    
    nv[0] = ny*3 + nx;
    if(day >= 5) {      
      for(int j = 0; j < 7; j++) {
	int tx = nv[j]%3, ty = nv[j]/3;
	a[ty*4+tx]++;
	a[(ty+1)*4+tx]++;
	a[ty*4+tx+1]++;
	a[(ty+1)*4+tx+1]++;
      }
      bool flag = true;
      for(int j = 0; j < 16; j++) {
	flag &= (a[j] != 0);
      }
      if(!flag) continue;
    }
    if(dfs(day+1, nv)) return mp[make_pair(day, v)] = true;
  }
  return mp[make_pair(day, v)] = false;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> n, n) {
    mp.clear();
    for(int i = 0; i < n; i++) {
      bit[i] = 0;
      for(int j = 0; j < 16; j++) {
	int b; cin >> b;
	bit[i] |= b<<j;
      }
    }
    int tmp = 0;
    tmp = 1<<5 | 1<<6 | 1<<9 | 1<<10;
    if(bit[0] & tmp) {
      cout << 0 << endl;
      continue;
    }
    vector<int> v(7, -1);
    v[0] = 4;
    cout << (int)dfs(0, v) << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 36060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      string a,b; cin>>a>>b;
      int num=(stoi)(a+b);
      rep(i,1,num){
            if(num%i==0){
                  if(num/i==i){
                        cout<<"Yes"<<endl;
                        return 0;
                  }
            }
      }
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const s = input.trim()
  const wether = ['Sunny', 'Cloudy', 'Rainy']

  switch (s) {
    case 'Sunny':
      console.log('Cloudy')
      break
    case 'Cloudy':
      console.log('Rainy')
      break
    case 'Rainy':
      console.log('Sunny')
      break
    defalt:
      break
  }
}
main()

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  
  string S, T; cin >> S >> T;

  int s = S.length(), t = T.length();

  int DP[s][t];

  if (S[0] == T[0]) DP[0][0] = 1;
  else DP[0][0] = 0;

  for (int i = 1; i < s; i++){
    if (DP[i - 1][0] == 1) DP[i][0] = 1;
    else{
      if (S[i] == T[0]) DP[i][0] = 1;
      else DP[i][0] = 0;
    }
  }

  for (int j = 1; j < t; j++){
    if (DP[0][j - 1] == 1) DP[0][j] = 1;
    else{
      if(S[0] == T[j]) DP[0][j] = 1;
      else DP[0][j] = 0;
    }
  }
  
  for (int i = 1; i < s; i++){
    for (int j = 1; j < t; j++){
      if (S[i] == T[j]){
        DP[i][j] = DP[i - 1][j - 1] + 1;
      }else{
        DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
      }
    }
  }
    
  string ans;

  if (DP[s - 1][t - 1] > 0){
    int i = s - 1, j = t - 1;
    while (i >= 0 && j >= 0 && DP[i][j] > 0){
      if (DP[i][j] == DP[i - 1][j]){
        i--;
      }else if(DP[i][j] == DP[i][j - 1]){
        j--;
      }else{
        ans = S[i] + ans;
        i--; j--;
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
 
using namespace std;
 #define mod 1000000009
#define ll long long
ll dp[5009];
  ll a[5009];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=1;
     for(int i=0;i<n;i++){
       for(int j=k;j>=a[i];j--){
          
               dp[j]=(dp[j]+dp[j-a[i]])%mod;
           
       }
    }ll ans=0;
     for(int i=0;i<n;i++){
      ll temp[k];
      for(int j=0;j<=k;j++){
          temp[j]=dp[j];     
      }
       for(int j=a[i];j<=k;j++){
          temp[j]=(temp[j]-temp[j-a[i]]+mod)%mod;
      }ll m=0;
      for(int j=max(k-a[i],m);j<k;j++){
          if(temp[j]){
              ans++;break;
          }
      }
    }
    cout<<n-ans;

}

Measured memory_bytes: 3724
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;


int main(){
	int A,B;
	cin>>A>>B;
	cout<<max(A+(A-1),max(A+B,B+(B-1)));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

def Ans(ans):
    lst = []
    small = min(ans)
    for i in ans:
        if i%small != 0:
            lst.append(i%small)
    lst.append(small)
    if len(lst) == 1:
        print(lst[0])
    else:
        ans = lst
        Ans(ans)
Ans(A)

Measured memory_bytes: 14252
#include<stdio.h>
int main(void){

	int x,a;
	for(int i=1;;i++){
	scanf("%d%d",&x,&a);
	if(a==0 && x==0)break;
	else if(x>a){
		int n=x;
			x=a;
			a=n;
	}
	printf("%d %d\n",x,a);
	}
	return 0;
}

Measured memory_bytes: 1028
D,N = map(int,input().split())
if D == 0:
    if N == 100:
        print('101')
    else:
        print(N)
elif D == 1:
    if N == 100:
        print('10100')
    else:
        print(100*N)
else:
    if N == 100:
        print('1010000')
    else:
        print(10000*N)
        

Measured memory_bytes: 2940
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
vector<vector<int>> hen;
vector<int>zyu;//重心からの数
int n,endflag=0;
int make_tree(int ter,int oya){
	vector<int> are;
	int kos=1,flag=1;
	for(auto it:hen[ter]){
		if(it==oya){continue;}
		int a=make_tree(it,ter);
		are.pub(a);
		kos+=a;
		if(a*2>n){flag=0;}
	}
	if(kos*2<n){flag=0;}
	if(kos*2==n){endflag=1;}
	if(flag==1){
		are.pub(n-kos);
		zyu=are;
	}
	return kos;
}
int main(void){
	int i,j;cin>>n;
	hen.res(n);
	vector<llint>fra(n+1);fra[0]=1;
	vector<llint>gya(n+1);
	for(i=0;i<n;i++){fra[i+1]=(fra[i]*(i+1))%mod;}
	llint gen=fra[n];gya[n]=1;
	for(int bi=0;bi<30;bi++){
		if(((mod-2)&(1<<bi))!=0){gya[n]*=gen;gya[n]%=mod;}
		gen=gen*gen;
		gen%=mod;
	}
	for(i=n-1;i>=0;i--){gya[i]=(gya[i+1]*(i+1))%mod;}
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		hen[a].pub(b);
		hen[b].pub(a);
	}
	make_tree(0,-1);
	if(endflag==1){cout<<(fra[n/2]*fra[n/2]%mod)<<endl;RE;}
	vector<llint>dp(n+1);
	dp[0]=1;
	for(auto it:zyu){
		vector<llint>ddp(n+1);
		for(i=0;i<=n;i++){
			for(j=0;j<=it;j++){
				if(i+j<0||i+j>n){continue;}
				ddp[i+j]+=((((dp[i]*fra[it])%mod)*((fra[it]*gya[j])%mod))%mod*(gya[it-j]*gya[it-j]%mod))%mod;
			}
		}
		for(i=0;i<=n;i++){dp[i]=ddp[i]%mod;}
	}
	llint ans=0;
	for(i=0;i<=n;i++){
		if(i%2==0){ans+=dp[i]*fra[n-i];}
		else{ans-=dp[i]*fra[n-i];}
		ans%=mod;
	}
	if(ans<0){ans+=mod;}
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 1024
import math
def prime(n):
    flag = True
    if n==1 or n==2:
        return True
    for i in range(2,math.ceil(math.sqrt(n))+1):
        if n%i == 0:
            flag = False
            break
    return flag

a,b=map(int,input().split())
A=set()
B=set()

for i in range(1,math.ceil(math.sqrt(a))+1):
    if a%i == 0:
        A.add(i)
        A.add(a//i)

for i in range(1,math.ceil(math.sqrt(b))+1):
    if b%i == 0:
        B.add(i)
        B.add(b//i)

A=[num for num in A if prime(num)]
B=[num for num in B if prime(num)]

ans=0
for b in B:
    if b in A:
        ans+=1
print(ans)

Measured memory_bytes: 4580
from fractions import gcd

N,M=map(int,input().split())
S=input()
T=input()

if S[0]!=T[0]:
    print(-1)
    exit()

gcd=gcd(M,N)

for t in range(M):
    if (t*N)/M==(t*N)//M:
        if S[(N*t)//M]!=T[t]:
            print(-1)
            exit()

print((M*N)//gcd)



Measured memory_bytes: 5432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		long[] a = new long[n];

		long sum1 = 0,sum2 = 0, ans1 = 0, ans2 = 0;

		for (int j = 0; j < a.length; j++) {
			a[j] = in.nextLong();
		}
		in.close();

		for(int i = 0; i < n; i++) {//偶数がプラス
			if(sum1 + a[i] > 0) {
				sum1 += a[i];
			} else {
				ans1 += 1 - (sum1 + a[i]);
				sum1 = 1;
			}
//			System.out.println(sum1 + " " + ans1);
			i++;
			if(i >= n) break;
			if(sum1 + a[i] < 0) {
				sum1 += a[i];
			} else {
				ans1 += sum1 + a[i] + 1;
				sum1 = -1;
			}
//			System.out.println(sum1 + " " + ans1);
		}
		System.out.println();

		for(int i = 0; i < n; i++) {//奇数がプラス
			if(sum2 + a[i] < 0) {
				sum2 += a[i];
			} else {
				ans2 += sum2 + a[i] + 1;
				sum2 = -1;
			}
//			System.out.println(sum2 + " " + ans2);
			i++;
			if(i >= n) break;
			if(sum2 + a[i] > 0) {
				sum2 += a[i];
			} else {
				ans2 += 1 - (sum2 + a[i]);
				sum2 = 1;
			}
//			System.out.println(sum2 + " " + ans2);
		}
		System.out.println(Math.min(ans1, ans2));
	}
}


Measured memory_bytes: 50892
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll ans;
  if(K%2==0) ans=A-B;
  else ans=B-A;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize(3,"Ofast","inline")
#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--)
#define ms(s) memset(s, 0, sizeof(s))
#define squ(x) (x)*(x)


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int , int> pi;
typedef unordered_map<int,int> un_map;
typedef priority_queue<int> prque;

template<class T>
inline void read (T &x) {
    x = 0;
    int sign = 1;
    char c = getchar ();
    while (c < '0' || c > '9') {
        if ( c == '-' ) sign = - 1;
        c = getchar ();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar ();
    }
    x = x * sign;
}

const int maxn = 3e5 + 10;
const int inf = 1e9;
const ll INF = ll(1e18);
const int mod = 998244353;
const double PI = acos(-1);
//#define LOCAL

int n;

void solve() {
	string s1,s2;
	cin>>s1>>s2;
	rep(i,0,n) {
		string s=s1.substr(0+i,n-i);
		string t=s2.substr(0,n-i);
		if (s==t) {
			printf("%d\n",n+i);
			return;
		}
	}
}
int main(int argc, char * argv[])
{
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    
    while(~scanf("%d",&n)) {
    	solve();
    }
    return 0; 
}


Measured memory_bytes: 256
t1[12],t2[12],i,j,k,z,c,r;

f(x){
	r=0;
	c=4;
	memcpy(t2,t1,48);
	t2[x]-=2;
	for(k=1;k<=9;){
			t2[k]?t2[k]>2?t2[k]-=3,r=!--c:t2[k+1]&&t2[k+2]?--t2[k],--t2[k+1],--t2[k+2],r=!--c:--t2[k]:0;
t2[k]||++k;
	}
}

int main(void){
	char s[16];
	for(;~scanf(" %s",s);){
		memset(t1,0,48);
		for(z=i=0;i<13;)++t1[s[i++]-'0'];
		for(i=1;i<=9;i++){
			if(t1[i]<4){
				++t1[i];
				for(j=1;j<=9;j++){
					if(t1[j]>1&&(f(j),r)){
						z++&&printf(" ");
						printf("%d",i,j);
						break;
					}
				}
				--t1[i];
			}
		}
		puts(z?"":"0");
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int d[500][500];
int flag[500][500];

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

void solve()
{
    int n;
    scanf("%d", &n);
    int n2 = n * n;
    vector<int> p(n2);
    int i,j;
    for (i = 0; i < n2; i++) {
        scanf("%d", &p[i]); p[i]--;
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            d[i][j] = MIN(MIN(i+1,n-i),MIN(j+1,n-j));
        }
    }

#define P(i,j) ((i)*n+(j))
    ll ans = 0;
    for (i = 0; i < n2; i++) {
        int x = p[i] / n;
        int y = p[i] % n;
        ans+=(d[x][y]- 1);
        d[x][y]--;
        flag[x][y] = 1;
        queue<int> que;
        que.push(P(x,y));
        while (!que.empty()) {
            int tmp=que.front();
            que.pop();
            int currx = tmp / n;
            int curry = tmp % n;

            int k;
            for (k = 0; k < 4; k++) {
                int x2 = currx + dx[k], y2 = curry + dy[k];
                if (x2 < 0 || x2 >= n || y2 < 0 || y2 >= n) continue;

                int dist2 = d[currx][curry] + (flag[x2][y2] ? 0 : 1);
                if (dist2 < d[x2][y2]) {
                    d[x2][y2] = dist2;
                    que.push(P(x2, y2));
                }
            }
        }
    }
    printf("%lld\n", ans);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
 
 
long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
class Combination{
	
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};
Combination C;
 
#define MAX 18
 
int n;
 
vector<int> va;
vector<int> vb;
 
int dp[1<<18][MAX];
 
inline int get_val(int pos,int id){
	if(pos%2==id%2){
		return va[id];
	}
	return vb[id];
}
 
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		va.push_back(a);
	}
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		vb.push_back(a);
	}
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)dp[1<<i][i]=0;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(dp[i][j]==-1)continue;
			int cn=0;
			for(int k=0;k<n;k++){
				if(((i>>k)&1))cn++;
			}
			int las=get_val(cn-1,j);
			for(int k=0;k<n;k++){
				if(((i>>k)&1))continue;
				int nex=get_val(cn,k);
				if(las<=nex){
					int cs=dp[i][j]+__builtin_popcount(i&(((1<<n)-1)^((1<<k)-1)));
					int &val=dp[i|(1<<k)][k];
					if(val==-1||val>cs){
						val=cs;
					}
				}
			}
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++){
		if(dp[(1<<n)-1][i]!=-1){
			if(ans==-1||ans>dp[(1<<n)-1][i]){
				ans=dp[(1<<n)-1][i];
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max();
const ll INFLL = numeric_limits<ll>::max();

signed main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    cin >> a;
    auto check = [&]() {
        bool temp = true;
        for (auto now : a) if (now > N - 1) temp = false;
        return temp;
    };
    ll ans = 0;
    while (true) {
        ll sum = 0;
        vector<ll> count(N, 0);
        for (int i = 0; i < N; i++) {
            if (a[i] <= N - 1) continue;
            ll minus = a[i] / N;
            sum += minus;
            count[i] = minus;
            a[i] %= N;
        }
        ans += sum;
        for (int i = 0; i < N; i++) {
            a[i] += sum - count[i];
        }
        if (check()) break;
    }
    cout << ans << endl;
}


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

int main()
{
  int n, x = 0, ans = 0;
  string s;

  cin >> n >> s;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'I')
      x++;
    else
      x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N, M;
vector<T> edges;
vector<P> G[110];
int dist[110][110];

vector<int> dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> q;
    vector<int> d(N);
    rep(i, N) d[i] = 1000000000;
    d[s] = 0;
    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top(); q.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        rep(i, G[v].size()) {
            int nv = G[v][i].first, w = G[v][i].second;
            if (d[nv]>d[v]+w) {
                d[nv] = d[v]+w;
                q.push(P(d[nv], nv));
            }
        }
    }
    return d;
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        edges.pb(make_tuple(a-1, b-1, c));
        G[a-1].pb(P(b-1, c));
        G[b-1].pb(P(a-1, c));
    }
    rep(i, N) {
        vector<int> d = dijkstra(i);
        rep(j, N) dist[i][j] = d[j];
    }
    int ans = 0;
    rep(i, M) {
        int a = get<0>(edges[i]), b = get<1>(edges[i]), c = get<2>(edges[i]);
        bool flag = true;
        rep(i, N) rep(j, N) {
            if (dist[i][j]==dist[i][a]+c+dist[b][j]) flag = false;
            if (dist[i][j]==dist[i][b]+c+dist[a][j]) flag = false;
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

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

int arr[6],k;
string si="Yay!",no=":(";

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    for(int i=1;i<=5;i++) cin>>arr[i];
    cin>>k;
    for(int i=1;i<5;i++){
        bool bul=0;
        for(int j=i+1;j<=5;j++){
            if(abs(arr[i]-arr[j]) > k){
                bul=1;
                break;
            }
        }
        if(bul==1){
            cout<<no;
            break;
        }
        if(i==4) cout<<si;
    }
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    flg=false
    for h in 1:3500
        for w in h:3500
            res=n*h*w/(4*h*w-n*w-n*h)
            if res>0 && isinteger(res)
                println("$h $w $(Int(res))")
                flg=true
                break
            end
        end
        if flg
            break
        end
    end
end
main()

Measured memory_bytes: 166280
import math, sys

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

map=[]
Hs=[]
Ws=[]
for _ in range(H):
    row=list(input())
    map.append(row)
    Hs.append(row.count("#"))
for i in range(W):
    count=0
    for j in range(H):
        if map[j][i]=="#":
            count+=1
    Ws.append(count)
#print(Hs,Ws)
tot = sum(Hs)
ans=0
for i in range(2**H):
    for j in range(2**W):
        i_bin=(bin(i)[2:]).zfill(H)
        j_bin=(bin(j)[2:]).zfill(W)
        count=0
        for i2 in range(H):
            if i_bin[i2]=="1":
                count+=Hs[i2]
        for j2 in range(W):
            if j_bin[j2]=="1":
                count+=Ws[j2]
        for i2 in range(H):
            for j2 in range(W):
                if i_bin[i2]=="1" and j_bin[j2]=="1" and map[i2][j2]=="#":
                    count-=1
        if tot - count==K:
            ans+=1
            #print(i_bin,j_bin,count,tot-count)
print(ans)


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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();

        int MOD = 1_000_000_007;
        long[] fact = new long[Math.max(N, M) + 1];
        fact[0] = 1;
        for (int i = 1; i < fact.length; i++) {
            fact[i] = i * fact[i - 1] % MOD;
        }

        long ans = Math.max(0, 2 - Math.abs(N - M)) * fact[N] * fact[M] % MOD;
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


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

int main(){
    int64_t N;
    cin >> N;
    for(int64_t a=1; a<=3500; a++){
        for(int64_t b=a; b<=3500; b++){
            int64_t n = N*a*b;
            int64_t d = 4*a*b - N*(a+b);
            if(d > 0 && n % d == 0){
                int64_t c = n/d;
                if(1 <= c && c <= 3500){
                    cout << a << " " << b << " " << c << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

int main(){
  char str[19];
  cin>>str;
  char ret[20];
  
  for(int i=0;i<19;i++){
    if(','==str[i]){
      ret[i]=' ';
    }else{
      ret[i]=str[i];
    }
  }
  ret[19]=NULL;
  cout<<ret;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N,A,B = map(int, input().split())
hN = [int(input()) for i in range(N)]

# 特定の爆破数で全滅させられるかを判定する関数
def enough(T):
    cnt = 0
    # 各魔物について確認していく
    for i in range(N):
        hp = hN[i]
        # 全体への共通ダメージ分
        hp -= B*T
        # 倒せていなければ追加ダメージを与える
        if hp > 0:
            cnt += (hp-1) // (A-B) +1
    # 追加ダメージに使用した合計爆破数がT回以内かどうか判定
    if cnt <= T:
        return True
    else:
        return False

# 2分探索で最初にTrueになる場所を見つける
# hi = 10 ** 9
# low = 0
# while low+1 < hi:
#     mid = (hi+low) // 2
#     if enough(mid):
#         hi = mid
#     else:
#         low = mid
# print(hi)

hi = 10 ** 9 + 1
low = 0
mid = 10 ** 9 // 2
while low+1 < hi:
    if enough(mid):
        hi = mid
    else:
        low = mid
    mid = (hi+low+1) // 2
print(mid)

Measured memory_bytes: 7072
class Combination:
    def __init__(self, n, mod):
        fact = [0]*(n+1)
        ifact = [0]*(n+1)
        fact[0] = 1
        for i in range(1, n+1):
            fact[i] = (fact[i-1]*i) % mod
        # 1/n!を逆元で求める
        ifact[n] = pow(fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            ifact[i-1] = (ifact[i]*i) % mod

        self.n = n
        self.mod = mod
        self.fact = fact
        self.ifact = ifact

    def c(self, n, r):
        if r < 0 or r > n:
            return 0
        ret = (self.fact[n]*self.ifact[r]) % self.mod
        return (ret*self.ifact[n-r]) % self.mod

    def p(self, n, r):
        if n < r:
            return 0
        return self.fact[n]*self.ifact[n-r] % self.mod


MOD = 10**9+7
N, M = map(int, input().split())
c = Combination(M, MOD)
ans = 0
for i in range(N+1):
    a = (-1)**i * c.c(N, i)*c.p(M, i)*(c.p(M-i, N-i)**2) % MOD
    ans = (ans+a) % MOD
print(ans)


Measured memory_bytes: 89772
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {

    int n,a,b;
    int c=0;
    cin>>n>>a>>b;
    if(n*a<b)cout<<n*a<<endl;
    else cout<<b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int vis [200009];
vector <int> adj[200009];
int dist[200009];
int n,e;
void bfs(int node)
{
    queue <int>Q;
    Q.push(node);
    vis[node] = 1;

    while(!Q.empty())
    {
        int u = Q.front();
        Q.pop();
        for(int k = 0; k<adj[u].size(); k++)
        {
            if(!vis[adj[u][k]])
            {
                int v = adj[u][k];
                dist[adj[u][k]] = dist[u]+1;
                if(adj[u][k]==n)
                    return ;
                vis[v] = 1;
                Q.push(v);
            }
        }
    }
}
int main ()
{
    cin>>n>>e;
   // memset(vis,0,sizeof(vis));
    for(int i = 1; i<=e; i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    bfs(1);
    if(dist[n]<=2 && dist[n]>0)
    {
        cout<<"POSSIBLE"<<endl;
    }
    else
        cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 10360
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
//4008160009
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false)
#define lid id<<1|1
#define rid (id<<1)+2
#define mid l+r>>1
#define lson lid, l, mid
#define rson rid, mid, r

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=405;
const int rot[4][4]{{0, 1, 2, 3}, {1, 2, 3, 0}, {2, 3, 0, 1}, {3, 0, 1, 2}};

int N, t;
map<vi,pi> MP;
map<vi,pi>::iterator it;
vi C[MAX];
ll tt, ret; 

inline void Insert(vi&T, int t)
{
    it=MP.find(T);
    if(it!=MP.end())
    {
        it->s.s+=t;
        return;
    }
    int repeat=(mp(T[0], T[1])==mp(T[2], T[3])?(T[0]==T[3]?4:2):1);
    MP[T]=mp(repeat, t);
}

inline void Add(vi&T, int t)
{
    vi tmp[4];
    forn(i, 4)
    {
        vi &tt=tmp[i];
        tt.resize(4);
        forn(j, 4)
            tt[j]=T[rot[i][j]];
    }
    sort(tmp, tmp+4);
    int ptr=unique(tmp, tmp+4)-tmp;
    forn(i, ptr)
        Insert(tmp[i], t);
}

inline int Find(vi&T)
{
    it=MP.find(T);
    return it->s.s*it->s.f;
}

int main()
{
    N=in();
    forn(i, N)
    {
        C[i].resize(4);
        forn(j, 4)
            C[i][j]=in();
        Add(C[i], 1);
    }
    
    forn(i, N)
    {
        Add(C[i], -1);
        for(int j=i+1; j<N; ++j)
        {
            Add(C[j], -1);
            reverse(all(C[j]));
            forn(k, 4)
            {
                tt=1;
                vi kk;
                for(t=0; t<4; ++t)
                {
                    kk={C[j][(k+t)&3], C[j][(k+t+1)&3], C[i][(t+1)&3], C[i][t]};
                    tt*=Find(kk);
                    if(!tt)
                        break;
					Add(kk, -1);
                }
                while(t--)
                {
                    kk={C[j][(k+t)&3], C[j][(k+t+1)&3], C[i][(t+1)&3], C[i][t]};
                    Add(kk, 1);
                }
                ret+=tt;
            }
            reverse(all(C[j]));
            Add(C[j], 1);
        }
    }
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collections;
import java.util.ArrayList;

/**
 * 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);
        TaskAtCoder solver = new TaskAtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtCoder
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            Map<String, Integer> map = new HashMap<>(N);
            for (int i = 0; i < N; i++)
            {
                String s = in.next();
                int occ = map.getOrDefault(s, 0);
                map.put(s, ++occ);
            }

            int max = Integer.MIN_VALUE;
            for (String s : map.keySet())
            {
                max = Math.max(max, map.get(s));
            }
            List<String> list = new ArrayList<>();
            for (String s : map.keySet())
            {
                if (map.get(s) == max) list.add(s);
            }
            Collections.sort(list);
            for (int i = 0; i < list.size(); i++)
            {
                if (i == list.size() - 1)
                    out.print(list.get(i));
                else
                    out.println(list.get(i));
            }
        }

    }
}



Measured memory_bytes: 78456
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

bool has(vector<string> &v, string s)
{

    return find(ALL(v), s) != v.end();
}

void show(vector<string> &v)
{
    rep(i, v.size())
    {
        cerr << v[i] << " ";
    }
    cerr << endl;
}

int main()
{
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
        {
            break;
        }
        string first = "";
        map<string, vector<string>> mp;
        rep(i, n)
        {
            string s, name = "", tmp = "";
            int j = 0;
            cin >> s;

            while (s[j] != ':')
            {
                name += s[j];
                j++;
            }
            if (i == 0)
                first = name;
            j++;
            while (s[j] != '.')
            {
                if (s[j] != ',')
                {
                    tmp += s[j];
                }
                else
                {
                    mp[name].push_back(tmp);
                    tmp = "";
                }
                j++;
            }
            mp[name].push_back(tmp);
        }
        // show(mp[first]);

        bool flg = true;
        while (flg)
        {
            //cerr << 1 << endl;
            flg = false;
            rep(i, mp[first].size())
            {
                string nowname = mp[first][i];
                if (mp[nowname].size() != 0)
                {
                    flg = true;
                    mp[first].erase(mp[first].begin() + i);
                    for (auto addstr : mp[nowname])
                    {
                        if (!has(mp[first], addstr))
                        {
                            mp[first].push_back(addstr);
                        }
                    }
                    break;
                }
            }
        }
        cout
            << mp[first].size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb push_back

signed main(){
    int H,W,N;
    cin >> H >> W >> N;
    vector<vector<int>> C(H,vector<int>(W));

    int h=0,w=0;
    bool rev = false;
    rep(i,N){
        int n; cin >> n;
        while(n--){
            C[h][w] = i+1;
            h += rev?-1:1;
            if(h == H) --h,rev ^= 1,++w;
            if(h == -1) ++h,rev ^= 1,++w;
        }
    }

    rep(i,H){
        rep(j,W){
            cout << C[i][j] << " ";
        }
        cout << '\n';
    }

}

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


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

    vector<int> pos;
    rep(i,n) {
        int temp;
        cin >> temp;
        pos.push_back(temp);
    }

    int max_dis = 0;

    rep(i,n) {
        int dis;
        if (i<n-1) dis=pos[i+1] -pos[i];
        else dis = pos[0] + (k-pos[i]);
        max_dis = max(max_dis, dis);
    }

    cout << k-max_dis << endl;


    return 0;

}



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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, n; cin >> n >> a;
    if(a >= n%500) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
b = []
for i in range(n):
    x, y = [int(i) for i in input().split()]
    a.append(x)
    b.append(y)
ans = 0
for s, t in [(-1, -1), (-1, 1), (1, -1), (1, 1)]:
    cur_min = float('inf')
    cur_max = float('-inf')
    for i in range(n):
        tmp = s*a[i] + t*b[i]
        cur_min = min(cur_min, tmp)
        cur_max = max(cur_max, tmp)
    ans = max(ans, cur_max - cur_min)
print(ans)

Measured memory_bytes: 24792
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	
	if (n % 2) cout << 0;
	else{
		long long ans = 0;
		for (long long i = 5; i <= n; i *= 5){
			ans += (n / i) / 2;
		}
		cout << ans;
	}
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] A = new int[N];

      for (int i = 0; i < A.length; ++i) {
        A[i] = in.nextInt();
      }

      int gcd = gcd (A[0], A[1]);
      for (int i = 2; i < A.length; ++i) {
        gcd = gcd(gcd, A[i]);
      }

      System.out.println(gcd);
    }
  }

  private static int gcd (int a, int b) {
    return b == 0 ? a : gcd (b, a % b);
  }
}

Measured memory_bytes: 50216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n;
double f(long long x)
{
	int ret=0;
	long long tmp=x;
	while(x)
	{
		ret+=x%10;
		x/=10;
	}
	return (double)(tmp)/ret;
}
double arr[2333333];
int main()
{
	scanf("%d",&n);
	/*
	for(int i=1;i<=n;i++)
	{
		arr[i]=(double)i/f(i);
	}
	double minn=1e9;
	for(int i=n;i>=1;i--)
	{
		if(arr[i]<minn)minn=arr[i],cout<<i<<' '<<arr[i]<<endl;
	}
	/*/
	long long bit=1,cur=0;
	for(int i=1;i<=n;i++)
	{
//		cout<<f(cur)<<endl;
		if(f(cur+(bit*10))<f(cur+bit))bit*=10;
		cur+=bit;
		printf("%lld\n",cur);
	}
	//*/
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

ll dp[13];
ll ndp[13];
const int MOD = 1000000007;
void solve() {
  string s;
  cin >> s;
  dp[0] = 1;
  for(int i = 0; i < s.size(); i++) {
    memset(ndp, 0, sizeof(ndp));
    for(int a = 0; a < 13; a++) {
      if(s[i] == '?') {
        for(int x = 0; x < 10; x++) {
          ndp[((10*a)+x)%13] += dp[a];
        }
      }
      else {
        ndp[((10*a)+s[i] - '0')%13] += dp[a];
      }
    }
    for(int i = 0; i < 13; i++) ndp[i] %= MOD;
    memcpy(dp, ndp, sizeof(dp));
  }
  cout << dp[5] << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 512
x, y = map(int,input().split())
c = (4.0*x-y) / 2.0
t = (y-2.0*x) / 2.0

if (c >= 0) and (int(c) - c == 0):
    if (t >= 0) and (int(t) - t == 0):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c; cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<1<<endl;
  }else if(a==b||b==c||a==c){
    cout<<2<<endl;
  }else{
    cout<<3<<endl;
  }
}

Measured memory_bytes: 256