akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
    #include <string.h>
     
    int main(void){
        int a=0,b=0,c=0,d=0;
        int N;
        scanf("%d",&N);
       
        for(int i = 0; i<N;i=i+1){
            char str[256];
            scanf("%s",&str);
            if(strcmp(str,"AC")==0 ) a++;
            if(strcmp(str,"WA")==0 ) b++;
            if(strcmp(str,"TLE")==0 ) c++;
            if(strcmp(str,"RE")==0 ) d++;
     
     
        }
     
        printf("AC x %d\n",a);
        printf("WA x %d\n",b);
        printf("TLE x %d\n",c);
        printf("RE x %d\n",d);
       
        return 0;
    }

Measured memory_bytes: 1640
#include<stdio.h>
int main(void){
  int a, b, c = 1, x = 0;
  int l[100] = {0};
  scanf("%d %d",&a, &b);getchar();
  for(int i = 0; i < a; i++){
    scanf("%d",&l[i]);getchar();
  }
  for(int i = 0; i < a; i++){
    x += l[i];
    if(x <= b){
    	c++;
    }
  }
  printf("%d\n", c);
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool in(string s1, string s2) {
  int64 idx = 0;
  REP(i, s2.size()) {
    if (idx < s1.size() && s1[idx] == s2[i]) idx++;
  }
  return idx == s1.size();
}

::std::vector<::std::int64_t> divisors(::std::int64_t x) {
	::std::vector<::std::int64_t> res;
	for (::std::int64_t i = 1; i*i <= x; ++i) {
		if (x % i == 0) {
			res.push_back(i);
			if (i * i != x) res.push_back(x / i);
		}
	}
	::std::sort(res.begin(), res.end());
	return res;
}

int main(void) {
  int64 A, B;
  cin >> A >> B;
  if (A <= 5) {
    cout << 0 << endl;
  } else if (A <= 12) {
    cout << B/2 << endl;
  } else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
from functools import lru_cache
import sys
sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


t = read_int()
for case_num in range(t):
    n, a, b, c, d = read_ints()

    @lru_cache(None)
    def solve(t):
        if t == 0:
            return 0
        if t == 1:
            return d
        ans = d * t
        if t % 2 == 0:
            ans = min(ans, solve(t // 2) + a)
        else:
            ans = min(ans, solve(t // 2) + a + d, solve(t // 2 + 1) + a + d)

        if t % 3 == 0:
            ans = min(ans, solve(t // 3) + b)
        else:
            rem = t % 3
            ans = min(ans, solve(t // 3) + b + d * rem,
                      solve(t // 3 + 1) + b + (3 - rem) * d)

        if t % 5 == 0:
            ans = min(ans, solve(t // 5) + c)
        else:
            rem = t % 5
            ans = min(ans, solve(t // 5) + c + d * rem,
                      solve(t // 5 + 1) + c + (5 - rem) * d)
        return ans

    print(solve(n))


Measured memory_bytes: 11448
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")
   


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define d7 1000000007
#define fori(n) for( ll i=0 ; i<n; i++)


long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){

ll n,k;
cin>>n;
ll a[n], b[n], c[n];
fori(n) cin>>a[i]>>b[i]>>c[i];
ll dp1[n], dp2[n], dp3[n];
dp1[0]=a[0]; dp2[0]=b[0]; dp3[0]=c[0];

fori(n-1){
dp1[i+1]=a[i+1]+max(dp2[i], dp3[i]);
dp2[i+1]=b[i+1]+max(dp1[i], dp3[i]);
dp3[i+1]=c[i+1]+max(dp2[i], dp1[i]);
}
ll ans=max(dp1[n-1], dp2[n-1]);
ans=max(ans, dp3[n-1]);
cout<<ans;

return 0;
}


Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    L = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    print((L / 3)**3)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3"""
        output = """1.000000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """999"""
        output = """36926037.000000000000"""
        self.assertIO(input, output)


Measured memory_bytes: 5652
#!/usr/bin/env python3
# Bitset 1 - Bit Operation 2


def run():
    a, b = [int(i) for i in input().split()]
    fmt = "{:032b}"
    mask = ~(1 << 32)

    print(fmt.format((a & b) & mask))
    print(fmt.format((a | b) & mask))
    print(fmt.format((a ^ b) & mask))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N+1);
    rep(i,N) cin >> A[i+1];

    rep(i,N) A[i+1] += A[i];
    map<ll, ll> dic;
    rep(i,N+1) dic[A[i]]++;

    ll ans = 0;
    for (auto i : dic) {
        ans += i.second*(i.second-1)/2;
    }

    cout << ans << ln;
}


Measured memory_bytes: 14336
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    while(cin>>str)
    {
        int flag=0;
        int sum=0;
        int num=0;
        if(str[0]!='A') flag=1;
        for(int i=2;i<=str.length()-2;i++)
        {
            if(str[i]=='C')
            {
                sum++;
            }
        }
        if(sum!=1) flag=1;
        for(int i=0;i<str.length();i++)
        {
            if(str[i]<'a'||str[i]>'z') num++;
        }
        if(num!=2) flag=1;
        if(flag==0) cout<<"AC"<<endl;
        else cout<<"WA"<<endl;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

      
uf = UnionFind(N + 1)

for _ in range(M):
  X, Y, Z = map(int, input().split())
  uf.union(X, Y)
  
  
print(uf.group_count() - 1)

Measured memory_bytes: 7860
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5010,p=1e9+7;
struct edge{int to,nxt;}e[N<<1];
int h[N],tot=1,f[N][N][2],g[N][2],fc[N],sz[N],n;
void adde(int x,int y){e[tot]=(edge){y,h[x]};h[x]=tot++;}
void dfs(int u,int ff)
{
    f[u][1][0]=1;sz[u]=1;
    for(int i=h[u];i;i=e[i].nxt)
    {
        int v=e[i].to;if(v==ff)continue;dfs(v,u);
        for(int j=1;j<=sz[u];j++)g[j][0]=f[u][j][0],g[j][1]=f[u][j][1],f[u][j][0]=f[u][j][1]=0;
        for(int j=1;j<=sz[u];j++)
            for(int k=1;k<=sz[v];k++)
                for(int s1=0;s1<=1;s1++)
                    for(int s2=0;s2<=1;s2++)
                        f[u][j+k][s1^s2]=(f[u][j+k][s1^s2]+1ll*g[j][s1]*f[v][k][s2])%p,
                        f[u][j][s1^s2^1]=(f[u][j][s1^s2^1]+1ll*g[j][s1]*f[v][k][s2]%p*fc[k])%p;
        sz[u]+=sz[v];
        for(int j=1;j<=sz[u];j++)g[j][0]=0,g[j][1]=0;
    }
}
int main()
{
    scanf("%d",&n);
    fc[2]=1;for(int i=4;i<=n;i+=2)fc[i]=fc[i-2]*1ll*(i-1)%p;
    for(int i=1;i<n;i++){int x,y;scanf("%d%d",&x,&y);adde(x,y),adde(y,x);}
    dfs(1,1);int ans=0;
    for(int i=2;i<=n;i+=2)ans=(ans+1ll*f[1][i][0]*fc[i]-1ll*f[1][i][1]*fc[i]%p+p)%p;
    printf("%d\n",ans);
}


Measured memory_bytes: 195328
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  vvll g(n);
  rep(i, m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  vll ans(n, 0);
  vector<bool> visited(n, false);
  auto bfs = [&](int start) -> void{
    queue<pair<int, int>> q;
    q.emplace(start, start);
    visited[start] = true;
    while(q.size()){
      ll node = q.front().first;
      ll par = q.front().second;
      ans[node] = par;
      q.pop();
      for(auto&& e: g[node]){
        if(!visited[e]){
          visited[e] = true;
          q.emplace(e, node);
        }
      }
    }
  };
  bfs(0);
  ans.erase(ans.begin());
  cout << "Yes" << endl;
  for(auto&& e: ans){
    print(e+1);
  }
}


Measured memory_bytes: 13004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var s = Line();
            var array = Enumerable.Range(0, 26).Select(x => (char)(x + 'a') + "").ToArray();

            Console.WriteLine(array.Except(s.Select(x => x + "")).DefaultIfEmpty("None").First());

        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 15840
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int a,p;
    cin>>a>>p;
    cout<<(3*a+p)/2<<endl;
    return 0;   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	int numa=0,numb=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A') numa++;
		else numb++;
	}
	if(numa==3||numb==3){
		cout<<"No"<<endl;
	}
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

int n, m;
const int N = 1e5 + 5;
int cnt[N];

void solve() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int u, v;
		cin >> u >> v;
		cnt[u] ^= 1, cnt[v] ^= 1;
	}
	if(*(max_element(cnt + 1, cnt + n + 1)) == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		// cout << "Case #" << tt << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;
using P = std::pair<ll, ll>;

ll N;
ll a[100010];
std::vector<P> vs;
ll cnt[100010];

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

  rep( i, N )
  {
    std::cin >> a[i];
    vs.emplace_back( P( a[i], i ) );
  }

  vs.emplace_back( P( 0, N+1 ) );

  std::sort( vs.rbegin(), vs.rend() );

  ll ans = 0, mi = 1ll<<60;

  rep( i, vs.size() )
  {
    ll x1 = vs[i].first, x2 = vs[i+1].first;

    chmin( mi, vs[i].second );

    cnt[mi] += (i+1)*(x1-x2);
  }

  rep( i, N )
    std::cout << cnt[i] << std::endl;

  return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int D = 32;
const int MAX_N = 51;

int N;
bool v[D][MAX_N];
long long int dp[D][MAX_N];

int main(){
  while(cin >>N && N){
    memset(v, 0, sizeof(v));
    memset(dp, 0, sizeof(dp));
    REP(i, N){
      int cnt; cin >>cnt;
      REP(j, cnt){
        int day; cin >>day;
        v[day][i] = 1;
      }
    }
    int ans = -1;
    REP(i, N) dp[0][i] = ((long long int)(1) << i);
    FOR(day, 1, 31){
      long long int sum = 0;
      REP(i, N) if(v[day][i]) sum = (sum | dp[day - 1][i]);
      REP(i, N) dp[day][i] = (v[day][i] ? sum : dp[day - 1][i]);
      if(sum == ((long long int)(1) << N) - 1){
        ans = day;
        break;
      }
    }
    cout <<ans <<endl;
    //debug
    //REP(i, D){
    //  REP(j, N) cout <<v[i][j] <<" ";
    //  cout <<endl;
    //}
    //cout <<"==========" <<endl;
    //REP(i, D){
    //  REP(j, N) cout <<dp[i][j] <<" ";
    //  cout <<endl;
    //}
  }
}

Measured memory_bytes: 1180
#include <stdio.h>
int main(){
  int a,b,n,m,tmp[50+1]={0};
  scanf("%d%d",&n,&m);
  for(int i=0; i<m; i++){
    scanf("%d%d",&a,&b);
    tmp[a-1]++;
    tmp[b-1]++;
  }
  for(int i=0; i<n; i++){
    printf("%d\n",tmp[i]);
  }
  return 0;
}

Measured memory_bytes: 1724
/*
Power_Calculus
https://onlinejudge.u-aizu.ac.jp/problems/1271
01<= n <= 1000
*/

#include <iostream>
#include <cmath>
#include <algorithm>    // 

using namespace std;

int N; //入力の保持
int dp[10001]; //最初のあたいの保持

/**
 * 再帰関数として深さ優先探索dfsをするメソッド
 * @pram now 現在見ているべき指数
 * @pram isCalced 計算結果を保持する配列
 * @pram depth    深さ
 */
void dfs(int now, int isCalced[15], int depth){

    //もう探索する必要がない
    if(depth == 13) return;

    /**
     * 現在探索している深さまでで、計算結果を取得しているものについて
     * 次(depth+1)計算することができるものを全て探索していく。
     * ex.[1] -> [1, 2] -> [1,2,3], [1,2,4]
     * [1,2] -> 1+2 = 3 -> [1,2,3]
     * [1,2,4] -> 4-1 = 3 -> [1,2,3,4]
     */
    for (int i=0; i <= depth; i ++){
        if(now + isCalced[i] > 10000) continue;

        //すでに求めてあるor未だ求めてないdp[next]より、今探索しているものが小さければ

        //掛け算によって次のものを求める
        if( dp[now + isCalced[i]] >= depth+1){

            dp[now + isCalced[i]] = depth+1;
            
            int nextIsCalced[15];
            for(int k = 0; k <= depth; k++) nextIsCalced[k] = isCalced[k];
            nextIsCalced[depth+1] = now + isCalced[i];

            dfs(now + isCalced[i], nextIsCalced, depth+1);

        }
    }

    for (int i=0; i <= depth; i ++){
        if(now - isCalced[i] <= 0) continue;

        //割り算によって次のものを求める
        if( dp[now - isCalced[i]] >= depth+1){

            dp[now - isCalced[i]] = depth+1;
            
            int nextIsCalced[15];
            for(int k = 0; k <= depth; k++) nextIsCalced[k] = isCalced[k];
            nextIsCalced[depth+1] = now - isCalced[i];

            dfs(now - isCalced[i], nextIsCalced, depth+1);

        }
    }

}

void solve(){

    //dp初期化
    dp[0] = 0; dp[1] = 0;
    for(int i = 2; i<10000; i++) dp[i] = 10000;

    int first_exponent = 1;//最初のべき指数
    int isCalced[15];//計算結果の保持
    int first_depth = 0;//最初の深さ

    isCalced[0] = 1;

    dfs(first_exponent, isCalced, first_depth );

    return;
}

int main(){
    solve();
    while(cin>>N, N!=0) cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 3004
s = int(input())

def myfunction(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return int(3*n + 1)

temp = s
a = []
i = 0
flg = True
while flg == True:
    if i == 0:
        a.append(temp)
        i += 1
        continue
    temp = myfunction(temp)
    a.append(temp)
    if a[i] in a[:(i-1)]:
        print(i+1)
        break
    i += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	#define lld I64d
#endif

struct trie {
	struct node {
		int son[2];
		bool bl;
	};
	vector<node> T;
	int sz;
	node n0;

	trie() {
		n0.son[0] =n0.son[1] =-1;
		n0.bl =false;
		sz =1;
		T.resize(1000000,n0);
	}

	void put(string &S) {
		int akt =0;
		for(int i =0; i < (int)S.length(); i++) {
			if(T[akt].son[S[i]-'0'] == -1)
				T[akt].son[S[i]-'0'] =sz++;
			akt =T[akt].son[S[i]-'0'];
		}
		T[akt].bl =true;
	}

	int zeroes(cat X) {
		if(X == 0) return 0;
		int ret =0;
		while(X%2 == 0) {
			ret++;
			X /=2;
		}
		return ret+1;
	}

	int SG(int akt, cat L, int dep =0) {
		if(T[akt].bl) return 0;
		int ret =0;
		for(int i =0; i < 2; i++) {
			if(T[akt].son[i] == -1) ret ^=zeroes(L-dep);
			else ret ^=SG(T[akt].son[i],L,dep+1);
		}
		return ret;
	}
};

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cat L;
	cin >> N >> L;
	trie T;
	for(int i =0; i < N; i++) {
		string S;
		cin >> S;
		T.put(S);
	}

	if(T.SG(0,L) == 0) cout << "Bob\n";
	else cout << "Alice\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 15596
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
typedef complex<long double> point;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	priority_queue <ll> que;
	for (int z=0;z<n;z++){
		ll temp;
		cin >> temp;
		que.push(temp);
	}
	while (m > 0){
		ll a = que.top();
		que.pop();
		que.push(a/2);
		m--;
	}
	ll ans = 0;
	while (!que.empty()){
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    H = LI()
    H = [0] + H + [10**9+1]
    for i in range(1, N+1):
        l = H[i-1]
        m = H[i]
        r = H[i+1]
        if m > r:
            if l == m:
                print("No")
                return
            elif l < m:
                if not H[i] - 1 == r:
                    print("No")
                    return
            else:
                print("No")
                return
        else:
            pass
        if l != m:
            H[i] -= 1
    print("Yes")

main()



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


int main(){
    int ans[100010] = {};
    string s;
    cin >> s;
    int n = s.length();
    int j = 0;
    while(j < n){
        int n1 = 0, n2 = 0;
        while(s[j] == 'R') j++, n1++;
        int pl = j - 1;
        int pr = j;
        while(s[j] == 'L') j++, n2++;
        ans[pl] = (n1 + 1) / 2 + n2 / 2;
        ans[pr] = n1 / 2 + (n2 + 1) / 2;
    }
    rep(i,n) cout << ans[i] << ' ';
  	cout << endl;
    return 0;
}

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

int main(){
    int n,a;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout<<v[(n/2)]-v[(n/2)-1]<<endl;
    return 0;
}






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

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

  sort(a.begin(),a.end());
  a.push_back(0);

  vector<int> b(n,0);
  int s=0,c=0,d=0,sequens=0;
  for(int i=0;i<n;i++){
    if(a[i] != a[i+1]){
      c = i-s+1;
      if(c < a[i]){
        d += c;
      }else if(c > a[i]){
        d += c-a[i];
      }
      s = i+1;
    }
  }

  cout <<d <<endl;

}


Measured memory_bytes: 1028
#include <bits/stdc++.h>
using i64 = long long;

constexpr i64 mod = 998244353;
int n;
std::vector<std::vector<int>> g;
std::vector<std::pair<int, int>> v { { -1000000001, 1000000001 } };

int rec(int p) {
    int to = p + 1;
    while (to <= n && v[to].first < v[p].second) {
        g[p].push_back(to);
        to = rec(to);
    }
    return to;
}

i64 dfs(int v) {
    i64 ret = 1;
    for (int to : g[v]) ret = ret * dfs(to) % mod;
    return ret + 1;
}

int main() {
    std::cin >> n;
    g.resize(n + 1);

    for (int i = 0; i < n; i++) {
        int x, d;
        std::cin >> x >> d;
        v.emplace_back(x, x + d);
    }

    std::sort(v.begin(), v.end());

    rec(0);

    std::cout << dfs(0) - 1 << std::endl;

    return 0;
}


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

typedef long long ll;

const int M = (int)2e5;

int h, w, k, cnt, top;
char s[15][1005];
int c[15][1005];
int sum[15];

bool check()
{
    for(int i = 0; i <= top; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            if(c[i][j] > k) return 0;
        }
    }
    return 1;
}

int main()
{
    scanf("%d %d %d", &h, &w, &k);
    for(int i = 0; i < h; ++i)  scanf("%s", s[i]);
    int ans = h * w;
    for(int i = 0; i < (1<<(h-1)); ++i)
    {
        cnt = top = 0;
        for(int l = 0; l < w; ++l)  c[top][l] = 0;
        for(int j = 0; j < h; ++j)
        {
            for(int l = 0; l < w; ++l)  c[top][l] += (s[j][l] == '1');
            if(i & (1<<j))
            {
                ++top, ++cnt;
                for(int l = 0; l < w; ++l)  c[top][l] = 0;
            }
        }
        if(!check()) continue;
        for(int j = 0; j <= top; ++j)   sum[j] = 0;
        for(int l = 0; l < w; ++l)
        {
            for(int j = 0; j <= top; ++j)   sum[j] += c[j][l];
            for(int j = 0; j <= top; ++j)
            {
                if(sum[j] > k)
                {
                    ++cnt;
                    for(int p = 0; p <= top; ++p)   sum[p] = c[p][l];
                    break;
                }
            }
        }
        ans = min(ans, cnt);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <utility>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    if( b == 100 ) cout << (b + 1) * (int)pow( 100 , a );
    else cout << b * (int)pow( 100 , a );
}


Measured memory_bytes: 3792
n, k = map(int, input().split())

mod = 10 ** 9 + 7
inv = pow(2, mod - 2) % mod

def calc(b, e, c):
    global mod
    global inv
    res = (e + b) % mod
    res = ((res * c) % mod ) * inv
    return res % mod

ans = 0
for i in range(k, n + 2):
    min_val = calc(0, i - 1, i)
    max_val = calc(n - i + 1, n, i)
    ans += (max_val - min_val + 1) % mod
    ans %= mod

print(ans)

Measured memory_bytes: 196944
#include <cstdio>
#include <iostream>
#include <climits>
#include <cmath>
#include <utility>
#include <vector>
#include <string>

using namespace std;

class BinaryTree
{
  struct Node
  {
      int parent;
      int left;
      int right;
  };
public:
  int size;
  vector<Node> nodes;
  Node operator[](int i)
  {
    return nodes[i];
  }
  BinaryTree(int n)
  {
    size = n;
    nodes.resize(n);
    for(int i = 0; i < n; i++)
    {
      nodes[i].parent = -1;
      nodes[i].left = -1;
      nodes[i].right = -1;
    }
  }
  bool isRoot(int id)
  {
    return nodes[id].parent == -1;
  }
  void SetSibling(int id, int left, int right)
  {
    nodes[id].left = left;
    nodes[id].right = right;
    if(left != -1) nodes[left].parent = id;
    if(right != -1) nodes[right].parent = id;
    //cerr << id << endl;
  }
  int parent(int id)
  {
    return isRoot(id)?-1:nodes[id].parent;
  }
  int sibling(int id)
  {
    if(isRoot(id)) return -1;
    if(nodes[nodes[id].parent].left == id) return nodes[nodes[id].parent].right;
    else return nodes[nodes[id].parent].left;
  }
  int degree(int id)
  {
    return (nodes[id].left != -1) + (nodes[id].right != -1);
  }
  int depth(int id)
  {
    int x = id;
    int cnt = 0;
    while(x != -1)
    {
      x = nodes[x].parent;
      cnt++;
    }
    return cnt;
  }
  int height(int id)
  {
    if(id == -1) return -1;
    return max(height(nodes[id].left),height(nodes[id].right)) + 1;
  }
  char* printType(int id)
  {
    if(nodes[id].parent == -1)
      return (char *)"root";
    else if(nodes[id].left == -1 && nodes[id].right == -1)
      return (char *)"leaf";
    else return (char *)"internal node";
  }
  void printInfo(int id)
  {
    printf("node %d: ",id);
    printf("parent = %d, ",parent(id));
    printf("sibling = %d, ",sibling(id));
    printf("degree = %d, ",degree(id));
    printf("depth = %d, ",depth(id));
    printf("height = %d, ",height(id));
    printf("%s\n", printType(id));
  }
  void preParse(int id)
  {
    if(id == -1) return;
    printf(" %d",id);
    preParse(nodes[id].left);
    preParse(nodes[id].right);
  }
  void inParse(int id)
  {
    if(id == -1) return;
    inParse(nodes[id].left);
    printf(" %d",id);
    inParse(nodes[id].right);
  }
  void postParse(int id)
  {
    if(id == -1) return;
    postParse(nodes[id].left);
    postParse(nodes[id].right);
    printf(" %d",id);
  }
};

int main()
{
  int n; cin >> n;
  BinaryTree tree(n);
  for(int i = 0; i < n; i++)
  {
    int id, l, r;
    cin >> id >> l >> r;
    tree.SetSibling(id,l,r);
  }
  int root;
  for(int i = 0; i < n; i++)
  {
    if(tree[i].parent == -1) root = i;
  }
  cout << "Preorder" << endl;
  tree.preParse(root);
  cout << endl;
  cout << "Inorder" << endl;
  tree.inParse(root);
  cout << endl;
  cout << "Postorder" << endl;
  tree.postParse(root);
  cout << endl;
}

Measured memory_bytes: 1224
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    for (int i = 0; i < n; i++)cin >> x[i];
    sort(x.begin(), x.end());

    double ret = (x[0] + x[1]) / 2;
    for (int i = 2; i < n; i++) {
        ret = (ret + x[i]) / 2;
    }

    cout << fixed << setprecision(10) << ret << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int> costs;
    for (int i=1; i<=n; i++) {
        int temp;
        cin>>temp;
        costs.push_back(temp);
    }
    int dp[n+1];
    dp[1] = 0;
    dp[2] = dp[1] + abs(costs[1] - costs[0]);
    for (int i=3; i<=n; i++) {
        dp[i] = min(dp[i-1] + abs(costs[i-1] - costs[i-2]), dp[i-2] + abs(costs[i-1] - costs[i-3]));
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1144
m,s[]={0,31,60,91,121,152,182,213,244,274,305,335};
main(d){char a[7][9]={"Thurs","Fri","Satur","Sun","Mon","Tues","Wednes"};
  while(1)
    {
      scanf("%d%d",&m,&d);
      if(!m)exit(0);
      d+=s[m-1];
      printf("%sday\n",&a[(d%7==0)?6:(d%7-1)][0]);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
   ll h;
   cin >> h;

   ll cou = 0;
   while(1){
       if(h == 0){
           break;
       }

       h /= 2;
       cou++;
   }



   ll ans = 0;
   ll k = 1;
   for(int i = 0; i < cou; i++){
       ans += k;
       k *= 2;
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(a>0) cout<<"Positive";
	else if(a<0 && b>0 || a==0) cout<<"Zero";
	else if((abs(a)-abs(b))%2!=0) cout<<"Positive";
	else cout<<"Negative";
	return 0;
}

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


fn abc(s: &str, t: &str) -> String {
    let s_: String = [s, s].concat();
    if s_.contains(t) {
        return "Yes".to_string();
    } else {
        return "No".to_string();
    }
}

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")
}

fn main() {
    /*
    assert_eq!(abc(), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    let s: String = read();
    let t: String = read();
    
    let result = abc(&s, &t);
    
    println!("{}", result);
}



Measured memory_bytes: 4352
//============================================================================
// Name        : ALDS1_1_A.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

int main() {
	vector<int> a;
	int i,j,n,key;
	cin >> n;
	a.resize(n);
	for(i=0; i<n; ++i) {
		cin >> a[i];
	}
	for(i=0; i<n; ++i) {
		key=a[i];
		for(j=i-1;j>=0 && a[j]>key; --j) {
			a[j+1]=a[j];
		}
		a[j+1]=key;
		for(int i=0; i<(int)a.size()-1; ++i) {
			cout << a[i] << " ";;
		}
		cout << a[(size_t)a.size()-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine
    print $ solve h w

solve :: Int -> Int -> Int
solve h w
    | mod h 3 == 0 || mod w 3 == 0 = 0
    | otherwise = minimum resH `min` minimum resW
  where
    f x y z
        | even $ x * y = abs $ z - (x * y) `quot` 2
        | s <- (x * y - min x y) `quot` 2
            = maximum [abs (s - z), abs (x * y - s - z), min x y]
    resH = [f h (w - i) (h * i)| i <-[1..w-1]]
    resW = [f w (h - i) (w * i)| i <-[1..h-1]]


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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();

    int a, b;
    cin>> a>> b;

    cout<< (b%a==0? a+b: b-a);
    nl;


    return 0;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

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

    if (t.substr(0, t.length() - 1) == s) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, diff, sum = 0;
    bool flag;
    std::string stra, tmp;
    cin >> N;
    cin >> stra;
    int size = stra.size();
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        if (tmp.size() < size) continue;
        for (int j = 0; j <= tmp.size()-size; j++) {
            if (tmp[j] == stra[0]) {
                diff = 1; flag = false;
                for (;;) {
                    if (j + (size-1)*diff > tmp.size()-1) break;
                    flag = true;
                    for (int k = 1; k < size; k++) {
                        if (tmp[j+(k*diff)] != stra[k]) {flag = false; break; }
                    }
                    if (flag) break;
                    diff++;
                }
                if (flag) { sum++; break; }
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3160
#!/usr/bin/env python3
from collections import defaultdict
N, K = map(int, input().split())

cnt = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    cnt[a] += b

total = 0
for k, v in sorted(cnt.items()):
    total += v
    if total >= K:
        print(k)
        exit()

Measured memory_bytes: 14940
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        if(d>=hypot(x,y)){
            ans++;
        }
    }
    cout<<ans<<"\n";
    return(0);
}

Measured memory_bytes: 3688
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main() {

    vector<vector<int>>g(1e5+10);
    int h[100005];

    int n,m;
	cin>>n>>m;

	for(int i=0; i<n; i++)
	cin>>h[i];
	g.resize(n);
	for(int i=0; i<m; i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int>vis(n,0);
	int cnt=0;
	for(int i=0; i<n; i++){
		 if(vis[i] == 1) continue;
		 int ok=1;
	     for(int j=0; j<g[i].size(); j++){
	     	if(h[g[i][j]] >= h[i]){
	     		ok=0;
	     		break;
	     	}
	     }
	     if(ok){
	     	cnt++;
	     	for(int j=0; j<g[i].size(); j++){
	     		vis[g[i][j]] = 1;
	     	}
	     }
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 8968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderBy(i => i).ToArray();
            var ans = 0;
            var chk = 0;
            var cnt = 0;
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != chk)
                {
                    if (chk > cnt) ans += cnt;
                    else if (chk < cnt) ans += cnt - chk;
                    chk = a[i];
                    cnt = 1;
                }else
                {
                    cnt++;
                }
            }

            if (chk > cnt) ans += cnt;
            else if (chk < cnt) ans += cnt - chk;

            Console.WriteLine(ans);
        }
    }
}

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

int main() {
  ll n;cin>>n;
  ll x = floor(pow(n, 0.5)) + 1;
  rep(i,x) {
    ll m = x-i;
    if (n%m==0) {
      int f = max(to_string(m).size(), to_string(n/m).size());
      cout << f;
      return 0;
    }
  }
}


Measured memory_bytes: 512
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    vector<P> res(N);
    REP(i,N) {
        int X,L;
        cin >> X >> L;
        res[i].first = X+L;
        res[i].second = X-L;
    }
    sort(res.begin(),res.end());
    ll ans = 0;
    int pre = -1000000000;
    REP(i,N) {
        //cout << res[i].second << " " << res[i].first << endl;
        if(res[i].second >= pre) {
            ans++;
            pre = res[i].first;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int s;
  cin >> s;
  if (s < 3) {
    cout << 0 << endl;
    return 0;
  } else if (s == 3) {
    cout << 1 << endl;
    return 0;
  }
  vector<vector<ll>> dp(s + 1, vector<ll>(s + 1, 0));
  for (int i = 0; i < 4; i++) dp[0][i] = 1;
  dp[3][3] = 1;

  for (int i = 4; i < s + 1; i++) {
    // insert
    dp[i][i] = dp[i - 3][i - 1] + dp[i - 4][i - 1];
    // not insert
    dp[i - 1][i] = dp[i - 1][i - 1];
    dp[i - 2][i] = dp[i - 2][i - 1];
    dp[i - 3][i] = dp[i - 3][i - 1] + dp[i - 4][i - 1];
    dp[i - 3][i] %= mod;
  }
  cout << dp[s - 3][s] << endl;
}


Measured memory_bytes: 34484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class30
    {
        static void Main()
        {
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long V = GCD(A[0], A[1]);
            long count = 1;
            
            for(int i = 2;V!=1 ; i++)
            {
                if (i > V / i)
                {
                    count++;
                    break;
                }
                if (V % i == 0)
                {
                    while (V % i == 0)
                    {
                        V /= i;
                    }
                    count ++;
                }
                
            }
            Console.WriteLine(count);
        }
        static long GCD(long a,long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N,A,B;
  cin>>N>>A>>B;
  ll h[N], answer, spells;
  for (int i = 0; i < N; i++) {
    cin>>h[i];
  }
  for (ll l = 1, r = 1e9; l <= r; spells <= (l+r)/2 ? answer = (l+r)/2, r = answer-1 : l = (l+r)/2+1) {
    spells = 0;
    for (int i = 0; i < N && spells <= (l+r)/2; i++) {
      if (h[i] > (l+r)/2*B) {
        spells += (h[i]-(l+r)/2*B-1)/(A-B)+1;
      }
    }
  }
  cout << answer;
}

Measured memory_bytes: 4408
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ab = [list(map(int, readline().split())) for _ in range(n)]
cd = [list(map(int, readline().split())) for _ in range(n)]
cd.sort()
cnt = 0
for c, d in cd:
    memo = []
    for i, (a, b) in enumerate(ab):
        if c > a and d > b:
            memo.append([i, b])
    if memo:
        cnt += 1
        memo.sort(key=lambda x: -x[1])
        ab.pop(memo[0][0])
print(cnt)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{  
     int a[15];
     for(int i=0;i<10;i++) cin>>a[i];
     sort(a,a+10);
    for(int i=9;i>=7;i--) cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1176