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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  string s;cin>>s;
  ll n=s.size();
  ll ans=n;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      ans=min(ans,max(i+1,n-1-i));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,m;
cin >> n >> m;
int s;
int c;
int ans[n];
REP(i,n) {
  ans[i]=-1;
}
bool flg = true;
REP(i,m) {
  cin >> s >> c;
  if(ans[s-1]==-1||ans[s-1]==c) {
    ans[s-1]=c;
  } else {
    flg = false;
  }
}
if(n>1&&ans[0]==0) flg=false;
if(flg==true) {
  REP(i,n) {
    if(ans[i]==-1) {
      if(n>1&&i==0) {
        cout << "1";
      } else {
        cout << "0";
      }
    } else {
      cout << ans[i];
    }
  }
  cout << endl;
} else {
  cout << "-1" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>> n;
    string s, t;
  cin >> s>> t;
  for(int i = 0; i < 2*n; ++i){
      if(i%2 == 0){
        cout << s[i/2];
    }else{
        cout << t[i/2];
    }
  }
}

Measured memory_bytes: 256
"""
AtCoder :: Beginner Contest 174 :: Distance
https://atcoder.jp/contests/abc174/tasks/abc174_b
"""
import sys


def main():
    """Main program."""
    point_count, dist = (int(i) for i in sys.stdin.readline().split())
    dist_sq = (dist * dist)
    soln = 0
    for _ in range(point_count):
        x, y = (int(i) for i in sys.stdin.readline().split())
        if (x * x) + (y * y) <= dist_sq:
            soln += 1
    print(soln)



if __name__ == '__main__':
    main()


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

using namespace std;

int n, x, ans;
int l[100], d[100];

int main(){
	cin >> n >> x;
	for(int i = 0; i < n; ++i) cin >> l[i];
	
	for(int i = 1; i <= n; ++i){
		d[i] = d[i - 1] + l[i - 1];
	}
	
	for(int i = 0; i <= n; ++i){
		if(d[i] <= x) ans++;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 200005
#define MOD 1000000007


int main(){

    vector<int> a(ARRAY_MAX,0);
    int n,k;
    cin >> n >> k;
    int tmp;
    int maxi = -1;
    REP(i,n){
        cin >> tmp;
        a[tmp-1]++;
        maxi = max(maxi,tmp);
    }
    /*REP(i,10){
        cout << a[i] << " ";
    }*/
    //cout << endl;
    //cout << maxi << endl;
    sort(a.begin(),a.begin()+maxi,greater<int>());
    /*REP(i,10){
        cout << a[i] << " ";
    }*/
    int cnt = 0;
    REP(i,k){
        cnt+= a[i];
    }
    cout << n-cnt << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

int main() {
  int n;
  std::cin >> n;
  if (n % 2 == 1) {
    std::cout << 0 << "\n";
    return 0;
  }
  int d[n];
  for (int i = 0; i < n; i++) {
    std::cin >> d[i];
  }
  std::sort(d, d + n);
  std::cout << d[n / 2] - d[n / 2 - 1] << "\n";
  return 0;
}

Measured memory_bytes: 640
N, A, B = map(int, input().split(' '))
S = input()

passed_a = 0
passed_b = 0
ans = []
for i in range(N):
    if S[i] == 'a':
        if passed_a + passed_b < A + B:
            ans.append('Yes')
            passed_a += 1
        else:
            ans.append('No')

    if S[i] == 'b':
        if passed_a + passed_b < A + B and passed_b < B:
            ans.append('Yes')
            passed_b += 1
        else:
            ans.append('No')

    if S[i] == 'c':
        ans.append('No')

for _ in ans:
    print(_)

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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> score;
    rep(i, n) cin >> s[i];
    rep(i, n)
    {
        score[s[i]] += 1;
    }
    int max = 0;
    for (auto i = score.begin(); i != score.end(); ++i)
    {
        if (i->second > max)
        {
            max = i->second;
        }
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    for (auto it = s.begin(); it != s.end(); ++it)
    {
        if (score[*it] == max)
            cout << *it << endl;
    }

    return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    string S;
    cin >> S;
    int appear[3]={};
    int lenS = S.length();
    rep(i, lenS){
        appear[S[i] - 'a']++;
    }
    if(max(appear[2], max(appear[0], appear[1])) - min(appear[2], min(appear[0], appear[1])) <= 1)
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)

#define p 998244353

//非再帰fft
void fft(ll*a,int n,ll g){
	for(int block=n;block>=2;block/=2){
		ll gi=1;
		for(int i=0;i<block/2;i++){
			for(int start=0;start<n;start+=block){
				//a[start+i]とa[start+i+block/2]を合体
				int temp=a[start+i]-a[start+i+block/2];
				a[start+i]+=a[start+i+block/2];
				if(a[start+i]>=p)a[start+i]-=p;
				a[start+i+block/2]=(temp+p)*gi%p;
			}
			gi=gi*g%p;
		}
        g=g*g%p;
	}

	//bit reverse
	int i=0;
	rep(j,1,n-1){
		for(int k=n>>1;k>(i^=k);k>>=1);//rev(i)に2進の+1をやる気持ち
		if(j<i){int t=a[j];a[j]=a[i];a[i]=t;}
    }
}

ll*comb(ll*a,int n,ll*b,int m){
	//0詰め
	int t=1;
	while(n+m-1>t)t*=2;
	if(t>(1<<26)){puts("error");exit(0);}
	ll*c=(ll*)calloc(t,sizeof(ll));
	memcpy(c,a,n*sizeof(ll));
	ll*d=(ll*)calloc(t,sizeof(ll));
	memcpy(d,b,m*sizeof(ll));
	//fft
	ll g=pom(3,(p-1)/t,p);
	fft(c,t,g);
	fft(d,t,g);
	//掛け算
	rep(i,0,t)c[i]=c[i]*d[i]%p;
	free(d);
	//復元
	fft(c,t,invp(g,p));
	ll coef=invp(t,p);
	rep(i,0,t)c[i]=c[i]*coef%p;
	return c;
}

ll a[1<<19],b[1<<19];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,m)scanf("%lld",b+i);
	ll*c=comb(a,n,b,m);
	rep(i,0,n+m-1)printf("%lld ",c[i]);
}


Measured memory_bytes: 27148
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {

int a, b, c, d, e, f;

	while(cin >> a >> b >> c >> d >> e >> f) {
	
	 double y = (double)(a*f - c*d)/(a*e - b*d);
	 double x = (double)(c - b*y)/a;

	printf("%.3f %.3f\n", x, y);
	}

    return 0;
}

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

ll a[114514],b[114514];


int main(){
	ll A,B,m;
	cin>>A>>B>>m;
	ll mia=1e18,mib=1e18;
	for(int i=0;i<A;i++){
		cin>>a[i];
		mia=min(a[i],mia);
	}
	for(int i=0;i<B;i++){
		cin>>b[i];
		mib=min(b[i],mib);
	}
	ll ans=mia+mib;
	for(int i=0;i<m;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans;

	return 0;
}


Measured memory_bytes: 1920
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    System.out.println(a[sc.nextInt()] == a[sc.nextInt()] ? "Yes":"No");
  }
}


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

int n, d, x;

int main() {
  cin >> n >> d >> x;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    for (int j = 0; j < d; ++j) {
      if (a * j + 1 <= d) x++;
    }
  }
  cout << x << endl;
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int ans = 0;
  int cnt = -1;
  int now = 2e9;
  int n;
  cin >> n;
  rep(i, n) {
    int h;
    cin >> h;
    if (now >= h) {
      cnt++;
      amax(ans, cnt);
    } else {
      cnt = 0;
    }
    now = h;
  }
  cout << ans << endl;
}


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

intmax_t f(intmax_t r) {
  std::string s = std::to_string(r);
  intmax_t res = 0;
  for (size_t i = 1; i < s.length(); ++i) {
    std::string s0 = s.substr(0, i);
    std::string s1 = s.substr(i);
    intmax_t r0 = std::stoi(s0);
    intmax_t r1 = std::stoi(s1);
    res = std::max(res, r0*r1);
  }
  if (res > 1e9) return -1;
  return res;
}

int testcase_ends() {
  intmax_t R;
  scanf("%jd", &R);

  int res = 0;
  while (R > 9) {
    R = f(R);
    ++res;
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) testcase_ends();
}



Measured memory_bytes: 2848
N, x = map(int,input().split())
A = list(map(int,input().split()))
adj = []
ans = 0
for i in range(N-1):
    adj.append(A[i]+A[i+1])

if N > 2:
    if adj[0] > x:
        dif = adj[0]-x
        if A[1] <= dif:
            adj[1] -= A[1]
        else:
            adj[1] -= dif
        ans += dif
            
    for i in range(1, N-2):
        if adj[i] > x:
            dif = adj[i]-x
            adj[i] = x
            adj[i+1] -= dif
            ans += dif

    if adj[N-2] > x:
        ans += adj[N-2]-x
else:
    if A[0] + A[1] <= x:
        ans = 0
    else:
        ans = A[0] + A[1] - x
print(str(ans))

Measured memory_bytes: 64612
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    for i in range(2):
        if s[i] == s[i + 1] == s[i + 2]:
            print("Yes")
            return
    print("No")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,ans,digi=0;
    cin >> n;
    for(int i=sqrt(n);i>0;i--){
        if(n % i == 0){
            ans = n/i;
            //cout << "ans" << " " << ans << endl;
            break;
        }
    }
    for(digi=0;;digi++){
        if(ans / pow(10,digi) < 1){
            //cout  << "pow" << " " << pow(10,digi) << endl;
            cout << digi << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main(){
	ll n;
	ll m;
	cin>>n>>m;
	vector<ll> s(m);
	vector<ll> c(m);
	vector<ll> ans(n,0);
 
	rep(i,m){
		cin>>s.at(i)>>c.at(i);
	}
 
	int test = 345;
	if (n>1)
	{
		ans.at(0)=1;
	}
	
 
	
	
	for (size_t i = 0; i < m; i++)
	{
		if (ans.at(s.at(i)-1)==0 || ans.at(s.at(i)-1)==c.at(i) || ((s.at(i)-1)==0 && ans.at(s.at(i)-1)==1))
		{
			ans.at(s.at(i)-1) = c.at(i);
		} else {
			cout<<-1;
			return 0;
		}
		
	}
 
 
	if (n>1 && ans.at(0)==0)
	{
		cout<<-1;
		return 0;
	}
 
	// ll res = 0;
	// for (size_t i = 0; i < n; i++)
	// {
		// res += ans.at(i)*pow(10,n-i-1);
	// }
 
	// cout<<res;
	
	for (size_t i = 0; i < n; i++)
	{
		cout<<ans.at(i);
	}
	
	
}

Measured memory_bytes: 256
/**
*   @Author : MeGA
*   @InitTime :01/25/20 10:43:57
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif
      int n;
      scanf("%d",&n);
      vector<int>a(n);
      for(int i=0;i<n;i++){
         scanf("%d",&a[i]);
      }
      a[0]--;
      for(int i=1;i<n;i++){
         if(a[i]-1 >= a[i-1])a[i]--;
      }
      for(int i=0;i<n-1;i++){
           if(a[i] > a[i+1]){
              printf("No");
              return 0;
           } 
      }
      printf("Yes");



}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] arrstring = br.readLine().split(" ");
		int[] arr = new int[n];
		
		for(int i =0 ;i<n;i++){
			arr[i] = Integer.parseInt(arrstring[i]);
		}
		int counter = 0;
		for(int i =0; i<arr.length;i++){
			if(arr[arr[i]-1]==i+1)counter++;
		}
		System.out.println(counter/2);//
	}
}

Measured memory_bytes: 24312
//Dictionary
#include <iostream>

using namespace std;

const int m = 1000003;

int h1(int key) {
    return key % m;
}

int h2(int key) {
    return 1 + (key % (m - 1));
}

int h(int key, int i) {
    return (h1(key) + i * h2(key)) % m;
}

int getInt(char c) {
    if(c == 'A') return 1;
    else if(c == 'C') return 2;
    else if(c == 'G') return 3;
    else if(c == 'T') return 4;
    return 0;
}

long long getKey(string str) {
    long long sum = 0, p = 1;
    for(int i=0; i<str.size(); i++) {
        sum += p * getInt(str[i]);
        p *= 5;
    }
    return sum;
}

class Dictionary {
private:
    string *data = new string[m];
public:
    Dictionary() {
        for(int i = 0; i < m; i++) data[i] = string("N");
    };
    void insert(string str) {
        int i=0, hash_key;
        while(i<m) {
            hash_key = h(int(getKey(str)), i);
            if(data[hash_key] == "N" || data[hash_key] == str) {
                data[hash_key] = str;
                break;
            }
            i++;
        }
    };
    string find(string str) {
        int i = 0, hash_key;
        while(i < m) {
            hash_key = h(int(getKey(str)), i);
            if(data[hash_key] == "N") return "no";
            else if(data[hash_key] == str) return "yes";
            i++;
        }
        return "no";
    };
};

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

    Dictionary D;
    string operation, operand;
    for(int i = 0; i < n; i++) {
        cin >> operation >> operand;
        if(operation[0] == 'i') D.insert(string(operand));
        else cout << D.find(string(operand)) << endl;
    }
}


Measured memory_bytes: 66700
#include<iostream>
using namespace std;
int main(){
  int a;
  int i;
  int c = 0;
  cin >> a;
  while(a>=500){
    a -= 500;
    c += 1000;
  }
  while(a>=5){
    a -= 5;
    c += 5;
  }
  cout << c << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll a[200001];
const ll INF=1000100010001000100;;
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i+1];
    rep(i,n) a[i+1]+=a[i];
    ll ans=INF;
    int l=1,r=3;
    FOR(i,2,n-1){
        ll lhf=a[i],rhf=a[n];
        ll lmn=abs(lhf-a[l]-a[l]),rmn=abs(rhf-a[r]-a[r]+a[i]);
        while(l+1<i&&lmn>abs(lhf-a[l+1]-a[l+1])) ++l,lmn=abs(lhf-a[l]-a[l]);
        while(r+1<n&&rmn>abs(rhf-a[r+1]-a[r+1]+a[i])) ++r,rmn=abs(rhf-a[r]-a[r]+a[i]);
        ll mn=min(min(lhf-a[l],a[l]),min(rhf-a[r],a[r]-a[i]));
        ll mx=max(max(lhf-a[l],a[l]),max(rhf-a[r],a[r]-a[i]));
        //cout<<mx<<" "<<mn<<endl;
        ans=min(ans,mx-mn);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>


int main(void)
{
  int n;
  int l;
  int a;
  
  scanf("%d %d",&n,&l);
  
  if(l>=0)
    a=l;
  else
  {
    if(n+l-1>=0)
      a=0;
    else
      a=n+l-1;
  }
  printf("%d",n*l+n*(n-1)/2-a);
  
  return 0;
  
}

Measured memory_bytes: 128
//<--sbhmsh-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
int main(){
  FASTIO
  int n;
	cin>>n;
	vector<pair<int, int>>v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.push_back({x, i+1});
	}
	sort(v.begin(), v.end());
	for(int i=0;i<n;i++){
		cout<<v[i].second<<" ";
	}
}


Measured memory_bytes: 1780
#include<iostream>

using namespace std;

int main(){
	int N;
	int num_even;
	int num_odd;
	cout.precision(20);
	cin >> N;
	num_even = N / 2;
	num_odd = N-num_even;

	// cout << N << endl;
	// cout << num_even << endl;
	// cout << num_odd<< endl;
	// cout << (N-num_even)/N << endl;
	// cout << (N-num_even)/(double)N << endl;

	cout << num_odd/(double)N << endl;
	

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long A, long long B, long long C) {
  if (C >= A && C <= B) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long C;
  long long B;
  long long A;
  cin >> A;
  cin >> B;
  cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	ll M;
	cin >> N >> M;
	vector<ll> X;
	for (int i = 1; i * i <= M; i++) {
		if (M % i == 0) {
			X.push_back(i);
			if (i * i != M) {
				X.push_back(M / i);
			}
		}
	}
	sort(X.begin(), X.end());
	ll ans = 0;
	int j = 0;
	while (X[j] * N <= M) {
		ans = X[j];
		j++;
		if (j == X.size()) {
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> 
#include<algorithm>
#include <cmath>
using namespace std;
using ull = unsigned long long;

int main() {
  	float t,a,dif= 100000000,result,h;
  	int n;
  	cin>>n>>t>>a;
  	for(int i= 0;i<n;i++){
      cin>>h;
      if (dif > abs(a - (t -h*0.006))){
        dif=abs(a - (t -h*0.006));
        result= i+1;
      }
    }
  	cout<<result<<endl;
  	return 0;
}



Measured memory_bytes: 256
K=input()
N=len(K)
D=int(input())
import numpy as np
d=np.zeros((N+1,D),dtype=np.int64)
d2=np.zeros((N+1,D),dtype=np.int64)
d[0,0]=1
m=10**9+7
r=(D+9)//D
for i in range(N):
    dc=d[i]
    dc2=d2[i]
    for j in range(r):
        dc=np.concatenate((dc,d[i]))
        dc2=np.concatenate((dc2,d2[i]))
    dc,dc2=np.cumsum(dc),np.cumsum(dc2)
    x=int(K[i])
    d[i+1]=np.roll(d[i],x)
    d2[i+1]=(dc[r*D:]-dc[r*D-x:(r+1)*D-x]+dc2[r*D:]-dc2[r*D-10:(r+1)*D-10])%m
print((d[-1,0]+d2[-1,0]-1)%m)

Measured memory_bytes: 28112
import numpy as np
import sys

# 整数の入力
a = int(sys.stdin.readline())
# スペース区切りの整数の入力
n = [int(i) for i in sys.stdin.readline().split()]

avg = np.mean(n)
p = round(avg)

print(int(sum([(i-p)*(i-p) for i in n])))


Measured memory_bytes: 19656
#include<iostream>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
using namespace std;
int main(){
	int n,m,k,p,q,r ,a,b,cost,time;
	while(cin>>n>>m,n){
		int c[m][m],t[m][m];
		rep(i,m)rep(j,m)c[i][j]=t[i][j]=INF;
		rep(i,n)cin>>a>>b>>cost>>time,a--,b--,
		c[a][b]=c[b][a]=cost,t[a][b]=t[b][a]=time;
		cin>>k; rep(i,k){
			cin>>p>>q>>r,p--,q--;
			if(r){
				int T[m]; rep(j,m)T[j]=INF;
				queue<int> F; T[p]=0; F.push(p);
				while(!F.empty()){
					int cur=F.front(); F.pop();
					rep(j,m)if(t[cur][j]&&T[j]>T[cur]+t[cur][j])
					F.push(j),T[j]=T[cur]+t[cur][j];
				}
				cout<<T[q]<<endl;
			}else{
				int C[m]; rep(j,m)C[j]=INF;
				queue<int> F; C[p]=0; F.push(p);
				while(!F.empty()){
					int cur=F.front(); F.pop();
					rep(j,m)if(c[cur][j]&&C[j]>C[cur]+c[cur][j])
					F.push(j),C[j]=C[cur]+c[cur][j];
				}
				cout<<C[q]<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 984
program ABC152D
    implicit none
    integer(8)::N,i,j,top,tail
    integer(8)::result=0
    integer(8),dimension(10,10)::C
    read(5,*)N
    C=0

    do i=1,N
        tail=mod(i,10)
        j=i
        top=i
        do
            j=j/10
            if(j==0)then
                exit
            end if
            top=j
        end do
        C(top+1,tail+1)=C(top+1,tail+1)+1
    end do

    do i=1,10
        do j=1,10
            result=result+C(i,j)*C(j,i)
        end do
    end do

    print'(i0)',result
end program ABC152D

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

using namespace std;

int main() {
    int m, n;
    cin >> m >> n;
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        m -= x;
    }
    if (m < 0) {
        cout << -1;
    } else {
        cout << m;
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a[3],k;
  REP(i,3) cin >> a[i];
  cin >> k;

  sort(a,a+3);
  COUT(a[0]+a[1]+a[2]*pow(2,k));
  return 0;
}

Measured memory_bytes: 256
#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;

#define MAX 100005
#define INF INT_MAX

struct Edge {
    int to;
    int cost;
};

int main(int, char**)
{
    int n;
    cin >> n;

    vector< vector<Edge> > G(n);
    rep(i,n) {
        int u, k;
        cin >> u >> k;
        rep(j,k) {
            int v, c;
            cin >> v >> c;
            G[u].push_back({v, c});
        }
    }
    priority_queue<P, vector<P>, greater<P> > q;
    vector<int> d(n, INF);
    d[0] = 0;
    q.push({0, 0});
    while (!q.empty()) {
        int v, c;
        tie(c,v) = q.top(); q.pop();
        if (d[v] < c) continue;
        for (auto e : G[v]) {
            if (d[e.to] <= d[v] + e.cost) continue;
            d[e.to] = d[v] + e.cost;
            q.push({d[e.to], e.to});
        }
    }
    rep(i,n) cout << i << " " << d[i] << endl;

    return 0;
}



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

public class Main {

    public static void main(String[] args) throws IOException {
        var rd = new BufferedReader(new InputStreamReader(System.in));
        var r = Integer.parseInt(rd.readLine());
        System.out.println(2 * Math.PI * r);
    }
}


Measured memory_bytes: 33024
#include <stdio.h>
int main()
{
    int sum = 0, a[101][101] = {0}, r, c;
    scanf("%d %d", &r, &c);
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            a[i][c] = a[i][c] + a[i][j];
            a[r][j] = a[r][j] + a[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        a[r][c] = a[r][c] + a[i][c];
    }

    for (int i = 0; i < r + 1; i++)
    {
        for (int j = 0; j < c + 1; j++)
        {
            if (j == 0)
            {
                printf("%d", a[i][j]);
            }
            else
            {
                printf(" %d", a[i][j]);
            }
        }
        printf("\n");
    }

    return 0;
}


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

typedef long long int big;

int main(){
	//freopen("pdi.txt","r",stdin);
	//freopen("pdo.txt","w",stdout);
	big h;
	big n=0;
	cin>>h;
	do{
		n++;
		h=h/2;
	}while(h!=0);
	
	big res = 1;
	while(n--){
		res=res*2;
	}
	cout<<(big)res-1<<endl;
	//getch();
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    double ans=0;
    for(int i=1; i<=n; i++){
        double res=1.0;
        int j=i;
        while(j<k){
            j*=2; res/=2.0;
        }
        ans+=res;
    }
    cout<<setprecision(30)<<ans/n<<endl;
}

Measured memory_bytes: 256
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
print(min((2*n+m)//4,m//2))

Measured memory_bytes: 10016
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

lint H, W, dp[1000][1000], sy, sx, gy, gx;
char mp[1000][1000];

struct tlint {
	lint val;
	lint y;
	lint x;
};

int main() {
	cin >> H >> W;
	cin >> sy >> sx; sy--; sx--;
	cin >> gy >> gx; gy--; gx--;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
			dp[i][j] = INF;
		}
	}

	auto comp = [](tlint a, tlint b) {
		return a.val < b.val;
	};

	priority_queue < tlint, vector<tlint>, decltype(comp)> que{ comp };
	dp[sy][sx] = 0;
	que.push({ -dp[sy][sx], sy, sx });
	while (!que.empty()) {
		tlint curr = que.top(); que.pop();
		if (curr.y == gy && curr.x == gx) break;
		REP(k, 4) {
			lint ny = curr.y + dy[k], nx = curr.x + dx[k];
			if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if (mp[ny][nx] == '#') continue;
			if (dp[ny][nx] > dp[curr.y][curr.x]) {
				dp[ny][nx] = dp[curr.y][curr.x];
				que.push({ -dp[ny][nx], ny, nx });
			}
		}
		REP(i, 5) {
			REP(j, 5) {
				lint ny = curr.y - 2 + i, nx = curr.x - 2 + j;
				if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
				if (mp[ny][nx] == '#') continue;
				if (dp[ny][nx] > dp[curr.y][curr.x] + 1) {
					dp[ny][nx] = dp[curr.y][curr.x] + 1;
					que.push({ -dp[ny][nx], ny, nx });
				}
			}
		}
	}

	if (dp[gy][gx] == INF) cout << -1 << endk;
	else cout << dp[gy][gx] << endk;
}


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

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

    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] == 'L'
            ||  i % 2 == 1 && s[i] == 'R') {
            cout << "No" << endl;
            exit(0);
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main () {
var n int
n = 0
fmt.Scan(&n)
stu := make([]int, n)
i := 0
for i < n {
  stu[i] = i+1
  i++
}
line := make([]int, n)
var tmp int
j := 0
for j < n {
  fmt.Scan(&tmp)
  line[tmp-1] = stu[j]
  j++
}
i = 0
for i < n {
  fmt.Printf("%d ", line[i])
  i++
}
}

Measured memory_bytes: 6016
package main

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

type Set struct {
	before int
	after  int
}

func main() {
	var n int
	s := wordScanner()
	scanInts(s, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanInts(s, &a[i])
	}

	var bmax, amax int
	l := make([]Set, n+2)
	for i, m := range a {
		if m > bmax {
			bmax = m
		}
		if a[n-i-1] > amax {
			amax = a[n-i-1]
		}
		l[i+1].before = bmax
		l[n-i].after = amax
	}

	for i := range a {
		fmt.Println(max(l[i].before, l[i+2].after))
	}
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 8576
N, T = map(int,input().split())
price = list(map(int,input().split()))
benefit = [0] * N
ans = 1
pr_low = float("inf")
be_max = 0
for i in range(N):
    if pr_low > price[i]:
        pr_low = price[i]
    else:
        benefit[i] = price[i] - pr_low
        if be_max < benefit[i]:
            be_max = benefit[i]
            ans = 1
        elif be_max == benefit[i]:
            ans += 1
print(ans)

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

int main(){
    long long N, sum{};
    cin >> N;
    for(long long i = 1; N/i-1>sqrt(N); i++){
        if(N % i == 0){
            sum += N / i - 1;
        }
    }
    cout << sum << endl;
}

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

 {
   char s1[10000]={};
   char s2[10000]={};
   cin>>s1;
   cin>>s2;
   int n=strlen(s1),cnt=0;
   int k=strlen(s2);
        for(int i=0;i<n;i++)
            if(s1[i]!=s2[i])
        {
            cnt=1;
            break;
        }

  if(cnt==1) puts("No");
  else puts("Yes");

}


Measured memory_bytes: 3616
#include <stdio.h>

void Do(int N, int M){
  int i, L, R, l, r;
  l = 1;
  r = N;
  for(i = 0;i < M;i++){
    scanf("%d %d", &L, &R);
    if(L > l) l = L;
    if(R < r) r = R;
  }
  if(r >= l) printf("%d\n", r - l + 1);
  else printf("0\n");
}

int main(void){
  int N, M;
  scanf("%d %d", &N, &M);
  Do(N, M);
  return 0;
}
    


Measured memory_bytes: 128
d=int(input())
c=[int(i) for i in input().split()]
s=[]
for i in range(d):
  s.append([int(i) for i in input().split()])
#print(d, c, s)

#Score
Score=[0]*d
last=[0]*26
d_last=[0]*26
t=[]
#d=1
score0=max(s[0])
Score[0]=score0
last[s[0].index(score0)]=1
t.append(s[0].index(score0)+1)
#d>=2
for j in range(1,d):
  d_last=[(j+1)-i if i>0 else 0 for i in last]
  cd=[c*dd for (c,dd) in zip(c,d_last)]
#  print("cd: {}".format(cd))
  score1=[s-c for (s,c) in zip(s[j],cd)]
  Score[j]=max(score1)
  last[score1.index(max(score1))]=j+1
  t.append(score1.index(max(score1))+1)

for l in t:
  print(l)

Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
		int a[1010][1010]={0};
		queue<int> qx,qy;
int main()
	{
		ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
		int h,w;
		cin>>h>>w;
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++){
					char f;
					cin>>f;
					if(f=='#'){
						a[i][j]=1;
						qx.push(i);
						qy.push(j);
					}
				}
		int ans;
		while(qx.size()){
						if(qx.front()-1>0&&a[qx.front()-1][qy.front()]==0){
							a[qx.front()-1][qy.front()]=a[qx.front()][qy.front()]+1;
							qx.push(qx.front()-1);
							qy.push(qy.front());
						}
						if(qx.front()+1<=h&&a[qx.front()+1][qy.front()]==0){
							a[qx.front()+1][qy.front()]=a[qx.front()][qy.front()]+1;
							qx.push(qx.front()+1);
							qy.push(qy.front());
						}
						if(qy.front()-1>0&&a[qx.front()][qy.front()-1]==0){
							a[qx.front()][qy.front()-1]=a[qx.front()][qy.front()]+1;
							qx.push(qx.front());
							qy.push(qy.front()-1);
						}
						if(qy.front()+1<=w&&a[qx.front()][qy.front()+1]==0){
							a[qx.front()][qy.front()+1]=a[qx.front()][qy.front()]+1;
							qx.push(qx.front());
							qy.push(qy.front()+1);
						}
			ans=a[qx.front()][qy.front()];
			qx.pop();
			qy.pop();
		}
		cout<<ans-1;
		return 0;
	 }

Measured memory_bytes: 12416
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int S;
    cin >> S;

    if(S == 0) {
        cout << "0:0:0\n";
        return 0;
    }

    if(S < 60) {
        cout << "0:0:" << S << "\n";
        return 0;
    }

    int h = S / 3600;
    int minutes = S - h * 3600;
    int m = minutes / 60;
    int s = ( minutes - ( m * 60 ) ) % 60;

    cout << h << ":" << m << ":" << s << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  string s;
  ll k;
  cin >> s >> k;
  k--;
  int point = 0;
  REP(i,s.size()){
    if(s[i] != '1'){
      point = i;
      break;
    }
  }
  if(k < point){
    cout << 1 << endl;
  }else{
    cout << s[point] << endl;
  }



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <complex>
#include <iomanip>
#include <cassert>
 
using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, a, b;
  cin >> n >> a >> b;
  if (abs(a - b) % 2 == 0) {
    cout << "Alice\n";
  } else {
    cout << "Borys\n";
  }
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
    lld x,y;
    cin >> x >> y;

    lld sol = 1;

    while(x <= y)
    {
        x *= 2;
        if (x <= y)
        {
            sol++;
        }else
        {
            break;
        }
    }

    cout << sol << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int MIN(int a,int b){
    return a<b?a:b;
}
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n,b[200001]={0},i,w[200001]={0};
    scanf("%d",&n);
    
    char s[n+1];
    int chk=0;
    scanf("%s",s);
    for(i=0;i<n;i++){
        if(s[i]=='.'){
            chk++;
        }
    }
    if(chk==0||chk==n){
        printf("0");
        return 0;
    }
    if(s[0]=='#'){
        w[0]=chk;
        b[0]=1;
    }else{
        w[0]=chk-1;
    }
    for(i=1;i<n;i++){
        if(s[i]=='#'){
            b[i]=b[i-1]+1;
            w[i]=w[i-1];
        }else{
            b[i]=b[i-1];
            w[i]=w[i-1]-1;
        }
    }
    int x=11451419;
    int ans[200001]={0};
    for(i=0;i<n;i++){
        if(b[i]==i+1&&w[i]==n-(i+1)){
          x=chk;  
        }
        ans[i]=b[i]+w[i];
    }
    qsort(ans,n,sizeof(int),compare);
    printf("%d",MIN(ans[0],x));
    return 0;
}




Measured memory_bytes: 3452
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,m; cin >> n >> m;
    pair<int, int> p[m+1];
    for (int i=0; i<m; i++) cin >> p[i].second >> p[i].first;
    sort(p, p+m);
    int ans=0, t=0;
    for (int i=0; i<m; i++){
        if (p[i].second>=t) t=p[i].first, ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars
    };

    if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] {
        println!("Bad")
    } else {
        println!("Good")
    }
}


Measured memory_bytes: 2140
#include<stdio.h>

int count;

void binarysearch(int S[], int n, int key){
  int top = 0, tail = n, a;
  while(top != tail){
    a = (top + tail)/2;
    if (S[a] == key){
      count++;
      break;
    } else if(S[a] < key) top = a + 1;
    else tail = a;
  }
}

int main(void){
  int i, n, q, b, S[100000];
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &b);
    binarysearch(S, n, b);
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 2172
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
  var nab = lines[0].split(' ');
  var n = Number(nab[0]);
  var a = Number(nab[1]);
  var b = Number(nab[2]);
  var pass = 0;
  var ab = 1;

  var info = lines[1].split('');
  for(i=0; i<n; i++){
    switch(info[i]){
      case 'a':
        if(pass < a+b){
          console.log("Yes");
          pass++;
          break;
        }else{
          console.log("No")
          break;;
        }
      case 'b':
        if(pass < a+b && b >= ab){
          console.log("Yes");
          pass++;
          ab++;
          break;
        }else{
          console.log("No");
          break;
        }
      case 'c':
        console.log("No");
        break;
    }
  }
});

Measured memory_bytes: 18384
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;
vector< int > A;

bool solve(int now,int sum){
    if(!sum) return true;
    else if(now == A.size() || sum < 0) return false;
    return solve( now + 1, sum - A[now]) || solve( now + 1, sum);
}

int main() {
    int num1, num2, test;
    cin >> num1;
    A.resize(num1);
    for (int i = 0; i < num1; i++) {
        cin >> A[i];
    }
    cin >> num2;
    for (int i = 0; i < num2; i++) {
        cin >> test;
        if (solve(0, test) == 1) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    cout << max(C - (A - B),0) << endl;

    return 0;
}


Measured memory_bytes: 256