akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

vi G[1005], s;
bool ok[1005], vis[1005];

void dfs(int u, int tar) {
	s.PB(u);
	vis[u] = 1;
	if(u == tar) {
		cout << s.size() << endl;
		for(int e : s) cout << e << endl;
		exit(0);
	}
	for(int v:G[u]) if(ok[v])
		dfs(v, tar);
	s.pop_back();
}

int32_t main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		int u, v;
		cin >> u >> v;
		G[u].PB(v);
	}
	for(int i=1;i<=n;i++) {
		vi undo;
		for(int u:G[i]) {
			if(u < i) {
				undo.PB(u);
				ok[u] = false;
			}
		}
		memset(vis, 0, sizeof vis);
		ok[i] = 1;
		for(int u:undo) {
			ok[u] = 1;
			dfs(u, i);
			ok[u] = 0;
		}
		for(int u:undo) ok[u] = 1;
	}
	cout << -1 << endl;
}





Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

typedef double P_type; //座標(integer or real)
typedef double G_real; //実数の戻り値(float or double or long double)
typedef complex<P_type> P;
const G_real P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return abs(a.real() - b.real()) < P_eps ? a.imag() + P_eps < b.imag() : a.real() + P_eps < b.real();
  }
};

P rotate(P p, double theta){
  return p * P(cos(theta), sin(theta));
}

//内積
P_type dot(P a, P b) {
  return (a * conj(b)).real();
}

//外積
P_type cross(P a, P b) {
  return (conj(a) * b).imag();
}

//反時計回り
int ccw(P a, P b, P c){
  if(cross(b-a, c-a) > P_eps) return 1; //COUNTER_CLOCKWISE(center:a)
  if(cross(b-a, c-a) < -P_eps) return -1; //CLOCKWISE(center:a)
  if(dot(b-a, c-a) < -P_eps) return -2; //c -> a -> b
  if(dot(a-b, c-b) < -P_eps) return 2; //a -> b -> c
  return 0; //a -> c -> b
}


int main(){
  int N, x[100], y[100];
  pair<P,int> p[200];

  cin >> N;

  for (int i=0; i<N; i++) {
    cin >> x[i] >> y[i];
    p[i] = {arg(P(x[i], y[i])), i};
  }

  sort(p, p+N);

  double ans = 0;

  for (int i=0; i<N; i++) {
    ll sumx = 0, sumy = 0;

    for (int j=i; j<i+N; j++) {
      sumx += x[p[j%N].second];
      sumy += y[p[j%N].second];
      ans = max(ans, sqrt(sumx * sumx + sumy * sumy));
    }
  }

  printf("%.15lf\n", ans);

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

char s[100001];
char tmp[100001];
char visit[100001];
int n;

int main() {
	scanf("%s", s);
	n = strlen(s);

	for (int i = 0; i < n; i++)
		s[i] -= '0';

	memcpy(tmp, s, sizeof(tmp));


	int l = 1, r = n, mid;
	while (l <= r) {
		mid = (l + r) / 2;
		memcpy(s, tmp, sizeof(s));
		memset(visit, 0, sizeof(visit));

		int now = 0;
		for (int i = 0; i < n - mid + 1; i++) {
			if (i - mid >= 0 && visit[i - mid]) now ^= 1;
			if (s[i] ^ now) {
				now ^= 1;
				visit[i] = 1;
			}
			s[i] = 0;
		}

		for (int i = n - mid + 1; i < n; i++) {
			if (i - mid >= 0 && visit[i - mid]) now ^= 1;
			s[i] ^= now;
		}

		int flag = 0;
		for (int i = 0; i < mid - 1; i++)
			if (s[i] != s[i + 1]) {
				flag++;
				break;
			}

		for (int i = n - mid ; i < n - 1; i++)
			if (s[i] != s[i + 1]) {
				flag++;
				break;
			}

		if (flag == 2) r = mid - 1;
		else l = mid + 1;
	}

	printf("%d", r);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

lint N, A, B;
vector<lint> h;

bool check_able(int n)
{
    lint m = 0;
    for (auto v : h)
    {
        m += max((v - n * B + A - B - 1) / (A - B), 0LL);
    }
    if (m <= n) return true;
    else return false;
}

int main()
{
    cin >> N >> A >> B;
    h.resize(N);

    lint low = 1;
    lint high = 1;
    for (auto &v : h)
    {
        cin >> v;
        high = max(high, v/B+1);
    }

    while (high - low > 0)
    {
        if (check_able((high+low)/2)) high = (high + low) / 2;
        else low = (high + low) / 2 + 1;
    }
    cout << low << endl;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader vd = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(vd.readLine());
		String[] bd = vd.readLine().split(" ");
		vd.close();
		int[] a = new int[bd.length];
		for(int i=0; i<bd.length;++i) a[i] = Integer.parseInt(bd[i]);
		int sum=0;
		for(int i=0; i<bd.length;++i) sum = sum + a[i];
		
		System.out.println(sum-n);
		
	}

}


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

int main(){
	int n,t,a;
	cin >> n >> t >> a;
	
	int candy = 0;
	double k = 1e9+7;
	for(int i=0; i<n; i++){
		int h;
		cin >> h;
		double T = t-h*0.006;
		if(abs(a-T) < abs(a-k)){
			k = T;
			candy = i+1;
		}
	}

	cout << candy << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long,long>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a,b) get<a>(b)
#define INF (ll)1e18+5
#define ull unsigned long long
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
   return powM(a, m-2, m);
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
const int N = 2e5+5;
/*ll parent[N];
ll siz[N];
vector<pair<ll, pair<ll, ll> > > v;
void make(){
    REP(i, 0, N){
        parent[i]=i;
        siz[i] = 1;
    }
}
ll find(ll x){
    while(parent[x] != x){
        x = parent[x];
    }
    return x;
}
void unite(ll a, ll b){
    a = find(a);
    b = find(b);
    if(a != b){
        if(siz[a] < siz[b]){
            swap(a, b);}
        parent[b] = a;
        if(siz[a] == siz[b]){
            siz[a]++;
        }
    }
}*/
const double pi = acos(-1) ;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout<<(ull)pow(1024, 14);
    double a, b, x;
    cin>>a>>b>>x;
    if(x >  (a*a*b)/2){
    double d = (double)((2*a*a*b-2*x)/(a*a*a));
    cout<<fixed<<setprecision(10)<<(atan(d)*180.0)/pi;}
    else{
        double d = (b*b*a)/(2*x);
        cout<<fixed<<setprecision(10)<<(atan(d)*180.0)/pi;
    }
}

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

int gcd(ll a,ll b){
  if (a%b == 0)return(b);
  else return(gcd(b,a%b));
}

int main(){
  int k;
  int flag;
  ll total=0;
  cin>>k;

/*

  if(k==1){
    cout<<1<<endl;
    return 0;
  }
  if(k==2){
    cout<<9<<endl;
    return 0;
  }
  //全部同じ数字
  for(int i=1;i<=k;i++){
    total+=i;
  }


  //2つ同じ数字の時
  for(int i=1;i<=k;i++){
    for(int j=i+1;j<=k;j++){
      int s =gcd(i,j);
      total += (s*6);

    }
  }

  //全部数字が違うとき
  for(int i=1;i<=k;i++){
    for(int j=i+1;j<=k;j++){
      for(int l=j+1;l<=k;l++){
        int  x = gcd(i,j);
        int  y = gcd(x,l);
        total+=(6*y);
      }
    }
  }
  cout<<total<<endl;

  */
  //全部数字が違うとき
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        int  x = gcd(i,j);
        int  y = gcd(x,l);
        total+=y;
      }
    }
  }

  cout<<total<<endl;
}


Measured memory_bytes: 3624
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    slen = len(s)

    ans = slen
    for i in range(slen-1):
        if s[i]!=s[i+1]:
            ans = min(ans, max(i+1, slen -i-1))
    
    print(ans)


solve()


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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())
#define INF 1e+9

lld N, M;
vector<int> edge[100001];
pl d[100001];

void dijkstra(int s) {
    priority_queue<pl, vector<pl>, greater<pl> > que;
    for(int i = 0; i < N; i++) {
        d[i] = make_pair(INF, 0);
    }
    d[s] = make_pair(0, 0);
    que.push(pl(0, s));

    while(!que.empty()) {
        pl p = que.top();
        que.pop();
        int v = p.second;
        if(d[v].first < p.first) continue;

        for(int i = 0; i < edge[v].size(); ++i) {
            int t = edge[v][i];
            if(d[t].first > d[v].first + 1) {
                d[t].first = d[v].first + 1;
                d[t].second = v;
                que.push(pl(d[t].first, t));
            }
        }
    }
}

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dijkstra(0);
    for(int i = 1; i < N; i++) {
        if(d[i].first == INF) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) {
        cout << d[i].second+1 << endl;
    }
}

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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int a, b;
    cin >> a >> b;

    if(a >= 13)
        cout << b << "\n";
    else if(a >= 6)
        cout << b/2 << "\n";
    else
        cout << 0 << "\n";

    return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int a,b;
	cin>>a>>b;
	for(int i=0;i<=a;i++)
		if(i*2+(a-i)*4==b){
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
#define ll long long

void add_self(ll& a, ll b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main()
{
	string k;
	cin >> k;
	int d;
	cin >> d;
	vector<vector<ll>> dp(d,vector<ll>(2));
	int n = k.size();
	dp[0][0] = 1;
	for(int i = 0;i < n;i++)
	{
		auto new_dp = vector<vector<ll>> (d,vector<ll>(2));
		for(int sum = 0;sum < d;sum++)
		{
			for(bool sm_already : {false,true})
			{
				for(int digit = 0;digit < 10;digit++)
				{
					if(digit > k[i]-'0' && !sm_already)
						break;
					add_self(new_dp[(sum+digit)%d][sm_already || (digit < k[i]-'0')],dp[sum][sm_already]);
				}
			}
		}
		dp = new_dp;
	}

	auto ans = (dp[0][true] + dp[0][false])%mod;
	--ans;
	if(ans == -1)
		ans = mod-1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#1 <= N <= 100
N = int(input())
flag = False
for i in range(0,N//4 + 1):
    for j in range(0,N//7 + 1):
        if 4*i + 7*j == N:
            flag = True
            print("Yes")
            # print("4*{0} + 7*{1} = {2}".format(i,j,4*i + 7*j))
            break
    if flag:
        break
if not flag:
    print("No")

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





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

    for(ll i=0;i<N;i++){
         ans += ((i+1)*(i+2))/2;
    }

    for(int i=0;i<N-1;i++){
        ll u,v;
        cin >> u >> v;
        --u;--v;
        if(u<v){
            ans -= (N-v) *(u+1);
        }else{
            ans -= (N-u)*(v+1);
        }
        
    }
    
    
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3624
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
  left[i+1] = (fractions.gcd(left[i],A[i]))
  right[N-i-1] = (fractions.gcd(right[N-i],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl; 


int main(){
    int n;
    cin >> n;
    print(n*800 - 200*(n/15));
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a[5];
void solve(){
	int ans = 0;
	for(int i = 0; i < 5; i++){
		cin >> a[i];
		if(a[i] == 0) ans = i+1;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

pii swaped(pii x){
	return pii(x.second, x.first);
}

pii& operator+=(pii &x, pii y){return x = pii(x.first+y.first, x.second+y.second);}
pii& operator-=(pii &x, pii y){return x = pii(x.first-y.first, x.second-y.second);}
pii operator+(pii x, pii y){return x+=y;}
pii operator-(pii x, pii y){return x-=y;}

int main(){
	int n, k;
	cin >> n >> k;
	vvector<pii> pop(k*2, vector<pii>(k*2, pii(0, 0)));
	rep(i, n){
		int x, y;
		char d;
		cin >> x >> y >> d;
		pop[x%(2*k)][y%(2*k)] += ((d=='W')?pii(1, 0):pii(0, 1));
	}
	vector<pii> line(2*k, pii(0, 0));
	rep(x, k){
		rep(y, 2*k){
			line[y] += pop[x][y];
			line[(y+k)%(2*k)] += pop[x+k][y];
		}
	}
	auto func = [&](){
		int res = 0;
		int sum = 0;
		rep(i, k){
			sum += line[i].first;
			sum += line[i+k].second;
		}
		res = sum;
		rep(i, 2*k){
			sum -= line[i].first;
			sum += line[i].second;
			sum -= line[(i+k)%(2*k)].second;
			sum += line[(i+k)%(2*k)].first;
			chmax(res, sum);
		}
		return res;
	};

	int ans = 0;
	ans = func();

	rep(x, 2*k){
		rep(y, 2*k){
			line[y] -= pop[x][y];
			line[(y+k)%(2*k)] += pop[x][y];
			line[(y+k)%(2*k)] -= pop[(x+k)%(2*k)][y];
			line[y] += pop[(x+k)%(2*k)][y];
		}
		chmax(ans, func());
	}

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


Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int n, k, a[105];
bool mem[N];

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

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

	for (int i = 1; i <= k; i++) {
		mem[i] = false;
		for (int j = 0; j < n; j++) {
			int x = a[j];

			if (i - x >= 0 && !mem[i - x]) {
				mem[i] = true;
			}
		}
	}

	if (mem[k]) {
		cout << "First\n";
	}
	else {
		cout << "Second\n";
	}

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int n,t;
	scanf("%d %d",&n,&t);
	int a[n];
	int i,j;
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int min=1000000001;
	int diffMax=0;
	int diffMaxNum=0;
	
	for(i=1;i<n;i++){
//		min(min,a[i-1]);
		if(a[i-1]<min){
			min=a[i-1];
		}
		if(a[i]-min > diffMax){
			diffMax = a[i]-min;
			diffMaxNum = 1;
		}else if(a[i]-min == diffMax){
			diffMaxNum++;
		}
	}
	
	printf("%d\n",diffMaxNum);
	
	return 0;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, x = MAP()
a = LIST()

a.sort()

ans = 0
for i in range(N-1):
	if a[i] > x:
		break
	else:
		x -= a[i]
		ans += 1
else:
	if x == a[-1]:
		ans += 1
print(ans)


Measured memory_bytes: 5448
using System;

namespace Contest_175
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading;

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int count = 0;

            for(int i=0; i<N-2; i++)
            {
                for(int j=i+1; j<N-1; j++)
                {
                    if (L[i] == L[j]) continue;
                    for(int k=j+1; k<N; k++)
                    {
                        if (L[i] == L[k] || L[j] == L[k]) continue;
                        if (L[i] + L[j] <= L[k] || L[j] + L[k] <= L[i] || L[i] + L[k] <= L[j]) continue;
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


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


int main()
{
 int x,n;
 cin >> x >> n;
 vector<int> vec(n);

for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
}

int ans=101;

 for(int i=101;-1<=i;i--){
   int count=0;
   for(int j=0;j<n;j++){
      if(vec.at(j)==i)count++;     
   }
    if(count==0){
    if(abs(x-i)<=abs(x-ans)){
     ans=i;
   }
  }
 }

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

  




  
    
    
    
  
  
  


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

int main() {
    int N;
    cin >> N;
    string s;
    map<string, int> mp;
    for (int i = 0; i < N; i++) {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    long long ans = 0, cnt;
    for (auto x : mp) {
        cnt = x.second;
        ans += cnt * (cnt - 1) / 2;
    }

    cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> arr,ar1;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        arr.push_back(a);
        if(i%2==0)
            ar1.push_back(a);
    }

    sort(arr.begin(),arr.end());
    //sort(ar1.begin(),ar1.end());

    for(int i=0;i<n;i+=2)
    {
        ar1.push_back(arr[i]);
    }
    sort(ar1.begin(),ar1.end());
    //for(int i=0;i<ar1.size();i++)
      //  cout<<ar1[i]<<" ";
    int cnt=0;
    for(int i=0;i<ar1.size();)
    {
        if(i+1<ar1.size()&&ar1[i]==ar1[i+1])
        {
            cnt+=2;
            i+=2;
        }
        else
            i++;
    }
    cout<<(ar1.size()-cnt)/2;
    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>
char s[30];
int i,j,len,vv,k,v[100];
int main()
{
    scanf("%s",s);
    len=strlen(s);
    if (len<26)
    {
        for (i=0;i<=30;i++)
            v[i]=0;
        for (i=0;i<=len-1;i++)
            v[s[i]-'a']=1;
        for (i=0;i<=25;i++)
        if (v[i]==0)
        break;
        printf("%s",s);
        printf("%c",i+'a');
    } else
    {
        vv=0;
        for (j=0;j<=len-2;j++)
        if (s[j]-s[j+1]!=1) {vv=1; break;}
        if (vv==0) {printf("-1");return(0);}
        i=0;
        for (j=0;j<=25;j++)
            v[j]=0;
        while (i<=len-1)
        {
         for (j=i+1;j<=len-1;j++)
            {
                vv=0;
             for (k=j+1;k<=len-1;k++)
             {
              if (s[k]>s[j])
                {
                 vv=1;
                 break;
                }
              }
              if (vv==1) break;
            }
            if (vv) {printf("%c",s[i]);v[s[i]-'a']=1;} else
            {
                for (j=0;j<=25;j++)
                if (v[j]==0&&j+'a'>s[i])
                {
                    printf("%c",j+'a');
                    break;
                }
                break;
            }
            i++;
        }
    }
    return(0);
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0) {
				break;
			}
			if(x < y) {
				System.out.println(x + " " + y);
			}else {
			    System.out.println(y + " " + x);
			}
		}
	}
}


Measured memory_bytes: 36948
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
x,k,d=map(int,input().split())
if x<0 and x+d*k<=0:
    print(abs(x+d*k))
elif x>0 and x-d*k>=0:
    print(x-d*k)
elif x<0:
    i=math.ceil((-1*x)/d)-1
    if (k-(i+1))%2==0:
        print(x+d*(i+1))
    else:
        print(abs(x+d*i))
elif x>0:
    i=math.ceil(x/d)-1
    if (k-(i+1))%2==0:
        print(abs(x-d*(i+1)))
    else:
        print(x-d*i)
elif x==0:
    if k%2==0:
        print(0)
    else:
        print(d)

Measured memory_bytes: 72664
import queue

h, w = map(int, input().split())
s = '#'*(w+2)
for _ in range(h):
    s += '#' + input() +'#'
s += '#'*(w+2)

ans = 0
for i in range((w+2)*(h+2)):
    if s[i] == '#':
        continue
    dist = [10**5]*(w+2)*(h+2)
    dist[i] = 0
    q = queue.Queue()
    q.put(i)
    while not q.empty():
        x = q.get()
        for j in (1, -1, w+2, -w-2):
            if s[j+x] =='#':
                continue
            if dist[j+x] > dist[x] + 1:
                dist[j+x] = dist[x] + 1
                q.put(j+x)
    for k in range((w+2)*(h+2)):
      if dist[k] != 10**5:
        ans = max(ans, dist[k])

print(ans)



Measured memory_bytes: 3952
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    s, w = _ia()
    if s <= w:
        return "unsafe"
    else:
        return "safe"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 61856
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int mod = 1e9+7;

int main(){
	ll n , k;
	cin >> n >> k;

	vector<ll> pre(n+3 , 0);

	for(ll i = 0 ; i <= n ; i++){
		pre[i+1] = i + pre[i];
	}

	ll ans = 0;
	for (ll i = k ; i <= (n+1) ; i++){
		ll mx = pre[n+1] - pre[n+1-i];
		ll mn = pre[i];

		ans += ((mx - mn + 1)%mod);
		ans %= mod;
	}

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


Measured memory_bytes: 4808
#include<stdio.h>
int main()
{
	int n,sum,t;
	while(scanf("%d",&n)!=EOF)
	{
		t=n;
		sum=0;
		while(n/10!=0)
		{
			sum+=n%10;
			n/=10;
		}
		sum=sum+n;
		if(t%sum==0)
		printf("Yes\n");
		else
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp

#include <iostream>
#include <vector>
using namespace std;
const int failure = -100000;
const int normal = 1;
const int unknown = 0;

struct scan{
	int first;
	int second;
	int third;
	bool isOK;
};

int main(){
	while(1){
		vector <scan> input;
		int parts[301]={};
		for(int i=0;i<301;i++){
			parts[i] = unknown;//????????????.
		}
		
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0 && b == 0){
			break;
		}
		int n;
		cin >> n;
		int input1,input2,input3,input4;
		bool isOK;
		for(int i=0;i<n;i++){
			cin >> input1 >> input2 >> input3 >> input4;
			if(input4){
				isOK = true;
			}else{
				isOK = false;
			}
			input.push_back({.first = input1,.second = input2,.third = input3,.isOK = isOK});
		}
		
		bool changed = true;
		while(changed){
			changed = false;
			for(int i=0;i<n;i++){
				if(input[i].isOK){
					if(parts[input[i].first] == normal && parts[input[i].second] == normal && parts[input[i].third] == normal){
					}else{
						changed = true;
					}
					parts[input[i].first] = normal;
					parts[input[i].second] = normal;
					parts[input[i].third] = normal;
				}else if(parts[input[i].first] + parts[input[i].second] + parts[input[i].third] == 2){
					if(parts[input[i].first] == unknown){
						parts[input[i].first] = failure;
					}else if(parts[input[i].second] == unknown){
						parts[input[i].second] = failure;
					}else{
						parts[input[i].third] = failure;
					}
					changed = true;
				}
			}
		}
		for(int i=1;i<=a+b+c;i++){
			if(parts[i] == normal){
				cout << "1" << endl;
			}else if(parts[i] == unknown){
				cout << "2" << endl;
			}else{
				cout << "0" << endl;
			}
		}
	}
	
	
	return 0;
}

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

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::string s, t;
    std::cin >> s >> t;
    int c = 0;
    for (int i = 0, n = s.length(); i < n; i++)
    {
        if (s[i] != t[i]) c++;
    }
    std::cout << c << '\n';
    return 0;
}

Measured memory_bytes: 3876
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}


//for(int i = ; i < ; i++){}

int main(){
  int n,d;
  cin>>n>>d;
  int x[n][d];
  int ans = 0; 
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin>>x[i][j];
    }
  }
  
  
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
        int sum = 0;
        for(int k = 0; k < d; k++){
          sum+=pow(x[i][k]-x[j][k],2);
        }
        if(sqrt(sum)-(int)sqrt(sum)==0){
          ans++;
        }
      }
    }
  
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int A, B , C, X, Y;
int main () {
  cin >> A >> B >> C >> X >> Y;
  int ans = 1e9;
  for(int i = 0; i/2 <= max(X,Y); i += 2) {
    int x = X - i / 2;
    int y = Y - i / 2;
    int p = i * C + max(x,0) * A + max(y,0) * B;
    ans = min(ans, p);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x=0;
		int x1=0;
		String str = sc.next();
		for(int i=0;i<n;i++) {
			if(str.charAt(i)=='I') {
				x++;
			}else if(str.charAt(i)=='D') {
				x--;
			}
			if(x1<x) {
				x1=x;
			}
		}
		System.out.println(x1);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int a[3][3];
int n;

int main() {
    for(int i = 0; i < 3; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    vector<vector<bool>> abo(3, vector<bool>(3, false));
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < 3; ++k) {
                if(b == a[j][k]) {
                    abo.at(j).at(k) = true;
                }
            }
        }
    }

    bool flg = false;

    for(int i = 0; i < 3; ++i) {
        if(abo.at(i).at(0) == true && abo.at(i).at(1) == true && abo.at(i).at(2) == true) {
            flg = true;
        }
    }

    for(int i = 0; i < 3; ++i) {
        if(abo.at(0).at(i) == true && abo.at(1).at(i) == true && abo.at(2).at(i) == true) {
            flg = true;
        }
    }

    if(abo.at(0).at(0) == true && abo.at(1).at(1) == true && abo.at(2).at(2) == true) {
        flg = true;
    }

    if(abo.at(0).at(2) == true && abo.at(1).at(1) == true && abo.at(2).at(0) == true) {
        flg = true;
    }

    if(flg) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import  copy
n = int(input())
a = list(map(int, input().split()))
check = copy.deepcopy(a)
#####segfunc######
def segfunc(x,y):
    return x+y

def init(init_val):
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]   
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0
num =2**(n-1).bit_length()
seg=[ide_ele]*(2*num - 1)
init(a)
ans_1 = 0
pre_sum = (-1) * a[0]
for i in range(n):
    q_sum = query(0,i+1)
    if q_sum * pre_sum >= 0:
        if pre_sum < 0:
            update(i, abs(pre_sum) + 1)
        else:
            update(i, (-1) * (pre_sum+1))
    pre_sum = query(0,i+1)
for i in range(n):
    ans_1 += abs(check[i] - seg[i + num - 1])
if a[0] == 0:
    a[0] = 1
else:
    if a[0] < 0:
        a[0] = 1
    else:
        a[0] = -1
ans_2 = 0
pre_sum = (-1) * a[0]
init(a)
for i in range(n):
    q_sum = query(0,i+1)
    if q_sum * pre_sum >= 0:
        if pre_sum < 0:
            update(i, abs(pre_sum) + 1)
        else:
            update(i, (-1) * (pre_sum+1))
    pre_sum = query(0,i+1)
for i in range(n):
    ans_2 += abs(check[i] - seg[i + num - 1])
print(min(ans_1,ans_2))

Measured memory_bytes: 102748
#include<iostream>

using namespace std;

static const int MAX = 8;
bool A[MAX][MAX];
bool visited[MAX];

int N, M;

int dfs(int v){
	bool all_visited = true;

	for(int i = 0; i < N; i++){
		if(visited[i] == false) all_visited = false;
	}

	if(all_visited) return 1;

	int ret = 0;

	for(int i = 0; i < N; i++){
		if(A[v][i] == false) continue;
		if(visited[i]) continue;

		visited[i] = true;
		ret += dfs(i);
		visited[i] = false;
	}

	return ret;
}

int main(){
	for(int i = 0; i < MAX; i++){
		for(int j = 0; j < MAX; j++){
			A[i][j] = false;
		}
		visited[i] = false;
	}

	cin >> N >> M;
	int a, b;
	for(int i = 0; i < M; i++){
		cin >> a >> b;
		A[a - 1][b - 1] = A[b - 1][a - 1] = true;
	}

	visited[0] = true;
	cout << dfs(0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 998244353;



void solve(){
	fio;
	int x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	int div= x/d;
	if(div>=k){
		cout<<x-k*d<<endl;
	}
	else{
		int left= k-div;
		if(left%2) cout<<abs(x-div*d-d)<<endl;
		else cout<<x-div*d<<endl;
	}
}


int32_t main(){
	fio;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<":\n";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3688
import java.util.Scanner;
public class Main {
	public static int gcd(int a,int b,int c) {
		int d=0;
		int ans=0;
		while(d==0) {
		if(a>b) {
			a=a-b;
		}
		else if(a<b) {
			b=b-a;
		}
		else {
			d=a;
		}
		}
		while(ans==0) {
		if(d<c) {
			c=c-d;
		}
		else if(d>c) {
			d=d-c;
		}
		else {
			ans=d;
		}
		}
		return ans;
	}
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int A=0;
		for(int i=1;i<K+1;i++) {
			for(int j=1;j<K+1;j++) {
				for(int k=1;k<K+1;k++) {
					A+=gcd(i,j,k);
				}
			}
		}
		System.out.println(A);
	}
}


Measured memory_bytes: 35796
n=int(input())
w=[input() for i in range(n)]
last=""
wl=[]
ans="Yes"
for x,i in enumerate(w):
    if x==0:
        last=i[-1]
        wl.append(i)
        continue
    if i in wl:
        ans="No"
    if i[0]!=last:
        ans="No"
    last=i[-1]
    wl.append(i)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    long long n, m, doi[10];
    cin >> n >> m;
    doi[0] = 1;
    for(int i = 1; i < 10; i++) doi[i] = 2 * doi[i - 1];
    cout << ((n - m) * 100 + m * 1900) * doi[m];
    return 0;
}


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

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

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;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    for (auto &i : A) cin >> i;

    map<int, int> mp;
    ll ans = 0;
    rep(i, N) {
        int a = A[i];
        ans += mp[i - a];
        mp[i + a]++;
    }

    cout << ans << endl;
}

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

void solve(int N, string S)
{
    vector<vector<int>> dp(N + 1, vector<int>(N + 1));
    for (int i = N - 1; i >= 0; i--)
    {
        for (int j = N - 1; j >= 0; j--)
        {
            if (S.at(i) == S.at(j))
                dp.at(i).at(j) = dp.at(i + 1).at(j + 1) + 1;
        }
    }
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (j <= i)
            {
                continue;
            }
            res = max(res, min(dp.at(i).at(j), j - i));
        }
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


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

int calc_gcd(int x, int y) {
    int r = x % y;
    if (r <= 0) {
        return y;
    } else {
        return calc_gcd(y, r);
    }
}

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a < b) swap(a, b);
	
	int answer;
	answer = calc_gcd(a, b);
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 3068
if __name__ == "__main__":
    n = input()
    char_string = "qazwsxedcrfvtgbyhnujmikolp"
    char_list = sorted(list(char_string))

    n = int(n)
    result_string = ""
    while 1:
        if n <= 26:
            break
        result_string = char_list[int((n%26)-1)] + result_string
        if (n % 26) == 0:
            n = n//26-1
        else:
            n = n//26
    result_string = char_list[n-1] + result_string
    print(result_string)





        



Measured memory_bytes: 8912
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;


int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int m, d; scanf("%d %d", &m, &d);
	
	int res = 0;
	for(int i = 1; i <= m; i++)
	{
		for(int j = 2; j <= 9; j++)
		{
			for(int k = 2; k <= 9; k++)
			{
				if(j*k == i && (j*10 + k) <= d)
				{
					// printf("%d %d %d\n", i, j, k);
					res++;
				}
			}
		}
	}
	printf("%d\n", res);
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
typedef long long ll;
const int mod = (1e9)+7;
int A[N],used[N];
int F,S;


ll mod_pow(ll x,ll n){
  ll res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}
 
ll nCr(ll n,ll r){
  static vector<ll> k(1e6);
  if(!k[0]){k[0]=1;for(int i=1;i<k.size();i++)k[i]=i*k[i-1]%mod;}
  ll a=mod_pow(k[r],mod-2);
  ll b=mod_pow(k[n-r],mod-2);
  return ((k[n]*a)%mod)*b%mod;
}

signed main(){
  int n;
  cin>>n;
  memset(used,-1,sizeof(used));

  
  for(int i=0;i<n+1;i++){
    cin>>A[i];
    if(used[A[i]]!=-1) F = used[A[i]], S = n-i;
    used[A[i]] = i;
  }
  
  int cnt = (F!=0)+(S!=0);
  cout<<n<<endl;
  for(int i=2;i<=n+1;i++){
    int ans = nCr(n+1,i);
    if(cnt&&F+S>=i-1) ans = (ans - nCr(F+S,i-1)+mod);
    cout<<ans%mod<<endl;
  }
    
  return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>

using namespace::std;



int main()
{
	int N;
	cin >> N;
	
	vector<int> A(N);
	vector<int> B(N);

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

		if (B[i] > (i + 1)) {
			cout << "-1" << endl;
			return 0;
		}
	}

	int m = N - 1;
	for (int i = N - 1; i >= 0; ) {

		for (int j = i; j >= 0; j--) {
			if (B[j] == (j + 1)) {
				A[m] = B[j];
				
				//cout << i << " " << j << " " << B[j] << endl;
				B.erase(B.begin() + j);
				
				
				m = m - 1;
				i = i - 1;
				break;
			}
		}

	}

	for (int i = 0; i < N; i++) {
		cout << A[i] << endl;
	}

	return 0;
}


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

int main(){
    ll k;
    cin >> k;
    ll x = 7;
    for(int i = 1; i <= k; i++){
        if(x % k == 0){
            cout << i << endl;
            return 0;
        }
        x = (10*x + 7) % k;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ans+=b-a+1;
    }
    cout<<ans<<endl;
}

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

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

  int max = 0;
  for(int i=1; i<=min(a, b); i++){
    if(a%i == 0 && b%i == 0){
      max = i;
    }
  }

  cout << (int64_t)a*b/max << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll INF = 1e10;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }

    ll ans = 0;
    for(int i = n-1; i >= 0; i--)
    {
        ll x = (a[i]+ans) % b[i];
        if(x == 0) continue;
        ans += b[i]-x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define f first
#define s second

int n, d[N], m[N];


int main() {
    scanf("%d",&n);
    for(int i=1; i<=n; i++) 
    {
        scanf("%d",d+i);
        m[1] += d[i] * (i%2?1:-1);
    }
    for(int i=2; i<=n; i++)
    {
        m[i] = (d[i-1] - m[i-1]/2) * 2;
    }
    for(int i=1; i<=n; i++) printf("%d ",m[i]);
    return 0;
}

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

int main(){
ll n, d;
cin >> n >> d;
ll ans = 0;
for(int i = 0; i< n;i++){
ll x, y;
cin >> x >> y;
if(sqrt(x*x + y*y) <=  d)ans++;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	int a[50],b[50],c[50];
	int ans=0;
	FOR(i,n){
		cin >> a[i];
	}
	FOR(i,n){
		cin >> b[i];
		ans+=b[i];
	}
	FOR(i,n-1){
		cin >> c[i];
	}
	FOR(i,n-1){
		if(a[i]+1==a[i+1]){
			ans+=c[a[i]-1];
		}
	}
	cout << ans << endl;


}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while (x->left != NIL) {
    x = x->left;
  }
  
  return x;
  
}

Node treeSearch(Node x, int k){
  
  if (x == NIL || k == x->key) {
    return x;
  }
  
  if (k < x->key) {
    return treeSearch(x->left, k);
  } else {
    return treeSearch(x->right, k);
  }
  
  
}

Node treeSuccessor(Node x){
  Node y;
  
  if (x->right != NIL) {
    return treeMinimum(x->right);
  }
  
  y = x->parent;
  
  while (y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  
  return y;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if (z->left == NIL || x->right == NIL) {
    y = z;
  } else {	
    y = treeSuccessor(z);
  }
  
  if (y->left != NIL) {
    x = y->right;
  } else {
    x = y->right;
  }
  
  if (x != NIL) {
    x->parent = y->parent;
  }
  
  if (y->parent == NIL) {
    root = x;
  } else if (y == y->parent->left) {
    y->parent->left = x;
  } else {
    y->parent->right = x;
  }
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  z->parent = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  
  if(y == NIL){
    root = z;
  } else if(z->key < y->key){
    y->left = z;
  } else {
    y->right = z;
  }
  

}


void inorder(Node u){
  
  if(u->left != NIL){
    inorder(u->left);
  }
  
  printf(" %d",u->key);
  
  if(u->right != NIL){
    inorder(u->right);
  }
  
}

void preorder(Node u){

  printf(" %d",u->key);
	
  if(u->left != NIL){
    preorder(u->left);
  }
  
  if(u->right != NIL){
    preorder(u->right);
  }
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  
  return 0;
}

Measured memory_bytes: 11000