akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N];
		int b[]=new int[N];
		int c[]=new int[N];
		int z=0,y=0,x=0,ans=0,ans2=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			z++;
		}z=0;
		Arrays.sort(A);
		ans=A[z+1];
		while(z<=N-1){
			y=A[z];
			while(true){
				if(y%ans==0){
					break;
				}
				x=y%ans;
				y=ans;ans=x;
			}
			if(z==0)
				ans=A[z];
			b[z]=ans;
			z++;
		}z=N-1;y=0;ans=A[z-1];
		while(z>=0){
			y=A[z];
			if(ans>y){
				x=ans;ans=y;y=x;
			}
			while(true){
				if(y%ans==0){
					break;
				}
				x=y%ans;
				y=ans;ans=x;
			}
			if(z==N-1)
				ans=A[z];
			c[z]=ans;
			z--;
		}z=0;y=0;
		while(z<N){
			if(z!=0&&z!=N-1){
				if(b[z-1]>=c[z+1]){
					y=b[z-1];ans=c[z+1];
				}
				else{
					y=c[z+1];ans=b[z-1];
				}
				while(true){
					if(y%ans==0){
						break;
					}
					x=y%ans;
					y=ans;ans=x;
				}
			}
			if(z==0)
				ans=c[1];
			if(z==N-1)
				ans=b[N-2];
			if(ans>ans2)
				ans2=ans;
			z++;
		}
		System.out.println(ans2);
	}
}

Measured memory_bytes: 61872
nen = input()
if int(nen[:4]) <=2018:
    print('Heisei')
elif int(nen[:4]) ==2019 and int(nen[5:7]) < 4:
    print('Heisei')
elif int(nen[:4]) ==2019 and int(nen[5:7]) == 4 and int(nen[8:10]) < 31:
    print('Heisei')
else:
    print('TBD')

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

int A, B, C;

int main(){
  cin >> A >> B >> C;
  cout << min(B/A, C) << endl;
}


Measured memory_bytes: 3564
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<ll> a(n+1);
    for (int i=1; i<n+1; i++) {
        cin >> a.at(i);
        a.at(i) %= m;
    }
    for (int i=1; i<n+1; i++) {
        a.at(i) += a.at(i-1);
        a.at(i) %= m;
    }
    map<ll, ll> mp;
    for (int i=0; i<n+1; i++) {
        mp[a.at(i)]++;
    }
    ll ans = 0;
    for (auto iter=mp.begin(); iter!=mp.end(); iter++) {
        ll tmp = iter->second;
        ans += tmp*(tmp-1)/2;
    }
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int tab[200005];
int a;
vector<int> dosort;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> a;
	for (int i=0;i<a;i++){
		cin >> tab[i];
		dosort.push_back(tab[i]);
	}
	sort(dosort.begin(),dosort.end());
	vector<int>::iterator low;
	//dosort.push_back(0);
	//low=lower_bound(dosort.begin(), dosort.end(), tab[i]);
	for (int i=0;i<a;i++){
		//low=lower_bound(dosort.begin(), dosort.end(), tab[i]);
		if(tab[i] > dosort[a/2-1]){
			cout << dosort[a/2-1]<<endl;
		}
		else cout << dosort[a/2]<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 3956
import math

A,B,H,M = map(int,input().split())
H_angle = (H*60+M)*360/(12*60)
M_angle = M*360/60
angle = min(abs(H_angle-M_angle),360-abs(H_angle-M_angle))
ans = (A**2+B**2-(2*A*B*math.cos(math.radians(angle))))**0.5

print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct FordFulkerson{
    struct edge{
        int to,cap,rev;
        edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
    };
    const int INF=1001001001;
    vector<vector<edge>>G;
    vector<int>used;

    FordFulkerson(int v):G(v),used(v){}

    void addEdge(int from,int to,int cap){
        G[from].push_back(edge(to,cap,G[to].size()));
        G[to].push_back(edge(from,0,G[from].size()-1));
    }

    int dfs(int v,int t,int f){
        if(v==t)return f;
        used[v]=true;
        for(int i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(used[e.to]||e.cap==0)continue;
            int d=dfs(e.to,t,min(f,e.cap));
            if(d==0)continue;
            e.cap-=d;
            G[e.to][e.rev].cap+=d;
            return d;
        }
        return 0;
    }

    int maxFlow(int s,int t){
        int flow=0;
        while(true){
            fill(used.begin(),used.end(),0);
            int f=dfs(s,t,INF);
            if(f==0)return flow;
            flow+=f;
        }
    }
};

signed main(){
    int V,E;
    scanf("%lld%lld",&V,&E);
    FordFulkerson ff(V);
    for(int i=0;i<E;i++){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        ff.addEdge(a,b,c);
    }
    cout<<ff.maxFlow(0,V-1)<<endl;
    return 0;
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    set<int> se;
    REP(i,n){
        int t;
        cin>>t;
        se.insert(t);
    }
    cout<<se.size()<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)
ll a[100100];
ll b[100100];
ll c[100100];

unordered_map<ll, ll> lmap;

int main(void)
{
    ll n; cin >> n;
    REP(i, n) {
        cin >> a[i];
        lmap[a[i]] ++;
    }
    ll sum = 0;
    for(auto &itr : lmap) {
//        printf("[%lld]%lld\n", itr.first, itr.second);
        if(itr.first < itr.second) sum += itr.second - itr.first;
        if(itr.first > itr.second) sum += itr.second;
    }
    cout << sum << endl;
}


Measured memory_bytes: 5028
#pragma comment(linker, "/STACK:32000000")
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, _= (n); i < _; ++i)
#define DWN(i, n) for (int i = (n) - 1; i >= 0; --i)
#define FOR(i, l, r) for (int i = (l), _ = (r); i < _; ++i)
#define EDGE(u, v, e) for (int e = head[u], v; e != nil && (v = to[e], true); e = next[e])

using namespace std;

typedef unsigned int uint;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;

inline bool read(int& val)    { return scanf("%d",    &val) != -1;}
inline bool read(int64& val)  { return scanf("%I64d", &val) != -1;}
inline bool read(double& val) { return scanf("%lf",   &val) != -1;}
inline bool read(char* val)   { return scanf("%s",     val) != -1;}
template<class T1, class T2>
inline bool read(T1& a, T2& b)
{ return read(a) && read(b); }
template<class T1, class T2, class T3>
inline bool read(T1& a, T2& b, T3& c)
{ return read(a) && read(b) && read(c); }
template<class T1, class T2, class T3, class T4>
inline bool read(T1& a, T2& b, T3& c, T4& d)
{ return read(a) && read(b) && read(c) && read(d); }
template<class T1, class T2, class T3, class T4, class T5>
inline bool read(T1& a, T2& b, T3& c, T4& d, T5& e)
{ return read(a) && read(b) && read(c) && read(d) && read(e); }

const int N = 64;
const long long mod = 1000000007;
int val[N];
int64 dp[N][2][2][2];
void add(int64& a, int64 b, int64 mod) {
	a += b;
	if (a >= mod) a -= mod;
	if (a < 0)	a += mod;
}

int64 dfs(int p, int up, bool xorlimit, bool sumlimit) {
	int64& ret = dp[p][up][xorlimit][sumlimit];
	if (p == -1) return up == 0;
	if (ret == -1) {
		ret = 0;
		int maxu = xorlimit ? val[p] : 2;
		int maxv = sumlimit ? val[p] : 2;
		if (maxu >= 0) {
			if (maxv >= 0) add(ret, dfs(p - 1, 0, maxu == 0, maxv == 0), mod); //xor = 0, sum = 0
			if (maxv >= 1) add(ret, dfs(p - 1, 1, maxu == 0, maxv == 1), mod); //xor = 0, sum = 1
		}
		if (maxu >= 1) {
			if (up == 1 && maxv >= 0) add(ret, dfs(p - 1, 1, maxu == 1, maxv == 0), mod); //xor = 1, sum = 0
			if (up == 0 && maxv >= 1) add(ret, dfs(p - 1, 0, maxu == 1, maxv == 1), mod); //xor = 1, sum = 1
		}
	}
	return ret;
}

int main() {
	long long n; cin >> n;
	REP (i, N) val[i] = (n & (1ll << i)) >> i;
	memset(&dp, -1, sizeof(dp));
	cout << dfs(63, 0, 1, 1);
//	freopen("test.txt", "r", stdin);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    string ans;
    if(A == B && A != C){
        ans = "Yes";
    }else if(A == C && A != B){
        ans = "Yes";
    }else if(B == C && A != B){
        ans = "Yes";
    }else{
        ans = "No";
    }
    
    cout << ans;
    return 0;
}


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

int main(){
  int N, K, x, a, b;
  int ans = 0;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> x;
    a = 2 * x;
    b = 2 * (K - x);
    ans = ans + min(a, b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools

def issquare(x):
    a = 1
    while x >= a*a:
        if x == a*a:
            return True
        a += 1
    return False

n,d = map(int, input().split())
ps = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for pi,pj in itertools.combinations(ps, 2):
    d = sum([(x-y)*(x-y) for x,y in zip(pi,pj)])
    if issquare(d):
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if ((A - B) % 2 == 0) {
      System.out.println((A + B) / 2);
    } else {  
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 20948
n = int(input())
s = input()
result = 0
for i in range(1000):
    x = format(i, "03")
    indx = s.find(x[0],0)
    indx1 = s.find(x[1], indx+1)
    indx2 = s.find(x[2], indx1+1)
    if indx>=0 and indx1>0 and indx2>0:
        result += 1

print(result)

Measured memory_bytes: 3060
N, M, K = map(int, input().split())
mod = 10**9+7

def nCk(n, k, mod):
    nu = 1
    de = 1 
    for i in range(1, k+1):
        nu *= (n-i+1)
        de *= i
        nu = nu % mod
        de = de % mod
    ans = nu * pow(de, mod-2, mod) % mod
    return ans

ans = nCk(N*M-2, K-2, mod)*N*M*(M+N)*(M*N-1)//6
ans = ans % mod
print(ans)

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

 typedef long long ll;

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

    vector<int> b(n - 1);
    for(int i = 0;i < n- 1;i ++) cin >> b.at(i);

    int sum = b.at(0);

    for(int i = 1; i < n - 1; i++)
    {
        sum += min(b.at(i-1), b.at(i));
    }

    sum += b.at(n - 2);

    cout << sum << endl;


     
     return 0;
 }

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, M, N, K, A[30], T, X;
  scanf("%d%d", &N, &M);
  for (j=0;j<M;j++) {
    A[j] = 0;
  }
  for (j=0;j<N;j++) {
    scanf("%d", &K);
    for (i=0;i<K;i++) {
      scanf("%d", &X);
      A[X-1]++;
    }
  }
  
  T = 0;
  for (j=0;j<M;j++) {
    if (A[j] == N) T += 1;
  }
  printf("%d\n", T);
  return 0;
}


Measured memory_bytes: 128
N = int(input())

word = {}
for i in range(N):
    t = list(input())
    t.sort()
    t = "".join(t)
    if t not in word:
        word[t] = 1
    else:
        word[t] += 1

ans = 0
for values in word.values():
    ans += values*(values-1)//2

print(ans)

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

char change(char c){
	if(c == ' ') return ' ';
	if(c == '.') return '.';
	return toupper(c);
}

int main()
{
	string s;
	getline(cin, s);
	for(string::const_iterator iter = s.begin();
		iter != s.end(); iter++)
	{
		cout << change(*iter);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto N = readln.chomp.to!long;

  long solve() {
    return N % 2 == 0 ? N/2 : N/2 + 1;
  }

  solve().writeln;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


int main(){
    int N; cin >> N;
    cout << N*N*N << endl;
    return 0;
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1e5+5;
int a[N],w[N],b[N],c[N],ans[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n,l,t;
	cin>>n>>l>>t;
	rep(i,1,n){a[i]=read();w[i]=read();}
	rep(i,1,n)b[i]=((a[i]+((w[i]==1)?t:-t))%l+l)%l;
	rep(i,1,n)c[i]=b[i];
	sort(c+1,c+n+1);
	int dy1=0;
	if(w[1]==1)
	{
		s64 c=0;
		rep(i,1,n)
		if(w[i]==2)c+=((s64)2*t+(l-(a[i]-a[1]))-1)/l;
		dy1=c%n+1;
	}
	else
	{
		s64 c=0;
		rep(i,1,n)
		if(w[i]==1)c+=((s64)2*t+(a[i]-a[1]))/l;
		dy1=(-c%n+n)%n+1;
	}
	int p=lower_bound(c+1,c+n+1,b[1])-c;
	rep(i,0,n-1)ans[(dy1+i)%n+1]=c[(p+i)%n+1];
	rep(i,1,n)printf("%d\n",ans[i]);
}



Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 50, MAX_M = 50;
int used[MAX_N][MAX_M], path[MAX_N][MAX_M];
int di[4] = { 1, 0, -1, 0 }, dj[4] = { 0, 1, 0, -1 };
int N, M;
char g[MAX_N][MAX_M];
P p[MAX_N][MAX_M];

void bfs(int si, int sj) {
	used[si][sj] = 1; p[si][sj] = P(-1, -1);
	queue<P> q; q.push(P(si, sj));

	while (q.size()) {
		int ui = q.front().first, uj = q.front().second; q.pop();
		for (int i = 0;i < 4;i++) {
			int ni = ui + di[i], nj = uj + dj[i];
			if (0 <= ni && ni < N && 0 <= nj && nj < M && !used[ni][nj]&&g[ni][nj] == '.') {
				used[ni][nj] = 1; p[ni][nj] = P(ui, uj);
				q.push(P(ni, nj));
			}
		}
	}
}

int main()
{
	cin >> N >> M;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < M;j++) cin >> g[i][j];
	}

	bfs(0, 0);

	int ci = N-1, cj = M-1;
	while (ci != -1) {
		path[ci][cj] = 1;
		int tmpi = ci;
		ci = p[ci][cj].first, cj = p[tmpi][cj].second;
	}

	if (!used[N - 1][M - 1]) {
		cout << -1 << endl;
		return 0;
	}

	int ans = 0;
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < M;j++)
			if (!path[i][j] && g[i][j] == '.') ans++;
	}

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



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
N = int(input())
t1 = 0
t2 = 0
num1 = 0
num2 = 0
for i in range(N):
    x = int(input())
    if t1 < x:
        t2 = t1
        num2 = num1
        t1 = x
        num1 = i
    else:
        if t2 < x:
            t2 = x
            num2 = i
for j in range(0, num1):
    print(t1)
print(t2)
for k in range(num1+1, N):
    print(t1)

Measured memory_bytes: 4540
import sys
input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    x = [int(x) for x in input().split()]

    ans = float("inf")
    for i in range(N + 1 - K):
        l = x[i]
        r = x[i + K - 1]
        if l < 0 < r:
            ans = min(ans, abs(l) + abs(r) + min(abs(l), abs(r)))
        else:
            ans = min(ans, max(abs(l), abs(r)))

    print(ans)

    


if __name__ == '__main__':
    main()



Measured memory_bytes: 14172
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[51];
    rep(i, H) cin >> S[i];
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') {
                bool exist = false;
                rep(k, 4) {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x < 0 || x >= H || y < 0 || y >= W) continue;
                    if(S[x][y] == '#') exist = true;
                }
                if(!exist) {
                    cout << "No" << endl;
                    return 0;
                }

            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>

int main()
{
	while (true){
	int a, b;
	char op;
	std::cin >> a >> op >> b;
	switch (op)
	{
	case '+':
		std::cout << a + b << std::endl;
		break;
	case '-':
		std::cout << a - b << std::endl;
		break;
	case '*':
		std::cout << a * b << std::endl;
		break;
	case '/':
		std::cout << a / b << std::endl;
		break;
	case '?':
		return 0;
	}
}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    string S;
    cin>>S;
    bool b[200001];
    rep(i,N){
        b[i+1]=(S[i]=='.');
    }
    bool flag,fflag;
    if(C<D){
        flag=true;
        for(int i=B+1;i<D;i++){
            flag=flag && (b[i-1] || b[i]);
        }
        for(int i=A+1;i<C;i++){
            flag=flag && (b[i-1] || b[i]);
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        flag=true;
        for(int i=B+1;i<D;i++){
            flag=flag && (b[i-1] || b[i]);
        }
        for(int i=A+1;i<C;i++){
            flag=flag && (b[i-1] || b[i]);
        }
        fflag=false;
        for(int i=B;i<D+1;i++){
            if(!b[i]) continue;
            fflag=fflag ||( b[i-1] && b[i+1] );
        }
        flag=flag&& fflag;
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 772
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int I = sc.nextInt();
    	String S = Integer.toString(I);
    	char s = S.charAt(S.length()-1);
    	if (s == '3') {
    		System.out.println("bon");
    	} else if (s == '0' || s == '1' || s == '6' || s =='8') {
    		System.out.println("pon");
    	} else {
    		System.out.println("hon");
    	}
    }
}

Measured memory_bytes: 35784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int H = Integer.parseInt(lines[0]);
      int W = Integer.parseInt(lines[1]);
      int N = H * W;

      int[][] arr = new int[H][W];
      for (int i = 0; i < H; i++) {
        String line = in.readLine();
        for (int j = 0; j < W; j++) {
          if (line.charAt(j) == '#') 
            arr[i][j] = 0;
          else
            arr[i][j] = N;
        }
      }

      int ans = bfs(arr, H, W, N);
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private boolean inside(int H, int W, int y, int x) {
    return 0 <= y && y < H && 0 <= x && x < W;
  }

  private int bfs(int[][] grid, int H, int W, int N) {
    int distMax = 0;
    int[] dy = { 1, 0,-1, 0};
    int[] dx = { 0, 1, 0,-1};

    Deque<Point> que = new ArrayDeque<Point>();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if(grid[i][j] == 0) que.offer(new Point(i, j));
      }
    }

    while(!que.isEmpty()) {
      Point cur = que.poll();

      for (int i = 0; i < 4; i++) {
        int ny = cur.y + dy[i];
        int nx = cur.x + dx[i];
        if(inside(H, W, ny, nx) && grid[ny][nx] == N) {
          int d = grid[cur.y][cur.x] + 1;
          grid[ny][nx] = d;
          que.offer(new Point(ny, nx));
          if(distMax < d) distMax = d;
        }
      }
    }

    return distMax;
  }

  class Point {
    public int y, x;

    public Point(int y, int x) {
      this.y = y;
      this.x = x;
    }
  }
}

Measured memory_bytes: 66712
buf = []
v = []
w = []
N, W = list(map(int, input().split()))
dp = [[0 for i in range(W + 1)]for j in range(N + 1)]
for i in range(N):
    buf.append(list(map(int, input().split())))
for i in range(len(buf)):
    v.append(buf[i][0])
    w.append(buf[i][1])

for i in range(N)[::-1]:
    for j in range(W + 1):
        if j < w[i]:
            dp[i][j] = dp[i + 1][j]
        else:
            dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i])
print(dp[0][W])

Measured memory_bytes: 26744
s = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
def geti(k,s):
  l = [-1]
  for i in range(len(s)):
    if s[i] == k:
      l.append(i)
  return l

def count(l,s):
  if l == [-1]:
    return 1000
  leng = len(s)
  if leng not in l:
    l.append(leng)
  c = 0
  for i in range(len(l)-1):
    if l[i+1] - l[i] - 1 > c:
      c = l[i+1] - l[i] - 1
  return c

ans = 1000
for a in alpha:
  if count(geti(a,s),s) < ans:
    ans = count(geti(a,s),s)
print(ans)

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

int main(){

  int x;
  cin>>x;
  int h = x / 3600;
  int m = (x / 60) % 60;
  int s = x % 60;
  cout<<h<<":"<<m<<":"<<s<<endl;

  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  string s;
  char a[6][6]={"abcde","fghij","klmno","pqrst","uvwxy","z.?! "};
  while(cin>>s){
    string ans="";
    if(s.size()%2){
      cout<<"NA"<<endl;
      continue;
    }
    rep(i,s.size()){
      if(s[i]<'1' || s[i]>'6' || s[i+1]<'1' || s[i+1]>'5'){
    ans="NA";
    break;
      }
      ans+=a[s[i]-'0'-1][s[i+1]-'0'-1];
      i++;
    }
    cout<<ans<<endl;
  }
}

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

void Main() {
  int a, b;
  std::cin >> a >> b;

  int ans = 0;
  int socket = 1;
  while (socket < b) {
    socket = socket - 1 + a;
    ans += 1;
  }

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

int main()
{
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K){
        cout << S << endl;
    }else{
        rep(i,K){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3628
X = int(input())
p5 = [i**5 for i in range(3000)]
p5s = set(p5)
M = 299**5
A = 0
while True:
    B5 = abs(A**5 - X)
    if B5 in p5s:
        B = p5.index(B5) if A**5 >= X else -p5.index(B5)
        print(A, B)
        exit()
    A += 1


Measured memory_bytes: 64072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\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;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

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

  for (ll i = 1; i <= x; i++) {
    ll S = i * (2 + (i - 1)) / 2;
    if (S >= x) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int cnt=0;
    rep(i,s.size()){
        if(s.at(i)!=t.at(i)){
            ++cnt;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3924
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	// A, B := nextInt(), nextInt()
	fmt.Println(nextInt() * nextInt())
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5;
int n,q,m,rest,a[N],b[N];

signed main(){
	read(n,q);m=n;
	for(int i=1;i<=n;i++) a[i]=b[i]=n;
	rest=(n-2)*(n-2);
	while(q--){
		int op,x;
		read(op,x);
		if(op==1){
			if(x<m){
				for(int i=x;i<m;i++) b[i]=n;
				m=x;
			}
			rest-=b[x]-2;
		}
		else{
			if(x<n){
				for(int i=x;i<n;i++) a[i]=m;
				n=x;
			}
			rest-=a[x]-2;
		}
	}
	write(rest);
}

Measured memory_bytes: 6728
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

point=[]
for _ in range(N):
    point.append(list(map(int,input().split())))

point.sort(key=lambda x: x[0])

shin=10**200
able=N-K
for i in range(able+1):
    temp_high=point[:N-i]
    for j in range(able+1-i):
        temp_low=temp_high[j:]
        for k in range(able+1-i-j):
            temp_left=temp_low[:]
            temp_left.sort(key=lambda x: x[1])
            temp_left=temp_left[k:len(temp_left)-(able+1-i-j)+k+1]
            #print(i,j,k)
            #print(temp_left)
            if temp_left:
                ans=temp_left[:]
            elif temp_low:
                ans=temp_low[:]
            else:
                ans=temp_high[:]
            x=[]
            y=[]
            for item in ans:
                x.append(item[0])
                y.append(item[1])
            #print(x)
            #print(y)
            num=((max(x)-min(x))*(max(y)-min(y)))
            shin=min(shin,num)

print(shin)




Measured memory_bytes: 3064
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Matrix.zero(n, m + 1)
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[i, j] = b[j]
  end
end
1.upto(m) do |j|
  if (a.column(j).covector * Vector.elements(Array.new(n, 1)))[0] < x
        puts "-1"
    exit
  end
end
min = Float::INFINITY
1.upto(2 ** n - 1) do |bit|
  ans = 0
  sum = 0
  1.upto(m) do |j|
    sum = (a.column(j).covector * Vector.elements(bit.to_s(2).rjust(n, "0").split('').map(&:to_i)))[0]
    break if sum < x
  end
  if sum >= x
    ans = (a.column(0).covector * Vector.elements(bit.to_s(2).rjust(n, "0").split('').map(&:to_i)))[0]
    min = ans if min > ans
  end
end
puts min

Measured memory_bytes: 15168
n, k = map(int, input().split())

V = list(map(int, input().split()))

I = []

for i in range(min(n, k)+1):
    for j in range(min(n, k)-i+1):
        I.append([i, j])

Vr = V[::-1]

maxi = 0

for l in I:
    H = V[0:l[0]] + Vr[0:l[1]]
    H.sort()
    t = min(len(H), k - len(H))
    t = max(0, t)
    minus = sum(s < 0 for s in H)
    score = sum(H[min(minus, t):])
    maxi = max(maxi, score)

print(maxi)



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

using namespace std;

int main()
{
  int N;
  cin >> N;
  
  vector<string> S(N);
  for (int i=0; i<N; i++){
    cin >> S[i];
  }
  
  sort(S.begin(),S.end());
  
  vector<int> track;
  
  for (int i=0; i<N-1; i++){
    if (S[i] != S[i+1]){
      track.push_back(i);
    }
  }
  track.push_back(N-1);
  vector<int> deff(track.size());

  for (int i=0; i<track.size();i++){
    if (i==0){
      deff[i] = track[i]+1;
    }
    if(i>0){
      deff[i]=track[i]-track[i-1];
    }
  }

  vector<int> deff_2(track.size());
  deff_2 = deff;
  
  sort(deff.begin(),deff.end());
  reverse(deff.begin(),deff.end());
  int ma;
  ma = deff[0];
  int dummy=0;
  for (int i=0; i<track.size();i++){
    dummy+=deff_2[i];
    if (ma == deff_2[i]){
      cout << S[dummy-1] << endl;
    }
  }

      
  

  

  
  
  return 0;
}


Measured memory_bytes: 16760
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll x;
  cin>>x;
  ll module=x/11;
  ll remainder=x%11;
  if(remainder==0) cout<<2*module<<endl;
 else if(remainder<=6) cout<<2*module+1<<endl;
 else cout<<2*module+2<<endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

    char number[1000];
    int i,num,sum=0;
    
    while(1) {
        scanf("%s",number);
        for(i=0;number[i]!='\0';i++){
            num=number[i]-'0';
            sum=sum+num;
        }
        if(sum==0) break;
        printf("%d\n",sum);
        sum=0;
        }
    
    return 0;
}



Measured memory_bytes: 2676
ABCD = input()

for i in range(1,2**3):
    X = ABCD[0]
    for j in range(3):
        if 1 << j & i:
            X += '+'
        else:
            X += '-'
        X += ABCD[j+1]
    # print('eval: ',X)
    if eval(X) == 7:
        print(X+'=7')
        break

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

int main() {
    Int d, t, s;
    cin >> d >> t >> s;
    Int x = d / s;
    if (d % s != 0) x++;
    print(x <= t ? "Yes" : "No");
    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

struct edge { int to; ll value; };

const int MAX_N = 100000;
int n,m;
vector<edge> g[MAX_N];
ll min_e[MAX_N];
ll cond[MAX_N][2];
ll INF = LLONG_MAX;

bool dfs(int u, int p, ll total, int odd) {
  if (cond[u][odd] < INF)
    return cond[u][odd] == total;

  cond[u][odd] = total;

  for (edge e : g[u]) {
    if (e.to == p) continue;
    if (!dfs(e.to, u, e.value - total, 1-odd))
      return false;
  }

  return true;
}

int main()
{
  cin >> n >> m;
  fill_n(min_e,n,LLONG_MAX);

  int u,v;
  ll s;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v >> s;
    u--,v--;
    g[u].push_back((edge){v, s});
    g[v].push_back((edge){u, s});
    min_e[u] = min(min_e[u], s);
    min_e[v] = min(min_e[v], s);
  }

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

  if (!dfs(0,-1,0,0)) {
    cout << 0 << endl;
    return 0;
  }

  ll t_min = 1, t_max = LLONG_MAX;
  for (int i = 0; i < n; i++) {
    if (cond[i][0] < INF && cond[i][1] < INF) {
      ll t = cond[i][1] - cond[i][0];
      if (t % 2 == 0 && t_min <= t/2 && t/2 <= t_max) {
        t_min = t_max = t/2;
      } else {
        t_min = LLONG_MAX;
        t_max = LLONG_MIN;
      }
    }
    if (cond[i][0] < INF) {
      t_min = max(t_min, 1-cond[i][0]);
      t_max = min(t_max, min_e[i]-1-cond[i][0]);
    }
    if (cond[i][1] < INF) {
      t_min = max(t_min, cond[i][1]-min_e[i]+1);
      t_max = min(t_max, cond[i][1]-1);
    }
  }

  //printf("mx=%lld mn=%lld\n",t_min,t_max);

  if (t_max >= t_min)
    cout << t_max - t_min + 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}


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

int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0);
	int h, n, c = 0;
	cin >> h >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	long long x = accumulate(v.begin(), v.end(), 0);
	cout << (x >= h ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string ans = "UNRESTORABLE";
        string key = Reader.ReadLine();
        string hint = Reader.ReadLine();

        for (int i = key.Length - hint.Length; i >= 0; i--)
        {
            bool isUnmatch = false;
            for (int j = 0; j < hint.Length; j++)
            {
                if (hint[j] == key[i + j])
                {
                    continue;
                }
                if (key[i + j] == '?')
                {
                    continue;
                }
                isUnmatch = true;
                break;
            }
            if (!isUnmatch)
            {
                char[] tmp = key.ToArray();
                for (int j = 0; j < hint.Length; j++) {
                    tmp[i + j] = hint[j];
                }
                ans = string.Join(string.Empty, tmp);
                break;
            }
        }
        ans = ans.Replace('?', 'a');
        Console.WriteLine(ans);
    }




    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



??p??d??
abc


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13268
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let (D, N) = read!(i32, i32);
    let X = if D == 0 {
        if N < 100 {
            N
        } else {
            101
        }
    } else if D == 1 {
        if N < 100 {
            N * 100
        } else {
            10100
        }
    } else if D == 2 {
        if N < 100 {
            N * 10000
        } else {
            1010000
        }
    } else {
        unreachable!()
    };
    println!("{}", X);
    return;
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    auto rec = [&](auto &&rec, int len, ll n, ll m) -> ll {
        if (len == s.size()) {
            return n+m;
        }

        int a = s[len] - '0';
        ll res = rec(rec, len+1, n+m, a);
        if (len > 0) {
            res += rec(rec, len+1, n, m*10+a);
        }
        return res;
    };
    cout << rec(rec, 0, 0, 0) << endl;
    return 0;
}


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

typedef long long LL;
typedef pair<LL,LL> PII;

const int MAXN = 300000;
vector<int> graph[MAXN];

int main() {
	
	int N,M;
	cin >> N >> M;
	for(int i=0; i<N; i++) {
		int K;
		cin >> K;
		for(int j=0; j<K; j++) {
			int p;
			cin >> p;
			p--;
			graph[i].push_back(N+p);
			graph[N+p].push_back(i);
		}
	}
	
	vector<int> used(N+M, 0);
	used[0] = 1;
	queue<int> qu;
	qu.push(0);
	while(!qu.empty()) {
		int cur = qu.front(); qu.pop();
		
		for(int i=0; i<graph[cur].size(); i++) {
			int next = graph[cur][i];
			if(used[next]) continue;
			used[next] = true;
			qu.push(next);
		}
		
	}
	bool ok = true;
	for(int i=0; i<N; i++) {
		if(!used[i]) ok = false;
	}	
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}



Measured memory_bytes: 12024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int x, k, q;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> x >> k;
    vector<int> r(k);
    rep(i, 0, k) cin >> r[i];
    cin >> q;
    vector<int> t(q), a(q);
    rep(i, 0, q) cin >> t[i] >> a[i];

    int MAX = x, MIN = 0;
    int high = x, low = 0;
    int now = 0, j = 0;
    rep(i, 0, q){
        while(j < k && r[j] <= t[i]){
            int diff = r[j] - now;
            if(j % 2 == 0){
                MAX -= diff;
                MIN -= diff;
                if(MAX <= 0){
                    low = x;
                }else if(MIN <= 0){
                    low -= MIN;
                }
                chmax(MAX, (int)0);
                chmax(MIN, (int)0);
            }else{
                MAX += diff;
                MIN += diff;
                if(MIN >= x){
                    high = 0;
                }else if(MAX >= x){
                    high -= MAX - x;
                }
                chmin(MAX, x);
                chmin(MIN, x);
            }
            // cout << j << " " << r[j] << " " << now << " : " << MAX << " " << high << " : " << MIN << " " << low << endl;
            now = r[j++];
        }
        int ans;
        if(low <= a[i] && a[i] <= high) ans = MIN + (a[i] - low);
        if(a[i] < low) ans = MIN;
        if(a[i] > high) ans = MAX;
        if(j % 2 == 0){
            ans = max(ans - (t[i] - now), (int)0);
        }else{
            ans = min(ans + t[i] - now, x);
        }
        cout << ans << endl;
    }
}

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

using ll = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    char a = s[0], b = s[n - 1];
    if ((a == b && n % 2 == 0) || (a != b && n % 2 == 1)) cout << "First" << endl;
    else cout << "Second" << endl;
}

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

    int main (){
     int n,m,x;
     cin >> n >> m >> x;
        
        vector<int> a(m);

        int ansf=0;
        int ansb=0;

        rep(i,m){
            cin >> a[i];
            if(a[i]>x){
                ansb++;
            }
            else{
                ansf++;
            }
        }

        int ans = min(ansf,ansb);

        cout << ans << endl;

        return 0;

    }


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

int main() {
  while(true) {
    int A[4],B[4];
    int hit = 0;
    int blow = 0;
    cin >> A[0] >> A[1] >> A[2] >> A[3];
    if(cin.eof()) break;
    cin >> B[0] >> B[1] >> B[2] >> B[3];
    for(int i=0;i<4;i++) {
      if(A[i] == B[i])
        hit++;
    }
    for(int i=0;i<4;i++) {
      for(int j=0;j<4;j++) {
        if(A[i] == B[j]) {
          blow++;
          break;
        }
      }
    }
    blow = blow - hit;
    cout << hit << " " << blow << endl;
  }
}

Measured memory_bytes: 1160
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
s=SI()
t=SI()
a=len(s)
b=len(t)
dp=[[0]*(a+1) for i in range(b+1)]
for i in range(1,b+1):
    for j in range(1,a+1):
        if s[j-1]==t[i-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=[]
i,j=b,a
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans.append(s[j-1])
        i -= 1
        j -= 1
#print(ans)
for x in list(reversed(ans)):
    print(x,end="")





            

    
    



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

 // mod. m での a の逆元 a^{-1} を計算する
 ll modinv(ll a, ll m) {
     ll b = m, u = 1, v = 0;
     while (b) {
         ll t = a / b;
         a -= t * b; swap(a, b);
         u -= t * v; swap(u, v);
     }
     u %= m;
     if (u < 0) u += m;
     return u;
 }

int main(){
    ll x,y;
    cin >> x >> y;
    bool can = true;
    if((2*x-y)%3||2*x-y<0)
        can = false;
    if((2*y-x)%3||2*y-x<0)
        can = false;
    if(!can){
        cout << 0 << endl;
        return 0;
    }
    ll a = (2*y-x)/3;
    ll b = (2*x-y)/3;
    // cout << a << endl;
    // cout << b << endl;
    ll s=1,t=1,u=1;
    for(int i=1;i<=a;i++){
        t*=i;
        t%=MOD;
    }
    for(int i=1;i<=b;i++){
        u*=i;
        u%=MOD;
    }
    for(int i=1;i<=a+b;i++){
        s*=i;
        s%=MOD;
    }
    ll ans = s * modinv(t,MOD) % MOD * modinv(u,MOD) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int X;
    cin >> X;
    int sum = 0;
    int i;
    for (i = 1; ; i++)
    {
        sum += i;
        if (sum >= X)
        {
            cout << i << endl;
            break;
        }
        
    }

    return 0;
}

Measured memory_bytes: 888