akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
		int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        // 出力
        System.out.println(Math.min(n*a, b));

    }

}


Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(){ int n, d, ans = 0;
	cin >> n >> d;
	for (int i=0; i<n; i++){ long long a, b;
		cin >> a >> b;
		if(sqrt(a*a + b*b) <= d){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
import sys
H,W=map(int,input().split())
s=[]
bla=0
whi=0
maze=[["" for i in range(W)] for j in range(H)]
for i in range(H):
    s.append(input())
for i in range(H):
    for j in range(W):
        if(s[i][j]=="#"):
            bla+=1
            maze[i][j]="#"
        else:
            whi+=1
            maze[i][j]="."

def clear_maze(sx,sy,gx,gy,maze,W,H):
    INF=100000000
    distance=[[INF for i in range(W)] for j in range(H)]
    
    def bfs():
        testx=[1,0,-1,0]
        testy=[0,1,0,-1]
        queue=[]
        
        queue.insert(0,(sy,sx))
        
        distance[sy][sx]=0
        count=0
        while len(queue):
            if(count>100000000):
                return -1
            count+=1
            x,y=queue.pop()
            
            if(x==gx and y==gy):
                break
            
            for i in range(0,4):
                nx,ny=x+testx[i],y+testy[i]
                
                if(0<=nx and nx<W and 0<=ny and ny<H):
                    if(maze[ny][nx]!="#"):
                        if(distance[ny][nx]==INF):
                            queue.insert(0,(nx,ny))
                            distance[ny][nx]=distance[y][x]+1
        if(distance[gy][gx]==INF):
            return -1
        else:
            return distance[gy][gx]
        
    return bfs()

area=W*H
step=clear_maze(0,0,W-1,H-1,maze,W,H)
if(step==-1):
    print(-1)
elif(maze[0][0]=="#"):
    print(-1)
elif(maze[H-1][W-1]=="#"):
    print(-1)
else:
    score=area-step-1-bla
    print(score)

Measured memory_bytes: 3192
n=parse(Int,readline())
a=map(x->parse(Int,x),split(readline()))
function xor(a,b)
	a+b-2*(a&b)
end
s=0
f=1
sum=0
x=0
for i=1:n
	sum+=a[i]
	x=xor(x,a[i])
	while sum!=x
		sum-=a[f]
		x=xor(x,a[f])
		f+=1
	end
	s+=i-f+1
end
println(s)


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

using namespace std;

#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)

int main(){
    int n,m,ans=0;
    scanf("%d %d",&n,&m);
    int k[15][15];
    int p[15]={0};
    rep(i,15) rep(j,15) k[i][j]=0;
    rep(i,m) {
        sc1(k[i][0]);
        rep(j,k[i][0]) sc1(k[i][j+1]);
    }
    rep(i,m) sc1(p[i]);
    rep(i,pow(2,n)) {
        int x=i;
        int s[15]={0};
        rep(j,n) {
            if (x&1)  s[j]=1;
            x=x>>1;
        }
        int chk=0;
        rep(j,m) {
            int cnt=0;
            rep(a,k[j][0]) if (s[k[j][a+1]-1]==1) cnt=(cnt+1)%2;
            if (cnt==p[j]) chk++;
        }
        if (chk==m) ans++;
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 4156
//
//  main.cpp
//  Problem Code
//
//  Created by Algo张伯威 on 2020/4/24.
//  Copyright © 2020 Algo张伯威. All rights reserved.
//

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;

int s[20];
int a[60], b[60], c[60], d[60];
int sum, n, m, q;

void check() {
    int now = 0;
    for(int i = 0; i < q; i++) {
        //printf("%d %d %d %d\n", a[i], b[i], c[i], s[b[i]] - s[a[i]]);
        if(s[b[i]] - s[a[i]] == c[i]) {
            now += d[i];
        }
    }
    sum = max(sum, now);
    return;
}

void dfs(int now, int val) {
    s[now] = val;
    if(now == n) {
        check();
        return;
    }
    for(int i = val; i <= m; i++) {
        dfs(now + 1, i);
    }
}

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for(int i = 0; i < q; i++) {
        scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
    }
    dfs(1, 1);
    printf("%d\n", sum);
    
    return 0;
}






















Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=1002;

inline void apn(int &a,int b){
	if(a>b)a=b;
}

inline char get_c(){
	static char buf[20000],*h,*t;
	if(h==t){
		t=(h=buf)+fread(buf,1,20000,stdin);
	}
	return h==t?EOF:*h++;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=get_c())>'9'||c<'0');
	while(x=x*10+c-48,(c=get_c())>='0'&&c<='9');
	return x;
}

int main(){
	static int fa[N],hx[N],dp[N][5002];
	int n=nxi();
	for(int i=2;i<=n;++i) fa[i]=nxi();
	for(int i=1;i<=n;++i) hx[i]=nxi();

	for(int x=n;x;--x){
		int y=fa[x];
		for(int i=hx[y];i>=0;--i){
			int p=dp[y][i];
			dp[y][i]=1e5;
			if(hx[x]<=i){
				dp[y][i]=(hx[x]?dp[y][i-hx[x]]:p)+dp[x][hx[x]];
			}
			if(dp[x][hx[x]]<=i){
				apn(dp[y][i],(dp[x][hx[x]]?dp[y][i-dp[x][hx[x]]]:p)+hx[x]);
			}
		}
	}
	puts(dp[1][hx[1]]>=1e5?"IMPOSSIBLE":"POSSIBLE");
	return 0;
}

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

int main(){
    int n, x;

    while(1){
        cin >> n >> x;
        // if (n == 0 && x == 0) break;
        if (n == 0 && x == 0) break;
        int cnt = 0;
        for (int i = 1; i <= n; ++i){
            for (int j = i + 1; j <= n; ++j){
                for (int k = j + 1; k <= n; ++k){
                    if (i + j + k == x) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i, a) for(int i = 0; i < (int) a; i++)
#define all(v) v.begin(), v.end()
#define f first
#define s second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

struct FT{
	int n;
	vector<ll> v;
	FT(int n){
		this->n = n;
		v.assign(n+2, 0);
	}
	ll operator[](int i){
		ll resp = 0;
		for(; i > 0; i-=(i&(-i))) resp += v[i];
		return resp;
	}
	void add(int i, ll x){
		for(; i <= n; i+=(i&(-i))) v[i]+=x;
	}
};

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

	ll n, d, a; cin >> n >> d >> a;
	vector<pair<ll, ll>> v(n);
	FOR(i, n) cin >> v[i].f >> v[i].s;

	sort(all(v));

	FT b(n);

	ll resp = 0;
	for(int i = 0; i < n; i++){
		if(v[i].s >= b[i+1]){
			ll altAtual = v[i].s - b[i+1];
			int maxi = distance(v.begin(), lower_bound(all(v), make_pair(v[i].f+2*d, (long long) -1)));

          	if(maxi < n && v[maxi].f > v[i].f+2*d) maxi--;
			ll bombas = altAtual/a;
			if(altAtual%a > 0) bombas++;
			resp+=bombas;

			b.add(i+1, bombas*a); b.add(maxi+2, -bombas*a);
		}

	}

	cout << resp << '\n';

	return 0;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main()
{
	int a, sum=0, max=0;;
	cin>>a;
	int s[a];
	for(int i=0; i<a; i++)
	{
		cin>>s[i];
		if(i>0 && s[i]<=s[i-1]) sum++;
		else sum=0;
		if(sum>=max) max=sum;
	}
	cout<<max;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vikas.k
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        private final long MAXN = 50;

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long[] p = new long[51];
            long[] u = new long[51];
            long K = in.nextLong();
            for (int i = 0; i < MAXN; i++) {
                u[i] = K / MAXN;
                p[i] = MAXN - 1;
            }
            for (int i = 0; i < K % MAXN; i++) u[i]++;
            for (int i = 0; i < MAXN; i++) {
                p[i] += u[i] * MAXN;
                for (int j = 0; j < MAXN; j++) if (i != j) p[j] -= u[i];
            }

            out.println(MAXN);
            for (int i = 0; i < MAXN; i++) {
                out.print(p[i] + " ");
            }
        }

    }

    static class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int s;
  cin>>s;
  int a[1000];
  a[1]=s;
  for(int i=2;i<1000;i++){
    if(a[i-1]%2==0){
      a[i]=a[i-1]/2;
    }else{
      a[i]=3*a[i-1]+1;
    }
  }
  for(int i=1;i<1000;i++){
    for(int j=i+1;j<1000;j++){
      if(a[i]==a[j]){
        cout<<j;
        return 0;
      }
    }
  }




}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

ll p(ll a,ll n) {
    if (n <= 0)return 1;
    return a * p(a - 1, n - 1) % mod;
}
ll kaijo(ll a) {
    if (a <= 0)return 1;
    return a * kaijo(a - 1) % mod;
}

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

    int n;
    cin >> n;
    vector<ll> a(n);
    double ave = 0;
    FOR(i, 0, n) {
        cin >> a[i];
        ave += a[i];
    }
    ave /= n;

    int ans = -1;
    double m = INF;
    FOR(i, 0, n)if (chmin(m, abs(a[i] - ave))) {
        ans = i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int S=sc.nextInt();
    int h=S/3600;
    int m=S%3600/60;
    int s=S%60;
    System.out.printf("%d:%d:%d\n",h,m,s);
  }
}



Measured memory_bytes: 26352
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            sum = 500 * i + 100 * j + 50 * k
            if sum == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		int x;
		int count;

		while (sc.hasNext()) {
			a = sc.nextInt();
			b = sc.nextInt();
			x = a + b;
			count = 0;
			while (0 < x) {
				count++;
				x = x / 10;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

std::size_t count(const std::string& s, const std::string& t)
{
  std::size_t result = 0;
  for (std::size_t i = 0; i < t.size(); ++i) {
    if (s[i] != t[i]) ++result;
  }
  return result;
}

std::size_t solve(const std::string& s, const std::string& t)
{
  std::size_t result = t.size();
  for (std::size_t i = t.size(); i <= s.size(); ++i) {
    result = std::min(result, count(s.substr(i - t.size(), t.size()), t));
  }
  return result;
}

int main()
{
  std::string s, t;
  std::cin >> s >> t;

  std::cout << std::setprecision(20);
  std::cout << solve(s, t) << std::endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf();

int main() {
    string S;
    ll K;
    cin >> S >> K;
    int i = 0;
    while (i < K) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
        i++;
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
const int inf = 0x3f3f3f3f;
const ll inff = 0x7ffffffffff;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
//head
const int N = 5010;
ll n, p[N];
ll c[N], k, ans = -inff;
ll f[N], g[N];
void go(ll now, ll st, ll as) {
	f[now] = st; g[now] = as;
	ans = max(ans, as);
	if(st == k) return;
	if(f[p[now]]) {	
		ll tmp = st + 1 - f[p[now]];
		ll val = as + c[p[now]] - g[p[now]];
		ans = max(ans, as + c[p[now]]);
		if(val <= 0) {
			ll le = min(tmp, (k - (st + 1)));
			ll nn = p[now];
			ll res = as + c[p[now]];
			while(le) {
				ans = max(ans, res);
				res += c[p[nn]];
				nn = p[nn];
				le--;
			}
		}
		if(val > 0) {
			ll le = (k - (st + 1));
			ll res = as + c[p[now]];
			ll nn = p[now];
			res += max(ll(0), (le / tmp - 1)) * val;
			ans = max(ans, res);
			le = le - max(ll(0), (le / tmp - 1)) * tmp;
			while(le) {
				res += c[p[nn]];
				ans = max(ans, res);
				nn = p[nn];
				le--;
			}
		}
		return;
	}
	go(p[now], st + 1, as + c[p[now]]);
}
int main() {
	n = read(), k = read();
	rep(i, 1, n) {
		p[i] = read();
	}
	rep(i, 1, n) {
		c[i] = read();
	}
	rep(i, 1, n) {
		rep(j, 0, n) f[j] = g[j] = 0;
		go(p[i], 1, c[p[i]]);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3868
#include<stdio.h>
#include<string.h>
int main(void){
  char s[100001];
  scanf("%s",s);
  long l=strlen(s);

  while(1){
    if(strncmp(s+l-5,"dream",5)==0){
      s[l-5]='\0';
      l-=5;
    }else if(strncmp(s+l-7,"dreamer",7)==0){
      s[l-7]='\0';
      l-=7;
    }else if(strncmp(s+l-5,"erase",5)==0){
      s[l-5]='\0';
      l-=5;
    }else if(strncmp(s+l-6,"eraser",6)==0){
      s[l-6]='\0';
      l-=6;
    }else{
      break;
    }
  }
    if(l==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}



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

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    int ans;
    if (a==1 && b==2) {
        ans = 3;
    } else if (a==1 && b==3) {
        ans = 2;
    } else if (a==2 && b==1) {
        ans = 3;
    } else if (a==2 && b==3) {
        ans = 1;
    } else if (a==3 && b==1) {
        ans = 2;
    } else if (a==3 && b==2) {
        ans = 1;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> arr(N+1);
  arr.at(0) = 2;
  arr.at(1) = 1;
  for (int i = 2; i < N + 1; i++) {
    arr.at(i) = arr.at(i-1) + arr.at(i-2);
  }
  cout << arr.at(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N, M, K;
    cin >> N >> M >> K;

    for(int a = 0; a <= N; a++){
        for(int b = 0; b <= M; b++){
            if(a * M + b * N - 2 * a * b == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
import Data.List
toInt::String->Int
toInt = read
isPrime::Int->Bool
isPrime 1 = False
isPrime 2 = True
isPrime 3 = True
isPrime n = foldr (\x y->mod n x /= 0 && y) True (2:[3,5..m])
  where
    m = ((\x->if odd x then x else x-1).floor.sqrt.fromIntegral) n
primeNum::[] Int->Int
primeNum [] = 0
primeNum (x:xs) = (if isPrime x then 1 else 0) + primeNum xs
main = do
  getLine
  getContents >>=
    print.primeNum.(map toInt).lines


Measured memory_bytes: 5612
#include <cstdio>

using namespace std;

int f[10000];

int main()
{
	int num;
	float weight,height;
	int i = 0;
	
	while(scanf("%d,%f,%f", &num, &weight, &height) != EOF){
		float bmi = weight / (height * height);
		
		if(bmi >= 25.0){
			f[i] = num;
			i++;
		}
	}
	
	for(int i = 0; f[i] != 0; i++){
		printf("%d\n", f[i]);
	}
	
	return(0);
}

Measured memory_bytes: 1052
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int m,k;
signed main(){
    I(m); I(k);
    int amax = 1LL << m;
    if (m == 0){
        if (k == 0){
            cout << "0 0" << endl;
        } else {
            cout << "-1" << endl;
        }
    } else if (m == 1){
        if (k == 0){
            cout << "0 0 1 1" << endl;
        } else {
            cout << "-1" << endl;
        }
    } else if (k >= amax) {
        cout << -1 << endl;
    } else {
        printf("%lld ",k);
        REP(i,amax){
            if (i==k) continue;
            printf("%lld ", i);
        }
        printf("%lld ",k);
        REPN(i,amax){
            if (i==k) continue;
            printf("%lld ", i); 
        }
    }
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int m=sc.nextInt();
			int n1=sc.nextInt();
			int n2=sc.nextInt();
			if((n1==0&&n2==0)&&m==0) break;
			int[] data = new int[m];
			for(int i=0;i<m;++i){
				data[i]=sc.nextInt();
			}
			int num=n2-n1+1;
			int[] data2 = new int[num];
			for(int i=0;i<num;++i){
				data2[i]=data[n1-1+i]-data[n1+i];
			}
			int max=0,ans=0;
			for(int i=0;i<num;++i){
				if(max<=data2[i]){
					max=data2[i]; ans=i+n1;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 57052
import itertools


if __name__ == "__main__":
    matching_word = input()

    matching_word = matching_word.lower()

    text = []

    while True:
        line = input()

        if line == 'END_OF_TEXT':
            break

        text.append(line)

    words = list(map(lambda word: word.lower(), itertools.chain.from_iterable(map(lambda line: line.split(), text))))

    num_occurrences = words.count(matching_word)

    print(num_occurrences)



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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_N = 13;
const int n = MAX_N;
const int m = 5;
int card[MAX_N];
vi x(m);

string judge(vi num)
{
  if(num[0] == 4) return "four card";
  if(num[0] == 3 && num[1] == 2) return "full house" ;
  if(num[0] == 1 && x[4] - x[0] == 4) return "straight";
  if(num[0] == 1 && x[0] == 0 && x[1] == 9 && x[4] == 12) return "straight";
  if(num[0] == 3) return "three card";
  if(num[0] == 2 && num[1] == 2) return "two pair";
  if(num[0] == 2) return "one pair";
  return "null";
}

int main()
{
  rep(i, n) card[i] = i;

  while(~scanf("%d,%d,%d,%d,%d", &x[0], &x[1], &x[2], &x[3], &x[4], &x[5])){
    vi num(MAX_N);
    rep(i, m) x[i] -= 1;
    rep(i, m) num[x[i]] += 1;
    sort(ALL(num), greater<int>());
    sort(ALL(x));
    cout << judge(num) << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
l = {}
for i in ['a', 'b', 'c']:
    l[i] = input()

def func(turn):
    if len(l[turn]) == 0:
        return turn
    
    else:
        next = l[turn][0]
        l[turn] = l[turn][1:]

        return func(next)

print(func('a').upper())
    

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	int r,g,b;
	cin>>r>>g>>b;
	if((r*100+g*10+b)%4==0) puts("YES");
	else puts("NO");

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

int main() {
    ll n,x,y,z;
    cin>>n;
    vl dp(3,0);
    for(int i=0;i<n;i++){
        vl ndp(3,0),c(3);
        for(int j=0;j<3;j++) cin>>c[j];
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    ndp[k] = max( ndp[k] , dp[j] + c[k] );
                }
            }
        }
         dp = ndp ;
    }
       cout<<max({dp[0],dp[1],dp[2]});
    return 0;
}

Measured memory_bytes: 256
def main():
    n,x,y = map(int,input().split())
    dst = {}
    for i in range(1,n):
        dst[i]=0
    for i in range(1,n):
        for j in range(i+1,n+1):
            d = min(j-i,abs(x-i)+1+abs(y-j))
            dst[d]+=1
    for i in range(1,n):
        print(dst[i])

if __name__ == "__main__":
    main()

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

int main()
{
	int d;
	cin>>d;
	if(d==22)
	  cout<<"Christmas Eve Eve Eve"<<endl;
	else if(d==23)
	  cout<<"Christmas Eve Eve"<<endl;
	else if(d==24)
	  cout<<"Christmas Eve"<<endl;
	else
	  cout<<"Christmas"<<endl;
	
	return 0;
}

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

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

    int cnt = 1;
    vector<int> num;
    num.push_back(s);
    while(true){
        if(s % 2 == 0){
            s /= 2;
        }
        else{
            s = (3 * s) + 1;
        }
        for(int i = 0; i < num.size(); i++){
            if(num[i] == s){
                cout << cnt + 1 << endl;
                return 0;
            }
        }
        num.push_back(s);
        cnt++;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    var Array(a, b, c, d) = in.readLine().split("\\s+").map(_.toInt)

    while (true) {
      c -= b
      if (c <= 0) {
        out.println("Yes")
        out.flush()
        return
      }
      a -= d
      if (a <= 0) {
        out.println("No")
        out.flush()
        return
      }
    }
  }
}


Measured memory_bytes: 54676
#include<bits/stdc++.h>
using namespace std;
template<typename T> inline T& Max(T &x,const T &y) {return x<y?(x=y):x;}
inline int read() {
	int x=0,f=1;
	char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=205;
int n,a[maxn][maxn];
int que[maxn],ql,qr,d[maxn];
int work(int s) {
	que[ql=qr=1]=s;
	fill(d+1,d+n+1,0);
	d[s]=1;
	while (ql<=qr) {
		int x=que[ql++];
		for (int i=1;i<=n;++i) if (a[x][i]) {
			if (!d[i]) {
				d[i]=d[x]+1;
				que[++qr]=i;
				continue;
			}
			if (abs(d[x]-d[i])==1) continue; else return -1;
		}
	}
	return *max_element(d+1,d+n+1);
}
int main() {
	n=read();
	for (int i=1;i<=n;++i) {
		static char s[maxn];
		scanf("%s",s+1);
		for (int j=1;j<=n;++j) a[i][j]=(s[j]=='1');
	}
	int ans(-1);
	for (int i=1;i<=n;++i) {
		int tmp=work(i);
		Max(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
MOD = 10**9+7
f = [1]
for i in range(10**5):
    f.append(f[-1] * (i+1) % MOD)

def nCr(n,r,mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

ans = 0
for i in range(N-K+1):
    ans += (A[-i-1] - A[i]) * nCr(N-1-i, K-1)
    ans %= MOD
print(ans)


Measured memory_bytes: 18544
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int num1 = sc.nextInt();
          int num2 = sc.nextInt();
          int num3 = sc.nextInt();
          System.out.println(num3);
          System.out.println(num1);
          System.out.println(num2);
          }
    }

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<double> ma(n);
	REP(i,n) cin >> ma[i];
	int f = 1;
  float ans = 0;
	REP(i,n) {
    ans += 1.0/ma[i];
  }
  cout << setprecision(16) << 1.0/ans << endl;

}


Measured memory_bytes: 3800
def main():
    n = int(input())
    sticks = sorted(list(map(int, input().split())))

    count = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                l1, l2, l3 = sticks[i], sticks[j], sticks[k]
                if l1 != l2 and l1 != l3 and l2 != l3:
                    if l1 + l2 > l3:
                        count += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
gets
S=gets.chop
s1=s2=0
S.chars do |c|
  s2+=1 if c=="("
  s2-=1 if c==")"
  next if 0<=s2
  s1+=1
  s2+=1
end
puts s1.times.map{"("}*"" + S + s2.times.map{")"}*""


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

const int N = 1e5+4, LOGN = 20;
vector <pair<int,int> > g[N];
int dp[N][LOGN], D[N];
long long dis[N];

void dfs(int v,int p){
	D[v] = D[p] + 1;
	dp[v][0] = p;
	for (auto it:g[v]){
		if (it.first!=p) {
			dis[it.first] = dis[v] + it.second;
			dfs(it.first, v);
		}
	}
}
int lca(int v, int u){
	if (D[v] < D[u]) swap(u,v);
	int d = D[v] - D[u];
	for (int i = 0; i < LOGN; i++) if (d & (1<<i)) v = dp[v][i];
	if (u == v) return v;
	for (int i = LOGN - 1; i >= 0; i--){
		if (dp[v][i] != dp[u][i]) v = dp[v][i], u = dp[u][i];
	}
	return dp[v][0];
}


long long dist(int u, int v){
	int LCA = lca(u, v);
	return dis[v] + dis[u];
}


int main(){
	int n; cin >> n;
	for (int i = 0; i < n -1 ; i++){
		int u, v, w; cin >> u >> v >> w;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	int q, k; cin >> q >> k;
	dfs(k,0);
	for (int i = 1; i < LOGN; i++)
		for (int j = 1; j <= n; j++) dp[j][i] = dp[dp[j][i-1]][i-1];
	while (q--){
		int u, v; scanf("%d%d",&u,&v);
		int LCA = lca(u,v);
		long long ans = dist(u,v);
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 20992
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

typedef vector<long long> vi;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') ans=3;
    else if(s[0]=='R' && s[1]=='R') ans=2;
    else if(s[1]=='R'&& s[2]=='R') ans=2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') ans=1;
    else ans=0;
    cout<<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
        using namespace std;
        #define int long long

        signed main() {
        int n,a0;bool t=false;
        cin>>n;
       vector<int> a;
        for(int i=0;i<n;i++){cin>>a0;a.push_back(a0);if(a0>0)t=true;}
        if(!t){
            int ans=a[0];
            for(int i=1;i<a.size();i++)ans=max(ans,a[i]);
            cout<<ans<<endl;
            cout<<n-1<<endl;
            while(a.size()!=1){
                if(a[0]!=ans){
                    cout<<1<<endl;
                    a.erase(a.begin());
                }else{
                    cout<<a.size()<<endl;
                    a.pop_back();

                }
            }
            return 0;
        }
        int x=0,y=0,xn=0,yn=0;vector<int> an;
        for(int i=0;i<n;i++){
            if(i%2){
                if(a[i]>0){
                    y+=a[i];
                    yn++;
                }
          
            }
            else{
                if(a[i]>0){
                    x+=a[i];
                    xn++;
                }
            } 
        }
        if(x<y){
            an.push_back(1);
            a.erase(a.begin());
        }
        while(a[0]<=0){
            an.push_back(1);
            an.push_back(1);
            a.erase(a.begin());
            a.erase(a.begin());
        }
        while(true){
            t=true;
            for(auto i=a.begin();i!=a.end();i+=2){
                if(*i<=0){
                    an.push_back(signed(i-a.begin()+1));
                    i=a.erase(i);
                    if(i!=a.end())a.erase(i);
                    t=false;
                    break;
                }
                if((i+1)==a.end())break;
            }
            if(t)break;
        }
        if(a.size()%2==0){
            an.push_back(a.size());
            a.pop_back();
        }
        while(a.size()!=1){
            an.push_back(2);
            a.erase(a.begin()+1);a.erase(a.begin()+1);
        }
        cout<<max(x,y)<<endl<<an.size()<<endl;
        for(int i=0;i<an.size();i++)cout<<an[i]<<endl;



        }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double a, b, h, m; cin >> a >> b >> h >> m;
    double pi = 3.14159265359;
    h = (h*30+m*30/60.0)*pi/180;
    m = m*6*pi/180;
    // cout << h << endl;
    // cout << m << endl;
    // cout << 2.0*pi << endl;
    double rad = h-m;
    if (rad < 0) rad = m-h;
    double tmp = a*a + b*b - 2*a*b*cos(rad);
    printf("%.11lf\n", sqrt(tmp));

    return 0;
}

Measured memory_bytes: 4228
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=105;
int n,a[maxn],f[maxn][2];
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  f[1][1]=1; f[1][0]=0;
  for(int i=2;i<=n;i++){
    f[i][1]=min(f[i-1][0],f[i-1][1])+1;
    f[i][0]=f[i-1][1];
    if(a[i-1]!=a[i]) f[i][0]=min(f[i][0],f[i-1][0]);
  }
  printf("%d\n",min(f[n][0],f[n][1]));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n, k, a[1005];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> k;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	ll sum = 0;
	for(ll i = 0; i < k; i++){
		sum += a[i];
	}
	cout << sum << '\n';
}


Measured memory_bytes: 3652
#define ll long long
#define pb push_back
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ll pay,s=0,c=100;
    cin>>pay;
    while(pay>c)
    {

        c=c+c/100;
        s++;


    }
cout<<s;

}


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
template <typename T> istream& operator>>(istream& i, vector<T>& o) { rep(j, o.size()) i >> o[j]; return i;}

const int tres = 4, vres = 4;
vector<int> dp(20010*tres), lim(20010*tres);
int main(void) {
    int n; cin >> n;
    vector<int> t(n), v(n); cin >> t >> v;
    rep(i, n) v[i] *= vres, t[i] *= tres;
    int s = 0;
    rep(i, n) {
        repi(j, s, s+t[i]) 
            lim[j] = v[i];
        s += t[i];
    }
    
    rep(_, 210*vres) repi(i, 1,dp.size()) 
        if (dp[i] - dp[i+1] <= 0 && dp[i] - dp[i-1] <= 0 && dp[i]+1 <= lim[i] && dp[i]+1 <= lim[i-1])
            dp[i]++;

    double ret = 0;
    rep(i, dp.size()-1) 
        ret += (dp[i] + dp[i+1]) / (double)vres * (1.0 / (double(tres))) / 2.0;

    cout << setprecision(40) << ret << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,vis[15][15][15],ans,x;
string s;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>s;
	REP(i,SZ(s)){
		x=s[i]-'0';
		REP(j,10)REP(k,10)if(vis[j][k][10])vis[j][k][x]=1;
		REP(j,10)if(vis[j][10][10])vis[j][x][10]=1;
		vis[x][10][10]=1;
	}
	REP(i,10)REP(j,10)REP(k,10)if(vis[i][j][k])ans++;
	cout<<ans<<"\n";
	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = 1e18;

// Greatest Common Divisor
ll gcd(ll a, ll b)
{
  while (b != 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

int main(int argc, char* argv[])
{
  int N, A;
  std::cin >> N >> A;

  std::cout << N * N - A  << std::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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// x^n in mod
ll modpow(ll x, ll n, ll mod){
  if(n==0) return 1;

  if(n%2==0){
    return modpow(x*x%mod, n/2, mod) % mod;
  }else{
    return x * modpow(x, (n-1), mod) % mod;
  }
}

int main(){
  ll m,n;cin>>m>>n;
  cout<<modpow(m, n, MOD)<<endl;

  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
long long H,W,K; cin>>H>>W>>K;
long long counter=0;
long long counter1=0;
if(H+W<=K){
cout<<0<<" "<<0<<endl;}
else if(H<=K){
counter=H+W-K;
cout<<0<<" "<<counter<<endl;}
else{
counter=H-K;
cout<<counter<<" "<<W<<endl;}}


Measured memory_bytes: 256
str = gets.split
N,K,S = str[0].to_i, str[1].to_i, str[2].to_i
a = 0

for i in 1..K do
    print S
    print " "
end
if S == 10**9
    a = 1
else
    a = S+1
end
for i in K+1..N do
    print a
    print " "
end
puts

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const long double eps=1e-60;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=1,cnt=0,w=0;
    rep(i,n){
        while(w<n){
            cnt++;
            w++;
            if(cnt*2-1>v[w-1])break;
        }
        ans=ans*cnt%mod;
        cnt--;
    }
    out(ans);
}

Measured memory_bytes: 1024
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    S = SI()
    K = I()
    ans = "1"
    for i,s in enumerate(S,start=1):
        if s!="1":
            ans = s
            break
        if i==K:
            ans = s
            break
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

bool BFS(vector<vector<bool>> temp_graph, int N)
{
  std::queue<int> enter_que;
  vector<bool> is_entered(N, false);
  int count = 0;
  enter_que.push(0);

  while (!enter_que.empty())
  {
    int room = enter_que.front();
    enter_que.pop();
    if (!is_entered[room])
    {
      is_entered[room] = true;
      count++;
    }
    rep(j, N)
    {
      if (temp_graph[room][j] && !is_entered[j])
        enter_que.push(j);
    }
  }

  if (count == N)
    return true;
  return false;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> graph(N, vector<bool>(N, false));
  vector<pair<int, int>> edge(M);

  rep(i, M)
  {
    int a, b;
    cin >> a >> b;
    graph[a - 1][b - 1] = true;
    graph[b - 1][a - 1] = true;
    edge[i] = make_pair(a - 1, b - 1);
  }

  int ans = 0;
  rep(i, M)
  {
    vector<vector<bool>> temp_graph = graph;
    temp_graph[edge[i].first][edge[i].second] = false;
    temp_graph[edge[i].second][edge[i].first] = false;
    if (!BFS(temp_graph, N))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
const vi tbl = {1, 1, 2, 6, 24, 120, 720, 5040};

int main(void){
    int n;
    cin >> n;
    vi P(n), Q(n);
    for(int &p : P) cin >> p;
    for(int &q : Q) cin >> q;
    int p = 0, q = 0;
    for(int i=1; i<n; i++){
        p += (P[i-1]-1)*tbl[n-i];
        q += (Q[i-1]-1)*tbl[n-i];
        for(int j=i; j<n; j++){
            if(P[j]>P[i-1]) P[j]--;
            if(Q[j]>Q[i-1]) Q[j]--;
        }
    }
    cout << (p>q?p-q:q-p) << '\n';
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1<<22, mod = 1e9 + 7;
int fact[maxn], inv[maxn];
void pre() {
	for(int i = 0; i < maxn; i++)
		if(i < 2) fact[i] = inv[i] = 1;
		else fact[i] = i, inv[i] = mod - (mod/i)*1ll*inv[mod%i]%mod;
	for(int i = 1; i < maxn; i++)
		fact[i] = fact[i]*1ll*fact[i-1]%mod,
		inv[i] = inv[i]*1ll*inv[i-1]%mod;
}
int bp(int a, int p) {
	int r = 1;
	while(p) {
		if(p&1) r = r*1ll*a%mod;
		a = a*1ll*a%mod, p>>=1;
	}
	return r;
}
int nck(int i, int j) {
	if(i < j || j < 0) return 0;
	int t = fact[i]*1ll*inv[j]%mod;
	return t*1ll*inv[i-j]%mod;
}
int get(int i, int j) {
	int t = bp(25, i-j);
	return t*1ll*nck(i, j)%mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	pre();
	int ans = 0, n, k;
	string s;
	cin >> k >> s;
	n = s.size();
	for(int i = n; i <= n+k; i++) ans = (ans + get(n+k, i))%mod;
	cout << ans;
	return 0;
}
//cacyaa
//128 + 2 + 128*


Measured memory_bytes: 37020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    ll a,b,c;
    scanf("%lld %lld.%lld", &a, &b, &c);
    cout << a*(b*100+c)/100;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<ll> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

  unordered_map<char, int> mp;
  vector<vector<int>> vv(3, vector<int> (n+1));
  vv[0][0] = 0;
  vv[1][0] = 0;
  vv[2][0] = 0;
  rep(i, 0, n){
    mp[s[i]]++;
    if(s[i] == 'R'){
      vv[0][i+1] = vv[0][i] + 1;
    }else{
      vv[0][i+1] = vv[0][i];
    }
    if(s[i] == 'G'){
      vv[1][i+1] = vv[1][i] + 1;
    }else{
      vv[1][i+1] = vv[1][i];
    }
    if(s[i] == 'B'){
      vv[2][i+1] = vv[2][i] + 1;
    }else{
      vv[2][i+1] = vv[2][i];
    }
  }
  long long ans = 0;
  rep(i, 0, n){
    rep(j, i+1, n){
      if (s[i] == s[j]) continue;

      if(s[i] != 'R' && s[j] != 'R'){
        ans += vv[0][n] - vv[0][j];
        if(2 * j - i > n) continue;
        if(s[2 * j - i] == 'R') ans--;
      }
      if(s[i] != 'G' && s[j] != 'G'){
        ans += vv[1][n] - vv[1][j];
        if(2 * j - i > n) continue;
        if(s[2 * j - i] == 'G') ans--;
      }
      if(s[i] != 'B' && s[j] != 'B'){
        ans += vv[2][n] - vv[2][j];
        if(2 * j - i > n) continue;
        if(s[2 * j - i] == 'B') ans--;
      }
    }
  }

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

Measured memory_bytes: 3704