akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const ll INF = 1LL << 60;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll n;
    cin >> n;
    ll a[n],all=0;
    for (ll i=0;i<n;i++){
        cin >> a[i];
        all+=a[i];
        all%=MOD;
    }
    ll ans=0;
    for (ll i=0;i<n;i++){
        all-=a[i];
        if (all<0)all+=MOD;
        ans+=(all*a[i])%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5192
#include<stdio.h>

#define N 100

int main(void)
{
	int i,j,k,n,m;
	double a[N][N],dp[N][N],S;
	
	while(1)
	{
		scanf("%d%d",&n,&m);
		if(n==0 && m==0) break;
		for(i=0;i<=n-1;i++)
		{
			for(j=0;j<=n-1;j++)
			{
				scanf("%lf",&a[i][j]);
			}
		}
		for(i=0;i<=m-1;i++)
		{
			for(j=0;j<=n-1;j++)
			{
				dp[j][i]=0;
			}
		}
		for(i=0;i<=n-1;i++)
		{
			dp[i][0]=1.0;
		}
		for(i=1;i<=m-1;i++)
		{
			for(j=0;j<=n-1;j++)
			{
				for(k=0;k<=n-1;k++)
				{
					S=a[k][j]*dp[k][i-1];
					if(dp[j][i]<S)
					{
						dp[j][i]=S;
					}
				}
			}
		}
		S=0;
		for(i=0;i<=n-1;i++)
		{
			if(dp[i][m-1]>S)
			{
				S=dp[i][m-1];
			}
		}
		printf("%.2lf\n",S);
	}
	return 0;
}

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

long long INF = 1e18;

int main(){
    int h,n;
   cin>>h>>n;
   int a[n+100];
   int sum = 0;
   for(int i=0; i<n;i++){
       cin>>a[i];
       sum+=a[i];

   }

   if(sum < h){
       cout<<"No"<<endl;
   }else{
       cout<<"Yes"<<endl;
   }
    return 0;
}

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

int main()
{
	string S;
	int K;
	cin >> S >> K;

	int N = S.size();
	vector<vector<vector<int>>> dp( N + 1, vector<vector<int>>( 2, vector<int>( K + 2 ) ) );
	dp[0][0][0] = 1;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < 2; j++ ) {
			int lim = S[i] - '0';
			if( j ) lim = 9;
			for( int k = 0; k <= K; k++ ) {
				for( int x = 0; x <= lim; x++ ) {
					int kk = 0;
					if( x ) kk = 1;
					dp[i + 1][j || x < lim][k + kk] += dp[i][j][k];
				}
			}
		}
	}

	int ans = dp[N][0][K] + dp[N][1][K];

	cout << ans << endl;
}


Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def main():
    a, b = map( int, input().split())
    if max((b-1+a-2)//(a-1), (b+a-1)//a) < (a+b)/a:
        print(max((b-1+a-2)//(a-1), (b+a-1)//a)*a)
    else:
        print(-1)
if __name__ == '__main__':
    main()



Measured memory_bytes: 5608
var input = function()
{
  return require('fs').readFileSync('/dev/stdin', 'utf8');
};

var range = function(a,b)
{
  var array = [];
  for (var i = a; i <= b; i++) {
    array.push(i);
  }
  return array;
}

var getKeyNum = function()
{
  return 3;
}

var out = function(x)
{
  console.log(x);
  return x;
}

var check = function(a,b)
{
  if(a==1)a='';
  
  if (checkNum(b)==true)
  {
    return a + ' ' + b;
  }
  if (includeNum(b)==true)
  {
    return a + ' ' + b;
  }
  return a;
}

var checkNum = function(x)
{
  if (x%getKeyNum() == 0)
  {
    return true;
  }
  return false;
}

var includeNum = function(x)
{
  var result =x;
  while (result !=0) {
    if (result%10 == getKeyNum()) {
      return true;
    }
    result = Math.floor(result/10);
  }
  return false;
}

out(range(1,input()).reduce(check));

Measured memory_bytes: 12832
def solve():
    ans = 0
    S = input()
    T = input()
    n,m = len(S),len(T)
    dp = [[0]*(m+1) for _ in range(n+1)]
    for j in range(1,m+1):
        dp[0][j] = j
    for i in range(1,n+1):
        dp[i][0] = i
        for j in range(1,m+1):
            if S[i-1]==T[j-1]:
                dp[i][j] = dp[i-1][j-1]
            else:
                dp[i][j] = min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
    ans = dp[-1][-1]
    return ans
print(solve())


Measured memory_bytes: 41956
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    double N,K;
    cin>>N>>K;
    
    double t,k=0;
    REP(i,N){
        t=(int)ceil(log(K/i)/log(2));
        k+=(pow((ld)1/2,t<=0?0:t))/N;
        
        //sl(t,k,(pow((ld)1/2,t<=0?0:t))/N)
    }
    //cout<<ac<<" "<<wa;
    cout<<fixed<<setprecision(32)<<k;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  int x = 0;
  int y = 0;
  
  for (int i = 2; i < N; i += 2) {
    if (S.at(i) != S.at(0)) {
      x++;
    }
  }
  for (int i = 1; i < N; i += 2) {
    if (S.at(i) == S.at(0)) {
      x++;
    }
  }
  
  y = min(x, N - x);
  
  cout << y << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 100005
#define all(x) x.begin(),x.end()
#define l_b lower_bound
#define u_b upper_bound
#define pb push_back
#define MOD 1000000007
void fastio(void);

ll cnt[sz];

int main(){
    fastio();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n,sum=0,num,la,lb;
    cin>>n;
    for(la=1;la<=n;la++){
        cin>>num;
        sum+=num;
        cnt[num]++;
    }

    ll q;   cin>>q;
    while(q--){
        ll b, c;
        cin>>b>>c;
        ll dif=c-b;
        sum+=cnt[b]*dif;
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout<<sum<<endl;
    }

    return 0;
}

void fastio(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

Measured memory_bytes: 4400
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

long long int sum = 0;


void merge(int A[],int left,int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  INT_MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] < R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
			sum += n1 - i;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	int A[n];
	for(int i = 0; i < n; i++) scanf("%d",&A[i]);

	mergeSort(A,0,n);

	printf("%lld\n",sum);

}


Measured memory_bytes: 4152
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std ;

long long GCD(long long a, long long b) {
    
    long long temp;
    
    if (a < b) temp = a, a = b, b = temp;
    
    while (b != 0)  temp = a % b, a = b, b = temp;
    
    return a;
        
}

long long LCM(long long a, long long b) {
    
    long long temp = a * (b / GCD(a, b));
    
    return temp;
}

int main() {
    
    long long n;
    
    cin >> n;
    
    vector<long long> nums;
    
    long long temp;
    
    for (int i = 0; i < n; i++) {
        
        cin >> temp;
        
        if (find(nums.begin(), nums.end(), temp) == nums.end())  nums.push_back(temp);
        
    }
    
    long long answer = nums[0];
    
    for (int i = 1; i < nums.size(); i++) { answer = LCM(answer, nums[i]); }
    
    cout << answer << endl;
    
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_S 3010

string S, T;
// S の [i,|S|-1] と、 T の [j,|T|-1] を使ったときの最大長部分文字列
string dp[MAX_S][MAX_S];

signed main()
{
    cin >> S >> T;
    REP(i, S.length()) { REP(j, T.length()) { dp[i][j] = ""; } }

    for(ll i = S.length()-1; i >= 0; --i) {
        for(ll j = T.length()-1; j >= 0; --j) {

            // パターン1: j だけ一つ前
            size_t cand = dp[i][j+1].length();
            int pat = 1;

            // パターン2: i だけ一つ前
            if(dp[i+1][j].length() > cand) {
                cand = dp[i+1][j].length();
                pat = 2;
            }

            // パターン3: i と j 共に一つ前
            if(S[i] == T[j]) {
                // 同じ文字ならそれも加える
                if(dp[i+1][j+1].length() + 1 > cand) {
                    cand = dp[i+1][j+1].length() + 1;
                    pat = 31;
                }
            }
            else {
                if(dp[i+1][j+1].length() > cand) {
                    cand = dp[i+1][j+1].length();
                    pat = 32;
                }
            }

            switch(pat) {
                case 1:
                    dp[i][j] = dp[i][j+1];
                    break;
                case 2:
                    dp[i][j] = dp[i+1][j];
                    break;
                case 31:
                    dp[i][j] = S[i] + dp[i+1][j+1];
                    break;
                case 32:
                    dp[i][j] = dp[i+1][j+1];
                    break;
                default:
                    assert(false);
            }
        }
    }
    printf("%s\n", dp[0][0].c_str());
    return 0;
}


Measured memory_bytes: 841984
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define cin1(x) scanf("%d",&x)
#define cin2(x,y) scanf("%d %d",&x,&y)
#define cin3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define rr read()
#define ll long long
#define CloseIo ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int main(){
	int a;
	string s;
	cin>>a;
	cin>>s;
	if(a<3200)
		cout<<"red\n";
	else
		cout<<s<<"\n";
    return 0;  
}  

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

int a,b;

int main(){
    scanf("%d %d", &a, &b);
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        puts("Possible");
    } else {
        puts("Impossible");
    }
    return 0;
}


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

ll N;
vector<string> ans;

void dfs(string s){
    ll n = s.size();
    if(n == N){
        ans.push_back(s);
        return;
    }
    char mx = 'a';
    for(auto ss : s) mx = max(mx, ss);
    for(char c = 'a'; c <= mx + 1; c++){
        dfs(s+c);
    }
}

int main(){
    cin >> N;
    dfs("a");
    sort(ans.begin(),ans.end());
    for(auto q : ans) cout << q << endl;
    return 0;
}

Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
long long a[100010];
int main(){
	int n;
	cin>>n;
	long long cnt=0;
	long long ans=1e9;
	long long res=0;
	bool flag=false;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<0)cnt++;
		if(a[i]==0)flag=true;
		a[i]=abs(a[i]);
		res+=a[i];
		ans=min(ans,a[i]);
	}
	if(flag||cnt%2==0){
		cout<<res<<endl;
	}
	else{
		cout<<res-ans*2<<endl;
	}
	return 0;
}

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

const int mod = 10000;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> c(n,-1);
  for(int i=0;i<k;i++){
    int a,b;
    cin >> a >> b; a--;
    c[a] = b;
  }
  
  int dp[110][5][5] = {};
  dp[0][0][0] = 1;

  for(int d=0;d<n;d++){
    for(int i=0;i<=3;i++){
      for(int j=0;j<=3;j++){
	for(int k=1;k<=3;k++){
	  if(c[d]>=0 && c[d]!=k)continue;
	  if(i==k && j==k)continue;
	  (dp[d+1][j][k] += dp[d][i][j]) %= mod;
	}
      }
    }
  }

  int ans = 0;
  for(int i=0;i<=3;i++){
    for(int j=0;j<=3;j++){
      (ans += dp[n][i][j]) %= mod;;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin>>A>>B>>K;
    if (A > B) swap(A,B);
    for (int i=A;i;i--){
        if (A % i == 0 && B % i == 0) K--;
        if (K == 0) {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int sc = 0;
	int p = min(a, k);
	k -= p;
	sc += p;

	p = min(b, k);
	k -= p;

	p = min(c, k);
	k -= p;

	sc += p * (-1);

	cout << sc;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int cnt = 0;
    for (int i = 0; i < n-1; i++) {
        if (s[i] == s[i+1]) cnt++;
    }
    cout << min(n-1, cnt+2*k) << endl;
    return 0;
}

Measured memory_bytes: 512
package main

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

// gcd ...
func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

// lcm ...
func lcm(a, b int) int {
	g := gcd(a, b)
	return (a / g) * b
}

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	ans := 0
	for i := 0; i < n; i++ {
		ans += sc.NextInt()
		ans--
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 768
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    K=int(readline())

    que=deque(["0"])
    res=[]
    count=0
    while count<K:
        n=que.popleft()
        if n=="0":
            for i in range(1,10):
                i=str(i)
                que.append(i)
                res.append(i)
                count+=1
        else:
            if n[-1]=="0":
                nex=["0","1"]
            elif n[-1]=="9":
                nex=["8","9"]
            else:
                m=int(n[-1])
                nex=[str(m-1),n[-1],str(m+1)]
            for l in nex:
                k=n+l
                que.append(k)
                res.append(k)
                count+=1

    print(res[K-1])
if __name__=="__main__":
    main()

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

bool chk(long long x, vector<ll>& a, int m,int N) {
    long long cnt = 0;
    for(int i=0; i<N; i++) {
        long long pos = lower_bound(a.begin(), a.end(), x / a[i]) - a.begin();
        cnt += (N - pos);
    }
    return cnt < m;//X以上の和がM個未満かどうか
}
//int m;
int main(){
    int N; ll K;
    cin >> N >> K;
    vector<ll> A(N,0);
    //m = N - K;
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll l = -ll(1e18) - 1, r = ll(1e18) + 1;
    while(l + 1 < r){
        //cout << l << " " << r << endl;
        ll x = (l + r) / 2;
        //cout << x << endl;
        ll tot = 0;
        rep(i,N){
            if(A[i] < 0){
                int L = -1, R = N;
                //cout << "aa" << endl;
                while(L + 1 < R){
                    int mid = (L+R)/2;
                    //cout <<x<<" "<<L<<" "<<R<<" "<<mid <<" "<< A[L]<<" "<<A[R]<<" "<<A[mid] <<endl;
                    if(A[i]*A[mid] < x) R = mid; else L = mid;
                }
                //cout << "bb" << endl;
                tot += N-R;
            }else{
                int L = -1, R = N;
                while(L + 1 < R){
                    int mid = (L+R)/2;
                    if(A[i]*A[mid] < x) L = mid; else R = mid;
                }
                tot += R;
            }
            if(A[i]*A[i] < x) tot--;
        }
        tot /= 2;
        bool flag = tot < K;
        //cout << flag << endl;
        if(flag) l = x; else r = x; 
    }
    cout << l << endl;
    /*
    long long ng = 0, ok = m;
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (chk(mid, A,m,N)) ok = mid;
        else ng = mid;
    }
    */
    //cout << ok << endl;
    //auto itr = lower_bound(A.begin(), A.end(), 0);
}


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

int main(){
    int y,m,d;
    string g;
    while(true){
        cin >> g;
        if(g[0] == '#'){
            break;
        }
        cin  >> y >> m >> d;

        if(y>31){
            g = "?";
            y -= 30;
        }
        else if(y==31){
            if(m > 4){
                g = "?";
                y = 1;
            }
            // y=4の時は必ず平成
        }

        cout << g << " " << y << " " << m << " " << d << endl;
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define KOREHA_IKERU int main() { int n; std::cin >> n; std::map<std::string, int> mp; for (int i = 0; i < n; i++) { std::string s; std::cin >> s; sort(s.begin(), s.end()); mp[s]++; } long long ans = 0; for (auto x : mp) { int m = x.second; ans += 1ll*m*(m-1) / 2; } std::cout << ans << std::endl; return 0; }
KOREHA_IKERU 

Measured memory_bytes: 11136
#!/usr/bin/env python3

from copy import deepcopy

def main():
    n = input()
    l = len(n)
    k = int(input())
    dp0 = [0 for j in range(4)]
    dp1 = [0 for j in range(4)]
    dp1[0] = 1
    for i in range(l):
        dppre0 = deepcopy(dp0)
        dppre1 = deepcopy(dp1)
        d = int(n[i])
        if d == 0:
            for j in [1, 2, 3]:
                dp0[j] += dppre0[j - 1] * 9
        else:
            for j in [1, 2, 3]:
                dp0[j] += dppre0[j - 1] * 9
                dp0[j] += dppre1[j - 1] * max(0, d - 1)
            for j in [0, 1, 2, 3]:
                dp0[j] += dppre1[j]
            dp1 = [0 for j in range(4)]
            for j in [1, 2, 3]:
                dp1[j] = dppre1[j - 1]
    print(dp0[k] + dp1[k])

if __name__ == "__main__":
    main()


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

int main(){
int h,w;
  cin >> h >> w;
  vector<string> field(h+2);
  string pad(w+2,'.');
  field.at(0) = pad;
  string tmp;
  rep(i,h){
    cin >> tmp;
    tmp = "." + tmp + ".";
    field.at(i+1) = tmp;
  }
  field.at(field.size()-1) = pad;
  
  vector<string> out(h,string(w,'#'));
  int nbom = 0;
  rep(i,h){
    rep(j,w){
      nbom = 0;
      if(field.at(i+1).at(j+1)=='#'){}
      else{
        if(field.at(i).at(j)=='#')nbom++;
        if(field.at(i).at(j+1)=='#')nbom++;
        if(field.at(i).at(j+2)=='#')nbom++;
        if(field.at(i+1).at(j)=='#')nbom++;
        if(field.at(i+1).at(j+2)=='#')nbom++;
        if(field.at(i+2).at(j)=='#')nbom++;
        if(field.at(i+2).at(j+1)=='#')nbom++;
        if(field.at(i+2).at(j+2)=='#')nbom++;
        out.at(i).at(j) = (char)(nbom+48);
      }
    }
  }
  rep(i,h)cout << out.at(i) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ((a+b) > (c+d)) {
   cout << "Left" << endl; 
  }
  else if ((a+b) < (c+d)) {
   cout << "Right" << endl; 
  }
  else {
   cout << "Balanced" << endl; 
  }
}

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

void isort(std::vector<int> vec){
    for(int i=0;i<vec.size();++i){
        auto v = vec[i];
      
        int j=i-1;
        for (j; j>=0; --j ){
            if(vec[j]<=v) break;
            vec[j+1] = vec[j];
        }
        vec[j+1] = v;

        for(auto& a:vec) cout<<a<<((&a!=&vec.back())? " ":"\n");
    }
} 

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int nb; cin>>nb;
    std::vector<int> cards; cards.resize(nb);
    for(auto& a:cards) cin>>a;
    isort(cards);
}

Measured memory_bytes: 3096
#include <cstdio>

template<class T>inline void fr(T &a) {
    T s=0,w=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=w*s;
}
template<class T>inline T fr() {T a;fr(a);return a;}
#define R() fr<int>()

int day[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};

signed main() {
    int m1=R(),d1=R(),m2=R(),d2=R();
    if(day[m1]==d1)puts("1");
    else puts("0");
    return 0;
}

Measured memory_bytes: 760
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
a = [0] * (n + 2)
r = defaultdict(int)
for i in range(m):
    x,y = readmi()
    a[x - 1] += 1
    a[y] += -1

for i in range(n + 1):
    a[i + 1] += a[i]
count = 0
flg = True
for i in range(n):
    if a[i] >= m:
        count += 1
print(count)

Measured memory_bytes: 9300
N = int(input())
A = [int(input()) for _ in range(N)]
A.insert(0,0)
B = [False]*(N+1)
B[1] = True
ans = 1
i = 1
while i <= N:
    if A[i] == 2:
        break
    if not B[A[i]]:
        B[A[i]] = True
        ans += 1
    else:
        ans = -1
        break
    i = A[i]
print(ans)

Measured memory_bytes: 7852
#include <iostream>
#include <cstdlib>

int main(){
  int x[100]={0},i=0,ans=0;
  char s[100];

  while(std::cin>>s){
    if(s[0]=='+'){
      ans=x[i-2]+x[i-1];
      x[i-2]=ans;
      x[i-1]=0;
      if(i!=1) i--;
    }else if(s[0]=='-'){
      ans=x[i-2]-x[i-1];
      x[i-2]=ans;
      x[i-1]=0;
      if(i!=1) i--;
    }else if(s[0]=='*'){
      ans=x[i-2]*x[i-1];
      x[i-2]=ans;
      x[i-1]=0;
      if(i!=1) i--;
    }else{
      x[i]=atoi(s);
      i++;
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 3116
X, K, D = map(int, input().split())

if abs(X) <= K * D:
    X2 = abs(X) % D
    K2 =  K - abs(X)//D
    if K2 % 2 == 0:
        print(abs(X2))
    else:
        print(min(abs(X2+D), abs(X2-D)))
else:
    print(abs(abs(X)-K*D))

Measured memory_bytes: 9136
n = int(input())
h = list(map(int, input().split()))

m = 0
ans  = [0]
while m <= n - 3:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))


Measured memory_bytes: 14252
a=int(input())
b=a
r=0
x=10
if x<a:
  r+=9
  x=1000
  if x<a:
    r+=900
    x=100000
    if x==a:
       r+=90000
    else:
       r+=max(0,a-9999)
  else:
    r+=max(0,a-99)
else:
  r+=9 if a==10 else a
print(r)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll x[105];
ll ans=1000000000000000;
ll K;
int main(void){
    ll n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<=100;i++){
        K=0;
        for(int j=0;j<n;j++){
            K+=(x[j]-i)*(x[j]-i);
        }
        ans=min(ans,K);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,c; cin >> n >> c;
    vector<vector<int>>d(c,vector<int>(c));
    erep(i,d)erep(e, i) cin >> e;
    vector<map<int,int>>v(3);
    rep(i,n)rep(j,n){
        int clr; cin >> clr;
        v[(i+j)%3][clr]++;
    }
    int ans = INF;
    rep(i,c)rep(j,c)rep(k,c){
        if(i == j or j == k or k == i) continue;
        int e = 0,f = 0,g = 0;
        for(auto itr : v[0]) e += itr.second * d[itr.first-1][i];
        for(auto itr : v[1]) f += itr.second * d[itr.first-1][j];
        for(auto itr : v[2]) g += itr.second * d[itr.first-1][k];
        cmin(ans, e+f+g);
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	//cout.precision(20);
	//cout << fixed;
	int n;
	cin >> n;
	map<int, int> mp;
	for (int i = 1; i * i <= n; i++)
	{
		for (int j = 1; j * j <= n; j++)
		{
			for (int k = 1; k * k <= n; k++)
			{
				int x = (i * i) + (j * j) + (k * k) + (i * j) + (i * k) + (j * k);
				mp[x]++;
			}
		}
	}
	for (int i = 1; i <= n; i++)
		cout << mp[i] << "\n";
	return 0;
}

Measured memory_bytes: 5980
h = int(input())
n = 100
for i in range(100):
    if pow(2,i) <= h < pow(2,i+1):
        print(pow(2,i) + pow(2,i)- 1)
        break
    
    elif h == pow(2, i+1):
        print(pow(2, i+1) + pow(2,i+1) - 1)
        break
    
    else:
        continue

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,a,b] <- readInts 
  print $ f n a b

f :: Int -> Int -> Int -> Int
f n a b = sum [ m | m <- [1..n]
                  , a   <= g m
                  , g m <= b ]
  where
    g = sum . int2lst

int2lst
  :: Int -> [Int]
int2lst n
  | q == 0 = [r]
  | otherwise = r: int2lst q
  where
--    (q,r) = quotRem n 10
    (q,r) = divMod n 10

Measured memory_bytes: 892
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 52, MAXM = 102, Mod = 998244353 , MAXLog = 20;

int n, k;
int arr[MAXN];
int memo[MAXM][MAXN][MAXN];
int solve(int iter, int l, int r) {
    if (iter == k || r < l)
        return 0;
    int &ret = memo[iter][l][r];
    if (~ret)
        return ret;
    ret = 0;
    ret = ret = max(ret, solve(iter + 1, l + 1, r) + arr[l]);
    ret = max(ret, solve(iter + 1, l, r - 1) + arr[r]);
    if (iter + 1 < k) {
        ret = max(ret, solve(iter + 2, l + 1, r));
        ret = max(ret, solve(iter + 2, l, r - 1));
    }
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }

    memset(memo, -1, sizeof memo);
    cout << solve(0, 1, n) << '\n';

    return 0;
}

Measured memory_bytes: 1408
use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        S: [String; n],
    }
    let mut ans = String::new();
    for i in b'a'..=b'z' {
        let mut cnt = 0;
        let mut f: Vec<usize> = Vec::new();
        for s in S.iter() {
            let mut flag = 0;
            for j in s.chars() {
                if i as char == j {
                    flag += 1;
                }
            }
            f.push(flag);
            if flag >= 1 {
                cnt += 1;
            }
        }
        let mut num_add = std::usize::MAX;
        for k in f.iter() {
            num_add = min(*k, num_add);
        }
        if cnt == n {
            for r in 0..num_add {
                ans = format!("{}{}", ans, i as char);
            }
        }
    }
    println!("{}", ans);
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    int n[4],s;
    rep(i,4) {
        cin >> c;
        n[i]=c-'0';
    }
    rep(bit,8) {
        s=n[0];
        rep(i,3) {
            if(bit&(1<<i)) {
                s+=n[i+1];
            }
            else {
                s-=n[i+1];
            }
        }
        if(s==7) {
            cout << n[0];
            rep(i,3) {
                if(bit&(1<<i)) {
                    cout << "+" << n[i+1];
                }
                else {
                    cout << "-" << n[i+1];
                }
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

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

int main(){
	int n, m, v, u, c;
	scanf("%d%d", &n, &m);
	for(int i = 0;i < m;i++){
		scanf("%d%d%d", &v, &u, &c);
		int t = G[u].size();
		G[v].push_back((edge){u, c, t});
		t = G[v].size()-1;
		G[u].push_back((edge){v, 0, t});
	}
	
	int flow = 0;
	while(1){
		fill(used, used+101, 0);
		int f = dfs(0, n-1, inf);
		if(f == 0)break;
		flow += f;
	}
	
	printf("%d\n", flow);
	return 0;
}


Measured memory_bytes: 3320
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

int imos[110000];
int main()
{
  int N, Q;
  cin >> N >> Q;
  string S; cin >> S;
  REP(i, S.size()) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      imos[i]++;
      i++;
    }
  }
  REP(i, 100010) imos[i + 1] += imos[i];

  auto psum = [&](int l, int r)->int {
    if (l == 0) return imos[r];
    else return imos[r] - imos[l - 1];
  };
  REP(i, Q) {
    int l, r; cin >> l >> r;
    l--, r--;
    int ans = psum(l, r);
    if (S[r] == 'A' && S[r + 1] == 'C') ans--;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    string S;
    cin>>S;
    ll K;
    cin>>K;
    int i=0;
    while(S[i]=='1'&&i<S.size())i++;
    if(K<=i){
        print(1);
    }else{
        print(S[i]-'0');
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::vector<long long> H(2);
  std::vector<long long> M(2);
  for (int i = 0; i < 2; i++)
  {
    scanf("%lld", &H[i]);
    scanf("%lld", &M[i]);
  }
  long long K;
  scanf("%lld", &K);
  ll t = (H[1] - H[0]) * 60 + M[1] - M[0];
  cout << max(t - K, 0LL) << endl;

  return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
int main(){
  ll n,k,x,min_time=1000000000,tmp;
  vector<ll> ne_x,po_x;
  cin >> n >> k;
  ne_x.push_back(0);
  po_x.push_back(0);
  for(int i=0;i<n;i++){
    cin >> x;
    if(x<0) ne_x.push_back(-x);
    else if(x>0) po_x.push_back(x);
    else k--;
  }
  if(k==0){
    cout << "0\n";
    return 0;
  }
  sort(ne_x.begin(),ne_x.end());
  sort(po_x.begin(),po_x.end());
  if(ne_x.size()>k){
    min_time=ne_x[k];
  }
  if(po_x.size()>k){
    min_time=(min_time<po_x[k])?min_time:po_x[k];
  }
  for(int i=1;i<k;i++){
    if(k-i>=ne_x.size()) continue;
    if(i>=po_x.size()) break;
    tmp=ne_x[k-i]+po_x[i];
    tmp+=(ne_x[k-i]<po_x[i])?ne_x[k-i]:po_x[i];
    min_time=(min_time<tmp)?min_time:tmp;
  }
  cout << min_time<<endl;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n){
    string s;
    cin >> s;
    sort(ALL(s));
    mp[s]++;
  }
  ll ans = 0;
  for(auto p : mp){
    ans += (ll)p.second * (p.second-1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
import queue

N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

dic = {}

for ab in AB:
    ab[0]-=1
    ab[1]-=1
    if ab[0] in dic:
        dic[ab[0]].append(ab[1])
    else:
        dic[ab[0]] = [ab[1]]

    if ab[1] in dic:
        dic[ab[1]].append(ab[0])
    else:
        dic[ab[1]] = [ab[0]]

# print(dic)

mm = [-1 for i in range(N)]
mm2 = [-1 for i in range(N)]
q = queue.Queue()
q.put(0)



while not(q.empty()):
    a = q.get()
    
    mm2[a] = 1

    for plc in dic[a]:
        if mm[plc] != -1:
            continue
        
        mm[plc] = a+1
        
        q.put(plc)

print("Yes")

for i in range(1,N):
    print(mm[i])







Measured memory_bytes: 139096
public class Main {


  private static void solve() {
    int n = ni();
    int w = ni();
    int[][] p = ntable(n, 2);
    
    long[][] dp = new long[n + 1][w + 110000];
    for (int i = 0; i < n; i ++) {
      for (int j = 0; j <= w; j ++) {
        dp[i + 1][j] = dp[i][j];
      }
      for (int j = 0; j <= w; j ++) {
          dp[i + 1][j + p[i][0]] = Math.max(dp[i + 1][j + p[i][0]], dp[i][j] + p[i][1]);
      }
    }
    long ret = 0;
    for (int i = 0; i <= w; i ++) {
      ret = Math.max(ret, dp[n][i]);
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 238292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,mod=998244353;
vector<int>v[N];
int n,a[N],tot,head[N],nex[N*20],to[N*20];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
ll sum[N],p[N],f[N],inv[N];
int main()
{
    inv[1]=1;
    for(int i=2;i<=1000000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    int tot=0;
    for(int i=1;i<=1000000;i++)
        for(int j=i;j<=1000000;j+=i)
            add(j,i);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        for(int j=head[a[i]];j;j=nex[j])
        {
            int v=to[j];
            p[v]=(p[v]+sum[v]*a[i])%mod;
            sum[v]=(sum[v]+a[i])%mod;
        }
    }
    ll ans=0;
    for(int i=1000000;i>=1;i--)
    {
        ans=(ans+p[i]*inv[i])%mod;
        for(int j=head[i];j;j=nex[j])
        {
            int v=to[j];if(v==i) continue;
            p[v]=(p[v]-p[i])%mod;
        }
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}
/*
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,mod=998244353;
vector<int>v[N];
int n,a[N];
ll sum[N],f[N],inv[N];
int main()
{
    inv[1]=1;
    for(int i=2;i<=1000000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    int tot=0;
    for(int i=1;i<=1000000;i++)
        for(int j=i;j<=1000000;j+=i)
            v[j].push_back(i),tot++;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        for(int j=0;j<v[a[i]].size();j++)
            sum[v[a[i]][j]]=(sum[v[a[i]][j]]+a[i])%mod;
    }
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<v[a[i]].size();j++)
        {
            int x=v[a[i]][j];
            sum[x]=(sum[x]-a[i])%mod,f[x]=sum[x];
        }
        for(int j=v[a[i]].size()-1;j>=0;j--)
        {
            int x=v[a[i]][j];
            ans=(ans+f[x]*a[i]%mod*inv[x])%mod;
            for(int k=0;k<v[x].size()-1;k++)
                f[v[x][k]]=(f[v[x][k]]-f[x])%mod;
        }
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}
*/


Measured memory_bytes: 164544
#include <stdio.h>
int main(void)
{
	int N = 0;
	int H[101];
	int count = 0;
	int max = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}

	for (int i = 0; i < N; i++) {
		if (H[i] >= max) {
			count++;
			max = H[i];
		}
	}
	printf("%d", count);
	return 0;
}



Measured memory_bytes: 128