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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

int main() {
    ll k;
    cin >> k;

    ll sum = 0;
    for (ll a = 1; a <= k; a++) {
        for (ll b = 1; b <= k; b++) {
            for (ll c = 1; c <= k; c++) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
}


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

using namespace std;

const int mx = 1e5 + 5;

vector<int> v[mx];
vector<bool> vis(mx,false);

//vector<int> indegree[mx]={0};

int dist[mx]={0};

void dfs(int a)
{
	vis[a]=true;

	for(int i: v[a])
	{
		if(!vis[i])
			dfs(i);

		dist[a]=max(dist[a],dist[i]+1);
	}
}
int main()
{	
	int n,m;
	cin>>n>>m;

	int x,y;

	while(m--)
	{
		cin>>x>>y;
		v[x].push_back(y);
		//indegree[b]++;	
	}

	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			dfs(i);
	}
	int res=0;

	for(int i=1;i<=n;i++)
	{
		res=max(res,dist[i]);
	}

	cout<<res<<'\n';
	return 0;	
}

Measured memory_bytes: 8192
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,k;
    cin >> n >> k;
    vl r;
    vl l;
    ll temp;
    F0R(i,n){
      cin >> temp;
      if(temp < 0){
        temp *= (-1);
        l.pb(temp);
      }
      else r.pb(temp);
    }
    if(l.size() > 0)
      sort(l.begin(),l.end());
    ll ans = INF;
    ll tempAns;
    F0R(i,k+1){
      if(i-1 < l.size() && k-i-1 < r.size()){
        ll leftB = 0;
        ll rightB = 0;
        if(i > 0) leftB = l[i-1];
        if(i < k) rightB = r[k-i-1];
        ll tempAns = leftB + rightB + min(leftB,rightB);
        ans = min(tempAns,ans);
      }
    }
    if(l.size() >= k)
      ans = min(ans,l[k-1]);
    if(r.size() >= k)
      ans = min(ans,r[k-1]);
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 1656
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,pair<int,int> >  p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};


int main(){
    int R,G,B,N;
    ll count=0;
    cin>>R>>G>>B>>N;
    for(int i=0;R*i<=N;i++){
        for(int j=0;j*G+R*i<=N;j++){
            int n=j*G+R*i;
            if( (N-n)%B==0  ) count++;
        }
    }
    cout<<count<<endl;
}



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

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strArray[] = str.split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);

		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			 System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 24388
def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table

n = int(input())
a = num_divisors_table(n-1)

ans = 0
for i in a:
    #print(i)
    ans += i

print(ans)

Measured memory_bytes: 74852
n,k=list(map(int,input().split()))
alst=list(map(lambda x:int(x)*100,input().split()))

ok=max(alst)
ng=0

while abs(ok-ng)>1:
    cen=(ok+ng)//2

    cnt=0

    for a in alst:
        cnt+=(a+cen-1)//cen-1

    if cnt<=k:
        ok=cen
    else:
        ng=cen+1

if ok%100==0:
    print(ok//100)
else:
    print(ok//100+1)

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

int main() {
  int N;
  cin >> N;
  if (N > 81)
    cout << "No" << endl;
  else {
    int count = 0;
    for (int i = 1; i < 10; i++) {
      if (N%i == 0 && N/i <10)
        count++;
    }
    if (count == 0)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
    
}


Measured memory_bytes: 3612
import sys 
input = sys.stdin.readline
a, b = map(int, input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A = set(prime_factorize(a))
B = set(prime_factorize(b))
ans = A&B
print(len(ans)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef unsigned long long ULL;
const ULL M=1e18;
int main(){
ULL N, ans=1; cin >> N; ULL A[N];
REP(i, N){ cin >> A[i]; if(A[i]==0){ cout << "0\n"; return 0; } }
REP(i, N){ 
  if(A[i]<=M/ans){ ans=ans*A[i]; }
  else{ cout << "-1\n"; return 0; }
}
cout << ans << "\n";
}

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

int main()
{
    ll N, K;
    string S;

    cin >> N >> K >> S;

    vector<ll> one;
    vector<ll> zero;

    char pre = S.at(0);
    ll cnt = 0;
    bool z = false;
    if (pre == '0')
    {
        z = true;
        one.push_back(0);
    }

    for (ll i = 0; i < N; i++)
    {
        if (pre == S.at(i))
        {
            cnt++;
        }
        else
        {
            if (z)
            {

                zero.push_back(cnt);
            }
            else
            {
                one.push_back(cnt);
            }
            pre = S.at(i);
            cnt = 1;
            z = !z;
        }
    }
    if (cnt > 0)
    {
        if (z)
            zero.push_back(cnt);
        else
            one.push_back(cnt);
    }

    ll oSize = one.size();
    ll zSize = zero.size();

    ll max = 1;
    for (ll i = 0; i < zSize; i++)
    {
        ll tmp = 0;
        ll tmp2 = 0;
        for (ll k = 0; k < K; k++)
        {
            if (i + k < zSize)
            {
                tmp += zero[i + k];
            }
            if (k == 0 && i + k < oSize)
            {
                tmp2 += one[i + k];
            }

            if (i + k + 1 < oSize)
            {
                tmp2 += one[i + k + 1];
            }
        }
        if (max < (tmp + tmp2))
        {
            max = tmp + tmp2;
        }
    }

    if (zSize == 0 && oSize > 0)
    {
        max = N;
    }
    cout << max << endl;
}

Measured memory_bytes: 1404
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int d, n;
    cin >> d >> n;
    if (d == 0) {
        if (n == 100) {
            cout << 101 << endl;
        }
        else {
            cout << n << endl;
        }
    }
    else if (d == 1) {
        if (n == 100) {
            cout << 10100 << endl;
        }
        else {
            cout << n << "00" << endl;
        }
    }
    else {
        if (n == 100) {
            cout << 1010000 << endl;
        }
        else {
            cout << n << "0000" << endl;
        }
    }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

set<ll> st;

vector<ll> vv;
vector<ll> sum;
vector<ll> ans;

void solve(){
	ll v = 0;
	ll st10 = 1;
	for(int c = 0; c <= 13; c++){
		REPN(i, 1, 999){
			st.insert(i * st10 + v);
		}
		st10 *= 10;
		if (v == 0){
			v = 9;
		} else {
			v = v * 10 + 9;
		}
	}
	/*FA(it, st){
		printf("%lld\n", *it);
	}
	return;*/
	FA(it, st){
		vv.pb(*it);
	}
	REP(i, 0, SZ(vv)){
		ll a = 0;
		for(ll t = vv[i]; t; t /= 10){
			a += t % 10;
		}
		sum.pb(a);
	}
	REP(i, 0, SZ(vv)){
		int fl = 1;
		REP(j, i + 1, SZ(vv)){
			if (vv[i] * sum[j] > vv[j] * sum[i]){
				fl = 0;
				break;
			}
		}
		if (fl){
			ans.pb(vv[i]);
		}
	}
	
	int k;
	scanf("%d", &k);
	REP(i, 0, k){
		printf("%lld\n", ans[i]);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1152
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		String T = next();

		int cnt = 0;
		for(int i=0;i<3;i++) {
			if(S.substring(i,i+1).equals(T.substring(i,i+1))) {
				cnt++;
			}
		}
		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21844
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))

ans = 0
for i in range(1, N - 1):
    for j in range(i + 1, N + 1):
        ans += N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j)
print(ans)


Measured memory_bytes: 43244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <string>
#include <iterator>

#define ll long long

using namespace std;

//signed main()
int main()
{
    ll D, N;
    cin >> D >> N;
/*
 * 1,2,3,...,99,101,102,...,199,201,...
 */
    if (100 == N) N = 101;
    ll rt = pow(100, D) * N;
    printf("%lld\n", rt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

string s;int k;
priority_queue<string, vector<string>, greater<string>> que;
signed main(){
  cin>>s>>k;set<string> st;
  rep(i,s.length()){
    string t;
    rep(j,5){
      if(i+j >= s.length())break;
      t += s[i+j];
      if(st.find(t) == st.end()){
        que.push(t);st.insert(t);
      }
    }
  }
  rep(i,k-1){
    que.pop();
  }
  cout << que.top() << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n,T,a[200001];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&T);
		a[T]++;if(T)a[T-1]++;a[T+1]++;
	}
	int ma=0;
	for(int i=0;i<=100000;i++)
		ma=max(ma,a[i]);
	printf("%d\n",ma);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  long long n,i,j,l,r=0,c[4]={};
  char s[100010];
  scanf("%s %lld",s,&n);
  for(l=0;s[l];l++);
  if(n>4){
    for(i=0;i<l;i++)s[l*3+i]=s[l*2+i]=s[l*1+i]=s[i];
    s[l*4]=0;
    for(i=1;s[i];i++){
      if(s[i]==s[i-1]){
	c[i/l]++;
	i++;
      }
    }
    if(n%2)printf("%lld\n",c[0]+(c[1]+c[2])*(n/2));
    else   printf("%lld\n",c[0]+(c[1]+c[2])*(n/2-1)+c[3]);
    return 0;
  }
  for(i=r=0;i<n;i++){
    for(j=0;j<l;j++)s[r++]=s[j];
  }
  s[r]=0;//printf("%s\n",s);
  for(i=1;i<r;i++){
    if(s[i-1]==s[i]){
      c[0]++;
      i++;
    }
  }
  printf("%lld\n",c[0]);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
using namespace std;
const long long M=1000000007;
int n,h,d,i,j;
long long f[1000005],s[1000005],ans;
int main()
{
	cin>>n>>h>>d;
	f[0]=1;
	for(i=1;i<=n;i++)
	{
		f[0]=f[0]*i%M;
		ans=(ans+f[0])%M;
	}
	s[0]=f[0];
	for(i=1;i<h;i++)
	{
		if(i<=d)
			f[i]=s[i-1]*ans%M;
		else
			f[i]=(s[i-1]-s[i-d-1])*ans%M;
		s[i]=(s[i-1]+f[i])%M;
	}
	cout<<((s[h-1]-s[h-1-d])%M+M)%M<<endl;
}


Measured memory_bytes: 15872
#include <iostream>

using namespace std;



int main() {
    string str;
    cin >> str;
    long len = str.size();
    if(str[0] != 65) {
        cout << "WA" << endl;
        return 0;
    }
    bool isPassed = false;
    for (int i = 2; i <= (len - 2); ++i) {
        if(str[i] == 67){
            isPassed = true;
        }
    }
    if(!isPassed){
        cout << "WA" << endl;
        return 0;
    }


    int smallChar = 0;
    for (int i = 0; i <= (len); ++i) {
        if(str[i] >= 97){
            smallChar++;
        }
    }
    if(smallChar == (len - 2)){
        cout << "AC" << endl;
        return 0;
    }else{
        cout << "WA" << endl;
        return 0;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N;
    int ans=0;
    cin>>N;
    rep1(i,9){
        rep1(j,9)
    if(N==i*j){
        Out("Yes");
        return 0;
    }
    }
    Out("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int h, w, n;
string data[1100];
int main() {
  while (cin >> h >> w >> n) {
    rep(i, h) cin >> data[i];
    pair<int, int> ce[10];
    rep(i, h) rep(j, w) {
      if (data[i][j] == 'S') {
        ce[0] = pair<int, int>(i, j);
      }
      if (isdigit(data[i][j])) {
        ce[data[i][j] - '0'] = pair<int, int>(i, j);
      }
    }
    int sum = 0;
    rep(i, n) {
      int mp[1100][1100];
      rep(i, 1100) rep(j, 1100) mp[i][j] = INF;
      bool used[1100][1100] = {};

      mp[ce[i].first][ce[i].second] = 0;
      used[ce[i].first][ce[i].second] = true;
      queue<pair<int, int>> que;
      que.push(ce[i]);
      while (que.size()) {
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        int dx[] = {0, 1, 0, -1};
        int dy[] = {1, 0, -1, 0};
        rep(i, 4) {
          int ddy = y + dy[i];
          int ddx = x + dx[i];
          if (ddy >= 0 && ddy < h && ddx >= 0 && ddx < w &&
              data[ddy][ddx] != 'X' && !used[ddy][ddx]) {
            used[ddy][ddx] = true;
            mp[ddy][ddx] = mp[y][x] + 1;
            que.push(pair<int, int>(ddy, ddx));
          }
        }
      }
      sum += mp[ce[i + 1].first][ce[i + 1].second];
    }
    cout << sum << endl;
  }

  return 0;
}

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

int main(){
  char input[10];
  char a[4];
  int b;
  int c;
  int i;
  int min;

  scanf("%s",&input);

  min=999;
  for(i=0;1<10;i++){
    a[0]=input[i];
    a[1]=input[i+1];
    a[2]=input[i+2];
    a[3]='\0';

    b=atoi(a);
    c=abs(753-b);

    if( c < min )
      min=c;

    if(input[i+3]=='\0')
      break;

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

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ATCodertest
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string[] b=a.Split(' ');
            int c=int.Parse(b[0]);
            int d=int.Parse(b[1]);
            int e=int.Parse(b[2]);
            if (c+d==e) Console.WriteLine("Yes");
            else if(c+e==d) Console.WriteLine("Yes");
            else if(d+e==c) Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }

    }
}

Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair< P , int > PP;

int res[1000005];
PP tmp[1000005];
int ans[1000005];

void suffixArray(char* s){
  
  int len=strlen(s);
  
  for(int i=0;i<=len;i++)res[i]=s[i];
  
  for(int k=1;k<=len;k*=2){
    
    for(int i=0;i<=len;i++){
      tmp[i].first.first=res[i];
      tmp[i].first.second=(i+k<=len?res[i+k]:0);
      tmp[i].second=i;
    }
    sort(tmp,tmp+len+1);
    
    int C=0;
    for(int i=0;i<=len;i++){
      int id=tmp[i].second;
      if(i&& (tmp[i-1].first<tmp[i].first))C++;
      res[id]=C;
    }
  }

  for(int i=0;i<=len;i++)ans[ res[i] ]=i;
}

char s[1000005];
char t[1000005];
int main(){
  scanf("%s",s);
  int lenS=strlen(s);
  
  suffixArray(s);

  int Q;
  scanf("%d",&Q);
  
  while(Q--){
    scanf("%s",t);
    int len=strlen(t);
    int l=0,r=lenS+1,m;
    while(r-l>1){
      m=(l+r)/2;
      if( strncmp( s+ans[m] , t ,len ) <=0 )l=m;
      else r=m;
    }
    if(strncmp(s+ans[l],t,len)==0)printf("1\n");
    else printf("0\n");
  }
  
  /*
  for(int i=0;i<(int)ans.size();i++){
    printf("%d %s\n",ans[i], (s+ans[i]) );
  }
  */
  
  return 0;
}

Measured memory_bytes: 21708
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    
    ll h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll a = h1 * 60 + m1;
    ll b = h2 * 60 + m2;
    cout << b - a + 1 - k + 1 - 2 << endl;

    return 0;
}

/*

*/

Measured memory_bytes: 3580
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 4000 + 15;
const ll MOD = 1e9 + 7;
int C = 700;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd;

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) (_v * _v)
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    ll h, a;
    cin >> h >> a;
    ll ans = h / a;
    if (h % a) {ans++;}
    cout << ans;
}

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

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> l(k,0),r(k,0),dp(n+1,0),lazy(n+1,0);
    rep(i,k) cin>>l[i]>>r[i];
    dp[0]=1;
    rep(i,n+1){
        if(i>0) lazy[i]=(lazy[i]+lazy[i-1])%mod;
        dp[i]=(dp[i]+lazy[i])%mod;
        rep(j,k){
            if(i+l[j]<=n) lazy[i+l[j]]=(lazy[i+l[j]]+dp[i])%mod;
            if(i+r[j]+1<=n) lazy[i+r[j]+1]=(mod+lazy[i+r[j]+1]-dp[i])%mod;
        }
    }
    cout<<(dp[n-1]+mod)%mod<<endl;
    //cout<<dp<<endl;
}

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

public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		String s = in.next();
		if(isPalindrome(s) && isPalindrome(s.substring(0, (s.length() - 1) / 2)) && isPalindrome(s.substring((s.length() + 3) / 2 - 1)))
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
	
	public static boolean isPalindrome(String s)
	{
		for(int i = 0; i < s.length(); ++i)
		{
			if(s.charAt(i) != s.charAt(s.length() - 1 - i))
			{
				return false;
			}
		}
		return true;
	}
}


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

ships = []
N, M = [int(x) for x in input().split()]
for i in range(M):
    ships.append([int(x) for x in input().split()])

from_1 = set([ship[1] for ship in ships if ship[0] == 1])
to_N = set([ship[0] for ship in ships if ship[1] == N])

if from_1.intersection(to_N):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

/*** Template Begins ***/

typedef long long    ll;
typedef pair<ll,ll>  PII;
typedef pair<ll, pair<int, int> > PIII;
typedef long double  ld;
typedef vector<int>  vi;

#define endl         '\n'
#define pb           push_back
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 

// Constants //

const int N = 1e5+7;

/*** Template Ends ***/

string s;

void solve(){
	
	cin >> s;
	int n = s.size(), mn = INT_MAX;
	for(int i = 0; i < n-2; i++){

		int x = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
		//cout << x << endl;
		mn = min(abs(753-x), mn);
	}
	cout << mn << endl;

}

int main(){
	
	ios;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF LLONG_MAX/1000

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

static const int MAX = 1100;

int d[MAX];
WeightGraph WG(MAX);

// true if negative loop, false if no negative loop
bool bellman_ford(const WeightGraph& WG, int (&d)[MAX], const int &n, const int& s) {
  // initialize to INF except the starting node
  for (int i = 0; i < n; i++) {
    d[i] = INF;
  }
  d[s] = 0;

  int ans;

  for (int i = 0; i < 2*n; i++) {
    if (i == n - 1) ans = d[n - 1];
    // cout << "i is: " << i << endl;
    for (int v = 0; v < n; v++) {
      // cout << "v is :" << v << endl;
      // cout << d[0] << " "<< d[1] << endl;
      for (auto adjacent : WG[v]) {
        int nv = adjacent.first;
        int nd = adjacent.second;
        if (d[v] != INF && d[nv] > d[v] + nd) {
          if (i == n-1) {
            d[nv] = d[v] + nd;
            d[nv] -= INF;
          } else {
            d[nv] = d[v] + nd;
          }
        }
      }
    }
  }
  // return false;
  // cout << ans << " " << d[n-1] << endl;
  return ans == d[n-1];
}

signed main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--; c = -1 * c;
    WG[a].push_back(Pi(b, c));
  }
  if (bellman_ford(WG, d, N, 0)) {
    cout << -1 * d[N-1] << endl;
  } else {
    cout << "inf" << endl;
  }
}



Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int N;
    int *ip; //A_i
    int *count;
    int i;
    int j;
    //N入力
    while(scanf("%d",&N)!=1);
    //メモリの確保
    ip =(int *)malloc((N-1)*sizeof(int)); //A_i
    count =(int *)malloc((N)*sizeof(int)); //出力
    //A_i 入力
    for (i=0;i<N-1;i++){
        while(scanf("%d",&ip[i])!=1);
    }
    //出力結果初期化
    for(i=0;i<N;i++){
        count[i]=0;
    }
    //計算処理
    for(i=0;i<N-1;i++){
        count[ip[i]-1]+=1;
    }
    //最終出力 
    for(i=0;i<N;i++){
        printf("%d\n",count[i]);
    }
    free(ip);
    free(count);
    return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define PI 3.14159265358979323846264338327950L
#define e18 1000000000000000000

using namespace std;

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

long long myGcd(long long a, long long b);
int myGcd(int a, int b);
long long myLcm(long long a, long long b);
int myLcm(int a, int b);
long long checkDigit(long long num);
int checkDigit(int num);

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

	int X, Y;
	bool f = false;

	cin >> X >> Y;

	REP(i, X + 1)
	{
		int ans = 2 * (X - i) + 4 * i;
		if (ans == Y)
			f = true;
	}

	if (f)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

long long myGcd(long long a, long long b)
{
	if (a % b == 0)
		return b;
	return myGcd(b, a % b);
}

int myGcd(int a, int b)
{
	if (a % b == 0)
		return b;
	return myGcd(b, a % b);
}

long long myLcm(long long a, long long b)
{
	return a * b / myGcd(a, b);
}

int myLcm(int a, int b)
{
	return a * b / myGcd(a, b);
}

long long checkDigit(long long num)
{
	string st = to_string(num);
	return st.size() - 1;
}

int checkDigit(int num)
{
	string st = to_string(num);
	return st.size() - 1;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))



using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

ll F(ll a, ll b) {
	ll c1=0, c2=0;
	while (a > 0) {
		a /= 10;
		c1++;
	}
	while (b > 0) {
		b /= 10;
		c2++;
	}
	return max(c1, c2);
}

ll A[100010];
int main() {
	int N; cin >> N;
	int K; cin >> K;
	ll M = 0;
	REP(i, N)cin >> A[i],M=max(M,A[i]);
	ll g = A[0];
	REP(i, N - 1) {
		g = gcd(g, A[i+1]);
	}
	if (M >= K && K%g == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}




Measured memory_bytes: 1024
#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, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S[K - 1] -= 'A' - 'a';
  cout << S << endl;
}

Measured memory_bytes: 3592
/*
	Created on 29-09-20 13:17

	@author: roastedcoder
*/

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const int MAX = 1e6 + 5;
const int N = 1e5 + 5;
//const int MAXX = 1e14;

//#define ll long long
#define int long long
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pb push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________

vector <int> graph[MAX];
bool vis[MAX];

void dfs(int node) {
	vis[node] = true;
	for(auto child : graph[node])
		if(!vis[child])
			dfs(child);
}

int32_t main() {
	roastedcoder
	int n, m; cin>>n>>m;
	while(m--) {
		int a, b; cin>>a>>b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	int res = 0;
	for(int i = 1; i<=n; i++) {
		if(!vis[i]) {
			dfs(i);
			res += 1;
		}
	}
	// res = number of connected component so number of roads will be res-1
	cout<<res-1<<endl;
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/
/*
MY NOTES:
  int for long long
  Don't make Segment Tree and Fenwick Tree 0-based you FOOL.
  Always try to exhaust the time being provided and PACE yourself.
*/

Measured memory_bytes: 31492
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
using namespace std;
string s[10];
int x, y, d = 1;
bool fU() {
	if (y == 0)return 0;
	else return s[y * 2 - 1][x] == '1';
}
void mU() { cout << "U"; y--; return; }
bool fD() {
	if (y == 4)return 0;
	else return s[y * 2 + 1][x] == '1';
}
void mD() { cout << "D"; y++; return; }
bool fL() {
	if (x == 0)return 0;
	else return s[y * 2][x - 1] == '1';
}
void mL() { cout << "L"; x--; return; }
bool fR() {
	if (x == 4)return 0;
	else return s[y * 2][x] == '1';
}
void mR() { cout << "R"; x++; return; }
signed main() {
	for0(i, 9)cin >> s[i];
	mR();
	while (x + y > 0) {
		for0(i, 4) {
			if ((i + 3 + d) % 4 == 0) {
				if (fU()) { mU(); d = 0; break; }
			}
			else if ((i + 3 + d) % 4 == 1) {
				if (fR()) { mR(); d = 1; break; }
			}
			else if ((i + 3 + d) % 4 == 2) {
				if (fD()) { mD(); d = 2; break; }
			}
			else if ((i + 3 + d) % 4 == 3) {
				if (fL()) { mL(); d = 3; break; }
			}
		}
	}
	printf("\n");
}


Measured memory_bytes: 3144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();
		int n;
		if (a - b > 0) {
			n = b;
		} else {
			n = a;
		}
		for (int i = n; 0 < i; i--) {
			if (a % i == 0 && b % i == 0) {
				k--;
				if (k == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scn.close();
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderByDescending(x => x).Take(l[1]).Sum());
    }
}


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

int main() {
	int n, m, X, Y; cin >> n >> m >> X >> Y;
	int max_x = (int) -1e9;
	int min_y = (int) 1e9;
	for (int i = 0; i < n; i++) {
	    int x; cin >> x; 
	    max_x = max(x, max_x);
	}
	for (int i = 0; i < n; i++) {
	    int y; cin >> y; 
	    min_y = min(y, min_y);
	}
	int y = 0;
	if (X < Y) {
	    for (int z = X + 1; z <= Y; z++)
	        y |= (z <= min_y && z > max_x); 
	}
	if (y) cout << "No War\n";
	else cout << "War\n";
 	return 0;
}

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

if n == 0:
    if A[0] == 1:
        print(1)
        exit()
    else: 
        print(-1)
        exit()

l = [1]
pre = 1
for i in range(n):
    if A[i] == 0:
        pre *= 2
        l.append(pre)
    else:
        pre = (l[i]-A[i])*2
        if pre <= 0:
            print(-1)
            exit()
        l.append(pre)

if A[-1] > l[-1]:
    print(-1)
    exit()
else:
    tmp = A[-1]
    ans = tmp

for i in range(2,n+2):
    if A[-i] != 0:
        tmp = min(A[-i]+tmp,l[-i])
        ans += tmp
    else:
        tmp = min(tmp,l[-i])
        ans += tmp
print(ans)

Measured memory_bytes: 674396
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i*4<=n;i++){
    if((n-i*4)%7==0){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
typedef long long LL;
struct node
{
	int to;
	node *nxt;
}edges[MAXN+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
int a[MAXN+5],N,dep[MAXN+5],dep2[MAXN+5],K,maxdep[MAXN+5];
LL ans=0;
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=Adj[u];
	Adj[u]=p;
}
void DFS(int u)
{
	dep[u]=1;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		DFS(v);
		dep[u]=max(dep[u],dep[v]+1);
	}
	if(dep[u]==K&&a[u]!=1)
	{
		ans++;
		dep[u]=0;
	}
}
int main()
{
	scanf("%d %d",&N,&K);
	for(int i=1;i<=N;i++)
		scanf("%d",&a[i]);
	if(a[1]!=1)
		a[1]=1,ans+=1LL;
	for(int i=2;i<=N;i++)
		AddEdge(a[i],i);
	DFS(1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;



int main(){
ll N, Ans = 0;cin >> N;
queue<ll> Q;

rep(i, 1, 10)Q.push(i);

rep(i, 0, N){

    ll q = Q.front(), a = 10*q + q%10;
    
    if(q%10 != 0)Q.push(a - 1);
    
    Q.push(a);
    
    if(q%10 != 9)Q.push(a + 1);
    
    if(i == N -1)cout << Q.front();
    
    else Q.pop();}
    
}

Measured memory_bytes: 5144
def answer():
    N = int(input()) # 人数
    l = []
    for _ in range(5):
        l.append(int(input())) # 都市間の移動時間

    time = 0
    time += (N-1) // min(l) +5
    return time

def main():
    print(answer())

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> par;
 
	//作るときはparの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N){
		par = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int find(int A){
		if(par[A] < 0) return A;
		return par[A] = find(par[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A){
		return -par[find(A)];//親をとってきたい
	}
 
	//AとBをくっ付ける
	bool unite(int A, int B){
		//AとBを直接つなぐのではなく、find(A)にfind(B)をくっつける
		A = find(A);
		B = find(B);
		if(A == B){
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう
		if(size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		par[A] += par[B];
		//Bの親をAに変更する
		par[B] = A;
 
		return true;
	}

    bool is_same(int A, int B){
        return find(A) == find(B);
    }
};

int main(){
    int n,m; cin >> n >> m;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i]; p[i]--;
    }

    UnionFind uni(n);
    rep(i,m){
        int x,y; cin >> x >> y; x--; y--;
        uni.unite(x, y);
    }
    int ans = 0;
    rep(i,n){
        if(uni.is_same(i,p[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	ll temp = min(B - 1, C);	
	ll ans = ((A * temp) / B) - A * (temp / B);
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main() {
	int a,b,k;cin>>a>>b>>k;
  	int cnt=0;
  	vector<int> t;
  	for(int i=1;i<=100;i++){
    	if(a%i==0 && b%i==0){
          	t.push_back(i);
        	cnt++;
        }
    }
  	cout<<t[cnt-k]<<endl;
}


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

int main() {
    uint64_t N, M;
    std::cin >> N >> M;

    uint64_t ans = 0;
    if (M < (2 * N)) {
        ans = M / 2;
    } else {
        ans = N + (M - 2 * N) / 4; 
    }

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

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

//A-Z = 65 - 90
//a-z = 97 - 122

using namespace std;

int main(void) {
    string str;
    
    getline(cin, str);
    
    for(char i:str) {
        if( islower(i) ) cout << (char)toupper(i);
        else if( isupper(i) ) cout << (char)tolower(i);
        else cout << i;
    }
    cout << endl;
    
    return 0;
    
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[101],t[101];
    scanf("%s %s",s,t);
    int l= strlen(s);
    if(strcmp(s,t)==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }



        char temp[l+1];
        temp[l]='\0';
        //char last=s[l-1];
        for(int i=0;i<l;i++)
        {
             int j = i;
             int k = 0;
        while (j<l)
        {
            temp[k] = s[j];
            k++;
            j++;
        }


        j = 0;
        while (j < i)
        {
            temp[k] = s[j];
            j++;
            k++;
        }
        //printf("%s\n",temp);
        if(strcmp(temp,t)==0)
            {cout<<"Yes";
                return 0;

            }
        }
        cout<<"No";
        return 0;






}


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

int main()
{
	int n;
	cin>>n;
	if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)
		cout<<"hon"<<endl;
	if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
		cout<<"pon"<<endl;
	if(n%10==3)
		cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    char c;
    int alpha[26] = {};
    while (cin >> c) {
        if (isalpha(c)) {
            c = tolower(c);
            alpha[c - 'a']++;
        }
    }

    for (int i = 0; i < 26; i++) {
        // cout << i + 'a' << " : " << alpha[i] << endl;
        printf("%c : %d\n", i + 'a', alpha[i]);
    }
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main() {
  int N;
  cin >>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  bool hantei=true;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==1){
    }else{
      if(A.at(i)%3==0){
      }else if(A.at(i)%5==0){
      }else{
        hantei=false;
        break;
      }
    }
  }
  if(hantei==true){
    cout <<"APPROVED"<<endl;
  }else{
    cout <<"DENIED"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    ll n,ans=0;
  	cin >> n;
  	for(ll i = 1; i<n+1;i++){
		if(i%5!=0 && i%3!=0){
          ans= ans+i;
        }
    }
  cout << ans << endl;
}


Measured memory_bytes: 3660
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int D = GetInt();
		int[,] X = new int[N, D];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < D; j++)
				X[i, j] = GetInt();

		int ans = 0;
		for(int i = 0; i < N; i++)
		{
			for(int j = i + 1; j < N; j++)
			{
				int sum = 0;
				for(int k = 0; k < D; k++)
					sum += (X[i, k] - X[j, k]) * (X[i, k] - X[j, k]);

				int sqrt = (int)Math.Sqrt(sum);
				if(sqrt * sqrt == sum)
					ans++;
			}
		}
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
package main

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

func main() {
	var n int
	var a []int
	n, a = receiveStdin()

	var p int
	var i = 0
	for {
		if i == n {
			break
		}

		for j := n - 1; j > i; j-- {
			if a[j-1] > a[j] {
				tmp := a[j]
				a[j] = a[j-1]
				a[j-1] = tmp
				p++
			}
		}
		i++
	}

	fmt.Println(strings.Join(transferIntToString(a), " "))
	fmt.Println(p)
}

func receiveStdin() (int, []int) {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	var a []int
	for i := 0; i < n; i++ {
		sc.Scan()
		b, e := strconv.Atoi(sc.Text())
		if e != nil {
			panic(e)
		}

		a = append(a, b)
	}

	return n, a
}

func transferIntToString(a []int) []string {
	if len(a) == 0 {
		return []string{}
	} else {
		var b []string
		for _, v := range a {
			b = append(b, strconv.Itoa(v))
		}
		return b
	}
}



Measured memory_bytes: 1124