akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll X; cin >> X;
    ll sum = 0;
    ll t = 0;
    while(sum < X)
    {
        sum += ++t;
    }

    cout << t << endl;
}

Measured memory_bytes: 3660
#include <cstdio>
int n;
int main() {
	while(scanf("%d", &n), n) {
		n *= 2;
		int ret = 0;
		for(int i = 2; i * i < n; i++) {
			if(n % i == 0 && n / i % 2 != i % 2) ret++;
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2696
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

import re

n = ni()
s = ns()
cnt = 0
cand = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            stri = str(i)
            strj = str(j)
            strk = str(k)
            first = False
            second = False
            for si in s:
                if si == strk and first and second:
                    cnt += 1
                    break
                elif si == strj and first:
                    second = True
                elif si == stri:
                    first = True

print(cnt)


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

using ll = long long int;
using P = std::pair<int, int>;

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

int main()
{
    int h, n;

    std::cin >> h >> n;

    std::vector<int> a(n), b(n);

    int am = 0;

    rep(i, n)
    {
        std::cin >> a[i] >> b[i];
        am = std::max(am, a[i]);
    }
    am += h;

    constexpr int INF = 1e9;

    std::vector<int> d(am, INF);

    d[0] = 0;

    for (int i = 1; i < am; ++i)
    {
        rep(j, n)
        {
            if (i >= a[j])
                d[i] = std::min(d[i], b[j] + d[i - a[j]]);
        }
    }

    int ans = INF;

    for (int i = h; i < am; ++i)
    {
        ans = std::min(ans, d[i]);
    }

    std::cout << ans << std::endl;

    return 0;
}

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

conflict = [0] * M

for m in range(M):
    a, b = map(int, input().split())
    conflict[m] = (a, b)

conflict = sorted(conflict, key=lambda x: x[0])

used = [False] * M
count = 0

for m in range(M):
    if not used[m]:
        head, tail = conflict[m]
        used[m] = True

        j = m + 1
        while j < M:
            h, t = conflict[j]
            if tail <= h:
                break
            else:
                tail = min(tail, t)
                used[j] = True
            j += 1
        count += 1

print(count)

Measured memory_bytes: 19248
n = int(input())
A = list(map(int, input().split()))

ca = [0]
for i in range(n):
    ca.append(A[i]+ca[i])

ans = 2020202020
for i in range(n):
    ans = min(ans, abs(ca[i]-(ca[-1]-ca[i])))

print(ans)


Measured memory_bytes: 26764
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 2e5+100;
const ll bits = 21;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

vector< vector<ll> >I,ans;

void mul(vector< vector<ll> >&a, vector< vector<ll> >&b){
    int n = a.size();
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans[i][j]=0;
            for(int k=0;k<n;k++){
                
                ans[i][j]+= (a[i][k]*b[k][j])%mod;
                ans[i][j]%=mod;
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            a[i][j] = ans[i][j];
        }
    }

}

vector< vector<ll> > power(vector< vector<ll> >a, ll n){


    vector<vector<ll>>res = I;

    while(n){
        if(n&1){
            mul(res,a);
        }
        n/=2;
        mul(a,a);
    }

    return res;

}

int main(){
    FASTIO;
    PRECISION;

    ll n,k;
    cin>>n>>k;

    vector< vector<ll> >init(n,vector<ll>(n,0));

    I = ans = init;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>init[i][j];
        }
    }


    for(int i=0;i<n;i++) I[i][i] = 1;

    init = power(init,k);

    ll ans = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans+=init[i][j];
            ans%=mod;
        }
    }

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<n;j++){
    //         cout<<init[i][j]<<" \n"[j==n-1];
    //     }
    // }

    cout<<ans<<"\n";

}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
A,B,C,D = list(map(int, list(input())))

if A+B+C+D == 7:
    print(str(A)+'+'+str(B)+'+'+str(C)+'+'+str(D)+'=7')
elif A+B+C-D == 7:
    print(str(A)+'+'+str(B)+'+'+str(C)+'-'+str(D)+'=7')
elif A+B-C+D == 7:
    print(str(A)+'+'+str(B)+'-'+str(C)+'+'+str(D)+'=7')
elif A+B-C-D == 7:
    print(str(A)+'+'+str(B)+'-'+str(C)+'-'+str(D)+'=7')
elif A-B+C+D == 7:
    print(str(A)+'-'+str(B)+'+'+str(C)+'+'+str(D)+'=7')
elif A-B+C-D == 7:
    print(str(A)+'-'+str(B)+'+'+str(C)+'-'+str(D)+'=7')
elif A-B-C+D == 7:
    print(str(A)+'-'+str(B)+'-'+str(C)+'+'+str(D)+'=7')
elif A-B-C-D == 7:
    print(str(A)+'-'+str(B)+'-'+str(C)+'-'+str(D)+'=7')



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		int res = 0;
		
		for(char c : s.toCharArray()) {
			res+=c=='-'?-1:1;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 1e4 + 10;

int n, k, m, b[N], a[30];
char s[20];

int main(){
    while(~scanf("%d %d", &n, &k)){
        memset(a, 0,sizeof(a));
        for(int i=0; i<n; i++){
            scanf("%s", s);
            int x = s[0] - 'A';
            a[x]++;
        }
        memset(b, 0, sizeof(b));
        int p = n / k;
        m = p;
        bool flag;
        for(int i=0; i<p; i++){
            sort(a, a+26);
            flag = 1;
            for(int j=0; j<k; j++){
                if(!a[25-j]){
                    flag = 0;
                    break;
                }
            }
            if(!flag){
                m = i;
                break;
            }
            for(int j=0; j<k; j++){
                a[25-j]--;
            }
        }
        printf("%d\n", m);
    }
    return 0;
}


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

typedef std::pair<float,float> point;
typedef std::vector<point> segments;

void print_array(segments list)
{
  for(int i = 0; i < list.size(); ++i){
    std::cout << list[i].first<<" "<<list[i].second<< std::endl;
  }
}

void print_point(point pt)
{
    std::cout << pt.first<<" "<<pt.second<< std::endl;
}

void koch(int n,point p1,point p2) {
    if(n==0) {
        return;
    }

    point s=std::make_pair((2*p1.first+p2.first)/3,(2*p1.second+p2.second)/3);
    point t=std::make_pair((p1.first+2*p2.first)/3,(p1.second+2*p2.second)/3);
    float ux=(s.first+std::cos(M_PI*60/180)*(t.first-s.first)-std::sin(M_PI*60/180)*(t.second-s.second));
    float uy=(s.second+std::sin(M_PI*60/180)*(t.first-s.first)+std::cos(M_PI*60/180)*(t.second-s.second));
    point u=std::make_pair(ux,uy);
    koch(n-1, p1, s);
    print_point(s);
    koch(n-1, s, u);
    print_point(u);
    koch(n-1, u, t);
    print_point(t);
    koch(n-1, t, p2);
} 
    
int main(void){
        
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n;
    std::cin >> n;
    segments segment;
    point p1=std::make_pair(0,0);
    point p2=std::make_pair(100,0);
    print_point(p1);
    koch(n,p1,p2);
    print_point(p2);
    return 0;
}

Measured memory_bytes: 1276
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	dp           [101][100001]int
	N, K, answer int
	a            [100]int
	MOD          = 1000000007
)

func readVariables() {
	N, K = nextInt(), nextInt()
	for i := 0; i < N; i++ {
		a[i] = nextInt()
	}
}

func main() {
	readVariables()
	dp[0][0] = 1
	for i := 0; i < N; i++ {
		for j := 0; j < K+1; j++ {
			if j-a[i]-1 >= 0 {
				dp[i+1][j] = dp[i][j] - dp[i][j-a[i]-1]
			} else {
				dp[i+1][j] = dp[i][j]
			}
			dp[i+1][j] = Mod(dp[i+1][j], MOD)
		}
	}
	for i := 0; i < N; i++ {
		for j := 1; j < K+1; j++ {
			dp[N][j] += dp[N][j-1]
			dp[N][j] = Mod(dp[N][j], MOD)
		}
	}
	answer = dp[N][K]
	// for i := 0; i < N+1; i++ {
	// 	for j := 0; j < K+1; j++ {
	// 		fmt.Print(dp[i][j], ",")
	// 	}
	// 	fmt.Println()
	// }
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func Mod(x, y int) int {
	if x >= 0 {
		return x % y
	} else {
		return y + x%y
	}
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define all(a)      a.begin(),a.end()
#define getc getchar_unlocked
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/
const int sz=10e6 + 5;
int m[sz];
int cnt[sz];
void solve()
{
  int n;
  cin >> n;
  int a[n+1];
  fp(i,1,n)
  {
      cin >> a[i];
      m[a[i]]=i;
      cnt[a[i]]++;
  }
  int ans=0;
  fp(i,1,n)
  {
      int flg=1;
      fp(j,1,sqrt(a[i]))
      {
          if((a[i]%j)==0)
          {
              if(m[j]!=0)
              {
                  if(m[j]!=i)
                  {
                      flg=0;
                      break;
                  }
                  if(m[j]==i && cnt[j]>1)
                  {
                      flg=0;break;
                  }
              }
              if(m[a[i]/j]!=0)
              {
                  if(m[a[i]/j]!=i)
                  {
                      flg=0;
                      break;
                  }
                  if(m[a[i]/j]==i && cnt[a[i]/j]>1)
                  {
                      flg=0;break;
                  }
              }
          }
      }
      if(flg)
        ans++;
  }
  cout << ans << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


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

char v[1000];
int fr1[26],fr2[26];

int main()
{
    char s1[200050],s2[200050],one,two;
    cin>>s1>>s2;
    for(int i=0; i<strlen(s1); i++){
        if(v[s1[i]]==0){
            v[s1[i]]=s2[i];
        }
        else if(s2[i]!=v[s1[i]]){
            cout<<"No";
            return 0;
        }
    }
    for(int i=0; i<strlen(s1); i++){
        fr1[s1[i]-97]++;
        fr2[s2[i]-97]++;
    }
    sort(fr1,fr1+26);
    sort(fr2,fr2+26);
    for(int i=0; i<26; i++){
        if(fr1[i]!=fr2[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 640
import sys
import numpy as np
def frog2(h, K):
    c = np.full_like(h, 0)
    c[0] = 0
    c[1] = abs(h[0] - h[1])
    for i in range(2, len(c)):
        k = min(i, K)
        c[i] = np.min(c[i-k:i] + abs(h[i-k:i] - h[i]))
        # c[i] = min(c[i-k] + abs(h[i-k] - h[i]) for k in range(1, min(i+1, K+1)))
    return c[-1]


N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

print(frog2(h, K))


Measured memory_bytes: 22908
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

vector<vector<int>> nxt_idx(string s){
  // res: s[i] 以降の(s[i]含む)最初のjのindex
  int N = s.size();
  vector<vector<int>> res(N+1, vector<int>(26, -1));
  vector<int> now(26, -1);
  for(int i = N; i >= 0; i--){
    now[int(s[i]-'a')] = i;
    res[i] = now;
  }
  return res;
}

void solve(std::string s, std::string t){
  ll ans = 0;
  ll N = s.size();
  ll M = t.size();
  auto idx = nxt_idx(s);
  dump(idx);
  ll cur = 0;
  int t_idx = 0;
  while(t_idx < M){
    ll i = idx[cur][t[t_idx]-'a'];
    dump(cur, ans, i);
    if(i==-1 && cur==0){
      cout << "-1" << endl;
      return;
    }
    if(i==-1) ans += N-cur ,cur = 0;
    else{
      // cur を i+1 まで動かす
      ans += i + 1 - cur;
      cur = i + 1;
      t_idx++;
    }
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  std::string s;
  std::cin >> s;
  std::string t;
  std::cin >> t;
  solve(s, t);
  return 0;
}


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

int main()
{
  int K;
  std::string S;
  std::cin >> K;
  std::cin >> S;
  if (S.length() <= K) std::cout << S << std::endl;
  else std::cout << S.substr(0, K) << "..." << std::endl;
  return 0;
}


Measured memory_bytes: 3640
import itertools
N = int(input().strip())
name = [input().strip() for _ in range(N)]

n_dict = {k:0 for k in 'MARCH'}
for n in name:
  if n[0] in 'MARCH':
    n_dict[n[0]] += 1

ans = 0
for a,b,c in itertools.combinations('MARCH', 3):
  ans += n_dict[a]*n_dict[b]*n_dict[c]
print(ans)

Measured memory_bytes: 55128
#include<stdio.h>
int main(){
	int a, b, c;
	int x;

	scanf("%d", &x);

	a = x / 3600;
	b = (x - 3600 * a) / 60;
	c = x - 3600 * a - b * 60;

	printf("%d:%d:%d\n", a, b, c);



	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int x[105],n;
int cnt=0;
void dfs(int pos,unsigned long long cheng)
{ //  if(cheng%2!=0&&ci!=0) return;
    if(pos==n+1)
    {
       if(cheng%2==0) cnt++;
       return;
    }
    dfs(pos+1,cheng*x[pos]);
    dfs(pos+1,cheng*(x[pos]-1));
    dfs(pos+1,cheng*(x[pos]+1));
}
int main()
{
   int i;
   scanf("%d",&n);
   for(i=1;i<=n;i++) scanf("%d",&x[i]);
   dfs(1,1);
   printf("%d\n",cnt);
}


Measured memory_bytes: 256
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; ll visit[] = {};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s >> m;m--;
	n = s.length();
	for(ll i=0;i<n;i++) {
		if(i == m) { cout<<s[i]; return; }
		if(s[i]!='1') {
			cout<<s[i];
			return;
		}
	}
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 6004
s = input()

check = ["KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA","AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"]

if s in check:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
const
	num = 100000;
var
	q,l,r,i : Longint;
	not_prime:array[1..num] of Boolean;
	count:array[0..num] of Longint;
function init(): Integer;
var i,j:Longint;
begin
	not_prime[1]:=True;
	for i := 2 to num do
	begin
		if not_prime[i]= False then
		begin
			j:=i+i;
			while j<=num do
			begin
				if not_prime[j]=False then 
					not_prime[j]:=True;
				j:=j+i;
			end;
		end;
	end;
	init := 0;
end;

function get_count(): Integer;
var i:Longint;
begin
	for i := 1 to num do 
	begin
		if  (not_prime[i]=False) and (not_prime[trunc((i+1)/2)]=False) then
		begin
			count[i]:=1;
		end;
		count[i]:=count[i]+count[i-1];
	end;
	get_count := 0;
end;

begin
	init();
	get_count();
	readln(q);
	for i := 1 to q do
	begin
		read(l);
		readln(q);
		writeln(count[q]-count[l-1]);
	end;
	readln;
end.

Measured memory_bytes: 1024
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a = int(readline())
  s = input()
  if a<3200:
    print('red')
  else:
    print(s)
  
  
if __name__ == '__main__':
  main()

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

int base(int d) {
  int ans = 1;
  for(int i = 0; i < d; ++i) {
    ans *= 100;
  }
  return ans;
}

int main() {
  int D, N;
  cin >> D >> N;
  int b = base(D);
  int n = 0;
  int i = 0;
  while(i < N) {
    n++;
    if(n % 100 != 0) {
      i++;
    }
  }
  cout << n * b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N, M;

    cin >> N >> M;

    int sum = 0;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }

    if (sum <= N) {
        cout << N - sum << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

#define NUM_OF_CONTESTS 26
int main(){
    int D;
    cin >> D;
    vector<int>c(NUM_OF_CONTESTS);
    REP(i,NUM_OF_CONTESTS)cin >> c[i];

    int s[D][NUM_OF_CONTESTS];
    REP(i,D){REP(j,NUM_OF_CONTESTS){cin >> s[i][j];}}

    vector<int>t(D);
    REP(i,D){
        cin >> t[i];
        t[i]--;
    }

    ll sat = 0;
    vector<vector<int>>last(D+1,vector<int>(NUM_OF_CONTESTS,0));


    REP(i,D){
        sat+=s[i][t[i]];
        last[i+1][t[i]]=i+1;
        REP(j,NUM_OF_CONTESTS){
            if(j!=t[i])
                last[i+1][j] = last[i][j];
            sat-=c[j]*(i+1-last[i+1][j]);
        }
        cout << sat <<endl;
    }
    return 0;
}

Measured memory_bytes: 3716
while True:
    n,x=[int(x) for x in input().split()]
    if [n,x]==[0,0]:
        break
    count=0
    if 3*(n-1)>=x:
        a_max=x//3-1
        if 2*n-1<x:
            a_min=x-(2*n-1)
        else:
            a_min=1
        for a in range(a_min,a_max+1):
            b_max=(x-a-1)//2
            b_min=(x-a)-n
            b_min=b_min if b_min>a+1 else a+1
            count+=b_max-b_min+1
    print(count)
            

Measured memory_bytes: 7740
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int a, b;
	std::cin >> a >> b;
	if (a + b >= 10) {
		std::cout << "error" << std::endl;
		return 0;
	}
	else {
		std::cout << a + b << std::endl;
	}
}

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

using namespace std;

typedef long long ll;

ll n, k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    cout << min(n % k, k - n % k) << "\n";
    return 0;
}


Measured memory_bytes: 256
import numpy as np

# input
H, W = map(int, input().split())
A = np.array([list(input()) for _ in range(H)])

B = A[:, np.any(A == '#', axis = 0)]
C = B[np.any(B == '#', axis = 1), :]

for i in range(C.shape[0]):
    print(''.join(C[i]))

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

int a[200005];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	int szukana = 1;
	int rozwalone = 0;
	for (int i = 1; i <= n; ++i){
		if (a[i] == szukana)
			szukana++;
		else
			rozwalone++;
	}
	if (rozwalone == n)
		cout << "-1\n";
	else
		cout << rozwalone << "\n";
}

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

void Main()
{
  int n;
  cin >> n;
  
  if(n >= 30)
    printf("Yes");
  else
    printf("No");
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}



Measured memory_bytes: 3660
S = input()

HIGH = int(S[:2])
LOW = int(S[2:])

if 1 <= HIGH <= 12:
	if 1 <= LOW <= 12:
		print('AMBIGUOUS')
	else:
		print('MMYY')
else:
	if 1 <= LOW <= 12:
		print('YYMM')
	else:
		print('NA')



Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
// #define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 1e5 + 5;
int a[maxn],dp[maxn];
int main(int argc, char const *argv[])
{
	memset(dp,0x3f3f3f3f,sizeof(dp));
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		scanf("%d",&a[i]);
	}
	dp[1] = 0;
	dp[2] = abs(a[1] - a[2]);
	for(int i = 3;i <= n; ++i)
	{
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]),dp[i - 2] + abs(a[i] - a[i - 2]));
		debug("dp[%d] = %d\n",i,dp[i]);
	}
	printf("%d\n",dp[n]);
	return 0;
}

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

int main(void){
  while(true){
    string str;
    if(!getline(cin, str)) break;;
    while(true){
      for(int i = 0; i < str.size(); i++){
        if(isalpha(str[i]) && str[i] == 'z'){
          str[i] = 'a';
        }else if(isalpha(str[i])){
          str[i]++;
        }
      }
      if(str.find("that") != string::npos || str.find("this") != string::npos || str.find("the") != string::npos) break;
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
<?php
list($N, $C) = ints();
for($i = 0; $i < $C; $i++){
    $G[] = ints();
    $count[0][$i] = 0;
    $count[1][$i] = 0;
    $count[2][$i] = 0;
}
for($i = 0; $i < $N; $i++){
    $row = ints();
    foreach($row as $j => $c){
        $count[($i+$j)%3][$c-1]++;
    }
}
$min = 10**18;
for($i = 0; $i < $C; $i++)
    for($j = 0; $j < $C; $j++)
        for($k = 0; $k < $C; $k++)
            if($i!=$j && $j!=$k && $i!=$k){
                $cost = 0;
                for($y = 0; $y < $C; $y++){
                    $cost += $count[0][$y] * $G[$y][$i]; 
                    $cost += $count[1][$y] * $G[$y][$j]; 
                    $cost += $count[2][$y] * $G[$y][$k]; 
                }
                chmin($min, $cost);
            }
echo $min,"\n";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}

/**
 * Warshall–Floyd
 * Attention: 1-origin
 **/
class Wf{
  public $d;
  public $n;
  function __construct($n)	{
    $this->n = $n;
    $array = array_fill(1, $n, PHP_INT_MAX);
    $this->d = array_fill(1, $n, $array);
    for($i = 1; $i <= $this->n; $i++){
        $this->d[$i][$i] = 0;
    }
  }
  function connect($a, $b, $c){
    $this->d[$a][$b] = $c;
  }
  function connect2($a, $b, $c){
    $this->d[$a][$b] = $c;
    $this->d[$b][$a] = $c;
  }
  function solve(){
    $d = &$this->d;
    $n = $this->n;
    for($k = 1; $k <= $n; $k++){
      for($i = 1; $i <= $n; $i++){
        for($j = 1; $j <= $n; $j++){
          if($d[$i][$j] > $d[$i][$k] + $d[$k][$j]){
            $d[$i][$j] = $d[$i][$k] + $d[$k][$j];
          }
        }
      }
    }
    return $d;
  }
}

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int n, r, p, c;

    while(true){
        stack<int> x;
        cin >> n >> r;
        if(n == 0 && r == 0) break;

        for(int i=1; i<=n; i++){
            x.push(i);
        }

        for(int i=0; i<r; i++){
            stack<int> pp, cc;
            cin >> p >> c;
            for(int i=0; i<p-1; i++){
                pp.push(x.top());
                x.pop();
            }
            
            for(int i=0; i<c; i++){
                cc.push(x.top());
                x.pop();
            }

            for(int i=0; i<p-1; i++){
                x.push(pp.top());
                pp.pop();
            }
            for(int i=0; i<c; i++){
                x.push(cc.top());
                cc.pop();
            }
        }

        cout << x.top() << endl;
    }

    return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <numeric>
using namespace std;
long long gcd(long long a,long long b){
  long long tmp,r,x=a*b;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return x/b;
}

int main() {
  long long A,B,C,D,x,y,z;
  cin>>A>>B>>C>>D;
  x=B/C-A/C;
  if(A%C==0) x++;
  y=B/D-A/D;
  if(A%D==0) y++;
  z=B/gcd(C,D)-A/gcd(C,D);
  if(A%gcd(C,D)==0) z++;
  cout<<B-A+1-(x+y-z)<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;
 

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n,q;
	string s;
	cin>>n>>s>>q;
	vector<set<int>> is(26);
	for(int i=0;i<n;++i){
		is[s[i]-'a'].insert(i);
	}
	while(q--){
		int opt;
		cin>>opt;
		if(opt==1){
			int i;
			char c;
			cin>>i>>c;
			--i;
			is[s[i]-'a'].erase(i);
			s[i]=c;
			is[s[i]-'a'].insert(i);
		}
		else{
			int l,r;
			cin>>l>>r;
			--l;
			int cnt=0;
			for(int i=0;i<26;++i){
				auto it=is[i].lower_bound(l);
				if(it!=is[i].end()&&*it<r) ++cnt;
			}
			cout<<cnt<<endl;
		}
	}
	return 0;
}



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


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<in> p(a,0ll);
    rep(i,a) cin>>p.at(i);
    vector<in> q(b,0ll);
    rep(i,b) cin>>q.at(i);
    vector<in> r(c,0ll);
    rep(i,c) cin>>r.at(i);
    priority_queue<P> que;
    rep(i,a) que.emplace(p[i],0ll);
    rep(i,b) que.emplace(q[i],1ll);
    rep(i,c) que.emplace(r[i],2ll);
    in eat_a=0ll,eat_b=0ll,eat_c=0ll;
    in ans=0ll;
    while(eat_a+eat_b+eat_c<x+y){
        in s,t;
        tie(s,t)=que.top();
        que.pop();
        if(t==2ll){
            eat_c ++;
            ans +=s;
        }
        if(t==0ll && eat_a<x){
            eat_a ++;
            ans +=s;
        }
        if(t==1ll && eat_b<y){
            eat_b ++;
            ans +=s;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13036
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;cin >> a >> b;
  if(a*b <= 0)cout << "Zero\n";
  else if(a > 0)cout << "Positive\n";
  else if((b - a)%2)cout << "Positive\n";
  else cout << "Negative\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
int a[N];
int n, k, q;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d%d", &n, &k, &q);
	for (int i = 0; i < n; i++)
		a[i] = k;
	for (int i = 0; i < q; i++) {
		int x;
		scanf("%d", &x);
		x--;
		a[x]++;
	}
	for (int i = 0; i < n; i++) {
		a[i] -= q;
		if (a[i] > 0)
			printf("Yes\n");
		else
			printf("No\n");
	}

	return 0;
}


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

int c[5];

int main()
{
    string name;
    int sum = 0; 
    
    for(int i = 0; i < 6; i++){
        cin >> c[i];
    }
    c[0]=c[0]*1;
    c[1]=c[1]*5;   
    c[2]=c[2]*10;
    c[3]=c[3]*50;
    c[4]=c[4]*100;
    c[5]=c[5]*500;
        
    for(int y = 0; y < 6; y++){
        sum += c[y];
    }
        
    if(sum < 1000){
        cout << 0 <<endl;
    }
    else{
        cout << 1 <<endl;
    }
    
}

Measured memory_bytes: 1164
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int count(int N)
{
        int cnt = 0;
        while (N)
        {
                cnt += N % 10;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N, x;
        cin >> N;
        vector<int> a(3 * N + 1);
        rep(i, 3 * N) cin >> a[i];
        sort(a.begin(), a.begin() + 3 * N);
        reverse(a.begin(), a.begin() + 3 * N);
        // rep(i, 3 * N)
        // {
        //         cout << a[i] << ' ';
        // }
        // cout << endl;

        ll ans = 0;
        for (int i = 1; i < 2 * N; i += 2)
        {
                ans += a[i];
        }

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


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:


//ll N;
const char dummy(ll n){
	cout << "? " << n << endl << flush;
	//if(n<=N and to_string(n) <= to_string(N)) return true;
	//if(n> N and to_string(n) > to_string(N)) return true;
	//return false;
	char c;
	cin >> c;
	return c=='Y';
}

void solve(){
	ll len = 11;
	while(len){
		if(dummy(stoll("1" + string(len-1,'0'))) and dummy(stoll(string(len,'9')))) break;
		len--;
	}

	if(len==11){
		while(len){
			if(dummy(stoll(string(len,'9')))==false) break;
			len--;
		}		
		len++;
	}

	//cout << len << endl;

	ll high = pow<ll>(10LL,len) -1LL;
	ll low  = pow<ll>(10LL,len-1) - 1LL;

	while(high-low>1){
		const ll mid = (low + high) /2LL;
		if(dummy(mid*10LL+9LL))
			high = mid;
		else
			low = mid;
	}

	cout << "! " << high << endl << flush;
	//cout << high << endl << flush;
	//if(high != N) cout << len << " " << high << " " << N << endl;
	return ;
}


int main(void){

	solve();

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    vector<ll> t(2),a(2),b(2);
    rep(i,2) cin >> t[i];
    rep(i,2) cin >> a[i];
    rep(i,2) cin >> b[i];
    rep(i,2){
        a[i]*=t[i];
        b[i]*=t[i];
    }
    if (a[0]+a[1]==b[0]+b[1]){
        cout << "infinity" << endl;
        return 0;
    }
    if (a[0]+a[1]<b[0]+b[1]){
        swap(a[0],b[0]);
        swap(a[1],b[1]);
    }
    if (a[0]>b[0]){
        cout << 0 << endl;
        return 0;
    }
    ll p=b[0]-a[0],q=a[0]+a[1]-b[0]-b[1];
    ll x=p/q;
    if (p%q==0){
        cout << 2*x << endl;
    }
    else {
        x+=1;
        cout << 2*x-1 << endl;
    }
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")

a,b,c = I()
if a == b == c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10156
n, m = STDIN.gets.split(' ').map(&:to_i)

cities = Array.new(m, 0)

m.times do |i|
  p, y = STDIN.gets.split(' ').map(&:to_i)
  cities[i] = [i, p, y]
end

sorted_cities = cities.sort_by do |city|
  city[2]
end

# p cities

map = {}

count = Hash.new(1)

sorted_cities.each do |city|
  map[city[2]] = count[city[1]]
  count[city[1]] += 1
end

cities.each do |city|
  puts "#{sprintf("%06d", city[1])}#{sprintf("%06d", map[city[2]])}"
end


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


def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)
    
    m = sum([v for v in c.values()])
    cl = len([c for c in c.keys()])

    while(m > cl):
        m -= 2
    
    print(m)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

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

Node root;

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

}

Node treeMaximum(Node x){
  while(x->right !=NIL){
    x=x->right;
  }
  return x;

}
Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;

  if(k<u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  else if(x->left !=NIL ) return treeMaximum(x->left);

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

}

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

  if(z->left==NIL || z->right == NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x= y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;

}

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

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

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

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

}

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


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

}


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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &a);
      Node t = treeSearch(root, a);

      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }

    else if ( com[0] == 'i' ){
      scanf("%d", &a);
      insert(a);
    }

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }


    else if ( com[0] == 'd' ){
      scanf("%d", &a);
      treeDelete(treeSearch(root, a));
    }

  }

  return 0;
}



Measured memory_bytes: 20416
N, *AB = map(int, open(0).read().split())
A = AB[:N+1]
B = AB[N+1:]

ans = 0

for i in range(N):
    left = min(A[i], B[i])
    ans += left
    A[i] -= left
    B[i] -= left
    
    right = min(A[i+1], B[i])
    ans += right
    A[i+1] -= right
    B[i] -= right
    
print(ans)

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

long long n,k,k2;
int a[200005];
int is_visited[200005];

class Loop{
public:
    Loop(int _s, int _st, int _g, int _gt):s(_s),st(_st),g(_g),gt(_gt){}
    int s,st,g,gt;
};

Loop find_loop(int i){
    int next=a[i];
    if(is_visited[next]!=-1){
        int st=is_visited[next];
        int gt=is_visited[i];
        Loop res(next,st,i,gt);
        return res;
    }
    is_visited[next]=is_visited[i]+1;
    return find_loop(next);
}

int main(){
    cin>>n>>k;
    k2=k;
    for(int i=0;i<n;++i){
        cin>>a[i];
        --a[i];
    }
    for(int i=0;i<n;++i) is_visited[i]=-1;
    is_visited[0]=0;
    Loop l=find_loop(0);
    int s=l.s,st=l.st,g=l.g,gt=l.gt;
    long long loop_size=gt-st+1;
    k-=st;
    k%=loop_size;
    int cur=s;
    for(long long i=0;i<k;++i){
        cur=a[cur];
    }

    for(int i=0;i<n;++i){
        if(is_visited[i]==k2){
            cout<<++i<<endl;
            return 0;
        }
    }
    cout<<++cur<<endl;
}

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

using namespace std;

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

  int n, a;
  cin >> n;
  int res = 1e9;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    int cnt = 0;
    while (a%2 == 0) {
      cnt++;
      a /= 2;
    }
    res = min(res, cnt);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256