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

using namespace std;

#define READ() 	    freopen("in.txt","r",stdin)
#define WRITE()     freopen("out.txt","w",stdout)
#define sf(n) 	    scanf("%d",&n)
#define sl(x)       scanf("%I64d",&x)
#define lsf(n) 	    scanf("%lld", &n)
#define pb(n) 	    push_back(n)
#define EPS 	    1e-10
#define INF         INT_MAX
#define MAX         100010
#define MOD         1000000007
#define LL          long long
#define endl        "\n"
#define pi          2.0*acos(0.0)
#define cnd         tree[idx]
#define lnd         tree[left]
#define rnd         tree[right]
#define callLeft    left,st,mid
#define callRight   right,mid+1,ed

int arr[MAX];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0); /// use "\n" instead of endl
//    READ();
//    WRITE();


    int n;
    cin >> n;

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

    int cnt = 0;

    for(int i=1;i<=n;i++)
    {
        int x = arr[i];
        if(i == arr[x])cnt++;
    }
    cout << cnt/2 << endl;

    return 0;
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let x: i64 = read();
    let mut a: i64 = 100;
    let mut cnt: usize = 0;
    while a < x {
        let interest = a as f64 * 0.01;
        a += interest as i64;
        cnt += 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2108
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    Int N;

    cin >> N;
    string ans;
    vi L = vi(N);
    rep(i,N){
        cin >> L[i];
    }
    sort(L.begin(), L.end(),greater<>());
    Int total =0;
    REP(i,1,N){
        total += L[i];
    }

    if(L[0] < total){
        ans = "Yes";
    }else{
        ans = "No";
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b);i++)
#define repv(vec,v) for(auto v=(vec).begin(); v!=(vec).end();v++)
#define sz(vec) (int)(vec).size()
#define PB push_back
#define F first()
#define S second()


int main(){
	int n,m;
	cin >> n >> m;
	vi a(n);
	int sum = 0;
	rep(i,0,n-1){
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	int mm = 0;
	
	repv(a, ai){
		if((double)*ai >= (double)sum/((double)(4*m)))
			mm++;
		else
			break;
	}
	if (mm >= m)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !
while True:
    a,b = map(int, input().split())
    
    if a == b == 0:
        break
    
    for i in range(a):
        for j in range(b):
            if i == 0 or i == (a-1) or j == 0 or j == (b-1):
                print("#",end="")
            else:
                print(".",end="")
        print()
        
    print()

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int a,b,c;cin >> a>> b >> c;
    ll sum=0;
    for(int i = 0; i < b; i++) {
        sum += a;
        if(sum % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    for (int i=1; i<=n; i++) {
        if (m <= 0) break;
        m--;
        cout << i + (n%2==0 && n-i-i+1<=n/2) << " " << n-i+1 << endl;
    }
}

Measured memory_bytes: 3184
### main

not_first = false

loop do
  h = gets.to_i
  break if h == 0

  lines = h.times.map{gets.chomp}

  w = lines.map{|l| l.length}.max
  lines.map!{|l| l + ' ' * (w - l.length)}
  #p [w, h]
  #lines.each{|l| p l}

  arhash = {}
  
  for y0 in (0...h)
    for x0 in (0...w)
      next if lines[y0][x0] == ' '

      tx0 = tx1 = x0
      ty = y0
      lines[ty][tx0] = ' '
      for tx in ((tx0 + 1)...w)
        break if lines[ty][tx] == ' '
        tx1 = tx
        lines[ty][tx] = ' '
      end

      by = ty + 1
      for dx in (-1..1)
        bx0 = tx0 + dx
        break if bx0 >= 0 && bx0 < w && lines[by][bx0] == '*'
      end
      bx0 = tx0 + dx
      while by < h && bx0 >= 0 && bx0 < w && lines[by][bx0] == '*'
        lines[by][bx0] = ' '
        by += 1
        bx0 += dx
      end
      by -= 1
      bx0 -= dx

      for dx in (-1..1)
        bx1 = tx1 + dx
        break if bx1 >= 0 && bx1 < w && lines[ty + 1][bx1] == '*'
      end
      bx1 = tx1
      for y in ((ty + 1)..by)
        bx1 += dx
        lines[y][bx1] = ' '
      end

      for x in ((bx0 + 1)...bx1)
        lines[by][x] = ' '
      end
      #p [[tx0, ty], [tx1, ty], [bx0, by], [bx1, by]];
      #lines.each{|l| p l}; exit

      ar = ((tx1 - tx0 + 1) + (bx1 - bx0 + 1)) * (by - ty + 1) / 2
      #p ar

      if arhash[ar].nil?
        arhash[ar] = 1
      else
        arhash[ar] += 1
      end
    end
  end

  puts '-' * 10 if not_first
  not_first = true

  for ar in arhash.keys.sort
    puts [ar, arhash[ar]].join(' ')
  end
end

Measured memory_bytes: 6152
#include <stdio.h>
#include <stdlib.h>

int partition(int*,int,int);

int main(){
  int *A;
  int n, i, r;

  //input
  
  scanf("%d", &n);

  A = malloc(sizeof(int)*n);

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

  //main

  r = partition(A,0,n-1);
  
  //output
  
  for(i = 0; i < n-1; i++){
    if(i == r){
      printf("[%d] ",A[i]);
    }
    else printf("%d ",A[i]);
  }

  if(i == r){
      printf("[%d]\n",A[i]);
    }
  else printf("%d\n",A[i]);
 
  free(A);
  
  return 0;
}

int partition(int *A,int p,int r){
  int i, j, temp;
  int x = A[r];
  i = p-1;

  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  return (i + 1);
}
  



Measured memory_bytes: 2144
/**
 * @author torith
 * @date 2018-10-27
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b){
    a += b;
    if (a >= md) a -= md;
}

inline void sub(int &a, int b){
    a -= b;
    if (a < 0) a += md;
}

inline int mul(int a, int b){
    return (int) ((ll) a * b % md);
}

inline int power(int a, long long b){
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, 1);
        b >>= a;
    }
    return res;
}

inline int dive(int a, int b){
    return mul(a, power(b, md - 2));
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    if(abs(N - M) > 1){
        cout << 0 << "\n";
        return 0;
    }

    int ans = 1;
    for (int i = 0; i < N; ++i) {
        ans = mul(ans,N-i);
    }
    for (int i = 0; i < M; ++i) {
        ans = mul(ans,M-i);
    }

    if(N == M){
        ans = mul(ans,2);
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

n = int(input())
dp = [[0]*3  for _ in range(n)] 
ABC = []
for _ in range(n):
    a,b,c = map(int,input().split())
    ABC.append([a,b,c])

def rec(flag,num):# flag は A=0,B=1,C=2を表す。 numは何番目かを表す。
    if dp[num][flag] != 0:
        return dp[num][flag]
    if num == 0:
        dp[num][flag] = ABC[num][flag]
        return dp[num][flag]
    else:
        res = 0
        if flag == 0:
            res = max(rec(1,num-1),rec(2,num-1))+ABC[num][flag]
        elif flag == 1:
            res = max(rec(0,num-1),rec(2,num-1))+ABC[num][flag]
        else:
            res = max(rec(1,num-1),rec(0,num-1))+ABC[num][flag]
        dp[num][flag] = res
        return dp[num][flag]

rec(0,n-1)
rec(1,n-1)
rec(2,n-1)

print(max(dp[n-1]))

Measured memory_bytes: 144876
#include <cstdio>

int main(){
int a,b;
char c;
while(true){
scanf("%d %c %d",&a,&c,&b);
if(c=='?') break;
if(c=='+') printf("%d\n",a+b);
if(c=='-') printf("%d\n",a-b);
if(c=='*') printf("%d\n",a*b);
if(c=='/') printf("%d\n",a/b);

}
return 0;
}

Measured memory_bytes: 1032
import bisect
A,B,Q = map(int,input().split())
INF = 10**18
s = [-INF]+[int(input()) for i in range(A)]+[INF]
t = [-INF]+[int(input()) for i in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(T-S)
            ans = min(ans,d1,d2)
    print(ans)

Measured memory_bytes: 77912
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

int main() {
    #ifdef LOCAL_JUDGE
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif

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

    for (LL n; cin >> n; ) {
        int pot = log2(n) + 1;
        cout << (1ll<<pot) - 1 << "\n";
    }

return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;
	while(ch<'-')ch=gt;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return k;
}
const int N=1e5+5,inf=1e9;
int a[N],b[N];
int main()
{
	int n=in();
	for(int i=1;i<=n;++i)(i&1)?a[in()]++:b[in()]++;
	int mx1=0,mi1=0,mx2=0,mi2=0;
	for(int i=1;i<=N-5;++i)
	{
		if(a[i]>a[mx1]||!mx1)mi1=mx1,mx1=i;
		else if(a[i]>a[mi1]||!mi1)mi1=i;
	}
	for(int i=1;i<=N-5;++i)
	{
		if(b[i]>b[mx2]||!mx2)mi2=mx2,mx2=i;
		else if(b[i]>b[mi2]||!mi2)mi2=i;
	}
	if(mx1!=mx2)return printf("%d\n",n-a[mx1]-b[mx2]),0;
	if(a[mx1]+b[mi2]>b[mx2]+a[mi1])return printf("%d\n",n-a[mx1]-b[mi2]),0;
	printf("%d\n",n-a[mi1]-b[mx2]);
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

void bubbleSort(char B[],int n);
void selectionSort(char A[],int n);

int main(){

  char A[72],B[72];
  int n,i,j,c=0;
  
  while(1){
    scanf("%d",&n);
    if(1<=n&&n<=36){
      for(i=0;i<2*n;i=i+2){
	scanf("%s", &A[i]);
      }
      break;
    }
  }

  for(i=0;i<2*n;i=i+2){
    B[i]=A[i];
    B[i+1]=A[i+1];
  }

  bubbleSort(B,n);
  selectionSort(A,n);

  for(i=0;i<2*n;i=i+2){
    if(i>0) printf(" ");
    printf("%c%c",B[i],B[i+1]);
  }
  printf("\n");
  printf("Stable\n");

  for(i=0;i<2*n;i=i+2){
    if(i>0) printf(" ");
    printf("%c%c",A[i],A[i+1]);
  }
  printf("\n");
  for(i=0;i<2*n;i=i+2){
    if(A[i]==B[i]&&A[i+1]==B[i+1]) c++;
    else {
      printf("Not stable\n");
      break;
    }

  }
  if(c==n) printf("Stable\n");
  return 0;
}

void selectionSort(char A[],int n){
  int i,j,min;
  char t,c;
  for(i=1;i<2*n;i=i+2){
    min=i;
    for(j=i;j<2*n;j++){
      if(A[min]>A[j]) min=j;
    }
    if(A[min]!=A[i]){
      t=A[i];
      c=A[i-1];
      A[i]=A[min];
      A[i-1]=A[min-1];
      A[min]=t;
      A[min-1]=c;
    }
  }
}

void bubbleSort(char B[],int n){
  int i,j;
  char c,t;
  for(i=1;i<2*n;i=i+2){
    for(j=2*n-1;j>=i;j=j-2){
      if(B[j]<B[j-2]) {
	t=B[j];
	c=B[j-1];
	B[j]=B[j-2];
	B[j-2]=t;
	B[j-1]=B[j-3];
	B[j-3]=c;
      }
    }
  }
}



Measured memory_bytes: 2088
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
int main(){
  long long n,m,a,b,i,j,k,l,w,d[4][100],r[4]={1};
  long long max=0,s[4][100]={};
  scanf("%lld %lld %lld %lld",&n,&m,&a,&b);
  d[0][0]=b;
  for(i=1;i<n;i++){
    scanf("%lld %lld",&w,&b);
    w-=a;
    for(j=r[w]++;j&&d[w][j-1]<b;j--)d[w][j]=d[w][j-1];
    d[w][j]=b;
  }
  /*for(i=0;i<4;i++){
    for(j=0;j<r[i];j++)printf("%lld ",d[i][j]);printf("\n");
    }//*/
  for(i=0;i<4;i++){
    for(j=0;j<r[i];j++)s[i][j+1]=d[i][j]+s[i][j];
  }
  /*for(i=0;i<4;i++){
    for(j=0;j<=r[i];j++)printf("%lld ",s[i][j]);printf("\n");
    }//*/
  for(i=0;i<=r[0];i++){
    for(j=0;j<=r[1];j++){
      for(k=0;k<=r[2];k++){
	for(l=0;l<=r[3];l++){
	  if((a+0)*i+(a+1)*j+(a+2)*k+(a+3)*l>m)continue;
	  max=MAX(max,s[0][i]+s[1][j]+s[2][k]+s[3][l]);
	}
      }
    }
  }
  printf("%lld\n",max);
  return 0;
}


Measured memory_bytes: 128
def cut(d, w, s):
    s %= 2 * (d + w)
    sq = []
    if 0 < s < w:
        sq = [(d, s), (d, w - s)]
    elif w < s < w + d:
        s -= w
        sq = [(s, w), (d - s, w)]
    elif w + d < s < 2 * w + d:
        s -= w + d
        sq = [(d, s), (d, w - s)]
    elif 2 * w + d < s < 2 * (w + d):
        s -= 2 * w + d
        sq = [(s, w), (d - s, w)]
    else:
        assert(False)
    p1, p2 = sq
    if p1[0] * p1[1] > p2[0] * p2[1]:
        p1, p2 = p2, p1
    return [p1, p2]


while True:
    N, W, D = map(int, input().split())
    if not (N | W | D):
        break
    square = [(D, W)]
    for _ in range(N):
        p, s = map(int, input().split())
        d, w = square.pop(p - 1)
        square.extend(cut(d, w, s))
    print(*sorted(d * w for d, w in square))

Measured memory_bytes: 7572
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    long n,m;
    cin >> n>> m;
    long a[n][m],b[m];
    F(i,0,n) F(j,0,m) cin >> a[i][j];
    F(i,0,m) cin >> b[i];
    long ans[n]={};
    F(i,0,n){
        F(j,0,m){
            ans[i]+=a[i][j]*b[j];
        }
    }
    F(i,0,n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3148
from math import gcd
k=int(input())
d={}
for a in range(1,k+1):
  for b in range(1,k+1):
    g=gcd(a,b)
    if g not in d:
      d[g]=0
    d[g]+=1
print(sum(gcd(a,c)*d[a] for a in d for c in range(1,k+1)))


Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, K;
vector<vi> G;

vi bfs(int s, int k){
    vi vis(N);
    queue<pii> Q;
    Q.push(mp(s, 0));
    while(sz(Q)){
        int u, d;
        tie(u, d) = Q.front();
        Q.pop();
        if(d > k || vis[u])continue;
        vis[u] = 1;
        each(v, G[u])Q.push(mp(v, d + 1));
    }
    return vis;
}

int main(){
    
    while(cin >> N >> K){
        G = vector<vi>(N);
        vi A(N - 1), B(N - 1);
        rep(i, N - 1){
            cin >> A[i] >> B[i];
            --A[i];
            --B[i];
            G[A[i]].push_back(B[i]);
            G[B[i]].push_back(A[i]);
        }

        int ans = INT_MAX;
        if(K % 2 == 0){
            rep(center, N){
                vi vis = bfs(center, K / 2);
                smin(ans, (int)count(all(vis), 0));
            }
        } else{
            rep(i, N - 1){
                vi visFromA = bfs(A[i], (K - 1) / 2);
                vi visFromB = bfs(B[i], (K - 1) / 2);
                int val = 0;
                rep(j, N)val += 1 - (visFromA[j] | visFromB[j]);
                smin(ans, val);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>

int main() {
	int K;
	std::cin >> K;

	int mod = 7 % K;
	int answer = 1;
	int count = 1;
	while (mod != 0) {
		count++;
		if (count > K) {
			std::cout << -1 << std::endl;
			return 0;
		}
		answer++;
		mod = (10 * mod + 7) % K;
	}

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<pair<int,int>> u(n),v(n);
    REP(i,n){
        int a,b;cin >> a >> b;
        u[i]={b,a};
    }
    REP(i,n){
        int c,d;cin >> c >> d;
        v[i]={c,d};
    }
    sort(ALL(u));
    reverse(ALL(u));
    sort(ALL(v));
    int ans=0;
    REP(i,n){
        REP(j,n){
            if(u[j].second<v[i].first&&u[j].first<v[i].second){
                ans++;
                u[j]={inf,inf};
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
while True:
    lst=input().split()
    a=int(lst[0])
    op=lst[1]
    b=int(lst[2])
    if op=='?':
        break
    if op=='+':
        print(a+b)
    if op=='-':
        print(a-b)
    if op=='*':
        print(a*b)
    if op=='/':
        print(a//b)


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

using ll=long long; 

bool f(int x){
	int cnt=0;
	while(x>0){
		x/=10;
		cnt++;
	}
	return cnt%2==1;
}

void solve(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1; i<=n; i++){
		if(f(i)){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            String str = scan.next();
            String str2 = scan.next();
            int num0 = Integer.parseInt(str);
            int num1 = Integer.parseInt(str2);
            System.out.println((num0 + num1) / 2);
            scan.close();
        }
    }



Measured memory_bytes: 26184
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
int main(){
  string str;
  int num;
  cin >> str >> num;
  for(int i = 0; i < str.size(); i+= num){
    cout << str[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
public class Main {
  private static void solve() {
    int n = ni();
    long X = ni();
    long[] x = nal(n);

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

    long ret = Long.MAX_VALUE;
    outer: for (int k = 1; k <= n; k ++) {
      long now = (k + n) * X;

      for (int i = 0; i < n; i += k) {
        long y = sum[Math.min(n, i + k)] - sum[i];
        long z = y * (i == 0 ? 5 : (2 * (i / k) + 3));
        now += z;
        if (z < 0 || now < 0) {
          continue outer;
        }
      }
      ret = Math.min(now,  ret);
    }
    System.out.println(ret);
  }

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

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

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

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

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

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

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

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

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

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

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

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


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

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  Union_Find uf(n);
  rep(i,q) {
    int t;
    cin >> t;
    if(t == 0) {
      int x, y;
      cin >> x >> y;
      uf.unite(x,y);
    } else {
      int x, y;
      cin >> x >> y;
      if(uf.same(x,y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

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

int main() {
  int H,W,h,w;
  cin >> H >> W;
  cin >> h >> w;
  
  cout << H*W - (H*w+W*h) + h*w << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        System.out.println("ABC" + line);
    }
}


Measured memory_bytes: 22612
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1):
    if n-k+1 >= i:
        print(comb(n-k+1, i)*comb(k-1, i-1) % mod)
    else:
        print(0)


Measured memory_bytes: 66264
a = []
N = gets.chomp.to_i
a = gets.split.map(&:to_i)
m = 0
n = 0
i = 1
j = 0
a.sort!
a.push(0)
while i <= N
  n = n + a[i]
  i = i + 2
end
while j <= N
  m = m + a[j]
  j = j + 2
end
puts (n - m).abs


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  int K;
  cin >> K;
  vector<LL> input(K);
  for (int i = 0; i < K; i++) cin >> input[i];
  reverse(input.begin(), input.end());
  LL minim = 1;
  LL maxim = 2;
  bool ok = true;
  for (auto val : input) {
    minim = minim / val * val + val - 1;
    maxim = maxim / val * val + val - 1;
    if (minim == maxim) ok = false;
    if (maxim < val) ok = false;
  }

  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  cout << minim + 1 << " " << maxim << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){

  int x, y, r;

  scanf("%d %d",&x, &y);

  while(1){
    r = x % y;
    if (r == 0)
      break;
    x = y;
    y = r;
  }

  printf("%d\n",y);
 
  return 0;
}

Measured memory_bytes: 1804
#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <algorithm>
#define fr first
#define sc second
using namespace std;

// first:x, second:y
typedef pair<int, int> iP;
typedef pair<iP, iP> iiiP;

iP sR, sL;
int h, w, used[50][50][50][50];
int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
char mapR[51][51], mapL[51][51];
bool judge;

void bfs(){
  queue <iiiP> que;
  que.push(iiiP(sL, sR));
  used[sL.fr][sL.sc][sR.fr][sR.sc] = 1;
  while(!que.empty()){
    iiiP p = que.front(); que.pop();
    if(mapL[p.fr.sc][p.fr.fr] != '%' && mapR[p.sc.sc][p.sc.fr] != '%'){
      for(int i = 0; i < 4; i++){
	int Lnx = min(w-1, max(0, p.fr.fr + dx[i]));
	int Lny = min(h-1, max(0, p.fr.sc + dy[i]));
	int Rnx = min(w-1, max(0, p.sc.fr - dx[i]));
	int Rny = min(h-1, max(0, p.sc.sc + dy[i]));
	
	if(mapL[Lny][Lnx] == '%' && mapR[Rny][Rnx] == '%'){ judge = true; break; }
	if(mapL[Lny][Lnx] == '#') Lnx = p.fr.fr, Lny = p.fr.sc;
	if(mapR[Rny][Rnx] == '#') Rnx = p.sc.fr, Rny = p.sc.sc;
	if(!used[Lny][Lnx][Rny][Rnx]){
	  que.push(iiiP(iP(Lnx, Lny), iP(Rnx, Rny)));
	  used[Lny][Lnx][Rny][Rnx] = 1;
	}
      }
    }
  }
}

int main(){
  
  while(cin >> w >> h, w){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin >> mapL[i][j];
	if(mapL[i][j] == 'L'){
	  mapL[i][j] = '.'; sL.fr = j, sL.sc = i;
	}
      }
      
      for(int j = 0; j < w; j++){
	cin >> mapR[i][j];
	if(mapR[i][j] == 'R'){
	  mapR[i][j] = '.'; sR.fr = j, sR.sc = i;
	}
      }
    }

    judge = false;
    memset(used, 0, sizeof(used));
    bfs();
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;

  }
}

Measured memory_bytes: 26560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, H;
int a[100010], b[100010];
int maxa;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> H;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    maxa = max(maxa, a[i]);
  }
  sort(b, b + N);
  reverse(b, b + N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (H > 0 && b[i] > maxa) {
      H -= b[i];
      ans++;
    }
  }
  if (H > 0) ans += (H + maxa - 1) / maxa;
  cout << ans << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h,w,k; cin>>h>>w>>k;
  string cs[h];
  
  rep(i,h) {
    string c; cin>>c;
    cs[i] = c;
  }
  
  int n = h+w;
  
  int res = 0;
  
  // {0, 1, ..., n-1} の部分集合の全探索
  for (int bit = 0; bit < (1<<n); ++bit)
  {
    /* bit で表される集合の処理を書く */

    
    // コピー
    string cocs[h];
    rep(i,h) {
      cocs[i] = cs[i];
    }

    /* きちんとできていることを確認してみる */
    // bit の表す集合を求める
    vector<int> S;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) { // i が bit に入るかどうか
        
        // ここで赤色に変える
        if(i<h) {
          // 行で赤に変えるもの
          cocs[i] = string(w, 'R');
        } else {
          // 列で赤に変えるもの
          int retu = i-h;
          rep(i,h) {
            // 各行の任意の列をRにする
            cocs[i][retu] = 'R';
          }
        }
        
      }
    }
    
    // 個数を確認
    int sharpC = 0;
    rep(i,h) {
      int hoge = sizeof(cocs);
      string target = cocs[i];
      sharpC += count(target.begin(), target.end(), '#');
    }

    if (sharpC == k) ++res;
  }
    
  cout<<res;
    
  return 0;
}

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

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

    vector<int> a(N);
    vector<int> b(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
        b.at(i) = a.at(i);
    }

    sort(b.rbegin(), b.rend());
    
    int max_num = b.at(0);
    int second_max = b.at(1);

    for (int i = 0; i < N; i++){
        if (a.at(i) < max_num){
            cout<< max_num <<endl;
        }
        else {
            cout<< second_max <<endl;
        }   
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int sizeA, sizeB,num;
	num = 0;
	string A, B;
	cin >> A >> B;
	sizeA = A.length();
	sizeB = B.length();
	if (sizeA > sizeB)cout << "GREATER" << endl;
	else if (sizeB > sizeA)cout << "LESS" << endl;
	else {
		for (int i = 0; i < sizeA; i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				break;
			}
			else if (B[i] > A[i]) {
				cout << "LESS" << endl;
				break;
			}
			else num++;
		}
		if (num == sizeA)cout << "EQUAL" << endl;
	}
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        
        if (A >= K) {
            System.out.println(K);
        } else if (A + B >= K) {
            System.out.println(A);
        } else if (A + B + C >= K) {
            System.out.println(A - (C - ((A + B + C) - K)));
        }
    }
}

Measured memory_bytes: 35660
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve()
{
	string s;
	cin >> s;
	vector<char> ans(10);
	int index = 0;
	for (int i = 0; i < s.length(); i++) {
		if (index == 0 && s[i] == 'B')continue;
		if (s[i] == 'B') {
			index--;
		}
		else
		{
			ans[index] = s[i];
			index++;
		}
	}
	for (int i = 0; i < index; i++)cout << ans[i];
	cout << endl;
}

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

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

int main () {
	
	int n=0, m=0, x=0, y=0, i=0;

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

	vector <int> v (n, 0);

	for (i=0; i<m; i++) {
		scanf("%d %d", &x, &y);
		v[x-1]++;
		v[y-1]++;
	}

	bool flag = 0;
	for (i=0; i<n; i++) {
		if (v[i]%2 == 1) {
			flag = 1;
			break;
		}
	}

	if (flag) printf("NO\n");
	else printf("YES\n");

	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
p = list(map(int, input().split()))
m = [(maximum + 1) / 2 for maximum in p]
S=[0]*(N+1)
for i in range(N):
  S[i+1]=S[i]+m[i]
ans=0

for i in range(N-K+1):
  if S[i+K]-S[i]>ans:
    ans=S[i+K]-S[i]
print(ans)

Measured memory_bytes: 81800
#include<iostream>

using namespace std;

int main(){
    int a ,b;
    cin >> a >> b;
    if ( a < b ) {
    cout <<"a < b"<< endl;
    }  if ( a > b ) { 
    cout <<"a > b"<< endl;
    }  if ( a == b ) {
    cout <<"a == b"  << endl;
    }
}

 



Measured memory_bytes: 3096
N = int(input())
H = list(map(int, input().split()))

def can_see_sea(i):
    hi = H[i]
    for h in H[0:i]:
        if h > hi:
            return False
    return True

count = 0

for i in range(N):
    if can_see_sea(i):
        count += 1

print(count)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    char c; cin >> c;
    char c2 = c + 1;
    cout << c2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
const int V = 10;
struct edge { int to, cost; };
std::vector<edge>v[100];
typedef std::pair<int, int>p;

int main() {
	int a, b, ans = 0, flag = 0;
	std::cin >> a >> b;
	if (1 <= b&&b < 10) {
		ans = b + a * 10;
	}
	else if (b >= 10&&b < 100) {
		ans = b + a * 100;
	}
	else if (b == 100) {
		ans = b + a * 1000;
	}
	for (int i = 0;i < 1000;i++) {
		if (ans == i*i) {
			std::cout << "Yes" << std::endl;
			flag = 1;
		}
	}
	if (flag == 0) {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = if N % 10 == 9 || N / 10 == 9 {
        "Yes"
    } else { "No" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 ll N,K;cin>>N>>K;vl a(N),b(N);rep(i,N)cin>>a[i]>>b[i];
  vector<pair<ll,ll>> p(N);
  rep(i,N){
    p[i]=make_pair(a[i],b[i]);
  }
  sort(all(p));
  
  ll cnt=0;
  f(i,0,N){
    cnt+=p[i].second;
    if(cnt>=K){
      cout<< p[i].first<<endl;
      break;
    }
  }
}





Measured memory_bytes: 3328
/**
 * Created by hiramekun at 23:41 on 2020-05-18.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    vvl cnt(10, vl(10));
    for (ll i = 1; i <= n; ++i) {
        ll head = to_string(i).front() - '0';
        ll tail = to_string(i).back() - '0';
        cnt[head][tail]++;
    }
    rep(i, 10) rep(j, 10) ans += cnt[i][j] * cnt[j][i];
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
	
		long long int x;
		cin >> x;
		long long int temp, sum = 0;

		if (x >= 500) {
			temp = x;
			temp = temp / 500;
			x = x % 500;
			sum += temp * 1000;
		}
		if (x >= 5) {
			temp = x;
			temp = temp / 5;
			x = x % 5;
			sum += temp * 5;
		}
		cout << sum << endl;
	
	
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(ab[0]*ab[1] %2 == 1 ?"Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9+7;
// const ll INF = 1000000000000000000LL;

 int main() {
		int n;
    cin >> n;
    vector<ll> A(n), x(n);
 
    ll res = 0;
    rep(i, n) {
        cin >> A[i];
        if (i % 2) res -= A[i];
        else res += A[i];
    }
    
    x[0] = res;
 
    rep(i,n-1) {
        x[i+1] =2 * A[i] - x[i];
    }
 
    rep(i, n) cout << x[i] << endl;
 
    return 0;
 }

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////


#define INF 1e12

ll N, M;
vector<ll> abv[1010];
ll i, j, k;
vector<ll> ans;
ll ansck;
ll mk[1010],mk2[1010];

bool dfs(ll a,ll p){
    mk2[a] = 1;
    ll i = 0, f = 0;
    fornum(i,0,abv[a].size()){
        ll b = abv[a][i];
        if(b==p){
            f++;
        }else if(mk2[b]){
            f +=99999;
        }
        mk[b]++;
    }
    //printf("<%lld>", f);
    if(f==1){
        ans.push_back(a);
        return true;
    }else if(f==0){
        fornum(i,0,abv[a].size()){
            ll b = abv[a][i];
            if(b<p)
                continue;
            if(mk[b]<2&&dfs(b,p)){
                ans.push_back(a);
                return true;
            }
        }   
    }
    /*
    fornum(i,0,abv[a].size()){
        ll b = abv[a][i];
        if(b<p)
            continue;
        mk[b]--;
    }*/
    mk2[a] = 0;
    //printf("\n");
    return false;
}

int main(){
    scanf("%lld%lld", &N, &M);
    fornum(i,0,M){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        abv[a].push_back(b);
    }
    fornum(i,0,N){
        fornum(j,0,N){
            mk[j + 1] = 0;
        }
        mk[i + 1] = 1;
        //printf("%lld\n", i + 1);
        if(dfs(i+1,i+1)){
            printf("%d\n", ans.size());
            fornum(i,0,ans.size()){
                printf("%lld\n", ans[i]);
            }
            return 0;
        }
    }
    printf("-1");
    return 0;
}


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

using namespace std;

int main(){
    string st;
    int out_max=0;
    int out_tmp=0;
    cin >> st;
    for(int i=0; i<st.size();i++){
        //cout<<st[i]<<endl;
        if(st[i]=='A'||st[i]=='C'||st[i]=='T'||st[i]=='G'){
            out_tmp++;
        }
        else{
            out_tmp=0;
        }
        /* 
        switch(st[i]){
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                out_tmp++;
            default:
                out_tmp=0;
        }
        */
        //printf("%d   %d\n",out_max,out_tmp);
        if(out_max < out_tmp){
            out_max = out_tmp;
        }
    }
    cout << out_max << endl;
    return 0;
}

Measured memory_bytes: 256