akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
P = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(N)
for x,y in src:
    x,y = x-1,y-1
    if uf.is_same(x,y): continue
    uf.unite(x,y)

bags = [set() for i in range(N)]
for i in range(N):
    r = uf.root(i)
    bags[r].add(i)

ans = 0
for i in range(N):
    for j in bags[i]:
        if P[j]-1 in bags[i]:
            ans += 1
print(ans)

Measured memory_bytes: 55060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

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

Measured memory_bytes: 256
while n = gets.to_i
  break if n.zero?

  a = []
  n.times do
    a << gets.to_i
  end
  count = 0

  (n-2).downto(0) do |i|
    0.upto(i) do |j|
      if a[j+1] < a[j]
        a[j], a[j+1] = a[j+1], a[j]
        count += 1
      end
    end
  end

  puts count
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if((d+s-1)/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	while(1){
	    sort(a,a+3);
	    a[2]=a[2]-a[0];
	    a[1]=a[1]-a[0];
	    a[0]=0;
	    if(a[0]==0&&a[1]==0&&a[2]==0){
	        cout<<ans<<endl;
	        return 0;
	    }
	    if(a[0]==0&&a[1]==2&&a[2]==2){
	        cout<<ans+1<<endl;
	        return 0;
	    }
	    if(a[0]==0&&a[1]==0&&a[2]==1){
	        cout<<ans+1<<endl;
	        return 0;
	    }
	    a[0]+=2;
	    ans++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    bool a[26];
    memset(a,0,sizeof(a));
    string s;
    cin >> s;
    int n = s.length();
    for(int i=0;i<n;i++){
    	a[s[i] - 'a'] = true;
    }
    for(int i=0;i<26;i++){
    	if(!a[i]) {
    		cout << char(i + 'a') << endl;
    		return 0;
    	}
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
// In God We Trust


# include <bits/stdc++.h>

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
#include <algorithm>


using namespace std;




signed main()
{
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
    
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
int main(void){
	int n,m;

	while(1){
		cin>>n>>m;
		int maxi=0;
		vector<int> a(n);
		if(n==0&&m==0){
			break;
		}
		FOR(i,0,n-1){
			cin>>a[i];
		}
		FOR(i,0,n-1){
			FOR(j,i+1,n-1){
				if(a[i]+a[j]<=m){
					maxi=max(maxi,a[i]+a[j]);
				}
			}
		}
		if(maxi==0){
			cout<<"NONE"<<endl;
		}else{
			cout<<maxi<<endl;
		}
		

	}

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
    int64_t n,h,w;
    cin>>n>>h>>w;

    int cnt=0;
    for(int i=0;i<n;i++){
        int64_t a,b;
        cin>>a>>b;

        if(a>=h&&b>=w)
            cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}  

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

int main() {
    ll n;
    cin >> n;
//    ifstream myfile("C:\\Users\\riku\\Downloads\\subtask_1_30.txt");
//    myfile >> n;

    vector<ll> numbers(n);
    rep(i, n) {
        cin >> numbers[i];
//        myfile >> numbers[i];
    }

    ll ans = 0;

    ll sums = 0;
    ll xors = 0;

    queue<ll> waiting;
    queue<ll> use;
    for (int i = 0; i < n; i++) {
        waiting.push(numbers[i]);
    }

    while (!waiting.empty()) {
        ll wf = waiting.front();
        ll n_sum = sums + wf;
        ll n_xor = xors ^wf;

        if (n_sum == n_xor) {
            sums = n_sum;
            xors = n_xor;
            waiting.pop();
            use.push(wf);
            ans += use.size();
        } else {
            ll uf = use.front();
            sums -= uf;
            xors = sums;
            use.pop();
        }

    }

    cout << ans << endl;

}

Measured memory_bytes: 3584
n, k = map(int, input().split())
l = list(map(int, input().split()))

use_d = []
for i in range(10):
  if i not in l:
    use_d.append(i)

use_d.sort()

m = str(n)

ds = []

import itertools
for i in itertools.product(use_d, repeat=len(m)):
  d = int("".join(str(x) for x in i))
  ds.append(d)
ds.sort()

import bisect
x = bisect.bisect_left(ds, n)
if x != len(ds):
  ans = ds[x]
else:
  ans = ''
  for i in range(len(m)+1):
    if i == 0:
      if use_d[0] == 0:
        ans += str(use_d[1])
      else:
        ans += str(use_d[0])
    else:
      ans += str(use_d[0])
  ans  = int(ans)
print(ans)  


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

using namespace std;
typedef complex<double> P;
typedef vector<P> Polygon;

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

#define prev(G, i) ( G[(i-1 + G.size()) % G.size()] )
#define curr(G, i) ( G[i] )
#define next(G, i) ( G[(i+1) % G.size()] )

double dot(P const& a, P const& b) {return real(conj(a)*b);}
double cross(P const& a, P const& b) {return imag(conj(a)*b);}

enum { counter_clock_wise, clockwise, cab_online, abc_online };
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return counter_clock_wise;
  if(cross(b, c) < 0) return clockwise;
  if(dot(b, c) < 0) return cab_online;
  if(norm(b) < norm(c)) return abc_online;
  return 0;
}

bool is_convex(Polygon const& G) {
  for(int i=0; i<(int)G.size(); i++)
    if( ccw(prev(G, i), curr(G, i), next(G, i)) == clockwise )
      { return false; }
  return true;
}

int main() {
  
  int N; cin >> N;
  Polygon G(N);
  rep(i, N) cin >> G[i].real() >> G[i].imag();
  cout << is_convex(G) << endl;
  
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e5+10;
ll n,m,f1[MAXN],f2[MAXN],up[MAXN];
vector <ll> pre[MAXN],suf[MAXN],node[MAXN];
void dfs_dp_init(int now,int fa)
{
	f1[now]=1;
	for(int i=0;i<node[now].size();i++)
	{
		ll to=node[now][i];
		if(to==fa)
			continue;
		dfs_dp_init(to,now);
		f1[now]=(f1[now]*(f1[to]+1))%m;
	}
	ll sum=1;
	for(int i=0;i<node[now].size();i++)
	{
		ll to=node[now][i];
		if(to!=fa)
			sum=(sum*(f1[to]+1))%m;
		pre[now].push_back(sum);
	}
	sum=1;
	for(int i=node[now].size()-1;i>=0;i--)
	{
		ll to=node[now][i];
		if(to!=fa)
			sum=(sum*(f1[to]+1))%m;
		suf[now].push_back(sum);
	}
}
void dfs_dp(int now,int fa)
{
	for(int i=0;i<node[now].size();i++)
	{
		ll to=node[now][i];
		if(to==fa)
			continue;
		f2[to]=f1[to],up[to]=up[now]+1;
		if(i)
			up[to]=(up[to]*pre[now][i-1])%m;
		if(i!=node[now].size()-1)
			up[to]=(up[to]*suf[now][node[now].size()-i-2])%m;
		dfs_dp(to,now);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		node[u].push_back(v);
		node[v].push_back(u);
	}
	dfs_dp_init(1,1);
	f2[1]=f1[1];
	dfs_dp(1,1);
	for(int i=1;i<=n;i++)
		printf("%lld\n",(f2[i]*(up[i]+1))%m);
	return 0; 
} 

Measured memory_bytes: 30640
/*

*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
//typedef pair <long long, long long> pll;
//typedef pair <int, long long> pil;
//typedef pair <int, string> pis;
//typedef pair <int, char> pic;
//typedef pair <long long, int> pli;
//typedef pair <long long, string> pls;
//typedef pair <long long, char> plc;
//typedef pair <string, int> psi;
//typedef pair <string, long long> psl;
//typedef pair <string, char> psc;
//typedef pair <char, int> pci;
//typedef pair <char, long long> pcl;
//typedef pair <char, string> pcs;

int n, a[200005];

int main () {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int c = 1, s = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] == c) {
			c++;
			continue;
		}
		s++;
	}
	if (s == n) {
		cout << -1;
		return 0;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 2e5+100;
using namespace std;
typedef long long ll;
vector <ll> q;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin>>x;
    for(ll i=1;i*i<=x;i++){
    	if(x%i==0)
    	q.push_back(i);
	}
	ll b;
	for(ll i=0;i<q.size();i++){
		for(ll a=1000;a>=0;a--){
			b=a-q[i];
			if(x==pow(a,5)-pow(b,5)){
				cout<<a<<" "<<b;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4096
#!/usr/bin/perl

my @a = ();
for(my $i=0;$i<3;$i++){
  my @b = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));
  push(@a,\@b);
}

my ($n) = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));
for(my $i=0;$i<$n;$i++){
  my ($b) = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));
  for(my $j=0;$j<3;$j++){
    for(my $k=0;$k<3;$k++){
      if( $a[$j]->[$k] == $b ){
        $a[$j]->[$k] = -1;
      }
    }
  }
}

my @r = (0,0,0);
my @c = (0,0,0);
for(my $j=0;$j<3;$j++){
  for(my $k=0;$k<3;$k++){
    $r[$j] += $a[$j]->[$k];
    $c[$k] += $a[$j]->[$k];
  }
}

if( $r[0]==-3 or $r[1]==-3 or $r[2]==-3 or $c[0]==-3 or $c[1]==-3 or $c[2]==-3 or 
    ($a[0]->[0] == -1 and $a[1]->[1] == -1 and $a[2]->[2] == -1 ) or 
    ($a[2]->[0] == -1 and $a[1]->[1] == -1 and $a[0]->[2] == -1 ) ){
  print "Yes\n";
} else {
  print "No\n";
}




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

int main(){
  int ans=0;
  int L,R,d;
  cin >> L >> R >> d;
  for(int i=L;i<=R;i++){
    if(i%d==0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

  for (int s=0; s<(1<<n)-1; s++) {
    for (int i=0; i<n; i++) {
      if (__builtin_popcount(s) != i) continue;
      for (int j=0; j<n; j++) {
        if (s>>j&1) continue;
        if (!a[i][j]) continue;
        (dp[s|1<<j][i+1] += dp[s][i]) %= mod;
      }
    }
  }
  cout << dp[(1<<n)-1][n] << endl;

  return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

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

	bool is_pairwise_prime = true;
	set<int> st;
	for (int i=0;i<N;i++) {
		vector<pair<long long, long long>> vec = prime_factorize(A[i]);
		bool break_flag = false;
		for (auto p : vec) {
			if (st.count(p.first)) {
				is_pairwise_prime = false;
				break_flag = true;
				break;
			} else {
				st.insert(p.first);
			}
		}
		if (break_flag) {
			break;
		}
	}

	bool is_setwise_prime = true;
	long long tmp = A[0];
	for (int i=1;i<N;i++) {
		tmp = GCD(tmp, A[i]);
	}
	if (tmp != 1) {
		is_setwise_prime = false;
	}

	if (is_pairwise_prime) {
		cout << "pairwise coprime" << endl;
	} else if (is_setwise_prime) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
}

Measured memory_bytes: 7316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=2e3+5;
int a[maxx][maxx];
int main(){
    ll l,r; cin>>l>>r;
    if(r-l+1>=2019){
        cout<<0<<endl;
    }
    else{
        ll ans=1e9;
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                ans=min(ans,i*j%2019);
            }
        }
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 256
import numpy as np

N,M = map(int,input().split())
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])

AB = np.array(A)

AB = AB[np.argsort(AB[:,0])]

yen = 0
cnt = 0
i = 0
while(1):
    cnt_ = cnt + AB[i,1]
    if(cnt_ >= M):
        yen += (M - cnt)*AB[i,0]
        break
    yen += AB[i,0]*AB[i,1]
    cnt = cnt_
    i += 1


print(yen)

Measured memory_bytes: 34020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int[] ia = readNums();
		int[] ary = new int[n+2];
		for (int i=0; i<n; i++) {
			ary[i+1] = ia[i];
		}
		int ans = 0;
		for (int i=1; i<=n+1; i++) {
			ans += abs(ary[i] - ary[i-1]);
		}
		for (int i=1; i<=n; i++) {
			int ao = abs(ary[i] - ary[i-1]) + abs(ary[i+1] - ary[i]);
			int an = abs(ary[i+1] - ary[i-1]);
			pln(ans - ao + an);
		}
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}
	
	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 41764
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
n=int(input())
A=[(e[0],int(e[2:]),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
print(s(A)+'table')
print("\n".join(f"{a} {b}" for a, b, c in A))


Measured memory_bytes: 26992
"""
[a,b]=list(map(float,input().split()))
import math
a=int(a)
b=int(b*100)
ans=a*b
ans=ans/100
ans=math.floor(ans)
print(ans)
"""
import decimal
[a,b]=list(input().split())
a10=decimal.Decimal(a)
b10=decimal.Decimal(b)
ans=a10*b10
ans=int(ans)
print(ans)


"""
[a,b]=list(input().split())
a=int(a)
b12=list(b.split('.'))
bkai=int(int(b12[0])*100+int(b12[1]))
ans=a*bkai
ans=ans//100
print(ans)
"""

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

int main() {
  long N, M;
  cin >> N >> M;
  long ans;
  ans = min(N, M/2);
  if (M-N*2>0) {
    ans += (M-N*2)/4;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <functional>

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

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	printf("%d\n",n-k+1);
	return 0;
}


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

using namespace std;

typedef long long ll;

int n;
ll a[200000];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a, a + n);

    ll b = a[n / 2];

    ll res = 0;
    for (int i = 0; i < n; ++i) {
        res += abs(a[i] - b);
    }

    cout << res << "\n";
}


Measured memory_bytes: 1792
package main

import (
        "bufio"
        "bytes"
        "fmt"
        "io"
        "os"
        "strconv"
        "strings"
)

func main() {
        fmt.Println(run(os.Stdin))
}

func run(in io.Reader) string {
        sc := bufio.NewScanner(in)

        sc.Scan()
        n, err := strconv.Atoi(sc.Text())
        if err != nil {
                panic(err)
        }

        sc.Scan()
        arrs := strings.Split(sc.Text(), " ")
        arr := make([]int, n)
        for i, v := range arrs {
                if arr[i], err = strconv.Atoi(v); err != nil {
                        panic(err)
                }
        }

        return SelectionSort(n, arr)
}

func SelectionSort(n int, arr []int) string {
        buf := new(bytes.Buffer)

        cnt := 0

        for i := 0; i < n; i++ {
                minIdx := i
                for j := i; j < n; j++ {
                        if arr[j] < arr[minIdx] {
                                minIdx = j
                        }
                }
                if i != minIdx {
                        swap(arr, i, minIdx)
                        cnt++
                }
        }

        for i, v := range arr {
                if i > 0 {
                        fmt.Fprintf(buf, " ")
                }
                fmt.Fprintf(buf, "%d", v)
        }
        fmt.Fprintf(buf, "\n%d", cnt)

        return buf.String()
}

func swap(arr []int, i, j int) {
        arr[i], arr[j] = arr[j], arr[i]
}



Measured memory_bytes: 1144
#include <bits/stdc++.h>
  
using namespace std;                           
 
string s;
int main(){
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s == "SUN"){
			cout << 7;
			return 0;
		}
		if(s == "MON"){
			cout << 6;
			return 0;
		}
		if(s == "TUE"){
			cout << 5;
			return 0;
		}
		if(s == "WED"){
			cout << 4;
			return 0;
		}
		if(s == "THU"){
			cout << 3;
			return 0;
		}
		if(s == "FRI"){
			cout << 2;
			return 0;
		}
		if(s == "SAT"){
			cout << 1;
			return 0;
		}
	}
    return 0;
}


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

int main(void)
{
	long long a,b,v,w,t,A,B;
	scanf("%lld",&a);
	scanf("%lld",&v);
	scanf("%lld",&b);
	scanf("%lld",&w);
	scanf("%lld",&t);
	if(a<b){
		A=a+v*t;
		B=b+w*t;
	}else{
		A=-1*a+v*t;
		B=-1*b+w*t;
	}
	if(A>=B)printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 1736
A,B = map(int,input().split())

def gcd(m,n):
  while m > 0 and n > 0:
    if m >= n:
      m = m - n
    else:
      n = n - m
  if m == 0:
    return n
  else:
    return m

print((A*B)//gcd(A,B))

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N, T;
int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N >> T;
    for (int i = 0; i < N; i++)
        cin >> arr[i];

    ll ans = T;
    for (int i = 0; i < N - 1; i++)
        ans += min (T, arr[i+1] - arr[i]);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
function main(input){
	var nums = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
  
    var count = 0;
  
    while(nums.every((n) => (n %2) === 0)) {
      count ++;
      nums = nums.map((n) => n/2);
    }
    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"2 5
1 WA
1 AC
2 WA
2 AC
2 WA"# => r#"2 2"#,


r#"1 3
1 AC
1 AC
1 AC"# => r#"1 0"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize, m: usize,
        ps: [(usize, String); m],
    }
    let mut tmp = vec![0; n];
    let mut ans = (0, 0);

    for i in 0..m {
        if tmp[ps[i].0 - 1] == -1 {
            continue;
        }

        if ps[i].1 == "WA" {
            tmp[ps[i].0 - 1] += 1;
        } else {
            ans.0 += 1;
            ans.1 += tmp[ps[i].0 - 1];
            tmp[ps[i].0 - 1] = -1;

        }
    }

    format!("{} {}", ans.0, ans.1).to_string()
}

Measured memory_bytes: 10492
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
#define maxn 200005
 typedef long long ll;
ll l,n,T,x[200005];
ll w[200005],t[200005];
ll sum[200005],ans[200005];
ll f(ll x){
  while(x<0)x+=l;
  return x%l;
}
ll calc(int left,int right,int p){
  if(p==1)return sum[right]-sum[left];
  else return (right-left)-(sum[right]-sum[left]);
}
 void solve(){
  ll o=T*2/l;
  ll nt=T*2%l;
  int h=0;
  for(int i=0;i<n;i++){
    if(w[i]==2)continue;
    ll key=i;
    key+=o*(n-sum[n]);
    while(h<n+n&&(w[h]==1||x[h]-x[i]<=nt))h++;
    key+=calc(i,h,2);
    key%=n;
    ans[key]=t[i];
  }
  h=n+n-1;
  for(int i=n+n-1;i>=n;i--){
    if(w[i]==1)continue;
    ll key=i;
    key+= n-(o*(sum[n]) )%n;
    while(h>=0&&(w[h]==2||x[i]-x[h]<=nt))h--;
    key+=(n-calc(h+1,i,1))%n;
    key%=n;
    ans[key]=t[i];
  }
}
 int main(){
  memset(ans,-1,sizeof(ans));
  cin>>n>>l>>T; 
  for(int i=0;i<n;i++){
    cin>>x[i]>>w[i]; 
    if(w[i]==1){
      t[i]=x[i]+T;
    } else{
      t[i]=x[i]-T;
    }
    t[i]=f(t[i]);
  }
  
  for(int i=0;i<n;i++){
    x[i+n]=x[i]+l;
    w[i+n]=w[i];
    t[i+n]=t[i];
  }
  for(int i=1;i<=n*2;i++){
    sum[i]=sum[i-1];
    if(w[i-1]==1)sum[i]++;
  }
  solve();
 for(int i=0;i<n;i++)
    cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve() {

}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/
    ll n;
    cin >> n;
    vll a(n + 1), b(n);
    forn(i, n + 1) cin >> a[i];
    forn(i, n) cin >> b[i];
    ll ans = 0;
    forn(i, n) {
        ans += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        if (b[i] > 0) {
            ans += min(a[i + 1], b[i]);
            a[i + 1] -= min(a[i + 1], b[i]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

vector<ll> ans ;
vector<bool> seen ;
 void dfs(const Graph & G,ll v){
   seen[v]=true ;
   for(auto u: G[v] ){
   if(seen[u]) continue ;
   ans[u]+=ans[v] ;
   dfs(G,u) ;
 }
}
int main(){
ll n ,k ;cin>>n>>k ;
 if(2*k-1>n) cout<<-1<<endl ;
  else{
    if(n%2==0){
      ll m= n/2 ;
      rep(i,m){
        cout<<k+2*i<<" "<<k+3*m-1-i<<" "<<k+4*m+i<<endl ;
      }
      rep(i,m){
        cout<<k+1+2*i<<" "<<k+4*m-1-i<<" "<<k+5*m+i<<endl ;
      }
      }
    else{
      ll m= n/2 ;
      rep(i,m+1){
        cout<<k+2*i<<" "<<k+3*m+1-i<<" "<<k+2*n+i<<endl ;
      }
      rep(i,m){
        cout<<k+1+2*i<<" "<<k+2*n-1-i<<" "<<k+2*n+m+1+i<<endl ;
      }
    }
  }
 return 0;
  }

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		double [] pp = new double[t];
		for(int i=0;i<t;i++) {
			pp[i] = 0;
		}
		double PP = 0;
		for(int i=0;i<t;i++) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			for(int j=0;j<m;j++) {
				int v = sc.nextInt();
				double r = sc.nextDouble();
				pp[i] += v*r;
				PP += r;
			}
			pp[i] /= PP;
			PP = 0;
		}
		double pph = 0;
		double R = 0;
		int p = sc.nextInt();
		int q = sc.nextInt();
		for(int i=0;i<q;i++) {
			int v = sc.nextInt();
			double r = sc.nextDouble();
			pph += v*r;
			R += r;
		}
		pph /= R;
		/*for(int i=0;i<t;i++) {
			System.err.print(pp[i]+" ");
		}
		System.err.println(pph);*/
		
		for(int i=0;i<t;i++) {
			if(pp[i]-pph > 0.0000001) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 41172
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    int k;
    cin>>k;
    int a[] = {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 ans = a[k-1];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
z[75][75];s,d,t,a,*p,j;main(i){for(;scanf("%d%d",&s,&d)*s;printf("%d\n",s)){for(memset(z,t=60,2e4);s--;)for(j=i=d+1;--i;a?*p=fmin(*p,a),*z[t]>*p?t=i:0:0)scanf("%d",&a),p=z[i];for(;--j;)for(s=j;--s;a?z[s][j]=z[j][s]=a:0)scanf("%d",&a);for(s=i=0;i++-d;t=a)for(s+=*z[t],*z[t]=0,a=j=d+1;--j;*p&&*z[a]>*p?a=j:0)p=z[j],*p=fmin(*p,p[t]);}}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<sstream>
#include<algorithm>
using namespace std;

int stoi(string s){
  stringstream ss(s);
  int res; ss >> res;
  return res;
}

int main(){
  string s;
  while(cin >> s,s!="0000"){
    bool f = true;
    for(int i=0;i<3;i++)f &= (s[i]==s[i+1]);
    if(f){ cout << "NA\n"; continue; }

    int cnt = 0;
    while(s!="6174"){
      sort(s.begin(),s.end());
      int S = stoi(s);
      reverse(s.begin(),s.end());
      int L = stoi(s);
      char N[5]; sprintf(N,"%04d",L-S);
      for(int i=0;i<4;i++)s[i] = N[i];
      cnt++;
    }
    cout << cnt << endl;
  }
}
      

Measured memory_bytes: 1284
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

ll gcd(ll a, ll b)
{
    return (b==0)?a:gcd(b,a%b);
}

int n;
ll s=0;
int main()
{
    cin>>n;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=n; ++j)
            for (int k=1; k<=n; ++k)
                s += gcd(i,gcd(j,k));
    cout<<s<<endl;
    return 0;
}



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

#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
}

typedef long long ll;

const int N = 50 + 2;
int n, s, a[N], mx; ll dp[N][N][N * N];

int main() {

	n = read(), s = read();
	For(i, 1, n) mx += a[i] = read();

	dp[0][0][0] = 1;
	For(i, 1, n) For(j, 0, i) For(k, 0, mx) {
		if (j && k >= a[i]) dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];	
		dp[i][j][k] += dp[i - 1][j][k];
	}

	ll ans = 0;
	For(i, 1, n) ans += dp[n][i][i * s];

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 54272
import java.util.*;
import java.io.*;


class Main {
    private static long base = 9973l;
    private static long mod  = 67280421310721l;

    public static long calc(String s) {
	long hash = 0;
	for(int i=0;i<s.length();++i) {
	    int c = s.charAt(i);
	    hash = ( hash * base ) % mod;
	    hash = hash + c;
	    hash = hash % mod;
	}
	return hash;
    }
    
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(br.readLine());
	HashSet<Long> S = new HashSet<Long>();
	for(int i=0;i<n;++i) {
	    String[] s = br.readLine().split(" ");
	    long hash = calc(s[1]);
	    if( s[0].equals("insert") ) {
		S.add(hash);
	    } else {
		if( S.contains(hash) ) {
		    System.out.println("yes");
		} else {
		    System.out.println("no");
		}
	    }
	}
    }
}
    



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

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

int main() {
    cin >> n >> m;
    n %= 500;
    if (m >= n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

int main(){
    int n;
    cin>>n;
    UnionFind uf(202020);
    rep(i,n){
        int x,y;
        cin>>x>>y;
        uf.unite(x,y+101010);
    }
    vector<ll> a(202020),b(202020);
    rep(i,101010){
        a[uf.find(i)]++;
        b[uf.find(i+101010)]++;
    }
    ll ans = 0;
    rep(i,202020)ans += a[i]*b[i];
    cout<<ans-n<<endl;
    return 0;
}

Measured memory_bytes: 4224
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

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

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

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

#define P pair<int,int>
#define V vector<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);
    int sum=0;
    REP(i,n+1)sum+=i;
    COUT(sum);
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: 美しい文字列 / Beautiful Strings
 */

#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 */

/* typedef */

/* global variables */

int cs[26];

/* subroutines */

/* main */

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

  for (int i = 0; i < w.size(); i++) cs[w[i] - 'a']++;

  bool ok = true;
  for (int i = 0; ok && i < 26; i++)
    if (cs[i] & 1) ok = false;

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Test int T;cin>>T;while(T--)
#define ls lower_bound
#define up upper_bound
#define bs binary_search
#define S second
#define F first
#define vi vector<int>  
#define pii pair<int,int>
#define vpi vector<pii>
#define vvi vector<vi>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define m_n(v) *min_element(all(v))
#define m_x(v) *max_element(all(v))
#define ___(a) for(auto &i:a) cin>>i
/* 
#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
*/
int power(int x, int y,int mod){
    int res = 1;
    while (y)
    {
        if (y & 1)
        res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int modInverse(int a, int m){
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int binomial(int n,int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/*
vector<int> prime;
void sieve(){
    bool arr[300000]={0};
    prime.pb(2);
    for(int i=3;i<300000;i+=2){
        if(arr[i])continue;
        for(int j=i*i;j<300000;j+=i) arr[j]=1;
        prime.pb(i);
    }
}*/
//const int N=1e18+2;
const int mod = 1e9+7;
const int N= 1e5+9;

int32_t main() {
    IOS;
    int n,m,k;
    cin>>n>>m>>k;
    vi a(n+1,0),b(m+1,0);
    for(int i=1;i<=n;i++) cin>>a[i],a[i] += a[i-1];
    for(int i=1;i<=m;i++) cin>>b[i],b[i] += b[i-1];
    int ans = 0;
    for(int i=0;i<=n;i++){
        int want = k - a[i];
        if(want < 0) break;
        int l = 0,r = m;
        int mid,take = 0;
        while(l<=r){
            mid = (l+r)/2;
            if(b[mid] <= want){
                take = max(take,mid);
                l = mid + 1;
            }
            else r = mid -1;
        }
        ans = max(ans , i+take );
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6344
#include<bits/stdc++.h>
#define p 1000000007
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
inline long long read_l()
{
	long long ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
int n;
long long a[300010];
int b[60][2];
long long ans=0;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read_l();
	for(int i=1;i<=n;i++)
	for(int j=0;j<=59;j++) b[j][(a[i]>>j)&1]++;
	long long x=1;
	for(int i=0;i<=59;i++)
	{
		long long tmp=(long long)b[i][0]*(long long)b[i][1];
		tmp%=p;
		ans+=tmp*x,ans%=p;
		x*=2,x%=p;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
N,T = map(int,input().split())
paths = list()
for i in range(N):
  ci,ti = map(int,input().split())
  paths.append((ci,ti))
paths.sort(key=lambda x: x[0])

flag=False
for path in paths:
  if path[1] <= T:
    print(path[0])
    flag=True
    break
if not flag:
  print('TLE')


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX_A = 5000;
static const int MAX_B = 5000;
 
int A, B;
int numa[MAX_A], numb[MAX_B];
 
int main(){
	cin >> A >> B;
	for(int i = 0; i < A; i++) cin >> numa[i];
	for(int i = 0; i < B; i++) cin >> numb[i];
	int ans = 0;
	for(int i = 0; i < B; i++){
		int cnt = 0;
		for(int j = 0; j < A; j++){
			if(numa[j] == numb[i + cnt]) cnt++;
			if(i + cnt >= B) break;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3144
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }
vector<int> color;
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};

vector<vector<Edge>> G;

void dfs(int v, int pre, int cur) {
    color[v] = cur;
    for(auto next_edge : G[v]) {
        if(next_edge.to == pre) continue;
        if(next_edge.weight & 1) dfs(next_edge.to, v, 1 - cur);
        else dfs(next_edge.to, v, cur);
    }
}

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

    int n; cin >> n;

    G.assign(n, vector<Edge>());
    for(int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    color.assign(n, 0); //色分け配列初期化
    dfs(0, -1, 1);
    for(auto v : color) cout << v << endl;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int x, y;
    cin >> x >> y;
    int min, max;
    min = x*2;
    max = x*4;
    if (y%2 == 0 && y <= max && y >= min){
        cout << "Yes"; 
    }else{
        cout << "No";
    }
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    vi deg ( n + 5 ) ;
    for ( int i = 2 ; i <= n ; i ++ )
    {
        int par ;
        cin >> par ;

        deg[par] ++ ;
    }

    for ( int i = 1 ; i <= n ; i ++ )
        cout << deg[i] , line ;


}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 4052