akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
  pair<int,int> fun[100];
  int num,acc,tel,i=0,tmp;
  int j,z;
  while(1){
    scanf("%d,%d",&num,&acc);
    if(num == 0 && acc == 0) break;
    fun[i] = make_pair(acc,num);
    i++;
  }
  sort(fun,fun+i);
  tmp = fun[i-1].first;
  j = 1;
  fun[i-1].first = j;
  for(z=i-2;z>=0;z--){
    if(tmp == fun[z].first){
      fun[z].first = j;
    }
    else{
      j++;
      tmp = fun[z].first;
      fun[z].first = j;
    }
  }
  while(cin >> tel){
    for(j=0;j<i;j++){
      if(fun[j].second == tel){
	cout << fun[j].first << endl;
      }
    }
  }
}

Measured memory_bytes: 1248
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i, a, b) for(int i=a;i<b;++i)
/////////////////

void solve(){
	string s;
	cin >> s;
	int cnt[2];
	cnt[0] = cnt[1] = 0;
	int cur = 0;
	cnt[0] = 1;
	rep(i, 1, sz(s)){
		if(s[i] != s[i-1]){
			cur ^= 1;
			++cnt[cur];
		}
	}
	if(cnt[0] > cnt[1]) swap(cnt[0], cnt[1]);
	if(cnt[0] == 0){
		cout << 0 << endl;
		return;
	}
	if(cnt[1] == 1){
		cout << 1 << endl;
		return;
	}
	cout << cnt[0] + cnt[1] - 1 << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int h,w,k;
		cin>>h>>w>>k;
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		string s[h];
		FOR(i,0,h)
		cin>>s[i];
		ll dp[h][w];
		FOR(i,0,h)
		{
			FOR(j,0,w)
			{
				dp[i][j]=mod;
			}
		}
		x2--;
		y2--;
		dp[x1-1][y1-1]=0;
		queue<pair<int,int> > re;
		re.push(mp(x1-1,y1-1));
		pair<int,int> cur;
		int x,y;
		while(!re.empty())
		{
			cur=re.front();
			x=cur.first;
			y=cur.second;
			re.pop();
			FOR(i,1,k+1)
			{
				if((x+i)>=h)
				break;
				if(s[x+i][y]=='@')
				break;
				if(dp[x+i][y]<=dp[x][y])
				break;
				if(dp[x+i][y]==mod)
				{
					re.push(mp(x+i,y));
				}
				dp[x+i][y]=dp[x][y]+1;
			}
			FOR(i,1,k+1)
			{
				if((x-i)<0)
				break;
				if(s[x-i][y]=='@')
				break;
				if(dp[x-i][y]<=dp[x][y])
				break;
				if(dp[x-i][y]==mod)
				{
					re.push(mp(x-i,y));
				}
				dp[x-i][y]=dp[x][y]+1;
			}
			FOR(i,1,k+1)
			{
				if((y+i)>=w)
				break;
				if(s[x][y+i]=='@')
				break;
				if(dp[x][y+i]<=dp[x][y])
				break;
				if(dp[x][y+i]==mod)
				{
					re.push(mp(x,y+i));
				}
				dp[x][y+i]=dp[x][y]+1;
			}
			FOR(i,1,k+1)
			{
				if((y-i)<0)
				break;
				if(s[x][y-i]=='@')
				break;
				if(dp[x][y-i]<=dp[x][y])
				break;
				if(dp[x][y-i]==mod)
				{
					re.push(mp(x,y-i));
				}
				dp[x][y-i]=dp[x][y]+1;
			}
//			cout<<re.size()<<'\n';
		}
//		FOR(i,0,h)
//		{
//			FOR(j,0,w)
//			{
//				cout<<dp[i][j]<<' ';
//			}
//			cout<<'\n';
//		}
		if(dp[x2][y2]==mod)
		cout<<-1;
		else
		cout<<dp[x2][y2];
	}
	return 0;
}


Measured memory_bytes: 13448
#include <cstdio>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <set>
#include <ctime>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;

namespace FastIO {
	template<typename tp> inline void read(tp &x) {
		x=0; register char c=getchar(); register bool f=0;
		for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
		for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
		if(f) x=-x;
	}
	template<typename tp> inline void write(tp x) {
		if (x==0) return (void) (putchar('0'));
		if (x<0) putchar('-'),x=-x;
		int pr[20]; register int cnt=0;
		for (;x;x/=10) pr[++cnt]=x%10;
		while (cnt) putchar(pr[cnt--]+'0');
	}
	template<typename tp> inline void writeln(tp x) {
		write(x);
		putchar('\n');
	}
}
using namespace FastIO;

char s[500005];
int hig[500005];
int n;

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for (int i = 1; i <= n; ++i) {
        if (s[i] == '<') hig[i] = hig[i - 1] + 1;
    }
    LL ans = hig[n];
    for (int i = n - 1; i >= 0; --i) {
        if (s[i + 1] == '>') {
            hig[i] = max(hig[i], hig[i + 1] + 1);
        }
        ans += hig[i];
    }
    writeln(ans);
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

LL check(LL N, LL M, LL C) {
	if (N == 0) {
		if (M == C)return 0;
		else return ((LL)1 << 50);
	}
	LL N0 = N & 1;
	LL M0 = M & 1;
	LL C0 = C & 1;
	if ((N0 ^ M0) == 0 && C0 == 0) {
		if (N0 == 0) {
			LL ret1 = check(N >> 1, M >> 1, C >> 1);
			LL ret2 = check((N - 1) >> 1, (M + 1) >> 1, C >> 1);
			LL ret = min(ret1, ret2);
			if (ret >= ((LL)1 << 50))return ((LL)1 << 50);
			if ((ret1 << 1) < (ret2 << 1) + 1)return (ret1 << 1);
			else return (ret2 << 1) + 1;
		}
		else {
			LL ret1 = check(N >> 1, M >> 1, C >> 1);
			LL ret2 = check((N - 1) >> 1, (M + 1) >> 1, C >> 1);
			LL ret = min(ret1, ret2);
			if (ret >= ((LL)1 << 50))return ((LL)1 << 50);
			if ((ret1 << 1) < (ret2 << 1) + 1)return (ret1 << 1);
			else return (ret2 << 1) + 1;
		}
	}
	else if ((N0 ^ M0) == 1 && C0 == 1) {
		if (N0 == 1) {
			LL ret1 = check(N >> 1, M >> 1, C >> 1);
			LL ret2 = check((N - 1) >> 1, (M + 1) >> 1, C >> 1);
			LL ret = min(ret1, ret2);
			if (ret >= ((LL)1 << 50))return ((LL)1 << 50);
			if ((ret1 << 1) < (ret2 << 1) + 1)return (ret1 << 1);
			else return (ret2 << 1) + 1;
		}
		else {
			LL ret1 = check(N >> 1, M >> 1, C >> 1);
			LL ret2 = check((N - 1) >> 1, (M + 1) >> 1, C >> 1);
			LL ret = min(ret1, ret2);
			if (ret >= ((LL)1 << 50))return (LL)1 << 50;
			else if ((ret2 << 1) + 1 < (ret1<<1)) {
				return (ret2 << 1) + 1;
			}
			else {
				return ret1<<1;
			}
		}
	}
	else return ((LL)1 << 50);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	VLL A(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	LL C = 0;
	for (int n = 2; n < N; n++)C = (C ^ A[n]);
	LL ret = check(A[0], A[1], C);
	if (ret >= ((LL)1 << 50))cout << -1 << "\n";
	else if (ret == A[0])cout << -1 << "\n";
	else cout << ret << "\n";
	
	return 0;
}


Measured memory_bytes: 3164
import sys

s = input()
n = len(s)
if s[0] == "0" or s[-1] == "1":
	print(-1)
	sys.exit()

possible = []
for i in range(n // 2):
	if s[i] != s[n - i - 2]:
		print(-1)
		sys.exit()

	if i > 0 and s[i] == "1":
		possible.append(i+1)

#print(possible)
l = len(possible)

edges = []

cnt = 0
for i in range(l):
	for j in range(cnt + 1, possible[i]):
		edges.append([j, possible[i]])
	if i != l - 1:
		edges.append([possible[i], possible[i+1]])
	else:
		edges.append([possible[i], possible[i] + 1])

	cnt = possible[i]

for i in range(cnt + 2, n + 1):
	edges.append([cnt + 1, i])

for e in edges:
	print(*e)


Measured memory_bytes: 20000
#include<iostream>
using namespace std;
const int n=9;

int main()
{
	int m;cin>>m;
	for(int i=0;i<m;i++)
	{
		if(i)cout<<endl;
		int b[n][n]={};
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				cin>>b[j][k];
			}
		}
		bool v[n][n];
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				v[j][k]=false;
			}
		}
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				for(int l=0;l<n;l++)
				{
					if(k!=l)
					{
						if(b[k][j]==b[l][j])
						{
							v[k][j]=v[l][j]=true;
						}
					}
				}
			}
		}
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				for(int l=0;l<n;l++)
				{
					if(k!=l)
					{
						if(b[j][k]==b[j][l])
						{
							v[j][k]=v[j][l]=true;
						}
					}
				}
			}
		}
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				for(int l=0;l<3;l++)
				{
					for(int u=0;u<3;u++)
					{
						for(int y=0;y<3;y++)
						{
							for(int t=0;t<3;t++)
							{
								if(l!=y&&u!=t)
								{
									if(b[j*3+l][k*3+u]==b[j*3+y][k*3+t])
									{
										v[j*3+l][k*3+u]=v[j*3+y][k*3+t]=true;
									}
								}
							}
						}
					}
				}
			}
		}
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				if(v[j][k])cout<<"*";
				else cout<<" ";
				cout<<b[j][k];
			}
			cout<<endl;
		}
	}
	return 0;
}

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


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

    int sum = 0;
    int count = 0;
    
    while(sum < n){
        sum += 2 * d + 1;
        count++;
    }
    
    print(count);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int n;
    int B,F,R,V;
    int v[4][3][10] = {};
     
    cin >> n;
     
    for(int i=1;i<=n; i++){
        cin >> B >> F >> R >>V;
        v[B-1][F-1][R-1] += V;
    }
     
    for(int i = 0;i<=3;i++){
        for(int j = 0;j<=2;j++){
            for(int k = 0;k<=9;k++){
                cout<< " " << v[i][j][k];
            }
            cout << endl;
        }
        if(i<3) cout << "####################" << endl;
    }
 
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    for(int i = 1; i <= 50000; i++) {
        if((int)(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << ":(" << endl;
    return 0;
}



Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

constexpr int64_t INF = 1000000000000000;
int64_t N;
int64_t rem_[200000];
const auto rem = rem_ + 10;
int64_t A[200000];
int64_t rembase_end[200000];
int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (int64_t i = 0; i <= N; ++i)
    {
        in >> A[i];
    }

    int64_t vnum = 0;
    auto rem_iter = rem;
    if (A[0] > 1) {
        out << -1 << endl;
        return 0;
    }
    if (A[0] == 1) {
        ++vnum;
    }
    else {
        rem[0] = 1;
    }
    int64_t rembase = 0;
    for (int64_t i = 1; i <= N; i++)
    {
        while (*rem_iter < A[i]) {

            if (rem_iter - rem > i) {
                out << -1 << endl;
                return 0;
            }

            A[i] -= *rem_iter;
            vnum += (*rem_iter) * (i - (rem_iter - rem) + 1);
            rembase += *rem_iter; if (INF < rembase) { rembase = INF; }
            rembase_end[i] += -*rem_iter;
            if (rembase != INF) {
                rembase += rembase_end[rem_iter - rem];
            }
            ++rem_iter;
            *rem_iter += rembase; if (INF < *rem_iter) { *rem_iter = INF; }
        }

        *rem_iter -= A[i];
        vnum += A[i] * (i - (rem_iter - rem) + 1);
        rembase += A[i]; if (INF < rembase) { rembase = INF; }
        rembase_end[i] += -A[i];

    }
    out << vnum << endl;


    return 0;
}
#endif


Measured memory_bytes: 5520
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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



int main(){
    int i;
    
    int N;
    cin >> N;
    
    cout << (180.0-360.0/N)*N << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  lint n, c = 0, a; cin >> n; a = n;
  map<lint, lint> m;
  for(lint j = 2; j <= sqrt(n); ++j){
  lint b = 0;
  while(a % j == 0){
    a /= j;
    ++b;
  }
  if(b != 0) m[j] = max(m[j], b);
  if(a == 1) break;
  }
  if(a != 1 && !m.count(a)) m[a] = 1;
  for(auto p: m){
    int tmp = 1;
    while(p.se - tmp >= 0){
      p.se -= tmp;
      ++tmp;
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3724
n, m, c = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
a = []
n.times do
  a << gets.chomp.split.map(&:to_i)
end
count = 0
1.upto(n) do |i|
  sum = c
  1.upto(m) do |j|
    sum += a[i-1][j-1] * b[j-1]
  end
  count += 1 if sum > 0
end
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    double d, t, s;
    cin >> d >> t >> s;
    if(d <= s * t)
        cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3736
use std::collections::*;
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        h: [i64; n],
    };

    let mut dp = vec![1 << 30; n];
    dp[0] = 0;

    for i in 1..n {
        dp[i] = min(dp[i], dp[i-1] +(h[i] - h[i-1]).abs());
        for j in  2..min(k+1, i+1) {
            dp[i] = min(dp[i], dp[i-j] + (h[i] - h[i-j]).abs());
        }
    }

    println!("{}", dp[n-1]);

}


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

a_u = round(sum(a)/n)
a_d = int(sum(a)/n)
ans_u = 0
ans_d = 0
for i in range(n):
    ans_u += (a[i]-a_u)**2
    ans_d += (a[i]-a_d)**2
print(min(ans_u,ans_d))
#print(round(-2.5),int(-2.5))

Measured memory_bytes: 9124
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		String A = "1100000011";

		String B = "1000000010000000100000001";

		String C = "1111";

		String D = "1000000110000001";

		String E = "11000000011";

		String F = "100000001100000001";

		String G = "110000011";

		

		for(;sc.hasNext();){

			String buffer = sc.nextLine();

			if(buffer.length() < 8){

				continue;

			}

			for(int i =1; i < 8; i++){

				buffer+= sc.nextLine();

			}

			if(buffer.indexOf(A) != -1){

				System.out.println("A");			

			}

			if(buffer.indexOf(B) != -1){

				System.out.println("B");			

			}

			if(buffer.indexOf(C) != -1){

				System.out.println("C");			

			}

			if(buffer.indexOf(D) != -1){

				System.out.println("D");			

			}

			if(buffer.indexOf(E) != -1){

				System.out.println("E");			

			}

			if(buffer.indexOf(F) != -1){

				System.out.println("F");			

			}

			if(buffer.indexOf(G) != -1){

				System.out.println("G");			

			}

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <bitset>
#include <cmath>
#include <string>
#include <stdlib.h>

#define ll long long
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)

using namespace std;


int main() {
    int n; cin >> n;
    int f[n][10];
    repp(i,0,n) {
        repp (j,0,10) cin >> f[i][j];
    }

    ll p[n][11];
    repp(i,0,n) {
        repp (j,0,11) cin >> p[i][j];
    }

    ll ans = -(1LL<<30);

    for (int b = 1; b < (1 << 10); ++b) {

        ll sum = 0;
        for(int i = 0; i < n; ++i) {
            int count = 0;
            for(int j = 0; j < 10; ++j) {
                if ((b>>j) & 1 && f[i][j]) ++count;
            }
            sum += p[i][count];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

fn main() {
    let line = read_as_vec::<usize>();
    let (n, k) = (line[0], line[1] as u64);

    let a: Vec<u64> = read_as_vec::<u64>();
    let mut g: u64 = a[0];

    for elem in &a {
        g = gcd(g, *elem);
    }

    if k % g == 0 && k <= *a.iter().max().unwrap() {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 3848
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$s = $sc->next();

$s_arr = str_split($s);
$c = count($s_arr);

$abbr = $s_arr[0] . ($c - 2) . $s_arr[$c - 1];

echo $abbr;

Measured memory_bytes: 4604
#include<iostream>
#include<cstdlib>
#include<cmath>
#define f(n) ((int)pow(3.0,n)-1)
int A,N,M,S[16];
int v(int n,int m,int g){if(m<=N)return v(n-1,m+1,S[m]==1?g+2*(1-g):g)+abs(g-S[m])*(f(n-1)+1);else return 0;}
int main(){while(1){scanf("%d%d",&N,&M);if(!(N||M))break;for(int i=0;i<3;++i){int t;scanf("%d",&t);for(int j=0;j<t;++j){int u;scanf("%d",&u);S[u]=i;}}A=v(N,1,0);A=std::min(A,f(N)-A);A=A<=M?A:-1;printf("%d\n",A);}return 0;}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    string sfirst = "abcdefghijklmnopqrstuvwxyz";
    string slast = "zyxwvutsrqponmlkjihgfedcba";

    if(s == slast){
        cout << -1 << endl;
        return 0;
    }

    if(s.size() < 26){
        set<char> st;
        rep(i, s.size()){
            st.insert(s[i]);
        }
        rep(i, sfirst.size()){
            if(st.find(sfirst[i]) == st.end()){
                s.push_back(sfirst[i]);
                cout << s << endl;
                return 0;
            }
        }
    }

    vector<char> vc;
    vc.push_back(s[s.size()-1]);
    repr(i, s.size()-1){
        if(s[i] < s[i+1]){
            sort(vc.begin(), vc.end());
            rep(j, vc.size()){
                // cout << vc[j] << endl;
                if(s[i] < vc[j]){
                    s[i] = vc[j];
                    break;
                }
            }
            rep(j, i+1){
                cout << s[j];
            }
            return 0;
        }
        else{
            vc.push_back(s[i]);
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, c;
    int i, cnt = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(i = a; i <= b; i++) {
        if(c % i == 0) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1852
#include <stdio.h>
#include <string.h>

int main () {
	int n;
	char s[105];
	
	scanf("%d", &n);
	scanf("%s", s);
	
	if(n % 2 != 0) {
		printf("No\n");
	}
	else {
		int mid = n/2;
		int i = 0;
		while (s[i] == s[mid + i]) {
			i += 1;
		}

		if(i == mid) {
			printf("Yes\n");
		}
		else if(i < mid) {
			printf("No\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P=pair<int,int>;
using PP=pair<P,P>;
using ll=long long;
int main(){
    int h,w;
    cin>>h>>w;
    int cnt=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin>>c;
            if(c=='#')cnt++;
        }
    }
    if(cnt==h+w-1)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hs = vec![0i16; n];
    for i in 0..(n - 1) {
        hs[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    hs[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    for i in 0..n {
        let hi = hs[i];
        let mut b = true;
        for j in 0..i {
            if hs[j] > hi {
                b = false;
                break;
            }
        }
        if b {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;


int main(){
    char c;
    cin >> c;
    char ans;
    if(c == 'A') ans = 'T';
    if(c == 'T') ans = 'A';
    if(c == 'C') ans = 'G';
    if(c == 'G') ans = 'C';
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    string P = "";
    string Q = "";

    ll p, q;
    for (ll i = 0; i < N; i++)
    {
        cin >> p;
        P += to_string(p);
    }
    for (ll i = 0; i < N; i++)
    {
        cin >> q;
        Q += to_string(q);
    }

    // 昇順にソート済みの入力
    vector<int> v;
    vector<string> x;
    for (ll i = 0; i < N; i++)
    {
        v.push_back(i + 1);
    }

    do
    {
        string str = "";
        for (auto a : v)
        {
            str += to_string(a);
        }

        // cout << str << endl;
        x.push_back(str);
    } while (std::next_permutation(v.begin(), v.end()));

    auto pl = lower_bound(x.begin(), x.end(), P);
    distance(x.begin(), pl);

    auto ql = lower_bound(x.begin(), x.end(), Q);
    cout << abs(distance(x.begin(), pl) - distance(x.begin(), ql)) << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 2424
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAXB = 60;

llint solve(llint A, llint B) {
  if (A == B) {
    return 1;
  }

  int k = MAXB;
  while (k >= 0) {
    bool a = (A >> k) & 1;
    bool b = (B >> k) & 1;

    if (a == b) {
      if (a) {
        A ^= 1LL << k;
        B ^= 1LL << k;
      }
      k--;
      continue;
    } else {
      assert(b && !a);
      break;
    }
  }

  assert(k >= 0);
  llint T = 1LL << k;

  int l = k - 1;
  while (l >= 0 && ((B >> l) & 1) == 0) l--;

  llint ret = T - A;

  llint l1 = T, r1 = T + (1LL << (l + 1));
  llint l2 = T + A, r2 = 2 * T;

  if (r1 <= l2)
    ret += r1 - l1 + r2 - l2;
  else
    ret += r2 - l1;
  return ret;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  llint A, B;
  cin >> A >> B;

  cout << solve(A, B) << "\n";
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int sx, sy, tx, ty;
string s = "";

void first();
void second();

int main(){
	cin.sync_with_stdio(false);
	cin >> sx >> sy >> tx >> ty;

	first();
	second();

	cout << s << endl;

	return 0;
}

void first() {
	int dx = tx - sx, dy = ty - sy;
	rep(i, dx) {
		s += 'R';
	}
	rep(i, dy) {
		s += 'U';
	}
	rep(i, dx) {
		s += 'L';
	}
	rep(i, dy) {
		s += 'D';
	}
}

void second() {
	int dx = tx - sx, dy = ty - sy;
	s += 'D';
	rep(i, dx + 1) {
		s += 'R';
	}
	rep(i, dy + 1) {
		s += 'U';
	}
	s += "LU";
	rep(i, dx + 1) {
		s += 'L';
	}
	rep(i, dy + 1) {
		s += 'D';
	}
	s += 'R';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]=='1')
            s[i]='9';
        else
            s[i]='1';
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define N 500000
#define INF 2000000000
int count;
void merge(int S[],int n,int left,int mid,int right);
void mergeSort(int S[],int n,int left,int right);
int L[N],R[N];
int main(){
  int i,n;
  int S[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  count = 0;
  mergeSort(S,n,0,n);
  for(i=0;i<n;i++){
    if( i>0 ) printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}
void merge(int S[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i] = S[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = S[mid+i];
  }
  L[n1] = INF;
  R[n2] = INF;
  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    count++;
    if( L[i] <= R[j] ){
      S[k] = L[i];
      i++;
    }
    else{
      S[k] = R[j];
      j++;
    }
  }
}
void mergeSort(int S[],int n,int left,int right){
  int mid;
  if( left+1 < right ){
    mid = ( left+right ) / 2;
    mergeSort(S,n,left,mid);
    mergeSort(S,n,mid,right);
    merge(S,n,left,mid,right);
  }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

constexpr int MaxK = 50;
int dp[100001];

int main() {

  rep(i, 100001) dp[i] = inf;
  dp[0] = 0;

  set<int> st;
  st.insert(1);
  rep(i, 8) st.insert(pow(6LL, i + 1));
  rep(i, 7) st.insert(pow(9LL, i + 1));

  int N; cin >> N;
  rep(i, N + 1) for (auto e: st) {
    if (i + e > N) continue;
    if (dp[i] == inf) continue;
    minimize(dp[i + e], dp[i] + 1);
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 640
# abc162_b
# https://atcoder.jp/contests/abc162/tasks/abc162_b

# FizzBuzz Sum
# iが３、５で割り切れるなら　FizzBuzz
# iが３で割り切れるなら　Fizz
# iが５で割り切れるなら　Buzz
# 上記、以外はi

# FizzBuzz列のN項目までの数の和
# ３、５と３*５の時以外の数を加算していく

# 入力
n = int(input())

# 処理
sum_num = 0
for i in range(1, n + 1):
    if not i % 3 == 0 and not i % 5 == 0:
        sum_num += i

print(sum_num)


Measured memory_bytes: 9136
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;cin>>n;

  cout << "ABC" << n ;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=input()
flag=True
if s[n:n+1]!='-':
  flag=False
for i in range(n):
  if s[i]=='-':
    flag=False
for i in range(n+1,len(s)):
  if s[i]=='-':
    flag=False
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int N, T;
vector<int> c(1010);
vector<int> t(1010);

int main() {
    cin >> N >> T;
    for(int i = 0; i < N; ++i) {
        cin >> c.at(i) >> t.at(i);
    }

    int flag = 0;
    int min = 100000;
    for(int i = 0; i < N; ++i) {
        if(t.at(i) <= T) {
            if(c.at(i) < min) {
                min = c.at(i);
            }
            flag = 1;
        }
    }

    if(flag == 1) {
        cout << min << endl;
    }else {
        cout << "TLE" << endl;
    }
}

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

using namespace std;


int main(){

int e,m;

while(cin>>e,e){

int min=100000;

for(int y=0;y*y<=e;y++){
for(int z=0;z*z*z+y*y<=e;z++){
int x=e-y*y-z*z*z;

if(x>=0&&x+y*y+z*z*z==e){
if(min>x+y+z)min=x+y+z;
}
}
}
cout<<min<<endl;
}

return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        long n = Long.parseLong(sc.next());
    
        long a = 26;
        long b = 26*26;
        int c = 1;
        long d = n-1;
        while(a < n){
            d = n-a-1;
            a += b;
            b *= 26;
            c++;
        }
        
        String s = Long.toString(d, 26);
        var sb = new StringBuilder();
        for(int i = s.length(); i < c; i++){
            sb.append('a');
        }
        for(int i = 0; i < s.length(); i++){
            if(Character.isDigit(s.charAt(i))){
                char e = (char)('a' + Integer.parseInt(s.substring(i, i+1)));
                sb.append(e);
            }else{
                char e = (char)(s.charAt(i) +10);
                sb.append(e);
            }
        }
        System.out.println(sb);
    }
}

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

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair < int , int > ii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

vector <int> V;

int main( int argc , char const *argv[] ) {
        ios_base :: sync_with_stdio(false); cin.tie(NULL);
        int n , x;
        cin >> n >> x;
        for( int i = 1; i <= n; i++ ) {
                int val;
                cin >> val;
                V.push_back( val );
        }
        V.push_back( x );
        sort( V.begin() , V.end() );
        vector <int> d;
        for( int i = 1; i < V.size(); i++ ) d.push_back( V[i]-V[i-1] );
        int g = d[0];
        for( int i = 1; i < d.size(); i++ ) {
                g = __gcd( g , d[i] );
        }
        cout << g << endl;
        return 0;
}








Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n;
	sd(n);
	if(n<1000){
		printf("ABC\n");
	}
	else{
		printf("ABD\n");
	}
	return 0;
}

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

const int N = 1000;
const int INF = 0x3f3f3f3f;

int n, m, f;
char map[N][N+1];

bool legal(int x, int y, int k)
{
    return x >= 0 && x < n && y >= 0 && y < m
        && map[x][y] != 'X';
}

void input()
{
    cin >> n >> m >> f;
    for (int i = 0; i < n; i ++) {
        scanf("%s", map[i]);
    }
}

int BFS(int k)
{
    int i, j;
    int d[N][N];
    typedef pair<int, int> P;
    queue <P> q;
    for (i = 0; i < n; i ++) {
        for (j = 0; j < m; j ++) {
            d[i][j] = INF;
            if ((k == 0 && map[i][j] == 'S') || map[i][j] == '0'+k) {
                q.push(P(i, j));
                d[i][j] = 0;
                map[i][j] = '.';
            }
        }
    }

    while( q.size() ) {
        P p = q.front();
        q.pop();
        int x = p.first;
        int y = p.second;

        if (map[x][y] == INF)
            return d[x][y];

        int pos[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
        for (i = 0; i < 4; i ++) {
            int nx = x + pos[i][0];
            int ny = y + pos[i][1];
            if (legal(nx, ny, k) && d[nx][ny] == INF) {
                q.push(P(nx, ny));
                d[nx][ny] = d[x][y]+1;
                if (map[nx][ny] == '0'+k+1) {
                    return d[nx][ny];
                }
            }
        }
    }

    return INF;
}

void solve()
{
    int res = 0;
    for (int i = 0; i < f; i ++) {
        res += BFS(i);
    }
    printf("%d\n", res);
}

int main(void)
{
    input();

    solve();

    return 0;
}

Measured memory_bytes: 6104
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


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

    ll x,n;

    cin >> x >> n;

    vector<ll> p(102, 0);

    for(ll i=0; i<n; i++){
        ll a;
        cin >> a;
        p[a] = 1;
    }

    ll ans;
    for(ll i=0; i<102; i++){
        ll pos = x-i;
        if(pos>=0&&pos<102){
            if(p[pos] == 0){
               ans = pos;
               break;
            }
        }
        pos=x+i;
        if(pos>=0&&pos<102){
            if(p[pos] == 0){
               ans = pos;
               break; 
            }
        }
    }
    

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
const int INF = (1 << 28);
int n, a, b, c,l[1000];
int dfs(int k, int a1,int b1, int c1){
    if(k==n){
        return (a1!=0&&b1!=0&&c1!=0)?abs(a-a1)+abs(b-b1)+abs(c-c1):INF;
    }
    int ans1=(a1==0)?dfs(k+1,a1+l[k],b1,c1):dfs(k+1,a1+l[k],b1,c1)+10;
    int ans2=(b1==0)?dfs(k+1,a1,b1+l[k],c1):dfs(k+1,a1,b1+l[k],c1)+10;
    int ans3=(c1==0)?dfs(k+1,a1,b1,c1+l[k]):dfs(k+1,a1,b1,c1+l[k])+10;
    int ans4=dfs(k+1,a1,b1,c1);
    return min(min(ans1,ans2),min(ans3,ans4));
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a>>b>>c;
    for(int i=0;i<n;i++) cin>>l[i];
    cout<<dfs(0,0,0,0)<<"\n";
}

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

int main(){
  int X;
  cin >> X;
  int num=1e6;
  for(int a=0;a<=num;a++){
    if(a*105>X){
      break;
    }
    for(int b=0;b<=num;b++){
      if(b*104>X){
        break;
      }
      for(int c=0;c<=num;c++){
        if(c*103>X){
          break;
        }
        for(int d=0;d<=num;d++){
          if(d*102>X){
            break;
          }
          for(int e=0;e<=num;e++){
            if(e*101>X){
              break;
            }
            for(int f=0;f<=num;f++){
              if(f*100>X){
                break;
              }
              if(a*105+b*104+c*103+d*102+e*101+f*100==X){
                cout << 1 << endl;
                return 0;
              }
            }
          }
        }
      }
    }
  }
  cout << 0 << endl;
  return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

ll n;
ll ans_color = 1000000;
ll ans_node = 1000000;
vector<vector<ll>> v(111);
vector<pair<ll,ll>> edge;

void seica_edge(ll num){
	
	queue<pair<pair<ll,ll>,ll>> q;
	ll depth = 0;
	ll max_sizuu[1111] = {};
	max_sizuu[0] = 2;
	q.push(MP(MP(edge[num].FI,edge[num].SE),1));
	q.push(MP(MP(edge[num].SE,edge[num].FI),1));
	
	while(!q.empty()){
		auto now = q.front();q.pop();
		ll node = now.FI.FI;
		ll prev = now.FI.SE;
		ll dep = now.SE;
		ll cou = 0;
		depth = max(depth,dep);
		REP(i,v[node].size()){
			ll aite = v[node][i];
			if(aite == prev)continue;
			cou++;
			q.push(MP(MP(aite,node),dep+1));
		}
		max_sizuu[dep] = max(max_sizuu[dep],cou);
	}
	ll tmp = 1;
	for(int i = 0;i < 1000;i++){
		if(max_sizuu[i] == 0)break;
		tmp *= max_sizuu[i];
	}
	
	if(ans_color > depth){
		ans_color = depth;
		ans_node = tmp;
	}
	else if(ans_color == depth){
		ans_node = min(ans_node,tmp);
	}
	
}

void seica_node(ll num){
		
	queue<pair<pair<ll,ll>,ll>> q;
	ll depth = 0;
	ll max_sizuu[1111] = {};
	max_sizuu[1] = 2;
	q.push(MP(MP(num,-1),1));
	
	while(!q.empty()){
		auto now = q.front();q.pop();
		ll node = now.FI.FI;
		ll prev = now.FI.SE;
		ll dep = now.SE;
		ll cou = 0;
		depth = max(depth,dep);
		REP(i,v[node].size()){
			ll aite = v[node][i];
			if(aite == prev)continue;
			cou++;
			q.push(MP(MP(aite,node),dep+1));
		}
		max_sizuu[dep] = max(max_sizuu[dep],cou);
	}
	ll tmp = 1;
	for(ll i = 1;i < 1000;i++){
		if(max_sizuu[i] == 0)break;
		tmp *= max_sizuu[i];
	}
	
	if(ans_color > depth){
		ans_color = depth;
		ans_node = tmp;
	}
	else if(ans_color == depth){
		ans_node = min(ans_node,tmp);
	}
	
}

int main(){
	cin >> n;
	REP(i,n-1){
		int a,b;
		cin >> a >> b;
		a--;b--;
		edge.PB(MP(a,b));
		v[a].PB(b);
		v[b].PB(a);
	}
	
	REP(i,n-1){
		seica_edge(i);
	}
	REP(i,n){
		seica_node(i);
	}
	
	cout << ans_color << ' ' << ans_node << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

ll _find(string &str){
    
    for(ll i=0;i<(ll)str.length();i++){
        if(str[i]!='1'){return i;}
    }
    return -1;
}

void solve(){
    string str;
    ll k;
    cin>>str;
    cin>>k;
    
    ll p=_find(str);
    if(p==-1){
        cout<<1<<endl;
        return ;
    }
    else{
        k--;
        if(k>=p){
            cout<<str[p];
        }
        else{
            cout<<1;
        }
    }
}

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

Measured memory_bytes: 3592