akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

const int MAX = 300000;

template <typename X>
struct SegTree {
  using FX = function<X(X, X)>; // X•X -> X となる関数の型
  int n;
  FX fx;
  const X ex;
  vector<X> dat;
  SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
    int x = 1;
    while(n_ > x) x *= 2;
    n = x;
  }
  void set(int i, X x) { dat[i + n - 1] = x; }
  void build() {
    for(int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
  }
  void update(int i, X x) {
    i += n - 1;
    dat[i] = x;
    while(i > 0){
      i = (i - 1) / 2;  // parent
      dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
  X query_sub(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l){
      return ex;
    }else if(a <= l && r <= b){
      return dat[k];
    }else{
      X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
      X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
      return fx(vl, vr);
    }
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k; cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  auto fx = [](int x1, int x2) -> int { return max(x1, x2); };
  int ex = 0;
  SegTree<int> rmq(MAX+1, fx, ex);
  rmq.set(a[0], 1);
  rmq.build();

  vector<int> dp1(n,0), dp2(n,0);
  dp1[0] = 1;
  FOR(i,1,n){
    dp1[i] = rmq.query(max(a[i]-k,0), min(a[i]+k,MAX)+1)+1;
    //dp2[i] = max(dp1[i-1], dp2[i-1]);
    rmq.update(a[i], dp1[i]);
  }

  int ans = 0;
  REP(i,n){
    chmax(ans, dp1[i]);
    //chmax(ans, dp2[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11424
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define MAX 45
int F[MAX];


int fibonacci(int i){
    if(i == 1 || i == 0) return F[i] = 1;
    if(F[i]) return F[i];
    return F[i] = fibonacci(i-1) + fibonacci(i-2);
}

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

    cout << F[n] << endl;

    return 0;
}


Measured memory_bytes: 3124
from collections import deque
N,M=map(int,input().split())
haba=[[] for i in range(N+1)]
for i in range(M):
    A,B=map(int,input().split())
    haba[A].append(B)
    haba[B].append(A)
kyori=[-1]*(N+1)
kyori[0]=0
kyori[1]=0

que=deque()
que.append(1)

while que:
    kari=que.popleft()
    for i in haba[kari]:
        if kyori[i]!=-1:
            continue
        kyori[i]=kari
        que.append(i)

ans=kyori[2:]
print("Yes")
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 34628
#line 1 "template.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define inf 0x3fffffff
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int M=8000000;
const int MOD=1000000007;
LL bin(LL x,LL n,LL MOD)
{
    LL ret=MOD!=1;
    for (x%=MOD;n;n>>=1,x=x*x%MOD)
        if (n&1) ret=ret*x%MOD;
    return ret;
}
LL invf[M],fac[M]={1};
void fac_inv_init(LL n,LL p)
{
    for (int i=1;i<n;i++)
        fac[i]=i*fac[i-1]%p;
    invf[n-1]=bin(fac[n-1],p-2,p);
    for (int i=n-2;i>=0;i--)
        invf[i]=invf[i+1]*(i+1)%p;
}

inline LL C(LL n,LL m){ // n >= m >= 0
    return n<m||m<0?0:fac[n]*invf[m]%MOD*invf[n-m]%MOD;
}

LL calc(LL x,LL y)
{
    LL ans=y%MOD;
    for (LL i=1;i<=x;i++)
        ans=(ans+C(y+i+1LL,i+1LL))%MOD;
        //cout<<ans<<endl;
    return ans;
}
LL a,b,c,d;
int main()
{
    fac_inv_init(4000000,MOD);
    //cout<<calc(2,2)<<endl;
    //return 0;
    cin>>a>>b>>c>>d;
    LL ans=(calc(c,d)+calc(a-1,b-1))%MOD;
    ans=(ans+MOD-calc(a-1,d))%MOD;
    ans=(ans+MOD-calc(c,b-1))%MOD;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 63232
# C
N, x = map(int, raw_input().split())
A = map(int, raw_input().split())

# greedy from left
res = 0
for i in range(1, N):
    if A[i] + A[i-1] > x:
        if x > A[i-1]:
            res += A[i] - x + A[i-1]
            A[i] = x - A[i-1]
        else:
            res += A[i]
            A[i] = 0
            res += A[i-1] - x
            A[i-1] = x
    else:
        pass

print res

Measured memory_bytes: 11340
n,k = map(int, input().split())
d = []
A = []
cld = [0]*(n+1)
for i in range(k):
  d.append(int(input()))
  A.append(list(map(int, input().split())))
  
for i,j in enumerate(A):
  for l in range(d[i]):
    cld[j[l]] += 1

print(cld.count(0)-1)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define tt long t;cin>>t;while(t--)
#define tez ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define plli pair<lli,lli>
#define vlli vector<lli>
#define vplli vector<plli>
#define pqlli priority_queue <lli>
#define pqplli priority_queue <plli>
#define mplli map<lli,lli>
#define all(v) v.begin(),v.end()
#define alll(s) s.begin(),s.end(),s.begin(), ::tolower
#define allu(s) s.begin(),s.end(),s.begin(), ::toupper
 
#define mod 1000000007
#define ff first
#define ss second
#define fori(i,a,b)    for(int i=a;i<b;i++)
#define ford(i,a,b)    for(int i=a;i>=b;i--)
#define br cout<<endl
#define sz(v) (long)v.size()
#define YS cout<<"YES"<<endl
#define ys cout<<"yes"<<endl
#define Ys cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define no cout<<"no"<<endl
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define bs binary_search
#define mp make_pair
#define llmn LLONG_MIN
#define llmx  LLONG_MAX
#define stp setprecision
#define fxd fixed
#define tu (char)toupper
#define tl (char)tolower
#define coutv(v) for(lli index=0;index<v.size();index++) {cout<<v[index]<<" ";} br;
 
using namespace std;
using namespace std::chrono; 
 
/*
lli count01(string s,char ch){
  lli mx=0,c=0;
  if(ch=='0'){
 
   fori(i,0,sz(s)){
     if(s[i]=='0'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}
 
   }
 
  }
  else{
 
    fori(i,0,sz(s)){
     if(s[i]=='1'){
        c++;}
     else{
        c=0;}
        if(c>mx){mx=c;}
 
    }
 
  }
return mx;
 
}
*/
/*
vector<lli> prime(lli n){
  bool a[n+1];
  memset(a,true,sizeof(a));
  for(lli i=2;i*i<=n;i++){
    if(a[i]){
      for(lli j=i*i;j<=n;j+=i)
      {  a[j]=false;}
    }
  }
  vector<lli>v;
  for(lli i=2;i<=n;i++){
    if(a[i]){
      v.pb(i);
    }
  }
  return v;
}
*/

/*
lli power( lli a, lli x){
    lli ans=1;
    a=a%mod;
    while(x>0){
       if(x%2==1){
        ans=(ans*a)%mod;
       }
       a=(a*a)%mod;
       x/=2;
   }
   return ans;
}
*/

//int dir[][2]={{0,1},{0,-1},{-1,0},{1,0}};

void solve(){
    lli n;
    cin>>n;
    cout<<!n<<endl;
}


int main(){
tez
auto start = high_resolution_clock::now(); 

solve();



auto stop = high_resolution_clock::now(); 
auto duration = duration_cast<microseconds>(stop - start);
double Tsec= (double)duration.count()/(double)1000000;
//cout<<Tsec<<endl;
 
return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[200010], cnt[200010];
int main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	int ans = 0;
	sort(cnt, cnt + 200010,greater<int>());
	for (int i = K; i < 200010; i++) {
		ans += cnt[i];
	}
	cout << ans << endl;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j,l;
	scanf("%d %d",&n,&l);
	int a[1000];
	int sum = 0;
	for(i=1;i<=n;i++){
		a[i] = l + i - 1;
		sum += a[i];
	}
	int temp = sum;
	int minim = inf;
	int ans;
	for(i=1;i<=n;i++){
		temp -= a[i];
		if(abs(temp - sum) < minim) {
			minim = abs(temp - sum);
			ans = temp;
		}
		temp = sum;
	}
	printf("%d\n",ans);
	return 0;
};

Measured memory_bytes: 256
N,K=map(int,input().split())
p=[int(i)-1 for i in input().split()]
q=[int(i)-1 for i in input().split()]
def inv(seq):
    res=[0 for i in range(N)]
    for i in range(N):
        res[seq[i]]=i
    return res
def times(seq1,seq2):
    res=[0 for i in range(N)]
    for i in range(N):
        res[i]=seq1[seq2[i]]
    return res
md=[[0 for i in range(N)] for i in range(6)]
for i in range(N):
    md[0][i]=p[i]
    md[1][i]=q[i]
for i in range(2,6):
    md[i]=times(md[i-1],inv(md[i-2]))
A=times(times(q,inv(p)),times(inv(q),p))
T=(K-1)//6
def expseq(seq,k):
    if k==0:
        return [i for i in range(N)]
    elif k==1:
        return seq
    elif k%2==0:
        return expseq(times(seq,seq),k//2)
    else:
        return times(expseq(times(seq,seq),k//2),seq)
tmp=expseq(A,T)
ans=times(times(tmp,md[(K-1)%6]),inv(tmp))
print(" ".join([str(i+1) for i in ans]))


Measured memory_bytes: 38732
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


int s[4][4]={
    {6,3,1,4},
    {2,0,2,0},
    {1,3,6,4},
    {5,0,5,0}
};
int check(int x,int y){
    return s[x%4][y%4];
}

main(){
    int h=in(),w=in();
    int mp[110][110];
    rep(i,h){
        string s;cin>>s;
        rep(j,w){
            mp[i][j]=(s[j]-'0');
        }
    }
    int t[110][110]={};
    t[0][0]=1;
    if(mp[0][0]!=6){
        cout<<"NO\n";return 0;
    }
    rep(i,h){
        rep(j,w){
            if(mp[i][j]==check(i,j))t[i+1][j+1]=1;
        }
    }
    queue<pii> q;
    q.emplace(1,1);
    int visited[110][110]={};
    visited[1][1]=1;
    int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
    while(!q.empty()){
        int x,y;
        tie(x,y)=q.front();
        q.pop();
        rep(i,4){
            if(t[x+dx[i]][y+dy[i]]){
                if(!visited[x+dx[i]][y+dy[i]]) {
                    q.emplace(x+dx[i],y+dy[i]);
                    visited[x+dx[i]][y+dy[i]]=1;
                }
            }
        }
    }
    cout <<(visited[h][w] ? "YES\n" : "NO\n");
}


Measured memory_bytes: 3356
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A,B,C,D; cin >> A >> B >> C >> D;
    string res;
    if (A + B > C + D) {res = "Left";}
    else if (A + B < C + D) {res = "Right";}
    else {res = "Balanced";}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
rest=[list(map(int,input().split())) for _ in range(N)]
#print(rest)
push=0
a=0
b=0
for i in range(N-1,-1,-1):
    #print(i)
    a = rest[i][0] + push
    push=push+((rest[i][1]-a%rest[i][1])%rest[i][1])
    #print(push)
print(push)



Measured memory_bytes: 60376
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int a, b, c, d, e;
   cin >> a >>b >> c;
   
   d = a - b ;
   e = c - d ;
   
   if(e > 0)
   cout << e << endl;
    
   else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1 % mod;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
vector<string> res;
ll n;
void recur(ll pos, char prevMax, string &s) {

  if (pos == n + 1) {
    res.push_back(s);
    return;
  }
  for (char c = 'a'; c <= prevMax + 1; c++) {
    s += c;
    recur(pos + 1, max(prevMax, c), s);
    s.pop_back();
  }
}

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

  cin >> n;
  string s = "a";
  recur(2, 'a', s);
  sort(res.begin(), res.end());
  for (string &s : res)
    cout << s << en;

  return 0;
}

Measured memory_bytes: 9716
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p,l,r;
};

struct Node t[MAX];
int n,d[MAX],h[MAX];

void depth(int u, int de){
  if(u==NIL)return;
  d[u]=de;
  depth(t[u].l,de+1);
  depth(t[u].r,de+1);
}

int high(int u){
  int h1=0,h2=0;
  if(t[u].l!=NIL)h1=high(t[u].l)+1;
  if(t[u].r!=NIL)h2=high(t[u].r)+1;
  return h[u]=(h1>h2 ? h1 : h2);
}

int sibling(int u){
  if(t[u].p==NIL)return NIL;
  if(t[t[u].p].l!=u && t[t[u].p].l!=NIL)return t[t[u].p].l;
  if(t[t[u].p].r!=u && t[t[u].p].r!=NIL)return t[t[u].p].r;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",t[u].p);
  printf("sibling = %d, ",sibling(u));
  int degree;
  if(t[u].l!=NIL)degree++;
  if(t[u].r!=NIL)degree++;
  printf("degree = %d, ",degree);
  printf("depth = %d, ",d[u]);
  printf("height = %d, ",h[u]);

  if(t[u].p==NIL)printf("root\n");
  else if(t[u].l==NIL && t[u].r==NIL)printf("leaf\n");
  else printf("internal node\n");
  
  }

int main(){
  int v,l,r,root=0,i;
  scanf("%d",&n);

  for(i=0;i<n;i++)t[i].p=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    t[v].l=l;
    t[v].r=r;
    if(l!=NIL)t[l].p=v;
    if(r!=NIL)t[r].p=v;
    
  }

  for(i=0;i<n;i++)if(t[i].p==NIL)root=i;

  depth(root,0);
  high(root);

  for(i=0;i<n;i++)print(i);
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <map>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll h, w, n;
ll a[15];
map<pair<ll, ll>, ll> ma;

int main()
{
    scanf("%lld%lld%lld", &h, &w, &n);
    for(ll i = 0; i < n; i++)
    {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        for(ll j = -2; j <= 0; j++)
        {
            for(ll k = -2; k <= 0; k++)
            {
                if(x + j < 1 || y + k < 1) continue;
                if(x + j + 2 > h || y + k + 2 > w) continue;
                ma[make_pair(x + j, y + k)]++;
            }
        }
    }
    for(auto it : ma)
    {
        a[it.S]++;
    }
    a[0] = (h - 2) * (w - 2);
    for(ll i = 1; i <= 9; i++)
    {
        a[0] -= a[i];
    }
    for(ll i = 0; i <= 9; i++)
    {
        printf("%lld\n", a[i]);
    }
    return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    char ch;
    cin >> ch;
    if (islower(ch)) cout << "a";
    else cout << "A";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
main() {
	for(int n,p[7]={},i;cin>>n,n;){
		for(i=n;i--;)cin>>n,p[n/10<6?n/10:6]++;
		for(i=0;i<7;p[i++]=0)cout<<p[i]<<endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-2;
const int inf=1e8;
int main(){
	int q;
	cin>>q;
	while(q--){
		double x,y,z;
		cin>>x>>y>>z;
		int n;
		cin>>n;
		vector<vector<double> >in(n,vector<double>(3));
		rep(i,n)rep(j,3)cin>>in[i][j];
		rep(i,n)rep(j,n)rep(k,n)if(i!=j&&j!=k&&k!=i){
			double a=hypot(hypot(in[i][0]-in[j][0],in[i][1]-in[j][1]),in[i][2]-in[j][2]);
			double b=hypot(hypot(in[k][0]-in[j][0],in[k][1]-in[j][1]),in[k][2]-in[j][2]);
			double c=hypot(hypot(in[i][0]-in[k][0],in[i][1]-in[k][1]),in[i][2]-in[k][2]);
			double t=a/x;
			if(abs(x*t-a)<EPS&&abs(y*t-b)<EPS&&abs(z*t-c)<EPS)cout<<k+1<<" "<<i+1<<" "<<j+1<<endl;
		}
	}
}

Measured memory_bytes: 1268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] nums = new long[1000001];
		
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			int m = sc.nextInt();
			nums[num] += m;
		}
		
		for (int i = 1; i < nums.length; i++) {
			if (k > 0 && nums[i] > 0) {
				k -= nums[i];
				if (k <= 0) {
					System.out.println(i);
					System.exit(0);
				}
			}
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 47692
import sys
N,Y = map(int,input().split())
        
for A in range(N+1)[::-1]:
  for B in range(N-A+1)[::-1]:
    C=N-A-B
    if (10000*A+5000*B+1000*C==Y):
      print(A,B,C)        
      sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  for (int i=0; i<w+2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i=0; i<h; i++) {
    string a;
    cin >> a;
    a="#"+a+"#";
    cout << a << endl;
  }
  for (int i=0; i<w+2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		boolean beforeC = true;
		for (char c : arr) {
			if (beforeC) {
				if (c == 'C') {
					beforeC = false;
				}
			} else {
				if (c == 'F') {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A[][] = new int[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        A[i][j]=sc.nextInt();
      }
    }
    int N = sc.nextInt();
    int b[] = new int[N];
    for(int i=0;i<N;i++){
      b[i]=sc.nextInt();
    }
    int B[][] = new int[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        B[i][j]=0;
      }
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<3;j++){
        for(int k=0;k<3;k++){
          if(A[j][k]==b[i]){
            B[j][k]=1;
          }
        }
      }
    }
    if(B[0][0]+B[0][1]+B[0][2]==3||
       B[1][0]+B[1][1]+B[1][2]==3||
       B[2][0]+B[2][1]+B[2][2]==3||
       B[0][0]+B[1][0]+B[2][0]==3||
       B[0][1]+B[1][1]+B[2][1]==3||
       B[0][2]+B[1][2]+B[2][2]==3||
       B[0][0]+B[1][1]+B[2][2]==3||
       B[2][0]+B[1][1]+B[0][2]==3){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
            
  }
  

  
}

Measured memory_bytes: 26964
n = int(input())
al = [0] + list(map(int, input().split())) + [0]
csum = 0
for a0,a1 in zip(al[:-1], al[1:]):
    v = abs(a1-a0)
    csum += v

ansl = []
for a0,a1,a2 in zip(al[:-2], al[1:-1], al[2:]):
    if a0 <= a1 <= a2 or a2 <= a1 <= a0:
        ansl.append(csum)
    elif a0 <= a1 and a1 >= a2:
        ansl.append(csum-(a1-max(a0,a2))*2)
    else:
        ansl.append(csum -(min(a2,a0)-a1)*2)

for a in ansl: print(a)

Measured memory_bytes: 90296
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
s = set()
for i in range(n):
    x = ni()
    if x in s:
        s.remove(x)
    else:
        s.add(x)
print(len(s))


Measured memory_bytes: 11884
#define  _USE_MATH_DEFINES
#include<bits/stdc++.h>

using namespace std;

int main(){
   long double avmhand = 2*M_PI/3600;
   long double avhhand = 2*M_PI/(12*3600);
   long double a,b,h,m;
   cin>>a>>b>>h>>m;
   long double angle = fabs(avhhand*(h+m/60)*3600-avmhand*m*60);
   long double c = sqrt(a*a+b*b-2*a*b*cos(angle));
   cout << std::setprecision(30);
   cout<<c<<endl;
   //cout<<angle;
   
   return 0;
}


Measured memory_bytes: 4080
import sys

n, m = map(int, input().split())

a = []

for i in range(n):
    a.append(list(map(int, input().split())))

a.sort()

i = 0
ans = 0

while m > 0:
    if m > a[i][1]:
        ans += a[i][0] * a[i][1]
        m = m - a[i][1]
        i += 1
    else:
        ans += a[i][0] * m
        print(ans)
        sys.exit()

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

int main(){
	int N, cnt = 0;
	cin >> N;
	string A, B, C;
	cin >> A >> B >> C;
	for(int i=0; i<N; i++){
		if(A[i] == B[i] && B[i] != C[i]){
			cnt++;
		}else if(A[i] != B[i] && B[i] == C[i]){
			cnt++;
		}else if(A[i] == C[i] && A[i] != B[i]){
			cnt++;
		}else if(A[i] != B[i]){
			cnt = cnt + 2;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int fx(int n){
  int a=0;
  for(;n>0;n=n/10){
    a=a+n%10;
  }
  return a;
}
int main()
{
  int N;
  scanf("%d",&N);
  if(N%fx(N)==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
using namespace std;

bool IsACGT(char c)
{
	return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

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

	int i = 0;
	int j = 0;

	int max_count = 0;
	while (true)
	{
		for (i = j; !IsACGT(S[i]) && S[i] != '\0'; ++i);

		if (S[i] == '\0')
		{
			break;
		}

		for (j = i; IsACGT(S[j]) && S[j] != '\0'; ++j);

		max_count = max(max_count, j - i);
	}

	cout << max_count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  
  if(x - r < 0 || x + r > W){
    printf("No\n");
  } else if(y - r < 0 || y + r > H){
    printf("No\n");
  } else if(x - r >= 0 && x + r <= W){
    printf("Yes\n");
  } else if(y - r >= 0 && y + r <= H){
    printf("Yes\n");
  }
  return 0;

}

Measured memory_bytes: 584
<?php
// https://atcoder.jp/contests/abc046/tasks/abc046_a
// 入力された文字列が何種類の文字で構成されているかを求めよ

// count_string($array, $string)で$arrayに含まれる$stringの数をカウントする
function count_string($array, $string)
{
  return count(array_keys($array, $string));
}

$array = explode(" ", trim(fgets(STDIN)));
$next = 0;
$ans = count($array);

foreach ($array as $key => $value) {
  if(count_string($array, $value) != 1){
    $ans--;
    $array[$key] = 0;
  }
}

echo $ans."\n";

Measured memory_bytes: 4856
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  string s;
  cin >> s;
  
  int ans = 0;
  REP(i,4){
    if(s[i] == '+') ans++;
    else ans--;
  }
  
  cout << ans << endl;

  return 0;
}

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

int main(void){

    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int K;
    cin >> K;
    cout <<vec[K-1]<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll a,b;
cin >>a>>b;
if(a<b){
cout<<a;
}
else if(a==b){
cout<<-1;
}
else{
if(a%b==0){
cout<<-1;
}
else{
cout<<a;
}
}

return 0;
}

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

int main() {
  int n;
  cin >>n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n)cin>>a.at(i);
  rep(i,n)cin>>b.at(i);
  int sum=0;
  rep(i,n){
    if(a.at(i)>b.at(i))sum+=a.at(i)-b.at(i);
  }
  cout<<sum<<endl;
}


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

using namespace std;
int input(){
    int res = 0; char c = ' ';
    while (c < '0') c = getchar();
    while (c >= '0') res = res * 10 + (c - '0'), c = getchar();
    return res;
}
const int N = 1e5 + 1;

int a[N];
int main(){
    int n = input(), k = input(), g = 0;
    for (int i = 0; i < n; ++ i)
        g = __gcd(g, a[i] = input());
    for (int i = 0; i < n; ++ i){
        if (a[i] >= k && (a[i] - k) % g == 0){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 640
N = int(input())
A = []
for i in range(N):
  As = list(map(int, input().split()))
  A.append(As)
r = 0
for i in range(N):
  for j in range(i+1, N):
    ok = False
    for k in range(N):
      if A[i][j] > A[i][k]+A[k][j]:
        print(-1)
        exit()
      if A[i][j] == A[i][k]+A[k][j] and k != i and k != j:
        ok = True
    if not(ok):
      r += A[i][j]
print(r)


Measured memory_bytes: 43228
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=200;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nHr(ll n,ll r){
	return nCk(n+r-1,r);
}

int n,m;
vi a;

int main(){
	Init();
	cin>>n>>m;
	a=vi(m);
	for(int i=0;i<m;i++){
		char c;
		cin>>c;
		if(c=='b') a[i]++;
	}
	ll res=1;
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++){
		vi b(m),c(i);
		int A=0,B=0,C=0;
		for(int k=0;k<m;k++){
			if(!a[k]&&A+B!=i) A++,b[k]=1;
			else if(a[k]&&A) A--,b[k]=1,c[B++]=k;
		}
		for(int k=0;k<m;k++) if(a[k]+b[k]==0&&C<j) C++,b[k]=1;
		if(B!=i||C!=j||2*i+2*j-1>n||i+j==0) continue;
		for(int k=0;k<i;k++){
			int l=c[k];
			c[k]=0;
			while(l<m) c[k]+=1-b[l++];
			c[k]=min(c[k],(n-2*i-2*j+1)/2);
		}
		c.push_back(0);
		reverse(c.begin(),c.end());
		vvl dp(i+1,vl(n+1));
		dp[0][0]=Div(F[i+j],F[j]);
		for(int k=0;k<n;k++) for(int I=i;I>=0;I--) for(int J=0;J<=c[I];J++) for(int l=1;I+l<=i&&J+k*l<=c[I+l];l++){
			dp[I+l][J+k*l]+=Div(dp[I][J],F[l]);
		}
		for(int k=0;k<=c[i];k++) (res+=dp[i][k]*nHr(2*k+4*i+2*j+1,n-2*k-2*i-2*j+1))%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

std::vector<std::pair<int32_t, uint32_t>> lEnds;
std::vector<std::pair<int32_t, uint32_t>> rEnds;
std::vector<bool> used;
std::vector<std::pair<int32_t, int32_t>> seg;

void input() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	uint32_t n;
	std::cin >> n;
	for (uint32_t i = 0;i < n;i++) {
		uint32_t l, r;
		std::cin >> l >> r;
		seg.push_back({l, r});
		lEnds.push_back({l, i});
		rEnds.push_back({r, i});
	}
}

uint64_t solve(bool startDir = true) {
	used = std::vector<bool>(lEnds.size(), false);
	std::sort(lEnds.rbegin(), lEnds.rend());
	std::sort(rEnds.begin(), rEnds.end());

	uint32_t lInd = 0;
	uint32_t rInd = 0;
	int32_t x = 0;
	int64_t ans = 0;

	bool dir = startDir;
	for (uint32_t i = 0;i < lEnds.size();i++) {
		if (dir) {
			while (used[lEnds[lInd].second]) {
				lInd++;
			}
			auto s = seg[lEnds[lInd].second];

			if (s.first <= x) {
				if (s.second >= x) {
					continue;
				} 
				ans += std::abs(x - s.second);
				x = s.second;
			} else {
				ans += std::abs(s.first - x);
				x = s.first;
			}
			used[lEnds[lInd].second] = true;
		} else {
			while (used[rEnds[rInd].second]) {
				rInd++;
			}
			auto s = seg[rEnds[rInd].second];

			if (s.second >= x) {
				if (s.first <= x) {
					continue;
				} 
				ans += std::abs(x - s.first);
				x = s.first;
			} else {
				ans += std::abs(s.second - x);
				x = s.second;
			}

			used[rEnds[rInd].second] = true;
		}
		dir = not dir;
	}
	ans += std::abs(x);
	return ans;
}

int main() {
	input();
	uint64_t ans = std::max(solve(), solve(false));
	//uint64_t ans = solve();
	std::cout << ans << "\n";
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

template <typename T>
class SegmentTree {
    public:
        int n;
        vector<T> data;
        T e;
        function<T(T, T)> operation;
        function<T(T, T)> process;

        SegmentTree() {}
        SegmentTree(int n_, T e_, function<T(T, T)> operation_, 
            function<T(T, T)> process_) : e(e_), operation(operation_), process(process_) {
            n = 1;
            while (n < n_) n <<= 1;
            data.assign(2 * n, e);
        }

        void build() {
            for (int i = n - 1; i > 0; --i) {
                data[i] = operation(data[i * 2 + 0], data[i * 2 + 1]);
            }
        }

        void set(int idx, T v) {
            data[idx + n] = process(data[idx + n], v);
        }

        void update(int idx, T v) {
            idx += n;
            data[idx] = process(data[idx], v);
            while (idx >>= 1) {
                data[idx] = operation(data[2 * idx + 0], data[2 * idx + 1]);
            }
        }

        T query(int a, int b) {
            return query(a, b + 1, 1, 0, n);
        }

        T query(int a, int b, int k, int l, int r) {
            if (a >= r || b <= l) return e;
            if (a <= l && b >= r) return data[k];
            T c = query(a, b, 2 * k + 0, l, (l + r) / 2);
            T d = query(a, b, 2 * k + 1, (l + r) / 2, r);
            return operation(c, d);
        }

        T operator[](int idx) {
            return data[idx + n];
        }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, q;
    string s;
    cin >> n >> s >> q;
    SegmentTree<ll> seg = SegmentTree<ll>(n, 0LL, 
            [](ll a, ll b) {return a | b; }, [](ll a, ll b) { return 1 << b; });
    rep (i, s.size()) seg.set(i, s[i] - 'a');
    seg.build();
    rep (_, q) {
        int t;
        cin >> t;
        if (t == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            idx--;
            seg.update(idx, c - 'a');
        } else {
            int res = 0;
            int l, r;
            cin >> l >> r;
            l--, r--;
            auto t = seg.query(l, r);
            cout << __builtin_popcount(t) << endl;
        }
    }
    
    return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a+b)%2 == 0) {
        cout << (a+b)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	
	for(int &x : a)
		cin >> x;
	sort(a.begin(), a.end());
	if(k >= n)
		cout << "0\n";
	else
		cout << accumulate(a.begin(), a.begin() + n - k, 0LL) << '\n';
	
	
	return 0;
}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;
  int m=0;
  map<string,int> mp;
  set<string> se;
  rep(i,n){
    string s;
    cin>>s;
    se.insert(s);
    chmax(m,++mp[s]);
  }
  vector<string> s;
  for(auto au:se){
    if(mp[au]==m){
      s.push_back(au);
    }
  }
  sort(all(s));
  for(auto au:s){
    cout<<au<<endl;
  }
}

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

int main(){
  int i,j,cnt=0;
  int m,d;
  cin>>m>>d;
  for(j=1;j<=m;j++){
    for(i=22;i<=d;i++){
      if((i%10)>=2 && (i/10)*(i%10)==j)cnt++;
    }
  }
  cout<<cnt;
}

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

const int INF = 1e18;

signed main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++) cin >> b[i];

  bool f = true;
  for (int i = 0; i < N; i++) {
    if (a[i] != b[i]) {
      f = false;
      break;
    }
  }

  if (f) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> S;
  int ans = 0;
  for (int i = 50; i >= 1; i--) {
    int d[60][60];
    for (int a = 0; a <= 55; a++) {
      for (int b = 0; b <= 55; b++) {
        d[a][b] = INF;
      }
    }

    for (int j = 1; j <= i - 1; j++) {
      for (int a = 0; a <= 55; a++) {
        d[a][a % j] = min(d[a][a % j], (int)pow(2, j));
      }
    }
    for (auto x : S) {
      for (int a = 0; a <= 55; a++) {
        d[a][a % x] = min(d[a][a % x], (int)pow(2, x));
      }
    }
    for (int k = 0; k <= 55; k++) {
      for (int a = 0; a <= 55; a++) {
        for (int b = 0; b <= 55; b++) {
          d[a][b] = min(d[a][b], d[a][k] + d[k][b]);
        }
      }
    }

    bool check = false;
    for (int j = 0; j < N; j++) {
      if (d[a[j]][b[j]] == INF) {
        check = true;
        break;
      }
    }

    if (check) {
      S.push_back(i);
      ans += pow(2, i);
    }
  }

  int d[60][60];
  for (int a = 0; a <= 55; a++) {
    for (int b = 0; b <= 55; b++) {
      d[a][b] = INF;
    }
  }
  for (auto x : S) {
    for (int a = 0; a <= 55; a++) {
      d[a][a % x] = min(d[a][a % x], (int)pow(2, x));
    }
  }
  for (int k = 0; k <= 55; k++) {
    for (int a = 0; a <= 55; a++) {
      for (int b = 0; b <= 55; b++) {
        d[a][b] = min(d[a][b], d[a][k] + d[k][b]);
      }
    }
  }

  bool check = true;
  for (int j = 0; j < N; j++) {
    if (d[a[j]][b[j]] == INF) {
      check = false;
      break;
    }
  }

  if (!check) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

divs = make_divisors(N)
ans = 0
for div in divs[1:]:
    m = div - 1
    if N % m == N // m:
        ans += m

print(ans)


Measured memory_bytes: 3296
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int num;
  cin >> num;
  vector<int> vec(num);
  for(int i=0; i<num; i++){
    cin >> vec[i];
  }
  int counter = 0;
  for(int i=0; i<num; i++){
    int max = 0;
    for(int j=0; j<vec.size(); j++){
      if(max < vec[j]){
        max = vec[j];
      }
    }
    for(int j=vec.size()-1; j>=0; j--){
      if(max == vec[j]){
        vec.erase(vec.begin() + j);
      }
    }
    counter++;
    if(vec.size() == 0) break;
  }
  cout << counter;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

ll sum(ll x) {
  ll s = 0;
  while (x > 0) {
    s += x % 10;
    x /= 10;
  }
  return s;
}

int main() {
  ll N;
  cin >> N;
  ll ans = INF;
  for (ll i = 1; i < N; i++) {
    ll A = i, B = N - i;
    ans = min(ans, sum(A) + sum(B));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int p, q, r, ans;
	cin >> p >> q >> r;
	ans = min(p + q, min(p + r, r + q));
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
int len;
char ss[4444];
vector<int>r,g;
int main()
{
	len=read();
	scanf("%s",ss);
	LL asd=0;
	LL s1,s2,s3;s1=s2=s3=0;
	for(int i=0;i<len;++i)
	{
		if(ss[i]=='R')
		{
			asd+=s2*s3;
			s1++;
		}
		else if(ss[i]=='G')
		{
			asd+=s1*s3;
			s2++;
		}
		else 
		{
			asd+=s1*s2;s3++;
		}
	}
	for(int i=0;i<len;i++)
    for(int j=i+1;j<len;j++)
	{
		if((i+j)&1)continue;
		if(ss[i]!=ss[j]&&ss[i]!=ss[(i+j)/2]&&ss[j]!=ss[(i+j)/2])asd--;
	}
	printf("%lld\n",asd);
}

Measured memory_bytes: 3800
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = list(input())
ans = 0

def score(t):
    if t == 'r':return p
    if t == 's':return r
    else:return s

dp = [[0 for i in range(2)] for j in range(n + 1)]
for i in range(k):
    dp[i][0] = 0
    dp[i][1] = score(t[i])
    tmp = i
    for j in range(i + k,n,k):
        dp[j][0] = max(dp[j - k])
        if t[j] == t[j - k]:
            dp[j][1] = dp[j - k][0] + score(t[j])
        else:
            dp[j][1] = max(dp[j - k]) + score(t[j])
        tmp = j
    ans += max(dp[tmp])
print(ans)

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

int main() {
  int money = 100000;
  int n;

  cin >> n;

  for(int i = 0; i < n; i++) {
    money *= 1.05;
    if(money % 1000 != 0) {
      money += 1000 - (money % 1000);
    }
  }

  cout << money << endl;

  return 0;
}

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

const int maxn=(int)1e5+10;
long long dp[maxn];

int main()
{
	int n,k;
	scanf("%d %d",&n, &k);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d %d",&a, &b);
		for(int j=k;j>=a;j--)
			dp[j]=max(dp[j],dp[j-a]+b);
	}
	long long maxi=0;
	for(int i=1;i<=k;i++)
		maxi=max(maxi,dp[i]);
	printf("%lld",maxi);
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;
vector<int>G[100006];
vector<int>G2[100006];
set<int>S[100006];
int A[100006], B[100006];
int ans[100006];
void dfs(int now, int par) {
	int cnt = 1;
	rep(i, G[now].size()) {
		int e = G[now][i];
		if (e!=par) {
			while (S[now].find(cnt) != S[now].end())cnt++;	
			S[now].insert(cnt);
			S[e].insert(cnt);
			ans[G2[now][i]] = cnt;
			dfs(e, now);
		}
	}

}

signed main() {
	int n; cin >> n;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		A[i] = a; B[i] = b;
		G2[a].push_back(i);
		G2[b].push_back(i);
	}
	int M = 0;
	rep(i, n)M = max(M, (int)G[i].size());
	cout << M << endl;

	dfs(0, -1);
	rep(i, n - 1)cout << ans[i] << endl;
}

Measured memory_bytes: 31104
#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 oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

bool possible(int ans, vi a, int k){
	for(int& x : a){
		k -= (x+ans-1) / ans - 1;
	}
	
	return k >= 0;
}

void solve(){
	int n, k;
	cin >> n >> k;
	
	vi a(n);
	for(int& x : a)cin >> x;
	
	int mn=1, mx=1e9;
	while(mn != mx){
		int mid = (mn + mx) / 2;
		if(possible(mid, a, k))mx = mid;
		else mn = mid+1;
	}
	
	cout << mn;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 4764
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
using namespace std;
const int maxn=805;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char a[maxn][maxn];
int h,w,k,xs,ys;
int dis[maxn][maxn];
queue<pii> q;
inline int cal(int x,int y)
{
    return min(x,min(h-1-x,min(y,w-1-y)));
}
bool check(int x,int y)
{
    return (x>=0 && y>=0 && x<h && y<w && a[x][y]=='.' && dis[x][y]<0);
}
void clea()
{
    while(!q.empty())
    q.pop();
}
int main()
{
    cin>>h>>w>>k;
	for(int i=0;i<h;i++)
    {
		scanf("%s",a[i]);
        for(int j=0;j<w;j++)
        {
            if(a[i][j]=='S')
            {
                xs=i;
                ys=j;
            }
        }
	}
	int minn=cal(xs,ys);
    clea();
	q.push(mp(xs, ys));
    memset(dis,-1,sizeof(dis));
	dis[xs][ys]=0;
	while(!q.empty())
    {
        pii p=q.front();
        q.pop();
        int x=p.fi,y=p.se;
        if(dis[x][y]<=k && minn>cal(x,y))
        minn=cal(x,y);
        for(int i=0;i<4;i++)
        {
            int xx=x+dx[i],yy=y+dy[i];
            if(!check(xx,yy))
            continue;
            q.push(mp(xx,yy));
            dis[xx][yy]=dis[x][y]+1;
        }
	}
    int ans=1+(minn+k-1)/k;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int asum=0;
    int bsum=0;
    cin >> s;
    
    for(int i=0;i<=2;i++){
        if(s[i] == 'A'){
            asum+=1;
        }else{
            bsum +=1;
        }
        
    }if(asum == 3 || bsum ==3){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<int>arr(n);
	int sum=0;
	for(int i=0; i<n; i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	int ans=0;
	for(int i=0; i<n; i++){
		int temp=sum-arr[i];
		ans+=temp*arr[i];
	}
	ans/=2;
	cout<<ans;
	return 0;

}

Measured memory_bytes: 3628