akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String[] outs = {"deficient number", "perfect number", "abundant number"};
                int n = sc.nextInt();
                //ツ篠ゥツ身ツづーツ甘慊づ楪姪アツ青板づ個和
                while(n != 0){ 
                        n = n-getS(n);
                        String out = ""; 
                        if(n < 0){ 
                                out = outs[2];
                        }else if(n == 0){ 
                                out = outs[1];
                        }else{
                                out = outs[0];
                        }   
                        System.out.println(out);
                        n = sc.nextInt();
                }   
        }   
        static int getS(int n){
                int sum = 0;
                for(int i = 1 ; i*i <= n ; i++){
                        if(n%i==0){
                                sum += i;
                                if(i*i != n){ 
                                        sum += n/i;
                                }   
                        }     
                }   
                sum -= n;
                return sum;
        }   
}

Measured memory_bytes: 12000
N = int(input())
A = [int(x) for x in input().split()]

cnt = [0 for _ in range(10**5 + 5)]
for a in A:
    cnt[a] += 1

ans = sum(A)

Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())

    ans -= B * cnt[B]
    ans += C * cnt[B]

    cnt[C] += cnt[B]
    cnt[B] = 0

    print(ans)

Measured memory_bytes: 20580
def main():
    x = int(input())
    n = int(pow(x,0.2))
    m = int(pow(x,0.25))

    ans = (0,0)
# B<0
    for a in range(n+1):
        for b in range(n+1):
            if a**5 + b**5 == x:
                ans = (a,-b)
# B>=0
    for a in range(m+1):
        for b in range(m+1):
            if a**5 - b**5 == x:
                ans = (a,b)
    
    print(ans[0],ans[1])
main()

Measured memory_bytes: 9336
#include <iostream>
#include <algorithm>
#include <functional>

#define N_HILLS 10
#define N_TOP   3

using namespace std;


void input_hills(int *hills)
{
  for(int i = 0; i < N_HILLS; ++i){
    cin >> hills[i];
  }
}


void output_top_hills(int *hills)
{
  // descending order
  sort(hills, hills+N_HILLS, greater<int>());

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


int main()
{
  int hills[N_HILLS];

  input_hills(hills);
  output_top_hills(hills);

  return 0;
}

Measured memory_bytes: 1176
using System;
    class Program
    {
        static long Gcd(long a, long b) {
            if (a < b)
                return Gcd(b, a);
            long d = 0;
            do {
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }
        static long Lcd(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        static void Main(string[] args)
        {
            long[] x = new long[1000];
            long[] y = new long[1000];
            int count=-1;
            string str = Console.ReadLine();
            while (!string.IsNullOrEmpty(str))
            {
                count++;
                string[] s = str.Split(' ');
                long a = long.Parse(s[0]);
                long b = long.Parse(s[1]);
                x[count] = Gcd(a, b);
                y[count] = Lcd(a, b);
                str = Console.ReadLine();
            }
            for (int n = 0; n <= count; n++)
                Console.WriteLine(x[n]+" "+y[n]);
        }
    }

Measured memory_bytes: 5620
#AGC033-B LRUD Game
"""
1つの駒が二次元グリッド上(HxW)にある。最初駒は(sr,sc)にある。
iターン目にそれぞれSiとTi方向に動くか、もしくは動かないを選択できる。
高橋くんはSiの動作を選ぶことができ、盤面から駒を出す事ができたら勝つ。(h or w < 1 or H < h or W < w)
青木くんはTiの操作を選ぶことができ、ゲーム終了までずっと盤面上に駒が存在すれば勝つ。
両者が最適に行動した時、どちらが勝つか出力せよ。(青木くんが勝つならYES)

"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

H,W,N = map(int,readline().split())
sh,sw = map(int,readline().split())
S = readline().rstrip().decode('utf-8')
T = readline().rstrip().decode('utf-8')

#上下左右の余裕
UDLR = [sh-1,H-sh,sw-1,W-sw]
#青木くんが超えてはならない逆端
UDLR3 = [H-sh,sh-1,W-sw,sw-1]
UDLR3 = [-i for i in UDLR3]
#高橋くんが移動できる最大値
#青木くんの行動によってマイナスされるが、この時青木くんの行動によって逆端を超えてはならない
UDLR2 = [0,0,0,0]

m = {"U":0,"D":1,"L":2,"R":3}
m2 = {"U":1,"D":0,"L":3,"R":2}
for i in range(N):
    s,t = m[S[i]],m2[T[i]]

    UDLR2[s] += 1
    
    for i in range(4):
        if UDLR2[i] > UDLR[i]:
            print("NO")
            exit()
    
    if UDLR2[t] -1 >= UDLR3[t]:
        UDLR2[t] -= 1

print("YES")


Measured memory_bytes: 74016
// dp[i]=min cost occured to reach ith position


#include<bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    vector<vector<int>> dp(n, vector<int>(3));
    vector<int> points(3);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>points[j];
        }
        for(int k=0;k<3;k++){
            // will make dp[i][k]
            dp[i][k]=0;
            for(int j=0;j<3;j++){
                if(j==k){
                    continue;
                }
                if((i-1)>=0){
                    dp[i][k]=max(dp[i-1][j], dp[i][k]);
                }
            }
            dp[i][k]+=points[k];
        }
    }

    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(dp[n-1][i], ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8744
n=int(input())

a=[int(x) for x in input().split()]

i=0
ans=0
saigo=0
k=1
kosuu=n

while i<=n-1:
    if a[i]!=k:
        ans+=1
        kosuu-=1
    else:
        saigo=a[i]
        k+=1
    i+=1

if kosuu==0:
    print(-1)
    exit()

if kosuu==saigo:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 100752
#include <stdio.h>
#define M 100005

int A[M],n;

int partition(int p,int r){
    int x=A[r],kari;
    int j= p -1;
    for(int i=p;i<r;i++){
        if(A[i]<= x){
            j++;
            kari= A[i];
            A[i] = A[j];
            A[j] = kari;
        }
    }
    kari = A[j+1];
    A[j+1]= A[r];
    A[r] = kari;
    return j+1;
}
int main(void){
    int i,q;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }

    q= partition(0,n-1);
    for(i=0;i<n;i++){
        if(i==q)printf("[");
        printf("%d",A[i]);
        if(i==q)printf("]");
        if(i!=n-1)printf(" ");
    }
    printf("\n");
    return 0;
}




Measured memory_bytes: 2136
object Main extends App {
  val in = scala.io.Source.stdin.getLines
  val in2 = in.map(_.split(' ').map(_.toInt).toSeq).toSeq.head
  //println(in2)
  val s = in2.sorted
  val ret = if(s == Seq(1,4,7,9)) "YES" else "NO"
  println(ret)
}


Measured memory_bytes: 27332
#include <iostream>
using namespace std;
int main()
{
	long long n,m,x,total=0,sum=0;
	cin>>n>>m>>x;
	long long a[m];
	for (int i=1;i<=m;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		sum=0;
		long long b[m];
		for (int j=1;j<=m;j++)
		{
			cin>>b[j];
			sum+=b[j]*a[j];
		}  
		sum+=x;
		if (sum>0)  total++;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
from math import *

if __name__ == '__main__':
    N = int(input())
    s = input().rstrip().split(' ')
    A = [int(elem) for elem in s]

    left = []
    total = sum(A)
    for elem in A:
        left.append(total - elem)
        total -= elem

    active = 1
    route = [min(active-A[0], left[0])]
    if route[0] <= 0: 
        if 0 == N and route[0] == 0:
            pass
        else:
            print(-1)
            exit()

    for i in range(1,N+1):
        active = active*2-A[i]
        route.append(min(active, left[i]))
        #print(route[i])
        if route[i] <= 0: 
            if i == N and route[i] == 0:
                break
            else:
                print(-1)
                exit()

    print(sum(route) + sum(A))

Measured memory_bytes: 27832
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d[100100];
ll v[100100];

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

int main(void){
	int n,i;
	ll ans=1ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> d[i];
		++v[d[i]];
	}
	if(d[0]){
		cout << 0 << endl;
		return 0;
	}
	if(v[0]>1){
		cout << 0 << endl;
		return 0;
	}
	for(i=1; i<n; ++i){
		mul_mod(ans,rwpw(v[i-1],v[i]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

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

	vector<ll> A(100010, 0), B(100010, 0);
	for (int i = 0; i < N+1; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];

	ll ans = 0;

	for (int i = 0; i < N; i++) {
		ll left = min(A[i], B[i]);
		ans += left;
		A[i] -= left;
		B[i] -= left;

		ll right = min(A[i+1], B[i]);
		ans += right;
		A[i+1] -= right;
		B[i] -= right;
	}

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


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){

    int H = 0;
    int A = 0;

    scanf("%d %d", &H, &A);

    if (H % A == 0){

        H = H / A;

    } else{

        H = H / A + 1;

    }
    printf("%d", H);

    return 0;
}

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

int main() {
  vector<int> a(4), b(4);
  while (cin >> a[0]) {
    for (int i = 1; i < 4; i++) cin >> a[i];
    for (int i = 0; i < 4; i++) cin >> b[i];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      if (find(b.begin(), b.end(), a[i]) != b.end()) {
        if (a[i] == b[i]) hit++;
        else blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
}

Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int main(void)
{
	int N, T;
	cin >> N >> T;
	int min = 1001;
	for (int i = 0; i < N; i++){
		int c, t;
		cin >> c >> t;
		if (T < t) continue;
		if (c < min)
			min = c;
	}
	if (min == 1001)
		cout << "TLE" << endl;
	else
		cout << min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
#define ll long long
const ll INF=0x3f3f3f3f;
const ll P=1e9+7;
ll fc[300000];

ll qpow(ll a,ll b,ll p){
	ll t=1,y=a;
	while (b>0){
		if (b&1) t=t*y%p%p;
		y=y*y%p%p;
		b>>=1;
	}
	return t;
}

ll comb(int n,int m){
	if (n==m||m==0) return 1;
	if (n<m) return 0;
	return fc[n]*qpow(fc[n-m]*fc[m]%P,P-2,P)%P%P;
}

void create(){

	fc[1]=1;
	for (int i=2;i<300000;i++){
		fc[i]=fc[i-1]*i%P%P;
	}
}


int main(){
	create();
	int h,w,a,b;
	
	cin>>h>>w>>a>>b;
	
	ll ans=comb(h+w-2,h-1);
	for (int i=1;i<=a;i++){
		//cout<<comb(h+b-a+i-2,h-a+i-1)*comb(w-b+i-2,i-1)<<endl;
		ans=ans-comb(h+b-a+i-2,h-a+i-1)*comb(w-b+(a-i+1)-2,(a-i+1)-1)%P;
		if (ans<=0) ans+=P;
	}
	cout<<ans<<endl;
	
}

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

int main() {
  
  int n, k ; 
  cin >> n >> k;
  
  int ans = 1 ; 
  
  for (int i = 0 ; i<n ; i++){
    if ( ans > k )
      ans += k ; 
    else 
      ans *= 2 ; 
      
  }
  
 cout << ans << endl ;

  
}




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

// unordered_map<int, unordered_map<int, long>> dp;
vector<vector<long>> dp;
long solve(int i, int profit, vector<int>&weights, vector<int>&profits)
{
    if(i >= weights.size())
    {
        return profit <= 0 ? 0 : INT_MAX;
    }
    if(profit <= 0)
        return 0;
    if(dp[i][profit] != -1)
        return dp[i][profit];
    dp[i][profit] = min(solve(i + 1, profit, weights, profits), solve(i + 1, profit - profits[i], weights, profits) + weights[i]);
    return dp[i][profit];
}

int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> weights(n), profits(n);
    int profit = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> weights[i] >> profits[i];
        profit += profits[i];   
    }
    dp = vector<vector<long>> (n, vector<long>(profit + 1, -1));
    int ans = -1;
    for(int i = profit; i >= 0; i--)
    {
        if(solve(0, i, weights, profits) <= w)
        {
            ans = i;
            break;
        }
        if(ans != -1)
            break;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int main () {
	string s;
	cin >> s;
	if (s=="AKIHABARA"||s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHABR"||s=="AKIHBARA"||s=="AKIHBAR"||s=="AKIHBRA"||s=="AKIHBR"
	||s=="KIHABARA"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHABR"||s=="KIHBARA"||s=="KIHBAR"||s=="KIHBRA"||s=="KIHBR") cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int b;
    int temp=0;
    cin>>b;
    int a[b];
    long long int sum=0;
    for(int i=0;i<b;i++){
        cin>>a[i];
    }
    //cout<<a[0];
    for(int i=0;i<b-1;i++){
        for(int j=i+1;j<b;j++){
            if(a[i]<a[j]){
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    //cout<<a[0]<<endl;
    for(int i=1;i<b;i++){
        sum=sum+a[i];
    }
    if(a[0]<sum){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a[n][m];
  int list[m+1]={};
  rep(i,n){
    cin >> a[i][0];
    int k = a[i][0];
    repi(j,1,k+1){
      cin >> a[i][j];
      int t = a[i][j];
      list[t]++;
    }
  }
  int ans = 0;
  repi(j,1,m+1){
    if(list[j]==n){
      ans++;
    }
  }
  cout << ans << endl;
      
   
  return 0;
}

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

typedef long long ll;
const ll INF = 1LL << 60;

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

ll N, M;
vector<vector<ll>> graph;
vector<ll> dp;

ll rec(ll l);

int main() {
  cin >> N >> M;
  graph = vector<vector<ll>>(N, vector<ll>());
  dp = vector<ll>(N+100,-1);
  for (ll i=0;i<M;i++){
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    graph.at(x).push_back(y);
  }

  //dp(i)(0<=i<N)の最大値を求めればよい
  ll ans = 0;
  for (ll i=0;i<N;i++){
    chmax(ans, rec(i));
  }
  cout << ans << endl;
}

ll rec(ll l){
  if (dp.at(l) != -1) return dp.at(l);

  ll ret = 0;
  for (auto i : graph.at(l)){
    chmax(ret, rec(i) + 1);
  }
  dp.at(l) = ret;
  return ret;
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a[2], k;
    cin >> a[0] >> a[1] >> k;

    int c = 0;
    for (int i = 0; i < k; i++) {
        a[c] /= 2;
        a[c ^ 1] += a[c];
        c ^= 1;
    }

    cout << a[0] << ' ' << a[1] << endl;

    return 0;
}

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

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

    int a[n][2];

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

    int ans = 0;
    int count = 0;
    for(int i = 0; i < n; i++){
        count = a[i][1] - a[i][0];
        if(count == 0){
            ans += 1;
        } else {
            ans += count + 1;
        }
    }

    cout << ans << endl;
}

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

#define ll long long 
#define inf 1000000007

int main () {
  ll n;
  cin >> n;
  int h[3] = {
    3, 5, 7  
  };
  vector<ll> ans;
  ans.push_back(375);
  ans.push_back(753);
  ans.push_back(537);
  ans.push_back(573);
  ans.push_back(357);
  ans.push_back(735);
  int l; 
  for (int p = 4; p <= 9; p++) {
  int sub[p];
  for (int i = 1; i <= p; i++) {
    for (int j = 1; j <= p; j++) {
      if (i + j >= p) {
          
      } 
      else {
        l = p - i - j;
        int itr = 0;
        for (int ii = 0; ii < i; ii++) {
          sub[itr] = 3;  
          itr++;
        }     
        for (int jj = 0; jj < j; jj++) {
          sub[itr] = 7;
          itr++;  
        }
        for (int lll = 0; lll < l; lll++) {
          sub[itr] = 5;
          itr++;  
        }
        sort(sub, sub + p);
        do {
          ll qq = 0;
          ll pp = 1;
          for (int ii = 0; ii < p; ii++) {
            qq += sub[ii] * pp;
            pp = pp * 10;
          }    
          ans.push_back(qq);
        } while (next_permutation(sub, sub + p));
      } 
    }  
  }
  }
  ll answer = 0;
  for (ll i = 0; i < ans.size(); i++) {
    if (n >= ans[i]) {
      answer++;  
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=a;i<=b;i++)
#define D(i,a,b) for (int i=a;i>=b;i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}
int x,y,n,m,vis[N],dui[N],r,in1[N];
int nedge,head[N*2],to[N*2],Next[N*2];
#define V to[i]
void add(int a,int b){
   Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
signed main(){
	n=read();
	F(i,1,n-1){
		x=read();y=read();add(x,y);add(y,x);in1[x]++;in1[y]++;
	}
	F(i,1,n){
		if (in1[i]==1) dui[++r]=i,vis[i]=1;
	}
	F(l,1,r){
		int t=dui[l];
		go(i,t){
			if (vis[V]!=2){
				vis[V]=vis[t]=2;
				go(j,V){
					in1[to[j]]--;
					if (in1[to[j]]==1&&vis[to[j]]==0) dui[++r]=to[j];
				}
				break;
			}
		}
	}
	F(i,1,n){
		if (vis[i]!=2) return puts("First"),0;
	}
	puts("Second");
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
int find(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}


int main(void) {
    long int N,ans=0,A,B;
    cin >> N;
    cin >> A;
    cin >> B;
    int n[10000];
    
    forr(i,1,N){
       int s = find(i);
       if(s>=A && s <= B){
           ans = ans + i;
       }
    }

      
    
      cout << ans << "\n";
  

  return 0;
}

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

int main() {
  
  int k,x;
  cin >> k >> x;
  
  for(int i = k-1; i > 0; i--) cout << x - i << " ";
  
  rep(i,k) {
    if(i == k-1) {
      cout << x + i << endl;
      break;
    }
    cout << x + i << " ";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX 1e5 + 1

int main() {
    int n, q, temp;
    long long sum = 0;
    std::cin >> n;
    std::vector<int> a(MAX, 0);

    for (int i = 0; i < n; i++) {
        std::cin >> temp;
        a.at(temp)++;
        sum += temp;
    }
    std::cin >> q;
    std::vector<int> b(q), c(q);
    for (int i = 0; i < q; i++) {
        std::cin >> b[i] >> c[i];
    }
    for (int j = 0; j < q; j++) {
        //各はintだが、積はこのままではintになってoverflowすることもある。ここの型変換しない場合は、b,cをlong　long型にする
        sum -= (long long)b[j] * a.at(b[j]);
        sum += (long long)c[j] * a.at(b[j]);
        a.at(c[j]) += a.at(b[j]);
        a.at(b[j]) = 0;

        std::cout << sum << std::endl;
    }
    return 0;
}

Measured memory_bytes: 4568
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();

            if (a >= 10 || b >= 10)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(a * b);
            }            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int n= scn.nextInt();
		int x= scn.nextInt();
		int y =scn.nextInt();
		ArrayList<ArrayList<Integer>> al = new ArrayList<>();
		res(n,x,y);

	}
	public static void res(int n,int x ,int y){
		ArrayList<ArrayList<Integer>>al = new ArrayList<>();
		for(int i=0;i<n;i++){
			ArrayList<Integer> al1 = new ArrayList<Integer>();
			al.add(al1);
		}
		for(int i=1;i<n;i++){
		   ArrayList<Integer> al1 = al.get(i-1);
		   ArrayList<Integer> al2 = al.get(i);
		   al1.add(i);
		   al2.add(i-1);
		   
		}
		ArrayList<Integer> al1 = al.get(x-1);
		al1.add(y-1);
		//al.add(al1);
		al1 =al.get(y-1);
		al1.add(x-1);
		
		HashMap<Integer,Integer> hm =new HashMap<>();
		for(int i=0;i<n;i++){
			bfs(i,al,hm);
		}
		for(int i=1;i<n;i++){
			if(hm.containsKey(i)){
			
				System.out.println(hm.get(i)/2);
			}else{
				System.out.println(0);
			}
		}
	
	}
	public static void bfs(int s,ArrayList<ArrayList<Integer>> al,HashMap<Integer,Integer> hm ){
		LinkedList<pair> q = new LinkedList<>();
		HashSet<Integer> hs = new HashSet<>();
		q.add(new pair(s,0));
		while(q.size()>0){
		     pair p1 =q.removeFirst();
			if(hs.contains(p1.val)){
				continue;
			}
			  if(hm.containsKey(p1.dis)){
				  hm.put(p1.dis,hm.get(p1.dis)+1);
			  }else{
				  hm.put(p1.dis,1);
			  }
			hs.add(p1.val);
			ArrayList<Integer> al1 = al.get(p1.val);
			for(int val : al1){
				q.addLast(new pair(val,p1.dis+1));
			}
		}
	}
	
	public static class pair{
		int val ;
		int dis;
		public pair(int val ,int dis){
			this.val=val;
			this.dis=dis;
		}
	}

}

Measured memory_bytes: 279748
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int M = 300000 + 1;
int query(int C, vector<int>& max_a){
  if(C == 1) return 0;
  int res = max_a[M - 1] % C;
  for(int i = 1; i * C - 1 < M; i++){
    res = max(res, max_a[i * C - 1] % C);
  }
  return res;
}

int main(){
  int N, Q;
  while(cin>>N>>Q){
    vector<bool> card(M, false);
    REP(i, N){
      int t; cin>>t;
      card[t] = true;
    }
    vector<int> max_a(M, 0);
    REP(i, M - 1) max_a[i + 1] = (card[i + 1]) ? i + 1 : max_a[i];
    REP(i, Q){
      int C; cin>>C;
      printf("%d\n", query(C, max_a));
    }
  }
  return 0;
}

Measured memory_bytes: 2324
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

int INF = 1000000005;
using namespace std;

int main() {
    ll n,a[100];
    cin >> n;
    a[0] = 2, a[1] = 1;
    FOR(i,2,n+1) {
        a[i] = a[i - 1] + a[i - 2];
    }
    cout << a[n] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    if(s.size()%2==1)
        {
            cout<<"No\n";
            
        }
    else
        {
            string flag="Yes";
            for(int i=0;i<s.size()/2;i++)
                {
                    if(s[i]!=s[i+s.size()/2])
                        {
                            flag="No";
                        }
                }
                
                cout<<flag<<endl;
        }
        
     
     
}


Measured memory_bytes: 256
n,m=input().split()
n=int(n)
m=int(m)
l=[]
for i in range(m):
    t=input().split()
    l.append((int(t[0]),int(t[1])))
l.sort()
i=0
res=0
flag=False
while True:
    ra=l[i][1]
    while l[i][0]<ra:
        if i==m-1:
            flag=True
            break
        ra=min(ra,l[i][1])
        i+=1
    res+=1
    if flag:
        break
print(res)


Measured memory_bytes: 17008
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
#include<iostream>
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}

ll MOD = 1000000007;
int main() {
	ll Q;
	cin >> Q;
  	ll A[100010],B[100010];
  	for (ll i = 3; i<=100000; i+=2){
      if(prime(i)&&prime((i+1)/2))
        A[i]=1;
      else 
        A[i]=0;
    }
  	B[1]=0;
  	B[3]=1;
  	for(ll i=3; i<=100000; i+=2){
      B[i]=B[i-2]+A[i];
    }
    ll l,r;
  	for(ll i=0; i<Q; ++i){
      cin>>l>>r;
      cout<<B[r]-B[l-2]<<endl;
      }
}
        
      
  





Measured memory_bytes: 2176
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

int x, y;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> x >> y;
    if(y%2 == 0 && x * 2 <= y && x * 4 >= y){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);

	for (ll i = A / 0.08; static_cast<ll>(i * 0.08) <= A; ++i)
	{
		if (static_cast<ll>(i * 0.08) == A && static_cast<ll>(i * 0.1) == B)
		{
			cout << i << endl;
			return EXIT_SUCCESS;
		}
	}
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	s += string(15, 'o');
	s = s.substr(0, 15);

	bool can_win = count(s.begin(), s.end(), 'o') >= 8;
	cout << (can_win ? "YES" : "NO") << endl;
	return 0;
}


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

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	ll x1 = b * d, x2 = a * c, x3 = a * d, x4 = b * c;
	
	cout << max({x1, x2, x3, x4});
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3688
#!/usr/bin/env python3
import sys


def solve(b: str):
    if b is 'A':
        print('T')
    elif b is 'T':
        print('A')
    elif b is 'C':
        print('G')
    else:
        print('C')

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    b = next(tokens)  # type: str
    solve(b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N = int(input())
W = [list(input().split()) for _ in range(N)]
S = sorted(W)
for i in range(N):
  for j in range(i+1, N):
    if S[i][0] == S[j][0] and int(S[i][1]) < int(S[j][1]):
      a = S[i]
      S[i] = S[j]
      S[j] = a
for k in range(N):
  print(W.index(S[k])+1)

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

struct data {
  long long d, c;
};

long long m;
vector<data> v;

long long solve();
long long calc(data& x);

int main() {
  cin >> m;
  v.resize(m);
  for(int i = 0; i < m; ++i) cin >> v[i].d >> v[i].c;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, now = 0;
  for(int i = 0; i < m; ++i) ans += calc(v[i]);
  for(int i = 0; i < m; ++i) {
    now += v[i].d;
    ++ans;
    if(now >= 10) {
      ++ans;
      now = now / 10 + now % 10;
    }
  }
  return --ans;
}

long long calc(data& x) {
  if(x.c <= 1) return 0;
  long long res = 0;
  if(x.d * 2 >= 10) {
    bool ch = x.c % 2;
    long long num = x.d * 2;
    num = num / 10 + num % 10;
    data newx = {num, x.c / 2};
    res += x.c / 2 * 2 + calc(newx);
    if(ch) {
      x.d += newx.d;
      ++res;
      if(x.d >= 10) {
        ++res;
        x.d = x.d / 10 + (x.d % 10);
      }
    }
    else
      x = newx;
    return res;
  }
  bool ch = x.c % 2;
  long long num = x.d * 2;
  data newx = {num, x.c / 2};
  res += x.c / 2 + calc(newx);
  if(ch) {
    x.d += newx.d;
    ++res;
    if(x.d >= 10) {
      ++res;
      x.d = x.d / 10 + (x.d % 10);
    }
  }
  else
    x = newx;
  return res;
}

Measured memory_bytes: 3328
#include <iostream>
#include<cmath>
using namespace std;
int main(void){
    long long int N,a[200000],x=0,y,min=10000000000,total=0;
    
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
        total+=a[i];
    }
    for(int i=0;i<N-1;i++){
        x+=a[i];
        y=total-x;
        if(abs(x-y)<min){
            min=abs(x-y);
        }
    }
    cout<<min<<endl;
    //cout<<x<<endl<<y;
    return 0;
}


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

using namespace std;
int main(){
  int n; cin >> n;
  vector<int> d;
  for(int i=0;i<n;i++){int x; cin >> x; d.push_back(x);}
  sort(d.begin(),d.end());
  cout << d[n/2] - d[n/2-1] << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi; 
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
    cin.sync_with_stdio(0);
    cin.tie(0); cin.exceptions(cin.failbit);
    ll n,ans=0;
    cin>>n;
    ll a[n];
    unordered_map<ll,ll> mp;
    rep(i,0,n)
    {
    	cin>>a[i];
    	mp[a[i]+i]++;
	}
	for(int i=n-1;i>0;i--)
	{
		--mp[a[i]+i];
		ans+=mp[i-a[i]];
	}
	cout<<ans<<endl;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

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

std::string s;
int n;

int main() {
    std::cin >> s;
    n = s.size();
    s = s.substr(0, s.size()-2);
    while (true) {
        int m = n/2;
        if (s.substr(0, m) == s.substr(m, m)) {
            break;
        }
        n -= 2;
    }
    std::cout << n << std::endl;
    return 0;
}

Measured memory_bytes: 256
n,x,m = map(int,input().split())

table = [0]*m

def calc(init,iter):
    ret = 0
    for _ in range(iter):
        ret += init
        init = (init*init)%m
    return ret

ret = x
cur = x % m
table[cur] = 1
for rnd in range(2,min(m+2,n+1)):
    cur = (cur*cur) % m
    if table[cur]:
        per = rnd - table[cur]
        persum = calc(cur,per)
        rnds = (n - rnd) // per
        ret += rnds*persum
        ret += calc(cur,n - rnd - per*rnds+1) 
        #print(cur,table[cur],rnd,per,persum,rnds)
        break
    else:
        table[cur] = rnd
        ret += cur



print(ret)

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

#define max 100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while (a!=0) {a=a/10;i++;}return i;}

int main()
{
    int a, b, c;
    
    scanf("%d %d", &a, &b);
    
    c=fmax(a+b, a-b);
    c=fmax(c, a*b);
    
    printf("%d", c);
    
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin >>n;
  int a[111111];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]<<" ";
  int ans;
  int s=1e9+1;
  for(int i=0;i<n-1;i++){
    int t=abs(a[n-1]-a[i]*2);
    if(s>t)ans=a[i],s=t;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,x=0,M=0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N; i++){
    if (S[i] == 'I') x++;
    if (S[i] == 'D') x--;
    M = max(M,x);
  }
  cout << M;
}

Measured memory_bytes: 256
class Integer
  def divisor
    res = []
    1.upto((self**0.5)) do |i|
      if self % i == 0
        res.push i
        res.push self / i if i != self / i
      end
    end
    res.sort
  end
end

def answer_if_valid(x, a, d)
  b = a - d
  if x == a ** 5 - b ** 5
    puts "#{a} #{b}"
    exit
  end
end

x = gets.to_s.to_i

r = x % 5

divisors = x.divisor.select{|t| r == t % 5}
candidates = divisors + divisors.map{|d| -d }

candidates.each do |d|
  
  left = (( x / d - d ** 4 ) / 5).abs
  
  if left == 0
    answer_if_valid(x,0,d)
    (d ** 3).abs.divisor.each do |a|
      answer_if_valid(x, a, d)
      answer_if_valid(x,-a, d)
    end
  end
  
  left.divisor.each do |a|
    answer_if_valid(x,  a, d)
    answer_if_valid(x, -a, d)
  end
end

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	ll k; cin >> k;
	int n=s.length();
	int ptr = 0,aft = 0;
	for(int i=0; i<n; i++){
		if(s[i]!='1'){
			ptr = i+1;
			aft = s[i]-'0';
			break;
		}
	}
	if(ptr==0){
		cout << 1;
	}else{
		if(k<ptr)cout << 1;
		else cout << aft;
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#define MAX_N (200000)

using namespace std;

typedef pair<int,int> P;
P points[MAX_N];
P sortedX[MAX_N];
P sortedY[MAX_N];
int cX[MAX_N];
int cY[MAX_N];

int cmp(const P& p1, const P& p2) {
  return p1.second > p2.second;
}
struct SegmentTree {
  int Storage[MAX_N*8];
  int N;
  void init(int n) {
    N=1;
    while(N<n) N*=2;

    for(int i=0;i<N*2;++i) {
      Storage[i]=0;
    }
  }

  void updateLeaf(int i, int value) {
    i += N-1;
    Storage[i]=value;
    while(i>0) {
      i = (i-1) / 2;
      Storage[i] = max(Storage[i*2+1], Storage[i*2+2]);
    }
  }

  int calcRangeGCD(int a,int b,int k,int l, int r) {
    if(b<=l || a>=r) return 0;
    if(a<=l && b>=r) {
      return Storage[k];
    } else {
      int tl = calcRangeGCD(a,b,k*2+1,l,(l+r)/2);
      int tr = calcRangeGCD(a,b,k*2+2,(l+r)/2,r);
      return max(tl,tr);
    }
  }
};
SegmentTree segmentTree;
int main() {
  int x1,y1,x2,y2;
  int N;
  bool flip=false;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  if (y1>y2) {
    swap(y1,y2);
    swap(x1,x2);
  }
  if (x1>x2) {
    flip=true;
    x1= (1000 * 1000 * 100 - 1) - x1;
    x2= (1000 * 1000 * 100 - 1) - x2;
  }
  scanf("%d", &N);
  int subN=0;
  for(int i=0;i<N;++i) {
    int X,Y;
    scanf("%d%d", &X, &Y);
    if (flip) {
      X= (1000 * 1000 * 100 - 1) - X;
    }
    if (X>=x1&&X<=x2 && Y>=y1&&Y<=y2) {
      sortedX[subN]=P(X,subN);
      sortedY[subN]=P(Y,subN);
      subN++;
    }
  }
  N=subN;
  sort(sortedX, sortedX+N);
  sort(sortedY, sortedY+N);
  for(int i=0;i<N;++i) {
    P sX=sortedX[i];
    cX[i]=sX.first;
    P sY=sortedY[i];
    cY[i]=sY.first;
    points[sX.second].first=i;
    points[sY.second].second=i;
  }
  sort(points,points+N,cmp);
  segmentTree.init(N);
  for(int i=0;i<N;++i) {
    P p=points[i];
    int m=segmentTree.calcRangeGCD(p.first,N,0,0,segmentTree.N);
    segmentTree.updateLeaf(p.first, m+1);
  }
  int num=segmentTree.calcRangeGCD(0,N,0,0,segmentTree.N);
  bool flag=false;
  if (num==min(x2-x1+1,y2-y1+1)) {
    flag=true;
  }

  long double answer = 0;
  answer += ((x2-x1) + (y2-y1))*100LL;
  answer += (5.0 * M_PI-20.0) * num;
  if (flag) {
    answer -= (5.0*M_PI-20.0);
    answer += (10.0*M_PI-20.0);
  }

  printf("%.20Lf\n", answer);
  return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<int,int> P;
#define fi first
#define se second
int main(){
    ios::sync_with_stdio(false);
   cin.tie(0);
int n,h;
cin>>n>>h;
vector<P> c(n),t(n);
for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    c.at(i)=P(a,b);
    t.at(i)=P(b,a);
}
sort(c.begin(),c.end(),greater<P>());
sort(t.begin(),t.end(),greater<P>());
int ans=0;
for(int i=0;i<n;i++){//切るが上回ったら投げるのをやめる
    if(c.at(0).fi>t.at(i).fi)break;
    h-=t.at(i).fi;
    ans++;
    if(h<=0)break;
}
if(h>0){
    if(h%c.at(0).fi==0)ans+=h/c.at(0).fi;
    else ans+=h/c.at(0).fi+1;
}
cout<<ans<<endl;
}


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

int main(){
  int sum[1010],tmp = 0;

  for(int i=0;i<1001;i++){
    tmp += i;
    sum[i] = tmp;
  }


  int n;
  while(cin >> n,n){
    int ans = 0;
    for(int i=0;i<=n;i++){
      for(int j=i+2;j<=n;j++){
	if(sum[j] - sum[i] == n){
	  ans++;
	  break;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
//y09-6 ビンゴ(2回目)
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    ROOP(){
        int N,M,S;
        cin >> N >> M >> S;
        if(N==0) return 0;

        int dp[50][3001];
        for(int i=0; i<50; i++){
            for(int j=0; j<3001; j++){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;

        for(int i=1; i<=N*N; i++){
            for(int j=1; j<=S; j++){
                if(j>=i) dp[i][j] = dp[i-1][j-i] + dp[i][j-i];
                if(j>M) dp[i][j] -= dp[i-1][j-M-1];
                dp[i][j] %= 100000;
                if(dp[i][j]<0) dp[i][j]+=100000;
            }
        }
        cout << dp[N*N][S] << endl;

    }
    return 0;
}




Measured memory_bytes: 3644
N = int(input())
P = []
P = input().split()
P = [int(i) for i in P]

Max = P[0]
count = 1

for i in range(N-1):
  if P[i+1] < Max:
    count += 1
    Max = P[i+1]
#  print('count=', count, 'Max=', Max)

print(count)

#print('N=', N)
#print('P=', P)



Measured memory_bytes: 25768
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int k = Integer.max(n - 1, Math.abs(x - 1) + Math.abs(y - n) + 1);
        int[] result = new int[k];

        for(int i = 1;i <= n;i++) {
            for(int j = i + 1;j <= n;j++) {
                int directD = j - i;
                int viaD = Math.abs(x - i) + Math.abs(y - j) + 1;
                result[Integer.min(directD, viaD) - 1]++;
            }
        }

        Arrays.stream(result).forEachOrdered(System.out::println);
    }
}


Measured memory_bytes: 26964
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
    	if(n % 10 == 3){
    		System.out.println("bon");
    	}else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
    		System.out.println("pon");
    	}else {
    		System.out.println("hon");
    	}
    }
}

Measured memory_bytes: 27040
#include <bits/stdc++.h>
using namespace std;
int main() {
  int w,h,n;
  cin >> w >> h >> n;
  int a,b,c;
  int x=0,y=0;
  for (int i=0; i<n; i++) {
    cin >> a >> b >> c;
    switch (c) {
      case 1:
         if (x < a) {
           x = a;
         }
        break;
      case 2:
        if (w > a) {
          w = a;
        }
        break;
      case 3:
        if (y < b) {
          y = b;
        }
        break;
      case 4:
        if (h > b) {
          h = b;
        }
    }
  }
  if (x >= w || y >= h) {
    cout << 0 << endl;
  } else {
    cout << (w-x)*(h-y) << endl;
  }
}

Measured memory_bytes: 256