akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int n;
    long long a[100000];
    long long min_abs = 1000000000;
    long long ans = 0;
    int nsign = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        min_abs = min(min_abs, abs(a[i]));
        ans += abs(a[i]);
        if (a[i] < 0) nsign++;
    }
    if (nsign % 2 == 1) ans -= 2 * min_abs;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> left_black(n);
	vector<int> right_white(n);
	for(int i=1;i<s.size();i++){
		left_black[i] = left_black[i-1];
		if(s[i-1]=='#') left_black[i]++;
	}
	for(int i=s.size()-2;i>=0;i--){
		right_white[i] = right_white[i+1];
		if(s[i+1]=='.') right_white[i]++;
	}
	// rep(i,s.size()){
	// 	cout << left_black[i] << ':' << right_white[i] << endl;;
	// }
	int ans = INF;
	rep(i,s.size()){
		ans = min(ans,left_black[i]+right_white[i]);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {

  int in, y, z, ans = 0;
  cin >> in;
  y = in;
  
  while(y > 0){
    ans += y % 10;
    y /= 10;
  }
  if(in % ans)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


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

int main(){
  int k,s;
  cin >> k >> s;
  
  int cnt=0;
  
  rep(x,k+1){
    rep(y,k+1){
      int z = s-x-y;
      if(z >= 0 && z <= k) cnt++;
    }
  }
   
  cout << cnt << endl;
      
  return 0;
}

Measured memory_bytes: 256
//Bingo.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
        Scanner sc=new Scanner(System.in);
        int a[]=new int[3];
        int c[]=new int[3];
        int d[]=new int[3];
        for(int i=0;i<3;i++){
            a[i]=sc.nextInt();
        }
        for(int i=0;i<3;i++){
            c[i]=sc.nextInt();
        }
        for(int i=0;i<3;i++){
            d[i]=sc.nextInt();
        }
        int n=sc.nextInt();
        int b[]=new int[n];
        for(int i=0;i<n;i++){
            b[i]=sc.nextInt();
        }

		for(int i=0;i<3;i++){
            for(int j=0;j<n;j++){
                if(a[i]==b[j]){
                    a[i]=-1;
                }
            }
        }
        for(int i=0;i<3;i++){
            for(int j=0;j<n;j++){
                if(c[i]==b[j]){
                    c[i]=-1;
                }
            }
        }
        for(int i=0;i<3;i++){
            for(int j=0;j<n;j++){
                if(d[i]==b[j]){
                    d[i]=-1;
                }
            }
        }
        if((a[0]==-1&&a[1]==-1&&a[2]==-1)||(c[0]==-1&&c[1]==-1&&c[2]==-1)||(d[0]==-1&&d[1]==-1&&d[2]==-1)||
         (a[0]==-1&&c[0]==-1&&d[0]==-1)||(a[1]==-1&&c[1]==-1&&d[1]==-1)||(a[2]==-1&&c[2]==-1&&d[2]==-1)||
         (a[0]==-1&&c[1]==-1&&d[2]==-1)||(a[2]==-1&&c[1]==-1&&d[0]==-1)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  string S;
  cin >> N >> S >> K;
  
  char X= S.at(K-1);
  string A;
  
  for(int i=0; i<N; i++){
    if (S.at(i)==X){
      if(i==0){
        A=X;
      }
      else{
        A+=X;
      }
    }
    else{
      if(i==0){
        A='*';
      }
      else{
        A+='*';
      }
    }
  }
  
  cout << A << endl;
}

Measured memory_bytes: 256
from collections import OrderedDict
od = OrderedDict()

n = int(input())
for num in range(n):
  a, b = input().split()
  od[a] = b
  
s = input()

for k, v in od.items():
  if k != s:
    del od[k]
  else:
    del od[k]
    break

count = 0
for k, v in od.items():
  count += int(v)
  
print(count)

Measured memory_bytes: 3572
/*
* All my senses intensify
* Whenever you and I, we dive
*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf ((ll)1e18)
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    // fast();
    string n;
    ll k;
    cin>>n>>k;
    ll dp[105][2][10];
    memset(dp , 0 , sizeof dp);
    dp[0][0][0] = 1;
    dp[0][0][1] = n[0] - '0' - 1;
    dp[0][1][1] = 1;
    for(ll i = 1 ; i < n.length() ; i++ )
    {
    	for(ll j = 0 ; j <= k ; j++ )
    	{
    		for(ll m = 0 ; m < 10 ; m++ )
	    	{
	    		dp[i][0][j + (m != 0)] += dp[i - 1][0][j];
	    		if(m < n[i] - '0')
	    			dp[i][0][j + (m != 0)] += dp[i - 1][1][j];
	    		if(m == n[i] - '0')
	    		dp[i][1][j + (m != 0)] += dp[i - 1][1][j];
	    	}
	    }
    }
    cout<<dp[n.length() - 1][0][k] + dp[n.length() - 1][1][k]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
vector<int>Prime={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};//15こ
vector<int>diviser(15,0);
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    for(int i=0;i<Prime.size();i++){
        for(int j=1;;j++){
            int a=pow(Prime[i],j);
            if (a>100)break;
            for(int k=1;k<=N;k++){
                if(k%a==0)diviser[i]++;
            }
        }
    }
    int over2=0,over4=0,over14=0,over24=0,over74=0;
    for(int i=0;i<15;i++){
        if(diviser[i]>=2)over2++;
        if(diviser[i]>=4)over4++;
        if(diviser[i]>=14)over14++;
        if(diviser[i]>=24)over24++;
        if(diviser[i]>=74)over74++;
    }
    int sub=0;
    if(over2>=3&&over4>=2)sub+=over4*(over4-1)*(over2-2)/2;
    if(over74>=1)sub+=over74;
    if(over2>=2&&over24>=1)sub+=over24*(over2-1);
    if(over4>=2&&over14>=1)sub+=over14*(over4-1);
    cout<<sub<<endl;
}

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int n,k;
	cin >> n >> k;
	
	cout << (n%k ? 1 : 0) << endl;		
	return 0;
}


Measured memory_bytes: 256
// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second
 
const int64 INF = 1e18;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int a, b, q; cin >> a >> b >> q;
  int64 s[a + 2], t[b + 2];
 
  s[0] = -1 * INF; t[0] = -1 * INF; s[a + 1] = INF; t[b + 1] = INF;
 
  for (int i = 1; i <= a; ++i) cin >> s[i];
  for (int i = 1; i <= b; ++i) cin >> t[i];
 
  for (int i = 0; i < q; ++i){
    int64 x; cin >> x;
    auto pos1 = lower_bound(s, s + a + 2, x);
    auto pos2 = lower_bound(t, t + b + 2, x);
 
    // *pos1, *(pos1 - 1), *pos2, *(pos2 - 1)
    int64 ans = min({max(*pos1 - x, *pos2 - x), 
		     max(x - *(pos1 - 1), x - *(pos2 - 1)),
		     2 * (*pos1 - x) + x - *(pos2 - 1),
		     *pos1 - x + 2 * (x - *(pos2 - 1)),
		     2 * (*pos2 - x) + x - *(pos1 - 1),
		     *pos2 - x + 2 * (x - *(pos1 - 1))}); 
    print(ans);
  }
 
  
  return 0;
}

Measured memory_bytes: 2944
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		vi a(n+1,0),b(n+1,0),c(n+1,0);
		vector<vi> dp(n+1,vi (3,0));
		rep(i,1,n+1)cin>>a[i]>>b[i]>>c[i];
		rep(i,1,n+1)
		{
			dp[i][0]=max(dp[i][0],a[i]+max(dp[i-1][1],dp[i-1][2]));
			dp[i][1]=max(dp[i][1],b[i]+max(dp[i-1][0],dp[i-1][2]));
			dp[i][2]=max(dp[i][2],c[i]+max(dp[i-1][1],dp[i-1][0]));
		}        

		cout<<max(max(dp[n][1],dp[n][2]),dp[n][0])<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
#define elif else if
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;

signed main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a + b == c + d)
		cout << "Balanced" << endl;
	else if(a + b > c + d)
		cout << "Left" << endl;
	else
		cout << "Right" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
if((A == B && A != C) || (A == C && A != B) || (B ==C && A!=B)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import math
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#############
# Main Code #
#############

N = int(input())

print(math.floor((N+1)/2))

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  set<int> xs;
  rep(i, K) {
    if (A + i > B)
      break;
    xs.insert(A + i);
  }
  rep(i, K) {
    if (B - i < A)
      break;
    xs.insert(B - i);
  }

  for (auto item : xs) {
    cout << item << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans[10],vis[10],k;
double m;
struct Node{
	int x,y;
}a[10];
double dist(int a1,int b1,int a2,int b2){
	return sqrt((a1-a2)*(a1-a2)+(b1-b2)*(b1-b2));
}
void dfs(int x){
	int i;
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[x]=i;
			vis[i]=1;
			if(x==n){
				k++;
	 	 		for(int i=1;i<n;i++)
					m+=dist(a[ans[i]].x,a[ans[i]].y,a[ans[i+1]].x,a[ans[i+1]].y);
			}	
			else dfs(x+1);
			ans[x]=0;vis[i]=0;		
		}		
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].x>>a[i].y;
	dfs(1);
	printf("%lf",m/k);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;

typedef long long ll;


const int INF = 1e9;

struct State
{
	int d, v, t, n;
	State(int d, int v, int t, int n) :d(d), v(v), t(t), n(n) {}
	bool operator < (const State& s) const {
		return d > s.d;
	}
};


struct edge
{
	int to, co;
	edge(int to, int co) :to(to), co(co) {}
};

int N, M, X;
int T[10000];
vector<edge> g[10000];
int dist[10000][205][3];
int main() {
	cin >> N >> M >> X;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}

	for (int i = 0; i < M; i++) {
		int a, b, d;
		cin >> a >> b >> d; a--; b--;
		g[a].emplace_back(b, d);
		g[b].emplace_back(a, d);
	}

	
	priority_queue<State> pq;
	pq.emplace(0, 0, 0, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= X; j++) {
			for (int k = 0; k < 3; k++) {
				dist[i][j][k] = INF;
			}
		}
	}
	dist[0][0][0] = 0;
	int ans;
	while (!pq.empty())
	{
		State st = pq.top(); pq.pop();
		int v = st.v, t = st.t, n = st.n;

		if (st.d > dist[v][t][n]) continue;

		if (v == N - 1) {
			ans = dist[v][t][n]; 
			break;
		}

		for (auto e : g[v]) {
			int nt = min(t + e.co, X);
			int nco = dist[v][t][n] + e.co;
			if (T[e.to] == n) {
				if (dist[e.to][0][n] > nco) {
					dist[e.to][0][n] = nco;
					pq.emplace(dist[e.to][0][n], e.to, 0, n);
				}
			}
			else if(T[e.to] == 1){
				if (dist[e.to][nt][n] > nco) {
					dist[e.to][nt][n] = nco;
					pq.emplace(dist[e.to][nt][n], e.to, nt, n);
				}
			}
			else {
				if (nt != X) continue;
				if (dist[e.to][0][T[e.to]] > nco) {
					dist[e.to][0][T[e.to]] = nco;
					pq.emplace(dist[e.to][0][T[e.to]], e.to, 0, T[e.to]);
				}
			}
		}
	}

	cout << ans << endl;
	

	return 0;
}



Measured memory_bytes: 28096
{-# LANGUAGE BangPatterns #-}

import Data.List
import Data.Int

funcmod :: Int64 -> Int64
funcmod n = n `mod` 1000000007

fib :: Int64 -> Int64
fib i = loop (i+1) 0 1
    where
        loop 0 a !b = a
        loop i a b = loop (i - 1) b (funcmod $ a + b)

solve2 :: Int64 -> Int64 -> [Int64] -> Int64 -> Int64        
solve2 n cur [] result = funcmod $ result * fib (n - cur)

solve2 n cur (i:rest) result
    | cur == i = 0
    | otherwise =
        solve2 n (i+1) rest $ funcmod $ result * fib (i - 1 - cur )

f :: [Int64] -> Int64
f(n:m:l) = solve2 n 0 l 1

main :: IO ()
main = interact $ show.f.map read.words




Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
unsigned long long int ull;
vector<int>adj[200105];
int visited[200105];
//int b[1000000];
//ll cnt,n,d;
#define mod 1000000007

void solve()
{
 int n;
 cin>>n;
 ll sum=0;
 for(int i=1;i<=n;i++)
 {
     if(i%3!=0 && i%5!=0 &&i%15!=0)
     sum+=i;
 }
 cout<<sum;
}
int main()
{
//int t;cin>>t;while(t--)
  solve();
  return 0;
}

Measured memory_bytes: 8328
#include <stdio.h>


int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    char ch;
    while(ch = getchar(), EOF != ch) {
        if(ch >= 'a' && ch <= 'z') {
            printf("%c", ch - 'a' + 'A');
        } else if (ch >= 'A' && ch <= 'Z') {
            printf("%c", ch - 'A' + 'a');
        } else {
            printf("%c", ch);
        }
    }

    return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l,min=10000000,sum=0,x;
  cin>>n>>l;
  for(int i=1;i<=n;i++)
  {
    if(abs(l+i-1) < min)
    {
      min=abs(l+i-1);
      x=l+i-1;
    }
    sum+=l+i-1;
  }
  cout<<sum-x;
  return 0;
}
  

Measured memory_bytes: 256
function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const A = inputs[1].split(' ').map(Number)
  const [Q] = inputs[2].split(' ').map(Number)
  const BC = inputs.slice(3).map(e => e.split(' ').map(Number))
  // console.log(A, BC)
  let count = {}
  let sum = 0
  for(let i = 0; i < N; i++) {
    if (count[A[i]] === undefined) count[A[i]] = 0
    count[A[i]] ++
    sum += A[i]
  }
  // console.log(count, sum)
  for (let i = 0; i < Q; i++) {
    if (count[BC[i][0]] === undefined) {
      // console.log(count)
      console.log(sum)
      continue
    }
    if (count[BC[i][1]] === undefined) count[BC[i][1]] = 0
    let diff = BC[i][1] - BC[i][0]
    sum += count[BC[i][0]] * diff
    count[BC[i][1]] += count[BC[i][0]]
    count[BC[i][0]] = 0
    // console.log(count)
    console.log(sum)
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 86856
let rec upper_bound l r p =
    if r <= 1 + l
    then l
    else let m = (l + r) / 2 in
        if p m 
        then upper_bound m r p
        else upper_bound l m p

let () = Scanf.scanf "%d %d %d\n" @@ fun n m k ->
    let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
    let bs = Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
    let accum values value = match values with
        [] -> [value]
        | values -> (value + List.hd values) :: values in
    let inc = Array.of_list @@ List.rev @@ Array.fold_left accum [0] as_ in
    let inc' =  Array.of_list @@ List.rev @@ Array.fold_left accum [0] bs in
    Printf.printf "%d\n" @@
    Array.fold_left max min_int @@
    Array.init (n + 1) @@ fun i ->
        if k < inc.(i) then 0
        else i + upper_bound 0 (m + 1) (fun j -> inc.(i) + inc'.(j) <= k)



Measured memory_bytes: 25772
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s.substr(0, 4) == "YAKI")
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#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;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=4e5+4;

ll fac[N],infac[N];
 
ll me(ll a,ll b)
{
    ll res=1;
 
    while(b)
    {
        if(b&1)
        res=(res*a)%mod;
 
        b>>=1;
 
        a=(a*a)%mod;
    }
 
    return res;
}
 
ll mi(ll a)
{
    return me(a,mod-2);
}
 
void factorial()
{
   fac[0]=1;
 
   for(ll i=1;i<N;i++)
   fac[i]=(i*fac[i-1])%mod;
 
   infac[N-1]=mi(fac[N-1]);
 
   for(ll i=N-1;i>=1;i--)
   infac[i-1]=(i*infac[i])%mod;
}
 
ll ncr(ll n,ll r)
{
    if(n<r)
    return 0;
 
    ll val=fac[n];
 
    val=(val*infac[r])%mod;
 
    val=(val*infac[n-r])%mod;
 
    return val;
}
 
bool comp(pair<int,int> a,pair<int,int> b)
{
	return a.F+a.S<b.F+b.S;
}

ll f(int a,int b)
{
	return ncr(a+b,b);
}

int main()
{
	factorial();

	int r,c,n;

	scn(r); scn(c); scn(n);

	vector<pair<int,int>> v(n);

	rep(i,0,n)
	scn(v[i].F),scn(v[i].S);

	sort(v.begin(),v.end(),comp);

	//dp[i] tells the no. of ways to reach the ith obstacle without passing
	//through any previous obstacles.
	ll dp[n];

	ll ans=f(r-1,c-1);

	//lpri(ans);

	for(int i=0;i<n;i++)
	{
		ll here=f(v[i].F-1,v[i].S-1);

		for(int j=0;j<i;j++)
		if(v[j].F<=v[i].F and v[j].S<=v[i].S)
		{
			int dx=v[i].F-v[j].F,dy=v[i].S-v[j].S;

			ll sub=(dp[j]*f(dx,dy))%mod;

			here=(here-sub+mod)%mod;
		}

		dp[i]=here;

		ll reduce=(dp[i]*f(r-v[i].F,c-v[i].S))%mod;

		ans=(ans-reduce+mod)%mod;
	}

	lpri(ans);

    return 0;
}

Measured memory_bytes: 6528
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int nA, nB; scanf("%d%d", &nA, &nB);
    vector<LL> A(nA); rep(i, nA) scanf("%lld", &A[i]);
    vector<LL> B(nB); rep(i, nB) scanf("%lld", &B[i]);
    vector<LL> C = convolution<998244353>(A, B);
    rep(i, C.size()) { if (i) printf(" "); printf("%lld", C[i]); } printf("\n");

    return 0;
}

Measured memory_bytes: 27176
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	int h,w,n;
	cin>>h>>w>>n;
	cout<<(n-1+max(h,w))/max(h,w)<<endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int t[n];
  int ans = 0;
  for(int i = 0; i < n; i++) cin >> t[i];
  for(int i = 0; i < n; i++) ans += t[i];
  int m;
  cin >> m;
  for(int i = 0; i < m; i++){
    int p, x;
    cin >> p >> x;
    cout << ans - t[p - 1] + x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int N;
   int l, r;
   int ans;
   ans = 0;
   int i;

   scanf("%d", &N);

   for (i = 0; i < N; i++){
        scanf("%d %d", &l, &r);
        ans += r - l + 1;
   }

   printf("%d\n", ans);
}
    

Measured memory_bytes: 128
#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

if __name__ == "__main__":
    main()


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

int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (z <= k && z >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define For(i,x,y) for (int (i)=(x);(i)<=(y);(i++))
ll Q,A,B,x,y,q[10000],top,one;
ll calc(ll x){
	ll sizeof_A=x-x/(one+1)+(A+B-x)/(one+1);
	return sizeof_A;
}
ll get(ll x){
	ll ans=x%(one+1),ans1=x%(one+1)==0;
	if (x==A+B)	return ans;	++x;	x=(A+B-x+1);
	ans+=x%(one+1)==0,ans1+=x%(one+1);
	return max(ans,ans1);
}
void work1(){
//Ag个分成B+1分, 
	one=(A-1)/(B+1)+1/*答案*/;
	ll l=0,r=A+B,ans=0;
	while(l<=r){
		ll mid=(l+r)>>1;
		if (calc(mid)<=A)	l=mid+1,ans=mid;
		else	r=mid-1;
	}
	while(ans<A+B){
		if (calc(ans+1)<=A){	ans++;	continue;	}
		if (ans+2>A+B)	break;
		if (calc(ans+2)<=A){	ans++;	continue;	}
		if (ans+3>A+B)	break;
		if (calc(ans+3)<=A){	ans++;	continue;	}
		if (ans+4>A+B)	break;
		if (calc(ans+4)<=A){	ans++;	continue;	}
		break;
	}
	while(ans&&(get(ans)>one||calc(ans)>A))--ans;
	For(i,x,y){
		if (i<=ans)	putchar(i%(one+1)==0?'B':'A'); 
		else	putchar((A+B-i+1)%(one+1)==0?'A':'B');
	}
}
void work2(){
	swap(A,B);	x=(A+B+1)-x;	y=(A+B+1)-y;	swap(x,y);	top=0;
	one=(A-1)/(B+1)+1/*答案*/;
	ll l=0,r=A+B,ans=0;
	while(l<=r){
		ll mid=(l+r)>>1;
		if (calc(mid)<=A)	l=mid+1,ans=mid;
		else	r=mid-1;
	}
	while(ans<A+B){
		if (calc(ans+1)<=A){	ans++;	continue;	}
		if (ans+2>A+B)	break;
		if (calc(ans+2)<=A){	ans++;	continue;	}
		if (ans+3>A+B)	break;
		if (calc(ans+3)<=A){	ans++;	continue;	}
		if (ans+4>A+B)	break;
		if (calc(ans+4)<=A){	ans++;	continue;	}
		break;
	}
	while(ans&&(get(ans)>one||calc(ans)>A))--ans;
	For(i,x,y){
		if (i<=ans)	q[++top]=i%(one+1)==0?'B':'A'; 
		else	q[++top]=(A+B-i+1)%(one+1)==0?'A':'B';
	}
	while(top)	putchar('A'+'B'-q[top--]);
}
int main(){
	int Q; scanf("%d",&Q);
	while(Q--){
		scanf("%d%d%d%d",&A,&B,&x,&y);
		if (A>=B)	work1();
		else	work2();
		puts("");
	}
}

Measured memory_bytes: 384
#include <stdio.h>
#define REP(i,n) for (int i=0;i<(n);++i)
const int INF = 1e9;

int N,M,X,Y;
int x[110],y[110];

int main(){
    scanf("%d%d%d%d",&N,&M,&X,&Y);
    REP(i,N) scanf("%d",&x[i]);
    REP(i,M) scanf("%d",&y[i]);

    for(int Z = X + 1; Z <= Y; ++Z){
        int isok = 1;
        REP(i,N) if(x[i]>=Z) isok = 0;
        REP(i,M) if(y[i]<Z) isok = 0;
        if(isok){
            printf("No War\n");
            return 0;
        }
    }
    printf("War\n");
    return 0;
}

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

if a % 2 == 0 and b % 2 == 0:
    print((b - a) // 2 % 2 ^ b)
elif a % 2 == 0 and b % 2 == 1:
    print((b - a + 1) // 2 % 2)
elif a % 2 == 1 and b % 2 == 0:
    print(a ^ ((b - a - 1) // 2 % 2) ^ b)
else:
    print(a ^ ((b - a) // 2 % 2))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();

            var minCost = long.MaxValue;

            for (int i = -100; i <= 100; i++)
            {
                var cost = 0L;
                for (int j = 0; j < N; j++)
                {
                    cost += (long)Math.Pow(i - a[j], 2);
                }
                minCost = Math.Min(cost, minCost);
            }

            return minCost;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27896
#include<bits/stdc++.h>
int main(){
    int n;std::cin>>n;
    std::vector<std::string>s(n);
    for(auto&&t:s)std::cin>>t;
    int ans=0;
    for(int i=0;i<n;i++){
        bool ng=false;
        for(int j=0;j<=n;j++){
            if(j==n){
                ans++;
                break;
            }
            for(int k=j+1;k<n;k++){
                if(s.at(j).at(k)!=s.at(k).at(j)){
                    ng=true;
                    break;
                }
            }
            if(ng)break;
        }
        std::rotate(s.begin(),s.begin()+1,s.end());
    }
    std::cout<<ans*n<<std::endl;
}



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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

        int lis[10];
        fill(lis, lis+10, 0);
        rep(i, n) {
            int c;
            cin >> c;
            lis[c]++;
        }

        rep(i, 10) {
            if (lis[i] == 0) cout << '-';
            else rep(j, lis[i]) cout << '*';
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3004
import math

flag = 0
ans = [0] * 4

while 1:
    try:
        side = list(map(int, input().split()))
    except EOFError:
        print(' '.join(str(a) for a in ans))
        break

    side.sort(reverse=True)
    a, b, c = side

    if flag:
        continue

    if a >= b + c:
        flag = 1
        continue
    else:
        ans[0] += 1
        bc = math.sqrt(b**2 + c**2)
        if a == bc:
            ans[1] += 1
        elif a < bc:
            ans[2] += 1
        else:
            ans[3] += 1



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

int top, S[1000];

void push(int x) {
/* top加一之后把元素插入 
   top所指的位置 */
    S[++top] = x;
}

int pop() {
    top--;
/* 返回top所指的元素 */
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char s[100];
    
    while ( scanf("%s", s) != EOF ) {
        if ( s[0] == '+' ) {
            a = pop();
            b = pop();
            push(a + b);
        } else if ( s[0] == '-' ) {
            b = pop();
            a = pop();
            push(a - b);
        } else if ( s[0] == '*' ) {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());
    
    return 0;
}


Measured memory_bytes: 2124
s = list(map(str, input().split()))[0]
fumi = {0:["R","U","D"], 1:["L","U","D"]}
is_yasui = True
for i in range(len(s)):
    if s[i] not in fumi[i%2]:
        is_yasui = False
        break
        
if is_yasui:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 2940
#include <cstdio>

int k,f=0,step=1;
int a[5];
void dfs(int step);
int check();
int main(){
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	scanf("%d",&k);
	if(check()) f=1;
	else dfs(step);
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}
int check(){
	if(a[1]>a[0] && a[2]>a[1]) return 1;
	else return 0;
}
void dfs(int s){
	if(f==1) return;
	else if(s>k){
		step--;
		return;
	}
	for(int i=0;i<3;i++){
		a[i] *= 2;
		if(check()){
			f = 1;
			return;
		}
		dfs(++step);
		a[i] /= 2;
	}
	step--;
	return;
}

Measured memory_bytes: 1632
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2e5+10;
int min(int a,int b){return a>b?b:a;}
int max(int a,int b){return a>b?a:b;}
bool judge(int pos,int lim,int s,int a[],int b[]){
  reverse(a,a+s);
  reverse(b,b+s);
//printf("::pos=%d lim=%d s=%d\n",pos,lim,s);
//printf("a::");for(int i=0;i<s;i++)printf(" %d",a[i]);printf("\n");
//printf("b::");for(int i=0;i<s;i++)printf(" %d",b[i]);printf("\n");
  int ml=1,mr=lim;
  if(a[0]==1)mr=lim-1;
  else if(a[0]==-1)ml=2;
  if(ml>mr)return true;
  for(int i=1;i<s;i++){
  	if(b[i]==1)ml--;
    else if(b[i]==-1)mr++;
    mr=min(mr,lim);
    ml=max(ml,1);
    if(a[i]==1)mr--;
    else if(a[i]==-1)ml++;
    mr=min(mr,lim);
    ml=max(ml,1);
//    printf("i=%d ml=%d mr=%d\n",i,ml,mr);
    if(ml>mr)return true;
  }
  if(pos>mr||pos<ml)return true;
  return false;
}
int main(){
  int n,m,x,y,s,ta[N],tb[N];
  string a,b;
  cin>>n>>m>>s>>x>>y>>a>>b;
  for(int i=0;i<s;i++)if(a[i]=='L')ta[i]=-1;
  else if(a[i]=='R')ta[i]=1;
  else ta[i]=0;
  for(int i=0;i<s;i++)if(b[i]=='L')tb[i]=-1;
  else if(b[i]=='R')tb[i]=1;
  else tb[i]=0;
  if(judge(y,m,s,ta,tb))printf("NO\n");
  else {
    for(int i=0;i<s;i++)if(a[i]=='D')ta[i]=1;
    else if(a[i]=='U')ta[i]=-1;
    else ta[i]=0;
    for(int i=0;i<s;i++)if(b[i]=='D')tb[i]=1;
    else if(b[i]=='U')tb[i]=-1;
    else tb[i]=0;
    if(judge(x,n,s,ta,tb))printf("NO\n");
    else printf("YES\n");
  }
}


Measured memory_bytes: 2312
public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        dice d1 = new dice();
        for (int i = 0; i < 6; i ++) { d1.number[i] = sc.nextInt(); }

        int q = sc.nextInt();
        for (int i = 0; i < q; i ++) { d1.getRight(sc.nextInt(), sc.nextInt()); }
    }
}

class dice {
    int number[]  = new int[6];

    public void getRight(int top, int front) {

        int right = - 1;
        if (top == number[3] && front == number[1] || top == number[1] && front == number[2]
            || top == number[2] && front == number[4] || top == number[4] && front == number[3]) { right = 0; }
        if (top == number[3] && front == number[5] || top == number[5] && front == number[2]
            || top == number[2] && front == number[0] || top == number[0] && front == number[3]) { right = 1; }
        if (top == number[4] && front == number[0] || top == number[0] && front == number[1]
            || top == number[1] && front == number[5] || top == number[5] && front == number[4]) { right = 2; }
        if (top == number[0] && front == number[4] || top == number[4] && front == number[5]
            || top == number[5] && front == number[1] || top == number[1] && front == number[0]) { right = 3; }
        if (top == number[2] && front == number[5] || top == number[5] && front == number[3]
            || top == number[3] && front == number[0] || top == number[0] && front == number[2]) { right = 4; }
        if (top == number[1] && front == number[3] || top == number[3] && front == number[4]
            || top == number[4] && front == number[2] || top == number[2] && front == number[1]) { right = 5; }
        System.out.println(number[right]);
    }
}

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

int main() {
  int N;
  cin >> N;
  
  if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) {
    cout << "pon" << endl;
  }
  
  else if (N%10 == 3) {
    cout << "bon" << endl;
  }
  
  else {
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3636
n, m  = gets.strip.split.map(&:to_i)
as = gets.strip.split.map(&:to_i)

candidates = [2,5,5,4,5,6,3,7,6].map.with_index {|e, i| [e, i+1] }.select {|e, i| as.include?(i) }.to_h

dp = Array.new(n+1)

(n+1).times do |i|
  tmp = candidates[i].to_i.to_s
  candidates.each do |cost, num|
    next if i-cost < 0 || dp[i-cost].to_i.zero?

    exists = dp[i-cost]
    c = exists > num.to_s ? exists+num.to_s : num.to_s+exists
    tmp = c if c.length > tmp.length || c.length== tmp.length && c>tmp
  end
  dp[i] = tmp
end

#p dp
puts dp[n]


Measured memory_bytes: 49020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,st,e;
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='A')
        {
            st=i+1;
            break;
        }
    }
    for(int i=0;i<l;i++)
    {
        if(s[i]=='Z')
        {
            e=i+1;
        }
    }
    x=e-st+1;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 640
////*24-AUG-19*///
//Why do we fall?//
// So we can learn to pick ourself up!//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n) {fr(j, 1, m) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
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;
    }
//z function -  z[i] is the length of the longest common prefix between s and the suffix of s starting at i
vector<int>z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int lis( int arr[], int n )
{
    int lis[n];

    lis[1] = 1;

    /* Compute optimized LIS values in bottom up manner */
    for (int i = 2; i <= n; i++ )
    {
        lis[i] = 1;
        for (int j = 1; j < i; j++ )
            if ( arr[i] >=arr[j] && lis[i] < lis[j] + 1)
                lis[i] = lis[j] + 1;
    }

    // Return maximum value in lis[]
    return *max_element(lis+1, lis+n+1);
}
signed main()
{
  int n,m;
  cin>>n>>m;
  if(m==1)
  {
      cout<<0<<endl;
      return 0;
  }
  if(n>=m)
  {
      cout<<1<<endl;
      return 0;
  }
  int x=n;
  int ans=1;
  while(m>x)
  {
      ans+=1;
      x+=(n-1);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

num = 1
li = [1]
flag = [True] * n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])

Measured memory_bytes: 102116
#include<iostream>
#include<sstream>
#include<iomanip>
#include<vector>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<bitset>
#include<string>
#include<numeric>
#include<algorithm>
#include<functional>
#include<iterator>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<complex>
#include<ctime>

using namespace std;

/*long long dp[10001];

int main()
{
    long long n,m,c,v,w,d;
    cin>>n>>m>>c;
    for(long long j=1;j<=n;j++)
        {
            cin>>v>>w>>d;
            for(long long i=0;i<12&&d;i++)
            {
                long long x=((1<<i)>d)?d:(1<<i);
                d-=x;
                for(long long k=c;k>=x*v;k--)
                    dp[k]=max(dp[k],dp[k-x*v]+x*w);
            }
        }
        cout<<dp[c]<<endl;
    long long x,y,z;
    for(long long i=1;i<=m;i++)
        {
            cin>>x>>y>>z;
            for(long long j=c;j>=0;j--)
                for(long long k=0;k<=j;k++)
                    dp[j]=max(dp[j],dp[j-k]+x*k*k+y*k+z);
        }
    cout<<dp[c]<<endl;
    return 0;
}*/

int main()
{
    int N;
    cin>>N;
    int k=N%10;
    if(k==3)
        cout<<"bon"<<endl;
    else if(k==1||k==0||k==6||k==8)
        cout<<"pon"<<endl;
    else
        cout<<"hon"<<endl;
}

Measured memory_bytes: 3592
import sys
from collections import Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    A = list(map(int, stdin.readline().rstrip().split()))
    Q = int(stdin.readline().rstrip())
    #BC = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = sum(A)
    counting = Counter(A)
    for i in range(Q):
        B, C = map(int, stdin.readline().rstrip().split())
        dif = C-B
        ans += counting[B]*dif
        counting[C] += counting[B]
        counting[B] = 0
        print(ans)


main()


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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

const string
        gray = "gray",
        brown = "brown",
        green = "green",
        light_blue = "light_blue",
        blue = "blue",
        yellow = "yellow",
        orange = "orange",
        red = "red";

bool between(int a, int mi, int ma) {
    return mi <= a && a <= ma;
}

int main() {

    int over_count = 0;

    int n;
    cin >> n;

    set<string> colors;

    rep(i, n) {

        int a;
        cin >> a;

        if (between(a, 1, 399)) {
            colors.insert(gray);
        } else if (between(a, 400, 799)) {
            colors.insert(brown);
        } else if (between(a, 800, 1199)) {
            colors.insert(green);
        } else if (between(a, 1200, 1599)) {
            colors.insert(light_blue);
        } else if (between(a, 1600, 1999)) {
            colors.insert(blue);
        } else if (between(a, 2000, 2399)) {
            colors.insert(yellow);
        } else if (between(a, 2400, 2799)) {
            colors.insert(orange);
        } else if (between(a, 2800, 3199)) {
            colors.insert(red);
        } else {
            over_count++;
        }

    }

    int current_size = colors.size();

    {
        // min
        cout << max(current_size, 1) << ' ';
    }
    {
        // max
        cout <<  current_size + over_count << endl;
    }


}

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

class Main{

    public static void main(String[] args) {

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inputData;
            StringBuilder sb = new StringBuilder();
            int i = 0;
	            while(true){
	            i++;
	            inputData = reader.readLine();
	            if("0".equals(inputData)){
	            	break;
	            }else{
	            	sb.append("Case " + i + ": " + inputData + System.getProperty("line.separator"));
	            }
            }
            System.out.print(sb.toString());

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

Measured memory_bytes: 31280
while True:
    h,w = map(int, input() .split())
    
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h - 1:
            print ('#'*w)
        else:
            print ('#'+'.'* (w - 2)+'#')
    print()    


Measured memory_bytes: 5612
N,A,B=map(int,input().split())

H=[]
for _ in range(N):
    H.append(int(input()))

ok=10**9+1
ng=0

while ok-ng>1:
    mid=(ok+ng)//2
    dmg=B*mid
    tgt=0
    for item in H:
        tgt+=-(-max(item-dmg,0)//(A-B))
    if tgt<=mid:
        ok=mid
    else:
        ng=mid

print(ok)

Measured memory_bytes: 7076
# -*- coding: utf-8 -*-
import math


def binary(n, m):
    lst = []
    while n != 0:
        lst.append(n % 2)
        n = n // 2
    lst = lst + [0] * (m - len(lst))
    return list(reversed(lst))


def calc(u, v, m):
    result = ""
    u_binary = binary(u, m)
    v_binary = binary(v, m)
    for i in range(m):
        if u_binary[i] == 1 and v_binary[i] == 1:
            result += "R"
        elif u_binary[i] == 0 and v_binary[i] == 0:
            result += "L"
        elif u_binary[i] == 1 and v_binary[i] == 0:
            result += "U"
        else:
            result += "D"
    return result


U = []
V = []
N = int(input())
even, odd = 0, 0
M = 0
for p in range(N):
    x, y = map(int, input().split())
    u = x + y
    v = x - y
    U.append(u)
    V.append(v)
    M = max(M, abs(u), abs(v))
    if (x + y) % 2 == 0:
        even += 1
    else:
        odd += 1

if even >= 1 and odd >= 1:
    print(-1)

else:
    m = math.floor(math.log2(M)) + 1 if M != 0 else 1
    lst = [2 ** i for i in range(m-1, -1, -1)]
    if odd == 0:
        lst.append(1)
    print(len(lst))
    print(" ".join(map(str, lst)))
    for u, v in zip(U, V):
        u = (u + 2 ** m - 1) // 2
        v = (v + 2 ** m - 1) // 2
        print(calc(u, v, m)+"R" if odd == 0 else calc(u, v, m))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod = 998244353;

struct StVal {
	ll v = 0; StVal() {}
	StVal(const ll _v) : v(_v) {}
	StVal(const StVal &v1, const StVal &v2) { v = (v1 + v2) % mod; }
	operator ll() const { return v; }
};

struct SegTree {
	int n;
	vector<StVal> st;
	vector<int> leaves;

	SegTree(const int n) : n(n), leaves(n) { init(1, 0, n - 1); }

	void init(const int si, const int lo, const int hi) {
		if (lo == hi) {
			if (si >= (int)st.size()) st.resize(si + 1);
			st[si] = StVal(); leaves[lo] = si;
		}
		else {
			const int mid = (lo + hi) >> 1;
			init(si << 1, lo, mid);
			init(si << 1 | 1, mid + 1, hi);
			st[si] = StVal(st[si << 1], st[si << 1 | 1]);
		}
	}

	StVal query(const int l, const int r) { return (l <= r && l < n && r >= 0) ? query(l, r, 1, 0, n - 1) : StVal(); }
	StVal query(const int l, const int r, const int si, const int lo, const int hi) {
		if (l <= lo && hi <= r) return st[si];

		const int mid = (lo + hi) >> 1;
		if (r <= mid) return query(l, r, si << 1, lo, mid);
		if (mid < l) return query(l, r, si << 1 | 1, mid + 1, hi);
		return StVal(query(l, r, si << 1, lo, mid), query(l, r, si << 1 | 1, mid + 1, hi));
	}

	void update(const int i, ll x) {
		int si = leaves[i]; st[si].v = (st[si].v + x) % mod;
		for (si >>= 1; si; si >>= 1)
			st[si] = StVal(st[si << 1], st[si << 1 | 1]);
	}
};

vector<int> L, R;

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

	int n, k; cin >> n >> k; SegTree dp(n + 1);
	L.resize(n); R.resize(n); dp.update(1, 1);
	for (int i = 0; i < k; i++)
		cin >> L[i] >> R[i];

	for(int i = 2; i <= n; i++)
		for (int j = 0; j < k; j++) {
			if (i - L[j] < 1) { continue; }
			dp.update(i, dp.query(max(1, i - R[j]), i - L[j]));
		}

	cout << dp.query(n, n) << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 9612