akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

class Sieve
{
private:
    int n;
    vector<int> f, primes;
public:
    Sieve(int n = 1) :n(n), f(n + 1)
    {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool IsPrime(int x) { return f[x] == x; }
    vector<int> PrimeList(int x)
    {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<ll, int>> PrimeFrequency(int x)
    {
        vector<int> fl = PrimeList(x);
        if (fl.size() == 0) return {};
        vector<pair<ll, int>> res(1, pair<ll, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            }
            else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll, int>> PrimeFrequencySelf(ll x)
    {
        vector<pair<ll, int>> res;
        for (int p : primes) {
            int y = 0;
            while (x % p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p, y);
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
};

int main()
{
    ll n;
    cin >> n;
    Sieve sieve(1e6);
    vector<pair<ll, int>> primeFrequency = sieve.PrimeFrequencySelf(n);
    int ans = 0;
    for (auto& item : primeFrequency) {
        int shoulder = 1;
        while (shoulder <= item.second) {
            item.second -= shoulder;
            shoulder++;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e18
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)

vector<int>edge[105];
int n,k;
ll h[105],s[105],mn[105];

bool cmp(const int&a,const int&b){
	return mn[a] < mn[b];
}
int deq[200005];

vector<ll> rec(int v,vector<ll>dp){
	vector<ll>ret = dp, zan;
	ll pre = 0;
	for(int i=0;i<edge[v].size();i++){
		if(h[v] < mn[edge[v][i]]){
			break;
		}
		ll pl = mn[edge[v][i]]-pre;
		pre = mn[edge[v][i]];
		//dp -> [0,...,pl-1] で ret を更新
		//[l,r)
		int l=0,r=0;
		if(pl){
    		for(int i=0;i<=k;i++){
    			while(l<r && dp[deq[r-1]]-1LL*deq[r-1]*s[v] < dp[i]-1LL*i*s[v]){
    				r--;
    			}
    			deq[r++] = i;
    			if(deq[l] <= i-pl) l++;
    			ret[i] = max(ret[i],dp[deq[l]]+1LL*(i-deq[l])*s[v]);
    		}
		}
		zan = rec(edge[v][i],dp);
		for(int i=k;i>=pl;i--){
			zan[i] = zan[i-pl] + s[v] * pl;
		}
		for(int i=0;i<pl;i++){
			zan[i] = -INF;
		}
		dp = zan;
	}
	ll pl = h[v]-pre; //cout << pl << "n" << endl;
	//dp -> [0,...pl]で ret を更新
	//[l,r)
	int l=0,r=0;
	for(int i=0;i<=k;i++){
		while(l<r && dp[deq[r-1]]-1LL*deq[r-1]*s[v] < dp[i]-1LL*i*s[v]){
    		r--;
    	}
    	deq[r++] = i;
    	if(deq[l] < i-pl) l++;
    	ret[i] = max(ret[i],dp[deq[l]]+1LL*(i-deq[l])*s[v]);
    }
    //cout << v << " " << endl;
    //rep(i,k+1) cout << i << " " << ret[i] << endl;
	return ret;
}
int main(){
	while(1){
		cin >> n >> k;
		if(n == 0) return 0;
		for(int i=1;i<=n;i++){
			edge[i].clear();
		}
		repn(i,n){
			cin >> h[i];
			h[i] = min(h[i],1LL*k);
		}
		repn(i,n) cin >> s[i];
		for(int i=2;i<=n;i++){
			int p; cin >> p; edge[p].pb(i);
		}
		for(int i=2;i<=n;i++){
			cin >> mn[i]; //cout << mn[i] << " " << k << endl;
			mn[i] = min(mn[i],1LL*k);
		}
		for(int i=1;i<=n;i++) sort(edge[i].begin(),edge[i].end(),cmp);
		vector<ll>val;
		val.push_back(0);
		for(int i=0;i<k;i++) val.push_back(-INF);
		auto ret = rec(1,val);
		ll ans = -INF;
		rep(i,ret.size()) ans = max(ans,ret[i]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 160616
from functools import reduce

MOD = 1000000007

def comb(n, r):
    if n < 0 or r < 0 or r > n:
        return 0
    r = min(r, n - r)
    if r == 0: return 1

    numer = [n - r + i + 1 for i in range(r)]
    denom = [i + 1 for i in range(r)]

    for i in range(1, r):
        divisor = denom[i]
        if divisor > 1:
            offset = (n - r) % (i + 1)
            for j in range(i, r, i+1):
                numer[j - offset] //= divisor
                denom[j] //= divisor

    res = 1
    for i in range(r):
        if numer[i] > 1:
            res *= numer[i]
    return res

    # return reduce(lambda x, y: x*y if y > 1 else x, numer)

def main():
    x, y = map(int, input().split())
    ans = 0
    if (x+y)%3==0 and x <= 2*y <= 4*x:
        n = (x + y) // 3
        r = y - n
        ans = comb(n, r) % MOD
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 30012
nums = [int(e) for e in input().split()]
current = nums[0]
num = nums[1]
move = nums[2]


current = abs(current)

res = current // move

if res >= num:
    print(current - move*num)
else:
    current = current - move * res
    num -= res
    if num%2 == 0:
        print(current)
    else:
        print(abs(current-move))


Measured memory_bytes: 9112
N, M = list(map(int, input().split()))
ken = [[] for _ in range(N)]

mlist = []
for i in range(M):
    a, b = list(map(int, input().split()))
    ken[a - 1].append(b)
    mlist.append((a, b,))

for v in ken:
    v.sort()


def search(v, lst):
    l, r = 0, len(lst) - 1
    while l <= r:
        m = (l + r) // 2
        if lst[m] == v:
            return m

        if lst[m] < v:
            l = m + 1
        else:
            r = m - 1
    return None


for a, b in mlist:
    print("{:06d}{:06d}".format(a, search(b,ken[a - 1]) + 1))


Measured memory_bytes: 35796
#include<iostream>
#include<string.h>
using namespace std;
string s;
char a,b,c;
int main()
{
	cin>>s;
	a=s[0];
	cin>>s;
	b=s[0];
	cin>>s;
	c=s[0];
	cout<<a<<b<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int alpha[26]={};
  int i;
  while(cin>>str){
    for(i=0;i<str.size();i++){
      if(str[i]>='a'&&str[i]<='z') alpha[str[i]-'a']++;
      else if(str[i]>='A'&&str[i]<='Z') alpha[str[i]-'A']++;
    }
  }
  for(i=0;i<26;i++){
    cout << (char)('a'+i) << " : " << alpha[i] << endl;
  }
  return 0;
}



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

int main(void)
{
	int m, f, r;
	int sum;
	char rank;
	
	while (1){
		cin >> m >> f >> r;
		if (m != -1 && f != -1){
			sum = m + f;
		}
		else if (m == -1 && f == -1){
			break;
		}
		else {
			sum = 0;
		}
		
		if (sum >= 80){
			rank = 'A';
		}
		else if (sum >= 65){
			rank = 'B';
		}
		else if (sum >= 50){
			rank = 'C';
		}
		else if (sum >= 30){
			rank = 'D';
			if (r >= 50){
				rank = 'C';
			}
		}
		else {
			rank = 'F';
		}
		
		cout << rank << endl;
	}
	
	return (0);
}

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

int main() {
	
	string sa, sb, sc; cin >> sa >> sb >> sc;
	string ans;
	int a_index = 0;
	int b_index = 0;
	int c_index = 0;
	char now = 'a';
	while (true) {		
		if (now == 'a') {
			if (a_index == sa.size()) {
				ans = "A";
				break;
			}
			now = sa[a_index];
			a_index++;		
		}
		else if (now == 'b') {
			if (b_index == sb.size()) {
				ans = "B";
				break;
			}
			now = sb[b_index];
			b_index++;		
		}
		else {			
			if (c_index == sc.size()) {
				ans = "C";
				break;
			}
			now = sc[c_index];
			c_index++;		
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int n;
vector<vector<int>> g;
vector<short> vis;
vector<int> ans;

void dfs(int v) {
    vis[v] = 1;
    for (int u : g[v]) {
        if (!vis[u]) {
            dfs(u);
        }
    }
}

void bfs(int v) {
    queue<pair<int, int>> q;
    q.push({v, 0});
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        v = p.x;
        ans[p.y]++;
        for (int u : g[v]) {
            if (!vis[u]) {
                vis[u] = 1;
                q.push({u, p.y+1});
            }
        }
    }
}

int main() {
    int x, y;
    cin >> n >> x >> y;
    g = vector<vector<int>>(n);
    fr(i, n-1) {
        g[i].pb(i+1);
        g[i+1].pb(i);
    }
    --x, --y;
    g[x].pb(y);
    g[y].pb(x);

    ans.assign(n+1, 0);
    fr(i, n) {
        vis = vector<short>(n);
        vis[i] = 1;
        bfs(i);
    }

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

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <algorithm>
int W,a,b;

int main(void){
    std::cin >> W >> a >> b;
    if(a+W < b){
        std::cout << std::abs(b-a-W);
    }else if(b+W < a){
        std::cout << std::abs(a-b-W);
    }else{
        std::cout << 0;
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
/*
v[1] ^ v[2] ^ v[3] = 0
v[2] ^ v[3] ^ v[4] = 0
=> v[1] ^ v[4] = 0
=> if n is not divisible by 3 all elements should be equal
*/
int const nmax = 100000;
std::map<int,int> frec;
int v[5 + nmax];

int main() {
  int n;
  std::cin >> n;
  for(int i = 1; i <= n; i++) 
    std::cin >> v[i];
  for(int i = 1;i <= n; i++)
    frec[v[i]]++;
  int verdict = 1;
  if(0 < (n % 3)) {
    verdict = (frec[v[1]] == n);
    if(0 < v[1])
      verdict = 0;
  } else {
    int total = 0;
    for(int i = 1;i <= n; i++) { 
      if(0 < (frec[v[i]] % (n / 3))) 
        verdict = 0;
      else if(0 < frec[v[i]]) {
        total ^= v[i];
        frec[v[i]] -= n / 3;
      }
    }
    if(0 < total)
      verdict = 0;
  }
  if(verdict == 1)
    std::cout << "Yes";
  else
    std::cout << "No";

  return 0;
}


Measured memory_bytes: 7464
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
#define dbg(x)                cerr <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////
const int nax = 1e5 + 10;
bool isvisited[nax];
int dist[nax];
int in_degree[nax];
vector<int> graph[nax];

void dfs(int node){

	assert(!isvisited[node]);
	isvisited[node]=true;
	for(auto i : graph[node]){
		dist[i]=max(dist[i], dist[node]+1);
		--in_degree[i];
		
		// if indegree 0 then call dfs
		if(in_degree[i]==0 ){
			dfs(i);
		}
	}
	
	
}

int main()
{
	int node, edge;
	scanf("%d%d",&node, &edge);
	
	//reading graph...
	for(int i=0; i< edge ; i++){
		int u, v; 
		scanf("%d%d",&u,&v);
		graph[u].emplace_back(v);
		++in_degree[v];
	}
	// calling dfs...
	
	for(int i=1; i<= node; i++){
		if(!isvisited[i] && !in_degree[i])
			dfs(i);
	}
	
	int ans=0;
	// maximum dist[.] will be the answer...
	for(int i=1 ; i<= node ; i++)
		ans= max(ans, dist[i]);
	
	printf("%d\n",ans);
    return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


Measured memory_bytes: 9728
// 参考: https://qiita.com/kuuso1/items/606b75c172cafa1d07f6

open System

let inputArray = stdin.ReadLine().Split(' ') |> Array.map int
let a = inputArray.[0]
let b = inputArray.[1]

let f a b = if (b % a) = 0 then a + b else b - a

f a b |> printfn "%d"

Measured memory_bytes: 11992
#include<stdio.h>

int max(int a,int b){
    return ((a > b) ? a : b);
}

int main(void){

    int N,i,B[99],A[100],ans = 0;

    scanf("%d",&N);
    for(i = 0;i < N-1;i++){
        scanf("%d",&B[i]);
    }

    A[0] = B[0];

    for(i = 0;i < N - 1;i++){
        A[i + 1] = B[i];
        if(max(A[i],A[i + 1]) != B[i]){
            A[i] = B[i];
        }
    }

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

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

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


int main() {
        bool ans = true;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(), a.end());
    rep(i,n-1) {
        if(a.at(i) == a.at(i+1)) ans = false;
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/

vi adj[MXN];


int main(){
	FASTIO
	
	int n;
	cin >> n;
	int a[n+4];
	for (int i = 2; i <= n; ++i) {
		cin >> a[i];
	}
	
	for (int i = 2; i <= n; ++i) {
		adj[i].push_back (a[i]);
		adj[a[i]].push_back (i);
	}
	
	for (int i = 1; i <= n; ++i) {
		cout << (i == 1 ? adj[i].size() : adj[i].size() - 1) << endl;
	}
    return 0;
}

/*

*/


Measured memory_bytes: 16004
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  string a,b,c;
  cin >> a >> b >> c;
  char next = 'a';
  while(true){
    if(next=='a'){
      if(a==""){
      cout << 'A' << endl;
      return 0;
      }
      next = a[0];
      a.erase(a.begin());
    }
    if(next=='b'){
      if(b==""){
      cout << 'B' << endl;
      return 0;
    }
      next = b[0];
      b.erase(b.begin());
    }
    if(next=='c'){
      if(c==""){
      cout << 'C' << endl;
      return 0;
    }
      next = c[0];
      c.erase(c.begin());
    }
    
    
    
  }
      
}


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

main() {
  int a,b,c=0;
  cin >> a >> b;
  for(a;a <=b; a++) {
    if(a/10000%10 == a%10 &&  a/1000%10  == a/10%10) {
      c += 1;
    }
  }
  cout << c <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  k -= 1;
  int n = s.length();
  int ind = -1;
  rep (i, n) {
    if (s[i] != '1') {
      ind = i;
      break;
    }
  }
  if (ind == -1 || k < ind) {
    printf("1\n");
    return 0;
  }
  printf("%c\n", s[ind]);
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main()
{
    long long int a,c;
    char s;

    while     (scanf("%lld %c %lld",&a,&s,&c) != EOF)


    {
        switch(s)
        {
        case '+':
            printf("%lld\n",a+c);
            break;
        case '-' :
            printf("%lld\n",a-c);
            break;
        }
    }
    return 0;

}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  string ans = "YES";
  if(a+b+c!=17) ans="NO";
  if(a*b*c!=175) ans="NO";
  if(a*b+b*c+c*a!=95) ans="NO";
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if(A>B){
        cout << A + max(A-1,B) << endl;
    }
    else if (A<B){
        cout << B + max(A,B-1) << endl;
    }
    else {
        cout << A + B << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int r;
	cin >> r;

	cout << r * r << endl;


	return 0;

}

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

if N == 0:
  print(X)
else:
  P = sorted(list(map(int, input().split())))
  ans = X
  for i in range(101):
    if X - i not in P:
      ans = X - i
      break
    else:
      if X + i not in P:
        ans = X + i
        break
      
  print(ans)

Measured memory_bytes: 9188
#include<stdio.h>
#include<stdlib.h>
#include<queue>
using namespace std;
int N,i,t,r=-2000000000,A[200005];
int main()
{
	priority_queue<int>Q;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	Q.push(A[N-1]);
	for(i=N-2;i>=0;i--)
	{
		r=Q.top()-A[i]>r?Q.top()-A[i]:r;
		Q.push(A[i]);
	}
	printf("%d\n",r);
	return 0;
}

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

int main(){
  int a;
  cin >> a;
  int ans=0;
  for(int i=105;i<=a;i+=2){
    int c=0;
    for(int j=1;j<=sqrt(i);j++){
      if(i%j == 0) c++;
    }
    if(c == 4) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b.at(i);
  int c=1;
  int e=0;
  rep1(i,a){
    if(c==2){
    cout<<e<<endl;
    break;
    }
    
    c=b.at(c-1);
    e++;
      if(i==a){
        cout<<-1<<endl;
      }
  }
      
}

Measured memory_bytes: 1024
<?php

main();

function main() {
	while(($n = trim(fgets(STDIN))) != -1) {
		$hunter = new TreasureHunter(1, 0);
		$hunter->findTreasure($n);
	}

}

class TreasureHunter {

	/**
	 *
	 * @var Point $p
	 */
	public $p;

	public function __construct($x, $y) {
		$this->p = new Point($x, $y);
	}

	public function step() {
		$this->p->toWill();
		$this->p->rotateR();
		$this->p->move();
		//echo $this->p;
	}

	public function findTreasure($n) {
		for ($i = 0; $i < $n - 1; $i++) {
			$this->step();
		}
		$this->sayPosition();
	}

	public function sayPosition() {
		echo $this->p->x . "\n";
		echo $this->p->y . "\n";
	}

}

class Point {
	public $x;
	public $y;
	public $vx;
	public $vy;

	public function __construct($x, $y) {
		$this->x = $x;
		$this->y = $y;
	}

	public function rotateR() {
		$vx = $this->vx;
		$vy = $this->vy;
		$this->vx = $vy;
		$this->vy = -$vx;
	}

	public function toWill() {
		$this->vx = -$this->x;
		$this->vy = -$this->y;
		$this->normalize();
	}

	public function move() {
		$this->x += $this->vx;
		$this->y += $this->vy;
	}

	private function normalize() {
		$v = $this->v();
		if ($v == 0) {
			$this->vx = 1;
			$this->vy = 0;
			return;
		}
		$this->vx /= $v;
		$this->vy /= $v;
	}

	private function v() {
		return sqrt($this->vx * $this->vx + $this->vy * $this->vy);
	}

	public function __toString() {
		return "(x, y, vx, vy) = ({$this->x}, {$this->y}, {$this->vx}, {$this->vy})\n";
	}
}

Measured memory_bytes: 6672
import java.io.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        String s[]=bu.readLine().split(" ");
        int i,a[]=new int[n];
        long sum=0,res=0,M=1000000007;
        for(i=0;i<n;i++)
        {
            a[i]=Integer.parseInt(s[i]);
            sum+=a[i];
        }

        for(i=0;i<n;i++)
        {
            sum-=a[i];
            res+=sum%M*a[i]%M;
            res%=M;
        }
        System.out.print(res);
    }
}


Measured memory_bytes: 61280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringBuilder s = new StringBuilder(br.readLine());
		s.append(s);
		
		String p = br.readLine();
		if (s.indexOf(p) == -1) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}

Measured memory_bytes: 24448
object Main extends App {

  import scala.io.StdIn._
  import scala.math.{abs, min}
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val population: Array[Array[Int]] = Array.tabulate(h){ _ ⇒ readLine.trim.split(' ').map(_.toInt)}
  println(
    (0 until h).flatMap{y ⇒ (0 until w).map{x ⇒ sumDistance(y, x, population)}}.min
  )
  def sumDistance(h: Int, w: Int, population: Array[Array[Int]]): Int = {
    population.indices.map{y ⇒
      population(y).indices.map{x ⇒
        population(y)(x) * min(abs(h - y), abs(w - x))
      }.sum
    }.sum
  }
}



Measured memory_bytes: 69936
<?php
/*
# 整数の入力
fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $b, $c);
# 文字列の入力
fscanf(STDIN, "%s", $s);
*/
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%d", $e);

$minutes = ['A' => $a, 'B' => $b, 'C' => $c, 'D' => $d, 'E' => $e];

$minKey = null;
$minVal = null;
foreach ($minutes as $key => $minute) {
    $mod = $minute % 10;
    if ($mod === 0) { $mod = 10; }

    if ($minKey === null || $minVal > $mod) {
        $minKey = $key;
        $minVal = $mod;
    }
}

$sum = 0;
foreach ($minutes as $key => $minute) {
    $orderTime =  toOrderTime($minute);
    if ($key === $minKey) {
        $sum += $minute;
    } else {
        $sum += $orderTime;
    }
}
echo $sum;

function toOrderTime($minute) {
    $mod = $minute % 10;
    if ($mod === 0) {
        return $minute;
    } else {
        return $minute + 10 - $mod;;
    }
}


?>


Measured memory_bytes: 4728
#include<stdio.h>
#include<string.h>
int main(){
int a,b,c,k;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&k);
int i,r=0;

for(i=1; i<=k; i++){
    if(i<=a) r++;
　　else if(i<=(a+b)) r+=0;
    else r--;
     }
 printf("%d",r );   
      
return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef unsigned long long ll;

const int mxp = 18;
ll L,A,B;
ll MOD;
ll tp[20];//powers of ten

/*

given L, A, B, M
which (L,A,B) is an arith progression A, A+B..., A+(L-1)B
find concat(A A+B A+2B .. A+(L-1)B) % M

1. find out how many steps to next magnitude

2. speed up the concat in current magnitude using matrix power

*/

ll mg(ll x)
{
    if(x==0)return 1;
    ll rtn = 0;
    while(x)
    {
        x/=10;
        rtn++;
    }
    return rtn;
}

//==========vvvv====matrix template====vvvv===============

ll SZ=3;//=3 in this problem
const int MAXSZ=5;

struct Mat
{
    ll m[MAXSZ][MAXSZ];
    Mat(){memset(m, 0, sizeof(m));}
};

Mat matMul(const Mat &A, const Mat &B)
{
    Mat rtn;
    for(int i = 0; i < SZ; i++)
        for(int k = 0; k < SZ; k++)
            if(A.m[i][k])for(int j = 0; j < SZ; j++)
            {
                rtn.m[i][j]=(rtn.m[i][j]+(A.m[i][k]*B.m[k][j]))%MOD;
            }
    return rtn;
}

//B is of size SZ
vector<ll> matMul(const Mat &A, const vector<ll> &B)
{
    vector<ll> rtn(SZ,0);
    for(int i = 0; i < SZ; i++)
        for(int j = 0; j < SZ; j++)
            rtn[i]=(rtn[i]+A.m[i][j]*B[j])%MOD;

    return rtn;
}

Mat matPow(Mat& M, ll p)
{
    if(p == 0)
    {
        Mat iden;
        for(int i=0;i<SZ;i++)iden.m[i][i]=1;
        return iden;
    }
    if(p == 1)return M;
    Mat rtn = matPow(M, p/2);
    if(p&1)return matMul(matMul(rtn, rtn), M);
    else return matMul(rtn, rtn);
}

//==========^^^^====matrix template====^^^^===============

void init()
{
    cin>>L>>A>>B>>MOD;

    SZ=3;

    tp[0]=1;
    FOR(i,1,mxp)tp[i]=tp[i-1]*10;
}

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

    init();

    if(L==1)
    {
        cout<<A%MOD<<'\n';
        return 0;
    }

    ll cur = A;
    ll val = cur%MOD;
    ll stp = L-1;

    while(stp)
    {
        //find end term in this mag
        ll mgi = mg(cur+B);
        ll p = (tp[mgi]-cur)/B;
        if( (tp[mgi]-cur)%B==0 )p--;
        p = min( stp, p );
        stp-=p;

        vector<ll> MA(3);
        MA[0]=val;
        MA[1]=(cur+B)%MOD;
        MA[2]=B%MOD;

        Mat T;
        T.m[0][0]=tp[mgi]%MOD;
        T.m[0][1]=1;

        T.m[1][1]=T.m[1][2]=1;

        T.m[2][2]=1;

        T = matPow(T,p);
        MA = matMul(T,MA);

        val=MA[0];
        cur=cur+p*B;
    }

    cout<<val<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c; 
  cin >>a>>b>>c; 
  int t; 
  if(a>b){  
    t=a;
    a=b;
    b=t;
    }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  cout<<a<<" "<<b<<" "<<c<<endl;
 return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<map>
#include<queue>
#include<functional>
using namespace std;


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

	if (N == 1 && M == 1)cout << 1 << endl;
	else if (N == 1)cout << M - 2 << endl;
	else if (M == 1)cout << N - 2 << endl;
	else cout << (N - 2) * (M - 2) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define P pair<int,int>
#define FF first
#define SS second
#define pb push_back
#define f(i,s,n) for(int i=s; i<n; i++)
#define fb(i,s,n) for(int i=s; i>=n; i--)
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007;

int main()
{
    FAST;
  	int n,k,cnt=0;
  	cin >> n >> k;
  	f(i,0,n)
    {
      	int a;
      	cin >> a;
      	if(a>=k) cnt++;
    }
  	cout << cnt << endl;
  	return 0;
}

Measured memory_bytes: 256
/*
lakshaygpt28
Lakshay Gupta
*/

#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;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

vll a;

int main() {
    fast_io();
    ll l, r;
    cin >> l >> r;
    for (ll i = l; i <= min(r, l + 2019); i++) {
        a.eb(i % 2019);
    }
    sort(all(a));
    ll ans = INF;
    for (ll i = 0; i < a.size(); i++) {
        for (ll j = i + 1; j < a.size(); j++) {
            ans = min((a[i] * a[j]) % 2019, ans);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#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;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int n,m,k;
const int mxN=6;
char arr[mxN][mxN];

int findCnt(int first,int second) {
    int cnt=0;
    F0R(i,n) {
        if((first>>i)&1)
            continue;
        F0R(j,m) {
            if((second>>j)&1)
                continue;
            if(arr[i][j]=='#')
                cnt++;
        }
    }
    return cnt;
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k;
    F0R(i,n) {
        F0R(j,m)
            cin >> arr[i][j];
    }
    int cnt=0;
    for(int i=0; i<(1<<n); i++) {
        for(int j=0; j<(1<<m); j++) {
            if(findCnt(i,j)==k)
                cnt++;
        }
    }
    cout << cnt;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using std::cin;
using std::cout;

int main(){
  int n;
  cin >> n;
  int* N = new int[n];
  for(int i = 0 ;i<n;++i){
    int tmp;
    cin >> tmp;
    N[tmp-1] = i+1;
  }
  for(int i = 0;i<n;++i){
    cout << N[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  vector<int>dp(3030);
  vector<int>change(3);
  change[0]=r,change[1]=g,change[2]=b;
  dp[0]=1;
  for(int i=0;i<3;i++){
  	for(int j=change[i];j<=n;j++){
  		dp[j]+=dp[j-change[i]];
  	}
  }
  cout<<dp[n]<<endl;
}







Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i,j,k,n;
  int c,v,vsum = 0;
  int csum = 0,cnt = 0;

  while(scanf("%d,%d",&v,&c) != EOF){
    csum += c; vsum += (v * c); cnt++;
  }
  printf("%d\n",vsum);
  printf("%d\n", (int)(csum/(double)cnt+0.5));

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll sum(ll n){
    ll ret = n * (n+1)/2;
    return ret;
}

int main(){
    int n;
    cin >> n;
    ll ans = 0;

    for(ll i = 1; i <= n;i++){
        ans += i*sum(n/i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
struct Train{
    int city[2];
    int fee;
    int time;
};
struct City{
    int silver;
    int time;
    vector<int> trainnum;
};
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    ll s;cin>>s;
    vector<Train> train(m);
    vector<City> city(n);
    For(i,0,m){
        cin >> train[i].city[0] >> train[i].city[1] >> train[i].fee >> train[i].time;
        train[i].city[0]--;
        train[i].city[1]--;
        city[train[i].city[0]].trainnum.push_back(i);
        city[train[i].city[1]].trainnum.push_back(i);
    }
    For(i,0,n){
        cin >> city[i].silver >> city[i].time;
    }

    vector<vector<ll>> dp(n,vector<ll> (51*n,1e18));//都市iに、銀貨j枚以上を持った状態で居るためにかかる最小時間
    For(j,0,51*n){
        if(j<=s) dp[0][j]=0;//最初
        else dp[0][j]=(j-s+city[0].silver-1)/city[0].silver*city[0].time;//都市0で全部交換する
    }
    queue<int> que;//from地点から更新
    que.push(0);
    while(!que.empty()){
        int from=que.front();
        que.pop();
        for(auto j:city[from].trainnum){//乗れる電車全部に対して
            int to = train[j].city[0]+train[j].city[1]-from;//行き先
            bool flag=false;
            for(int num=train[j].fee;num<51*n;num++){
                if(dp[to][num-train[j].fee]>dp[from][num]+train[j].time){//どこか一箇所でも更新があるか
                    dp[to][num-train[j].fee]=dp[from][num]+train[j].time;
                    flag=true;
                }
            }
            if(flag) {//更新があったら
            	for(int i=0;i<51*n;i++){
                	if(i+city[to].silver<51*n) dp[to][i+city[to].silver]=min(dp[to][i+city[to].silver],dp[to][i]+city[to].time);
            	}//行き先で銀貨を買う会
             	que.push(to);//行き先からまた出発
            }
        }
    }
    For(i,1,n){
        ll ans=1e18;
        For(j,0,51*n){
            ans=min(ans,dp[i][j]);
        }
        cout<<ans<<endl;
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	rep(i, n){
		int ai = -1;
		int mi = i%2;
		if(s.at(i) == 'g'){
			ai = 0;
		}else{
			ai = 1;
		}
		if(mi > ai){
			ans++;
		}else if(mi < ai){
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n;
  cin >> n;
  if (n<1000) {
    cout << "ABC" << "\n";
  }
  if (n>=1000) {
    cout << "ABD" << "\n";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               ll n;
               cin>>n;

               string ans ;
               while(n>0)
               {
                    n--;
                    ans.pb('a'+n%26);
                    n/=26;
               }
               reverse(ans.begin(),ans.end());
               cout<<ans;
       }
}


Measured memory_bytes: 3600
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>

using namespace std;

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

#define COST(p) ((p).first)
#define LR(p) ((p).second.first)
#define X(p) ((p).second.second.first)
#define Y(p) ((p).second.second.second)
#define PI(c,l,x,y) (make_pair(c,make_pair(l,make_pair(x,y))))
#define L (0)
#define R (1)

int main(){
  int w,h;
  while(cin>>w>>h, w+h){
    int s[h][w];
    priority_queue<pi,vector<pi>,greater<pi> > q;
    int memo[2][h][w];
    memset(memo,-1,sizeof(memo));
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        char c; cin>>c;
        switch(c){
        case 'T':
          s[i][j]=0;
          break;
        case 'S':
          q.push(PI(0,L,j,i)); memo[L][i][j]=0;
          q.push(PI(0,R,j,i)); memo[R][i][j]=0;
        case 'X':
          s[i][j]='X';
          break;
        default:
          s[i][j]=c-'0';
          break;
        }
      }
    }
    const int dx[] = { 3, 2, 2, 2, 1, 1, 1, 1, 1};
    const int dy[] = { 0, 1, 0,-1, 2, 1, 0,-1,-2};
#define OK(x,y,w,h) (x>=0&&y>=0&&x<w&&y<h)
    while(q.size()){
      pi p = q.top(); q.pop();
      int c =COST(p), x = X(p), y = Y(p);
      int lr = LR(p), nlr = (lr==0?1:0);
      /*
      cout << x << "," << y <<  " " << (lr==0?'L':'R') <<endl;
      for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
          printf("%3d ",memo[0][i][j]);
        }
        printf(" || ");
        for(int j=0; j<w; j++){
          printf("%3d ",memo[1][i][j]);
        }
        printf(" || ");
        for(int j=0; j<w; j++){
          printf("%3d ",s[i][j]);
        }
        puts("");
      }
      puts("");
      */
      if(s[y][x]==0){
        cout << c << endl;
        break;
      }
      for(int i=0; i<9; i++){
        int xx,yy=y+dy[i];
        if(lr==L)
          xx = x+dx[i];
        else
          xx = x-dx[i];
        //cout << " " <<  xx << "," << yy << endl;
        if(OK(xx,yy,w,h)&&(s[yy][xx]!='X')&&(memo[nlr][yy][xx]==-1)){
          memo[nlr][yy][xx]= c + s[yy][xx];
          q.push(PI(c+s[yy][xx],nlr,xx,yy));
        }
      }
      if(q.empty()){
        cout << "-1" << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 944
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

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

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

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

    cout << a[N - 1] - a[0] << endl;
}


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

return 0;
}


Measured memory_bytes: 3628
import numpy as np

N = int(input())
Alist = list(map(int,input().split()))

#ans = np.prod(Alist)
Alist.sort()
ans = 1
for i in range(N):
  #print (Alist[i])
  ans*= Alist[i]
  if Alist[i]==0:
    break
  if ans >10**18:
    break

if ans >10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 39700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n); for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
using veci = vector<int>;
using vecl = vector<long long>;
using vecd = vector<double>;
using vecs = vector<string>;
int main(){//文字列の大きさで分岐し、以上なら最初の分だけ回す
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (s.size() <= n){
    cout << s << endl;
  }
  else{
    rep(i, n){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int t[101000];
int val[101000],b[101000],c[101000],k2=0;
int h[101000],nxt[201000],K=0,to[201000];
void ins(int u,int v){nxt[++K]=h[u];h[u]=K;to[K]=v;}
int Min;
void dfs(int x,int o)
{
	t[x]=o;Min=min(Min,val[x]);c[++k2]=x;
	for(int i=h[x];i;i=nxt[i])if(!t[to[i]])dfs(to[i],o);
}
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&val[i]);
	for(int i=1;i<=m;i++)
	{
		int u,v;scanf("%d%d",&u,&v);u++;v++;ins(u,v);ins(v,u);
	}
	int cnt=0,s=0;long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!t[i])
		{
			Min=1e9;k2=0;
			dfs(i,++s);
			for(int j=1;j<=k2;j++)if(val[c[j]]==Min){ans+=Min;Min=1e9;}else b[++cnt]=val[c[j]];
		}
	}
	if(s==1)return 0*puts("0");
	int lst=(s-1)*2-s;
	sort(b+1,b+cnt+1);
	if(lst>cnt)return 0*puts("Impossible");
	for(int i=1;i<=lst;i++)ans+=b[i];
	printf("%lld",ans);return 0;
 } 

Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main ()
{
	int a,b,c;
	cin >> a >> b >> c;
	if ( a>b )
		swap (a,b);
	if ( b>c )
		swap (b,c);
	if ( a>b )
		swap (a,b);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int a = 0, b = 0;
    rep(i,8){
        int inp;
        cin >> inp;
        if(i < 4){
            a += inp;
        }else{
            b += inp;
        }
    }
    cout << max(a,b) << endl;
}

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

int main(){
	while(1){
		
		int n;
		double m = 0,a1 = 0,a2 = 0;
		
		cin >> n;
		if(n == 0) break;
		double *s = new double [n];
		for(int i = 0;i < n;i++){
		s[i] = 0;
		}
		for(int i = 0;i < n;i++){
			cin >> s[i];
		}
		
		for(int i = 0;i < n;i++){
			m += s[i];
		}
		m = m / n;
		for(int i = 0;i < n;i++){
			a2 += pow(s[i] - m,2);
		}
		a1 = sqrt(a2 / n);
		delete[] s;
		printf("%f\n",a1);
	}
	return 0;
}

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

int main()
{
  int n;
  bool key = true;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    if (s == "Y")
    {
      key = false;
      cout << "Four" << endl;
      break;
    }
  }
  if (key)
  {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3532
from collections import Counter

S = input()
T = input()


S_count = Counter(S)
T_count = Counter(T)

S_number = sorted(S_count.values())
T_number = sorted(T_count.values())

flag = True

if len(S_number) != len(T_number):
    flag = False
else:
    for i in range(len(S_number)):
        if S_number[i] != T_number[i]:
            flag = False
        
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//宣言文
		//標準入力オブジェクトを生成
		Scanner sc = new Scanner(System.in);
		//標準入力で以下の変数を初期化
		int numberN = sc.nextInt();
		int numberSum =  digitSum(numberN);

		//標準出力 ハージャッド数ならば”YES”　違えば　”NO”
		if(numberN % numberSum  == 0) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
	}

	//標準入力Nを桁毎に合計し和を返す。
	private static int digitSum(int num) {

		int sum = 0;
		while(num > 0) {
			 sum += num % 10;
			 num /= 10;
		}
		return sum;
	}
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int  n, m;
    cin >> n >> m;
    vector<ll> x(m);
    rep(i, m) cin >> x[i];

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

    vector<ll> A(m, 0);
    for(int i = 1; i < m; i++){
        A[i] = x[i] - x[i - 1];
    }

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

    ll ans = 0;
    for(int i = 0; i < m - n + 1; i++){
        ans += A[i];
    }

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

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

int main() {
  int i;
  char x,y,z,w;
  cin >> x >> y >> z >> w;
  if(x =='Y' && y == 'A' && z == 'K' && w == 'I') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}     
    

Measured memory_bytes: 256