akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
using namespace std;
int main () {
	int n;
	while (cin >> n, n) {
		int lo = 0, hi = 0, sum = 0, count = 0;
		while (hi < n) {
			if (sum < n) {
				hi++;
				sum += hi;
			}
			else if (sum > n) {
				sum -= lo;
				lo++;
			}
			else {
				count++;
				hi++;
				sum += hi;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
const int MOD = 998244353;
int cnt[3];

int main() 
{
	int n; scanf("%d ", &n);
	long long res = 1;
	for (int i = 0; i < 3 * n; ++i)
	{
		char c = getchar();
		int x = (++c ^ 64) / 8;
		int y = x ? x - 1 : 2;
		int z = y ? y - 1 : 2;
		if (cnt[y] > cnt[z])
			std::swap(y, z);
		if (cnt[x] < cnt[y]) 
		{
			res = res * (cnt[y] - cnt[x]++) % MOD;
			continue;
		}
		if (cnt[x] < cnt[z]) 
		{
			res = res * (cnt[z] - cnt[x]++) % MOD;
			continue;
		}
		res = res * ++cnt[x] % MOD;
	}
	printf("%lld\n", res);
}

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

int main() {
	long long X;
	cin >> X;
	long long num = 100;

	int count = 0;
	while (true) {
		num = (long long)(num * 1.01);
		count++;
		if (num >= X)break;
	}

	cout << count;
}

Measured memory_bytes: 3632
using System;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            int h = S / 3600;
            int m = ( S % 3600 ) / 60;
            int s = S - ( h * 3600 + m * 60 );
            Console.WriteLine(h + ":" + m + ":" + s);
         }
     }
    
}

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
void solve()
{
  unsigned long long int n;
  cin>>n;
  unsigned long long int a[n];
  unsigned long long int i=0;
  for(i=0;i<n;i++)
    cin>>a[i];
  for(i=0; i<n;i++)
  {
    if(a[i]==0){
      cout<<0;
      return;
    }
  }
  unsigned long long int t=1;
  for(i=0;i<n;i++)
  {
    t*=a[i];
    unsigned long long int b=(unsigned long long int)(1e18)/t;
    //cout<<t<<endl;
    if(i+1<n && a[i+1]>b){
      cout<<-1;
      return;
    }
  }
  cout<<t;
}

int main()
{
  solve();
}

Measured memory_bytes: 4420
import java.util.*;
	public class Main {

		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			char[] a = sc.next().toCharArray();
			char[] b = sc.next().toCharArray();
			char[] c = sc.next().toCharArray();
			
			int an= a.length;
			int bn = b.length;
			int cn = c.length;
			char turn = 'a';
			
			while(true) {
				if(turn=='a') {
					if(an==0) {
						System.out.println("A");
						return;
					}
					turn = a[a.length-an];
					an--;
				}
				if(turn=='b') {
					if(bn==0) {
						System.out.println("B");
						return;
					}	
					turn = b[b.length-bn];
					bn--;
				}	
				if(turn=='c') {
					if(cn==0) {
						System.out.println("C");
						return;
					}
					turn = c[c.length-cn];
					cn--;
				}
			}		
		}
	}

Measured memory_bytes: 35636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
template< typename T = long long >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}
int main(){
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<endl;
}

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

int main() {
    int x,y;
    cin>>x>>y;
    char a[x][y];
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++)cin>>a[i][j];
    }
    //printing double
    for(int i=0;i<x;i++){
        for(int z=1;z<=2;z++){
        for(int j=0;j<y;j++){
            cout<<a[i][j];
        }
        cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def prime_table(N):
    P = [False]*2+[True]*(N-1)
    for i in range(2,int(N**.5)+1):
        if P[i]: P[2*i::i] = [False]*(N//i-1)
    return P
P = prime_table(100000)
PP = [0] * 100000
for i in range(1,100000):
    PP[i] = PP[i-1] + (P[i]&P[(i+1)//2])
PP[2] = False
for _ in range(int(input())):
    l, r = map(int, input().split())
    print(PP[r]-PP[l-1])

Measured memory_bytes: 7108
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
ll K;

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	int t=b-a;
	t = t*(t+1);
	t = t/2;
	t -= b;
	printf("%d\n",t);
	return 0;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> vs(n);
	for (auto &&v : vs)
	{
		cin >> v;
	}

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

	long double ans = (vs[0] + vs[1]) / 2.0;
	for (int64_t i = 1; i < n - 1; i++)
	{
		ans = (ans + vs[i + 1]) / 2.0;
	}

	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		int b, f, r, v;
		int[][][] info = new int[4][3][10];
		for(int i = 0; i < size; i++){
			 b = sc.nextInt() - 1;
			 f = sc.nextInt() - 1;
			 r = sc.nextInt() - 1 ;
			 v = sc.nextInt();
			 info[b][f][r] += v;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					System.out.print(" ");
					System.out.print(info[i][j][k]);
				}
				System.out.println("");
			}
			if(i < 3)
				System.out.println("####################");
		}
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int L, R, d;
  cin >> L >> R >> d;
  // main procedure
  int ans = (R / d) - (L / d) + (L % d == 0 ? 1 : 0);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
io = STDIN
n,c=io.gets.split.map(&:to_i)
stc=[]
n.times do
  stc << io.gets.split.map(&:to_i)
end
last=[]
def machine(last,s,t,c)
  last.each_with_index do |(ss,tt,cc),i|
    if cc==c || tt<s
      last[i]=[s,t,c]
      return
    end
  end
  last << [s,t,c]
end
ar=stc.sort_by{|s,t,c|s}
last << ar.shift
ar.each do |s,t,c|
  machine(last,s,t,c)
end
puts last.size


Measured memory_bytes: 14712
import string
write = input()
lis = list(write)
judge = 0
if write[-1] in string.ascii_uppercase or write[1] in string.ascii_uppercase:
    print("WA")
elif write[0] == "A" and write[2:-1].count("C") == 1:
    lis.pop(lis.index("A"))
    lis.pop(lis.index("C"))
    for i in lis:
        if i in string.ascii_lowercase:
            judge += 1    
    if judge == len(lis):
        print("AC")
else:
    print("WA")

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char a,b,c;
  a=s1[0],b=s2[0],c=s3[0];
  a-=32,b-=32,c-=32;
  cout << a << b << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    while(true){
        int e; cin >> e;
        if(e==0) break;
        int ans = INF;
        for(int z = 0; z*z*z<=e; z++){
            for(int y = 0; z*z*z+y*y<=e; y++){
                ans = min(ans,e-z*z*z-y*y+y+z);
            }
        }
        cout << ans << endl;
    }
}


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



class Dijkstra {
public:
    struct edge { ll v, dist; };

    struct state {
        ll v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };

    const ll INF = (1LL << 60);
    ll N;
    ll MOD = 1e9+7;
    vector< vector<edge> > E;

    Dijkstra(ll n): N(n), E(n) {}

    //有効グラフの時はこっち。u→vに距離dで結ぶ
    void add_directed_edge(ll u, ll v, ll d) {
        E[u].push_back((edge) { v, d });
    }

    //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
    void add_undirected_edge(ll u, ll v, ll d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }

    //Sを始点として、他の頂点への最短経路を探す
    vector<pair<ll,ll>> shortest_path(ll S) {
        vector<pair<ll,ll>> dp(E.size(), {INF,0});
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        dp[S].first = 0;
        dp[S].second = 1;
        while(!q.empty()) {
            ll v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v].first < cost) continue;
            for(int i=0;i < E[v].size() ; i++) {
                ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
                if(dp[nv].first > ncost){
                    dp[nv].first = ncost;
                    dp[nv].second = dp[v].second;
                    q.push((state) { nv, ncost });
                }
                else if(dp[nv].first == ncost){
                    dp[nv].second += dp[v].second;
                    dp[nv].second %= MOD;
                }
            }
        }
        return dp;
    }
};



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,m,r;
    cin>>n>>m>>r;
    Dijkstra d(n);
    for(int i=0;i<m;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        d.add_directed_edge(a,b,c);
    }
    vector<pair<ll,ll>> v = d.shortest_path(r);
    for(int i=0;i<n;i++){
        if(v[i].first == (1LL<<60)){
            cout << "INF\n";
            continue;
        }
        cout << v[i].first << "\n";
    }

}


Measured memory_bytes: 20156
#include <iostream>
#include <cstdio>
using namespace std; 
typedef long long ll; 
int main()
{
	// freopen("AGC019-A.in", "r", stdin); 
	int q, h, s, d, n; 
	scanf("%d%d%d%d%d", &q, &h, &s, &d, &n); 
	h = min(h, q << 1); 
	s = min(s, h << 1); 
	d = min(d, s << 1); 
	printf("%lld\n", (ll)(n >> 1) * d + (ll)(n & 1) * s);
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int INF = 1145141919;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)cin >> v[i];
    vector<int> so = v;
    sort(so.begin(), so.end(), greater<>());

    for (int i = 0; i < n; i++) {
        if (v[i] == so[0])cout << so[1] << endl;
        else cout << so[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n;
  cin >> n;
  int a[n];
  for(int i = 0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  n = n/2;
  cout << a[n] - a[n-1] << endl;
  return 0;
}



Measured memory_bytes: 640
import java.util.PriorityQueue;
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		PriorityQueue<Integer> P = new PriorityQueue<>();
		for (int i = 0; i < N; i++) {
			P.add(sc.nextInt());
		}
		
		// 結果の出力
		int sum = 0;
		for (int i = 0; i < K; i++) {
			sum += P.poll();
		}
		System.out.println(sum);
		
		sc.close();
	}
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector < int > v(n);
	
	for (int i = 0; i < n; i++)
		cin>>v[i];
		
	sort(v.begin(), v.end());
	
	for (int i = 0; i + 1 < n; i++)
		if (v[i] == v[i + 1]) {
			cout<<"NO\n";
			return 0;
		}
	cout<<"YES\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    string s ;
    cin >> s ;

    size_t l = s.length();
    int N ;
    if(l%2 == 0){
        N = l/2;
    }else{
        N = l /2 + 1 ;
    }

    string a[N];
    for(int i = 0; i < N; i++ ){
        a[i] = s[i * 2] ;
    }
    
    for(int j = 0; j < N; j++ ){
        cout << a[j] ;

    }
    cout << endl;
    


    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int r = 0;
  for(char c : s) {
    if (c == 'R') {
      ++r;
    }
  }
  if (r > n-r) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,p;
	int a[100004];
	int ma=0;
	cin >> N;
	rep(i,100004){
		a[i]=0;
	}
	rep(i,N){
		cin >> p;
		if(p!=0){
			a[p-1]++;
		}
		a[p]++;
		a[p+1]++;
	}
	rep(i,100004){
		if(a[i]>=ma){
			ma=a[i];
		}
	}
	cout << ma << endl;
}

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

// ???????????§???????????§?????§??????
int DP[1024][1024] = {};

int main(){
    int N;
    cin >> N;
    for(int c=0; c<N; ++c){
        string X,Y;
        cin >> X >> Y;
        int xlen = (int)X.size();
        int ylen = (int)Y.size();

        for(int i=0;i<=xlen;++i){
          DP[i][0] = 0;
        }
        for(int i=0;i<=ylen;++i){
          DP[0][i] = 0;
        }

        for(int i=1;i<=xlen;++i){
            for(int j=1;j<=ylen;++j){
                if(X[i-1] == Y[j-1]){ // X???i???????????¨Y???j?????????????????????????????????index?????????????????¨?????¨??????
                    DP[i][j] = DP[i-1][j-1] + 1;
                } else {
                    DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
                }
            }
        }
        cout << DP[xlen][ylen] << endl;
    }
}

Measured memory_bytes: 7172
#include<stdio.h>
int main(){
    int h,w;
    char str[100][100];

    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",str[i]);
    }

    int cnt[100][100]={{}};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int ii=i-1;ii<=i+1;ii++){
                if(!(0<=ii&&ii<h)){
                    continue;
                }
                for(int jj=j-1;jj<=j+1;jj++){
                    if(!(0<=jj&&jj<w)){
                        continue;
                    }
                    if(str[ii][jj]=='#'){
                        cnt[i][j]++;
                    }
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(str[i][j]!='#'){
                printf("%d",cnt[i][j]);
            }else{
                printf("#");
            }
        }
        printf("\n");
    }
    return 0;
}

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << x << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll x,y;
    ll a,b,c;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    ll ab = 0;
    if(a+b > c*2){
        ll mn = min(x,y);
        x -= mn;
        y -= mn;
        ans += mn*c*2;
    }
    if(a*x > 2*c*x){
        ans += 2*c*x;
    }
    else{
        ans += a*x;
    }
    if(b*y > 2*c*y){
        ans += 2*c*y;
    }
    else{
        ans += b*y;
    }
    cout << ans << '\n';
}



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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}

int main()
{
		int a,b;
		cin>>a>>b;
		cout<<max(0,a-2*b)<<endl;
	return 0;
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fst first
#define snd second

typedef long long ll;

int main() {
    int n; cin >> n;
    double res = 0;
    cout.precision(20);
    fore(i, 0, n) {
        double x; string s; cin >> x >> s;
        if(!s.compare("JPY")) res += x;
        else res += 380000.0 * x;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import math
s = input()
k = int(input())

def connection_list(s):
  res = [0 for i in range(len(s))]
  prev = ''
  cnt = 0
  start = 0
  connected = 0
  for i in range(len(s)):
    if s[i] == prev:
      cnt += 1
    else:
      res[start] = cnt
      cnt = 0
      start = i
      prev = s[i]
  if cnt > 0:
    res[-1] = cnt
  if s[0] == s[-1]:
    connected = res[-1] + res[0] + 1
  return res, connected

def calc_ceil(n):
  return math.ceil(n/2)
cl, cn = connection_list(s)
if cl[-1] == len(cl) - 1:
  res = calc_ceil(len(cl) * k - 1)
else:
  cl = list(map(calc_ceil, cl))
  if cn > 0:
    res = sum(cl[1:-1]) * k + cl[0] + cl[-1] + calc_ceil(cn) * (k - 1)
  else:
    res = sum(cl) * k
print(res)

Measured memory_bytes: 38536
#include<iostream>
#include<vector>
#include<queue>
#define INF 1000000000

using namespace std;

struct vEdge {
	int adj;
	vector<int> weight;
	vector<int> tovtx;
	vEdge() {}

	void setadj(int a) { adj = a; }

	void setnum(int w, int n2) {
		weight.push_back(w); tovtx.push_back(n2);
	}
};

void dijkstra0(const vector<vEdge>& vedge, vector<int>& cost) {
	int mindex, min, temp, v,w, size = vedge.size(), count = 1;
	vector<bool> optimum(size, false);
	queue<int> qdata;
	cost.at(0) = 0; optimum.at(0) = true;

	while (count < size) {
		mindex = -1; min = INF;
		for (int i = 0; i < size; i++) if (optimum.at(i)) {
			for (int j = 0; j < vedge.at(i).adj;j++){
				v = vedge.at(i).tovtx.at(j);
				if (!optimum.at(v)) {
					w = vedge.at(i).weight.at(j);
					temp = cost.at(i) + w;
					if (temp < min) {
						min = temp;
						mindex = v;
					}
					if (temp < cost.at(v)) cost.at(v) = temp;
				}
			}
		}
		optimum.at(mindex) = true;
		count++;
	}

}

int main(void) {
	int size, num, adj, w, n2;
	cin >> size;

	vector<int> cost(size, INF);
	vector<vEdge> vedge(size);

	for (int i = 0; i < size; i++) {
		cin >> num >> adj;
		vedge.at(num).setadj(adj);
		for (int j = 0; j < adj; j++) {
			cin >> n2 >> w;
			vedge.at(num).setnum(w, n2);
		}
	}
	dijkstra0(vedge, cost);

	for (int i = 0; i < size; i++) cout << i << " " << cost.at(i) << endl;
	return 0;

}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);
const int OFFSET = (1 << 11);
const int MAXM = (1 << 12);
const int mod = (int)1e9 + 7;
const int inv2 = (mod + 1) / 2;

int n;
int a[MAXN], b[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
}

int dp[MAXM][MAXM];
int C[MAXM][MAXM];

void solve()
{
	C[0][0] = 1;
	for(int i = 0; i < MAXM; i++)
		for(int j = 0; j < MAXM; j++)
		{
			if(i) C[i][j] += C[i - 1][j];
			if(C[i][j] >= mod) C[i][j] -= mod;
			if(j) C[i][j] += C[i][j - 1];
			if(C[i][j] >= mod) C[i][j] -= mod;
		}

	int answer = 0;
	for(int i = 0; i < n; i++)
	{
		answer = answer + mod - C[2 * b[i]][2 * a[i]];
		if(answer >= mod) answer -= mod;
		if(answer < 0) answer += mod;
	}

	for(int i = 0; i < n; i++)
		dp[OFFSET - b[i]][OFFSET - a[i]]++;
	

	for(int i = 0; i < MAXM; i++)
		for(int j = 0; j < MAXM; j++)
		{
			if(i) dp[i][j] += dp[i - 1][j];
			if(dp[i][j] >= mod) dp[i][j] -= mod;
			if(j) dp[i][j] += dp[i][j - 1];
			if(dp[i][j] >= mod) dp[i][j] -= mod;
		}

	for(int i = 0; i < n; i++)
	{
		answer += dp[OFFSET + b[i]][OFFSET + a[i]];
		if(answer >= mod) answer -= mod;
	}

	answer = (answer * 1ll * inv2) % mod;
	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 135424
#include "bits/stdc++.h"
 
using namespace std;

int main(){
	string N;
	int sum = 0;
	cin >> N;

	for(int i=0; i<N.size(); i++){
		sum += int(N[i]) - int('0');
	}

	if(atoi(N.c_str())%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}





Measured memory_bytes: 256
def palindrome(s):
    if s==s[::-1]:
        return True
    else:
        return False

s = input()
ans = []
ans.append(palindrome(s))
ans.append(palindrome(s[:len(s)//2]))
ans.append(palindrome(s[len(s)//2+1:]))
print("Yes") if all(ans) else print("No")

Measured memory_bytes: 3064
#include<stdio.h>

main(){

  int x,y,a,b,c;

  scanf("%d%d",&x,&y);
  
  if( x>y ){
    a = x;
    b = y;
  }
  else{
    a = y;
    b = x;
  }
  
  while( b != 0){
    c = b;
    b = a%b;
    a = c;
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <map>
#include <vector>
#include <numeric>

using namespace std;
int main() {
    int n;

    cin >> n;
    if (n==1) {
        cout << "Hello World" << endl;

    } else {
        int a, b;
        cin >> a;
        cin >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 888
const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(i=>parseInt(i))

const S = next()
console.log(S.slice(0, 3))


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

int n;
int a[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ///freopen("in.txt", "r", stdin);
   //freopen("out.txt", "w", stdout);
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i+1];
    a[0] = 0; a[n+1] = 0;
    n+=2;
    ll cnt = 0;
    for(int i=1; i<n; i++){
        cnt += abs(a[i] - a[i-1]);
    }
    for(int i=1; i<n-1; i++){
        cout << (cnt - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])) << "\n";
    }
    return 0;
}

Measured memory_bytes: 1664
N,M,C = map(int, input().split())

B = [int(i) for i in input().split()]

A = []
counter = 0

for i in range(N) : 
    A_tmp = [int(i) for i in input().split()]
    A.append(A_tmp)

for i in range(N) : 
    sum = C #初期値
    for j in range(M) : 
        sum += A[i][j] * B[j]
    if(sum > 0) : counter += 1

print(counter)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll MOD=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(n)
    LIN(t)
    double a; cin >> a;
    Read_VL(h,n);
    vector< double > b(n);

    double mi = 100000;
    REP( i, 0, n ){
      double deq = t - h[i] * 0.006;
      mi = fmin( mi, abs( a - (deq) ) );
      b[i] = abs( a - ( deq ) );
    }
    ll ans = 0;
    REP( i, 0, n ){
      if( b[i] == mi ) ans = i;
    }
    puta( ans + 1 );

    return 0;
}


Measured memory_bytes: 256
def resolve():
    O = input()
    E = input()
    length = max(len(O), len(E))
    s = ""
    for i in range(length):
        o = "" if len(O) <= i else O[i]
        e = "" if len(E) <= i else E[i]
        s += o
        s += e
    print(s)


if '__main__' == __name__:
    resolve()

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

using namespace std;

#define F first
#define S second

int N, K;
int H[100005];
int dp[100001];

int main() {
	cin >> N >> K; 
	H[0] = INT32_MAX; // to avoid RTE
	for (int i = 1; i <= N; i++) cin >> H[i];
	for (int i = 0; i <= N; i++) dp[i] = INT32_MAX;
	int ans = 0;
	
	dp[N] = 0; // the base case
	K = min(N - 1, K);
	
	for (int i = N; i > 1; i--) {
		for (int j = 1; j <= K; j++) {
			if (i - j < 0) break;
			dp[i - j] = min(dp[i - j], abs(H[i] - H[i - j]) + dp[i]);
		}
	}

	cout << dp[1] << endl;

	return 0;
}

Measured memory_bytes: 1024
public class compiler
  Shared Sub Main()
    Dim input As String = Console.ReadLine()
    Dim s1 As String = input.Substring(0, 1)
    Dim s2 As String = input.Substring(1, 1)
    Dim s3 As String = input.Substring(2, 1)
    Dim s4 As String = input.Substring(3, 1)
    
    Dim output As String = "No"
    If s1 = s2 Then
        If s1 <> s3 AndAlso s3 = s4 Then
            output = "Yes"
        End If
    ElseIf s1 = s3 Then
        If s1 <> s2 AndAlso s2 = s4 Then
            output = "Yes"
        End If
    ElseIf s1 = s4 Then
        If s1 <> s2 AndAlso s2 = s3 Then
            output = "Yes"
        End If
    End If
    
    Console.WriteLine(output)
  End Sub
end class


Measured memory_bytes: 19792
#include <iostream>

using namespace std;

#define MAX_C 100

int main()
{
    int r, c, v;
    
    int csum[MAX_C], rsum;
    
    for(int i = 0; i < MAX_C; i++) { csum[i] = 0; }
    
    cin >> r >> c;
    
    for(int i = 0; i < r; i++)
    {
        rsum = 0;
        
        for(int j = 0; j < c; j++)
        {
            cin >> v;
            
            cout << v;
            
            rsum += v;
            
            csum[j] += v;
            
            if(j + 1 == c)
            {
                cout << ' ' << rsum << endl;
            }
            else
            {
                cout << ' ';
            }
        }
    }
    
    rsum = 0;
    
    for(int i = 0; i < c; i++)
    {
        cout << csum[i];
        
        rsum += csum[i];
        
        if(i + 1 == c)
        {
            cout << ' ' << rsum << endl;
        }
        else
        {
            cout << ' ';
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

bool flag[404][404]={};
ll ans=0,dp[404][404]={},sum[404][404]={};
int n,a[404];
ll f(int r,int l){
	if(flag[r][l])return dp[r][l];
	flag[r][l]=true;
	if(r==l)return 0;
	ll fans=INF;
	rep(i,r,l)fans=min(fans,f(r,i)+f(i+1,l));
	return dp[r][l]=fans+sum[r][l];
}

int main(){
	cin>>n;
	rep(i,1,n+1)cin>>a[i];
	rep(i,1,n+1)sum[1][i]=sum[1][i-1]+a[i];
	rep(i,1,n+1)rep(j,i,n+1)sum[i][j]=sum[1][j]-sum[1][i-1];
	ans=f(1,n);
	print(ans);
}



Measured memory_bytes: 2944
<?php
fscanf(STDIN, '%s', $s);
fscanf(STDIN, '%s', $t);

$count = 0;
for ($i=0; $i < 3; $i++) {
    if (substr($s, $i, 1) === substr($t, $i, 1)) {
        $count++;
    }
}

echo $count;

echo PHP_EOL;


Measured memory_bytes: 16036
def popcnt(n):
    return bin(n).count("1")

N = int(input())
evi = [[-1 for _2 in range(N)] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x,y = map(int, input().split())
        evi[i][x-1] =  y



ans = 0
for i in range(2**N) :
    d = [0 for _ in range(N)]
    for j in range(N) :
        if((i >> j) & 1) :
            d[j] = 1
    flg = True
    for j in range(N) :
        if(d[j]) :
            for k in range(N) :
                if(evi[j][k] == -1): continue
                if(evi[j][k] != d[k]): flg=False
    if(flg) :
        ans = max(ans, popcnt(i))
        
print(ans)
    
            

Measured memory_bytes: 3064
n = int(input())
lis = []
for i in range(n):
    a,b = list(map(int,input().split()))
    lis.append([a,b])
lis.sort(key=lambda x:x[1])
ans = 0
time = 0
for item in lis:
    time += item[0]
    if time > item[1]:
        ans += 1

if ans == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38872
#include<iostream>
using namespace std;
#define INF 1000000000

struct Card {
  char mark; int number;
};

int partition(Card A[], int left, int right){
  int x = A[right].number;
  int j = left;
  for ( int i = left; i < right; i++){
    if ( A[i].number <= x ){
      swap(A[i], A[j]);
      j ++;
    }
  }
  swap(A[j], A[right]);

  return j;
}

void quickSort(Card A[], int left, int right){
  if ( left < right ) {
    int q = partition(A, left, right);
    quickSort(A, left, q-1);
    quickSort(A, q+1, right);
  }
}

void merge(Card A[], int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  Card l[n1], r[n2];
  for ( int i = 0; i < n1; i++){ l[i] = A[left + i]; } // 0 to mid-1
  for ( int i = 0; i < n2; i++){ r[i] = A[mid + i]; } // mid to right-1
  l[n1].number = INF;
  r[n2].number = INF;

  int i = 0, j = 0;
  for ( int k = left; k < right; k++){
    if ( l[i].number <= r[j].number){
      A[k] = l[i];
      i++;
    }else {
      A[k] = r[j];
      j++;
    }
  }
}

void mergeSort(Card A[], int left, int right){
  if ( left + 1 < right){
    int mid = ( left + right ) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n;
  cin >> n;
  Card c1[n+1], c2[n+1];

  char mark[2];
  int number;
  for ( int i = 0; i < n; i++){
    cin >> mark >> number;
    c1[i].mark = c2[i].mark = mark[0];
    c1[i].number = c2[i].number = number;
  }

  mergeSort(c1, 0, n);
  quickSort(c2, 0, n-1);

  string state = "Stable";
  for ( int i = 0; i < n; i++){
    if (c1[i].mark != c2[i].mark || c1[i].number != c2[i].number){
      state = "Not stable";
    }
  }

  cout << state << endl;
  for ( int i = 0; i < n; i++){
    cout << c2[i].mark << " " << c2[i].number << endl;
  }
  return 0;
}


Measured memory_bytes: 5436
K, A, B = map(int, input().split())

ans = 1
if A >= B:
    ans += K
else:
    restk = K
    # A < B
    restk -= A - 1

    if restk <= 0:
        ans += K
    else:
        if restk > 1:
            ans = max(K+1, A + (restk // 2)*(B - A) + restk % 2)
        else:
            ans = A + 1
print(ans)


Measured memory_bytes: 9116
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
int main()
{
    fast
    ll t = 1;
   // cin>>t;
    while(t--){
    ll n,k;
    cin>>n>>k;
    ll cnt = 0;
    f(n)
    {
        ll val;
        cin>>val;
        if(val>=k)
        {
            cnt++;
        }
    }
    cout<<cnt<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int x; cin>>x;
	x/=200;
	cout<<10-x<<endl;
}

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

int main() {
  int A,B,number;
  cin >> A >> B;
  for(int i=0;i<B-A+1;i++){
    int m = i + A;
    int a,b,c,d,e;
    a = m % 10;
    m /= 10;
    b = m % 10;
    m /= 10;
    c = m % 10;
    m /= 10;
    d = m % 10;
    m /= 10;
    e = m % 10;
    if(a==e && b==d){
      number ++;
    }    
  }
  cout << number << endl;
}

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

using namespace std;

#define int long long
#define forr(i,n) for(int i = 0;i < (int)n; i++)
#define forn(i,n) for(int i = (int)(n-1); ~i ;i--)
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ar array

const int INF = (int)2e9;
const int mxN = (int)1000000000000001;

int n;
string ans = "";

void solve(){
	cin >> n;
	int cur = 26;
	int len = 1;
	while(n > cur){
		n -= cur;
		cur *= 26;
		len++;
	}
	n--;
	while(len > 0){
		len--;
		int cr = n%26;
		n/=26;
		ans+=(char)(cr+'a');
	}
	reverse(all(ans));
	cout<<ans<<"\n";
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3644
using System;
using System.IO;
using System.Linq;

namespace ABC118D_2
{
    // ABC118Dを漸化式で解く
    class Program
    {
        private static readonly int[] requiredMatches = { 2, 5, 5, 4, 5, 6, 3, 7, 6 };

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var numMatches = temp[0];
            var numNumbers = temp[1]; // 使わない
            var availableNumbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var maxNumber = new string[numMatches + 1];

            for (int i = 0; i <= numMatches; i++)
            {
                maxNumber[i] = "";

                foreach (int candidate in availableNumbers)
                {
                    if (i < requiredMatches[candidate - 1])
                    {
                        // マッチが足りない場合はスキップ
                        continue;
                    }

                    if (maxNumber[i - requiredMatches[candidate - 1]] == "")
                    {
                        // 最初の数字はマッチを使い切るように置く
                        if (i != requiredMatches[candidate - 1])
                        {
                            continue;
                        }
                    }

                    maxNumber[i] = GetMax(candidate + maxNumber[i - requiredMatches[candidate - 1]], maxNumber[i]);
                }

                Console.Error.WriteLine(i + " : " + maxNumber[i]);
            }

            Console.WriteLine(maxNumber[numMatches]);
        }

        string GetMax(string a, string b)
        {
            if (a.Length > b.Length)
            {
                return a;
            }
            else if (a.Length < b.Length)
            {
                return b;
            }
            else
            {
                return a.CompareTo(b) > 0 ? a : b;
            }
        }
    }
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n;
vector<int> g[maxn];
int viz[maxn];

void get_path(int at, int p, int dst, vector<int>& path) {
  if (dst == at) return;
  for (int to: g[at]) {
    if (to == p) continue;
    path.push_back(to);
    get_path(to, at, dst, path);
    if (path.back() != dst) path.pop_back();
  }
}

void dfs(int at, int p, int color) {
  viz[at] = color;
  for (int to: g[at]) {
    if (to == p) continue;
    if (viz[to] == -1) {
      dfs(to, at, color);
    }
  }
}

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

  fill(viz, viz+maxn, -1);

  cin>>n;
  for (int i=0; i<n-1; i++) {
    int u, v; cin>>u>>v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  viz[1] = 1;
  viz[n] = 0;

  vector<int> path = { 1 };
  get_path(1,-1,n,path);

  {
    int N = path.size();
    int l=1; int r=N-2;
    bool turn = true;
    while (1) {
      if (turn) {
	if (viz[path[l]]!=-1) break;
	viz[path[l++]] = 1;
      } else {
	if (viz[path[r]]!=-1) break;
	viz[path[r--]] = 0;
      }
      turn = !turn;
    }
  }

  for (int i=1; i<=n; i++) {
    if (viz[i]==-1) continue;

    dfs(i,-1,viz[i]);
  }

  vector<int> cnt(2);
  for (int i=1; i<=n; i++) {
    cnt[viz[i]]++;
  }

  if (cnt[1] > cnt[0]) out("Fennec");
  out("Snuke");
  return 0;
}


Measured memory_bytes: 39032
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;++i)cin>>A[i];
  int sum=0;
  for(int i=0;i<n;++i)sum^=A[i];
  for(int i=0;i<n;++i)cout<<(sum^A[i])<<" ";
  
  return 0;
}
//2020.06.23 18:15:37


Measured memory_bytes: 3916
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		200000									// 最大配列数

// 内部変数
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static FILE *szpFpT;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
#endif

	// 配列数取得
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列取得
	for (i = 0; i < siACnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &si1Array[i]);
#else
		fscanf(stdin, "%d", &si1Array[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 表示
	printf("%d", si1Array[siACnt - 1]);
	for (i = siACnt - 3; i >= 0; i -= 2) {
		printf(" %d", si1Array[i]);
	}
	if (i == -1) {
		i = 0;
	}
	else {
		i = 1;
	}
	for ( ; i < siACnt; i += 2) {
		printf(" %d", si1Array[i]);
	}
	printf("\n");

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 2816
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		//sc.next();
		for(int k = 0; k < n; k++) {
			char[][] c = new char[8][8];
			for(int i = 0; i < 8; i++) {
				String s = sc.next();
				for(int j = 0; j < 8; j++) {
					c[i][j] = s.charAt(j);
				}
			}
			int X = sc.nextInt() - 1;
			int Y = sc.nextInt() - 1;
			//sc.next();
			Deque<Point> q = new ArrayDeque<Point>();
			q.addLast(new Point(X, Y));
			int[] dx = {1, -1, 0, 0};
			int[] dy = {0, 0, 1, -1};
			c[Y][X] = '0';
			while(!q.isEmpty()){
				Point p = q.pollLast();
				for(int i = 0; i < 4; i++) {
					for(int j = 1; j <= 3; j++) {
						int nx = p.x + j * dx[i];
						int ny = p.y + j * dy[i];
						if(nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && c[ny][nx] == '1') {
							c[ny][nx] = '0';
							q.addLast(new Point(nx, ny));
						}
					}
				}
			}
			System.out.println("Data " + (k + 1) + ":");
			for(int i = 0; i < 8; i++) {
				for(int j = 0; j < 8; j++) {
					System.out.print(c[i][j]);
				}
				System.out.println();
			}

		}
		sc.close();
	}
}


Measured memory_bytes: 26356
import java.util.Scanner;

public class Main {

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

		int n = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());

		int[][] num = new int[n][d];
		double pos = 0.0;
		int count = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				num[i][j] = Integer.parseInt(sc.next());
			}
		}

		for (int i = 0; i < n - 1; i++) {
			for (int k = i + 1; k < n; k++) {
				pos = 0.0;
				double tmp = 0.0;
				for (int j = 0; j < d; j++) {
					tmp = Math.abs(num[i][j] - num[k][j]);
					tmp *= tmp;
					pos += tmp;
				}
				if (Math.sqrt(pos) % 1.0 == 0.0) {
					count++;
				}
			}
		}

		System.out.println(count);

	}
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    string s;
    cin >> s;

    string _s = s;
    reverse(s.begin(), s.end());
    if (_s != s)
    {
        cout << "No" << endl;
        return 0;
    }

    int n = s.size();
    string s1 = s.substr(0, (n - 1) / 2);
    string s2 = s.substr((n + 1) / 2);

    string _s1 = s1;
    string _s2 = s2;
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());

    bool flag = (s1 == _s1) && (s2 == _s2);

    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256