akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll x = 800 * N;
  ll y = 200 * (N / 15);

  cout << x - y << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
mod = 10**9 + 7
ans = 1
cnt = [0] * N
for a in A:
    if a > 0:
        ans *= (cnt[a - 1] - cnt[a])
    cnt[a] += 1
    ans %= mod
for i in range(cnt[0]):
    ans *= 3 - i
    ans %= mod
print(ans)

Measured memory_bytes: 14092
N, K = map(int, input().split())

# if N == K:
#     print(0)
#     exit(0)
# elif N < K:
#     print(N)
#     exit(0)

ans = []
before = abs(N - K)
N = N % K
for i in range(10000):
    ze = abs(N - K)
    ans.append(ze)
    before = ze
    N = ze
print(min(ans))


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, M, K);

  bool ok = false;
  REP(i, M + 1) {
    REP(j, N + 1) {
      if (N * i + M * j - 2 * i * j == K) {
	// debug(i);
	// debug(j);
	ok = true;
      }
    }
  }

  OK(ok);

  return 0;
}



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

int main() {
        int N, // 駐車時間
            A,
            B;
        int P1;

        cin >> N >> A >> B;

        P1 = A * N;

        if (P1 <= B) {
                cout << P1 << endl;
        } else {
                cout << B << endl;
        }
}


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

int main()
{
    long long N, K;
    cin >> N >> K;
    vector<long long> m(100010, 0LL);
    for (long long i = 0; i < N; i++)
    {
        long long a, b;
        cin >> a >> b;
        m[a] += b;
    }
    for (long long i = 1LL; i <= 100010LL; i++)
    {
        m[i] += m[i - 1LL];
    }
    for (long long i = 0LL; i <= 100009LL; i++)
    {
        if (m[i] < K && K <= m[i + 1LL])
            cout << i + 1LL << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#define _[2<<17]
n,i,flag;A _,B _,T _,F _;long M,D _,P _,R _,R2 _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);for(i=0;i<2<<17;i++)flag+=R[i]!=R2[i];return 0*flag;}
////////////

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

int main(void)
{
    int h, w, d;
    scanf("%d%d%d", &h, &w, &d);

    int a;
    int i, j, k;
    int px[90001], py[90001];
    int de[90001];

    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            scanf("%d", &a);
            px[a] = i;
            py[a] = j; 
        }
    }

    for (i = d + 1; i <= h * w; i++)
        de[i] = de[i - d] + abs(px[i] - px[i - d]) + abs(py[i] - py[i - d]);
    

    int q;
    scanf("%d", &q);
    while (q--) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", de[r] - de[l]);
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>

typedef long long ll;

const int MAX_N = 100010;
const ll MOD = 1000000007;

ll gt[MAX_N], rev[MAX_N];

ll mult(ll a, ll b){
   if(b==0) return 1;
   if(b==1) return a % MOD;
   ll g = mult(a, b/2); 
   if(b%2) return g * g % MOD * a % MOD;
   return g * g % MOD;
}

ll C(ll n, ll k){
   if(k>n || k<0) return 0;
   return gt[n] * rev[n-k] % MOD * rev[k] % MOD;
}

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

   int a;
   ll m;
   std::vector<int> indice(n,-1);
   for(int i=0; i<n+1; ++i){
      std::cin >> a;
      --a;
      if(indice[a]<0) indice[a] = i;
      else {
	 m = indice[a];
	 m += n - i;
      }
   }

   gt[0] = 1;
   rev[0] = mult(gt[0], MOD-2);
   for(int i=1; i<=n+1; ++i){
      gt[i] = gt[i-1] * i % MOD;
      rev[i] = mult(gt[i], MOD-2);
   }


   ll ans;
   for(int i=1; i<=n+1; ++i){
      ans = C(n+1, i) - C(m,i-1) + MOD;
      //std::cout << C(n+1,i) << ' ' << C(m,i-1) << std::endl;
      ans %= MOD;
      std::cout << ans << std::endl;
   }
   return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int A = 26;
Int D = 365;
Int c[26];
Int s[365][26];

int main() {
    Int d;
    cin >> d;
    for (Int i = 0; i < (Int)A; i++) {
        cin >> c[i];
    }
    for (Int i = 0; i < (Int)D; i++) {
        for (Int j = 0; j < (Int)A; j++) {
            cin >> s[i][j];
        }
    }
    srand(time(NULL));
    for (Int i = 0; i < (Int)D; i++) {
        print((rand() % A) + 1);   
    }
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int h[n + 1], sol[n + 1];
    cin >> h[0] >> h[1];
    sol[0] = 0; sol[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i ++) {
        cin >> h[i];
        sol[i] = min(sol[i - 1] + abs(h[i] - h[i - 1]),
                sol[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << sol[n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    int i,h[n];
    int ans=0;
    int cnt=0;
    for (i=0;i<n;i++){
        scanf("%d",&h[i]);
        if(i!=0){
            if(h[i-1]>= h[i]){
                cnt++;
            }else{
                if(ans <cnt){ans=cnt;}
                cnt=0;
            }
            
        }
    }
    if(ans <cnt){ans=cnt;}
   
    

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

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  int Q[N];
  for(int i=0; i<N; i++){
    int p;
    cin >> p;
    Q[p-1] = i;
  }
  int max = 1;
  int tmp = Q[0];
  int n = 1;
  for(int i=1; i<N; i++){
    if(tmp < Q[i]){
      n++;
      tmp = Q[i];
    } else {
      if(max < n)
	max = n;
      tmp = Q[i];
      n = 1;
    }

    if(i == N-1)
      if(max < n)
	max = n;
  }

  cout << N - max << endl;
  return 0;
}


Measured memory_bytes: 1024
(defmacro input []
  (clojure.string/split (read-line) #"\s"))

(defn OTO [[A B]]
  (let [n (-> (str A B) Double/parseDouble Math/sqrt)]
    (if (= n (double (int n)))
      "Yes"
      "No")))

(-> (input)
  OTO
  println)

Measured memory_bytes: 65256
def read_int():
    return int(input().strip())


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


def solve():
    N, x = read_ints()
    A = read_ints()
    answer = 0
    for i in range(1, N):
        if A[i-1]+A[i] > x:
            eat = A[i]+A[i-1]-x
            if eat <= A[i]:
                A[i] -= eat
                answer += eat
            else:
                eat -= A[i]
                answer += A[i]
                A[i] = 0
                A[i-1] -= eat
                answer += eat
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 84460
#include <cstdio>
using namespace std;

int main() {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);// don't forget &
    while (true) {
        c -= b;
        if (c <= 0) {
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0) {
            puts("No");
            return 0;
        }
    }
    
    return 0;
}


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

int main()
{
    ll n, ans = 0;
    cin >> n;
    ll a[n], b[n], c[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];

    rep(i, n)
    {
        ans += b[a[i] - 1];
        if (i == 0)
            continue;
        if (a[i] == a[i - 1] + 1)
            ans += c[a[i - 1] - 1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <string>
using namespace std;

int keta(long long int a)
{
	int i = 0;
	while (a != 0) {
		a /= 10;
		++i;
	}
	return i;
}

int main()
{
	long long int n;
	cin >> n;
	long long int tmp = n;
	n = sqrt(n);
	while (1) {
		if (tmp%n == 0) {
			if (keta(n) > keta(tmp / n))cout << keta(n) << endl;
			else cout << keta(tmp / n) << endl;

			return 0;
		}
		else --n;
	}


	return 0;
}


Measured memory_bytes: 256
import sys 
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

def main():
    s = S()
    print(s[0:3])
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 9504
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int A, P;

int main(){
	cin >> A >> P;
	P += A * 3;
	P /= 2;
	cout << P << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair 
#define pb push_back 
#define fi first
#define se second
#define MOD 1000000007
#define DOMOD(d) if ((d) >= MOD) d %= MOD;
#define DONEGMOD(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
 
#define inp(a) scanf("%d", &a)
#define inp2(a,b) scanf("%d %d", &a, &b)
#define inp3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define inp4(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
 
#define inpl(a) scanf("%lld", &a)
#define inpl2(a,b) scanf("%lld %lld", &a, &b)
#define inpl3(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define inpl4(a,b,c,d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i=a;i<b;i++)
#define mset(a,val) memset(a,val,sizeof(a))
#define printv(v) for (int i=0;i<(int) v.size(); i++) cout<<v[i]<<" " 
#define MAX 100005
using namespace std ;
typedef long long int ll ;
typedef pair<int,int> pii ;
typedef pair<long long , long long > pll ;
typedef pair<int,pii> pipi ;
typedef pair<int,pair<int,string>> piis ;
typedef pair<ll,string> pls ;
typedef pair<ll,pll> plpl ;

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


int main()
{
	#ifdef DIRI
		//freopen("inp.txt","r",stdin) ;
	#endif
	
	time_t start = clock() ;
	
	for (int t=1;t<=1;t++)
	{
		int n ; cin>>n ;
	
	int done = 0, x = n-2 ;
	
	vector<int> v ;
	
	if (n == 3)
	{
		cout<<"2 5 63"<<endl ; return 0 ;
	}
	if (n % 3 == 0)
	{
		x -= 2 ;
	}
	
	int done2, last ;
	int limit = (n & 1) ? 14999 : 15000 ;
	for (int i=1;i<=min(x,limit);i++)
	{
		cout<<2*i<<" " ;
		v.pb(2*i) ;
		done++ ;
	}
	
	//done2 = done ; last = v.back() ;
	for (int i=3;i<=30000;i+=6)
	{
		cout<<i<<" " ;
		v.pb(i) ;
		done++ ;
		if (done == n)
		{
			cout<<endl ; break ;
		}
	}
	int gcdd = v[0], maxi = v[0] ;
	ll sum = (ll) v[0] ;
	for (int i=1;i<n;i++)
	{
		gcdd = gcd(gcdd,v[i]) ;
		maxi = max(maxi,v[i]) ;
		sum += (ll) v[i] ;
 	}
 	
 	if (gcdd == 1 and maxi <= 30000)
	{
		
	}else
	{
		cout<<"Error1 at"<<t<<endl ; return 0 ;
	}
 	
 	for (int i=0;i<n;i++)
 	{
		if (gcd(v[i],sum-v[i]) == 1)
		{
			cout<<"Error at"<<t<<" "<<v[i]<<" "<<sum<<endl ; 
			//cout<<"Done2 "<<done2<<" "<<last<<endl ; return 0 ;
		}
	}
	
	
	}
	
		
	time_t end = clock() ;
	
	double tt = (end - start) / CLOCKS_PER_SEC ;
	cerr<<fixed<<setprecision(5)<<tt<<endl ;
	
    return 0 ;
}


Measured memory_bytes: 512
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String[] S=sc.next().split("");
    	
    	for(int i=0;i<S.length;i++) {
    		
    		if(S[i].equals("C")) {
    			for(int j=i+1;j<S.length;j++) {
    				if(S[j].equals("F")) {
    					System.out.println("Yes");
    					return;
    				}
    			}
    		}
    		
    	}
    	
    	System.out.println("No");
    }
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    ll ans = 0;

    for (int i = 1; i < n; ++i)
    {
        if (i < n)
            ans += a[i / 2];
    }

    cout << ans << endl;
}


Measured memory_bytes: 4012
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
    int n, m;
    cin >> n >> m;
    vector<array<int, 2>> ans;
    if ((n & 1) ^ 1) {
        int a = 1, b = n / 2;
        while (a < b) {
            ans.pb({a, b});
            a++; b--;
        }
        a = n / 2 + 1, b = n - 1;
        while (a < b) {
            ans.pb({a, b});
            a++; b--;
        }
    } else {
        int a = 1, b = n;
        while (a < b) {
            ans.pb({a, b});
            a++; b--;
        }
    }
    for (int i = 0; i < m; i++) {
        cout << ans[i][0] << " " << ans[i][1] << endl;
    }
}
int32_t main() {
    BOLT;
    solve();
}

Measured memory_bytes: 5276
N, M = map(int,input().split())
E = set()
d = [[10**9]*N for k in range(N)]
for k in range(N):
    d[k][k] = 0
for k in range(M):
    a, b, c = map(int,input().split())
    E.add((a-1,b-1,c))
    d[a-1][b-1] = c
    d[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
ans = 0
for e in E:
    if d[e[0]][e[1]] != e[2]:
        ans += 1
print(ans)


Measured memory_bytes: 9432
import java.util.Arrays;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static final Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	public static void main(String __[]){
		int n,min,max;
		while (true) {
			n=s.nextInt();
			if(n==0)return;
			min=s.nextInt();
			max=s.nextInt();
			long[] in=fal_rnd(n);
			Arrays.parallelSort(in);

			long v=-114514,r=-114514;
			for(int i=min;i<=max;i++) {
				if(in[n-i]-in[n-i-1]>=v) {
					v=in[n-i]-in[n-i-1];
					r=i;
				}
			}
			System.out.println(r);
		}
	}
}

Measured memory_bytes: 56264
def c():
    n = int(input())
    a = [int(ai) for ai in input().split()]
    div = {4:0, 2:0, 1:0}
    for i in a:
        if i % 4 == 0:
            div[4] += 1
        elif i % 2 == 0:
            div[2] += 1
        else:
            div[1] += 1
    if div[2] == 0:
        need = -1
    else:
        need = 0
    if div[4] - div[1] >= need:
        print('Yes')
    else:
        print('No')
    # print(div)

c()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll a, b, k; cin >> a >> b >> k;
    ll x = max(a - k, 0LL), y = max(b - max(k - a, 0LL), 0LL);
    cout << x << " " << y << "\n";
}


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

int main() {
  char X,Y;
  cin >> X >> Y;
  if (X > Y) {
    cout << '>' << endl;
  }
  else if (X < Y) {
    cout << '<' << endl;
  }
  else {
    cout <<  '=' << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  int X;
  cin >> X;
  vector<int> P;
  FOR(i,2,100100){
    int flg = 1;
    for(auto x : P){
      if(i % x == 0) {flg = 0; continue;}
      if(x*x>i) continue;
    }
    if(flg) P.push_back(i);
  }
  for(auto x : P){
    if(x>=X) {cout << x; return 0;}
  }
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>
#define SIZE 100005
#define MOD 1000000007

using namespace std;

class CCountOrder {
public:
    static void solve(std::istream& cin, std::ostream& cout) {
        int64_t n;
        cin >> n;
        string tmp, p, q;
        for (int j = 0; j < n; ++j) { cin >> tmp; p += tmp; }
        for (int j = 0; j < n; ++j) { cin >> tmp; q += tmp; }
        string base;
        for (int i = 1; i < n+1; ++i) { base += to_string(i); }
        int index = 0;
        int p_index = 0;
        int q_index = 0;
        while (next_permutation(base.begin(), base.end())){
            index++;
            if (base == p) p_index = index;
            if (base == q) q_index = index;
        }
        cout << abs(p_index - q_index) << endl;
    }
};


int main() {
    CCountOrder solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int a;
		cin >> a;
		n -= a;
	}
	cout << (n < 0 ? -1 : n) << endl;
	return 0;
}

Measured memory_bytes: 3636
//*****************************believer******************************//
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef map<ll,ll> mi;
 
#define f first
#define ss second
#define ins insert
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define pq priority_queue
#define sqr(n) floor(sqrt(n))
#define sz(v) ((ll)(v.size()))
#define trav(a,x) for (auto& a: x)
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define mem(a) memset(a, -1, sizeof (a))
#define ssort(v) sort((v).begin(),(v).end())
#define rsort(v) sort((v).rbegin(),(v).rend())
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define foo(i,a,b) for (ll i = (a); i < (b); ++i)
#define foor(i,a,b) for (ll i = (a); i >= (b); --i)

const ll N=2e5+100;
ll wt[105],val[105];
ll dp[N][105];

ll solve(ll w,ll x)
{
    if(dp[w][x]!=-1)
    return dp[w][x];
    
    if(wt[x]>w)
    return dp[w][x]=solve(w,x-1);
    
    else
    return dp[w][x]=max(solve(w,x-1),solve(w-wt[x],x-1)+val[x]);
}

int main()
{
    ll n,w;
    cin>>n>>w;
    foo(i,1,n+1)
    cin>>wt[i]>>val[i];
    mem(dp);
    
    foo(i,0,N)
    dp[i][0]=0;
    
    foo(i,0,104)
    dp[0][i]=0;
    
    ll ans=solve(w,n);
    cout<<ans<<"\n";
    
    return 0;
}


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

int main()
{
   unsigned long long n,k;
  unsigned long long arr[200005];
  unsigned long long maxm=1;
   unsigned long long cnt =0;

  cin>>n>>k;

  for(int i=0;i<n;i++){
        cin>>arr[i];
        cnt+=arr[i];
  }
  sort(arr,arr+n);

  if (k>=n){
    cout<<0;
  } else if (k==0){
   cout<< cnt;


  }
  else {
  for (int i=n-1;i>=0;i--){
        if (maxm<=k){
        cnt-=arr[i];}
        maxm++;
  }
   cout<<cnt;}

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,tmp;
  cin>>N;
  if(N%111==0){
    tmp=N/111;
  }
  else{
    tmp=N/111+1;
  }
  cout<<111*tmp;
  return 0;
}

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

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   long long int n;
   
   cin>>n;
   
   long long int arr[n+1];
   
   vector<long long int>cnt(n+1);
  
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
       
       cnt[arr[i]]++;
   }
   
  long long int sum=0;
  
   for(int i=1;i<=n;i++)
   {
      sum+=cnt[i]*(cnt[i]-1)/2;   
   }
  
    for(int i=1;i<=n;i++)
    {
       int x = cnt[arr[i]];
      
       cout<<sum - x*(x-1)/2 + (x-1)*(x-2)/2<<endl;
    }
   
   
   return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

void solve(long long N, std::vector<long long> a, std::vector<long long> b,
           std::vector<long long> c) {
  map<ll, vl> edges;
  rep(i, 0, N - 1) {
    edges[a[i] - 1].push_back(b[i] - 1);
    edges[b[i] - 1].push_back(a[i] - 1);
  }

  ll maxCnt = 0;
  ll start = -1;
  itrep(it, edges) {
    if (maxCnt < it->second.size()) {
      maxCnt = it->second.size();
      start = it->first;
    }
  }

  queue<ll> que;
  vector<bool> checked(N);
  que.push(start);
  checked[start] = true;

  vector<ll> ans(N);
  sort(all(c), greater<ll>());
  ll i = 0;
  while (!que.empty()) {
    ll n = que.front();
    que.pop();
    ans[n] = c[i++];

    itrep(it, edges[n]) {
      if (!checked[*it]) {
        que.push(*it);
        checked[*it] = true;
      }
    }
  }

  ll score = 0;
  rep(i, 0, N - 1) { score += min(ans[a[i] - 1], ans[b[i] - 1]); }
  print(score);

  rep(i, 0, N) {
    cout << ans[i];
    if (i != N - 1) {
      cout << " ";
    }
  }
  cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N - 1);
  std::vector<long long> b(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  std::vector<long long> c(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &c[i]);
  }
  solve(N, std::move(a), std::move(b), std::move(c));
  return 0;
}


Measured memory_bytes: 1920
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
int l,r;
int main()
{
	fast;
	cin>>s;
	for (int i=0;i<s.size();i++)
	   if (s[i]=='A')
	   {
	   	  l=i;
	   	  break;
	   }
	for (int i=s.size()-1;i>=0;i--)
	   if (s[i]=='Z')
	   {
	   	   r=i;
	   	   break;
	   }
	cout<<r-l+1<<endl;
    return 0;
}

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

struct edge{
    int a, b;
};

int main(){
    int n, m; cin >> n >> m;
    vector<edge> lis;
    for(int i = 0; i < m; i++){
        int c, d; cin >> c >> d;
        edge e = {c, d};
        lis.push_back(e);
    }
    sort(lis.begin(), lis.end(), [](auto const& x, auto const& y){return x.b < y.b;});
    int ans = 0;
    int bridge = 0;
    for(int i = 0; i < m; i++){
        if(bridge > lis[i].a && bridge <= lis[i].b){
            continue;
        }else{
            ans++;
            bridge = lis[i].b;
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll vec_max(auto & , string);
ll vec_min(auto & , string);

int main(){
  faster();
  int d,g;
  cin >> d >> g;
  vi p(d),c(d);
  rep(i,d) cin >> p[i] >> c[i];
  int ans=0,score=0,tmp=100000;
  for(int i=0;i<(1<<d);i++){
    ans = 0;
    score = 0;
    bitset<10> bits(i);
    rep(j,d){
      if(bits.test(j)){
        ans += p[j];
        score += p[j]*(j+1)*100;
        score += c[j];
      }
    }
    if(score < g){
      for(int k=d-1;k>=0;k--){
          if(!(bits.test(k))){
            rep(i,p[k]){
              ans++;
              score += (k+1)*100;
              if(score >= g) break;
            }
            break;
          }
      }
    }
    if(score >= g) tmp = min(ans , tmp);
  }
  cout << tmp << endl;
}


























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x, auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
ll vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
ll vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n, p; cin >> n >> p;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll c[51][51];
  c[0][0] = 1;
  for(int i = 1; i <= 50; ++i) {
    c[i][0] = c[i][i] = 1;
    for(int j = 1; j < i; ++j) c[i][j] = c[i-1][j]+c[i-1][j-1];
  }
  int even = 0, odd = 0;
  rep(i, n) {
    if(a[i]%2==0) ++even;
    else ++odd;
  }
  ll ans = 0;
  for(int i = p; i <= odd; i+=2) ans += c[odd][i];
  ans *= (ll)pow(2, even);

  cout << ans << endl;
}


Measured memory_bytes: 4080
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int MAX = 1100;

int n, m, a, h, p, q;
vector<pint> line[MAX];

int main() {
    while (true) {
        scanf("%d %d %d", &n, &m, &a);
        if (n == 0) break;
        
        for (int i = 0; i < MAX; ++i) line[i].clear();
        
        for (int i = 0; i < m; ++i) {
            scanf("%d %d %d", &h, &p, &q);
            line[h].PB(MP(p,q));
        }
        for (int i = MAX-1; i >= 0; --i) {
            for (int j = 0; j < line[i].size(); ++j) {
                if (line[i][j].FI == a) {a = line[i][j].SE; break;}
                else if (line[i][j].SE == a) {a = line[i][j].FI; break;}
            }
        }
        cout << a << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1292
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toInt()
        val p = Array(N) { sc.next().toInt() }.sorted()
        pw.println(p.take(K).sum())
    }
}


Measured memory_bytes: 42932
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int count_fox_number(ll a, ll b){
  if(a < 2) a = 2;
  if(!(a < b)) return 0;
  int ans = b - a;
  bool prime_small[1000100];
  for(int i = 2; (ll) i * i < b; i++) prime_small[i] = true;
  int cnt_pow[1000100];
  REP(i, b - a) cnt_pow[i] = INF;
  for(int i = 2; (ll)i * i < b; i++){
    if(prime_small[i]){
      for(int j = 2 * i; (ll) j * j < b; j += i) prime_small[j] = false;
      for(ll j = max(2LL, (a + i - 1)/i) * i; j < b; j += i){
        if(cnt_pow[j - a] == -1) continue;
        ll t = j;
        int cnt = 0;
        while(t % i == 0){
          t /= i;
          cnt++;
        }
        assert(cnt != 0);
        if(cnt_pow[j - a] < cnt){
          cnt_pow[j - a] = -1;
          ans--;
        }else{
          cnt_pow[j - a] = cnt;
        }
      }
    }
  }
  return ans;
}

int main(){
  ll a, b;
  while(cin>>a>>b){
    cout<<count_fox_number(a - b, a + b + 1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 6040
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N = INT()
a = LIST()

a_cnt = Counter(a)
num_1 = a_cnt[1]
num_2 = a_cnt[2]
num_3 = a_cnt[3]

dp = [[[0.0]*(301) for i in range(301)] for j in range(301)]
 
for i in range(1, N+1):
    for j in range(min(i, num_2+num_3)+1):
        for k in range(min(j, num_3)+1):
            s = i-j
            t = j-k
            res = 0
            if s > 0:
                res += dp[s-1][t][k]*s  
            if t > 0:
                res += dp[s+1][t-1][k]*t
            if k > 0:
                res += dp[s][t+1][k-1]*k
            res += N
            res /= (s+t+k)

            dp[s][t][k] = res

print(dp[num_1][num_2][num_3])


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
struct Vector {
  T x, y;
  T Norm() const { return std::sqrt(x * x + y * y); }
  Vector& operator+=(const Vector& v) {
    (*this).x += v.x;
    (*this).y += v.y;
    return *this;
  }
  Vector operator+(const Vector& v) const { return Vector(*this) += v; }
  Vector& operator-=(const Vector& v) {
    (*this).x -= v.x;
    (*this).y -= v.y;
    return *this;
  }
  Vector operator-(const Vector& v) const { return Vector(*this) -= v; }
  Vector& operator*=(T t) {
    (*this).x *= t;
    (*this).y *= t;
    return *this;
  }
  Vector operator*(T t) const { return Vector(*this) *= t; }
  bool operator<(const Vector& v) const {
    if (x != v.x) {
      return x < v.x;
    }
    return y < v.y;
  }
  Vector Rot90() const { return {-y, x}; }
};

int main() {
  in(int, x1, y1, x2, y2);
  Vector<int> v1 = {x1, y1}, v2 = {x2, y2};
  Vector<int> v = v2 - v1;
  Vector<int> v3 = v2 + v.Rot90();
  Vector<int> v4 = v3 + v.Rot90().Rot90();
  out(v3.x, v3.y, v4.x, v4.y);
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int dp[200005][35],t[200005];
P<int,int> a[200005];
bool cmp(P<int,int> x,P<int,int> y){
	RE x.F*(y.S+1)>y.F*(x.S+1);
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	int la,lt;
	la=lt=0;
	P<int,int> in;
	FOR(i,1,n){
		cin>>in.F>>in.S;
		if(in.F){
			a[++la]=in;
		}else t[++lt]=in.S+1;
	}
	sort(t+1,t+lt+1);
	FOR(i,1,lt)t[i]=t[i]+t[i-1];
	FOR(i,0,la)FOR(j,1,30)dp[i][j]=m+1;
	sort(a+1,a+la+1,cmp);
	FOR(i,1,la){
		FOR(j,1,30){
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+1+(dp[i-1][j-1]+1)*a[i].F+a[i].S);
		}
	}
	int ans=0,ind;
	FOR(i,0,30){
		if(dp[la][i]>m)continue;
		ind=upb(t+1,t+lt+1,m-dp[la][i])-t;
		gmax(ans,i+ind-1);
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 59648
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll
#define F first
#define S second

const int MOD = 1e9 + 7;
void add(int &a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

int mult(int a, int b) {
	return (a * 1ll * b) % MOD;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

const int N = 410;
int vl[N][N], pref[N][N], dp[N][N], l[N], r[N];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
	int n, c;
	cin >> n >> c;
	for (int x = 1; x <= 400; x++) {
		vl[x][0] = 1;
		for (int a = 1; a <= c; a++) {
			vl[x][a] = mult(vl[x][a - 1], x);
		}
	}
	for (int a = 0; a <= c; a++) {
		for (int x = 1; x <= 400; x++) {
			pref[a][x] = (pref[a][x - 1] + vl[x][a]) % MOD;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> r[i];
	}
	for (int i = 0; i < n; i++) {
		for (int sum = 0; sum <= c; sum++) {
			for (int take = 0; take + sum <= c; take++) {
				add(dp[i + 1][sum + take], mult(dp[i][sum], sub(pref[take][r[i]], pref[take][l[i] - 1])));
			}
		}
	}
	cout << dp[n][c] << '\n';
}

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

int main(void) {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> s(n + 1, k - q);
    s.at(0) = 0;
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        s.at(a)++;
    }
    for (int i = 1; i <= n; i++) {
        if (s.at(i) > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    cout << ((s < t) ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
  int N;
cin >> N;
  vector<pair<string, int>> pairs(N);
  rep(i, N){
	cin >> pairs.at(i).first >> pairs.at(i).second;
pairs.at(i).second = (100- pairs.at(i).second)*1000 + 1 + i;
}
  sort(pairs.begin(), pairs.end());
rep(i, N)
  cout << pairs.at(i).second % 1000 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
string low(string w){
    string w_ = "";
    for(int i=0;i<w.size();i++){
        if(w[i] >= 'A' && w[i] <= 'Z'){
            w_ += w[i]+32;
        }else{
            w_ += w[i];
        }
    }
    return w_;
}

int main(){
    string w; cin >> w;
    string t;
    string tmp = "";
    int cnt=0;
    int line = 0;
    w = low(w);
    
    string tango = "";

    while(true){
        getline(cin, t);
        if(t=="END_OF_TEXT"){
            if(tango==w){
                cnt += 1;
            }
            break;
        }
        t = low(t);

        // for(int i=0;i<t.size();i++){
        //     if(i==0){
        //         if(tmp==w){
        //             cnt++;
        //         }
        //         tmp="";
        //     }
            
        //     if(t[i]!=' '){
        //         tmp += t[i];
        //     }else{
        //         if(tmp==w){
        //             cnt++;
        //         }
        //         tmp="";
        //     }
        // }
        for(int i=0;i<t.size();i++){
            if(i==0){
                if(tango==w){
                    cnt += 1;
                }
                tango = "";
            }
            
            if(t[i]!=' '){
                tango += t[i];
            }else{
                if(tango==w){
                    cnt += 1;
                }
                tango = "";
            }
        }
        // cout << cnt<< endl;
        
    }

    cout << cnt<< endl;
    return 0;
}


Measured memory_bytes: 3204
#pragma GCC optimize(2)
//#pragma comment(linker, "/STACK:102400000,102400000")
 
#include <bits/stdc++.h>
using namespace std;
#define rep(i, beg, end) for (int i = beg; i < end; i++)
#define rrep(i, beg, end) for (int i = beg; i >= end; i--)
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int N = 6000;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
 
ll p[N];
ll c[N];
ll n, k;
 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    cin >> n >> k;
    rep(i, 1, n + 1)
    {
        cin >> p[i];
    }
 
    rep(i, 1, n + 1)
    {
        cin >> c[i];
    }
 
    ll ans = -1e18;
    rep(i, 1, n + 1)
    {
        int x = i;
        ll tot = 0;
        vector<int> sc;
        while (true)
        {
            x = p[x];
            tot += c[x];
            sc.push_back(c[x]);
            if (x == i)
                break;
        }
 
        int l = sc.size();
        ll t = 0;
        rep(j, 0, l)
        {
            t += sc[j];
            if (j + 1 > k)
                break;
            ll now = t;
            if (tot > 0)
            {
                ll e = (k - j - 1) / l;
                now += tot * e;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748