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

using namespace std;


int main(){
	long long int N;
	cin >> N;
	vector<vector<long long int >>L(3, vector<long long int>(N));
	for( size_t i = 0; i < 3; i++ ){
		for( size_t j = 0; j < N; j++ ){
			cin >> L[i][j];
		}
		sort(L[i].begin(), L[i].end());
	}
	long long int idxA = N - 1, idxB = N - 1, idxC = N - 1, ans = 0;
	vector<long long int>memo(N);

	long long int num = 0;
	while( idxB >= 0 ){
		while( idxC >= 0 && L[2][idxC] > L[1][idxB] ){
			num++;
			idxC--;
		}
		memo[idxB] = num;
		idxB--;
	}

	num = 0;
	idxB = N - 1;
	while( idxA >= 0 ){
		while( idxB >= 0 && L[1][idxB] > L[0][idxA] ){
			num += memo[idxB];
			idxB--;
		}
		ans += num;
		idxA--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d;
    string s1,s2,s3;
    cin>>s1;
    cin.ignore();
    cin>>s2;
    vector<ll>v,u;
    map<char ,ll>mp,mp1;
    map<char ,ll>::iterator it;
    for(i=0;i<s1.size();i++)
    {
        mp[s1[i]]++;
        mp1[s2[i]]++;

    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        k=it->second;
        v.push_back(k);
    }
    for(it=mp1.begin();it!=mp1.end();it++)
    {
        k=it->second;
        u.push_back(k);
    }
    sort(v.begin(),v.end());
    sort(u.begin(),u.end());
    if(u==v){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}

    return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<string>

using namespace std;

int main(){
  string s;
 cin >> s;
  bool cnt[26]={false};
  
  for(int i=0;i<s.length();i++)  cnt[s[i]-'a']=true;
  
  int res=0;
  
  for(int i=0;i<26;i++){
    if(!cnt[i]) {
      break;
    }
    else {
      res++;
    }
}
  if(res<26) cout << char('a'+res) << endl;
  else cout << "None" << endl;
}

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

const int mod = 1000000007;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int> > dp(H+1, vector<int>(W, 0));
	dp[0][0] = 1;
	// i:天辺からの低さ j:右に何本目か k:隙間に横棒があるかを2進数で表現
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 1 << (W-1); k++) {
				bool ok = true;
				for (int l = 0; l < W-2; l++) {
					if (((k >> l) & 1) && ((k >> (l+1)) & 1)) ok = false;
				}
				if (ok) {
					if (j >= 1 && ((k >> (j-1)) & 1)) {
						dp[i+1][j-1] += dp[i][j];
						dp[i+1][j-1] %= mod;
					} else if (j <= W-2 && ((k >> j) & 1)) {
						dp[i+1][j+1] += dp[i][j];
						dp[i+1][j+1] %= mod;
					} else {
						dp[i+1][j] += dp[i][j];
						dp[i+1][j] %= mod;
					}
				}
			}
		}
	}
	cout << dp[H][K-1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    string s;
    cin >> n >> m >> s;
    //最初に'AC'を数えて、それまでの'AC'のかずの総和を入れていく
    vector<int>c(n+1);
    int sum = 0;
    for(int i = 0;i<n-1; i++){
        if(s.at(i) == 'A' and s.at(i+1) == 'C'){
            sum += 1;
        }
        c[i+1] = sum;
    }
    //a ~ b-1の範囲に含まれるものの和を出力
    for(int i =0;i<m;i++){
        int a,b;
        cin >> a >> b;
        cout << c[b-1] -c[a-1] << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  int n, m, k;
  cin >> n >> m >> k;
  for (int a = 0; a <= n; ++a)
    for (int b = 0; b <= m; ++b) {
      int c = a * (m - b) + b * (n - a);
      if (c == k) {
        cout << "Yes\n";
        return 0;
      }
    }
  cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int M, K;
  cin >> M >> K;
  if (M == 1){
    if (K == 0){
      cout << "0 0 1 1" << endl;
    } else {
      cout << -1 << endl;
    }
  } else {
    if (K >= (1 << M)){
      cout << -1 << endl;
    } else {
      vector<int> c;
      for (int i = 0; i < (1 << M); i++){
        if (i != K){
          c.push_back(i);
        }
      }
      vector<int> ans = c;
      ans.push_back(K);
      reverse(c.begin(), c.end());
      for (int x : c){
        ans.push_back(x);
      }
      ans.push_back(K);
      int sz = ans.size();
      for (int i = 0; i < sz; i++){
        cout << ans[i];
        if (i < sz - 1){
          cout << ' ';
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    vector<vector<int>> x(20,vector<int>(20));
    vector<vector<int>> y(20,vector<int>(20));
    rep(i,n) {
        cin >>a[i] ;
        rep(j,a[i]){
            cin >>x[i][j] >>y[i][j];
        }
    }
    int ans =0;
    for (int bit = 0; bit< (1 << n);bit++) {
      bitset<15> s(bit);
      bool ok = true;
      rep(i,n){
        if (s[i]){
            rep(j,a[i]){
              if (s[x[i][j]-1] != y[i][j]) ok = false; 
            }
        }
      }
      int t=s.count();
      if (ok) ans = max(ans,t);
    }
    cout<<ans<<endl;
}

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

using namespace std;


int main() {
	int N,K;
    cin >> N >> K;

    vector<int> a(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    // 両者最適な操作をする場合に残りの石がi個のときに石を選択する者が勝つかどうか(0:負け 1:勝ち)dp[i]
    vector<int> dp(K+1, -1);

    // 初期条件
    dp[0] = 0;

    for (int i = 1; i <= K; i++) {
        // それぞれの石を選んだ時
        for (int j = 1; j <= N; j++) {
            dp[i] = 0;

            if (i-a[j] >= 0) {
                // 負けの局面が存在したとき
                if (dp[i-a[j]] == 0) {
                    dp[i] = 1;
                    break;
                }
            }
        }   
    }

    if (dp[K] == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
	return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int num = sc.nextInt();
            int taro = 0, hanako = 0;
            for (int i=0; i<num; i++){
                String a = sc.next();
                String b = sc.next();
                if (a.compareTo(b) > 0) {
                    taro += 3;
                } else if (a.compareTo(b) < 0) {
                    hanako += 3;
                } else {
                    taro += 1;
                    hanako += 1;
                }
            }
            System.out.println(taro + " " + hanako);
        }
    }
}



Measured memory_bytes: 29424
#include<iostream>
#include<algorithm>
#include <stdlib.h>
#include <locale>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a<=k){
    cout << "Yay!" << endl;
  }
  else{
  	cout << ":(" << endl;
  }
return 0;
}

Measured memory_bytes: 3612
import bisect

N = int(input())
S = input().strip()

A = [[] for j in range(10)]


for i, s in enumerate(S):
    A[int(s)].append(i)

v = set()


ans = 0
for i in range(10):
    if A[i]:
        for j in range(10):
            if A[j]:
                x = bisect.bisect_right(A[j], A[i][0])
                if x != len(A[j]):
                    for k in range(10):
                        if A[k]:
                            y = bisect.bisect_right(A[k], A[j][x])
                            if y != len(A[k]):
                                ans += 1

print(ans)







Measured memory_bytes: 4328
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 15:18:29 2018
ALDS1-4c
@author: maezawa
"""
def can_load(w, k, p):
    n = len(w)
    m = 0
    tk = 0
    i = 0
    while tk < k:
        if m + w[i] <= p:
            m += w[i]
            i += 1
            if i >= n:
                return n+1
        else:
            m = 0
            tk += 1
    return i


n, k = list(map(int, input().split()))
w = []
tr = [0 for _ in range(k)]

for i in range(n):
    w.append(int(input()))

maxw = max(w)
# =============================================================================
# for p in range(maxw, maxw*n):
#     if can_load(w, k, p) == n:
#         print(p)
#         break
# =============================================================================
right = maxw*n
left = maxw
while left<right:
    mid = (right+left)//2
    cl = can_load(w, k, mid)
    if cl == n:
        print(mid)
        break
    elif cl < n:
        left = mid + 1
    else:
        right = mid
print(right)    
    
    
    
    
    


Measured memory_bytes: 9564
#include<iostream> 
using namespace std;
int main()
{
	int k,s,x,y,z,count=0;
	cin>>k>>s;
	for(int i=k;i>=0;i--){
		int x=s;
		if(i>x)continue;
		for(int j=k;j>=0;j--){
			int y=x-i,z=y-j;
			if(j>y||z<0)continue;
			else if(z<=k)count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int a[1000];
    cin >> n;
    REP(i,n)cin >> a[i];
    int sum;
    REP(i,n)sum += a[i];
    if(sum%10==0){
        sort(a,a+n);
        REP(i,n)if(a[i]%10!=0){
            cout << sum-a[i] << endl;
            return 0;
        }
        cout << 0 << endl;
        return 0;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
def main():
  n=int(input())
  v=list(map(int,input().split()))
  total=0
  v.sort()
#  print(v)
  v[0]=(v[0]+v[1])/2
  v[1]=1001
  for i in range(1,n-1):
    v.sort()
    v[0]=(v[0]+v[1])/2
    v[1]=1001
 #   print(v)
  
  print(v[0])
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;
const ll INF = 1e18L + 5;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    int n, w;
    cin >> n >> w; 
    vector<ll> weight(n,0);
    vector<ll> value(n,0);
    ll sum_val=0;
    rep(i,0,n){
        cin >> weight[i] >> value[i];
        sum_val += value[i];
    }
    // dp[i] = min sum of weights with total value exactly equal to i
    vector< ll > dp (sum_val+1, INF);

    dp[0]=0;

    for(int i=0; i<n; i++){
        for(int j=sum_val; j>=value[i]; j--){
            dp[j] = min(dp[j], dp[j-value[i]]+weight[i]);
        }
    }

    ll answer=0;
    for(ll i=0; i<=sum_val; i++){
        if(dp[i]<=w)
            answer = max(answer, i);
    }

    cout << answer << endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;

#define MAXN 100000
int N;
struct node{
    int num,pos;
}A[MAXN+5];
map<int,int> ID;

bool cmp1(node x,node y){
    return x.num<y.num;
}
bool cmp2(node x,node y){
    return x.pos<y.pos;
}

int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        A[i].pos=i;
        scanf("%d",&A[i].num);
    }
    sort(A+1,A+N+1,cmp1);
    for(int i=1;i<=N;i++)
        ID[A[i].num]=i;
    sort(A+1,A+N+1,cmp2);
    int Ans=0;
    for(int i=1;i<=N;i++)
        Ans+=ID[A[i].num]%2!=i%2;
    printf("%d",Ans/2);
}


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int a;
  cin>>a;
  if(a==0)cout<<1;
  else cout<<0;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

//const ll MOD_CONST = 1000000007;
const ll MOD_CONST = 998244353;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	if (a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}

	ll cnt = 0;
	
	for (int i = 0; i < n; i++) {
		if (a[i + 1] > a[i] + 1) {
			cout << -1 << endl;
			return 0;
		}

		if (a[i + 1] <= a[i]) {
			cnt += a[i];
		}


	}
	
	cout << cnt << endl;
}



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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7  ;

int a[MAXN] ;

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

   string s ;
   cin >> s ;
   int n = s.size();
   if(s[0]!=s[n-1])
   {
       if(n%2==1)
            return cout<<"First",0;
       return cout<<"Second",0;
   }
   if(n%2==0)
        return cout<<"First",0;
    return cout<<"Second",0;

}


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

int main() {
    int k, a, b;
    int i = 1;
    cin >> k;
    cin >> a >> b;
    while(i <= b){
        int kk = k * i;
        if(a <= kk && kk <= b){
            cout << "OK" << endl;
            return 0;
        }
        i++;
    }
    cout << "NG" << endl;
    return 0;
}

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



int32_t main(){
	bool can = true;
	string s;
	cin >> s;
	int n = s.size();
	if(s[0] != '1') can = false;
	if(s[n-1] != '0') can = false;
	for(int i = 1 ; i < n-1; i ++){
		if(s[i] != s[n-i-2]) can = false;
	}
	if(!can){
		cout << -1 << endl;
	}
	else{
		set<int> p;
		vector<pair < int, int > > tree;
		int last = 1;
		int ac = 1;
		for(int i=1;i<n+1;i++) p.insert(i);
		p.erase(1);
		for(int i = 1 ; i < n; i ++){
			if(s[i] == '1'){
				int u = *p.begin();
				p.erase(u);
				tree.push_back({u,last});
				ac ++ ;
				last = u;
				while(ac != (i+1)){
					u = *p.begin();
					tree.push_back({u,last});
					p.erase(u);
					ac ++ ;
				}
			}
		}
		if(p.size()){
			tree.push_back({last, *p.begin()});
		}
		for(int i = 0 ; i < tree.size() ; i ++){
			cout<< tree[i].first <<" " << tree[i].second << endl;
		}
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> a(N);
  for(int i = 0; i < N; i++){
	string x;
    int y, z;
    cin >> x >> y;
    y *= -1;
    z = i + 1;
    a.at(i) = make_tuple(x, y, z);
  }
  sort(a.begin(), a.end());
  
  for(int i = 0; i < N; i++){
    int y, z;
    string x;
    tie(ignore, ignore, z) = a.at(i);
    cout << z << endl;
  }
}
    
    
  

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#define Max 100005
using namespace std;
struct node
{
	int x;
	int y;
}data[Max];
bool cmp(node a,node b)
{
	if(a.y==b.y)
		return a.x<b.x;
	return a.y<b.y;
}
int n,m,Min=Max;
int main()
{
		scanf("%d%d",&n,&m);
		for(int i=0;i<m;i++)
		{
			scanf("%d%d",&data[i].x,&data[i].y);
			Min=min(Min,data[i].y);
		}
		sort(data,data+m,cmp);
		int ans=1;
		for(int i=1;i<m;i++)
		{
			if(data[i].x>=Min)
			{
				ans++;
				Min=data[i].y;
			}
		}
		printf("%d\n",ans);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  if(0 == N%2){
    cout << N/2 << endl;
  }else{
    cout << N/2 + 1<< endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char a;
    cin>>a;
    if(a>='a' && a<='z') cout<<'a'<<endl;
    else cout<<'A'<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B,C,X;
int main(){
    cin>>A>>B>>C>>X;
    int ct = 0;
    rep(i,A+1) rep(j,B+1) rep(k,C+1) if(500*i+100*j+50*k==X) ct++;
    pr(ct);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int N, A, B, C, D;
string S;
int arrive[200005];
int j;

void dfs(int i) {
    if(i + 1 > N - 1) return ;
    j = i + 1;
    if(S[j] != '#') {arrive[j] = 1; dfs(j);}
    
    if(i + 2  > N - 1) return ;
    j = i + 2;
    if(S[j] != '#') {arrive[j] = 1; dfs(j);}
    return ;
}

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

    cin >> N >> A >> B >> C >> D >> S;

    if(C < D){
        memset( arrive, 0, sizeof(arrive) );
        dfs(B - 1);
        if(arrive[D - 1] == 0) {cout << "No" << endl; return 0;}

        memset( arrive, 0, sizeof(arrive) );
        dfs(A - 1);
        if(arrive[C - 1] == 0) {cout << "No" << endl; return 0;}
        cout << "Yes" << endl;
        return 0;
    }
    else {
         bool check = true;
        for(int i = A; i <= C - 1; i++){
            if(S[i] == '#' and S[i-1] == '#') check = false;
        }
        if(check){
            bool check2 = false;
            for(int i = B; i <= D; i++){
                if(S[i-2]=='.' and S[i-1]=='.' and S[i] == '.') check2 = true;
            }
            if(check2) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 2512
#include <iostream>
#include <stack>

using namespace std;

struct sets { int i, sum, k; };

int n, s, cnt;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int k) {
    stack<sets> S;
    S.push(sets{i, sum, k});

    while (!S.empty()) {
        sets u = S.top();
        if (u.k == n && u.sum == s) { cnt++; }

        if (u.i == 10 && u.k == 0 && u.sum == 0) { break; }

        if (u.i < 10 && u.k < n) {
            S.push(sets{u.i + 1, u.sum, u.k});
            S.push(sets{u.i + 1, u.sum + a[u.i], u.k + 1});
        }
        else if (u.i == 10) {
            int tmp = u.k;
            while (S.top().k == tmp) { S.pop(); }
        }
        else { S.pop(); }
    }
}

int main() {
    while (cin >> n >> s) {
        if (!n && !s) { break; }
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
N,K=map(int, input().split())
instr=input()
lft=0
rgt=1
voids=int(instr[0] == '0')
maxlen=0
while lft < rgt:
    maxlen = max(maxlen, rgt-lft)
    if rgt < N and (instr[rgt] == '1' or (instr[rgt-1] == '0' and instr[rgt] == '0')):
        rgt += 1
    elif rgt < N and voids < K:
        voids += 1
        rgt += 1
    else:
        voids -= lft+1 < N and instr[lft] == '0' and instr[lft+1] == '1'
        lft += 1
print(maxlen)


Measured memory_bytes: 3316
#include<stdio.h>
int main(void){
  int i;
  char s1[11],s2[11],s3[11];
  scanf("%s%s%s",s1,s2,s3);
  s1[0]=s1[0]-32;
  s2[0]=s2[0]-32;
  s3[0]=s3[0]-32;
  printf("%c%c%c",s1[0],s2[0],s3[0]);
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int x = nextInt();
        int[] minRequired = new int[x + 1];
        for (int i = 1; i < Math.min(6, minRequired.length); i++) minRequired[i] = 1;
        for (int i = 6; i <= x; i++) {
            minRequired[i] = Integer.MAX_VALUE;
            for (int j = 1; j <= 5; j++) minRequired[i] = Math.min(minRequired[i], 1 + minRequired[i - j]);
        }

        boolean can = false;
        for (int numOf100s = 0; numOf100s * 100 <= x; numOf100s++) {
            int rem = x - numOf100s * 100;
            if (minRequired[rem] <= numOf100s) {
                can = true;
                break;
            }
        }

        System.out.println(can ? '1' : '0');
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
#include <stdio.h>
int main(){
  int bingo[3][3],check[3][3]={0};
  int n,tmp;
  int i,j,k,flag=0;
  
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&bingo[i][j]);
    }
  }
  
  scanf("%d",&n);
  
  for(k=0;k<n;k++){
    scanf("%d",&tmp);
    
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        if(tmp==bingo[i][j]){
          check[i][j]=1;
        }
      }
    }
  }
  
  for(i=0;i<3;i++){
    if((check[i][0]+check[i][1]+check[i][2])==3){
      flag=1;
    }
    if((check[0][i]+check[1][i]+check[2][i])==3){
      flag=1;
    }
  }
  if((check[0][0]+check[1][1]+check[2][2])==3){
      flag=1;
  }
  if((check[2][0]+check[1][1]+check[0][2])==3){
      flag=1;
  }
  
  if(flag==1){
    printf("Yes");
  } else {
    printf("No");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, C, K; cin >> N >> C >> K;
  vector<ll> T(N);
  for(int i = 0; i < N; i++) cin >> T.at(i);
  sort(T.begin(), T.end());
  int x = T.at(0), count = 0, bus = 0;
  for(int i = 0; i < N - 1; i++) {
    count++;
    if(count == C || T.at(i + 1) - x > K) {
      //cout << "did" << i << endl;
      bus++;
      count = 0; x = T.at(i + 1);
    }
    if(i == N - 2) {
        bus++;
    }
  }
  cout << bus << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var lis = new List<Pair>();
            for (int i = 0; i < n; i++)
            {
                var ab = IO.RSInt;
                lis.Add(new Pair(ab[0], ab[1]));
            }
            lis.Sort((a, b) => a.b - b.b);

            long time = 0;
            for (int i = 0; i < n; i++)
            {
                time += lis[i].a;
                if (time > lis[i].b)
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }

    }

    public struct Pair
    {
        public Pair(int a, int b)
        {
            this.a = a;
            this.b = b;
        }
        public int a;
        public int b;
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 26412
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s, t; cin >> s >> t;
	cout << t + s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<queue>

using namespace std;
typedef pair<int,int>P;

const int INF = 100000000;

char a[50][50];
int H,W;
	int d[50][50];
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};
	int bfs(){
		queue<P> que;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				d[i][j]=INF;
			}
		}
		que.push(P(0,0));
		d[0][0]=0;
		while(que.size()){
			P p=que.front(); que.pop();
			if(p.first==(H-1) && p.second==(W-1))break;
			for(int i=0;i<4;i++){
				int nx = p.first+dx[i], ny =p.second+dy[i];
				if (0<=nx && nx < H && 0 <= ny && ny < W && a[nx][ny]!='#' && d[nx][ny]==INF){
					que.push(P(nx,ny));
					d[nx][ny]=d[p.first][p.second]+1;
				}
			}
		}
		return d[H-1][W-1];
	}
	int main(){
		int z=0;
		cin>>H>>W;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>a[i][j];
			}
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(a[i][j]=='#'){
					z++;
				}
			}
		}
		int res = bfs();
		if(res==INF)cout<<-1<<endl;
		else{
		int x = H*W-z-res-1;
		cout << x <<endl;
	}
	return 0;
  }


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

int main() {
    string N;
    int a[N.size()+10]={};
    int counter=0;
    int count=0;
    cin >>N;
    for(int i=0;i<N.size();i++){
    if(N.at(i)=='A'||N.at(i)=='C'||N.at(i)=='G'||N.at(i)=='T'){
    a[i]=1;}
    else a[i]=0;}
    for(int i=0;i<N.size();i++){
    if(a[i]==0){
    count=max(count,counter);
    counter=0;}
    else{
    counter++;}}
    count=max(count,counter);
    cout<<count<<endl;}


Measured memory_bytes: 256
# B
x,y = map(int,input().split())

# 2a + 4b = y
# 2a+2b = 2x

# 2b = y-2x
b = (y-2*x) / 2

flg = True

if b < 0:
  flg = False

if (2 * b) % 2 == 1 :
  flg = False

a = 2*x -2*b
if a < 0:
  flg = False

if flg:
  print('Yes')
else:
  print('No')

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b;
  cin >> a >> b;
  int cur = 1;
  int ret = (b - cur) / (a - 1);
  if((b-cur)%(a-1) != 0){
    ret++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
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.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n + 2];

            for (int i = 0; i < n; i++) {
                x[i + 1] = in.nextInt();
            }

            long sum = 0;
            for (int i = 0; i < n + 1; i++) {
                sum += Math.abs(x[i + 1] - x[i]);
            }

            for (int i = 1; i <= n; i++) {
                out.println(sum - Math.abs(x[i + 1] - x[i]) - Math.abs(x[i] - x[i - 1]) + Math.abs(x[i + 1] - x[i - 1]));
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 44640
if __name__ == "__main__":
    N = int(input())
    x = 0
    y = 0
    t = 0
    flag = True
    for i in range(N):
        ti, xi, yi = [int(i) for i in input().split()]
        d = abs(xi - x) + abs(yi - y)

        if flag and (ti - t) >= d and ((ti - t) - d) % 2 == 0:
            t = ti
            x = xi
            y = yi
        else:
            flag = False
    print("Yes" if flag else "No")

Measured memory_bytes: 3316
# coding: utf-8
# Your code here!
a=int(input())
    
b=[]   

c=0.0
    

for i in range(a):
    b.append(input().split())
    
    
    if b[i][1]=="BTC":
        b[i][0]=float(b[i][0])*380000
        
    
        
    
    c+=float(b[i][0])
    
        
    
print(c) 



Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for(int i = 0; i < h; i++) {
    cin >> s[i];
  }
  int ans = 0;
  int black = 0;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s[i][j] == '#') {
        black++;
      }
    }
  }
  for(int i = 0; i < (1 << h); i++) {
    for(int j = 0; j < (1 << w); j++) {
      int cnt = black;
      for(int a = 0; a < h; a++) {
        for(int b = 0; b < w; b++) {
          if(i & (1 << a)) {
            if(s[a][b] == '#') {
              cnt--;
            }
          } else if(j & (1 << b)) {
            if(s[a][b] == '#') {
              cnt--;
            }
          }
        }
      }
      if(cnt == k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define pb push_back

void solve(string s, int l) {
    vector<string> v;
    for(int i=0; ; i++) {
        int n = s.size();
        string a = "";
        rep(i,l-n) a += "0";
        a += s;
        string tmp = a, down, up;
        sort(ALL(tmp));
        down = tmp;
        sort(RALL(tmp));
        up = tmp;
        s = to_string(stoi(up) - stoi(down));

        rep(j,SZ(v)) {
            if(a == v[j]) {
                printf("%d %d %d\n", j, stoi(a), i-j);
                return ;
            }
        }
        v.pb(a);
    }
    return ;
}

int main() {
    string s;
    int l;
    while(cin>>s>>l, l) solve(s,l);
    return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  */

signed main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;

  V<int> L(k), R(k);
  {
    int cnt = 0;
    rep(i, 0, n){
      if(s[i] == 'o'){
        L[cnt++] = i;
        i += c;
        if(cnt == k) break;
      }
    }
  }
  {
    int cnt = k-1;
    for(int i = n-1; i >= 0; i--){
      if(s[i] == 'o'){
        R[cnt--] = i;
        i -= c;
        if(cnt == -1) break;
      }
    }
  }
  
  rep(i, 0, k){
    if(L[i] == R[i]) cout << L[i]+1 << endl;
//    cout << L[i] << " " << R[i] << endl;
  }

  return 0;
}





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

#define  PI 3.14159265358979

int main( void ) {

    int n;
    cin >> n;
    long long   sum=0;
    vector<int> num( n );
    for( int i = 0; i < n; i++){
        cin >> num.at( i );
        sum += num.at( i );
    }
    sort(num.begin(),num.end());
    //min
    int minv = num.at( 0 );
    int maxv = num.at( n - 1 );
    cout << minv << " " << maxv << " " << sum << endl;

    return 0;
}



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

int n;
double p[3018], dp[3005][3005], ans = 0;

int main() {
	cin >> n;
	for(int i = 1; i<= n; i++)
		cin >> p[i];

	dp[0][0] = 1;
	for(int i = 0; i<= n; i++) {
		for(int j = 0; j<= n; j++) {
			if(i > j && i + j == n)
				ans += dp[i][j];
			if((i + j + 1) > n)
				continue;
			dp[i + 1][j] += dp[i][j] * p[i + j + 1];
			dp[i][j + 1] += dp[i][j] * (1.0 - p[i + j + 1]);
		}
	}
	printf("%.15lf", ans);
	return 0;
}


Measured memory_bytes: 70016
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,k = get_nums_l()

ans = 0

while n > 0:
    ans += 1
    n = n // k

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

void nckinit(ll n,ll md){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=md;
  }
  gya[n]=gyaku(kai[n],md);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=md;
  }
  gya[0]=1;
}
ll nck(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  ret*=gya[k];
  ret%=md;
  return ret;
}
ll npk(ll n,ll k,ll md){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=md;
  return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

int main() {
	int res = 0 , cnt = 0 , n;
	string s;
	cin>>n>>s;
	for(int i = 0 ; s[i] != '\0' ; ++i){
		if(s[i] == 'I')++cnt;
		else --cnt;
		res = max(res , cnt);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
print(cnt)


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

int main()
{
    char s[30];
    scanf("%s",s);
    int count=0;

    for(int i=0;i<strlen(s);i++)
    {
        for(int j=i+1;j<strlen(s);j++)
        {
            if(s[i]==s[j])
            {
                count++;
            }

        }
    }
    if(count>0)
    {
        printf("no\n");

    }
    else
    {
        printf("yes\n");
    }
    return 0;

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
    
int main(void){
    int x, y;
    cin >> x >> y;
    
    if(y - 2*x >= 0 && (y - 2 * x) % 2 == 0 && (x - (y - 2*x)/2 >= 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3644
n = int(input())
ss = [0] * n
for i in range(n):
    ss[i] = input()

m = int(input())
ts = [0]*m
for i in range(m):
    ts[i] = input()

ans = 0
t = 0

for i in range(n):
    t = 0
    for j in range(n):
        if ss[i] == ss[j]:
            t += 1
    for k in range(m):
        if ss[i] == ts[k]:
            t -= 1
    ans = max(ans,t)

print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = 0;

		if (b == 100)
			b += 1;

		switch (a) {
		case 0:
			ans = b;
			break;
		case 1:
			ans = 100 * b;
			break;
		case 2:
			ans = 10000 * b;

			break;

		default:
			break;
		}

		System.out.println(ans);

		sc.close();

	}

}


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

using namespace std;

#define ll long long
#define pb push_back

int main()
{

    string str, ptr;
    cin >> str >> ptr;
    int cnt = 0;
    for(int i = 0; i < str.length(); i++)
    {
        if( str[i] != ptr[i])
            cnt++;
    }
   cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3912
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (__typeof(a) i = (a); i < (b); ++i)
#define iter(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1 << 31);

#define sc second
#define fs first
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T>
T smod(T a, T b) {
  return (a % b + b) % b;
}
// vim: cc=60 ts=2 sts=2 sw=2:

ll w[105], v[105];

ll memo[100][100'050];
ll dp(int nat, int wat) {
  if (wat == 0) return 0;
  if (wat < 0) return -INF;
  if (nat < 0) return 0;
  if (memo[nat][wat] != -1) return memo[nat][wat];

  ll res = 0;
  res = max(res, dp(nat - 1, wat));
  res = max(res, dp(nat - 1, wat - w[nat]) + v[nat]);

  return memo[nat][wat] = res;
}

int main() {
  // code
  memset(memo, -1, sizeof(memo));

  int N, W;
  cin >> N >> W;

  rep(i, 0, N) { cin >> w[i] >> v[i]; }

  cout << dp(N - 1, W) << endl;

  // codend
}


Measured memory_bytes: 78464
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # sum([(a * i + b) // m for i in range(n)])
    def floor_sum(n, m, a, b):
        ret = 0
        while True:
            ret += (a // m) * n * (n-1) // 2 + (b // m) * n
            a %= m
            b %= m
            y = (a * n + b) // m
            x = b - y * m
            if y == 0:
                return ret
            ret += (x // a + n) * y
            n, m, a, b = y, a, m, x % a

    for _ in range(int(input())):
        N, M, A, B = map(int, input().split())
        print(floor_sum(N, M, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 71172
#C - Build Stairs
N = int(input())
H = list(map(int,input().split()))

target = H[0]
target_max = 0
result = 'Yes'
for i in range(1,N):
    if (H[i] < target - 1) or (target_max > H[i]):
        result = 'No'
        break
    elif H[i] == target - 1:
        target -= 1
    else:
        target = H[i] - 1
    target_max = max(target,target_max)           
print(result)

Measured memory_bytes: 20692
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = ns()
k = ni()
i = 0
while i < len(s):
    if s[i] == '1':
        i += 1
    else:
        ans = int(s[i])
        break

if k <= i:
    ans = 1

print(ans)

Measured memory_bytes: 3696