akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        # self.group_num = n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        # self.group_num -= 1

n, k = LI()
P = LI()
C = LI()
U = UnionFind(n)
for i in range(n):
    U.union(P[i] - 1, i)

D = defaultdict(int)
for i in range(n):
    D[U.root(i)] += C[i]

ans = -INF
k -= 1
for j in range(n):
    now = P[j] - 1
    r = D[U.root(now)]
    m = U.get_size(now)
    ret = C[now]
    ans = max(ans, ret)
    if k // m and r >= 0:
        ret += k // m * r
        ans = max(ans, ret)
        for l in range(k % m):
            now = P[now] - 1
            ret += C[now]
            ans = max(ans, ret)
    else:
        for l in range(min(m, k)):
            now = P[now] - 1
            ret += C[now]
            ans = max(ans, ret)

print(ans)







Measured memory_bytes: 85276
/* Written in FCP - alpha version */
#ifdef false
/* Original code */
$i
N:int D:int
p:vpii:N
$p
int ans = 0
i:0..N {
    double d = sqrt((double)p[i].fi*p[i].fi + (double)p[i].se*p[i].se)
    if d <= D {
        ans++
    }
}
<<ans
#endif
/* Transpiled code */

#include <bits/stdc++.h>

#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second

using namespace std;

using str = string;
using uint = unsigned int;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<str>;
using vvs = vector<vector<str>>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

template<typename T>
std::ostream& operator<<(std::ostream& s, std::vector<T> t) {
    for (int i = 0; i < sz(t); i++) {
        s << t[i] << (i == sz(t) - 1 ? "" : " ");
    }
    return s;
}



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

    
        int N;
cin >> N;
int D;
cin >> D;
vpii p(N);
for (int __i = 0; __i < N; __i++) {
int __a, __b; cin >> __a >> __b; p[__i] = mp(__a, __b);
}
int ans = 0;
for (int i = 0; i < N ; ++i) {
    double d = sqrt((double)p[i].fi*p[i].fi + (double)p[i].se*p[i].se);
    if (d <= D) {
        ans++;
    };
};
cout <<ans;
        goto end_tc_label;
        end_tc_label:;
    
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    int n, k, x, y, res;
    cin >> n >> k >> x >> y;
    if (k < n) res = k*x + (n-k)*y;
    else res = n*x;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll n;
	cin >> n;
	vector<double> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	cout << (ll)a.back() << " ";

	double mid = a.back() / 2;
	sort(all(a), [&](double x, double y) { return abs(x - mid) < abs(y - mid); });
	cout << (ll)a[0] << endl;
}

Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
h,w,k = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from itertools import *
ans=10**10
import copy
for tmp in list(product([True,False], repeat=h-1)):
    num_sp = sum(tmp)+1
    cnt=[0]*num_sp
    nxt_cnt=[0]*num_sp
    last_spl=-1
    ok=True

    spl_l=[]
    for aaa in range(h):
        spl_l.append(sum(tmp[:aaa]))
    cur_ans=sum(tmp)
    for i in range(w):
        for j in range(h):
            spl = spl_l[j]
            nxt_cnt[spl] += int(l[j][i])
            cnt[spl] += int(l[j][i])

        if max(cnt) > k:
            cur_ans+=1
            cnt=copy.copy(nxt_cnt)
            if last_spl+1 == i or max(nxt_cnt)>k:
                ok=False
                break
            last_spl=i-1
        nxt_cnt=[0]*num_sp
        if not ok:
            break
    if ok:
        ans=min(ans,cur_ans)

print(ans)

Measured memory_bytes: 47964
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=4e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;
	int tem=(c*d)/__gcd(c,d);
	int ans=b/c+b/d-b/tem;
	trace(ans);
	ans-=a/c+a/d-a/tem;
	trace(ans);
	cout<<b-a-ans<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int X,Y,Z,ans=0;

int main(){
  cin >> X  >> Y >> Z;

  while(1){
    X=X-2*Z;
    if(X<=0) break;
    X=X-Y;
    if(X<0){
      break;
    }
    ans++;
    X=X-Y;
    if(X<Z){
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int f(int a){
	int b=0;
	while(a>0){
		b+=a%10;
		a/=10;
	}
	return b;
}

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

	int n,a,b;
	cin >> n >> a >> b;
	int sum=0;
	int x;
	rep(i,1,n+1){
		x=f(i);
		if(x >= a  && x<=b)sum+=i;
	}
	cout << sum;

	return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			TreeMap<String, Integer> m = new TreeMap<>();
			for(int i = 0; i < q; i++) {
				int query = sc.nextInt();
				switch(query) {
				case 0:
					m.put(sc.next(), sc.nextInt());
					break;
				case 1:
					System.out.println(m.getOrDefault(sc.next(), 0));
					break;
				case 2:
					m.remove(sc.next());
					break;
				case 3:
					Map<String, Integer> sub = m.subMap(sc.next(), true, sc.next(), true);
					for(Map.Entry<String, Integer> entry: sub.entrySet()) {
						System.out.println(String.format("%s %d", entry.getKey(), entry.getValue()));
					}
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 331600
#include <stdio.h>
int main() {
    int n, i;
    for(n = 1; n <= 9; n = n + 1) {
        for(i = 1; i <= 9; i = i + 1) {
            printf("%dx%d=%d\n", n, i, n*i);
        }
    }
    return 0;
}



Measured memory_bytes: 2024
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dpc[10000][10000];
ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else {return dpc[n][r]=combination(n - 1, r - 1)  + combination(n - 1, r);}}


ll nCr(ll n, ll r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}

bool chsK(string s) {
	int n = s.length();
	if (n % 2 == 0) {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i-1])return false;
		}
	}
	else {
		for (int i = 0;i <= n / 2;i++) {
			if (s[i] != s[n - i-1])return false;
		}
	}
	return true;
}

int check(int X, int Y, int K, int J) {
	int t;
	if (K >= Y && J <= X)t = X - J + K - Y + 1;
	else if (K <= X || J >= Y) t = K - J;
	else if (J >= X && K <= Y)t = min(K - J, J - X + Y - K + 1);
	else if (K >= X && K <= Y)t = min(K - J, X - J + Y - K + 1);
	else if (J >= X && J <= Y)t = min(K - J, J - X + K - Y + 1);
	return t;
}

int main() {

	int n, x, y;
	cin >> n >> x >> y;
	int count;
	
	vector<int>cou(n);
	//for (int i = 1;i < n;i++) {
		//count = 0;
		for (int j = 1;j <= n-1;j++) {
			for (int k = j+1;k <= n;k++) {
				cou[check(x,y,k,j)]++;
			}
		}
		//cout << count << endl;
	//}
	for (int i = 1;i < n;i++)cout << cou[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[10];
int main(){
	for(int i = 0; i < 4; i += 1){
		int N;
		cin >> N;
		c[N] += 1;
	} 
	cout << (c[1] && c[9] && c[7] && c[4] ? "YES" : "NO");
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,k,i,j;
            cin>>n>>k;
            int ar[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i];
            int dp[k+1];
            dp[0]=1;
            for(i=1;i<=k;++i)
            {
                dp[i]=1;
                for(j=1;j<=n;++j)
                {
                    //cout<<i-ar[j]<<endl;
                    if(i-ar[j]>=0)
                        if(dp[i-ar[j]]==1)
                            dp[i]=0;
                }
                //cout<<i<<" "<<dp[i]<<endl;
            }
            if(dp[k]==1)
                cout<<"Second"<<endl;
            else
                cout<<"First"<<endl;
        }
        return 0;
    }


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


int main () {

const int cnum = 10;
int **p_teams;        /* teamの配列を入れるポインタのポインタ */
int *p_t;
int *p_t2;

int team_num;

	while (1) {
		cin >> team_num;      /* チームの数を取り込む */

		if (team_num < 2) {
			break;
		}

		p_teams = new int*[team_num]; /* チームのデータを保存する領域を確保　*/

		for (int i = 0;i < team_num;i++)
		{
			p_teams[i] = new int[cnum];      /* チームごとのデータ領域を確保 */
		}

		for (int i = 0; i < team_num; i++) {
			p_t = p_teams[i];

			cin >> p_t[0] >> p_t[1] >> p_t[2] >> p_t[3] >> p_t[4] >> 
			p_t[5] >> p_t[6] >> p_t[7] >> p_t[8];

			int m = p_t[1] + p_t[3] + p_t[5] + p_t[7];
			int s = p_t[2] + p_t[4] + p_t[6] + p_t[8];
			p_t[9] = m * 60 + s;
		}

		for (int i = 0; i < team_num - 1;i++)
		{
			// p_t = p_teams[i];
			for (int j = i + 1;j < team_num;j++)
			{
				//p_t2 = p_teams[j];
				//cout << i << " " << j << " " << p_t[0] << " " << p_t[9] << " " << p_t2[0] << " " << p_t2[9] << "\n";
				if (p_teams[i][9] > p_teams[j][9]) {
					//cout << "swap\n";
					int *x = p_teams[i];
					p_teams[i] = p_teams[j];
					p_teams[j] = x;
					// p_t = p_teams[i];
				}
			}
		}

		cout << p_teams[0][0] << "\n" << p_teams[1][0] << "\n" << p_teams[team_num - 2][0]<< endl;
		
		for (int i = 0;i < team_num;i++)
		{
			delete[] p_teams[i];      /* チームごとのデータ領域を解放 */
			p_t++;
		}

		delete[] p_teams;
	} 
	
  return 0;
}

Measured memory_bytes: 1464
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
typedef long long ll;

int fact(ll n, ll p, ll limit);

int main()
{
	ll n, p;
	ll pp;
	ll i;
	ll cnt;
	ll ans = 1;

	scanf("%lld %lld", &n, &p);

	pp = p;
	cnt = 0;
	i = 2;
	while (p > 1 && i * i <= p) {
		if (p % i == 0) {
			p /= i;
			cnt++;

			if (cnt == n) {
				ans *= i;
				cnt = 0;
			}
		}
		else {
			cnt = 0;
			i++;
		}
	}

	if (fact(n, p, pp)) {
		ans *= p;
	}

	printf("%lld\n", ans);

	return 0;
}

int fact(ll n, ll p, ll limit)
{
	ll f = 1;

	while (n && f <= limit && p <= limit) {
		if (n & 1) {
			f *= p;
		}
		
		n >>= 1;
		p *= p;
	}

	if (n || limit % f) {
		return 0;
	}
	else {
		return 1;
	}
}


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

int main(){
    int n;
    cin >> n;
    for(int i=0;i<3;i++){
        if(n%10==7){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3044
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif
    ll d, t, s;
    cin >> d >> t >> s;
    cout << ((t*s>=d)?"Yes":"No") << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int n,x,i,now=0,cnt=1;
    scanf("%d%d",&n,&x);
    int l[n];
    for(i=0;i<n;i++) scanf("%d",&l[i]);
    for(i=0;i<n;i++){
        now+=l[i];
        if(now<=x) cnt++;
        else break;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MAX 2000001
#define VMAX 10000


int main(){
  unsigned short A[MAX],B[MAX];
  int C[VMAX+1];
  int n, i, j;
  unsigned short k;

  scanf("%d", &n);
  
 
  for(i=1; i<=n; i++){
    scanf("%hd",&A[i]);
    if(k < A[i]) k = A[i];
  }
  k++;
  for(i=0; i<=k; i++){
    C[i] = 0;
  }

  for(j=1; j<=n; j++){
    C[A[j]]++;
  }

  for(i=1; i<=k; i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1; i<=n; i++){
    printf("%d",B[i]);
    if(i == n) break;
    printf(" ");
  }
  printf("\n");
 
  return 0;
  
}



Measured memory_bytes: 9580
#include<cstdio>
#include<algorithm>
int main(){
    int n,k,x,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        ans+=2*std::min(x,k-x);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import Text.Printf

data Point = Point Double Double deriving Show
dist (Point x1 y1) (Point x2 y2) = sqrt $ (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) 

main = do
  [x1, y1, x2, y2] <- return . map (\x -> read x :: Double) . words =<< getLine
  let p1 = Point x1 y1
  let p2 = Point x2 y2
  putStrLn $ printf "%.08f" $ dist p1 p2

Measured memory_bytes: 4124
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
void print(ll n)
{
    if(n < 26)
        printf("%c", n + 'a');
    else
    {
        print(n / 26 - 1);

        print(n % 26);
    }

}

void solve()
{
   ll n;
   cin>>n;
   print(n-1);
}
int  main()
{
   // IOS
        solve();
    return 0;
}



Measured memory_bytes: 3724
import sys
from collections import deque


class MaxFlow:
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, node_size, inf):
        self._node = node_size
        self._inf = inf
        self._level = [-1]*self._node
        self._iter = [0]*self._node
        self._graph = [[] for _ in range(self._node)]

    def add_edge(self, from_, to, cap):
        self._graph[from_].append(self.Edge(to, cap, len(self._graph[to])))
        self._graph[to].append(self.Edge(from_, 0, len(self._graph[from_])-1))

    def bfs(self, start):
        for i in range(self._node):
            self._level[i] = -1
        que = deque()
        self._level[start] = 0
        que.append(start)
        while que:
            cur_vertex = que.popleft()
            for e in self._graph[cur_vertex]:
                if self._level[e.to] < 0 < e.cap:
                    self._level[e.to] = self._level[cur_vertex] + 1
                    que.append(e.to)

    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:
            return flow
        for e in self._graph[cur_vertex][self._iter[cur_vertex]:len(self._graph[cur_vertex])]:
            if e.cap > 0 and self._level[cur_vertex] < self._level[e.to]:
                flowed = self.dfs(e.to, end_vertex, min(flow, e.cap))
                if flowed > 0:
                    e.cap -= flowed
                    self._graph[e.to][e.rev].cap += flowed
                    return flowed
        return 0

    def solve(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self._level[sink] < 0:
                return flow
            for i in range(self._node):
                self._iter[i] = 0
            while True:
                f = self.dfs(source, sink, self._inf)
                if f == 0:
                    break
                flow += f


def main():
    n, m = map(int, sys.stdin.readline().split())
    mf = MaxFlow(n, 10 ** 4)
    for _ in range(m):
        u, v, c = map(int, sys.stdin.readline().split())
        mf.add_edge(u, v, c)
    print(mf.solve(0, n - 1))

if __name__ == '__main__':
    main()



Measured memory_bytes: 6336
n = int(input())
listStone = input().split()
for i in range(n) :
  listStone[i] = int(listStone[i])

dp = [-1 for _ in range(n)]
dp[0] = 0
dp[1] = abs(listStone[1] - listStone[0])

for i in range(2, n) :
  dp[i] = min((dp[i-2]+abs(listStone[i]-listStone[i-2])),(dp[i-1]+abs(listStone[i]-listStone[i-1])))

print(dp[-1])

Measured memory_bytes: 17408
#include <iostream>

int main()
{
	long N, K;
	std::cin >> N >> K;
	long ans;

	if ( K != 0 )
	{
		// 何人に何枚配っても、できるだけ均等に配るなら、差分は絶対に1枚になる
		ans = ( ( N % K ) != 0 );
	}
	else
	{
		// 0人に配る（＝配らない）から、0で良いのかな…？
		ans = 0;
	}

	std::cout << ans << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;


int alt[3]={3,5,7};
int ans=0;
//dd:決まった桁
void solve(ll dd,bool t,bool f,bool s,int to){
    if(t&&f&&s){
        ans++;
        rep(i,3){
        ll tmp=dd*10+alt[i];
        if(tmp<=to){
            solve(dd*10+alt[i],t,f,s,to);
        }
        }
    }
   else{
        rep(i,3){
        ll tmp=dd*10+alt[i];
        if(tmp<=to){
            if(i==0)solve(tmp,true,f,s,to);
            else if(i==1)solve(tmp,t,true,s,to);
            else { solve(tmp,t,f,true,to);}
        }
        }
    }
}
int main(){
    int n;
    cin>>n;
    bool t,f,s;
    t=f=s=false;
    solve(0LL,t,f,s,n);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int ans;
    for (i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
N = int(input())
AC, WA, TLE, RE = 0,0,0,0

for _ in range(N):
    S = input()
    
    if S == 'AC':
        AC += 1
    elif S == 'WA':
        WA += 1
    elif S == 'TLE':
        TLE += 1
    elif S == 'RE':
        RE +=1 
    else:
        continue

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))


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

int main() {
	int n, ans = 0;
	cin >> n;
  	for(int i = 1; i <= n; i++)
    {
      if(9 < i && i < 100) continue;
      if(999 < i && i < 10000) continue;
      if(i == 100000) continue;
      ans++;
    }
	cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	bool result = (a % 2 != 0) && (b % 2 != 0);
	cout << (result ? "Yes" : "No") << endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;
    
    //code
    int a , b , c , d;

    cin >> a >> b >> c >> d;

    int lt = abs(a-c);
    int up = abs(b-d);
    
    string ans = "" , hell = "" , temp = "";

    ans += string(up , 'U');
    ans += string(lt , 'R');

    temp = ans;

    hell = string(up , 'D');
    hell += string(lt , 'L');
    
    ans += hell;
    ans += "LU";
    ans += temp;
    ans += "RD";

    ans += "RD";
    ans += hell;
    ans += "LU";

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n; cin >> n;
    int b[n-1];
    for(int i = 0; i < n-1; i++) cin >> b[i];

    int sum = 0;
    for(int i = 0; i < n-2; i++){
        sum += min(b[i], b[i+1]);
    }
    cout << sum + b[0] + b[n-2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int cnt;
char s[30861], ck[3]="CF";
int main(){
	scanf("%s", s);
	for(int i=0; s[i]&&cnt<2; ++i)
		if(s[i]==ck[cnt]) ++cnt;
	if(cnt==2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  string a,b,c,id;
  cin>>a>>b>>c;
  rev(a);rev(b);rev(c);
  id=a.at(a.size()-1);
  while(1){
  if(id=="a"){
    if(a.empty()){
      ou("A");
      return 0;
    }
    id=a.at(a.size()-1);
    a.pop_back();
  }
  if(id=="b"){
    if(b.empty()){
      ou("B");
      return 0;
    }
    id=b.at(b.size()-1);
    b.pop_back();
  }
  if(id=="c"){
    if(c.empty()){
      ou("C");
      return 0;
    }
    id=c.at(c.size()-1);
    c.pop_back();
  }
  }
}

Measured memory_bytes: 256
n = int(input())
dp = [[0 for _ in range(3)] for _ in range(n+1)]
 
for i in range(n):
    abc = list(map(int, input().split(" ")))
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + abc[j])

print(max(dp[-1]))

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

int Q;

int main() {
  cin >> Q;
  for(int q = 0; q < Q; ++q) {
    long long A, B; cin >> A >> B;
    if(A > B) swap(A, B);
    if(A == B) cout << 2 * (A - 1) << endl;
    else if(A + 1 == B) cout << 2 * (A - 1) << endl;
    else {
      long long C = floorl(sqrtl(1.0L * (A * B - 1)));
      if(C * (C + 1) >= A * B) cout << (A - 1) + (C + C - (A + 1)) << endl;
      else cout << (A - 1) + (C + (C + 1) - (A + 1)) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<vector<int> > edge(n+1);
  vector<int> hairu(n+1, 0);
  REP(i, n-1+m) {
    int a, b; cin >> a >> b;
    edge[a].push_back(b);
    ++hairu[b];
  }
  int root = -1;
  FOR(i, 1, n+1) if (hairu[i] == 0) {
    root = i;
    break;
  }
  vector<int> ans(n+1, -1);
  ans[root] = 0;
  queue<int> que;
  que.push(root);
  while (!que.empty()) {
    int now = que.front(); que.pop();
    for (int v : edge[now]) {
      if (hairu[v] == 1) {
        ans[v] = now;
        que.push(v);
      } else --hairu[v];
    }
  }
  FOR(i, 1, n+1) cout << ans[i] << '\n';
  return 0;
}


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

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

    int min_cost = 1e9;
    int c = 0;
    bool flag = false;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> c >> t;
        if (T >= t && min_cost > c) {
            min_cost = c;
            flag = true;
        }
    }
    if (flag) cout << min_cost << endl;
    else cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>a(n);
for(int i= 0; i< n;i++){
    cin>>a[i];
}
int count=1;
for(int  i =1 ; i <n; i++){
        int p=1;
    for(int  j =0 ; j <i; j++){
        if(a[i] < a[j]){
            p=0;
        }
    }
if(p==1)
    count++;
}

cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,L;cin>>N>>L;
	string ans="",s[105];
	for(int i=0;i<N;++i) cin>>s[i];
	sort(s,s+N);
	for(int i=0;i<N;++i)ans+=s[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

using Graph = vector<vector<int>>;
map<ll, ll> mp;

vector<bool> seen;
void dfs(const Graph &G, int v, int c) {
    seen[v] = true;
    mp[c]++;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v, c);
    }
}

int main() {
    int N, M; cin >> N >> M;

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    seen.assign(N, false);
    int cnt = 0;
    rep(i, N) {
        if(!seen[i]) {
            dfs(G, i, cnt);
            cnt++;
        }
    }
    ll ans = 0;
    for(auto x : mp) chmax(ans, x.second);
    cout << ans << endl;
}


Measured memory_bytes: 29804
#include<bits/stdc++.h>
using namespace std;
int f[100005];
int n,m;
vector<int> a[100005];
//vector<int> a1[100005];
int F(int i)
{
   // cerr<<i<<endl;
    if(f[i]!=-1) return f[i];
    f[i]=0;
    for(int j=0;j<a[i].size();j++)
        f[i]=max(f[i],F(a[i][j])+1);
    return f[i];
}
int main()
{
    cin>>n>>m;
    int x,y;
    while(m--)
        {
            cin>>x>>y;
            a[y].push_back(x);
        }
    memset(f,-1,sizeof(f));
    for(int i=1;i<=n;i++)
        {
            f[i]=0;
            for(int j=0;j<a[i].size();j++)

            {

                f[i]=max(f[i],F(a[i][j])+1);
            }
        }
   // cerr<<f[3]<<endl;
    int res=0;
    for(int i=1;i<=n;i++)
        res=max(res,f[i]);
    cout<<res;

}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

int main(){
  ll A,B,C,D; cin>>A>>B>>C>>D;
  if(A>=D) cout<<0;
  else if(B<=C) cout<<0;
  else{
	cout<<min(B,D)-max(A,C);
  }
}

Measured memory_bytes: 256
s = input()
if s.find("keyence") != -1:
    print("YES")
else:
    cond = False
    for i in range(1,7):
        if s[0:i]+s[-(7-i):] == "keyence":
            cond = True
            print("YES")
            break
    if cond == False:
        print("NO")

Measured memory_bytes: 2940
#include <iostream>
using namespace std;int f[4]={1,0,-1,0},F[4]={0,1,0,-1},I,n,p,x,y,i,j,d[505][505],a,w[505][505];void D(int x,int y){for(int i=0;i<4;++i){int X=x+f[i],Y=y+F[i];if(d[X][Y]>d[x][y]+w[X][Y])d[X][Y]=d[x][y]+w[X][Y],D(X,Y);}}int main(){cin>>n;for(I=0;I<n*n;++I){i=I/n+1,j=I%n+1;w[i][j]=1,d[i][j]=min(min(i,n-i+1),min(j,n-j+1));}for(i=1;i<=n*n;++i){cin>>p;p--;x=p/n+1;y=p%n+1;a+=--d[x][y];w[x][y]=0;D(x,y);}cout<<a<<endl;}

Measured memory_bytes: 20980
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;
int main()
{
int k;
cin>>k;
string s;
cin>>s;
if(s.size()<=k)cout <<s;
else 
{
for(int i=0;i<k;i++)cout <<s[i];
cout <<"...";
}


}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#include "string"

vector<int>preffix(string &s) {
    int n=s.size();
    vector<int>pi(n,0);
    for(int i=1;i<n;i++) {
        int j=pi[i-1];
        while(j>0 and s[i]!=s[j])
            j=pi[j-1];
        if(s[i]==s[j])
            pi[i]=j+1;
    }
    return pi;
}

int kmp(string &t,string &p) {
    vector<int>ans;
    int n=t.size();
    int m=p.size();
    vector<int>pi=preffix(p);
    int j=0;
    for(int i=0;i<n;i++) {
        while(j>0 and t[i]!=p[j])
            j=pi[j-1];
        if(t[i]==p[j]) {
            j++;
            if(j==m){
                ans.push_back(i-j+1);
                j = pi[j-1];
            }
        }
    }
    return ans.size();
}

int solve(string &s,string &t){
	int l=1,r = s.size()/t.size() + 1,ans = -1;

	while(l<=r){
		int m = (l + r)/2;
		string tt = "";
		for(int i=0;i<m;i++)
			tt += t;
		if(kmp(s,tt) > 0){
			ans = m;
			l = m + 1;
		}
		else
			r = m - 1;
	}
	return ans;
}

int32_t main(){
	boost;
	string S,T;
	cin>>S>>T;
	string s = S;
	while(s.size() <= S.size()  + T.size())
		s += S;
	s += S;
	int ans1 = solve(s,T);
	if(ans1 == -1){
		cout<<0<<endl;
		return 0;
	}

	s += s;
	
	int ans2 = solve(s,T);

	if(ans1 != ans2)
		cout<<-1<<endl;
	else
		cout<<ans2<<endl;
}




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

const int N = 1e3+3;
int A[N];
void solve() {
    int n;
    scanf("%d",&n);
    vector<int> pos[2];
    ll sum[2] = {0,0};
    bool allNegative = true;
    for(int i=1;i<=n;++i) {
        scanf("%d",&A[i]);
        int ind = i&1;
        if(A[i]>=0) {
            allNegative = false;
            sum[ind] += A[i];
            pos[ind].push_back(i);
        }
    }
    int ind = 0;
    if(allNegative) {
        int ind =1;
        for(int i=2;i<=n;++i) {
            if(A[ind]<A[i]) {
                ind = i;
            }
        }
        printf("%d\n", A[ind]);
        printf("%d\n", n-1);
        int pos = n;
        for(int i = n;i>ind;--i) {
            printf("%d\n", pos);
            --pos;
        }
        for(int i=1;i<ind;++i) {
            printf("%d\n", 1);
        }
        return;
    }
    if(sum[0]<sum[1] || (sum[0]==sum[1] && pos[0].size()<pos[1].size())){
        ind = 1;
    }
    printf("%lld\n", sum[ind]);
    vector<int> op;
    int l = pos[ind][0],r = pos[ind].back();
    int x = n;
    for(int i = n;i>r;--i) {
        op.push_back(x);
        --x;
    }
    for(int i=1;i<l;++i) {
        op.push_back(1);
    }
    int totalLen = r-l+1;
    int val = 0;
    for(int i=0;i<pos[ind].size()-1;++i) {
        int u = 1, v = pos[ind][i+1]- pos[ind][i]+1;
        while(u<v) {
            op.push_back( (v+u)/2);
            v-=2;
        }
    }
    printf("%d\n", (int)op.size());
    for(int i=0;i<op.size();++i) {
        printf("%d\n", op[i]);
    }
}

int main() {
   //freopen("input.txt","r",stdin);
   solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){//桁数
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){//最小公倍数
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){//最大公約数
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int e=0;
  for(int i=0; i<=a; i++){
    for(int k=0; k<=b; k++){
      for(int j=0; j<=c; j++){
        int d=500*i+100*k+50*j;
        if(x==d)
          ++e;
      }
    }
  }
  cout<<e<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,c,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;




    }

    return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
using namespace std;

const int N = 3*1e5+10;

char s[N];
int root,last,sz,ch[N][26],fa[N],sum[N],l[N];
void add(int x) {
    int c=s[x]-'a';
    int p=last,np=++sz; last=np;
    l[np]=x+1;
    for(;p&&!ch[p][c];p=fa[p]) ch[p][c]=np;
    if(!p) fa[np]=root;
    else {
        int q=ch[p][c];
        if(l[p]+1==l[q]) fa[np]=q;
        else {
            int nq=++sz; l[nq]=l[p]+1;
            memcpy(ch[nq],ch[q],sizeof(ch[q]));
            fa[nq]=fa[q];
            fa[np]=fa[q]=nq;
            for(;p&&q==ch[p][c];p=fa[p]) ch[p][c]=nq;
        }
    }
}

int n,m,b[N],cnt[N];

void get_sum() {
    for(int i=1;i<=sz;i++) cnt[l[i]]++;
    for(int i=1;i<=n;i++) cnt[i]+=cnt[i-1];
    for(int i=1;i<=sz;i++) b[cnt[l[i]]--]=i;
    for(int i=sz;i;i--) {
        int p=b[i]; sum[p]=1;
        for(int j=0;j<26;j++)
            sum[p]+=sum[ch[p][j]];
    }
}

int main() {
    scanf("%s",s);
    n=strlen(s);
    root=last=++sz;
    for(int i=0;i<n;i++) add(i);
    get_sum();
    m=1;
    while(m--) {
        int x,p=root; scanf("%d",&x);
        while(x) {
            for(int c=0;c<26;c++)if(ch[p][c]) {
                if(sum[ch[p][c]]>=x) {
                    putchar('a'+c);
                    x--; p=ch[p][c];
                    break;
                }
                else x-=sum[ch[p][c]];
            }
        }
        puts("");
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int n, k; cin >> n >> k;
  ll dp[n+1][n+1][n*n+1] = {}; dp[0][0][0] = 1;
  repr(i,1,n+1) rep(j,i+1) repr(k,2*j,n*n+1) {
    if (j!=0) dp[i][j][k] += dp[i-1][j-1][k-2*j];
    dp[i][j][k] += dp[i-1][j][k-2*j] * (2*j+1);
    if (j<i) dp[i][j][k] += dp[i-1][j+1][k-2*j] * (j+1) * (j+1);
    dp[i][j][k] %= MOD;
  }
  // debug(dp[n][0],dp[n][0]+n*n+1);
  ll result = dp[n][0][k];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 51072
from functools import reduce
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    print(sum([reduce(mul, (0.5
                            if i << j < K
                            else end_of_loop()
                            for j in range(K)), 1 / N)
               for i in range(1, N + 1)]))
    return


main()


Measured memory_bytes: 6792
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut arr: Vec<usize> = (0..n).map(|_| read()).collect();
    arr.sort();
    let mut ans = 0;
    for i in 0..k {
        ans += arr[i];
    }
    println!("{}", ans);
}


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

int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}


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

int main() {
    int x;
    cin >> x;
    if(400 <= x  && x < 600){
        cout << 8 << endl;
    }
    else if(600 <= x && x < 800){
        cout << 7 << endl;
    }
    else if(800 <= x && x < 1000){
        cout << 6 << endl;
    }
    else if(1000 <= x  && x < 1200){
        cout << 5 << endl;
    }
    else if(1200 <= x && x  < 1400){
        cout << 4 << endl;
    }
    else if(1400 <= x && x  < 1600){
        cout << 3 << endl;
    }
    else if(1600 <= x && x < 1800){
        cout << 2 << endl;
    }
    else if(1800 <= x && x < 2000){
        cout << 1 << endl;
    }
}




Measured memory_bytes: 3628
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	string s;
	cin >> s;
	REP(i, s.size()) if(i%2 == 0) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

    int n = sc.nextInt();
    
    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
        h[i] = sc.nextInt();
    }

    long[] dp = new long[n];
    for (int i = 0; i < dp.length; i++) {
        dp[i] = Long.MAX_VALUE;
    }

    dp[0] = 0;
    dp[1] = Math.abs(h[1] - h[0]);

    for (int i = 2; i < h.length; i++) {
        long p = Math.abs(dp[i-1] + Math.abs(h[i] - h[i-1]));
        long q = Math.abs(dp[i-2] + Math.abs(h[i] - h[i-2]));
        dp[i] = Math.min(dp[i], Math.min(p, q));
    }
    
    System.out.println(dp[n-1]);
  }
}

Measured memory_bytes: 51064
#include<bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define p push
#define p1 pop
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll,ll>
#define e 1000000007
using namespace std;
int main(){
    string s,t;cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1];
    string res="";
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=m;++j)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=n,j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            res+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(res.begin(),res.end());
    cout<<res;
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <utility> // pair make_pair
#include <algorithm>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;
using Graph = vector<pair<int, int> >;


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

  bool A[N];
  memset(A, 0, sizeof(A));
  
  Graph G(K);
  
  for (int i = 0; i < K; i++) {
    int a, b; cin >> a >> b;
    G[i] = make_pair(a, b);
  }

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


  // for (int i = K - 1; i >= 0; i--) {
  //   cout << G[i].first << " " << G[i].second << endl;
  // }

  int cnt = 0;
  
  for (int i = K -1; i >= 0;) {
    int f = G[i].first;
    cnt++;
    while (G[i].second > f) {
      i--;
    }
  }

  cout << cnt << endl;
}


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

#define mx 100005
#define ll long long

int ar[mx];
char ch[mx];

int n,m,sum;

int main()
{
   cin>>n>>m;
   for(int i=1;i<=m;i++)
   {
       cin>>ar[i];
       sum+=ar[i];
   }
   if(sum>n)cout<<-1<<endl;
   else cout<<n-sum<<endl;

    return 0;
}


Measured memory_bytes: 3680