akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 1010
#define M 5010
using namespace std;
int n,fa[N],a[N],fir[N],nxt[N<<1],to[N<<1],tot(1),f[N][2],fl(0);

inline void add(int u,int v){
	to[++tot]=v; nxt[tot]=fir[u]; fir[u]=tot;
}

void dfs(int x){
	int cur=0,s=0,mx=-1,g[2][M];
	for (int j=0;j<=a[x];j++)
		g[cur][j]=0;
	g[0][0]=1;
	for (int i=fir[x];i;i=nxt[i])
		if (to[i]!=fa[x]){
			dfs(to[i]);
			if (fl) return;
			cur^=1;
			for (int j=0;j<=a[x];j++)
				g[cur][j]=0;
			for (int j=0;j<=a[x];j++){
				if (j+f[to[i]][0]<=a[x])
					g[cur][j+f[to[i]][0]]|=g[cur^1][j];
				if (j+f[to[i]][1]<=a[x])
					g[cur][j+f[to[i]][1]]|=g[cur^1][j];
			}
			s+=f[to[i]][0]+f[to[i]][1];
		}
	for (int i=a[x];i>=0 && !~mx;i--)
		if (g[cur][i]) mx=i;
	if (!~mx){
		fl=1; return;
	}
	f[x][0]=a[x]; f[x][1]=s-mx;
//	printf("%d %d %d\n",x,f[x][0],f[x][1]);
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a_.out","w",stdout);
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		scanf("%d",&fa[i]);
		add(i,fa[i]),add(fa[i],i);
	}
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dfs(1);
	if (fl)
		puts("IMPOSSIBLE");
	else
		puts("POSSIBLE");
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep1(i, n) {
        if (i%3==0) continue;
        if (i%5==0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	char c;
	cin >> c;

	string v = "aiueo";
	for (int i = 0; i < 5; ++i) {
		if (v[i] == c) {
			cout << "vowel" << endl;
			return 0;
		}
	}

	cout << "consonant" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
int n,m,f[2005][2005],pn=4e6,fr[4000005],infr[4000005];
int C(int x,int y)
{
	if(x<0||y<0||x<y) return 0;
	return 1ll*fr[x]*infr[y]%mod*infr[x-y]%mod;
}
int main()
{
	fr[0]=infr[0]=1;
	for(int i=1;i<=pn;i++)
		fr[i]=1ll*fr[i-1]*i%mod;
	infr[pn]=fpow(fr[pn],mod-2);
	for(int i=pn-1;i>0;i--)
		infr[i]=1ll*infr[i+1]*(i+1)%mod;
	scanf("%d%d",&n,&m);
	if(m==1)
	{
		printf("1");
		return 0;
	}
	f[0][1]=1;
	for(int i=1;i<=n+1;i++)
	{
		for(int j=1;j<=i;j++)
		{
			f[i][j]=addmod(f[i-1][j]+1ll*f[i][j-1]*C((n-i+1)+(m-1)*(n-j+2)-1,m-2)%mod);
			//printf("i=%d,j=%d,f=%d,C(%d,%d)=%d\n",i,j,f[i][j],(n-i+1)+(m-1)*(n-j+1)-1,m-2,C((n-i+1)+(m-1)*(n-j+1)-1,m-2));
		}
	}
	int ans=1ll*f[n+1][n]*fr[n]%mod;
	printf("%d",ans);
	return 0;
}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
const int B = 450;
const int MAX_S = (200000/B)+10;

int N, Q, S;
bool lazy[2][MAX_S];
int A[2][200000+B];
int M[2][MAX_S];

void push(int k, int b) {
  if (!lazy[k][b]) return;
  rep(i, B) A[k][b*B+i] = A[k^1][b*B+i];
  lazy[k][b] = false;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  S = (N-1)/B+1;
  rep(k, 2) {
    rep(i, S) M[k][i] = INF;
    rep(i, N+B) A[k][i] = INF;
    rep(i, N) cin >> A[k][i], M[k][i/B] = min(M[k][i/B], A[k][i]);
  }
  cin >> Q;
  rep(i, Q) {
    int type, y, z;
    cin >> type >> y >> z;
    type--;
    int k = type%2;
    if (type/2 == 0) {
      y--;
      int b = y/B;
      push(k, b);
      push(k^1, b);
      A[k][y] = z;
      M[k][b] = INF;
      rep(i, B) M[k][b] = min(M[k][b], A[k][b*B+i]);
    }
    else if (type/2 == 1) {
      y--, z--;
      // min [y, z]
      int lb=y/B, rb=z/B, m = INF;
      push(k, lb);
      push(k, rb);
      if (lb == rb) {
        for (int i=y; i<=z; i++) m = min(m, A[k][i]);
      }
      else {
        for (int i=y; i<(lb+1)*B; i++) m = min(m, A[k][i]);
        for (int i=rb*B; i<=z; i++) m = min(m, A[k][i]);
        for (int b=lb+1; b<=rb-1; b++) m = min(m, M[k][b]);
      }
      cout << m << "\n";
    }
    else {
      rep(b, S) {
        if (!lazy[k^1][b]) {
          lazy[k][b] = true;
          M[k][b] = M[k^1][b];
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 4724
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed

    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)

    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res

import sys
import io, os
#input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, m, Q = map(int, input().split())
X = []
A = []
for i in range(m):
    l, r = map(int, input().split())
    l, r = l-1, r-1
    A.append(l)
    A.append(r)
    X.append((l, r, 0, i))
for i in range(Q):
    p, q = map(int, input().split())
    p, q = p-1, q-1
    A.append(p)
    A.append(q)
    X.append((p, q, 1, i))
X.sort(key=lambda x: (x[1], x[2]))

A = list(set(A))
A.sort()
d = {}
for i, a in enumerate(A):
    d[a] = i

bit = BIT(550)
ans = [-1]*Q
for l, r, t, i in X:
    l, r = d[l], d[r]
    if t == 0:
        bit.add(l, 1)
    else:
        ans[i] = bit.sum(l, r+1)
print(*ans, sep='\n')


Measured memory_bytes: 84900
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i,intial,n) for(int i=intial; i<(n) ; i++)
#define REP(i,intial,n) for(int i=intial; i<=(n) ; i++)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define MP make_pair
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

LL big_mod(LL n, LL p)
{
    if(p==0) return 1;
    if(!(p&1))
    {
        LL r = big_mod(n,p/2) % MOD;
        return ( (r%MOD) * (r%MOD) ) % MOD;
    }
    else return ( ( n%MOD) * (big_mod(n,p-1) %MOD)) % MOD;
}
long long gcd(long long a, long long b) {
  while (b != 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
LL ar[200010];
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
   int n;
   while(cin>>n)
   {
       LL first=0;
       LL second=0;
       LL minimum=10e19;
       rep(i,0,n)
       {
           cin>>ar[i];
           first+=ar[i];
       }
       rep(i,0,n-1)
       {
           second+=ar[i];
           minimum=min(minimum,abs(first-2*second));
       }
       cout<<minimum<<endl;
   }

}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define N 200000
int n, K, a[N];

int main() {
    cin >> n >> K;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]), ans += a[i] >= K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Five, Five Everywhere
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 55;
const int MAX_P = 55555;
const int M = 5;

/* typedef */

typedef vector<int> vi;

/* global variables */

bool primes[MAX_P + 1];

/* subroutines */

int gen_primes(int maxp, vi &pnums) {
  memset(primes, true, sizeof(primes));
  primes[0] = primes[1] = false;

  int p;
  for (p = 2; p * p <= maxp; p++)
    if (primes[p]) {
      pnums.push_back(p);
      for (int q = p * p; q <= maxp; q += p) primes[q] = false;
    }
  for (; p <= maxp; p++)
    if (primes[p]) pnums.push_back(p);
  return (int)pnums.size();
}

/* main */

int main() {
  vi pnums;
  int pn = gen_primes(MAX_P, pnums);
  //printf("pn=%d\n", pn);

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

  vi ans;

  for (vi::iterator vit = pnums.begin(); vit != pnums.end(); vit++) {
    int &pi = *vit;
    if (pi % M == 1) {
      ans.push_back(pi);
      if (ans.size() >= n) break;
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    if (i) putchar(' ');
    printf("%d", ans[i]);
  }
  putchar('\n');

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int b[100001],n,i,j,k,l,r,x;
ll a[100001],ans;

int dg(int l,int r)
{
	int X;
	if (x<b[l]) {ans+=b[r]-x;return b[r];}
	if (x>b[r]) {ans+=x-b[l];return b[l];}
	if (a[l]>=a[r])
	{
		a[l]+=a[r];
		ans+=b[r]-dg(l,r-1);
		return b[r];
	}
	else
	{
		a[r]+=a[l];
		ans+=dg(l+1,r)-b[l];
		return b[l];
	}
}

int main()
{
	#ifdef file
	freopen("agc023d.in","r",stdin);
	#endif
	
	scanf("%d%d",&n,&x);
	fo(i,1,n) scanf("%lld%d",&b[i],&a[i]);
	
	dg(1,n);
	printf("%lld\n",ans);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 8860
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
fw = s[:len(s)//2]
rv = s[::-1][:len(s)//2]
ans = 0
for i in range(len(s)//2):
    if fw[i] != rv[i]:
        ans += 1
print(ans)

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<double> v(n);
	for(int i=0; i<n; i++)
	
		cin>>v[i];
	
	sort(v.begin(), v.end());
	
	double ans = (v[0]+v[1])/2;
	for(int i=2; i<n; i++)
	{
		ans = (ans +v[i])/2;
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    string s;
    cin >> s;
    int cnt = 0;
    for(auto c : s){
        if(c == '2')cnt++;
    }

    ppp(cnt);


    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N=(int)1e3+5,INF=(int)1e18+7;

int n,m;

vector<string>v;
int dp[N][N];

int solve(int r,int c)
{
    
    if(r==n-1 and c==m-1)
    {
        return 1;
    }
    int &ans=dp[r][c];
    if(ans!=-1)return ans;
    ans=0;
    
    int op1=0,op2=0;
    
    if(r+1<n and v[r+1][c]=='.')
    {
        op1=solve(r+1,c);
    }
    
    if(c+1<m and v[r][c+1]=='.')
    op2=solve(r,c+1);
    
    
    return ans=(op1+op2)%mod;
    
}


void solve()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    v=vector<string>(n);
    for(auto &x:v)cin>>x;
    
    int ans=solve(0,0);
    
    cout<<ans;
   
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}


Measured memory_bytes: 12692
n,k=map(int,input().split())
a=[0]
aa=list(map(int,input().split()))
for i in range(n):
    a.append(aa[i])
count=[0]*(n+1)
now=1
r=[]
kaburi=-1
for i in range(1,n+1):
    if count[now]==0:
        count[now]=1
        r.append(now)
        now=a[now]
    else:  
        kaburi=now
        break
# print(r)
syuki=len(r)
kaburi_i=0
for i in range(syuki):
    if kaburi==r[i]:
        kaburi_i=i
num=syuki-kaburi_i #何周期か
#print(num)
if k<kaburi_i:
    print(r[k])
else:
    ind=k-kaburi_i
    ind=ind%num
    print(r[kaburi_i+ind])

Measured memory_bytes: 108488
#include<stdio.h>

#define MAX 100
#define INF 100000000

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim(){

  int i, u, v, mincost, sum = 0;
  int d[MAX], p[MAX], color[MAX];

  for(i = 0; i < n; i++){

    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){

    mincost = INF;
    u = -1;

    for(i =0; i < n; i++){
      if(mincost > d[i] && color[i] != BLACK){

        u = i;
        mincost = d[i];
      }
    }
    if(u == -1)
      break;

    color[u] = BLACK;

    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INF){
        if(d[v] > M[u][v]){

          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  for(i = 0; i < n; i++){
    if(p[i] != -1)

      sum += M[i][p[i]];
  }
  return sum;
}

int main(){

  int i, j, m;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){

      scanf("%d", &m);

      if(M[i][j] = (m == -1))
        M[i][j] = INF;

      else M[i][j] = m;
    }
  }

  printf("%d\n", prim());

  return 0;
}


Measured memory_bytes: 2104
[L, R] = map(int, input().split())

res = 2018
R2 = min(R+1, L+2019)
for i in range(L, R2):
  for j in range(i+1, R2):
    res = min(res, ((i % 2019) * (j % 2019)) % 2019)
    if res == 0:
      break

print(res)


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++)
    {
        if(((i%2 == 0) && (s[i] == 'L')) ||((i%2 ==1) && (s[i] == 'R')))
        {
            cout << "No";
            return 0;
        }

    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
 
const int INF = 10000000;

int n;
vi v;

int ans = INF;


void calc(int i, int s, int t){
	if(i == n){
		ans = min(ans, abs(s - t));
		return;
	}
	calc(i + 1, s + v[i], t);
	calc(i + 1, s, t + v[i]);
}

int main(){
	int s = 0, t = 0;
	while(cin >> n && n > 0){
		v = vi(n, 0);
		ans = INF;
		rep(i, n) cin>>v[i];
		calc(0, 0, 0);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
#include<stdio.h>
int A,B,C,X[105][105],Y[105][105],i,j,k;
long long t;
int main()
{
    scanf("%d%d%d",&A,&B,&C);
    for(i=0;i<A;i++)
        for(j=0;j<B;j++)
            scanf("%d",&X[i][j]);
    for(i=0;i<B;i++)
        for(j=0;j<C;j++)
            scanf("%d",&Y[i][j]);
    for(i=0;i<A;i++)
    {
        for(j=0;j<C;j++)
        {
            for(k=t=0;k<B;k++)
                t+=X[i][k]*Y[k][j];
            printf("%lld%s",t,j==C-1?"\n":" ");
        }
    }
    return 0;
}


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

public static class Program
{
    public static void Main()
    {
        new Solve().Run();
    }
}

public class Solve
{
    int[] a;
    int[] query;
    int n;

    public void Run()
    {
        Console.ReadLine();
        a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        n = a.Length;
        Console.ReadLine();
        query = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        foreach (var m in query)
        {
            Console.WriteLine(Func2(0, 0, m) ? "yes" : "no");
        }
    }

    public bool Func2(int i, int sum, int m)
    {
        if (i == n)
        {
            return sum == m;
        }
        return Func2(i + 1, sum, m) || Func2(i + 1, sum + a[i], m);
    }
}




Measured memory_bytes: 9384
using System;
using System.Linq;
using static System.Console;

namespace B
{
  class Program
  {
    static void Main(string[] args)
    {
      int N = int.Parse(ReadLine());
      string A = ReadLine();
      string B = ReadLine();
      string C = ReadLine();

      bool[,] table = new bool[3,N];

      for(int i = 0; i<N; i++) {
        table[0,i] = A[i] == B[i];
        table[1,i] = B[i] == C[i];
        table[2,i] = C[i] == A[i];
      }

      int[] count = new int[N];
      for(int i = 0; i<N; i++)
        for(int j = 0; j<3; j++)
          if(!table[j, i])
            count[i]++;
      for(int i = 0; i<N; i++)
        count[i] = count[i] == 0 ? 0 : count[i]-1;
      WriteLine(count.Sum());
    }
  }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int N=0;cin>>N;
    for(long long int i=N;i>0;i--){
        int s=sqrt(i);
        if(s*s==i){
            cout<<i;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		int n = sc.nextInt();

		long f = 0;
		for ( int i=1; i<=n; i++ ) {
		for ( int j=1; j<=n; j++ ) {
		for ( int k=1; k<=n; k++ ) {
			int g = gcd3(i, j, k);
			f = f + g;
		}
		}
		}
		System.out.println(f);
	}

	private static int gcd3(int a, int b, int c) {
		if ( a==1 || b==1 || c==1 ) return 1;
		int g1 = gcd2(a, b);

		if ( g1==1 ) return 1;
		int g2 = gcd2(g1, c);
		return g2;
	}
	private static int gcd2(int a, int b) {
		while ( b>0 ) {
			int r = a%b;
			a = b;
			b = r;
		}
		return a;
	}

}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 100000000000000;
    ll x,y;

    ll d = sqrt(n);
    for(ll i = 1; i <= d; ++i) {
        if(n%i != 0)continue;
        ans = min(ans,i + (n)/i -2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_N 100

int n, i, t1, t2, s1, s2, r[MAX_N], rc[MAX_N], j;

int sort(const void *a, const void *b){
  return *(int*)b - *(int*)a;
}

int main(){
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    r[i] = 0;
    rc[i] = 0;
  }
  for(i = 0; i < n * (n - 1) / 2; i++){
    scanf("%d %d %d %d", &t1, &t2, &s1, &s2);
    if(s1 == s2){
      r[t1 - 1]++;
      rc[t1 - 1]++;
      r[t2 - 1]++;
      rc[t2 - 1]++;
    }
    if(s1 > s2){
      r[t1 - 1] += 3;
      rc[t1 - 1] += 3;
    }
    if(s1 < s2){
      r[t2 - 1] += 3;
      rc[t2 - 1] += 3;
    }
  } 
  qsort(rc, n, sizeof(int), sort);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(r[i] == rc[j]){
	printf("%d\n", j + 1);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX_N 1005
#define MAX_M 100

int N;
int B[MAX_N];

int main()
{
    int A[5];
    rep(i, 5) cin >> A[i];
    int tmp = 10;
    int j;
    rep(i, 5)
    {
        if (A[i] % 10 != 0 && A[i] % 10 < tmp)
        {
            tmp = A[i] % 10;
            j = i;
        }
    }
    if (tmp == 10)
    {
        cout << A[0] + A[1] + A[2] + A[3] + A[4] << endl;
    }
    else
    {
        int ans = A[j];
        rep(i, 5)
        {
            if (i == j)
                continue;
            ans += ((A[i] + 9) / 10) * 10;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n[3] = {};
    cin >> n[0] >> n[1] >> n[2];

    int cnt = 0;
    while (true) {
        if (n[0] == n[1] && n[1] == n[2]) {
            cout << cnt << endl;
            break;
        }
        sort(n, n+3);
        if (n[0] + 2 <= n[2]) {
            n[0] += 2;
            ++cnt;
        } else {
            ++n[0];
            ++n[1];
            ++cnt;
        }
    }
}

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

using namespace std;

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

int N, K;
vector<ll> A;

void solve(){
    ll m = 1e16;
    ll height = A[0];
  
    for (int b = 0; b < (1 << N); b++)
    {
        height = A[0];
        ll cost = 0;
        bitset<20> bs(b);
        int cnt = 0;
        vector<int> v;

        if(__builtin_popcount(b) < K) continue;

      
        for (int i = 1; i < N; i++){
            if(bs.test(i)){
                cost += max(height - A[i] + 1, (ll)0);
                height = max(height + 1, A[i]);
                
            }
            else{
                height = max(height, A[i]);
            }

            
        }
        m = min(m, cost);
    }
    
    cout << m << endl;
}


int main(){
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    
    solve();

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  int ans = INT_MAX;
  cin >> n;

  vector<int> w(n);
  vector<int> left(n);
  vector<int> right(n);

  for(int i=0; i<n; i++) {
    cin >> w[i];
    left[i] = (i==0? w[i] : left[i-1]+w[i]);
  }

  for(int i=0; i<n; i++) {
    right[n-i-1] = (i==0? w[n-i-1] : right[n-i]+w[n-i-1]);
  }

  for(int i=0; i<n-1; i++) {
    ans = min(ans, abs(left[i]-right[i+1]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 888
import bisect
from collections import deque

n = int(input())
la = [int(input()) for _ in range(n)]
result = deque([])

for a in la:
    idx = bisect.bisect_left(result, a)
    if idx==0:
        result.appendleft(a)
    else:
        result[idx - 1] = a
print(len(result))

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

int main(){
  double N,A,B,C,D,E;
  cin >>N>>A >>B >>C >>D >>E;
  double bottle=min(min(min(min(A,B),C),D),E);
  //cout<<N<<" "<<bottle<<endl;
  cout<<setprecision(18)<<ceil(N/bottle)+4<<endl;
  return 0;
}

 

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

map<int, map<int, int>> mp;
map<int, map<int, set<int>>> armp;

int parent(int x, int c) {
	if (mp[c][x] == 0) {
		armp[c][x].insert(x);
		mp[c][x] = x;
		return x;
	}
	if (mp[c][x] == x) return x;
	int pi = parent(mp[c][x], c);
	set<int> my = armp[c][x];
	armp[c][pi].insert(my.begin(), my.end());
	armp[c][x].clear();
	return mp[c][x] = pi;
}
void unite(int p, int q, int c) {
	int pp = parent(p, c);
	int qp = parent(q, c);

	if (pp < qp) {
		mp[c][qp] = pp;
		armp[c][pp].insert(armp[c][qp].begin(), armp[c][qp].end());
		armp[c][qp].clear();
	}
	else if (pp > qp) {
		mp[c][pp] = qp;
		armp[c][qp].insert(armp[c][pp].begin(), armp[c][pp].end());
		armp[c][pp].clear();
	}
}
void solv() {

	ll n;
	cin >> n;
	ll a[100010];
	ll sum = 0;
	ll one = (n * (n + 1)) / 2;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if (sum % one != 0) {
		cout << "NO" << endl;
		return;
	}
	ll b = sum / one;
	ll bs = 0;
	for (int i = 0; i < n; i++)
	{
		int nex = (i + 1) % n;
		ll f = a[i];
		ll t = a[nex];
		if ((t - b - f) % n != 0) {
			cout << "NO" << endl;
			return;
		}
		if ((t - b - f) > 0) {
			cout << "NO" << endl;
			return;
		}
		bs += (t - b - f) / (-n);
	}

	if (bs == b) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

}




int main() {
	solv();

	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 061_abc_c / Link: https://abc061.contest.atcoder.jp/tasks/abc061_c?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,K;

LL ans = 0LL;

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

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> N >> K;
	vector<PII>v;
	FOR(i, 0, N) {
		int a, b; cin >> a >> b;
		v.push_back(PII(a, b));
	}
	SORT(v);
	LL cnt = 0;
	FOR(i, 0, SZ(v)) {
		PII a = v[i];

		cnt += a.second;
		if (cnt >= K) {
			ans = a.first;
			break;
		}
	}
	cout << ans << "\n";

	return 0;
}


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

namespace ABC042_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = scan();
            Array.Sort(a);
            if (a[0] == 5 & a[1] == 5 & a[2]==7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
        static int[] scan()
        {
            return Array.ConvertAll
                (Console.ReadLine().Split(' '), int.Parse);
        }
    }
}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    string S;
    cin >> S;
    int price = 700;
    if(S[0] == 'o'){price += 100;}
    if(S[1] == 'o'){price += 100;}
    if(S[2] == 'o'){price += 100;}
    cout << price << endl;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    cout<<pow(N,3)<<endl;
    return 0;
}


Measured memory_bytes: 3840
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def yn(f) return (f)? "Yes": "No" end
def ynb(f) return (f)? "YES": "NO" end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
a,b,c = inp
p [b/a,c].min

Measured memory_bytes: 1788
#include <stdio.h>

	int cnt = 0;
void insertionSort(int A[],int n, int g){
	
	int v, j;
	for(int i = g ; i < n ;i++){
		v = A[i];
		j = i-g;
		while( j >= 0 && A[j] > v)
		{
		A[j + g] = A[j];
			j = j-g;
			cnt++;
		}
		
		A[j+g] = v;
		
	}

}
void shellSort(int A[],int n){
	

	//int m = (n-1)/3 + 1;
	int G[100];
	int a = 1;
	G[0] = 1;
	int i = 0;
	
	for( ;G[i] <= n;i++){
		
		G[i+1] = 3*G[i]+1; 
		
	}
	int m = i;
	
	
	for(i = m-1;i >= 0 ; i--){
		insertionSort(A,n,G[i]);
	}
	
	
	printf("%d\n",m);
	for(i = m-1;i >= 0;i--){
	printf("%d ",G[i]);
	}
	
	printf("\n");
	printf("%d\n", cnt);
	
	
	for(i = 0;i < n; i++){
	printf("%d",A[i]);
		if(i != n-1)printf("\n");
	}
	
}


int main(void){
	
	int n;
	scanf("%d",&n);
	int number[n];


	for(int i = 0;i < n;i++)
	{
		scanf("%d",&number[i]);
	}
	
	shellSort(number,n);
	
	return 0;

}


Measured memory_bytes: 5672
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
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; }

//https://qiita.com/drken/items/68b8503ad4ffb469624c
//https://qiita.com/drken/items/ace3142967c4f01d42e9
//https://atcoder.jp/contests/dp/tasks/dp_d

ll dp[100001];	//重さwで最大の価値
int main()
{
	int N, W; cin >> N >> W;
	vector<int> vs(N), ws(N);
	rep(i, N) cin >> ws[i] >> vs[i];

	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < N; ++i) {
		for (int w = W; w >= 0; --w) {
			if (w >= ws[i]) {
				chmax(dp[w], dp[w - ws[i]] + vs[i]);
			}
		}
	}
	cout << dp[W] << endl;
}


Measured memory_bytes: 3980
NN = 202020
MOD = 10**9+7
INF = float("inf")

n, a, b = map(int, input().split())

# f = [0]*NN
# rf = [0]*NN
# inv = [0]*NN
f = [1, 1]
rf = [1, 1]
inv = [0, 1]

for i in range(2, NN):
    f.append((f[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    rf.append((rf[-1] * inv[-1]) % MOD)


def C(n, r):
    return (f[n] * rf[r] * rf[n-r]) % MOD


ac = bc = 0
tmp = 1
for i in range(1, max(a, b)+1):
    tmp = (tmp*(n-i+1)*inv[i])%MOD
    # tmp = tmp * (n - i + 1) // i
    # print(rf[i], inv[i], tmp)
    if i == a:
        ac = tmp
    if i == b:
        bc = tmp

# print(ac, bc)

sisu = 1
x = 2
while n:
    if n&1:
        sisu = sisu*x%MOD
    x = x*x%MOD
    n = n>>1
    # print(n, x, sisu)

ans = (sisu-1-ac-bc)%MOD

print(ans)


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

int main()
{
    int N,K,C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    bool b[N];
    rep(i,N+1) b[i] = false;
    int i = 0;
    int j = 0;
    vector<int> v;
    vector<int> r;
    while(j <= K and i < N){
        if (S[i] == 'o'){
            //cout << i+1 << " ";
            v.push_back(i+1);
            //b[i+1] = true;
            i+=C+1;
            j++;
        }
        else{
            i++;
        }
    }
    reverse(S.begin(), S.end());
    //cout << endl;
    i = 0; j = 0;
    stack<int> ans;
    while(j < K and i < N){
        if (S[i] == 'o'){
            //cout << N - i << " ";
            //if (b[N- i]) ans.push(N- i);
            r.push_back(N-i);
            i+=C+1;
            j++;
        }
        else{
            i++;
        }
    }
    reverse(r.begin(), r.end());
    int xxx = v.size();
    int yyy = r.size();
    rep(z,min(xxx,yyy)){
        if (v[z] == r[z]){
            cout << v[z] << endl;
        }
    }
//    while(!ans.empty()){
//        cout << ans.top() << endl;
//        ans.pop();
//    }
    //cout << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int S, W;
	cin >> S >> W;
	if (S <= W)
		cout << "unsafe" << '\n';
	else
		cout << "safe" << '\n';
	return 0;
}


Measured memory_bytes: 3668
import java.util.*;class Main{public static void main(String[]r){for(Scanner s = new Scanner(System.in);s.hasNext();){int i,x,y,b;List<Integer>a=new ArrayList<Integer>();for(i=4;i-->0;)a.add(s.nextInt());for(i=x=y=0;i<4;i++)if(a.get(i)==(b=s.nextInt()))++x;else if(a.contains(b))++y;System.out.println(x+" "+y);}}}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static class Pair implements Comparable<Pair> {
		long num, count;
		
		public Pair(long num, long count){
			this.num = num;
			this.count = count;
		}
		
		public int compareTo(Pair p){
			return Long.compare(this.num, p.num);
		}
	}
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final long K = sc.nextLong();
			
			Pair[] pairs = new Pair[N];
			for(int i = 0; i < N; i++){
				pairs[i] = new Pair(sc.nextLong(), sc.nextLong());
			}
			Arrays.sort(pairs);
			
			long[] num = new long[N + 1];
			long[] sum = new long[N + 1];
			for(int i = 1; i <= N; i++){
				num[i] = pairs[i - 1].num;
				sum[i] = pairs[i - 1].count;
			}
			
			for(int i = 1; i <= N; i++){
				sum[i] += sum[i - 1];
			}
			
			for(int i = 1; i <= N; i++){
				if(sum[i - 1] < K && sum[i] >= K){
					System.out.println(num[i]);
					break;
				}
			}
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

void solve() {

}

int main() {
  ll a,b;
  cin >> a >> b;
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <cstdio>

int N;
int as[200000];
int bs[200000];

int check(int x){
  for(int i=1;i<N;i++){
    if(bs[N-i]==bs[N-i+1]||bs[N+i]==bs[N+i-1]){
      return bs[N-i+1];
    }
  }
  return bs[1];
}

int main(){
  scanf("%d",&N);
  for(int i=1;i<=N*2-1;i++){
    scanf("%d",&as[i]);
  }
  int low=1,high=N*2;
  while(high-low>1){
    int mid=(low+high)/2;
    for(int i=1;i<=N*2-1;i++){
      bs[i]=(as[i]>=mid);
    }
    if(check(mid)){
      low=mid;
    }else{
      high=mid;
    }
  }
  printf("%d\n",low);
  return 0;
}


Measured memory_bytes: 1664
// 0000000000D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000I0000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000M0000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A0000000000000
#include <bits/stdc++.h>
#define ld long double
#define mod 1000000007
#define ll_inf 1000000000000000000
#define int_inf 1000000000
#define pb push_back
#define ll long long int
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define fi first
#define se second
#define prout(x) cout.precision(x)
using namespace std;
int n;
vector<int>v[100010];
int dis[100010][2];
bool vis[100010];
void bfs(int node, int id){
    dis[node][id]=0;
    vis[node]=1;
    queue<int>q;
    q.push(node);
    while(!q.empty()){
        node=q.front(); q.pop();
        int sz=v[node].size();
        for(int i=0;i<sz;i++){
            int nx=v[node][i];
            if(!vis[nx]){
                dis[nx][id]=dis[node][id]+1;
                vis[nx]=1;
                q.push(nx);
            }
        }
    }
}
int main(){
    cin>>n;
    for(int i=1;i<n;i++){
        int x, y;
        scanf("%d%d",&x, &y);
        v[x].pb(y);
        v[y].pb(x);
    }
    bfs(1,0);
    memset(vis,0,sizeof vis);
    bfs(n,1);
    int x=0, y=0;
    for(int i=1;i<=n;i++){
        if(dis[i][0]<=dis[i][1])x++;
        else y++;
    }
    if(x>y)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}
// 0000000000D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000I0000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000M0000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A0000000000000


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

main() {
  int A, B, x, a, b, c, d, e, sum;
  cin >> A >> B;
  for(int i=0; i<(B-A)+1; i++){
    x = A+i;
    a = x%10;
    x /=10;
    b = x%10;
    x /=10;
    c = x%10;
    x /=10;
    d = x%10;
    x /=10;
    e = x%10;
    if(a == e && b == d){
      sum ++;
    }
  }  
  cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, mx, mn = N, say, a[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",a + i);
		mx = max(mx, a[i]);
		mn = min(mn, a[i]);
	}
	if(mx - mn > 1)
		return printf("No\n"),0;

	for(int i = 1; i <= n; i++)
		if(a[i] == mn)
			say++;

	if(mx != mn){
		mn = mx - say;
		n -= say;
		if(mn <= 0)
			puts("No");
		else if(n/mn >= 2)
			puts("Yes");
		else
			puts("No");
		return 0;
	}

	if(n == mn + 1)
		puts("Yes");
	else if(n/mn >= 2)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 640
import math
def main():
    Dog, Mon = map(int, input().split())
    comb = 0

    if Dog > Mon:
        if Dog > Mon + 1:
            pass
        else:
            comb = (math.factorial(Dog) * math.factorial(Mon)) % (10**9+7)

    elif Dog == Mon:
        comb = (math.factorial(Dog) * math.factorial(Mon) * 2) % (10**9+7)
    else:
        if Mon -1 > Dog:
            pass
        else:
            comb = (math.factorial(Dog) * math.factorial(Mon)) % (10**9+7)

    print(comb)

if __name__ == "__main__":
    main()

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

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


Measured memory_bytes: 3088
def main():
	n, k = map(int, input().split())
	h = [0]*n
	diff = [0]*n
	for i in range(n):
		h[i] = int(input())
	h.sort()
	min_diff = 10**9
	for i in range(n-k+1):
		this_diff = h[i+k-1] - h[i]
		if this_diff < min_diff:
			min_diff = this_diff
	print(min_diff)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8240
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX = 10000;

void Main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  rep(i, A) cin >> a[i];
  rep(i, B) cin >> b[i];
  int ma = 1e6, mb = 1e6;
  rep(i, A) ma = min(ma, a[i]);
  rep(i, B) mb = min(mb, b[i]);
  int ans = ma + mb;
  rep(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    ans = min(ans, a[x]+b[y]-c);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	char S[7];
	scanf("%s",S);
	if(S[2]==S[3]){
		if(S[4]==S[5]){
		printf("Yes\n");
		}
		else {
		printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1636
import numpy as np
N = int(input()) 
line = input().split()
l = [int(s) for s in line]

ary = np.array(l)
count = 0

while  not sum(ary) == 0 :
    
    aa = ary % 2
    
    if not sum(aa) == 0:
        break
    
    ary = ary / 2
    
    count += 1

print(count)

Measured memory_bytes: 12464