akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int D;
    cin >> D;
    vector<int> c(26);
    REP(i,26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    REP(i, D)REP(j, 26) cin >> s[i][j];
    REP(i, D){
        // pr(max_element(ALL(s[i]))-s[i].begin()+1);
        pr(1);
    }
}

Measured memory_bytes: 3680
#include<iostream>
using namespace std;
char ch[10] = {'a','a','a','a','a','a','a','a','a','a'};
int main(){
  int n;
  cin>>n;
  while(ch[0]=='a'){
    for(int i=n-1;i>0;i--){
      if(ch[i]-'a'<= i) break;
      ch[i-1]++;
      ch[i]='a';
    }
    if(ch[0]!='a') break;
    char s='a';
    bool f=false;
    for(int i=0;i<n;i++){
      if(ch[i]==s+1) s=ch[i];
      if(ch[i]>s+1) {f=true;break;} 
    }
    if(!f){
    for(int i=0;i<n;i++) cout<<ch[i];
    cout<<endl;
    }
    ch[n-1]++;
  }
}


Measured memory_bytes: 1536
import sys

def II(): return str(input())
def MI(): return map(int,input().split())
def MI2(): return map(str,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    S, T = MI2()
    A, B = MI()
    U = II()
    
    if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
    print(A, B)

if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double D1, D2, D3, Dx;
		double sum1 = 0, sum2 = 0, sum3 = 0, max = 0;
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			y[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			sum1 += Math.abs(x[i] - y[i]);
			sum2 += Math.pow(Math.abs(x[i] - y[i]), 2);
			sum3 += Math.pow(Math.abs(x[i] - y[i]), 3);
			max = Math.max(max, Math.abs(x[i] - y[i]));
		}
		D1 = sum1;
		D2 = Math.sqrt(sum2);
		D3 = Math.cbrt(sum3);
		Dx = max;
		System.out.printf("%f%n", D1);
		System.out.printf("%f%n", D2);
		System.out.printf("%f%n", D3);
		System.out.printf("%f%n", Dx);
		sc.close();
	}
}


Measured memory_bytes: 26556
#include<iostream>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int* a=new int[n];
  int s=0;
  for(int i=0;i<n;i++){ cin>>a[i]; s+=a[i]; }
  int c=0;
  double b=s/(double)(4*m);
  for(int i=0;i<n;i++){
    if(a[i]>=b)c++;
  }
  if(c>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
const int N = 2e5 + 5;
const int inf = 0x3f3f3f3f;
queue<int> Q;
int n, s, t, head[N], tot = 1, dis[N], id[2][N], p[N], q[N], idcnt, cur[N];
struct node{int to, nex, val;}a[1000005];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void add(int x, int y, int z)
{
	a[++ tot].to = y; a[tot].nex = head[x]; a[tot].val = z; head[x] = tot;
	a[++ tot].to = x; a[tot].nex = head[y]; a[tot].val = 0; head[y] = tot;
}
int bfs()
{
	while(!Q.empty()) Q.pop();
	for(int i = 1; i <= t; i ++) dis[i] = 0;
	dis[s] = 1; Q.push(s);
	while(!Q.empty())
	{
		int x = Q.front(); Q.pop();
		for(int i = head[x]; i; i = a[i].nex)
		{
			int y = a[i].to;
			if(!dis[y] && a[i].val)
			{
				dis[y] = dis[x] + 1;
				if(y == t) return 1;
				Q.push(y);
			}
		}
	}
	return 0;
}
int dfs(int x, int want)
{
	if(x == t || !want) return want;
	int f, get = 0;
	for(int &i = cur[x]; i && want; i = a[i].nex)
	{
		int y = a[i].to;
		if(dis[y] == dis[x] + 1 && a[i].val)
		{
			f = dfs(y, min(want, a[i].val));
			if(!f) {dis[y] = 0; continue;}
			a[i].val -= f; a[i ^ 1].val += f;
			want -= f; get += f;
		}
	}
	return get;
}
int dinic()
{
	int mxflow = 0, flow;
	while(bfs())
	{
		for(int i = 1; i <= t; i ++) cur[i] = head[i];
		while(flow = dfs(s, inf)) mxflow += flow;
	}
	return mxflow;
}
void work(int x, int *nx, int *id) {if(id[x]) return; id[x] = idcnt; work(nx[x], nx, id);}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; i ++) p[i] = read() + 1;
	for(int i = 1; i <= n; i ++) q[i] = read() + 1;
	int res = n;
	for(int i = 1; i <= n; i ++) if(!id[0][i]) idcnt ++, work(i, p, id[0]);
	for(int i = 1; i <= n; i ++) if(!id[1][i]) idcnt ++, work(i, q, id[1]);
	s = ++ idcnt; t = ++ idcnt;
	for(int i = 1; i <= n; i ++)
	{
		if(p[i] == i && q[i] == i) res --;
		else if(p[i] == i) add(id[1][i], t, 1);
		else if(q[i] == i) add(s, id[0][i], 1);
		else if(p[i] != q[i]) add(id[1][i], id[0][i], 1);
		else add(id[1][i], id[0][i], 1), add(id[0][i], id[1][i], 1);
	}
	printf("%d\n", res - dinic());
	fclose(stdin);
	fclose(stdout);
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int main(void){
    int n;
    bool flg = false;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    FOR(i, 1, 9 + 1) {
        FOR(j, 1, 9 + 1) {
            if (i * j == n) {
                flg = true;
            }
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    int n,m,a,b;
    cin>>n>>m;
    vector<vector<int>>jop(1e5+9);
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a>m)
            continue;
        jop[m-a].push_back(b);
    }
    priority_queue<int>pq;
    int ans=0;
    for(int i=m-1;i>=0;i--)
    {
        for(int j=0;j<jop[i].size();j++)
            pq.push(jop[i][j]);
        if(!pq.empty())
        {
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using namespace std;
namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}

int main(){
  int n;cin>>n;
  vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
  set<int> s;
  for(int i=0;i<n;i++)s.insert(a[i]);
  ndifix::sort(a);

  if(s.size()==1){
    if(a[0]==0){cout<<"Yes"<<endl;return 0;}
    if(a[0]!=0){cout<<"No"<<endl;return 0;}
  }
  if(s.size()==2){
    if(n%3!=0){cout<<"No"<<endl;return 0;}
    if(a[0]!=0){cout<<"No"<<endl;return 0;}
    if(a[0]!=a[n/3-1]){cout<<"No"<<endl;return 0;}
    a.erase(a.begin(),a.begin()+n/3);
    if(a[0]!=a.back()){cout<<"No"<<endl;return 0;}
    {cout<<"Yes"<<endl;return 0;}
  }
  if(s.size()==3){
    if(n%3!=0){cout<<"No"<<endl;return 0;}
    int p,q,r;
    p=a[0];
    if(a[0]!=a[n/3-1]){cout<<"No"<<endl;return 0;}a.erase(a.begin(),a.begin()+n/3);
    q=a[0];
    if(a[0]!=a[n/3-1]){cout<<"No"<<endl;return 0;}a.erase(a.begin(),a.begin()+n/3);
    r=a[0];
    if(a[0]!=a[n/3-1]){cout<<"No"<<endl;return 0;}a.erase(a.begin(),a.begin()+n/3);
    if((p^q)==r){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
}


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

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

  cout << max(A * B, C * D) << endl;
  return 0;
}

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

int main(){
    int h,w;cin>>h>>w;
    vector<vector<string>> df;
    for (int i=0;i<h;i++){
        vector<string> row;
        for (int j=0;j<w;j++){
            string value;
            cin >> value;
            row.push_back(value);
        }
        df.push_back(row);
    }
    string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            if (df[i][j] == "snuke"){
                cout << alphabet[j] << i+1 << endl;
                return 0;
            }
        }
    }



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int i;
  int a[3]={1,2,3};
  for(i=0;i<3;i++){
    if(a[i]!=A&&a[i]!=B){
      cout<<a[i];}}
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

H, W = Is()
h, w = Is()
print(H*W-h*W-H*w+h*w)


Measured memory_bytes: 63852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

const int mod = 998244353;
struct ModInt {
    lint x;
    ModInt (lint a) : x((a % mod + mod) % mod) {}
    ModInt operator - () const {
        return ModInt(-x);
    }
    ModInt &operator += (const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator -= (const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator *= (const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator + (const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator - (const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator * (const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(lint t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t % 2) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator /= (const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator / (const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator << (ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

vector<ModInt> fact;
ModInt combination(int n, int k) {
    if (k < 0 || n < k) return ModInt{0};
    else return fact[n] / fact[k] / fact[n - k];
}

int main() {
    int N;
    lint A, B, K;
    cin >> N >> A >> B >> K;
    ModInt now(1);
    fact.push_back(now);
    rep(i, N) {
        ModInt M(i + 1);
        now *= M;
        fact.push_back(now);
    }
    ModInt ans(0);
    rep(i, N + 1) {
        if (K - A * i >= 0 && (K - A * i) % B == 0 && (K - A * i) / B <= N) {
            ans += combination(N, i) * combination(N, (K - A * i) / B);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6512
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include <iomanip>

using namespace std;

const int MAX = 3001;
double dp[MAX][MAX];
int N;
double p[MAX];

int main() {
   cin >> N;
   for (int i = 0; i < N; i++) {
      cin >> p[i];
   }

   dp[0][0] = 1.;
   for (int i = 1; i <= N; i++) {
      for (int j = 0; j < i; j++) {
         dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
         dp[i][j + 1] += dp[i - 1][j] * p[i - 1];
      }
   }

   double ans = 0.;
   for (int i = N / 2 + 1; i <= N; i++) ans += dp[N][i];
   cout << fixed << setprecision(10) << ans << endl;
   return 0;
}


Measured memory_bytes: 68992
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define X real()
#define y imag()

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	int m;
	cin >> m;

	ll acum = 0;
	vector<ll> v(n);
	for (int i = 0; i < n; ++i) {
		ll aux;
		cin >> aux;
		acum += aux;
		v[i] = acum;
	}

	for (int i = 0; i < n; ++i) {
		v[i] %= m;
	}

	ll res = 0;

	unordered_map<int, int> sol;

	for (int i = 0; i < n; ++i) {
		if (v[i] == 0) ++res;

		if (sol.find(v[i]) == sol.end()) sol.insert(make_pair(v[i], 0));

		res += sol[v[i]];
		++sol[v[i]];
	}

	cout << res << '\n';
	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 4492
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, ans = 1000000007;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for (int i = 1; i < 101; i++){
        int sum = 0;
        for (int j = 0; j < N; j++){
            sum += (A.at(j) - i) * (A.at(j) - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;
template< typename T > void modAdd(T& a, T b, T mod) { a = (a+b)%mod; }

int N, M;
lint dp[302][302][302];
const lint MOD = (lint)1e9 + 7;

int main() {
	cin >> N >> M;
	memset(dp, 0, sizeof(dp));
	dp[0][1][0] = 1;
	for_(i,0,M) for_(c,0,N+1) for_(s,0,N) {
		if (c+s <= N) {
			modAdd(dp[i+1][c+s][0], dp[i][c][s] * lint(c), MOD);
			modAdd(dp[i+1][c][s], dp[i][c][s] * lint(s), MOD);
		}
		if (c+s+1 <= N) modAdd(dp[i+1][c][s+1], dp[i][c][s] * lint(N-c-s), MOD);
	}
	cout << dp[M][N][0] << endl;
}

Measured memory_bytes: 215424
#include <iostream>
#include <set>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;

char a[10];
char b[4] = {'Y','A','K','I'};

int main()
{

    cin>>a;
    int len = strlen(a);
    int ti = 0;

    for(int i = 0;i<4;i++)
    {
        if(a[i]==b[ti]) ti++;
        else break;
    }
    if(ti==4) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>

using namespace std;

int main(void){
	char s[100000];
	stack<int> box;
	cin >> s;
	int banhei=0;
	int i=0,res=0;
	while(s[i] != '\0'){
		if(banhei >= 1 && box.top() != s[i]-'0'){
			box.pop();
			res += 2;
			banhei--;
		}else{
			if(s[i] == '1'){
				box.push(1);
			}else{
				box.push(0);
			}
			banhei++;
		}
		i++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 768
N = int(input())
T = []
ans = 0
for i in range(N):
    a = int(input())
    T.append([list(map(int, input().split())) for _ in range(a)])

for bit in range(1 << N):
    target = bin(bit)[2:].zfill(N)
    nk = 0
    for i in range(N):
        if target[i] == '1':
            if any(target[x-1] != str(y) for x, y in T[i]):
                break
            else:
                nk += 1
    else:
        ans = max(ans, nk)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

ll N;

int main() {
    cin >> N;
    vector<ll> A(N), S(N);
    ll sum = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
        S[i] = sum;
    }
    ll ans = LLINF;
    ll i = 0, k = 2;
    ll p, q, r, s;
    FOR(j, 1, N-3) {
        ll left = S[j];
        ll right = S[N-1] - S[j];
        while(true) {
            if(2 * S[i] > left) {
                if(i > 0 && abs(left - 2 * S[i-1]) < abs(left - 2 * S[i]))  i--;
                break;
            }
            i++;
        }
        while(true) {
            if(2 * (S[k] - S[j]) > right) {
                if(abs(right - 2 * (S[k-1] - S[j])) < abs(right - 2 * (S[k] - S[j]))) k--;
                break;
            }
            k++;
        }
        p = S[i];
        q = S[j] - S[i];
        r = S[k] - S[j];
        s = S[N-1] - S[k];
        auto ma = max({p, q, r, s});
        auto mi = min({p, q, r, s});
        // cerr << i << " " << j << " " << k << endl;
        ans = min(ans, ma - mi);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3456
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var dict = new Dictionary<string, int>();

        var n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine();
            if (dict.ContainsKey(s))
            {
                dict[s]++;
            }
            else
            {
                dict[s] = 1;
            }
        }

        var m = int.Parse(Console.ReadLine());
        for (int i = 0; i < m; i++)
        {
            var s = Console.ReadLine();
            if (dict.ContainsKey(s))
            {
                dict[s]--;
            }
        }

        var max = 0;
        foreach (var item in dict)
        {
            max = Math.Max(max, item.Value);
        }

        Console.WriteLine(max);
    }
}


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

vector<int> g[100005];
int in[100005];
int n;
int ans[100005];


void dfs(int v, int prev) {
  vector<int> tmp;
  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i];
    if(u == prev) continue;
    dfs(u,v);
    tmp.push_back(ans[u]);
  }
  sort(tmp.begin(),tmp.end(),greater<int> ());
  for(int i = 0; i < tmp.size(); i++) {
    ans[v] = max(ans[v],tmp[i] + i + 1);
  }
 
  return;
}
  
int main() {
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    g[a].push_back(i);
    in[a]++;
  }

  dfs(0,-1);
  

 

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

  

  

  
  


Measured memory_bytes: 17408
#include <stdio.h>
int main(){
	/*???????¨????*/
	int a,b;
	char op;
	int answer[100];
	int i,t;
	
	/*??\???*/
	for(i=0;i<100;i++){
		do{
			printf("");
			scanf("%d %c %d",&a,&op,&b);
		}while(!(a>=0 && a<=20000 && b>=0 && b<=20000) || (b==0 && op=='/'));
		if(op=='+'){
			answer[i]=a+b;
		}else if(op=='-'){
			answer[i]=a-b;
		}else if(op=='*'){
			answer[i]=a*b;
		}else if(op=='/'){
			answer[i]=a/b;
		}else if(op=='?')break;
	}
	
	/*??????*/
	for(t=0;t<i;t++){
		printf("%d\n",answer[t]);
	}
	return 0;
}

Measured memory_bytes: 600
x, k, d = map(int, input().split())

dx = abs(x)
y = dx // d

if k >= y:
    dx = dx - y * d
    if (k-y) % 2 == 0:
        print(dx)
    else:
        dx = abs(dx - d)
        print(dx)
elif k < y:
    dx = dx - k * d
    print(dx)


Measured memory_bytes: 9104
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF=1e9+7;
const int maxn=5e5+5;

int n,cnt=0;
int f[maxn],g[maxn];
char s[maxn];

void kmp(int *fail){
	fail[0]=-1;
	for(int i=1,j=-1;i<n;++i){
		for(;j>=0&&s[j+1]!=s[i];j=fail[j]);
		if(s[j+1]==s[i]) fail[i]=++j;
		else fail[i]=j;
	}
	return;
}

bool check(int x,int *fail){return ((x+1)%(x-fail[x])||(x+1==x-fail[x]));}

int main(){
	scanf("%s",s);
	n=strlen(s);
	kmp(f);
	int len=n-1-f[n-1];
	if(len==n||n%len){
		puts("1\n1");
		return 0;
	}
	if(len==1){
		printf("%d\n1\n",n);
		return 0;
	}
	reverse(s,s+n);
	kmp(g);
	FOR(i,0,n) if(check(i,f)&&check(n-i-2,g)) ++cnt;
	printf("2\n%d\n",cnt);
	return 0;
}

Measured memory_bytes: 4608
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    C = input()
    print(chr(ord(C) + 1))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9928
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int W,H,x,y;

    private void solve() {
        W = nextInt();
        H = nextInt();
        x = nextInt();
        y = nextInt();

        int flag = 0;
        if (x * 2 == W && y * 2 == H) {
            flag = 1;
        }

        double S = (double)W * H / 2.0;

        out.println(String.format("%.09f %d", S, flag));
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 23252
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX_N = 10000;
static const int INF = 1 << 30;
 
int N;
int a[MAX_N - 1];
int memo[2][MAX_N / 2 + 1], memo2[2][MAX_N / 2 + 1];
 
int main(){
	scanf("%d", &N);
	for(int i = 0; i < N - 1; i++) scanf("%d", &a[i]);
	fill(memo[0], memo[2], INF);
	fill(memo2[0], memo2[2], INF);
	memo[0][1] = 0;
	memo[1][0] = 0;
	for(int i = 0; i < N - 1; i++){
		for(int j = 0; j <= N / 2; j++){
			if(j == 0){
				memo2[1][j] = 0;
			}else{
				memo2[0][j] = min(memo[0][j - 1], memo[1][j - 1] + a[i]);
				memo2[1][j] = min(memo[0][j] + a[i], memo[1][j]);
			}
		}
		for(int j = 0; j < 2; j++){
			for(int k = 0; k <= N / 2; k++){
				memo[j][k] = memo2[j][k];
			}
		}
	}
	printf("%d\n", min(memo[0][N / 2], memo[1][N / 2]));
	return 0;
}


Measured memory_bytes: 2840
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

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

string s[12];
bool used[12][12];

void dfs(int y, int x) {
    used[y][x] = true;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (0 <= nx && nx < 12 && 0 <= ny && ny < 12 && s[ny][nx] == '1' && used[ny][nx] == false) {
            dfs(ny, nx);
        }
    }
}

int main(void) {
    while (1) {
        bool flag = false;
        for (int i = 0; i < 12; i++) {
            if (!(cin >> s[i])) flag = true;
        }
        if (flag) break;
        for (int i = 0; i < 12; i++)
            for (int j = 0; j < 12; j++) 
                used[i][j] = false;
        int ans = 0;
        for (int i = 0; i < 12; i++) {
            for (int j = 0; j < 12; j++) {
                if (s[i][j] == '1' && !used[i][j]) {
                    ans++;
                    dfs(i, j);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
	int h,w;cin>>h>>w;
	vector<vector<char>> v(h,vector<char>(w));
	vector<int> c(26,0);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>v[i][j];
			c[v[i][j]-'a']++;
		}
	}
	int f=0;
	int s=0;
	int d=0;
	for(int i=0;i<26;i++){
		f+=c[i]/4;
		c[i]%=4;
	}
	for(int i=0;i<26;i++){
		d+=c[i]/2;
		c[i]%=2;
	}
	for(int i=0;i<26;i++){
		s+=c[i];
	}
	if(h%2+w%2==2){
		int d2=h/2+w/2;
		if((s==1)*(d<=d2)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else if(h%2+w%2==1){
		int d2;
		if(h%2==1){
			d2=w/2;
		}else{
			d2=h/2;
		}
		if((s==0)*(d<=d2)){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(d+s>0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}


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


def fast():
    candidate = list()
    
    while len(b) != 0:
        for i in range(len(b))[::-1]:
            if b[i] == (i+1):
                value = b.pop(i)
                candidate.append(value)
                break
            
        else:
            return [-1]

    candidate.reverse()
    return candidate

ans_list = fast()
for ans in ans_list:
    print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int N;
  int i;
  int s;
  scanf("%d",&N);
  int a=N;
  for(i=0;i<8;i++){
    int b;
    b=a%10;
    s=s+b;
    a=a/10;
  }
  if(N%s==0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = ll(1e9 + 7);



int main() {
	string S;
	cin >> S;
	map<char,int> mp;

	for (const auto& c : S) {
		++mp[c];
	}

	if (mp.size() != 2) {
		cout << "No" << endl;
	}
	else if (mp[S[0]] != 2) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
  
struct Stack{
  int data[100000];
  int idx;
  Stack():idx(0){}
  void push(int val){ data[idx++]=val;}
  int pop(){ return data[--idx];}
};

int main(){
  Stack s;
  int val;
  while(std::cin>>val){
    if(val==0)
      std::cout<<s.pop()<<std::endl;
    else
      s.push(val);
  }
  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int v[55];
double ans;
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v, v + n);
    ans = v[0];
    for(int i = 1; i < n; i++){
        ans = (ans + v[i]) / 2.0;
    }
    printf("%.7f", ans);
    return 0;
}



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

int main()
{
  int N, T, H, L;
  while (cin >> N >> T >> H >> L) {
    vector<int> t(N), h(N);
    for (int i = 0; i < N; ++i)
      cin >> t[i] >> h[i];

    int sum = 0;
    bool gameover = false;
    while (!gameover) {
      for (int i = 0; i < N; ++i) {
        if (t[i] > 0) {
          sum += 10;
          --t[i];
          ++T;
        } else if (h[i] > 0) {
          sum += 100;
          --h[i];
          ++H;
        } else {
          gameover = true;
        }

        if (T > L) {
          gameover = true;
        } else if (sum >= 90) {
          sum -= 90;
          if (sum / 10 > T) {
            gameover = true;
          } else {
            t[i] += sum / 10;
            T -= sum / 10;
            sum = 0;
          }
        }

        if (gameover) {
          cout << i+1 << endl;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int selectionSort(int A[], int N)
{
	int i, j, minj, t, sw = 0;
	for (i = 0; i < N - 1; i++)
	{
		minj = i;
		for (j = i + 1; j <= N - 1; j++)
		{
			if (A[minj] > A[j])
				minj = j;
		}
		t = A[minj];
		A[minj] = A[i];
		A[i] = t;
		if (i != minj)
			sw += 1;
	}
	return sw;
}

int main()
{
	int sw, N,i;
	int A[100];

	scanf("%d",&N);

	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);

	sw=selectionSort(A,N);

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

	return 0;
}


Measured memory_bytes: 2764
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define begin begin()
#define end end()

void _main(){
    string s; cin >> s;
    //int n ; cin >> n;
    int n = (s.size()-1)/2;
    string left,right;
    left  = s.substr(0,n);
    right = s.substr(n+1,n);
    auto kaibun = [](string s){
        int n = s.size()/2;
        rep(i,n){
            if(s[i] != s[s.size()-1-i]) return false;
        }
        return true;
    };
    if(kaibun(s) && kaibun(left) && left == right){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return;
}
int main() {
    _main();
    return 0;
}
    

Measured memory_bytes: 3036
N = gets.to_i
a = gets.split.map(&:to_i)

h = Hash.new(0)

a.each do |d|
  h[d-1] += 1
  h[d] += 1
  h[d+1] += 1
end

p h.sort_by{ |_, v| v }.reverse[0][1]

Measured memory_bytes: 21248
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(a) printf(a ? "Yes\n" : "No\n");
#define printYN(a) printf(a ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
//#include <vector>

using namespace std;

int main() {

	char w[100];
	int count['z' - 'a'] = {};
	bool isgood = true;
	scanf("%s", w);
	rep(i, strlen(w)) ++count[w[i] - 'a'];
	rep(i, 'z' - 'a') {
		if (count[i] % 2 == 1)isgood = false;
	}
	printyn(isgood);

	return 0;
}

Measured memory_bytes: 128
def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    temp1 = x // d
    temp2 = x // d + 1
    if abs(x - d * temp1) < abs(x - d * temp2):
        temp = temp1
    else:
        temp = temp2

    if k <= temp:
        print(abs(x - d * k))
        return

    left = k - temp
    if left % 2 == 0:
        print(abs(x - d * temp))
        return
    else:
        answer = min(abs(x -d * temp + d),abs(x - d * temp - d ))
        print(answer)
        return


if __name__ == '__main__':
    main()


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

const int maxn = 13;
int N, M, a[1005], mask[1005];
ll dp[1<<maxn][1005];
const ll INF = 1e15;

ll f(int msk, int i) {
    if (dp[msk][i] != -1) return dp[msk][i];
    if (i == M) {
        //cout << msk << ": " << ((msk+1) == (1<<N)) << '\n';
        dp[msk][i] = ((msk+1) == (1<<N)) ? 0 : INF;
        //printf("[%d][%d]: %lld\n",msk,i,dp[msk][i]);
        return dp[msk][i];
    }
    dp[msk][i] = INF;
    dp[msk][i] = min(dp[msk][i],f(msk,i+1));
    dp[msk][i] = min(dp[msk][i],f(msk|mask[i],i+1)+a[i]);
    //printf("[%d][%d]: %lld\n",msk,i+1,f(msk,i+1));
    //printf("[%d][%d]: %lld\n",msk|mask[i],i+1,f(msk|mask[i],i+1)+a[i]);
    return dp[msk][i];
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> a[i];
        int bi; cin >> bi;
        while (bi--) {
            int ci; cin >> ci;
            ci--;
            mask[i] |= 1<<ci;
        }
        //cout << i << ": " << mask[i] << '\n';
    }
    memset(dp,-1,sizeof dp);
    ll ans = f(0,0);
    cout << (ans < INF ? ans : -1) << '\n';
}


Measured memory_bytes: 64640
#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 n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] += 32;
    cout << s << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)
#define size(a) (int) a.size()

int32_t main() { fastio;
	int n; cin >> n;
	int res = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			int g = __gcd(i, j);
			for (int k = 1; k <= n; k++) {
				res += __gcd(g, k);
			}
		}
	}	    
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 3640
def main():
    x = input()
    x1, x2 = x.split(' ') 
    a = int(x1)
    b = int(x2)
    if a > b:
        print("a",">","b")
    elif a < b:
        print("a","<","b")
    else:
        print("a","==","b")

if __name__ == "__main__":
    main()

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

long long int dp[101][200001];
vector <pair<int,int>> v;
int n,w,a,b;

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

	cin >> n >> w;
	for(int i=0;i<n;i++)
	{
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}

	for(int i=0;i<=100;i++)
	{
		fill(dp[i],dp[i]+200001,1e18);
	}
	dp[0][0] = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=200000;j>=0;j--)
		{
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
			if(dp[i][j]!=-1)
			{
				if(j + v[i].second <= 200000)
				{
					dp[i+1][j + v[i].second] = min(dp[i+1][j + v[i].second],dp[i][j] + v[i].first);
				}
			}
		}
	}

	long long int res = 0;
	for(int i=200000;i>=0;i--)
	{
		if(dp[n][i] <= w)
		{
			res = i;
			break;
		}
	}

	cout << res << '\n';

	return 0;
}


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

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin >> L.at(i);
    }
    int D = 0;
    int count = 0;
    for(int i=0;i<N;i++){
        D = D + L.at(i);
        if(D<=X){
            count++;
        }
    }

    cout << count+1 << endl;

    return 0;

}

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

#define all(x)   (x).begin(),(x).end()           /*sorting STL */
#define elif 	 (else if)
/*LOOPs*/
#define FOR(i,a,b)	 for(ll i = a;i < b; i++)
#define FRR(i,a,b)	 for(ll i = a;i <= b; i++)
#define ROF(i,b,a)	 for(ll i = b-1;i >= a; i--)
#define RRF(i,b,a)	 for(ll i = b;i >= a; i--)

/*In|Output section*/
#define SP 		printf(" ")
#define NL 		printf("\n")
#define in 		std::cin
#define out		std::cout

/*max, min section*/
#define TRIPmin(a, b, c) 	min(a, min(b, c))
#define TRIPmax(a, b, c)    max(a, max(b, c))

//defined function has gone here

/*********************************************************************************/

int main() {
	int a, b;

	cin >> a >> b;
	string x, y;	
	x = "", y = "";
	for(ll i = 1; i <= b; i++) {
		x += (a + 48);
	}
	for(ll i = 1; i <= a; i++) {
		y += (b + 48);
	}
	//cout << x << " " << y << "\n";	
	string g = x, h = y;
	while(g.length() < h.length()) g += "0";
	while(g.length() > h.length()) h += "0";
	
	//cout << g << " " << h;

	ll k = g.length()-1;
	for(ll i = 0; i <= k; i++) {
		if(g[i] < h[i]) {
			cout << x;
			return 0;
		}
		if(g[i] > h[i]) {
			cout << y;
			return 0;
		}
	}
	cout << x;
	return 0;
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

int main() {
    int n;
    cin >> n;
    vector<int> d(3);
    rep(i, 3) cin >> d[i];
    vector<pair<int, int>> q;
    rep(i, n) {
        string s;
        cin >> s;
        int a = 0, b = 1;
        if (s == "AB") a = 0, b = 1;
        if (s == "AC") a = 0, b = 2;
        if (s == "BC") a = 1, b = 2;
        q.emplace_back(a, b);
    }
    string ans;
    auto add = [&](int a, int b) {
        d[a]++;
        d[b]--;
        ans += 'A' + a;
    };
    q.emplace_back(0, 1);
    rep(i, n) {
        int a = q[i].first;
        int b = q[i].second;
        if (!d[a] && !d[b]) {
            cout << NO << endl;
            return 0;
        }
        if (!d[a]) {
            add(a, b);
        } else if (!d[b]) {
            add(b, a);
        } else {
            int na = q[i + 1].first;
            int nb = q[i + 1].second;
            if (a == na || a == nb) {
                add(a, b);
            } else {
                add(b, a);
            }
        }
    }
    cout << YES << endl;
    rep(i, n) { cout << ans[i] << endl; }
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

PLL solve(int64 x, int64 c) {
  if (x == 0) return PLL(x, c-1);
  int64 cnt = 0, now = x, i;
  for (i = 1; i < c; i++) {
    now += x;
    cnt++;
    while (now > 9) {
      now = now/10 + now % 10;
      cnt++;
    }
    if (now == x) break;
  }
  if (i == c-1) return PLL(now, cnt);
  int64 loop = cnt;
  cnt = 0;
  while (c >= i+1) {
    cnt += c / (i+1) *loop;
    c = c / (i+1) + c % (i+1);
  }
  now = x;
  REP(i, c-1) {
    cnt++;
    now = now + x;
    while (now > 9) {
      cnt++;
      now = now/10 + now%10;
    }
  }
  return PLL(now, cnt);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 M;
	cin >> M;
  vector<int64> d(M), c(M), a(M);
  int64 res = 0;
  REP(i, M) {
    cin >> d[i] >> c[i];
    PLL ret = solve(d[i], c[i]);
//    cout << ret.sc << " " << ret.fs << endl;
    res += ret.sc;
    a[i] = ret.fs;
//	  cout << ret.fs << " " << ret.sc << endl;
  }
  int64 now = a[0];
  FOR(i, 1, M) {
    now += a[i];
    res++;
    while (now > 9) {
      now = (now % 10) + now/10;
      res++;
    }
  }
  cout << res << endl;
}


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

int main(){
        int64_t N,T;
        cin >> N >> T;

        vector<int64_t> v(N);
        for(int i=0;i<N;i++){
                cin >> v[i];
        }

        int time=0;
        for(int i=0;i<N-1;i++){
                time+=min(T,v[i+1]-v[i]);
        }
        time+=T;

        cout << time << endl;

        return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    ll N,A,B;
    cin >> N >> A >> B;
    cout << min(A*N,B) << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        string input= Console.ReadLine();
        Console.WriteLine(input.Replace(","," "));


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13140
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	for i := 0; i < len(s); i++ {
		if s == t {
			fmt.Println("Yes")
			return
		}
		t = t[len(s)-1:] + t[0:len(s)-1]
	}
	fmt.Println("No")
}


Measured memory_bytes: 512