akhauriyash/Code-Regression huggingface dataset:
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  int N = readln.chomp.to!(int);
  int[] X = readln.chomp.split.to!(int[]);
  int[] sortX = X.dup;
  sort(sortX);

  if (N == 2) {
    writeln(sortX[1]);
    writeln(sortX[0]);
    return;
  }

  int[] A = sortX[(N / 2 - 2)..(N / 2 + 2)];

  foreach (int a; X) {
    if (a <= A[1]) {
      writeln(A[2]);
    }
    else if (a >= A[2]) {
      writeln(A[1]);
    }
  }
}


Measured memory_bytes: 13040
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const double EPS = 1e-10;

int main() {
	string S;
	cin >> S;
	if (S.size() == 2) cout << S << endl;
	else {
		reverse(S.begin(), S.end());
		cout << S << endl;
	}
}

Measured memory_bytes: 256
# ABC138D - Ki (main, dfs inside main())
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    def dfs(v: int, p: int) -> None:
        for u in T[v]:
            if u != p:  # p: parent -> skip
                cnt[u] += cnt[v]  # cumulative sum
                dfs(u, v)

    N, Q = tuple(map(int, input().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, (N+1: 1-idx -> 0-idx)
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 303308
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    ll ans = INF;
    erep(i, 1, n/2) {
        ll a = i, b = n - a, ca = 0, cb = 0;
        while (a > 0) ca += a % 10, a /= 10;
        while (b > 0) cb += b % 10, b /= 10;
        ans = min(ans, ca + cb);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
int mod = 1e9+7;
long long dp[2001][2001];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto &a : A) cin >> a;
    for (int i = 0; i < N; i++) {
        for (int j = 2; j < 2001; j++) {
            dp[N-i-1][j] = dp[N-i][j];
            if (A[N-i-1] < j) dp[N-i-1][j]++;
        }
    }
    for (int i = 0; i < N; i++) {
        ans += dp[i][A[i]]*K;
        ans %= mod;
        ans += dp[0][A[i]]*((K-1)*K/2%mod);
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 31488
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = arr[0];
        int b = arr[1];
        Console.WriteLine(a * b + " " + (a + b) * 2);
    }
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int N,M,ans(0);
vector <int> connect[8];
int passed[8]={0};

int dfs(int n){
  passed[n]=1;
  bool finish(true);
  for (int i(0);i<N;i++){
    // cout << passed[i]<<" ";
    if (passed[i]==0) finish=false;
  }
  cout<<endl;
  if (finish==true) ans+=1;
  for (int i(0);i<connect[n].size();i++){
    if (passed[connect[n][i]]==0) dfs(connect[n][i]); // is not still path
  }
  passed[n]=0;
  return 0;
}

int main() {
  cin>>N>>M;
  for (int i(0);i<M;i++) {
    int a,b;
    cin>>a>>b;
    connect[b-1].push_back(a-1);
    connect[a-1].push_back(b-1);
  }
  dfs(0);
  cout<<ans<<endl;
  return 0;
}


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

void testcase(){
    int d,t,s;
    cin >> d >> t >> s;
    if(t*s>=d)
        cout << "Yes";
    else
        cout << "No";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



Measured memory_bytes: 3636
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,a,b = iim()
if n > 1:
    print(max((n-2)*(b-a)+1,0))
else:
    if a==b:
        print(1)
    else:
        print(0)

Measured memory_bytes: 3064
N,a,b = map(int,input().split())

MOD = 10**9 + 7

def nCr(n,r):
  p = 1
  q = 1
  if n-r >= r:
    for i in range(r):
      p *= n-i
      p %= MOD
      q *= i+1
      q %= MOD
  else:
    for i in range(n-r):
      p *= n-i
      p %= MOD
      q *= i+1
      q %= MOD
  return p*pow(q,MOD-2,MOD)

print((pow(2,N,MOD)-1-nCr(N,a)-nCr(N,b))%MOD)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, k;
vector <int> a, v[N];
int ans;

int dfs(int node){
    int ret = 0;
    for(auto &i : v[node]){
        ret = max(ret, dfs(i));
    }
    if(a[node] && ret == k - 1){
        ans++;
        return 0;
    }
    return ret + 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        a[i]--;
        if(i > 0) v[a[i]].push_back(i);
    }
    ans = a[0] > 0;
    a[0] = 0;
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 10752
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	long long i, j, mask, keta;
	string S;

	cin >> S;
	keta = S.length();

	long long sum = 0, po = 0;
	for (mask = 0; mask < (1 << keta - 1); mask++) {
		// cout << "mask->" << mask << endl;
		po = 0;
		for (i = 0; i < keta; i++) {

			
			if (mask & (1 << i)) {
				int tmp = (mask & (1 << i));
			//	cout << "po->" << po << endl;
			//	cout << stoll(S.substr(po, i - po + 1)) << endl;
				
				sum += stoll(S.substr(po, i - po + 1));
				po = po + (i - po + 1);
			}
		}
		//cout << "stoi(S.substr(po))" << stoll(S.substr(po)) << endl;
		//cout << endl;
		sum += stoll(S.substr(po));

	}


	//cout << "sum->" << sum << endl;
	cout << sum << endl;


	
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

mod = 10**9 + 7

ans = 1

cnt = [0, 0, 0]
a.each do |ai|
  t = 0
  3.times do |cnt_i|
    if ai == cnt[cnt_i]
      t += 1
    end
  end
  ans *= t
  ans %= mod

  3.times do |cnt_i|
    if ai == cnt[cnt_i]
      cnt[cnt_i] += 1
      break
    end
  end
end

puts ans


Measured memory_bytes: 23128
/** Bismillahir Rahmanir Raheem **/
/**
********************************************************************
******************* Author:Ashik Iqbal****************************
********************************************************************
**/
/**
Name : Ashik Iqbal.
Email: ashiqueiqbal998@gmail.com.
Computer Science and Engineering.
North South University.
Dhaka, Bangladesh.
**/

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


/** templates starts here **/
#define ll long long int
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define stll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mpii map<int,int>
#define mpll map<ll,ll>
#define mpss map<string,string>
#define mpsi map<string,int>
#define mpis map<int,string>
#define mpsll map<string,ll>
#define mplls map<ll,string>
#define sit set<int>::iterator
#define slit set<ll>::iterator
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define asrt(a) sort(a, a+n)
#define grtasrt(a) sort(a, a+n,greater<int>())
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define REV(i,j,k) for(int i=j;i>k;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
#define mx 1000005
const int mod=1e9+7;
const int N = (int) 1e5 + 5;
/** templates ends here **/


int main ()
{

    fast;
    int n;
    cin>>n;
    int k = n;
    int sum = 0, rem;
    while(n!=0)
    {
        rem = n%10;
        sum+=rem;
        n/=10;
    }
    if(k % sum == 0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    deque<int> b;
    REP(i,N){
        int a; cin>>a;
        if((i+1)%2==N%2) b.push_front(a);
        else b.push_back(a);
    }
    REP(i,N) cout<<b[i]<<' ';
    cout<<endl;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	ld L;
	cin >> L;
	cout << setprecision(15) << L*L*L/27.0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

LL a[100005];

LL prefix[100005];

int main() {
    LL n, m;
    scanf("%lld%lld", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    prefix[0] = a[0] % m;
    for (int i = 1; i < n; i++) {
        prefix[i] = (prefix[i - 1] + a[i]) % m;
    }
    sort(prefix, prefix + n);

    vector<LL> group;

    LL count = 1;
    for (int i = 1; i < n; i++) {
        if (prefix[i] != prefix[i-1]) {
            group.push_back(count);
            count = 1;
        } else {
            count++;
        }
    }
    group.push_back(count);

    LL ans = 0;
    for (auto c : group) {
        ans += (c * (c-1)) / 2;
    }
    for (int i = 0; i < n; i++) {
        if (prefix[i] % m == 0) {
            ans++;
        }
    }
    printf("%lld\n", ans);
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug cout<<"Reached\n";

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;

    cin>>s;

    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    int a[214514],b[214514];
    vector<int> V[214514];
    bool al[214514]={};
    cin >> N;
    REP(i,N-1){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        V[a[i]].push_back(b[i]);
        V[b[i]].push_back(a[i]);
    }
    
    
    pair<int,int> mx={0,0};
    vector<pair<int,int>> Q;
    
    REP(l,2){
        REP(i,N){
            al[i]=false;
        }
        Q.push_back({mx.first,0});
        mx.second=0;
        while(!Q.empty()){
            int P,M;
            pair<int,int> f;
            f=Q[((int)(Q.size()))-1];
            P=f.first;
            M=f.second;
            al[P]=true;
            Q.pop_back();
            if(mx.second<M){
                mx.first=P;
                mx.second=M;
            }
            REP(i,V[P].size()){
                if(al[V[P][i]]==false){
                    Q.push_back({V[P][i],M+1});
                }
            }
        }
    }
    
    int R=mx.second;
    //cout << R << endl;
    
    if(R==0){
        cout << "First" << endl;
        return 0;
    }
    if(R==1){
        cout << "Second" << endl;
        return 0;
    }
    
    if((R+2)%3!=0){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 21872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int t[5];
char ca[20];

int main(){
	int a,b,c;
	int i,j,k;
	int s=0;
	int n,m;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>ca;
		m=strlen(ca)-1;
		for(j=0;j<m;j++){
			if(ca[j]=='A' && ca[j+1]=='B')s++;
		}
		j=0;
		if(ca[0]=='B')t[0]++,j++;
		if(ca[m]=='A')t[1]++,j++;
		if(j==2)t[2]++;
	}
	if(t[0]>0 && t[0]==t[1] && t[1]==t[2])s+=t[0]-1;
	else s+=min(t[0],t[1]);
	cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		int max;
		int a = sc.nextInt();
		max = a;

		int b = sc.nextInt();
		if (b > max)
			max = b;

		int c = sc.nextInt();
		if (c > max)
			max = c;
		int k = sc.nextInt();


	int result = 0;
	
	if(max==a) result = (int) (b+c+a*Math.pow(2, k));
	if(max==b) result = (int) (a+c+b*Math.pow(2, k));
	if(max==c) result = (int) (b+a+c*Math.pow(2, k));
		

		
		System.out.println(result);

	}
}


Measured memory_bytes: 20692
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

struct point{
	double x,y;
	point operator+(point p){
		return point{x+p.x,y+p.y};
	}
	point operator-(point p){
		return point{x-p.x,y-p.y};
	}
	point operator*(double p){
		return point{x*p,y*p};
	}
	point operator/(double p){
		if(!p) return point{0,0}; 
		return point{x/p,y/p};
	}
	bool operator==(point p){
		return fabs(x-p.x)<eps&&fabs(y-p.y)<eps;
	}
};
 
typedef pair<point,point> pp;
typedef vector<point> VP;
const point O{0,0};
 
class Geom{
	public:
	double IP(point p,point q){
		return p.x*q.x+p.y*q.y;
	}
	double CP(point p,point q){
		return p.x*q.y-q.x*p.y;
	}
	string Containment_polyon_point(VP p,point x){
		bool flag=0;
		p.push_back(p[0]);
		for(VP::iterator i=p.begin();i!=p.end()-1;i++){
			point a=*i-x,b=*(i+1)-x;
			if(a.y>b.y) swap(a,b);
			double ip=IP(a,b),cp=CP(a,b);
			if(a.y<=0&&b.y>0&&cp<0) flag=!flag;
			if(cp<eps&&cp>-eps&&ip<=0) return "On_side";
		}
		return flag?"Containment":"not_Containment";
	}
	void Point_in(point& p){
		cin>>p.x>>p.y;
	}
};

int N,Q;
point x;
string s;
VP p;

int main(){
	Geom geo;
	cin>>N;
	p=VP(N);
	for(int i=0;i<N;i++) geo.Point_in(p[i]);
	cin>>Q;
	for(int i=0;i<Q;i++){
		geo.Point_in(x);
		s=geo.Containment_polyon_point(p,x);
		if(s=="Containment") cout<<2<<endl;
		else if(s=="On_side") cout<<1<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 3232
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int N;
    cin >> N;
    for(int i=0; i <= 25 ; i++){
        for(int j=0; j<=14; j++){
            if(i*4 + j*7 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=80;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	int qa=nxi(),qb=nxi();
	printf("%d %d\n",N,N);
	for(int i=0; i<N; ++i){
		for(int j=0; j<N/2-1; ++j){
			putchar((j&1)==0&&(i&1)==0&&--qb>0?'#':'.');
		}
		putchar('.');
		putchar('#');
		for(int j=N/2+1; j<N; ++j){
			putchar((j&1)==0&&(i&1)==0&&--qa>0?'.':'#');
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  map<int,int> A;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A[a]++;
  }
  for(pair<int,int> p:A){
    if(p.first%2==N%2 || (p.second!=2 && p.first!=0) || p.first>=N || (p.second==1 && p.first!=0)){
      puts("0");
      return 0;
    }
  }
  int ans=1;
  for(int i=0;i<N/2;i++)
    ans=ans*2%1000000007;
  cout<<ans<<endl;
}

Measured memory_bytes: 7580
#include <iostream>
using namespace std;
int main() {
  int n;
  cin>>n;
  char str[n];
  for(int i=0;i<n;i++){
    cin>>str[i];
  }
  if(n%2==0){
    int x=(n/2);
    int i=0;
    int count=0;
    while(i<(n/2)){
      if(str[i]==str[x])
      {
        count++;
        }
      else{
        count=0;
        break;
      }  
      ++i;
      ++x;
    }
    if(count!=0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
  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 ll long long

void remove(vector<ll>& vec, ll index){
    vec.erase(vec.begin() + index);
}

int main(){
	ll n;
	cin >> n;
	vector<ll> bi(n);
	vector<ll> ans(n);
	REP(i, n){cin >> bi[i];}
	REP(i, n){
		ll max = 0;
		bool flag = false;
		REP(j, n-i){
			if (bi[j] == j + 1){
				max = j;
				flag = true;
			}
		}
		if (!flag) {cout << -1 << endl; return 0;}
		ans[i] = max + 1;
		remove(bi, max);
	}
	REP(i, n){cout << ans[n-i-1] << endl;}
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc135/submissions/8198071
//参考にさせて頂いたコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e13+7;

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

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    ll N,count=0;
    int A[1000000];
    int B[1000000];
    cin>>N;
    for(ll i=0;i<=N;i++)cin>>A[i];
    for(ll i=0;i<N;i++)cin>>B[i];
    rep(i,N){
        if (A[i] >= B[i]) {
            count += B[i];
        } else {
            int diff = B[i] - A[i];

            if (diff > A[i+1]) {
                count += A[i] + A[i+1];
                A[i+1] = 0;
            } else {
                count += A[i] + diff;
                A[i+1] -= diff;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (10000006)
ll n, f[MAXN], inv[MAXN], p2[MAXN], mod=998244353;
int main(){
	FAST
	cin>>n;
	auto qexp=[&](ll x,ll e){
		ll sum=1;
		for(;e;e>>=1,x*=x,x%=mod)if(e&1)sum*=x,sum%=mod;
		return sum;
	};
	p2[0]=1; FOR(i,1,MAXN-1)p2[i]=p2[i-1]*2%mod;
	f[0]=1; FOR(i,1,MAXN-1)f[i]=f[i-1]*i%mod;
	inv[MAXN-1]=qexp(f[MAXN-1],mod-2);
	DEC(i,MAXN-2,0)inv[i]=inv[i+1]*(i+1)%mod;
	auto C=[&](ll n,ll k){
		return n < k ? 0 : f[n] * inv[k] % mod * inv[n-k] % mod;
	};
	ll ans=qexp(3,n);
	FOR(i,n/2+1,n){
		ans -= 2 * C(n, n-i) % mod * p2[n-i] % mod, ans += mod, ans %= mod;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 238068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>edge[100005];
int col[100005];
bool bad[100005];
bool used[100005];
vector<int>C; int cnt;
void dfs(int v,int p,int c){
	if(used[v]) return;
	used[v] = 1; if(col[v] && col[v]!=c) bad[p]=1;
	col[v] = c; cnt++;
	for(int i=0;i<edge[v].size();i++){
		if(used[edge[v][i]] == 0){
			dfs(edge[v][i],p,-1*c);
		}
		else if(col[edge[v][i]] && col[edge[v][i]]==c)bad[p]=1;
	}
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	ll ans = 0; int cnt2;
	for(int i=1;i<=n;i++){
		if(used[i]) continue;
		cnt=0;
		dfs(i,i,1);
		if(cnt==1);
		else if(bad[i]) ans++;
		else ans+=2;
		if(cnt!=1) C.pb((bad[i]?1:2)); else cnt2++;
	}
	ans+=1LL*n*n-1LL*(n-cnt2)*(n-cnt2);
	//cout<<ans<<endl;
	for(int i=0;i<C.size();i++){
		for(int j=i+1;j<C.size();j++){
			if(C[i]==2&&C[j]==2) ans+=4;
			else ans+=2;
		}	
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11904
#include <stdio.h>

int main(void) {
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r); //60 40 30 -50 3
	
	if ((x < 0) || (y < 0)) {
		printf("No\n");
	} else if ((x + r <= W) && (y + r <= H)) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
n = int(input())
w = [input() for i in range(n)]

used_words = [w[0]]

def check_shiritori(b_word, a_word):
    if b_word[-1] == a_word[0]:
        return True
    else:
        return False

rule_flag = True
for i in range(1, n):
    if w[i] in used_words:
        rule_flag = False 
        break       
    if check_shiritori(w[i-1], w[i]):
        used_words.append(w[i])
    else:
        rule_flag = False
        break

if rule_flag is True:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a[10001],ans=0,bns=0,cns=0,dns=0;
char s[1001];

int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='W')ans++;
		if(s[i]=='E')bns++;
		if(s[i]=='N')cns++;
		if(s[i]=='S')dns++;
	}
	if((ans!=0&&bns!=0&&cns==0&&dns==0)||(ans!=0&&bns!=0&&cns!=0&&dns!=0)||(ans==0&&bns==0&&cns!=0&&dns!=0))
	{
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MN = 100100;
int v[MN],w[MN];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	string s,t;
	cin >> s >> t;
	int rs = 0;
	for(int i=0;i<s.size();i++) {
		v[i] = rs;
		rs += s[i]-'A'+1;
	}
	v[s.size()] = rs;
	rs = 0;
	for(int i=0;i<t.size();i++) {
		w[i] = rs;
		rs += t[i]-'A'+1;
	}
	w[t.size()] = rs;
	int q;
	cin >> q;
	while(q--) {
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--;b--;c--;d--;
		int ss = v[b+1]-v[a];
		int ts = w[d+1]-w[c];
		bool po = ((ts-ss)%3==0);
		cout << (po?"YES":"NO") << '\n';
	}
}

Measured memory_bytes: 1744
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 
  int N;
  cin>>N;
  vector<vector<int>>A(2,vector<int>(N));
  for(int i=0;i<=1;i++){
  
    for(int j=0;j<=N-1;j++){
    
      cin>>A[i][j];
    }
  }
  int ans=0;
  int count=0;
  for(int i=0;i<=N-1;i++){
  
    count=0;
    for(int j=0;j<=i;j++){
    
      count+=A[0][j];
    }
    for(int j=i;j<=N-1;j++){
    
      count+=A[1][j];
    }
    ans=max(ans,count);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3604
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
t = LI()
v = LI()

max_v = [0]*(N+1)  # 0秒後,t1秒後,t1+t2秒後,…の時点で出せる最大速度
for i in range(N-1):
    max_v[i+1] = min(v[i],v[i+1],max_v[i]+t[i])
for i in range(N-2,-1,-1):
    max_v[i+1] = min(max_v[i+1],v[i],v[i+1],max_v[i+2]+t[i+1])

ans = 0
for i in range(N):
    if t[i] >= (v[i]-max_v[i]) + (v[i]-max_v[i+1]):
        ans += t[i]*v[i]-(v[i]-max_v[i])**2/2-(v[i]-max_v[i+1])**2/2
    else:
        x = (t[i]+max_v[i]+max_v[i+1])/2
        ans += t[i]*x-(x-max_v[i])**2/2-(x-max_v[i+1])**2/2

print(ans)


Measured memory_bytes: 9332
#include <iostream>
#include <cstdio>
using namespace std;
int house[200008];
int main() {
    int k,n,i;
    cin >> k>>n;
    for (i=1; i<=n; i++) {
        cin >> house[i];
    }
    int max=-99,dis;
    for (i=1; i<n; i++) {
        dis=house[i+1]-house[i];
        if (dis>max) {
            max=dis;
        }
    }
    if (((k-house[n])+house[1])>max) {
        max=((k-house[n])+house[1]);
    }
    cout << k-max;
    return 0;
}


Measured memory_bytes: 1024
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,d=parseMap(split(readline()))
    if a<=c
        if b<=c
            println(0)
        else
            println(min(b,d)-c)
        end
    else
        if d<=a
            println(0)
        else
            println(min(d,b)-a)
        end
    end
end
main()

Measured memory_bytes: 161180
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

	string S;
	cin>>S;
	string T = "2019/04/30";

	if(T<S){
		cout << "TBD" << endl;
	}else{
		cout << "Heisei" <<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,W;cin>>N>>W;
    vvl dp(N+1,vl(100005,INF));
    rep(i,N+1)dp[i][0]=0;
    repl(i,1,N+1){
        ll w,v;cin>>w>>v;
        rep(j,100005){
            if(j>=v)dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w);
            else dp[i][j]=dp[i-1][j];
        }
    }
    per(i,100005){
        rep(j,N+1){
            if(dp[j][i]!=INF and dp[j][i]<=W){
            cout<<i<<endl;
            return 0;
            }
        }
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,a; cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, x, y;
        cin >> n;
        pair<long double, pair<int,int> > a[2 * n];
        long double ans = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x >> y;
            a[i].ff = atan2(y, x);
            a[i].ss.ff = x;
            a[i].ss.ss = y;
        }
        sort(a, a + n);
        for(int i = n; i < 2 * n; i++) a[i] = a[i - n], a[i].ff += 2 * PI;
        for(int i = 0; i < n; i++)
        {
            x = 0, y = 0;
            for(int j = i; j < n + i; j++)
            {
                x += a[j].ss.ff;
                y += a[j].ss.ss;
                ans = max((ll)ans, x * x + y * y);
            }
        }
        ans = sqrt(ans);
        cout << fixed << setprecision(11) << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 
  int i,a=0,j,sai1[6],sai2[6];
  char dic[101];
  for(i=0;i<6;i++){
		scanf("%d",&sai1[i]);
		sai2[i]=sai1[i];
  }
  scanf("%s",dic);

  for(i=0;i<=100;i++){
		if(dic[i]=='\0')break;
		
		if(dic[i]=='W'){
			sai1[0]=sai2[2];
			a=sai2[2];
			sai1[2]=sai2[5];
			sai1[3]=sai2[0];
			sai1[5]=sai2[3];
			
			for(j=0;j<6;j++){
				sai2[j]=sai1[j];
			}
			}else if(dic[i]=='E'){
			sai1[0]=sai2[3];
			a=sai2[3];
			sai1[2]=sai2[0];
			sai1[3]=sai2[5];
			sai1[5]=sai2[2];
			
			for(j=0;j<6;j++){
				sai2[j]=sai1[j];
			}
			}else if(dic[i]=='S'){
			sai1[0]=sai2[4];
			a=sai2[4];
			sai1[1]=sai2[0];
			sai1[4]=sai2[5];
			sai1[5]=sai2[1];
			
			for(j=0;j<6;j++){
				sai2[j]=sai1[j];
			}
			}else if(dic[i]=='N'){
			sai1[0]=sai2[1];
			a=sai2[1];
			sai1[1]=sai2[5];
			sai1[4]=sai2[0];
			sai1[5]=sai2[4];
			
			for(j=0;j<6;j++){
				sai2[j]=sai1[j];
			}
		}
	}
	printf("%d\n",a);
	return 0;
}

	
		
		

Measured memory_bytes: 596
import java.util.*;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner stdIn=new Scanner(System.in);
        long N=stdIn.nextInt();
        long A=stdIn.nextInt();
        long B=stdIn.nextInt();

        
        long tt=(N-2)*(B-A)+1;
        if(tt<0){
            System.out.println(0);
        }else{
            System.out.println(tt);
        }
    }
}

Measured memory_bytes: 21076
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);

    if( (a+b) % 2 != 0 ){
        printf("IMPOSSIBLE\n");
    }else{
        printf("%d\n",(a+b)/2 );
    }
    return 0;
}

Measured memory_bytes: 128
use proconio::*;

fn run() {
    input! {
        n: u64,
        k: u64,
    }
    const MOD: u64 = 1_000_000_007;
    let mut large = 0;
    let mut small = 0;
    let mut ans = 0;
    for i in 1..=(n + 1) {
        large += n + 1 - i;
        small += i - 1;
        if i >= k {
            ans = (large - small + 1 + ans) % MOD;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2140
from collections import deque
K =int(input())

INF = 10**9+7
A = [INF] * (K)

q = deque()
q.append(1)
A[1] = 1
while q:
    x = q.popleft()
    if A[(x*10)%K] > A[x]:
        A[(x*10)%K] = A[x]
        q.appendleft((x*10)%K)
    if A[(x+1)%K] > A[x]+1:
        A[(x+1)%K] = A[x]+1
        q.append((x+1)%K)

print(A[0])

Measured memory_bytes: 6060
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;

int main() {
    while(true) {
LOOP:
        string s;
        getline(cin, s);
        const char* c = s.c_str();
        if(*c == '.') return 0;

        stack<char> st;

        for (char& ch : s) {
            if(ch == '[') {
                st.push('[');
                continue;
            } else if(ch == '('){
                st.push('(');
                continue;
            } else if(ch == ']') {
                if(st.empty()) {
                    cout << "no" << endl;
                    goto LOOP;
                }
                if(st.top() == '[') {
                    st.pop();
                    continue;
                }
                else {
                    cout << "no" << endl;
                    goto LOOP;
                }
            } else if(ch == ')') {
                if(st.empty()) {
                    cout << "no" << endl;
                    goto LOOP;
                }
                if(st.top() == '(') {
                    st.pop();
                    continue;
                } else {
                    cout << "no" << endl;
                    goto LOOP;
                }
            }
        }
        if(st.empty()) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3004
N = int(input())

# 最初の入力を初期値とする
T, A = map(int, input().split())

# N-1回入力を繰り返す
for i in range(N-1):
    # tとaを入力
    t, a = map(int, input().split())

    # 最小公倍数nは max(⌈A/x⌉, ⌈B/y⌉) で求めることができる
    #マイナスの//は切り上げになる
    n = max(-(-T // t), -(-A // a))
    # 最小公倍数に比率を掛ける
    T = n*t
    A = n*a
    
# 結果の出力
print(T+A)



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

void Main() {
  long long N, K;
  cin >> N >> K;

  long long mod = N % K;
  cout << min(mod, K - mod) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  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 MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int dfs(int v, vector<bool> visited, Graph G){
    bool all_visited = true;
    rep(i, visited.size()){
        if(!visited[i]) all_visited = false;
    }
    if(all_visited) return 1;
    
    int ret = 0;
    
    rep(i, visited.size()){
        if(G[i][v] == 0) continue;
        if(visited[i]) continue;
        
        visited[i] = true;
        ret += dfs(i, visited, G);
        visited[i] = false;
    }
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;
    Graph G(n, vector<int>(n));
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = 1; G[b][a] = 1;
    }
    vector<bool> visited(n);
    
    visited[0] = true;
    
    cout << dfs(0, visited, G) << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, long long C, long long D, std::string S){
    for (int i = A - 1; i < C - 1; i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << NO << endl;
            return;
        }
    }
    for (int i = B - 1; i < D - 1; i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << NO << endl;
            return;
        }
    }
    if (C > D) {
        // A < B < D < C
        int mbd = 0;
        int j = 0;
        for (int i = B - 2; i < min(D + 1, N); i++) {
            if (S[i] == '.') j++;
            else j = 0;
            mbd = max(mbd, j);
        }
        if (mbd < 3) {
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    std::string S;
    std::cin >> S;
    solve(N, A, B, C, D, S);
    return 0;
}



Measured memory_bytes: 772
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll v[10000];

void solve(long long N) {
  N--;
  ll y = 1;
  ll k = 0;
  while (N > 0) {
    y *= 26;
    N -= y;
    k++;
  }
  if (N != 0) {
    N += y;
  } else {
    k++;
  }
  ll i = 0;
  if (N == 0) {
    v[i++] = 0;
  }
  while (N > 0) {
    v[i++] = N % 26;
    N /= 26;
  }
  for (int j = k - 1; j >= 0; j--) {
    char ch = 'a' + v[j];
    cout << ch;
  }
  cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3720
n,l = map(int, input().split())
lst = list(range(l,l+n))
lst2 = []
for i in lst:
  if i > 0:
    lst2.append(i)
  else:
    lst2.append(-i)
x = sum(lst)-lst[lst2.index(min(lst2))]
print(x)

Measured memory_bytes: 2940
// AGC 021 A

#include <iostream>
#include <cmath>
using namespace std;

int hoge(long long N){
  long long itemp;
  int power;
  int anstmp,ans;

  itemp = N;
  for(int i=0; ; i++){
    itemp /=10;
    if(itemp == 0){
      power = i;
      break;
    }
  }
  // cout <<"power"<< power<<" "<<N<<endl;
  // ftemp += (double)N;
  // ftemp = log10(ftemp);
  // power = floor(ftemp);
  itemp = 1;
  for(int i=0; i<power; i++){
    itemp *=10;
  }
  if(power>0){
    ans = power*9 + N/itemp - 1;
    anstmp = hoge(N%itemp) + N/itemp;
    if(anstmp > ans){
      ans = anstmp;
    }
  }else{
    ans = N/itemp;
  }
//  cout << ans <<" "<<N<<" " <<power<<" " << itemp<<" "<<power <<endl;
  return ans;
}

int main(){
  long long N;
  int ans;

  cin >> N;

  ans = hoge(N);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define __ ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
double R;
int main(){
__;
cin>>R;
cout<<2*R*3.1415;
}


Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
bool used[100007];
vector<int> path[100007];
queue<int> q1,q2;
int main(){
	int n;
	int i,j,k;
	int t;
	int a,b;
	int s[2]={0};
	cin>>n;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	q1.push(0);
	q2.push(n-1);
	for(i=0;;i++){
		if(q1.empty() && q2.empty())break;
		t=q1.size();
		for(j=0;j<t;j++){
			a=q1.front();
			q1.pop();
			if(used[a])continue;
			used[a]=true;
			s[0]++;
			for(k=0;k<path[a].size();k++){
				if(used[path[a][k]])continue;
				q1.push(path[a][k]);
			}
		}
		t=q2.size();
		for(j=0;j<t;j++){
			a=q2.front();
			q2.pop();
			if(used[a])continue;
			used[a]=true;
			s[1]++;
			for(k=0;k<path[a].size();k++){
				if(used[path[a][k]])continue;
				q2.push(path[a][k]);
			}
		}
	}
	if(s[0]>s[1])cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}
				
		
		


Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 1000000000
int n,k;
int x[100005],y[100005],ans[100005];
vector<int>g[100005];
bool o=true;
void dfs(int v,int p){
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u!=p){
            dfs(u,v);
            if(x[u]==INF)continue;
            if(x[v]==INF){
                x[v]=x[u]-1;
                y[v]=y[u]+1;
            }else{
                int r=x[u]-1,l=y[u]+1;
                if(r%2!=x[v]%2)o=false;
                if(l<x[v]||y[v]<r)o=false;
                x[v]=max(r,x[v]);
                y[v]=min(l,y[v]);
            }
        }
    }
}
void dfs2(int v,int p){
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u!=p){
            if(ans[v]-1>=x[u])ans[u]=ans[v]-1;
            else ans[u]=ans[v]+1;
            dfs2(u,v);
        }
    }
}
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        g[--a].push_back(--b);
        g[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        x[i]=INF;
        y[i]=INF;
    }
    cin>>k;
    for(int i=0;i<k;i++){
        int v,p;
        cin>>v>>p;
        x[--v]=p;
        y[v]=p;
    }
    dfs(0,-1);
    if(!o){
        cout<<"No\n";
        return 0;
    }
    ans[0]=x[0];
    dfs2(0,-1);
    cout<<"Yes\n";
    for(int i=0;i<n;i++)cout<<ans[i]<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    int A, B; cin >> A >> B;

    int price = -1;
    for(int x = 1; x <= 1000; x++){
        if((2*x)/25 == A and x/10 == B){
            price = x;
            break;
        }
    }
    cout << price << endl;



    return 0;
}

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

int main() {
  int N,Z=0;
  cin>>N;
  vector<int> p(N);
for (int i=0;i<N;i++) {
  cin>>p.at(i);
  Z+=p.at(i);
}
  int X=Z/2,Q=0,a=0;
  while(X>Q){
    Q+=p.at(a);
    a++;
  }
  if(a>0){
    a--;
  }
  cout<<min(abs(Z-2*Q),abs(Z-2*(Q-p.at(a))))<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int A,B;
    scanf("%d %d", &A, &B);
    
    if(A > 8 || B > 8){
        printf(":(");
    }else if ((A >= 0) && (B >= 0)){
        printf("Yay!");
    }else{
        printf(":(");
    }
    return 0;
}

Measured memory_bytes: 888