akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
     
typedef long long lo;
     
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}
namespace {
    const int mo = 998244353;
    inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
    inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; }
    inline int mul(int x, int y) { return (lo) x * y % mo; }
    inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
    }
}
const int N = 1e6 + 233;
int n, L, ans, a[N], cnt[N], inv[N];
int np[N], p[N], p_cnt = 0, mu[N];
vector <int> fac[N];

inline void prepare(int n) {
	np[1] = true; mu[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (!np[i]) p[++p_cnt] = i, mu[i] = -1;
		for (int j = 1; j <= p_cnt && p[j] * i <= n; j++) {
			np[p[j] * i] = true;
			if (i % p[j] == 0) break;
			else mu[p[j] * i] = -mu[i];
		}
	}	
}

int main(void) {
	read(n);
	rep (i, n) read(a[i]), cnt[a[i]]++;
	L = *max_element(a + 1, a + n + 1);
	prepare(L);
	for (int i = 1; i <= L; i++) 
		for (int j = i; j <= L; j += i)
			fac[j].push_back(i);
	inv[0] = inv[1] = 1;
	for (int i = 2; i <= L; i++) inv[i] = sub(mo, mul(mo / i, inv[mo % i]));
	for (int E = 1; E <= L; E++) {
		int t = 0, coef = 0;
		for (auto d : fac[E])
			coef = add(coef, mul(add(mo, mu[E / d]), inv[d]));
		for (int val = E; val <= L; val += E)
			t = add(t, mul(val, cnt[val]));
		ans = add(ans, mul(mul(t, t), coef));
	}
	// cout << ans << "\n";
	int cut = 0;
	rep (i, n) cut = add(cut, a[i]);
	cout << mul(sub(ans, cut), power(2)) << "\n";
}


Measured memory_bytes: 134400
using System;


class Program
{
    static void Main(string[] args)
    {
        int k = int.Parse(Console.ReadLine());
        int ans=0;
        if (k % 2 == 0)
        {
            ans = (int)Math.Pow((k/2),2.0d);
        }
        else
        {
            ans = ((int)Math.Pow(k,2)-1)/4;
        }



        Console.WriteLine(ans); 
        
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <cmath>
#include <math.h>

typedef long long ll;
using namespace std;

int main(void){
    ll a, b, c;
    cin >> a >> b >> c;
    
    ll d = c - a -b;
    if(d > 0 && d * d > 4 * a * b) cout <<"Yes"<<endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<climits>

#define FASTREAD      ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i>=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second

using namespace std;
ll n,a[100005],b[100005],c[100005],dp[100010][3],op0,op1,op2;
int main()
{
    scl(n);
    FOR(i,1,n)
    {
        scl(a[i]);
        scl(b[i]);
        scl(c[i]);
    }
    dp[n][0]=a[n];
    dp[n][1]=b[n];
    dp[n][2]=c[n];
    FORr(i,n-1,1)
    {
        if(i+1<=n)
        {
            op0=dp[i+1][0];
            op1=dp[i+1][1];
            op2=dp[i+1][2];
        }
        else
        {
            op0=LONG_MIN;
            op1=LONG_MIN;
            op2=LONG_MIN;
        }
        dp[i][0]=max(op1+a[i],op2+a[i]);
        dp[i][1]=max(op0+b[i],op2+b[i]);
        dp[i][2]=max(op0+c[i],op1+c[i]);
       // cout<<dp[i][0]<<endl;
    }
    ll ans=max(dp[1][0],dp[1][1]);
    ans=max(ans,dp[1][2]);
    ptl(ans);
    return 0;
}


Measured memory_bytes: 8516
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
int main(){
  int n,m;
  scanf("%d",&n);
  map<string,int> mp;
  for(int i=0; i<n; ++i){
    string s; cin>>s;
    mp[s]++;
  }
  scanf("%d",&m);
  for(int i=0; i<m; ++i){
    string s; cin>>s;
    mp[s]--;
  }
  int max_profit=0;
  for(map<string,int>::iterator ite=mp.begin(); ite!=mp.end(); ++ite){
    if( ite->second > max_profit){
      max_profit = ite->second;
    }
  }
  cout << max_profit <<endl;
  return 0;
}

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

#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61)
typedef long long int ll;

int main() {
	int N, i;
	cin >> N >> i;
	cout << N + 1 - i << endl;
}

Measured memory_bytes: 256
// AOJ 2195: Cat Numbers!
// 2017.12.10

#include <stdio.h>
#include <stdlib.h>

int f[17][10] = {{0},
{2,5,3},
{2,5,3,11},
{2,5,3,37},
{2,5,3,11,101},
{2,5,3,41,271},
{2,5,3,7,11,13,37},
{2,5,3,239,4649},
{2,5,3,11,73,101,137},
{2,5,3,37,333667},
{2,5,3,11,41,271,9091},
{2,5,3,21649,513239},
{2,5,3,7,11,13,37,101,9901},
{2,5,3,53,79,265371653},
{2,5,3,11,239,4649,909091},
{2,5,3,31,37,41,271,2906161},
{2,5,3,11,17,73,101,137,5882353}};

int p[17][10] = {{0},
{1,1,2},
{2,2,2,1},
{3,3,3,1},
{4,4,2,1,1},
{5,5,2,1,1},
{6,6,3,1,1,1,1},
{7,7,2,1,1},
{8,8,2,1,1,1,1},
{9,9,4,1,1},
{10,10,2,1,1,1,1},
{11,11,2,1,1},
{12,12,3,1,1,1,1,1,1},
{13,13,2,1,1,1},
{14,14,2,1,1,1,1},
{15,15,3,1,1,1,1,1},
{16,16,2,1,1,1,1,1,1}};

long long fp[17][10] = {{0},		//  fp[i] = f[i][j] ^ p[i][j]
{2, 5, 9},
{4, 25, 9, 11},
{8, 125, 27, 37},
{16, 625, 9, 11, 101},
{32, 3125, 9, 41, 271},
{64, 15625, 27, 7, 11, 13, 37},
{128, 78125, 9, 239, 4649},
{256, 390625, 9, 11, 73, 101, 137},
{512, 1953125, 81, 37, 333667},
{1024, 9765625, 9, 11, 41, 271, 9091},
{2048, 48828125, 9, 21649, 513239},
{4096, 244140625LL, 27, 7, 11, 13, 37, 101, 9901},
{8192, 1220703125LL, 9, 53, 79, 265371653LL},
{16384, 6103515625LL, 9, 11, 239, 4649, 909091},
{32768, 30517578125LL, 27, 31, 37, 41, 271, 2906161},
{65536, 152587890625LL, 9, 11, 17, 73, 101, 137, 5882353}};

long long tens[17];
int a, b;

typedef struct { long long A, B; } T;
T ans[200]; int sz;

int cmp(T *a, T *b)
{
	if (a->A - b->A) { if (a->A < b->A) return -1; else return 1; }
	if (a->B < b->B) return -1;
	return 1;
}

void check(long long x, long long y)
{
	long long A, B;

	A = x+y+1, B = y-x+1;
	if ((A & 1) || (B & 1)) return;
	A = (A >> 1) - tens[b], B >>= 1;
	if (A >= tens[a-1] && A < tens[a] &&
	    B >= tens[b-1] && B < tens[b]) ans[sz].A = A, ans[sz++].B = B;
}

void rec(int k, long long x, long long y)
{

	int i;
	long long s, t;

	if (!f[b][k]) {
		if (x >= tens[b-1])	check(x, y);
		return;
	}
	s = fp[b][k], t = f[b][k];
	rec(k+1, x, y*s);
	for (i = 0; i < p[b][k]; i++) {
		x *= t;
		if (x >= tens[b]) break;
		s /= t;
		rec(k+1, x, y*s);
	}
}

int main()
{
	int cno, i;
	long long x;

	for (x = 1, i = 0; i <= 16; i++, x *= 10) tens[i] = x;

    scanf("%d", &cno);
	while (cno--) {
		scanf("%d%d", &a, &b);
		sz = 0;
		rec(0, 1, 1);

		qsort(ans, sz, sizeof(T), cmp);
		if (!sz) puts("No cats.");
		else for (i = 0; i < sz; i++) printf("%lld %lld\n", ans[i].A, ans[i].B);
	}
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int red = 0, blue = 0;
    REP (i, 0, n) {
        red += s[i] == 'R';
        blue += s[i] == 'B';
    }
    cout << (red > blue ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x,t;
    
    cin >> n >> x >> t;
    cout << (t / n)*x << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
list_str = []
for count in range(0,n):
    list_str.append(raw_input())
if n != 1:
	for count in range(0,n):
	    if count == 0:
	        output = set(list_str[count])
	    else:
	        compare1 = set(output)
	    	compare2 = set(list_str[count])
	    	output = list(compare1 & compare2)

	tmp_output = ""
	
	for count1 in range(0,len(output)):
		#print output[count1]
		min = 1000
		for count2 in range(0,n):
			num = list_str[count2].count(output[count1])
			if num < min:
				min = num
			#print min
		tmp_output += min*output[count1]
	output = tmp_output
	#output.sort()
else:
	output = list_str[0]
output = sorted(output)
output = ''.join(output)
print output

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


int main() {
  priority_queue<int> pq;
  while (true){
      string com;
      cin >> com;
      if (com == "end"){
          break;
      }else if(com == "extract"){
          int ret;
          ret = pq.top();
          cout << ret << endl;
          pq.pop();
      }else{
          int cont;
          cin >> cont;
          pq.push(cont);
      }
  }
  
  
}


Measured memory_bytes: 7136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rg register
#define maxn 1200000
#define inf 0x7f7f7f7f
#define mod (ll)(1e9+7)
#pragma GCC optimize(3)
#pragma -fcrossjumping
#pragma -fdefer-pop
#pragma -fmerge-constans
#pragma -fthread-jumps
#pragma -floop-optimize
#pragma -fif-conversion
#pragma -fif-conversion2
#pragma -fdelayed-branch
#pragma -fguess-branch-probability
#pragma -fcprop-registers
#pragma -fforce-mem
#pragma -foptimize-sibling-calls
#pragma -fstrength-reduce
#pragma -fgcse
#pragma -fcse-follow-jumps
#pragma -frerun-cse-after-loop
#pragma -fdelete-null-pointer-checks
#pragma -fextensive-optimizations
#pragma -fregmove
#pragma -fschedule-insns
#pragma -fsched-interblock
#pragma -fcaller-saves
#pragma -fpeephole2
#pragma -freorder-blocks
#pragma -fstrict-aliasing
#pragma -funit-at-a-time
#pragma -falign-functions
#pragma -fcrossjumping
#pragma -finline-functions
#pragma -fweb
#define int ll
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline ll print(ll x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>=10)
    {
        print(x/10);
    }
    putchar(x%10+'0');
}
ll a,b;
inline ll gcd(ll a,ll b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
ll num[maxn],tot;
inline void fj(ll x)
{
	for(rg int i=1;i*i<=x;++i)
	{
		if(x%i==0)
		{
			num[++tot]=i;
			if(i!=x/i) num[++tot]=x/i;
		}
	}
}
int prime[maxn],cnt;
int Num[maxn];//统计素数个数 
int n;
ll ans;
inline void fj1(int x)
{
	if(x==1) prime[++cnt]=1,num[cnt]=1;
	for(rg int i=2;i*i<=x;++i)
	{
		if(x%i==0)
		{
			prime[++cnt]=i;
			Num[cnt]=1;
			x/=i;
			while(x%i==0)
			{
				x/=i;
				Num[cnt]++;
			}
		}
	}
	if(x>1)//x为质数 
	{
		prime[++cnt]=x;
		num[cnt]=1;
	}
}
signed main()
{
	a=read(),b=read();
	ll c=gcd(a,b);
//	cout<<c<<endl;
	fj(c);
	fj1(c);
	if(a==1||b==1) cout<<1;
	else cout<<cnt+1;
}

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

int main() {
	int n;
	
	set<string> st;
	for (cin >> n; n--;) {
		string s; cin >> s;
		st.insert(s);
	}
	
	cout << st.size() << "\n";
	
	return 0;
}


Measured memory_bytes: 19128
#include <iostream>

using namespace std;

int main(){
    int a, b, c;
    int m, n;
    
    cin >> a >> b >> c;
    
    if (a < b){
        
    } else {
        m = a;
        a = b;
        b = m;
    }
    
    if (c < a){
        m = a;
        n = b;
        a = c;
        b = m;
        c = n;
    } else if (c < b){
        m = b;
        b = c;
        c = m;
    } else {
        
    }

    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_9_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] a = ReadIntAr();
            int m = ReadInt();
            int[] b = ReadIntAr();
            a = a.Except(b).ToArray();
            Array.Sort(a);
            foreach (var item in a) Console.WriteLine(item);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 57872
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;


int main(void) {
	int n;
	int r[200001];
	int maxi = -INF;
	int mini;

	cin >> n;
	FOR(i, 1, n) {
		cin >> r[i];
	}
	mini = r[1];

	FOR(i, 2, n) {
		maxi = max(maxi, r[i] - mini);
		mini = min(mini, r[i]);
	}
	cout << maxi << endl;

	return 0;
}


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

int main(void) {
    int a, b, i, j;
    while(1) {
        cin >> a >> b;
        if(a == 0) {
            break;
        }

        for(i=0; i<a; i++) {
            for(j=0; j<b; j++) {
                if (i==0 || j ==0 || i==(a-1) || j ==(b-1)) {
                    printf("#");
                }else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3044
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String inputed = new String(in.readLine());
		int temp = Integer.parseInt(inputed);

		int answer = temp * temp * temp;
		System.out.println(answer);

	}
}

Measured memory_bytes: 24228
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n;
  cin>>n;
  vector<vector<int>> a(2,vector<int>(n));
  rep(i,2){
    rep(j,n){
      cin>>a[i][j]; 
    }
  }
  //////どこで下に降りる？
  int ans=0;
  
  rep(i,n){ //i番目で降りる
    int cnt=0;
    for(int j=0;j<=i;j++){
      cnt+=a[0][j]; 
      
    }
    for(int j=i;j<n;j++){
      cnt+=a[1][j];
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int k, x;
cin >> k >> x;
if (k * 500 >= x) cout << "Yes";
else cout << "No";
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

using namespace std;

void fill(char b, char c, int n){
    for(int i=0;i<100;i++) cout << b;
    cout << endl;
    for(int j=0;j<49;j++){
        for(int i=0;i<100;i++){
            if(n>0 && j%2==1 && i%2 == 0){
                n--;
                cout << c;
            } else cout << b;
        }
        cout << endl;
    }
}

int main(void){
    int A, B;
    cin >> A >> B;
    cout << 100 << " " << 100 << endl;
    fill('#', '.', A-1);
    fill('.', '#', B-1);
    return 0;
}

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

tmp = 0
ans = 0
idx = 0
for i in range(N):
    if tmp + A[i] > K:
        break
    tmp += A[i]
    ans += 1
    idx += 1

idx -= 1
max_ans = ans

for i in range(M):
    if tmp + B[i] <= K:
        ans += 1
        max_ans = max(ans, max_ans)
        tmp += B[i]
        continue
    else:
        if idx >= 0:
            tmp -= A[idx]
            ans -= 1
            idx -= 1

        tmp += B[i]
        ans += 1

        if tmp <= K:
            max_ans = max(ans, max_ans)

print(max_ans)

Measured memory_bytes: 40620
using System;

namespace P0028_ModeValue
{
    class Program
    {
        static void Main(string[] args)
        {
            var map = new int[100]; 

            while (true)
            {
                var line = Console.ReadLine();
                if (line == null) break;

                map[int.Parse(line)-1]++;
            }
            
            int max = 0;

            foreach (var m in map)
            {
                if(max < m) max = m;
            }

            for (int i = 0; i < 100; i++)
            {
                if (max == map[i]) Console.WriteLine(i+1);
            }

        }
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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

	ll  a, b ,c, d;
	cin>>a>>b>>c>>d;
	while(1){
		c = c-b;
		if(c<=0) {
			cout<<"Yes\n";
			break;
		}
		a = a-d;
		if(a<=0) {
			cout<<"No\n";
			break;
		}
	}


	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; string s, t; cin >> n >> s >> t;
    ll pos = 0;
    while(pos<s.size()){
        bool chk = true;
        for(ll i=pos, j=0; i<s.size(); i++, j++){
            if(s[i] != t[j]) chk = false;
        }
        if(chk) break;
        pos++;
    }
    cout << s.size()+pos << endl;
}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n; cin >> n;
    ll ans = 0;
    for (int a = 1; a <= n; a++) {
        int b_max = (n-1) / a;
        ans += b_max;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

vector<int> way[SIZE];
int st[SIZE];

pair<ll,bool> dfs(int now, int back=-1){
  //debug(now);
  ll sum = 0;
  vector<ll> vec;
  int cc = 0;

  if(way[now].size() == 1){
    return {st[now],true};
  }
  
  for(int i=0;i<(int)way[now].size();i++){
    pair<ll,bool> res;
    
    if(back == way[now][i]) continue;
    
    res = dfs(way[now][i],now);

    if(res.second == false){
      return {-1,false};
    }
    
    sum += res.first;
    vec.push_back(res.first);
    cc++;
  }

  if(sum < st[now]){
    return {-1,false};
  }
  
  if(cc == 1){
    if(sum == st[now]){
      //cerr << now+1 << " : " << sum << endl;
      return {sum,true};
    }else{
      return {-1,false};
    }
  }

  ll d = sum - st[now];

  //debug(sum);
  
  if(d > st[now]){
    return {-1, false};
    
  }else{
    //cerr << now+1 << " : " << st[now]-d*2 << endl;

    //check d

    ll rest = 0;
    ll q = 0;
    
    for(int i=0;i<vec.size();i++){
      //debug(vec[i]);

      ll min_rv = min(rest,vec[i]);
      vec[i] -= min_rv;

      ll min_2 = min(q, vec[i]/2);
      q += min_2;

      //debug(q);
      
      rest += vec[i] - min_rv - min_2*2;      
      q += min_rv;
    }

    //debug(q);
    
    if(q < d){
      debug("Yeah!");
      return {-1,false};
    }
    
    return {sum-d*2,true};
  }

}

int main(){
  int n;

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d",st+i);
  }

  for(int i=0;i<n-1;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--; b--;

    way[a].push_back(b);
    way[b].push_back(a);
  }

  if(n == 2){
    if(st[0] == st[1]){
      puts("YES");
    }else{
      puts("NO");
    }
    return 0;
  }

  pair<ll,bool> result = {-1,false};
  
  for(int i=0;i<n;i++){

    if(way[i].size() >= 2){
      debug(i);
      result = dfs(i);
      break;
    }
    
  }

  debug(result.first);
  
  if(result.first == 0 && result.second == true){
    puts("YES");
  }else{
    puts("NO");
  }

    return 0;
}


Measured memory_bytes: 16768
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;

int main(){
  cin>>n;
  lint A=0,B=0;
  REP(i,n){
    lint a,b;cin>>a>>b;
    lint mult=max((A+a-1)/a,(B+b-1)/b);
    chmax(mult,1ll);
    A=a*mult;
    B=b*mult;
  }
  cout<<A+B<<endl;
  return 0;
}





Measured memory_bytes: 256
from collections import defaultdict

M = 998244353
B = 10**18 % M

def mex(s):
  for i in range(max(s)+2):
    if i not in s:
      return i

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in sorted(e.keys(), reverse=True):
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
      x = pow(B, i, M)
      sum_g[m] += x
      sum_g[0] -= x
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(set)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].add(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret = (ret + sx*sy*sz)%M
  return ret

N = int(input())
edge = [read_edge() for i in range(3)]

print(solve(N, edge))

Measured memory_bytes: 115928
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>

using namespace std;

int main()
{
	queue<pair<string,int> > q;//后面的两个>要用空格隔开 
	int n,tms;
	cin>>n>>tms;
	for(int i=0;i<n;i++){
		string name;
		int t;
		cin>>name>>t;
		q.push(make_pair(name,t));
	}
	pair<string,int> u;
	int cnt=0;
	while(!q.empty()){
		u=q.front();
		q.pop();
		cnt+=min(u.second,tms);
		u.second-=tms;
		if(u.second<=0)cout<<u.first<<' '<<cnt<<endl;
		else q.push(u);
	}
	return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<int> ac(n), wa(n);
	vector<int> p(m); vector<string> res(m);
	rep(i, m){
		cin >> p.at(i) >> res.at(i);
	}
	int cntac = 0, cntwa = 0;
	rep(i, m){
		if(ac.at(p.at(i) - 1) == 0){
			if(res.at(i) == "AC"){
				ac.at(p.at(i) - 1) = 1;
			}
			else wa.at(p.at(i) - 1)++;
		}
		else continue;
	}
	rep(i,n){
		if(ac.at(i) == 1){
			cntac++;
			cntwa += wa.at(i);
		}
	}
	cout << cntac << " " << cntwa;
} 

Measured memory_bytes: 6912
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,b,ch[100000],nod[100000];
vector<ll>v1[100000];
queue<ll>que;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n+m-1;i++){
        cin>>a>>b;
        a--,b--;
        v1[a].push_back(b);
        nod[b]++;
        ch[b]=1;
    }
    for(int i=0;i<n;i++){
        if(ch[i]==0){
            que.push(i);
        }
    }
    while(que.size()){
        ll q=que.front();
        que.pop();
        for(auto x:v1[q]){
            if(nod[x]==1){
                que.push(x);
                ch[x]=q+1;
            }
            nod[x]--;
        }
    }
    for(int i=0;i<n;i++)cout<<ch[i]<<endl;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int f = 1;
    for(int i=0;i<S.size();i++){
        if(i%2 && S[i] == 'R'){
            f = 0;
        }
        if(i%2==0 && S[i] == 'L')
            f = 0;
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import os
import pprint

#fd = os.open('ALDS1_11_D-3.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

"""connected components"""

l = list(map(int, input().split()))
DEBUG = False

# node num
n = l[0]

# relation num
m = l[1]

# each node color
colors = [None] * n

rel_list = []
for _ in range(n):
    rel_list.append([])
# relation
for _ in range(m):
    l = list(map(int, input().split()))
    s = l[0]
    t = l[1]
    rel_list[s].append(t)
    rel_list[t].append(s)

if DEBUG:
    print(rel_list)

# coloring by DFS or BFS
for node_index in range(n):

    stack = []
    if colors[node_index] is None:
        stack.append(node_index)
        while stack:
            # process top of stack
            top = stack.pop()
            colors[top] = node_index

            relations = rel_list[top]
            for relation in relations:
                if colors[relation] is None:
                    stack.append(relation)

if DEBUG:
    print(colors)

# question num
q = int(input())

for _ in range(q):
    l = list(map(int, input().split()))
    s = l[0]
    t = l[1]
    if colors[s] == colors[t]:
        print('yes')
    else:
        print('no')

Measured memory_bytes: 33288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<long long, long long> P;
typedef long long ll;
typedef pair<ll, P> PP;
struct edge
{
    ll to;
    ll cost;
    ll time;
};
struct node
{
    ll rate;
    ll time;
};
ll dp[60][6000];
int main()
{
    ll n, m, s;
    cin >> n >> m >> s;
    s = min(s, 5000LL);
    vector<vector<edge>> v(n);
    rep(i, m)
    {
        int a, b, c, t;
        edge e;
        cin >> a >> b >> c >> t;
        a--;
        b--;
        e.to = a;
        e.cost = c;
        e.time = t;
        v[b].push_back(e);
        e.to = b;
        v[a].push_back(e);
    }
    vector<P> p(n);
    rep(i, n)
    {
        cin >> p[i].first >> p[i].second;
    }

    rep(i, 60)
    {
        rep(j, 6000)
        {
            dp[i][j] = 1e18;
        }
    }
    priority_queue<PP, vector<PP>, greater<PP>> que;
    dp[0][s] = 0;
    que.push(PP(0, P(0, s)));
    while (!que.empty())
    {
        PP pp = que.top();
        que.pop();
        ll d = pp.first;
        ll node = pp.second.first;
        ll nokori = pp.second.second;
        for (auto e : v[node])
        {
            if (dp[node][min(nokori + p[node].first, 5000LL)] > d + p[node].second)
            {
                dp[node][min(nokori + p[node].first, 5000LL)] = d + p[node].second;
                que.push(PP(d + p[node].second, P(node, min(nokori + p[node].first, 5000LL))));
            }

            if (e.cost > nokori)
            {
                continue;
            }
            if (dp[e.to][nokori - e.cost] > e.time + d)
            {
                que.push(PP(e.time + d, P(e.to, nokori - e.cost)));
                dp[e.to][nokori - e.cost] = e.time + d;
            }
        }
    }
    for (int i = 1; i < n; i++)
    {
        ll mn = 1e18;
        for (int j = 0; j < 6000; j++)
        {
            mn = min(mn, dp[i][j]);
        }
        cout << mn << endl;
    }
}

Measured memory_bytes: 12240
import java.util.Scanner;

public class Main  {

	public static  void main(String[] args) {
		int A , B , C , K;
	int T = 0 ;
	Scanner sc = new Scanner(System.in);
	A = Integer.parseInt(sc.next());
	B = Integer.parseInt(sc.next());
	C = Integer.parseInt(sc.next());
	K = Integer.parseInt(sc.next());
	while(K != 0 && A != 0) {
		T++;
		A--;
		K--;
	}while(K != 0 && B != 0) {
		B--;
		K--;
	}while(K != 0 && C != 0) {
		T--;
		C--;
		K--;
	}
	System.out.println(T);
	}

}


Measured memory_bytes: 27184
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char c[100],hc[100];
  int n,count=0;
  while(cin>>c){
    n = 0;
    for(int i=strlen(c)-1;i>=0;i--){
      hc[n] = c[i];
      n++;
    }
    for(int i=0;i<strlen(c);i++){
      if(hc[i]!=c[i]) break;
      else if(i==strlen(c)-1) count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {

    long N;

    cin >> N ;

    long L = sqrt(N) + 1;
    //int L = N / 2; 

    // N = A * B
    // A = N / B
    // B = N / A

    //int A;
    //int B;

    // int a_s = to_string(A).size();
    // int b_s = to_string(B).size();
    // min(a_s, b_s)

    long ans = 100000000000;

    for (long i = 1; i < L ; i++) {

        if (N % i != 0){
            continue;
        }

        long A = i;
        long B = N / i;

        long a_s = to_string(A).size();
        long b_s = to_string(B).size();
        long temp_max = max(a_s, b_s);

        if (ans > temp_max){

            ans = temp_max;
        }
       
    }

    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 3680
n, m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
c = [list(map(int, input().split())) for i in range(m)]

d = 10**17
for i in range(n):
    for j in range(m):
        r = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
        if r < d:
            d = r
            ans = j+1
    print(ans)
    d = 10**17

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(){
  int A,B,ans=1;
  scanf("%d%d",&A,&B);
  if(B==1){
    printf("0\n");
    return 0;
  }
  int sum =A;
  while(sum<B){
    ans++;
    sum+=(A-1);
  }

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

Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int r,g,b = 0;
  int x = 0;
  scanf("%d""%d""%d",&r,&g,&b);
  x = (100*r)+(10*g)+b;
  if(x % 4 == 0) {
    printf("YES\n");
  }else {
    printf("NO\n");
  }
} 

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }
    var cur = 1
    var diff = 0
    var ans = 1
    while (cur < n) {
        if (t[cur] == t[cur - 1]) {
            cur++
            continue
        }
        if (t[cur] > t[cur - 1]) {
            if (diff >= 0) {
                diff = 1
            } else {
                ans++
                diff = 0
            }
        } else {
            if (diff <= 0) {
                diff = -1
            } else {
                ans++
                diff = 0
            }
        }
        cur++
    }
    println(ans)
}

Measured memory_bytes: 58196
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int N;
vector<int> W, wforward, wback;

void solve() {
	cin >> N;
	W.resize(N);
	wforward.resize(N);
	wback.resize(N);
	for (int n = 0; n < N; n++)cin >> W[n];
	wforward[0] = W[0];
	for (int n = 1; n < N; n++)wforward[n] = wforward[n - 1] + W[n];
	wback[N - 1] = W[N - 1];
	for (int n = N - 2; n >= 0; n--)wback[n] = wback[n + 1] + W[n];
	int ans = 100*100+1;
	for (int n = 0; n < N - 1; n++) {
		ans = min(ans, abs(wforward[n]-wback[n+1]));
	}
	cout << ans << endl;
	return;
}

Measured memory_bytes: 256
N,M,K=list(map(int,input().split()))
root=[i for i in range(N)]
height=[1 for i in range(N)]
l=[set() for i in range(N)]
mem=[0]*N
def find(n):
   f=n
   while n != root[n]:
      n=root[n]
   root[f]=n
   return n
def union(a,b):
   A=find(a)
   B=find(b)
   if A==B:
      return
   elif height[A]<height[B]:
      height[B]+=height[A]
      height[A]=0
      root[A]=B
   else:
      root[B]=A
      height[A]+=height[B]
      height[B]=0
def same(a,b):
   A=find(a)
   B=find(b)
   if A==B:
      l[a].add(b)
      l[b].add(a)
for i in range(M):
   a,b=list(map(int,input().split()))
   a-=1;b-=1
   l[a].add(b)
   l[b].add(a)
   union(a,b)
for j in range(K):
   a,b=list(map(int,input().split()))
   a-=1;b-=1
   same(a,b)
for i in range(N):
   print(height[find(i)]-len(l[i])-1,end=" ")


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int k; cin >> k;
    queue<lint> q;
    repn(i, 9){
        q.push(i);
    }
    while(!q.empty()){
        lint n = q.front(); q.pop();
        if(k == 1){
            out(n); return 0;
        }
        if(n%10 != 0) q.push(n*10+n%10-1);
        q.push(n*10+n%10);
        if(n%10 != 9) q.push(n*10+n%10+1);
        k--;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, q;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];

	cin >> q;
	vector<int> m(q);
	for (int i = 0; i < q; i++) cin >> m[i];

	vector<bool> ok(q, false);

	for (int bit = 0; bit < (1 << n); bit++) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) sum += A[i];
		}
		for (int i = 0; i < q; i++) {
			if (sum == m[i]) ok[i] = true;
		}
	}

	for (int i = 0; i < q; i++) {
		if (ok[i]) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

    vector<vector<char> > s(100,vector<char>(100));

    rep(i,50){
        rep(j,100){
            s[i][j] = '.';
            s[99-i][j] = '#';
        }
    }
    int cnt = 0;
    int tate = 0;
    rep(i,b - 1){
        if(cnt >= 50){
            cnt=0;
            tate += 2;
        }
        s[tate][(2*i)%100] = '#';
        cnt++;
    }
    tate = 51;
    cnt = 0;
    rep(i,a-1){
            if(cnt >= 50){
                cnt=0;
                tate += 2;
            }
            s[tate][(2*i)%100] = '.';
        cnt++;
    }
    cout << 100 << " " << 100 << endl;
    rep(i,100){
        rep(j,100){
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import collections
import math
N = int(input())
A = list(map(int, input().split(' ')))
c = collections.Counter(A)
d1 = {}
d2 = {}
for i in c:
    d1[str(i)] = (c[i]*(c[i]-1))/2
    d2[str(i)] = ((c[i]-1)*(c[i]-2))/2

s = sum(d1.values())

for i in range(N):
    ans = s - d1[str(A[i])]+d2[str(A[i])]
    print(int(ans))


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

#define INF 1<<29

template <typename T>
struct MaxFlow {
  struct Edge {
    int to, rev; T cap;
    Edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap) { }
  };

  typedef vector<Edge> Edges;
  vector<Edges> G;
  int V;
  vector<int> level, iter;

  MaxFlow(int V) : V(V) { G.resize(V); }

  void add_edge(int from, int to, T cap) {
    G[from].emplace_back(to, G[to].size(), cap);
    G[to].emplace_back(from, (int)G[from].size()-1, 0);
  }

  void bfs(int source) {
    level.assign(V, -1);
    queue<int> que;
    que.emplace(source);
    level[source] = 0;
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (int i = 0; i < (int)G[v].size(); i++) {
	Edge &e = G[v][i];
	if (e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.emplace(e.to);
	}
      }
    }
  }

  T dfs(int v, int sink, T flow) {
    if (v == sink) return flow;
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
      Edge &e = G[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
	T d = dfs(e.to, sink, min(e.cap, flow));
	if (d > 0) {
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }

  T dinic(int source, int sink) {
    T flow = 0;
    while (true) {
      bfs(source);
      if (level[sink] < 0) return flow;
      iter.assign(V, 0);
      T f;
      while ((f = dfs(source, sink, INF)) > 0) flow += f;
    }
  }
};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int V, E; cin >> V >> E;
  MaxFlow<int> mf(V);
  REP(i, E) {
    int u, v, c; cin >> u >> v >> c;
    mf.add_edge(u, v, c);
  }
  cout << mf.dinic(0, V-1) << endl;
  return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
int main()
{
	int x[10000],i,j=0;
	for (i = 0; i < 10000; i++)
	{
		scanf("%d", &x[i]);
		if (x[i] == 0)
		{
			break;
		}
		j++;
	}
	for (i = 0; i < j; i++)
	{
		printf("Case %d: %d\n", i+1, x[i]);
	}
	return 0;
}

Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  vector<vector<int>> dp(n+1,vector<int>(2));
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      dp[i+1][0]=dp[i][0]*2;
      dp[i+1][1]=dp[i][1]*3+dp[i][0];
    }
    else{
      dp[i+1][0]=dp[i][0];
      dp[i+1][1]=dp[i][1]*3+dp[i][0]*2;
    }
  }
  cout << dp[n][1] << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static char s, t, b;
	static int[] dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
	
	public static void main(String[] args) {
		while (read()) {
			solve();
		}
	}

	static boolean read() {
		n = sc.nextInt();
		if (n == 0) return false;
		
		s = sc.next().charAt(0);
		t = sc.next().charAt(0);
		b = sc.next().charAt(0);
		
		return true;
	}

	static void solve() {
		double[][][] dp = new double[n + 1][5][5];
		for (int i = 0; i <= n; i++) { 
			for (int j = 0; j < 5; j++) {
				for (int k = 0; k < 5; k++) {
					dp[i][j][k] = 0.0;
				}
			}
		}
	
		int pos_s = s - 'A', pos_t = t - 'A', pos_b = b - 'A';
		int sx = pos_s % 3 + 1, sy = pos_s / 3 + 1;
		int gx = pos_t % 3 + 1, gy = pos_t / 3 + 1;
		int bx = pos_b % 3 + 1, by = pos_b / 3 + 1;
		
		dp[n][sy][sx] = 1.0;
		
		for (int i = n; i > 0; i--) {
			for (int y = 1; y <= 3; y++) {
				for (int x = 1; x <= 3; x++) {
					for (int l = 0; l < 4; l++) {
						int ty = y + dy[l], tx = x + dx[l];
						if (((ty == by) && (tx == bx)) || (tx == 0 || tx == 4 || ty == 0 || ty == 4)){
							ty = y; tx = x;
						}
						dp[i - 1][ty][tx] += dp[i][y][x] * 0.25; 
					}
				}
			}
		}
		
		System.out.printf("%.8f", dp[0][gy][gx]);
		System.out.println();
	}
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int K, A, B;

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

    int k = 0;
    bool flag = false;
    while (k < B) {
        k += K;
        if (A <= k && k <= B) {
            flag = true;
            break;
        }
    }

    if (flag) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
n, x, m = map(int, input().split())

a = []
check = [-1] * m
i = 0
while check[x] == -1:
  a.append(x)
  check[x] = i
  x = x * x % m
  i += 1
if n <= i:
  print(sum(a[:n]))
else:
  print(
    sum(a[:check[x]])
    + (n - check[x]) // (i - check[x]) * sum(a[check[x]:])
    + sum(a[check[x] : check[x] + (n - check[x]) % (i - check[x])]))

Measured memory_bytes: 13336