akhauriyash/Code-Regression huggingface dataset:
import sys

#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h, w, a):
    da = [[0] * w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1, w):
        da[0][i] = da[0][i - 1] + a[0][i]
    for i in range(1, h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i - 1][j] + cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p, q, x, y):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y] - da[x][q - 1]
    if q == 0:
        return da[x][y] - da[p - 1][y]
    return da[x][y] - da[p - 1][y] - da[x][q - 1] + da[p - 1][q - 1]

H, W, K = map(int, sys.stdin.readline().rstrip().split())
grid = [list(map(int, list(sys.stdin.readline().rstrip()))) for _ in range(H)]
da = da_generate(H, W, grid)

ans = 10 ** 18
for i in range(2**(H - 1)):
    res = 0
    s = [k for k, j in enumerate(range(H), 1) if i >> j & 1] # s行は含まない
    res += len(s)
    s.append(H)
    y = 0
    for w in range(1, W + 1): # w行は含まない
        x = 0
        flag = False
        for s_i in s:
            if da_calc(x, y, s_i - 1, w - 1) > K:
                if y + 1 < w:
                    res += 1
                    y = w - 1
                else:
                    flag = True
                break
            x = s_i
        else:
            pass
        if flag:
            break
    else:
        ans = min(ans, res)

print(ans)

Measured memory_bytes: 44268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    vector<string> s(3);
    rep(i,3) cin>>s[i];
    sort(begin(s),end(s));
    int ans=INF;
    auto calc=[](char c1,char c2)->bool{
        return (c1=='?' || c2=='?' || c1==c2);
    };
    do{
        string a=s[0],b=s[1],c=s[2];
        int A=a.size(),B=b.size(),C=c.size();
        vector<bool> flag1(10000,true),flag2(10000,true),flag3(10000,true);
        rep(x,A){
            rep(i,B){
                if(x+i<A && !calc(a[x+i],b[i])) flag1[x]=false;
            }
            rep(i,C){
                if(x+i<A && !calc(a[x+i],c[i])) flag3[x]=false;
            }
        }
        rep(x,B){
            rep(i,C){
                if(x+i<B && !calc(b[x+i],c[i])) flag2[x]=false;
            }
        }
        rep(x,3000)rep(y,3000){
            if(flag1[x] && flag2[y] && flag3[x+y]){
                chmin(ans,max({x+y+C,A,B+x}));
            }
        }
    }while(next_permutation(begin(s),end(s)));
    cout<<ans<<endl;
}

Measured memory_bytes: 3688
w = input()
a = [0 for _ in range(26)]

for i in range(len(w)):
    s = ord(w[i]) - ord("a")
    a[s] += 1

for i in range(26):
    if a[i] % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int x;
    cin>> x;
    cout<< (1 - x)<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define FIO "agc37E"
#define ll long long

using namespace std;
const int N=1e5+5;

int n,k;
char s[N];

int a[N<<1];
inline string get(int l,int r){
  int t=k;
  for(int i=1;i<=n;i++)a[i]=i;
  string ret="";
  if(k==1){
    for(int i=n+1;i<=n<<1;i++)a[i]=a[n*2+1-i];
    for(int i=1;i<=n;i++)ret=ret+s[a[i+l-1]];
    return ret;
  }
  if(r^n){
    t--;
    for(int i=n+1;i<=n<<1;i++)a[i]=a[n*2+1-i];
    for(int i=1;i<=n;i++)
      a[i]=a[i+n+1-l];
    l+=n-r;
  }
  while(t>1){
    for(int i=n+1;i<=n<<1;i++)a[i]=a[n*2+1-i];
    for(int i=1;i<=n;i++)
      a[i]=a[n+1+i-l];
    l=2*l-n-1;
    t--;
  }
  for(int i=n+1;i<=n<<1;i++)a[i]=a[n*2+1-i];
  for(int i=1;i<=n;i++)ret=ret+s[a[i+l-1]];
  return ret;
}

int main(){
  scanf("%d%d%s",&n,&k,s+1);

  char low='z'+1;
  int cnt=0,mx=0;
  for(int i=1;i<=n;i++){
    if(s[i]<low){
      low=s[i];
      cnt=1;
      mx=1;
    }else if(s[i]==low)cnt++;
    else mx=std::max(cnt,mx),cnt=0;
  }

  if(s[n]==low){
    int x=n;
    while(x-1&&s[x-1]==low)x--;
    x=n-x+1;
    if((1<<min(30,k))>=(n+x-1)/x){
      for(int i=1;i<=n;i++)putchar(low);
      return 0;
    }
  }

  if((1<<min(30,k-1))>=(n+mx-1)/mx){
    for(int i=1;i<=n;i++)putchar(low);
    return 0;
  }

  string ans="";
  ans+=char('z'+1);
  //printf("mx=%d\n",mx);

  for(int i=1,j;i<=n;i=j+1){
    while(i<=n&&s[i]!=low)i++;
    if(i>n)break;
    j=i;
    while(s[j+1]==s[i])j++;
    if(j-i+1==mx||j==n){
      //printf("%d %d\n",i,j);
      ans=min(ans,get(i,j));
    }
  }
  cout<<ans;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    int num = n % 10;
    string ans;
    switch (num) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            ans = "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            ans = "pon";
            break;
        case 3:
            ans = "bon";
            break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
   int w,h,x,y,r;
   scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
   if(0<=x-r && 0<=y-r && x+r<=w && y+r<=h)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}



Measured memory_bytes: 2108
def main():
  import bisect
  n,k=map(int,input().split())
  x=list(map(int,input().split()))
  ans=abs(x[0])*2+abs(x[-1])*2
  if 0 in x:
    r=x.index(0)
    l=max(0,r-(k-1))
  else:
    r=bisect.bisect_right(x,0)
    l=max(0,r-k)
  ans=2*abs(x[0])+2*abs(x[-1])
  for i in range(l,min(n-k+1,r+1)):
    if x[i]*x[i+k-1]<=0:
      a=min(abs(x[i]),abs(x[i+k-1]))
      b=max(abs(x[i]),abs(x[i+k-1]))
      ans=min(ans,2*a+b)
    else:
      b=max(abs(x[i]),abs(x[i+k-1]))
      ans=min(ans,b)
  print(ans)
if __name__=='__main__':
  main()


Measured memory_bytes: 14380
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a==7) {
        if (b==5 && c==5) {
            printf("YES\n");
        }
        else
            printf("NO\n");
    }

    else if (b==7) {
        if (a==5 && c==5) {
            printf("YES\n");
        }
        else
            printf("NO\n");
    }

    else if (c==7) {
        if (b==5 && a==5) {
            printf("YES\n");
        }
        else
            printf("NO\n");
    }

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


Measured memory_bytes: 128
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         Unit[] arr = new Unit[N];
         for(int i=0; i < N; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());
            arr[i] = new Unit(x, y);
         }
         //days increase, reward decrease
         Arrays.sort(arr);
         int maxday = 1;
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         int i=0;
         for(; i < N; i++)
         {
            if(arr[i].a == maxday)
               pq.add(-1*arr[i].b);
            else
               break;
         }
         int res = 0;
         for(; maxday <= M; maxday++)
         {
            for(; i < N; i++)
            {
               if(arr[i].a <= maxday)
                  pq.add(-1*arr[i].b);
               else
                  break;
            }
            if(pq.size() == 0)
               continue;
            int max = -1*pq.poll();
            res += max;
         }
         System.out.println(res);
      }
   }
   class Unit implements Comparable<Unit>
   {
      public int a;
      public int b;
      
      public Unit(int x, int b)
      {
         a = x;
         this.b = b;
      }
      public int compareTo(Unit oth)
      {
         if(a != oth.a)
            return a-oth.a;
         return oth.b-b;
      }
   }

Measured memory_bytes: 46928
#include<stdio.h>
int main(void){
        int n,m,x,y;
        int a[100],b[100];
        int i;
        int max,min;
        scanf("%d %d %d %d",&n,&m,&x,&y);
        for(i=0;i<n;i++) scanf("%d",&a[i]);
        for(i=0;i<m;i++) scanf("%d",&b[i]);
        max=x; min=y;
        for(i=0;i<n;i++) if(a[i]>max) max=a[i];
        for(i=0;i<m;i++) if(b[i]<min) min=b[i];
        if(max>=min) printf("War\n");
        else printf("No War\n");
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;

int main(){
    int n,c;
    cin>>n>>c;
    vector<int> imos(100050);
    for(int i=0;i<n;++i){
        int s,t,c;
        cin>>s>>t>>c;
        imos[s]++;
        imos[t+1]--;
    }
    for(int i=0;i<100000;++i)imos[i+1] += imos[i];
    int ret = 0;
    for(int i=1;i<=100000;++i){
        ret = max(ret,imos[i]);
    }
    ret = min(ret,c);
    cout << ret << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(20) << x << endl
const int MOD = 1e9 + 7;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

template <int mod = 1000000007>
struct Combination {
  std::vector<long long> fac, finv, inv;
  Combination(ll n) : fac(n + 1, 0), finv(n + 1, 0), inv(n + 1, 0) {
    for (ll i = 0; i < n + 1; ++i) {
      bool one_or_zero = i == 0 || i == 1;
      fac[i] = one_or_zero ? 1 : fac[i - 1] * i % mod;
      inv[i] = one_or_zero ? 1 : mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = one_or_zero ? 1 : finv[i - 1] * inv[i] % mod;
    }
    inv[0] = 0;
  }
  ll operator()(ll n, ll r) {
    if (n < r || n < 0 || r < 0)
      return 0;
    else if (n == r || r == 0)
      return 1;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
  }
};

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

  ll n, k;
  cin >> n >> k;
  Combination<MOD> comb(n + 1);
  ll ans = 0;
  for(ll i = 0; i < min(n, k + 1); ++i) {
    ans += (comb(n, i) * comb(n - 1, i)) % MOD;
    ans %= MOD;
  }
  out(ans % MOD);

  return 0;
}


Measured memory_bytes: 4992
#include<cstdio>

int main(){
	int H, W;

	while(1){
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) break;
		else if (H == 0 || W == 0) printf("ばなな\n");

		else for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if ((i + j)%2 == 0) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2576
using System;
using System.Linq;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var wr = Console.ReadLine().ToCharArray();
            var cnt_r = 0;
            for (int i = 0; i < n; ++i) {
                if (wr[i] == 'R') cnt_r++;
            }
            int ans = 0;
            for (int i = 0; i < cnt_r; ++i) {
                if (wr[i] == 'W') ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28200
/*
    B - Great Ocean View
    https://atcoder.jp/contests/abc124/tasks/abc124_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    int Hi[20] = {};
    for (int i = 0; i < n; i++) {
        cin >> Hi[i];
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        bool can_see = true;
        int cur = Hi[i];
        for (int j = 0; j <= i; j++) {
            if (cur < Hi[j])
                can_see = false;
        }

        if (can_see)
            sum++;
    }
    cout << sum << endl;
}

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

double n, k, ans;
double win_c[100000], c[100000];


int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		c[i] = i + 1;
		win_c[i] = 1 / n;
		while (c[i] < k) {
			c[i] = c[i] * 2;
			win_c[i] = win_c[i] / 2;
		}
		ans = ans + win_c[i];
	}
	cout << setprecision(12)<< ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");

  var L = parseInt( input );
  var l = L / 3;
  
  console.log( ( l * l * l ) );
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>

int main(){
    /*
    int t;
    long long int total = 1;
    scanf("%d", &t);

    for(int i = 0; i < t; i++){
        long long int angka;
        scanf("%lld", &angka);
        total *= angka;
    }
    if( total > 1000000000000000000){
            printf("-1\n");
        }else{
             printf("%lld\n", total);
        }*/

    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d\n", a*b);

    return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
	#include<ext/pb_ds/assoc_container.hpp>
	#include<ext/pb_ds/tree_policy.hpp>
	#define int long long
	#define w(t) int t;cin>>t;while(t--)
	#define pb push_back
	#define mk make_pair
	#define ascSort(v) sort(v.begin(), v.end())
	#define descSort(v) sort(v.begin(), v.end(), greater<int>())
	#define ff first
	#define ss second
	#define pi pair<int,int>
	#define vi vector<int>
	#define umapi unordered_map<int,int>

	const int m=998244353;
	using namespace std;
	using namespace __gnu_pbds;

	typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

	void FIO(){
		#ifndef ONLINE_JUDGE
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
		#endif
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);	
	}

	int32_t main(){
		
		//FIO();
		
			int a,b,c,d;cin>>a>>b>>c>>d;
			cout<<max(max(b*d,a*c),max(a*d,b*c));
				
		

        		
		return 0;
		
			
	}



		
		

Measured memory_bytes: 3636
N = int(input())
S = input()
ans = 0
 
numlist = [str(i) for i in range(10)]
for a in numlist:
    idx_a = S.find(a)
    if idx_a == -1 or idx_a >= N - 2:
        continue
    
    for b in numlist:
        idx_b = S[idx_a+1:].find(b)
        if idx_b == -1 or idx_a + idx_b + 1 >= N - 1:
            continue
        
        for c in numlist:
            if c in S[idx_a + idx_b + 2:]:
                ans += 1
print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
int main(){
    ll N, K; cin >> N >> K;
    string S; cin >> S;

    ll cnt = 0; ll l = 0; ll r = 0;
    rep(i,N-1) if(S[i] == S[i+1]) cnt++;
    cout << min(cnt + 2*K, N-1) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define LL long long
int main(){
    CIN(N);
    CIN(T);
    LL ans = T;
    I vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    REP(a,N-1){
        ans += T - max(0,T - (vec.at(a+1)-vec.at(a)));
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

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

  for(int i=n; i>=0; i--){
    bool flg=true;
    rep(j,i){
      if(s[n-i+j] != t[j]){
        flg=false;
        break;
      }
    }
    if(flg){
      cout<<2*n-i<<endl;
      return 0;
    }
  }

  return 0;
}


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

#ifdef LOCAL
#include <local.h>
#endif

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using i64 = long long;
template <typename T> using p = pair<T,T>;

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

    int k, a, b; cin >> k >> a >> b;
    if (((a+k-1)/k)*k <= b)
        cout << "OK" << ende;
    else
        cout << "NG" << ende;

    return 0;
}


Measured memory_bytes: 3664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (NK[0] == 1)
            {
                Console.WriteLine(NK[1]);
            }
            else
            {
                Console.WriteLine(NK[1] * (Math.Pow(NK[1]- 1, NK[0] - 1)));
            }
        }
    }
}

Measured memory_bytes: 13268
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long mod = 10^^9 + 7;
int n;
int[] a;

void main() {
    scan(n);
    a = readln.split.to!(int[]);

    // ２回でてくるものを探す
    auto cnt = new int[](n + 1);

    foreach (i ; 0 .. n + 1) {
        cnt[a[i]]++;
    }

    auto x = -1;

    foreach (i ; 1 .. n + 1) {
        if (cnt[i] == 2) {
            x = i;
            break;
        }
    }

    // 左にあるもの、右にあるものの個数をカウント
    int L, R;

    foreach (i ; 0 .. n + 1) {
        if (a[i] == x) {
            L = i;
            break;
        }
    }

    foreach_reverse (i ; 0 .. n + 1) {
        if (a[i] == x) {
            R = n - i;
            break;
        }
    }

    auto fact = new long[](n + 2);
    auto fact_r = new long[](n + 2);
    fact[0] = 1L;
    fact_r[0] = 1L;

    foreach (i ; 1 .. n + 2) {
        fact[i] = (i * fact[i - 1]) % mod;
    }

    fact_r[n + 1] = modpow(fact[n + 1], mod - 2, mod);

    foreach_reverse (i ; 0 .. n + 1) {
        fact_r[i] = ((i + 1) * fact_r[i + 1]) % mod;
    }

    debug {
        writeln("fact:", fact);
        writeln("fact_r:", fact_r);
    }

    long binom(int n, int k) {
        return fact[n] * fact_r[n - k] % mod * fact_r[k] % mod;
    }

    foreach (k ; 1 .. n + 2) {
        long ans = binom(n + 1, k);

        if (L + R >= k - 1) {
            ans -= binom(L + R, k - 1);
            if (ans < 0) ans += mod;
        }

        writeln(ans);
    } 
}

T modpow(T)(T x, T y, T mod){
    return y ? modpow(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 7484
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
res = 0
for i in range(1, N + 1):
    p = 1
    x = i
    while x < K:
        x *= 2
        p /= 2
    res += p
res /= N
print(res)


Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  vi t(9,0);
  rep(i,n)
    if(a[i]<3200)t[a[i]/400]++;
    else t[8]++;
  int ans=0;
  rep(i,8)if(t[i])ans++;
  if(ans) cout<<ans<<" "<<ans+t[8]<<endl;
  else cout<<1<<" "<<t[8]<<endl;
}


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

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

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

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

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

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

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

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

use std::collections::HashMap;
use std::cmp::Ordering;


fn main() {
    input!{
        n:i32,
        restaurant : [(String , i32);n],
    }


   let mut result  = restaurant.into_iter().enumerate().map(|(i,(s,p))| (i,s,p)).collect::<Vec<_>>();
   //.map(|i,(s,u)| (i,s,u)).collect();
   result.sort_by(|r,l| {
       if r.1 != l.1 {return r.1.cmp(&l.1)}
       else{
           match r.2.cmp(&l.2) {
               Ordering::Less => {return Ordering::Greater}
               _ => {return Ordering::Less}
           }
       }
   });

    let ret = result.iter().map(|&(index,_,_)| (index+1).to_string()).collect::<Vec<_>>();


   println!("{}",ret.connect("\n"));
   
   


}


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

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

	set<int> set;
	rep(i, n) {
		int a;
		cin >> a;
		set.insert(a);
	}

	cout << ((set.size() == n) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 9600
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int h[100010];
int main()
{
    int n, m, a, b, i;
    scanf("%d%d", &n, &m);
    while(m--)
    {
        scanf("%d%d", &a, &b);
        if(a == n)
        {
            h[b]++;
        }else
        if(b == n)
        {
            h[a]++;
        }else
        {
            h[a]++;
            h[b]++;
        }
    }
    int mark = 0;
    for(i = 1; i < n; ++i)
    {
        if(h[i] % 2 == 1)
        {
            mark = 1;
            puts("NO");
            break;
        }
    }
    if(!mark)
        puts("YES");
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm> 
int a[1000000];
int main()
{
	int n,c;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{	
		scanf("%d",&c);
		a[c-1]++;
		a[c]++;
		a[c+1]++;
	}
	std::sort(a,a+1000000);
	printf("%d",a[999999]);
	return 0;
}

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

int main() {
  int N;
  int count = 0;
  int M = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
      cin >> A.at(i);
  }
  for(int i = 0; i < N; i++){
      if(A.at(i) % 2 == 0){
          count++;
      }
  }
  for(int i = 0; i < N; i++){
      if(A.at(i) % 2 == 0 && A.at(i) % 3 == 0){
         count--;
      }
      else if(A.at(i) % 2 == 0 && A.at(i) % 5 == 0){
         count--;
      }
  }
  if(count == 0 ){
      cout << "APPROVED" << endl;
  }
   else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int num1 = scan.nextInt();
      String op = scan.next();
      int num2 = scan.nextInt();
        if(op.equals("+")){
          System.out.println(num1 + num2);
        }
        else{
          System.out.println(num1 - num2);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef pair<ll,ll> pl;

int n;
ll w;
vector<pl> s;//重さ、価値

ll dp[101][100005];

ll rec(int i, ll j){
    if(dp[i][j] > 0) return dp[i][j];

    ll res = 0;
    if(i==n){
        //全品物検索完了
        return 0; 
    }else if(j < s[i].first){
        //持ち帰れない
        res = rec(i+1, j);
    }else{
        res = max(rec(i+1, j), rec(i+1, j-s[i].first) + s[i].second);
    }

    dp[i][j] = res;
    return res;
}

int main() {
    cin>>n>>w;
    s.resize(n);

    REP(i,n){
        ll a,b;
        cin>>a>>b;
        s[i] = pl(a,b);
    }

    memset(dp,-1,sizeof(dp));

    ll ans = rec(0,w);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79232
using System;

public class Test
{
	public static void Main()
	{
		
		int a = int.Parse(Console.ReadLine());
		 for(int i = 0; a > i; i ++){
		 	int line1, line2, line3;
		 	
		 	string[] str = Console.ReadLine().Split(' ');
		 	
		 	line1 = int.Parse(str[0]);
		 	line2 = int.Parse(str[1]);
		 	line3 = int.Parse(str[2]);
		 	
		 	if(isRightTri(line1, line2, line3)){
		 		
		 		Console.WriteLine("YES");
		 		
		 	}else{
		 		
		 		Console.WriteLine("NO");
		 		
		 	}
		 	
		 }
		
	}
	
	public static bool isRightTri(int line1, int line2, int line3){
		bool isRightTri = false;
		int sqLine1 = line1*line1;
		int sqLine2 = line2*line2;
		int sqLine3 = line3*line3;
		
		if(sqLine1 == sqLine2 + sqLine3){ isRightTri = true; }
		else if(sqLine2 == sqLine1 + sqLine3){ isRightTri = true; }
		else if(sqLine3 == sqLine1 + sqLine2){ isRightTri = true; }
		
		return isRightTri;
	}
}


Measured memory_bytes: 15940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int p[maxn];
vector<int> child[maxn];
vector<int> ans[maxn];
bool vis[maxn];

int dfs(int u){
	vis[u]=1;
	for(int v:child[u]){
		ans[u].pb(dfs(v));
	}
	sort(ALL(ans[u]));
	int ret=0;
	REP(i,SZ(ans[u])) ret=max(ret,ans[u][i]+SZ(ans[u])-i);
	return ret;
}


int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>p[i];
		;p[i]--;
		child[p[i]].pb(i);
	}
	cout<<dfs(0);
}



Measured memory_bytes: 27264
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        Arrays.sort(a);
        System.out.println((a[2] - a[1]) + (a[1] - a[0]));
    }
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<int> E[610];
double DP[610], DP2[610];

int main(){
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int s, t;
		cin >> s >> t;
		E[s].push_back(t);
	}
	DP[1] = 1;
	for(int i = 1; i <= N; i++){
		for(int to : E[i]){
			DP[to] += DP[i] / E[i].size();
		}
	}
	for(int i = N - 1; i >= 1; i--){
		for(int to : E[i]){
			DP2[i] += DP2[to];
		}
		DP2[i] /= E[i].size();
		DP2[i] += 1;
	}
	double diff = 0;
	for(int i = 1; i <= N - 1; i++){
		if(E[i].size() == 1){
			continue;
		}
		//cout << "i = " << i << endl;
		for(int to : E[i]){
			double rem = DP2[i] - (DP2[to] + 1) / E[i].size();
			rem = rem * E[i].size() / (E[i].size() - 1);
			//cout << rem << endl;
			diff = max(diff, (DP2[i] - rem) * DP[i]);
		}
		//cout << diff << endl;
	}
	printf("%.10f\n", DP2[1] - diff);
	return 0;
}

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

#include <boost/pending/disjoint_sets.hpp>
#include <boost/property_map/property_map.hpp>

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

template <typename T1, typename T2>
bool pair_second_lt(const pair<T1, T2> &p1, const pair<T1, T2> &p2) {
  return p1.second < p2.second;
}

int solve(vector<int> &A, vector<int> &B, int N) {
  unordered_map<int, int> rank;
  unordered_map<int, int> parent;

  boost::disjoint_sets<boost::associative_property_map<unordered_map<int, int>>,
                       boost::associative_property_map<unordered_map<int, int>>>
      dset(boost::make_assoc_property_map(rank),
           boost::make_assoc_property_map(parent));

  for (size_t i = 0; i < N; i++) {
    dset.make_set(i);
  }

  for (size_t i = 0; i < A.size(); i++) {
    dset.union_set(A[i] - 1, B[i] - 1);
  }

  std::vector<int> count_vec(N, 0);
  for (size_t i = 0; i < N; i++) {
    count_vec[dset.find_set(i)]++;
  }

  return *(max_element(ALL(count_vec)));
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  std::vector<int> A(M, 0), B(M, 0);
  for (size_t i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }

  // main procedure
  int ans = solve(A, B, N);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 22124
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int i,u,minv,d[MAX],color[MAX];
  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(i = 0 ; i < n ; i++){
      if(color[i] != BLACK && M[u][i] != INFTY){
	if(d[i] > d[u] + M[u][i]){
	  d[i] = d[u] + M[u][i];
	  color[i] = GRAY;
	}
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i,d[i] == INFTY ? -1 : d[i]);
  }
}

int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = INFTY;
    }
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d %d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d %d",&v,&c);
      M[u][v] = c;
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	char t = '1';
	int ri = 0;
	rep(j, k) {
		while (ri < n&&s[ri] == t)ri++;
		while (ri < n&&s[ri] != t)ri++;
		while (ri < n&&s[ri] == t)ri++;
		if (ri == n)break;
	}
	int ans = ri;
	rep(i, n) {
		if (i == n)break;
		if (i>0&&s[i] == '1') {
			while (ri < n&&s[ri] == '0')ri++;
			while (ri < n&&s[ri] == '1')ri++;
		}
		ans = max(ans, ri - i);
		while (i + 1 < n&&s[i + 1] == s[i])i++;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 512
// C - Big Array
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)

int main(){
	int N; ll K; cin>>N>>K;
	vector<ll> count(100000);
	int maxi = 0;
	rp(i,N){
		int a,b; cin>>a>>b;
		count[a-1] += b;
		maxi = max(maxi, a);
	}
	rp(i,maxi){
		if(K<=count[i]){
			cout<< i+1 <<endl;
			break;
		}
		K -= count[i];
	}
}

Measured memory_bytes: 1024
using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string r = Console.ReadLine();
                if (r == null) break;
                double[] k0 = new double[6];
                for (int i = 0; i < 6; i++) k0[i] = double.Parse(r.Split(' ')[i]);
                string x, y;
                y = ((k0[2] * k0[3] - k0[0] * k0[5]) / (k0[1] * k0[3] - k0[0] * k0[4])).ToString();
                x = ((k0[2] - k0[1] * double.Parse(y)) / (k0[0])).ToString();
                Console.WriteLine(String.Format("{0:0.000} {1:0.000}", double.Parse(x), double.Parse(y)));
            }
        }
    }
}

Measured memory_bytes: 8920
# https://beta.atcoder.jp/contests/abc056/submissions/2924044
N, K, *as = $stdin.read.split.map(&:to_i)
AS = as.sort.reverse

sum_a = 0
ans = 0
for i in 0...N
  if sum_a + AS[i] < K
    sum_a += AS[i]
    ans += 1
  else
    ans = 0
  end
  #p a: AS[i], sum_a: sum_a, ans: ans
end
p ans



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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string s;
    cin >> s;
    for(int i=1; i<s.size(); i++)
    {
        if (s[i] != s[i-1]) return cout << "Yes\n" , 0;
    }
    cout << "No\n";


    return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin>>s;
    char last=s[0];
    bool flag=true;
    repd(i,1,s.size()){
        if(last==s[i]){
            flag=false;
        }
        last=s[i];
    }

    if(flag){
        cout<<"Good"<<endl;
    }else{
        cout<<"Bad"<<endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,K,L;
int color[200001];
int color2[200001];
vector<int>G[200001];
vector<int>G2[200001];
bool used[200001];

void dfs(int x,int c){
	color[x]=c;
	used[x]=true;
	REP(i,G[x].size()){
		if(used[G[x][i]]==false){
			dfs(G[x][i],c);
		}
	}
}


void ddfs(int x,int c){
	color2[x]=c;
	used[x]=true;
	REP(i,G2[x].size()){
		if(used[G2[x][i]]==false){
			ddfs(G2[x][i],c);
		}
	}
}

typedef pair<int,int>P;
int main(){
	cin>>N>>K>>L;
	REP(i,K){
		int p,q;
		cin>>p>>q;
		p--;q--;
		G[p].push_back(q);
		G[q].push_back(p);
	}
	REP(i,L){
		int r,s;
		cin>>r>>s;
		r--;s--;
		G2[r].push_back(s);
		G2[s].push_back(r);
	}
	REP(i,200001){
		color[i]=-1;
		color2[i]=-1;
		used[i]=false;
	}
	int c=0;
	REP(i,N){
		if(used[i]==false){
			dfs(i,c);
			c++;
		}
	}
	REP(i,200001){
		used[i]=false;
	}
	c=0;
	REP(i,N){
		if(used[i]==false){
			ddfs(i,c);
			c++;
		}
	}
	map<P,int>m;
	REP(i,N){
		m[P(color[i],color2[i])]++;
	}
	REP(i,N){
		//cout<<"a"<<color[i]<<" "<<color2[i]<<endl;
		cout<<m[P(color[i],color2[i])]<<endl;
	}
	return(0);
}

Measured memory_bytes: 28160
from itertools import combinations as co
h,w,k=map(int,input().split())
m=[list(input()) for i in range(h)]
pr=[]
pc=[]
for i in range(h+1):
  pr+=list(co(range(h),i))
for i in range(w+1):
  pc+=list(co(range(w),i))
a=0
for i in pr:
  for j in pc:
    n=[m[x][:] for x in range(h)]
    for x in i:
      for y in range(w):
        n[x][y]="."
    for x in j:
      for y in range(h):
        n[y][x]="."
    if sum(x.count("#") for x in n)==k:
      a+=1
print(a)


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

using namespace std;

struct edge
{
  int to, cost;
};

typedef pair< int, int > Pi;
const int INF = 1LL << 30;

int N, M, P;
int v1[100], v2[100];
double dp1[100], dp2[100];
vector< vector< edge > > g;

void Dijkstra(int s, int *v, double *dp)
{
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  fill_n(v, N, INF);
  fill_n(dp, N, 0);

  que.emplace(0, s);
  v[s] = 0;
  dp[s] = 1;

  while(!que.empty()) {
    auto p = que.top();
    que.pop();
    if(p.first > v[p.second]) continue;
    for(auto &e : g[p.second]) {
      if(p.first + e.cost < v[e.to]) {
        v[e.to] = p.first + e.cost;
        dp[e.to] = dp[p.second];
        que.emplace(v[e.to], e.to);
      } else if(p.first + e.cost == v[e.to]) {
        dp[e.to] += dp[p.second];
      }
    }
  }
}

int main()
{
  cout << fixed << setprecision(10);

  while(cin >> N >> M >> P, N) {
    g.resize(N);

    while(M--) {
      int X, Y, Z;
      cin >> X >> Y >> Z;
      g[X].emplace_back((edge) {Y, Z});
      g[Y].emplace_back((edge) {X, Z});
    }
    Dijkstra(0, v1, dp1);
    Dijkstra(N - 1, v2, dp2);

    while(P--) {
      int A;
      cin >> A;
      if(v1[A] + v2[A] == v1[N - 1])
        cout << (double) dp1[A] * dp2[A] / dp1[N - 1] << endl;
      else
        cout << 0 << endl;
    }
    cout << endl;

    g.clear();
  }
}

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

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 100010
#define MOD 1000000007

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

int n, k, r, s, p;

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

    string t;
    cin >> n >> k >> r >> s >> p;
    map<char, int> mi;

    mi['r'] = p;
    mi['p'] = s;
    mi['s'] = r;

    cin >> t;

    int ans = 0;
    	
    for (int i = 0; i < n; ++i)
    {
    	ans += mi[t[i]];
    }

    int i = 0;
    for (int i = 0; i < k; ++i)
    {
    	int m = i;
    	while(m + k < n)
    	{
    		if(t[m] == t[m + k])
    			ans -= mi[t[m]], m += k;
    		m += k;
    	}
    }
    cout << ans;

 	return 0;
}


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

n, a, b = [int(x) for x in input().split()]
s = input()
c_a = 0
c_f = 1
for e in s:
    if e == 'a':
        if c_a < a + b:
            print("Yes")
            c_a += 1
            continue
    elif e == 'b':
        if c_a < a + b:
            if c_f <= b:
                print("Yes")
                c_a += 1
                c_f += 1
                continue
    print("No")


Measured memory_bytes: 4016
#include <stdio.h>

int main() {
	int n,i,j;
	char mark;
	int num;
	int Mark=4,Num=13;
	int a[Mark][Num+1];

	for(i=0;i<Mark;i++)
	{
		for(j=1;j<Num+1;j++)
		{
			a[i][j]=1;
		}
	}

	scanf("%d\n",&n);

	for(i=0;i<n;i++)
	{
		scanf("\n",&mark);
		scanf("%c %d\n",&mark,&num);
		
		if(mark==83)
		{
			a[0][num]=0;
		}else if(mark==72)
		{
			a[1][num]=0;
		}else if(mark==67)
		{
			a[2][num]=0;
		}else if(mark==68)
		{
			a[3][num]=0;
		}
	}
	
	for(i=0;i<Mark;i++)
	{
		for(j=1;j<Num+1;j++)
		{
			if(a[i][j]==1)
			{
				if(i==0)
				{
					printf("S %d\n",j);
				}else if(i==1)
				{
					printf("H %d\n",j);
				}else if(i==2)
				{
					printf("C %d\n",j);
				}else if(i==3)
				{
					printf("D %d\n",j);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2724