akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 1000000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x)
{
  head++;
  Q[++tail] = x;
}

P dequeue()
{
  P tmp = Q[head++];
  return tmp;
}


int main()
{
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n;
  while(n > 0)
    {
      if(Q[head].t > q)
	{
	  Q[head].t -= q;
	  u = Q[head];
	  elaps += q;
	  enqueue(u);
	}
      else
	{	  
	  u = dequeue();
	  elaps += u.t;
	  printf("%s %d\n",u.name,elaps);
	  n--;
	}	
    }
  return 0;
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;

    int size_a = a.size(), size_b = b.size();
    string ans;
    if (size_a > size_b) ans = "GREATER";
    else if (size_a < size_b) ans = "LESS";
    else {
        for (int i = 0; i < size_a; i++) {
            int ax = a[i] - '0', bx = b[i] - '0';
            if (ax > bx) {
                ans = "GREATER";
                break;
            }
            else if (ax < bx) {
                ans = "LESS";
                break;
            }
            if (i == size_a-1) ans = "EQUAL";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;


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

        if(N.endsWith("2")||N.endsWith("4")||N.endsWith("5")
           ||N.endsWith("7")||N.endsWith("9")){

                System.out.println("hon");
            }
            else if(N.endsWith("0")||N.endsWith("1")||N.endsWith("6")||N.endsWith("8")){
                System.out.println("pon");
            }else if(N.endsWith("3")){
                System.out.println("bon");
            }
    
    }
}


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

int main()
{
    int n;
    cin >> n;
    int a[n+1];
    int num;
    for(int i=1;i<=n;++i){
        cin >> num;
        a[num] = i;
    }
    for(int i=1;i<=n;++i) cout << a[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin >> n ;
    int ans;
    int div_num = 3;
    ans = n/div_num;
    cout << ans << endl;

}

Measured memory_bytes: 256
l = list(map(int, input().split()))
n = l[0]
m = l[1]
c = l[2]

b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
# a = list(map(int, input().split()) for i in range(n))

num_correct = 0

for i in range(n):
    sum = 0
    for j in range(m):
        sum += a[i][j]*b[j]
    sum += c
    if sum > 0:
        num_correct += 1

print(num_correct)


Measured memory_bytes: 62104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll>>ch;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ch.push_back(make_pair(x,y));
	}
	sort(ch.begin(),ch.end());
	reverse(ch.begin(),ch.end());
	priority_queue<ll>wo;
	ll ans=0;
	for(ll i=1;i<=m;i++){
	//	cout << ch[ch.size()-1].first<<endl;
		while(ch.size()!=0&&ch[ch.size()-1].first<=i){
			ll now=ch[ch.size()-1].second;
			wo.push(now);
			ch.pop_back();
		//	cout << i<<endl;
		//	cout << now;
		}
		if(!wo.empty()){
		ans+=wo.top();
		wo.pop();
		}
	//	cout << ans<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

const ll M = 1000000007;

ll fastexp(ll x, ll e) {
	ll ans = 1;
    x %= M;
	for(; e > 0; e >>= 1) {
		if(e&1) { ans *= x; ans %= M; }
		x *= x;
        x %= M;
	}
	return ans;
}

ll fat(ll x) {
    ll ans = 1;
    for (ll i = 2; i <= x; i++) {
        ans *= i;
        ans %= M;
    }
    return ans;
}

ll comb(ll n, ll k) {
    ll x = (fat(k) * fat(n - k)) % M;
    return (fat(n) * fastexp(x, M - 2)) % M;
}

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

    int x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int diag = (x + y) / 3;

    x -= diag;

    if (x < 0) {
        cout << 0 << endl;
        return 0;
    } else if (x > diag) {
        cout << 0 << endl;
        return 0;
    }

    cout << comb(diag, x) << endl;

    return 0;
}

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

ll N, K;
ll num[200005];
ll maximum = 2e18;

ll neg, pos, zero;
ll a, b, c;

ll numLessNeg(ll key){
    ll r = N-1;
    ll tot = 0;
    for (ll i=a-1; i>=0; i--){
        while (num[i]*num[r] <= key && r >= a+b) r--;
        tot += N-1-r;
    }
    return tot;
}

ll numLessPos(ll key){
    ll r = a-1;
    ll tot = 0;
    for (ll i=0; i<a; i++){
        while (num[i]*num[r] <= key && r >= 0) r--;
        tot += a-1-r;
        if (r < i) tot--;
    }

    r = a+b;
    for (ll i=N-1; i>=a+b; i--){
        while (num[i]*num[r] <= key && r < N) r++;
        tot += r-(a+b);
        if (r > i) tot--;
    }
    return tot/2;
}

int main(){
    cin >> N >> K;
    a = b = c = 0;
    for (int i=0; i<N; i++){
        scanf("%lld", &num[i]);
        if (num[i] < 0) a++;
        else if (num[i] == 0) b++;
        else c++;
    }
    sort(num, num+N);
    neg = a*c;
    pos = a*(a-1)/2+c*(c-1)/2;
    zero = b*(b-1)/2+b*(a+c);

    if (K <= neg){
        ll l = -maximum, r = 0, m;
        while (l < r){
            m = l+(r-l)/2;
            if (numLessNeg(m) < K) l = m+1;
            else r = m;
        }
        cout << l << endl;
    }
    else if (K > neg && K <= neg+zero){
        cout << 0 << endl;
    }
    else {
        ll l = 1, r = maximum, m;
        while (l < r){
            m = l+(r-l)/2;
            if (numLessPos(m) < K-neg-zero) l = m+1;
            else r = m;
        }
        cout << l << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
int n,a,b;
ld dp[150000],dp2[150000],ch[150000],par[150000];
vector<int> v[150000],u;
void dfs(int a){
    ld tmp=0.0;
    for(int x:v[a]){
        if(ch[x]!=0)continue;
        ch[x]=1;
        par[x]=a;
        dfs(x);
        tmp+=dp[x]+1.0;
    }
    if(a==0)dp[a]=tmp/(ld)v[a].size();
    else if(v[a].size()>1)dp[a]=tmp/ld(v[a].size()-1.0);
    else u.push_back(a);
    return ;
}
void dfs2(int a){
    int b=par[a];
    ld p=v[b].size();
    if(p==1)dp2[a]=1;
    else if(b==0)dp2[a]=((dp[b]+1)*p-(dp[a]+2))/(p-1);
    else if(p>1)dp2[a]=((dp2[b]+1)+(dp[b]+1)*(p-1)-(dp[a]+2))/(p-1);
    
    for(int x:v[a]){
        if(ch[x]!=0)continue;
        ch[x]=1;
        dfs2(x);
    }
    
    
    //cout<<"P"<<p<<" "<<b<<endl;
    //cout<<a<<" "<<dp2[a]<<endl;
    //cout<<a<<" "<<dp2[a]<<"W"<<endl;
    return ;
}
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++)ch[i]=0;
    ch[0]=1;
    par[0]=-1;
    dfs(0);
    //cout<<"W"<<endl;
    for(int i=0;i<n;i++)ch[i]=0;
    ch[0]=1;
    dfs2(0);
    for(int i=0;i<n;i++){
        //cout<<dp[i]<<" "<<dp2[i]<<endl;
        if(i==0)cout<<setprecision(15)<<dp[i]<<endl;
        else cout<<setprecision(15)<<(dp[i]*ld(v[i].size()-1)+dp2[i])/(ld)v[i].size()<<endl;
    }
}


Measured memory_bytes: 25464
/**
 *    author        : Saurav Paul 
 *    created       : July 12, 2020 9:02 PM
 *    Problem Name  : A - Payment
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc173/tasks/abc173_a
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    long long x;
    cin >> x;
    x = x%1000;
    cout << (x?1000-x:0) << endl ;

    return 0 ;
}


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

int main() {
  int N;
  cin >> N;
  int f = N;
  int sum;
  while(true){
  if((N%10)==0){
    break;
  }
  else if((N%10)!=0){
    sum+=N%10;
    N=N/10;

  }
  }
  if((f%sum)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

const int N=(int)1e5+5;

vi gr[N];

int vis[N];
int dp[N];

vi topo;

int dfs(int u)
{
	if (dp[u]!=-1)
		return dp[u];
	int p=0;
	for (int v: gr[u])
    {
		p=max(p,dfs(v)+1);
    }
    return dp[u]=p;
}

int main(int argc, char const *argv[])
{
	crap;
	rep(i,N)
		dp[i]=-1;
	int n,m;
	cin>>n>>m;
	int u,v;
	rep(i,m)	
		cin>>u>>v,gr[u].pb(v);

	int ans=-1;
	f(i,1,n)
	{
		int lng=dfs(i);
		ans=max(ans,lng);
	}

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

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a[3];
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]==a[1])
    {
        if(a[1]==a[2])
        {
            cout<<"No";
        }
        else
        {
            cout<<"Yes";
        }
    }
    else if(a[1]==a[2])
    {
        if(a[1]==a[0])
        {
            cout<<"No";
        }
        else
        {
            cout<<"Yes";
        }
    }
    else if(a[0]==a[2])
    {
        if(a[1]==a[2])
        {
            cout<<"No";
        }
        else
        {
            cout<<"Yes";
        }
    }
    else
    {
        cout<<"No";
    }
    return 0;
}









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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}
const ll mod = 1e9 + 7;

bool chack(int i, int j, int k, int l) {

	vector<int> a = {i, j, k, l};
	if(a[0] == 0 && a[1] == 1 && a[2] == 2)return true;
	if(a[1] == 0 && a[2] == 1 && a[3] == 2)return true;
	for(int i = 0; i < 3; i++) {
		swap(a[i], a[i + 1]);
		if(a[0] == 0 && a[1] == 1 && a[2] == 2)return true;
		if(a[1] == 0 && a[2] == 1 && a[3] == 2)return true;
		swap(a[i], a[i + 1]);
	}
	return false;
}

int main()
{
	int n = ri(); //0 = a, 1 = g, 2 = c, t = 3;
	vector<vector<vector<vector<ll>>>> dp(n + 1, vector<vector<vector<ll>>>(4, vector<vector<ll>>(4, vector<ll>(4))));
	dp[0][3][3][3] = 1;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 4; j++) {
			for(int k = 0; k < 4; k++) {
				for(int l = 0; l < 4; l++) {
					for(int t = 0;t < 4; t++) {
						//j -> k -> l -> t
						if(chack(j, k, l, t))continue;
						dp[i + 1][t][l][k] += dp[i][l][k][j];
						dp[i + 1][t][l][k] %= mod;
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < 4; i++) for(int j = 0; j < 4; j++) for(int k = 0; k < 4; k++) {
		ans += dp[n][i][j][k];
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
const int max_N = 100010;
int idx,N,M,i;
string s;
bool S[max_N];
int main()
{
    cin>>N>>M>>s;
    idx = N;//初始设置为N；
    stack<int> sql;
    for(;idx>0;)
    {
        //从能到达的最远距离idx-M到idx-1内寻找可以到达的点.
        for(i=0;i<M;i++)
        {
            if(s[idx-M+i]=='0'&&idx-M+i>=0)//点可达且在N内.
                {
                    idx=idx-M+i;
                    sql.push(M-i);//更新下标，将移动的距离放入栈中。
                    break;
                }
        }
        //无路可走
        if(i==M) {sql.push(0);break;}
    }
    if(!sql.top())cout<<"-1"<<endl;
    else
    {
        while(!sql.empty())
        {
         cout<<sql.top()<<" ";
         sql.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 876
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (_S == _T && (_T = (_S = _B) + fread(_B, 1, 1 << 15, stdin), _S == _T) ? EOF : *_S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char _B[1 << 15], *_S = _B, *_T = _B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}
#define maxn 500010
const int mod = 1e9 + 7;
int a[maxn], pre[maxn], suf[maxn], pre2, low[maxn], up[maxn];
int pwd[maxn], ans, bit[maxn];
bool appear[maxn];
int main()
{
//	setfile();
	int n, K = 0; scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		--a[i];
		K += (a[i] == -1);
		if (a[i] != -1) appear[a[i]] = 1;
	}
	pwd[0] = 1;
	for (int i = 1; i <= n; ++i) pwd[i] = 1ll * pwd[i - 1] * i % mod;
	for (int i = 0; i < n; ++i) pre[i] = (i > 0 ? pre[i - 1] : 0) + (a[i] == -1);
	for (int i = n - 1; ~i; --i) suf[i] = suf[i + 1] + (a[i] == -1);
	for (int i = 0; i < n; ++i) low[i] = (i > 0 ? low[i - 1] : 0) + !appear[i];
	for (int i = n - 1; ~i; --i) up[i] = up[i + 1] + !appear[i];
	// printf("K = %d\n", K);
	ans = pwd[K];

	int CK2 = (1ll * K * (K - 1) >> 1) % mod;
	if (a[n - 1] != -1)
	{
		for (int j = a[n - 1] + 1; j <= n; j += j & -j) ++bit[j];
		pre2 = (pre2 + up[a[n - 1]]) % mod;
	}
	for (int i = n - 2; i >= 0; --i)
	{
		if (a[i] != -1)
		{
			int num = 0;
			for (int j = a[i]; j; j -= j & -j)
				num += bit[j];
			ans = (ans + 1ll * num * pwd[K] % mod * pwd[n - i - 1]) % mod;
			ans = (ans + 1ll * low[a[i]] * pwd[K - 1] % mod * suf[i] % mod * pwd[n - i - 1]) % mod;
			for (int j = a[i] + 1; j <= n; j += j & -j) ++bit[j];
			pre2 = (pre2 + up[a[i]]) % mod;
		}
		else
		{
			ans = (ans + 1ll * pre2 * pwd[K - 1] % mod * pwd[n - i - 1]) % mod;
			K > 1 ? ans = (ans + 1ll * CK2 * pwd[K - 2] % mod * (suf[i] - 1) % mod * pwd[n - i - 1]) % mod : 0;
		}
		// printf("%d\n", ans );
	}
	printf("%d\n", ans );
	return 0;
}
/*
5
5 2 0 3 1 
*/

Measured memory_bytes: 14336
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, M, Q = map(int, readline().split())
    A = [[0] * N for _ in range(N)]
    for _ in range(M):
        l, r = map(int, readline().split())
        A[l - 1][r - 1] += 1

    B = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(N):
            B[i + 1][j + 1] = B[i][j + 1] + B[i + 1][j] - B[i][j] + A[i][j]

    ans = [0] * Q
    for i in range(Q):
        p, q = map(int, readline().split())
        p -= 1
        q -= 1
        ans[i] = B[q + 1][q + 1] - B[q + 1][p] - B[p][q + 1] + B[p][p]

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 25788
import java.io.*
import java.util.*

fun solve(N: Int, x: IntArray, y: IntArray, h: IntArray) {
    // z = max(0, H - |x-cx| - |y-cy|)
    if (100 in h) {
        val idx = h.indexOf(100)!!
        println("${x[idx]} ${y[idx]} 100")
        return
    }
    for (cx in 0..100) {
        for (cy in 0..100) {
            val dists = (0 until N)
                .filter{ h[it] != 0 }
                .map { h[it] + Math.abs(x[it] - cx) + Math.abs(y[it] - cy) }
                .distinct()
            if (dists.size == 1) {
                val H = dists[0]
                if ((0 until N)
                    .filter{ h[it] == 0 }
                    .map{ h[it] + Math.abs(x[it] - cx) + Math.abs(y[it] - cy) }.all{ it>=H }){
                    println("$cx $cy $H")
                    return
                }
            }
        }
    }
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val x = IntArray(N)
    val y = IntArray(N)
    val h = IntArray(N)
    for (i in 0 until N) {
        x[i] = sc.next().toInt()
        y[i] = sc.next().toInt()
        h[i] = sc.next().toInt()
    }
    solve(N, x, y, h)
}


Measured memory_bytes: 52064
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
int i[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  cin >>a>>b;
  d=max(a,b);
  e=d,d--;
  e+=max(min(a,b),d);
  cout <<e<<'\n';
  return (0);
}


Measured memory_bytes: 256
import java.io.IOException;

public class Main {
	/**
	* @param args
	*/
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	o = 0;

		while((o = parseNum()) != 0) {
			o = (o%39==0)?39:o%39;
			System.out.println("3C"+((o<=9)?0:"")+o);
		}
	}

	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;

			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if (skp == 0 || buf == -1) {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Measured memory_bytes: 16848
fun main(args: Array<String>) = println(run {
    val x = readLine()!!.toInt()

    val ok = BooleanArray(1001)
    ok[1] = true
    for (b in 2..31) {
        var k = b*b
        while (k<=1000) {
            ok[k] = true
            k *= b
        }
    }

    ok.take(x+1).withIndex().last { it.value }.index

})


Measured memory_bytes: 34032
import sys
import copy
input = sys.stdin.readline

n = int(input())
# カードの番号だけintにcastしながら受け取る
A = [None for _ in range(n)]
M = [None for _ in range(n)]
for i in range(n):
    tmp = list(input().split())
    A[i] = [tmp[0], int(tmp[1])]
    M[i] = [tmp[0], int(tmp[1])]

# mergeSortで使う
SENTINEL = 1000000005
merge_count = 0


def main():
    # print("before sort:{}".format(A))
    quickSort(A, 1, len(A) - 1)
    # print("quickSort Result:{}".format(A))
    mergeSort(M, 0, len(M))
    # print("mergeSort Result:{}".format(M))

    print(isStable(A, M))
    for a in A:
        print(a[0] + ' ' + str(a[1]))


def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q - 1)
        quickSort(A, q + 1, r)


def partition(A, p, r):
    last = A[r][1]
    i = p - 1
    # print("last:{}".format(last))
    # print("i:{}".format(i))
    for j in range(i, r, 1):
        # print("A[j]:{}".format(A[j]))
        if A[j][1] <= last:
            # print("change")
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
            i += 1

        # print(A)
    tmp = A[i]
    A[i] = A[r]
    A[r] = tmp

    return i


def merge(M, left, mid, right):
    # print("---merge start---")
    # print("M is {}".format(M))
    # print("left:{0}, mid:{1}, right{2}".format(left, mid, right))
    global merge_count

    L = M[left:mid] + [["SENTINEL", SENTINEL]]
    R = M[mid:right] + [["SENTINEL", SENTINEL]]

    # print("L:{}".format(L))
    # print("R:{}".format(R))

    i, j = 0, 0
    for k in range(left, right, 1):
        merge_count += 1
        # print("k:{0}".format(k))
        if L[i][1] <= R[j][1]:
            M[k] = L[i]
            i += 1
        else:
            M[k] = R[j]
            j += 1

    # print("M is {}".format(M))
    # print("----merge end----")


def mergeSort(M, left, right):
    # print("------mergeSort start--------")
    # print("left:{0}, right:{1}".format(left, right))

    if left + 1 < right:
        mid = (left + right) // 2
        # print("left:{0}, mid:{1}, right:{2}".format(left, mid, right))
        mergeSort(M, left, mid)
        mergeSort(M, mid, right)
        merge(M, left, mid, right)


def isStable(A, M):
    for i in range(len(A)):
        if A[i] != M[i]:
            return "Not stable"
    return "Stable"


if __name__ == '__main__':
    main()



Measured memory_bytes: 31012
N, K, Q = (int(x) for x in input().split())
#A = list(map(int, 0))
B = [K-Q] * N

for i in range(Q):
  A=int(input())
  #print(A)
  B[A-1]+=1
  #print(B)
  
for i in range(N):
  if(B[i]>=1):
  	print("Yes")
  else:
    print("No")

Measured memory_bytes: 6596
/**
 * https://atcoder.jp/contests/abc070/tasks/abc070_b
 */
fun main() {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    val min = if (a < c) c else a
    val max = if (b < d) b else d

    val answer = if (min > max) {
       0
    } else {
        max - min
    }
    print(answer)
}


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

int main()
{
    char input, ans;
    cin >> input;
    if ('A' <= input && input <= 'Z')
    {
        ans = 'A';
    }
    else
    {
        ans = 'a';
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
/**
 *    author        : Saurav Paul 
 *    created       : August 24, 2020 11:29 AM
 *    Problem Name  : A - Takoyaki
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc176/tasks/abc176_a
 *    @genarated by : ai-virtual-assistant
**/

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

using ll = long long int ;

void solve(){

    ll N , X , T;
    cin >> N >> X >> T;
    cout << ((N+X-1)/X) * T << endl ;

}

int main(){
    ios_base::sync_with_stdio(false);

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

    return 0 ;
}


Measured memory_bytes: 3644
#include <stdio.h>
 
int main()
{
  int a[4];
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  if (a[0] == a[1])
    printf("%d",a[2]);
  else if (a[0] == a[2])
    printf("%d",a[1]);
  else
    printf("%d",a[0]);
}

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

int main() {
    vector<int> v(3);
    for (int i = 0; i < 3; i++)
        cin >> v.at(i);
    sort(v.begin(), v.end());
    int d0 = v.at(2) - v.at(0);
    int d1 = v.at(2) - v.at(1);
    if ((d0 + d1) % 2 == 0) {
        cout << (d0 + d1) / 2 << endl;
    }else{
        cout << (d0 + d1 + 3) / 2 << endl;
    }
    return 0;   
}

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

using namespace std;

int main(){
    double a,b;  
    cin >> a >> b;
    
    double ans = (b-1.0) / (a-1.0);
    cout << ceil(ans) << endl;
    
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string S;
	int w;
	cin >> S >> w;
	int count = 0;
	for (int i = 0; i < S.length(); i += w) {
		cout << S[i];
	}
	cout << endl;
	return 0;
}

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

struct ystruct {
    double val;
    int64_t init_length;
    int64_t split_num;
};
bool operator<=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val <= rhs.val;
}
bool operator<(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val < rhs.val;
}
bool operator>=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val >= rhs.val;
}
bool operator>(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val > rhs.val;
}
bool operator==(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val == rhs.val;
}
bool operator!=(const ystruct& lhs, const ystruct& rhs) {
    return lhs.val != rhs.val;
}
ostream& operator<<(ostream& os, ystruct const& yst) {
    return os << yst.val;
}

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

    int64_t total_length = 0;
    priority_queue<ystruct> yp;
    vector<int64_t> avec;
    for (uint64_t i = 0; i < N; i++) {
        int64_t A;
        cin >> A;
        yp.push(ystruct{val : 1.0 * A, init_length : A, split_num : 0});
        avec.push_back(A);
        total_length += A;
    }

    // 適当な初期値を与えて上界とする
    double upper_bound = -1;
    for (auto a : avec) {
        int64_t split_num_heuristic = (K * a) / total_length;
        upper_bound = max(upper_bound, 1.0 * a / (split_num_heuristic + 1));
    }
    int64_t j = 0;
    while (j < K) {
        ystruct y = yp.top();
        yp.pop();

        //int64_t split_num_min = (y.init_length / upper_bound) - 1L;
        int64_t split_num_min;
        if (upper_bound == 0) {
            split_num_min = 0;
        } else {
            split_num_min = (y.init_length / upper_bound) - 1L;
        }

        if (y.split_num < split_num_min) {
            y.split_num = split_num_min;
            y.val = 1.0 * y.init_length / (y.split_num + 1);
            j += split_num_min;
            yp.push(y);
        } else {
            y.split_num = y.split_num + 1;
            y.val = 1.0 * y.init_length / (y.split_num + 1);
            j++;
            yp.push(y);
        }
    }
    ystruct yy = yp.top();
    if (yy.init_length % (yy.split_num + 1) == 0) {
        cout << (yy.init_length / (yy.split_num + 1)) << endl;
    } else {
        cout << (1 + yy.init_length / (yy.split_num + 1)) << endl;
    }
}


Measured memory_bytes: 11676
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] aList = new long[N];
		long[] bList = new long[N];
		long[] cList = new long[N];
		for (int i = 0; i < N; i++) {
			aList[i] = sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			bList[i] = sc.nextLong();
		}
		for (int i = 0; i < N; i++) {
			cList[i] = sc.nextLong();
		}
		Arrays.sort(aList);
		Arrays.sort(bList);
		Arrays.sort(cList);
		int i_a = 0;
		int i_b = 0;
		int i_c = 0;
		long sum = 0L;
		for (; i_b < N; i_b++) {
			while (i_a < N && aList[i_a] < bList[i_b]) {
				i_a++;
			}
			while (i_c < N && bList[i_b] >= cList[i_c]) {
				i_c++;
			}
			sum+=((long)i_a)*((long)N-(long)i_c);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 98468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int x, y; cin >> x >> y;
			(y ? a[i] : b[i]) |= 1 << (x - 1);
		}
	}
	auto cnto = [&](int bi) {
		int ret = 0;
		for (int i = 0; i < n; i++) {
			ret += (bi >> i) & 1;
		}
		return ret;
	};
	int ans = 0;
	for (int i = 1; i < (1 << n); i++) {
		int t = i;
		bool flag = true;
		for (int j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				t |= a[j];
				t &= ~b[j];
				flag &= t == i;
			}
		}
		if (flag) ans = max(ans, cnto(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	a,b,c,d=MI()
	dp=[[0]*(d+1) for _ in range(c+1)]
	dp[a][b]=1

	for i in range(a-1,c):
		for j in range(b-1,d):
			if i+1==a and j+1==b:
				continue
			#print(i,j)
			dp[i+1][j+1]=dp[i][j+1]*(j+1)+dp[i+1][j]*(i+1)-i*j*dp[i][j]
			dp[i+1][j+1]%=998244353

	print(dp[c][d])
















if __name__ == "__main__":
	main()


Measured memory_bytes: 144228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define _GLIBCXX_DEBUG
const int MOD = 1000000007;

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 100;

void SelectionSort(int A[], int n)
{
	int cnt = 0;
	
	for (int i = 0; i < n; i++){
		int minIndex = i;
		for (int j = i+1; j < n; j++){
			if (A[j] < A[minIndex]){
				minIndex = j;
			}
		}
		if (minIndex != i){
			int temp;
			temp = A[minIndex];
			A[minIndex] = A[i];
			A[i] = temp;
			cnt++;
		}
	}
	for (int i = 0; i < n; i++){
		if (i > 0)
			cout << " ";
		cout << A[i];
	}
	cout << endl << cnt << endl;
}



int main()
{
	int A[MAX];
	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> A[i];
	}
	SelectionSort(A, n);
	
	
	return 0;
}


Measured memory_bytes: 3092
/*
[agc036] B - Do Not Duplicate
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2e5;
const int MAX_A = 2e5;
const int MAX_LOG_NK = 64;

int N;
ll K;
int A[MAX_N];
int rlast[MAX_A + 1];
bool has[MAX_A + 1];
ll d[MAX_LOG_NK][MAX_N];
vector<int> ans;

void solve() {
    for (int i = N - 1; i >= 0; i--) {
        rlast[A[i]] = N + i;
    }
    for (int i = N - 1; i >= 0; i--) {
        d[0][i] = rlast[A[i]] - i + 1;
        rlast[A[i]] = i;
    }

    for (int k = 1; k < MAX_LOG_NK; k++) {
        for (int i = 0; i < N; i++) {
            d[k][i] =
                min(N * K + 1, d[k - 1][i] + d[k - 1][(i + d[k - 1][i]) % N]);
        }
    }

    ll cur = 0;
    for (int k = MAX_LOG_NK - 1; k >= 0; k--) {
        ll nxt = cur + d[k][cur % N];
        if (nxt <= N * K) {
            cur = nxt;
        }
    }

    for (ll i = cur; i < N * K; i++) {
        int a = A[i % N];
        if (has[a]) {
            while (ans.back() != a) {
                has[ans.back()] = false;
                ans.pop_back();
            }
            has[a] = false;
            ans.pop_back();
        } else {
            ans.push_back(a);
            has[a] = true;
        }
    }
}

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

    solve();

    for (int a : ans) {
        cout << a << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 104180
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        if (d[2] == d[3] && d[4] == d[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
from itertools import*
n=int(input())
a=[input().split()for _ in[0]*n]
for b in a:
 b[3:5]=b[4],b[3]
def g():
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[i]for i in p]
   if f[::5]==e[::5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(g())


Measured memory_bytes: 5660
N, K = map(int, input().split())
cnt = [0] * N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        cnt[A[j]-1] += 1
ans = 0
for i in range(N):
    if cnt[i] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9192
import sys
sys.setrecursionlimit(10**9)

def dfs(s,check):
  if len(check)==n:
    if len(set(check))==n:
      return 1
    else:
      return 0
  ans=0
  for i in edge[s]:
    ans+=dfs(i,check+[i])
  return ans

n,m=map(int,input().split())
edge=[[] for _ in range(n+1)]
for i in range(m):
  s,t=map(int,input().split())
  edge[s].append(t)
  edge[t].append(s)
print(dfs(1,[1]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, a, b;
ll p[100005];
set<ll> s;

ll parent(ll x){
	if (p[x] == x) return x;
	return p[x] = parent(p[x]);
}

void merge_parent(ll a, ll b){
	a = parent(a);
	b = parent(b);
	if (a == b) return;
	if (a > b) swap(a, b);
	p[b] = a;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	REP(i, 0, n) p[i] = i;
	REP(i, 0, m){
		cin >> a >> b;
		a--;
		b--;
		merge_parent(a, b);
	}
	
	REP(i, 0, n){
		s.insert(parent(i));
	}
	cout << (ll)s.size() - 1 << endl;
}

//cout.flush()
//cout << fixed << setprecision(9) << x << endl;

Measured memory_bytes: 8184
#include <iostream>
#include <cstdint>
#include <algorithm>

using namespace std;
int main(void)
{
  int N, M;
  cin >> N >> M;

  int maxL = INT_MIN, minR = INT_MAX;
  for (int i = 0; i < M; i++)
  {
    int L, R;
    cin >> L >> R;
    maxL = max(maxL, L);
    minR = min(minR, R);
    if (maxL > minR) break;
  }
  cout << max(0, minR - maxL + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long>a[500];
int main(){
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        a[(int)s[i]].push_back(i);
    }
    long long h=1;
    int pre=-1;
    for(int i=0;i<t.size();i++){
        if(a[(int)t[i]].size()==0){
            cout<<-1;
            return 0;
        }
        else{
            int l=0,r=a[(int)t[i]].size()-1;
            int pos=-1;
            while(l<=r){
                if(l==r){
                    if(a[(int)t[i]][l]>pre){
                        pos=a[(int)t[i]][l];
                    }
                    break;
                }
                int mid=(l+r)/2;
                if(a[(int)t[i]][mid]>pre){
                    pos=a[(int)t[i]][mid];
                    r=mid-1;
                }
                else{
                    l=mid+1;
                }
            }
            if(pos==-1){
                h++;
                pre=a[(int)t[i]][0];
            }
            else{
                pre=pos;
            }
        }
    }
    //cout<<h<<" "<<pre<<endl;
    cout<<(unsigned long long)((long long)(h-1)*s.size()+pre+1)<<endl;
}


Measured memory_bytes: 1724
#include <iostream>
#include <algorithm>
 
int main(){
 
int a = 0,b = 0,c = 0,k = 0;
int kiyomaru = 0;
 
std::cin >> a >> b >> c >> k;
 
kiyomaru = std::max({a,b,c});
 
for (int i = 0; i < k; i++) {
	
	kiyomaru *=2;
    
    }
    
if (a == std::max({a,b,c})){
 
std::cout << kiyomaru + b + c << std::endl;
 
}else if(b == std::max({a,b,c})){
 
 
std::cout << kiyomaru + a + c << std::endl;
 
}else{
 
std::cout << kiyomaru + b + a << std::endl;
 
}
 
return 0;
 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int Mt[10],ranking[3],i;
    ranking[0]=0;
    ranking[1]=0;
    ranking[2]=0;
    scanf("%d%d%d%d%d%d%d%d%d%d",&Mt[0],&Mt[1],&Mt[2],&Mt[3],&Mt[4],&Mt[5],&Mt[6],&Mt[7],&Mt[8],&Mt[9]);
    for(i=0;i<10;i++)
    {
        if(ranking[0]<Mt[i])
        {
            ranking[2]=ranking[1];
            ranking[1]=ranking[0];
            ranking[0]=Mt[i];
        }
        else if(ranking[1]<Mt[i])
        {
            ranking[2]=ranking[1];
            ranking[1]=Mt[i];
        }
        else if(ranking[2]<Mt[i])
        {
            ranking[2]=Mt[i];
        }
    }
    printf("%d\n%d\n%d\n",ranking[0],ranking[1],ranking[2]);
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, l;
  cin >> n >> l;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  vector<ll> s(n-1);

  bool flag = false;
  ll idx = -1;
  for(int i=1;i<n;i++) {
    if(a[i] + a[i-1] >= l) {
      flag = true;
      idx = i-1;
      break;
    }
  }
  if(!flag) {
    cout << "Impossible" << endl;
    return 0;
  } else {
    cout << "Possible" << endl;
  }

  for(int i=0;i<idx;i++) {
    cout << i + 1 << endl;
  }
  for(int i=n-2;i>idx;i--) {
    cout << i + 1 << endl;
  }
  cout << idx + 1 << endl;



}


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

int main()
{
  std::string s;
  std::cin >> s;
  int answer;
  if(s[0] == '1') answer++;
  if(s[1] == '1') answer++;
  if(s[2] == '1') answer++;
  std::cout << answer << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	string s,num;
	cin>>s;
	ll d,min_d=9999,n;
	REP(i,0,s.size()-3)
	{
		num=s.substr(i,3);
		n=stol(num);
		d=abs(753-n);
		min_d=min(d,min_d);
		num.erase(num.begin(),num.end());
	}
	cout<<min_d;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	LLI k, n;
	cin >> k >> n;
	vector<LLI> a(n);

	REP(i, n)
	{
		cin >> a[i];
	}
	LLI ma = k + a[0] - a[n - 1];
	REP(i, n - 1)
	{
		chmax(ma, a[i + 1] - a[i]);
	}
	cout << k - ma;

	return 0;
}

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

using namespace std;

using int64 = long long;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
struct StronglyConnectedComponents {
  const G &g;
  UnWeightedGraph gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return (comp[k]);
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(G &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        int x = comp[i], y = comp[e];
        e = comp[(int) e];
        t[x].push_back(e);
      }
    }
  }
};


int main() {
  int V, E, Q;
  scanf("%d %d", &V, &E);
  UnWeightedGraph g(V), buff;
  for(int i = 0; i < E; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].emplace_back(b);
  }
  StronglyConnectedComponents< UnWeightedGraph > scc(g);
  scc.build(buff);
  scanf("%d", &Q);
  while(Q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    puts(scc[a] == scc[b] ? "1" : "0");
  }
}


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

int main() {
    string  S, T;
    int     size, ans = 0;
    
    cin >> S >> T;
    
    size = S.size();
    for ( int ii = 0; ii < size; ii++ ) {
        if ( S[ii] != T[ii] ) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define repeat(i, n) for(int (i) = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int N;
	cin >> N;
	vector<ll> h(N, 0);
	repeat(i, N) {
		cin >> h[i];
	}

	string result = "Yes";

	ll prev = h[0];
	for(int i = 1; i < N; i++) {
		ll n = h[i];
		if (prev <= (n-1)) {
			prev = n - 1;
			continue;
		} else if (prev <= n) {
			prev = n;
			continue;
		}

		result = "No";
		break;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 1024
main=do
 s<-getLine
 t<-getLine
 let sl=length s
 let tl=length t
 let ok=[map(\c->if c=='?' then 'a' else c)$(take i s)++t++(drop(i+tl)s)|i<-[0..sl-tl],f$zip(take tl$drop i s)t]
 putStrLn$if null ok then"UNRESTORABLE"else minimum ok
f[]=True
f((a,b):s)=if a/='?'&&a/=b then False else f s

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long A[N];
  A[0]=2;
  A[1]=1;
  for(int i=2;i<=N;i++) {
    A[i]=A[i-1]+A[i-2];
  }
  cout<<A[N]<<endl;
  return 0;
}
  


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

int main(){
    int n;
    int a;
    int remain;
    
    cin >> n >> a;

    remain = n % 500;

    if (remain <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    

}

Measured memory_bytes: 3524
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

int main() {
    ll n, k, t, d;
    vector<pair<ll, ll>> s;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> t >> d;
        s.emplace_back(d, t);
    }
    sort(s.begin(), s.end(), greater<>());
    ll sum = 0, typ = 0;
    map<ll, multiset<ll>> u;
    priority_queue<pair<ll, ll>> q;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, decltype(greater<>())> p((greater<>()),
                                                                                vector<pair<ll, ll>>());
    for (int i = 0; i < k; i++) u[s[i].second].insert(s[i].first);
    for (auto &e:u) typ++;
    for (auto &e:u) for (auto f:e.second) sum += f;
    for (int i = 0; i < k; i++) p.push(s[i]);
    for (int i = k; i < n; i++) q.push(s[i]);
    ll res = sum + typ * typ;

    while (1) {
        while ((!p.empty()) && u[p.top().second].size() <= 1) p.pop();
        while ((!q.empty()) && u[q.top().second].size() > 0) q.pop();
        if (p.empty() || q.empty()) break;
        u[q.top().second].insert(q.top().first);
        u[p.top().second].erase(u[p.top().second].find(p.top().first));
        sum += (q.top().first - p.top().first);
        typ++;
        res = max((long long) (sum + typ * typ), res);
        p.pop();
        q.pop();
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 15088