akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
set<string> s1;
set<string>::iterator it;
string s_kth,minstr,tmp;
char sz[5001];
void broken(string str_c)
{
	int i,j,k;
	k=str_c.length();
	for(i=1;i<=k;i++)
	{
		for(j=0;j<k-i+1;j++)
		{
			tmp=str_c.substr(j,i);
			s1.insert(tmp);
		}
	}
	return;
}
int main()
{
	int i,l,k;
	scanf("%s",sz);
	s_kth=sz;
	l=s_kth.length();
	scanf("%d",&k);
	minstr=s_kth;
	if(k>l)
	{
		broken(s_kth);
	}
	else
	{
		for(i=0;i<l-k;i++)
		{
			tmp=s_kth.substr(i,k);
			if(tmp<minstr)
			{
				broken(tmp);
				minstr=tmp;
			}
		}
		tmp=s_kth.substr(l-k,k);
		broken(tmp);
	}
	it=s1.begin();
	for(i=0;i<k-1;i++)
	{
		it++;
	}
	printf("%s",(*it).c_str());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	double ans=0;
	range(i,1,n+1){
		ll need = k<=i ? 0 : (ll)ceil(log2(1.0*k/i));
		double d =1.0/n;
		rep(j,need)d/=2;
		ans += d;
	}
	fcout(15)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
void solve();

signed main () {
	cout.precision(10);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		solve();
	}
	return 0;
}
int n;
const int N = 1e5 + 55;
int which[N];
void solve() {
	cin >> n;
	for (int i = 1; i <= n; i += 1) {
		int x;
		cin >> x;
		which[x] = i;
	}
	for (int i = 1; i <= n; i += 1) {
		cout << which[i] << ' ';
	} 
}		


Measured memory_bytes: 1664
n = gets.to_i
b = gets.split(" ").map(&:to_i)

a = Array.new(n)
a.each.with_index do |_, i|
  if i == 0
    a[i] = b[i]
  elsif i < a.length - 1
    a[i] = [b[i], b[i-1]].min
  else
    a[i] = b[i-1]
  end
end

ans = 0
a.each do |i|
  ans += i
end
p ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define ll long long
#define S second
#define F first
using namespace std;
ll n,m,ans;
pll p[100009];
multiset < ll > s;
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>p[i].F>>p[i].S;
    sort(p,p+n);int j = 0;
    for(int i=1;i<=m;i++){
        while(j < n && p[j].F <= i){
            s.insert(p[j++].S);
        }
        if(s.empty()) continue;
        ans += *s.rbegin();
        s.erase(s.find(*s.rbegin()));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6400
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int count = count(n);
        String t = String.valueOf(n);
        if (t.length() == 1) {
            System.out.println(n);
            return;
        }
        int head = Character.getNumericValue(t.charAt(0)) - 1;
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < t.length() - 1; i++) {
            builder.append("9");
        }
        if (head > 0) {
            builder.insert(0, head);
        }
        System.out.println(Math.max(count, count(Long.parseLong(builder.toString()))));
    }

    private static int count(long v) {
        int count = 0;
        while (v > 0) {
            count += v % 10;
            v /= 10;
        }
        return count;
    }
}

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

int main()
{
        ll a, b, k;
        cin >> a >> b >> k;

        ll total = b - a + 1;
        for (int i = 0; i < total; ++i) {


                if (i < k || i >= total-k) {
                        cout << a+i << endl;
                }



        }
}


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

#define N_MAX 50001

using namespace std;

bitset<N_MAX> prime;

void make_cache() {
    prime.set();
    for (int i = 2; i < N_MAX; i++) {
        if (prime[i]) {
            for (int j = i + i; j < N_MAX; j += i) {
                prime.reset(j);
            }
        }
    }
}

int count_pattern(int n) {
    int count = 0;
    for (int i = 2; i <= n/2; i++) {
        if (prime[i] && prime[n-i]) count++;
    }
    return count;
}

int main() {
    make_cache();
    int n; 
    while (cin >> n, n!=0) {
        cout << count_pattern(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 872
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	long A = sc.nextLong();
    	long B = sc.nextLong();
    	long C = sc.nextLong();
    	long K = sc.nextLong();
    	if (K <= A) {
    		System.out.println(K);
    	} else if (K <= A + B) {
    		System.out.println(A);
    	} else {
    		long Cnum = K - (A + B);
    		System.out.println(A - Cnum);
    	}
    }
}

Measured memory_bytes: 35824
#include <iostream>
#include <cassert>
#include <algorithm>
#define N int(1e5+1)
using namespace std;
typedef pair<int,int> pii;
int dp[N];
struct{
    int w,v;
}a[100];
int main(int argc,char ** argv)
{
    int n,w;
    cin>>n>>w;
    fill(dp+1,dp+N,w+1);
    for(int i=0;i<n;++i){
        cin>>a[i].w>>a[i].v;
    }
    for(int i=0;i<n;++i){
        for(int j=N-1;j>=a[i].v;--j){
            dp[j]=min(dp[j],dp[j-a[i].v]+a[i].w);
        }
    }
    int i;
    for(i=N-1;dp[i]>w;--i);
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 4028
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int a = sc.nextInt();
        int x[] = new int[a];
        int y[] = new int[a];
        double xx,yy;
        for(int i = 0;i < a;i++){
          x[i] = sc.nextInt();
          y[i] = sc.nextInt();
        }
      
        double ans = 0,tmp = 0;
        for(int i = 0;i < a;i++){
          for(int j = i + 1; j < a;j++){
            xx =  (x[i] - x[j]) * (x[i] - x[j]);
            yy =  (y[i] - y[j]) * (y[i] - y[j]);
            tmp =  xx + yy;
            ans += Math.pow(tmp,0.5) * 2 / a;
          }
        }
      System.out.println(ans);
    }
}

Measured memory_bytes: 35836
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin>>s;
  string ans="yes";
  for(int i=1;i<s.size();i++){
    for(int j=0;j<i;j++){
      if(s[i]==s[j]){
        ans="no";
      }
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c) {
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}



Measured memory_bytes: 2100
n = gets.chomp.to_i
s = gets.chomp
ans = 0
0.upto(n) do |i|
  count = 0
  as = []
  0.upto(i) do |j|
    if !as.include?(s.split("").at(j)) then
      as.push(s.split("").at(j))
    end
  end
  bs = []
  (i+1).upto(n) do |j|
    if !bs.include?(s.split("").at(j)) then
      bs.push(s.split("").at(j))
    end
  end
  as.each do |char|
    if bs.include?(char) then
      count += 1
    end
  end
  if ans < count then
    ans = count
  end
end
puts ans


Measured memory_bytes: 3964
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s; cin >> s;
	bool result = s[0] == 'A';
	int cntC = 0;
	for (int i = 2; i <= (int)s.length() - 2; i++)
		if (s[i] == 'C')
			cntC++;
	result &= cntC == 1;
	for (int i = 1; i < (int)s.length(); i++)
		if (s[i] >= 'A' && s[i] <= 'Z' && s[i] != 'C')
			result = false;
	cout << (result ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int a[5];
	for(int i = 0; i < 5; ++i){
		cin >> a[i];
	}
	for(int i = 0; i < 5; ++i){
		if(a[i] == 0){
			cout << (i + 1) << endl;
			break;
		}
	}
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3572
import copy
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def count_black(board, H, W):
    ans = 0
    for i in range(H):
        for j in range(W):
            if board[i][j] == "#":
                ans += 1
    return ans


def main():
    H, W, K = [int(i) for i in input().strip().split()]
    board = [list(input().strip()) for _ in range(H)]

    ans = 0
    for i in range(2**(H+W)):
        tmp = copy.deepcopy(board)
        for j in range(H+W):
            if (i >> j) & 1:
                if j < H:
                    tmp[j] = ["R"] * W
                else:
                    for k in range(H):
                        tmp[k][j - H] = "R"
        if count_black(tmp, H, W) == K:
            ans += 1
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 74696
n = int(input())
a = sorted(map(int, input().split()))
cnt = 0

for k in range(1, 9):
    b = list(filter(lambda x: x < 400*k, a))
    if b:
        cnt += 1
    a = a[len(b):]
if cnt:
    print(cnt, cnt+len(a))
else:
    print(1, len(a))


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

int main () {
    int number;
    int division;

    scanf("%d",&number);
    
    if (number % 2 == 0){
        printf("%d\n",number);
    } else {
        division = number * 2;
        printf("%d\n",division);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	int dp[310000];

	
	void solve(){


		ini(n);
		ini(n1);
		dp[0] = 0;
		FOR(i,0,n){
			ini(x,x1);
			if(x1>n1)continue;
			for(int i1 = n1-x1;i1>=0;i1--){
				dp[i1+x1] = max(dp[i1+x1],dp[i1]+x);
				//out(x,i1+x1,dp[i1+x1]);
			}
		}
		int rick = 0;
		FOR(i,0,n1+1){
			rick =max(rick,dp[i]);
		}
		out(rick);

		


		
		
	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



Measured memory_bytes: 3236
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        int X=sc.nextInt();
        int Y=sc.nextInt();
        boolean kakaku=true;
        if(B>=A){
            kakaku=false;
        }
        boolean maisuu=true;
        if(Y>=X){
            maisuu=false;
        }
        if(maisuu){
            int l=Math.min(2*X*C,X*A+Y*B);
            System.out.println(Math.min(l,2*Y*C+A*(X-Y)));
        }else{
            int l=Math.min(2*Y*C,X*A+Y*B);
            System.out.println(Math.min(l,2*X*C+B*(Y-X)));
        }
        
}
        
        
    }


Measured memory_bytes: 21844
n = int(input())
p = list(map(int ,input().split()))
ans =0

for i in range(1 ,n-1):
    # print(i)
    if p[i-1] <p[i] <p[i+1] or p[i-1] >p[i] >p[i+1]:
        ans +=1
       
print(ans)

Measured memory_bytes: 3060
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = replicateM 2 getLine >>= print . length . filter id . uncurry ( zipWith (==) ) . mp

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

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

    int a[h][w]={};
    queue<vector<int>> q;
    rep(i,h*w){
        char c;
        cin>>c;
        if(c=='#'){
            a[i/w][i%w]=1;
            vector<int> v{i/w,i%w};
            q.push(v);
        }
    }

    int ans=0;
    while(q.size()!=0){
        int s=q.size();
        rep(i,s){
            vector<int> v=q.front();
            q.pop();
            //a[v[0]][v[1]]=1;

            if(v[0]-1>=0){
                int _h=v[0]-1,_w=v[1];
                if(a[_h][_w]==0){
                    vector<int> _v{_h,_w};
                    q.push(_v);
                    a[_h][_w]=1;
                }
            }
            if(v[0]+1<h){
                int _h=v[0]+1,_w=v[1];
                if(a[_h][_w]==0){
                    vector<int> _v{_h,_w};
                    q.push(_v);
                    a[_h][_w]=1;
                }
            }
            if(v[1]-1>=0){
                int _h=v[0],_w=v[1]-1;
                if(a[_h][_w]==0){
                    vector<int> _v{_h,_w};
                    q.push(_v);
                    a[_h][_w]=1;
                }
            }
            if(v[1]+1<w){
                int _h=v[0],_w=v[1]+1;
                if(a[_h][_w]==0){
                    vector<int> _v{_h,_w};
                    q.push(_v);
                    a[_h][_w]=1;
                }
            }
        }
        ans++;
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 59572
// /****************** 			***********************/
//      /****************BSMRSTU*****************/
// /***********BISMILLAHIR RAHMANIR RAHIM*************/
// /*.................Mohammad Imran................*/
// /*..................Dept Of CSE.................*/

// #include<bits/stdc++.h>
// #define ll long long
// #define llu unsigned long long
// #define pi acos(-1.0)
// #define dd double
// const int N          = (int)2e5 + 5 ;
// const int maxN       = (int)1e6 + 6 ;
// const ll  Mod        = (ll)1e9 + 7 ;
// const int inf        = (int)2e9 ;
// const ll  Inf        = (ll)1e18 ;
// const int mod        = (int)1e9 + 7 ;

// using namespace std;
// int main(){
// 	ll n;
// 	char  a[105],b[105],c[400];
// 	cin>>n;
// 	for(ll i=0;i<n;i++){
// 		cin>>a[i];
// 		cin>>b[i];
		
// 	}
// 	for(ll j=0;j<n;j++){
// 		if(j%2==0){
// 		     c[j]=a[j];	
// 		}
// 		else
// 			c[j]=b[j];
// 	}
// 	for(ll k=0;k<(n*n);k++){
// 		cout<<c[k]<<" ";
// 	}

// 	return 0;
// }
/****************** 			***********************/
     /****************BSMRSTU*****************/
/***********BISMILLAHIR RAHMANIR RAHIM*************/
/*.................Mohammad Imran................*/
/*..................Dept Of CSE.................*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define pi acos(-1.0)
#define dd double
const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;
using namespace std;
int main(){
	ll n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	for(ll i=0;i<n;i++){
	cout<<a[i];
	cout<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
using namespace std;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main(){
    int n,ans,temp;
    set<long long int> s;
    scanf("%d%d",&n,&ans);
    n--;
    while(n--){
        scanf("%d",&temp);
        ans=gcd(ans,temp);
    }
    for(long long int i=1;i*i<=ans;i++)if(ans%i==0){
            s.insert(i);
            s.insert(ans/i);
    }
    for(auto u:s)printf("%lld\n",u);
}


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

using ld=long double;
struct Query{
    ld p,t;
    ld res=-1;
};
const ld INF=1e10;
const ld EPS=1e-10;
const ld HEIGHT=50;
const ld WIDTH=100;
const ld DEPTH=30;
struct Tank{
    int n;
    vector<ld> b;
    vector<ld> h;
    vector<ld> level;
    vector<ld> win;
    Tank(int n):n(n){
        b.assign(n+1,-1);
        b[0]=0,b[n]=WIDTH;
        h.assign(n+1,-1);
        h[0]=INF,h[n]=INF;
        level.assign(n,0);
        win.assign(n,0);
    };
};
void solve(ld t,Tank tank,vector<Query>& query){
    int n=tank.n;
    int idx=-1;
    ld scc=INF*WIDTH*DEPTH*2;
    for(int i=0;i<n;i++){
        if(tank.win[i]<EPS) continue;
        ld wid=tank.b[i+1]-tank.b[i];
        ld tmp=((min(tank.h[i],tank.h[i+1])-tank.level[i])*wid*DEPTH)/tank.win[i];
        if(tmp<scc){
            scc=tmp;
            idx=i;
        }
    }
    assert(idx>=0);
    vector<ld> nextLevel(n);
    for(int i=0;i<n;i++){
        ld wid=tank.b[i+1]-tank.b[i];
        nextLevel[i]=tank.level[i]+tank.win[i]/DEPTH/wid*scc;
    }
    for(int i=0;i<query.size();i++){
        if(query[i].res<-EPS && query[i].t<t+scc){
            for(int j=0;j<n;j++){
                if(query[i].p<tank.b[j+1]){
                    query[i].res=tank.level[j]+(nextLevel[j]-tank.level[j])/scc*(query[i].t-t);
                    break;
                }
            }
        }
    }
    if(n==1) return;
    int cto=tank.h[idx]<tank.h[idx+1] ? idx-1 : idx+1;
    if(abs(nextLevel[cto]-nextLevel[idx])<EPS){
        tank.n--;
        tank.b.erase(tank.b.begin()+max(idx,cto));
        tank.h.erase(tank.h.begin()+max(idx,cto));
        int pos=0;
        for(int i=0;i<n;i++){
            if(i!=max(idx,cto)){
                tank.level[pos]=nextLevel[i];
                pos++;
            }
        }
        tank.win[min(cto,idx)]+=tank.win[max(cto,idx)];
        tank.win.erase(tank.win.begin()+max(idx,cto));
        solve(t+scc,tank,query);
    }
    else{
        tank.win[cto]+=tank.win[idx];
        tank.win[idx]=0;
        tank.level=nextLevel;
        solve(t+scc,tank,query);
    }
    return;
}
int main(){
    int d;
    cin>>d;
    while(d--){
        int n;
        cin>>n;
        Tank tank(n+1);
        for(int i=0;i<n;i++){
            int b,h;
            cin>>b>>h;
            tank.b[i+1]=b,tank.h[i+1]=h;
        }
        int m;
        cin>>m;
        for(int i=0;i<m;i++){
            int f,a;
            cin>>f>>a;
            for(int j=0;j<=n;j++){
                if(f<tank.b[j+1]){
                    tank.win[j]+=a;
                    break;
                }
            }
        }
        int l;
        cin>>l;
        vector<Query> query(l);
        for(int i=0;i<l;i++){
            ld p,t; cin>>p>>t;
            query[i]={p,t,-1};
        }
        solve(0,tank,query);
        for(int i=0;i<l;i++){
            cout<<fixed<<setprecision(10);
            cout<<min(HEIGHT,query[i].res)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3224
// 2013/07/14 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

bool uruu(int y)
{
	return (y%400==0 || (y%4==0 && y%100!=0));
}

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

		if(S=="#")
			break;

		int cnt = 0;

		while(true){
			int loc = S.find(".");

			if(loc==string::npos)
				break;

			S.replace(loc, 1, " ");
			cnt++;
		}

		if(cnt==4){
			istringstream is(S);
			int b, ka, t, w, ki;
			is >> b >> ka >> t >> w >> ki;

			int KI = (((b*20+ka)*20+t)*18+w)*20+ki;

			int y = 2012;
			int m = 12;
			int d = 21;

			if(KI<11){
				d += KI;
				KI = 0;
			}
			else{
				y = 2013;
				m = 1;
				d = 1;
				KI -= 11;
			}

			while(true){
				if(uruu(y) && KI>=366){
					y++;
					KI -= 366;
				}
				else if(!uruu(y) && KI>=365){
					y++;
					KI -= 365;
				}
				else{
					break;
				}
			}

			while(true){
				if((m==1 || m==3 || m==5 || m==7 || m==8 || m==10) && KI>=31){
					m++;
					KI -= 31;
				}
				else if((m==4 || m==6 || m==9 || m==11) && KI>=30){
					m++;
					KI -= 30;
				}
				else if(m==2 && uruu(y) && KI>=29){
					m++;
					KI -= 29;
				}
				else if(m==2 && !uruu(y) && KI>=28){
					m++;
					KI -= 28;
				}
				else{
					break;
				}
			}

			if(KI>0){
				d += KI;
				KI = 0;
			}

			cout << y << '.' << m << '.' << d << endl;
		}
		else if(cnt==2){
			istringstream is(S);
			int y, m, d;
			is >> y >> m >> d;

			long long D = 0;

			if(y==2012&&m==12){
				D = d-21;
			}
			else{
				D = 11;

				for(int i=2013; i<y; i++){
					if(uruu(i)){
						D += 366;
					}
					else{
						D += 365;
					}
				}

				for(int i=1; i<m; i++){
					if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10){
						D += 31;
					}
					else if(i==4 || i==6 || i==9 || i==11){
						D += 30;
					}
					else if(i==2 && uruu(y)){
						D += 29;
					}
					else if(i==2 && !uruu(y)){
						D += 28;
					}
					else{
						break;
					}
				}

				D += (d-1);
			}

			int ki = D%20;
			D /= 20;

			int w = D%18;
			D /= 18;

			int t = D%20;
			D /= 20;

			int ka = D%20;
			D /= 20;

			int b = D%13;

			cout << b << '.' << ka << '.' << t << '.' << w << '.' << ki << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int x;
	cin>>x;
	vector<bool> expo(x+1);
	expo[1]=1;
	for(int i=2;i<=int(sqrt(x));i++){
		int v=i*i;
		while(v<=x){
			expo[v]=1;
			v*=i;
		}
	}
	for(int i=x;i>=1;i--)
		if(expo[i]){
			cout<<i<<endl;
			return 0;
		}
}

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

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 2) {
      ans++;
    }
    if (a[i] < 2 || a[i] % 2 == 0) {
      continue;
    }

    int j = 3;
    bool flag = true;
    while (j <= sqrt(a[i])) {
      if (a[i] % j == 0) {
        flag = false;
        break;
      }
      j += 2;
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3136
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char n = sc.next().charAt(0);
    if(n == 'A'){
      System.out.println("T");
    }else if(n == 'G'){
      System.out.println("C");
    }else if(n == 'T'){
      System.out.println("A");
    }else{
      System.out.println("G");
    }
  }
}

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

int main() {
	int N,c;
	cin >> N;
	c=0;
	vector<int> A(N);
	vector<int> B(N);
	for(int i=0;i<N;i++){
		cin >>A.at(i);
		B.at(i)=A.at(i);
	}
	sort(A.begin(),A.end());
	for(int i=0;i<N;i++){
		if(A.at(i)!=B.at(i)){
			c+=1;
		}
	}
	if((c==0)||(c==2)){
		cout << "YES"<<endl;
	}	
	else{
		cout <<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

char grid[100][100];
int dp[100][100];
int main() {
    int i,j;
    int H,W;
    scanf("%d %d",&H,&W);
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) scanf(" %c",&grid[i][j]);
    }

    dp[0][0] = (grid[0][0] == '#') ? 1:0;
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            if ((i > 0) || (j > 0)) {
                dp[i][j] = 1e9;
                if (i > 0) dp[i][j] = min(dp[i][j],dp[i-1][j]+((grid[i-1][j] == '.') && (grid[i][j] == '#')));
                if (j > 0) dp[i][j] = min(dp[i][j],dp[i][j-1]+((grid[i][j-1] == '.') && (grid[i][j] == '#')));
            }
        }
    }
    printf("%d\n",dp[H-1][W-1]);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    vvi g(n, vi());
    for (int i = 0; i < n - 1; i++)
    {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
    vi d(n);
    vector<bool> used(n, false);
    map<int, int> m;
    for (int i = 0; i < n; i++)
    {
        used.assign(n, false);
        d.assign(n, LLONG_MAX);
        d[i] = 0;
        queue<int> q;
        q.push(i);
        used[i] = true;
        while (sz(q))
        {
            int i = q.front();
            q.pop();
            for (int j : g[i])
                if (!used[j])
                {
                    used[j] = true;
                    d[j] = d[i] + 1;
                    q.push(j); 
                }
        }
        for (int j = 0; j < n; j++)
            m[d[j]]++;
    }
    for (int i = 1; i <= n - 1; i++)
        cout << m[i] / 2 << endl;
    GAME_OVER;
}

Measured memory_bytes: 512
N, x = map(int, input().split())
A = [int(i) for i in input().split()]
sorted_A = sorted(A)

i = 0
while i < N and x > 0:
    x -= sorted_A[i]
    i += 1

if x == 0:
    print(i)
else:
    print(i-1)

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b;
	char ch;
	t = 1;
	while(t--) {
	 cin >> a >> ch >> b;
	 if(ch == '+')
	  cout << a + b << endl;
	 else
	  cout << a - b << endl;
	}
	return 0;
}



Measured memory_bytes: 256
// Patience kam ho gya bc!
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int vis[N];
int dp[N];
vector<int>v[N];
void dfs(int s){
	vis[s]=1;
	for(auto i : v[s]){
		if(!vis[i]){
			dp[i]+=dp[s];
			dfs(i);
		}
	}
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n ,q;
		cin >> n >> q;
		for(int i=0 ;i < n-1;i++){
			int x ,y;
			cin >>x >>y;
			v[x].pb(y);
			v[y].pb(x);
		}
		while(q--){
			int nd,x;
			cin >> nd >> x;
			dp[nd]+=x;
		}
		dfs(1);
		fn1{
			cout << dp[i] <<" ";
		}
		
	
	
	}
	return 0;
}

Measured memory_bytes: 70272
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
}Node;

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if (cur == nil) break;
    if(isf > 0) printf(" ");
    printf("%d",cur-> key);
    cur = cur->next;
    isf++;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s %d",com,&key);
    if(com[0] == 'i'){ insert(key); np++; size++;}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F') deleteFirst();
	else if(com[6] == 'L') deleteLast();
      }
      else{
	deleteKey(key);
	nd++;
      }
      size--;
    } 
  }
  printList();
  return 0;
}



Measured memory_bytes: 32952
while True:
    H, W = map(int, input().split())

    # H = 0 かつ W = 0 のとき終了する
    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()


    # データセットごとに改行する
    print()


Measured memory_bytes: 7000
S = input()

for i, s in enumerate(S):
    if i%2==0:
        if s=='R' or s=='U' or s=='D':
            pass
        else:
            print('No')
            exit()
    else:
        if s=='L' or s=='U' or s=='D':
            pass
        else:
            print('No')
            exit()
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int s[3];
int main()
{
    for(int i=0;i<3;i++)
        scanf("%d",&s[i]);
    sort(s,s+3);
    int sum=0;
    sum+=s[2]-s[1];
    s[0]+=s[2]-s[1];
    s[1]=s[2];
    sum+=(s[2]-s[0])/2;
    s[0]+=(int)((s[2]-s[0])/2)*2;
    if(s[0]<s[2])sum++,s[0]+=2;
    if(s[0]>s[2])sum++;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class MathUtil {
	public static long gcd(long x, long y) {
		if(x == 0) return y;
		if(y == 0) return x;
		if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		}
	}
}

class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long x = in.nextInt();
		long y = in.nextInt();
		System.out.println(MathUtil.gcd(x, y));
	}
}

Measured memory_bytes: 26300
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
#define mp make_pair
#define ba 47
#define mo 999999137
#define mod 974711
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
int h[105];
bool vis[105];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void update(int &x,int y) {
    x = inc(x,y);
}
pii Solve(int l,int r,int v) {
    int minv = 1e9;
    for(int i = l ; i <= r ; ++i) minv = min(minv,h[i]);
    int p,cnt = 0;
    pii res = mp(1,1);
    for(int i = l ; i <= r ; ++i) {
	if(h[i] > minv) ++cnt;  
    }
    for(int i = l ; i <= r ; ++i) {
	if(h[i] > minv) {
	    p = i;
	    while(p < r && h[p + 1] > minv) ++p;
	    pii f = Solve(i,p,minv);
	    res.fi = mul(res.fi,f.fi);
	    res.se = mul(res.se,inc(f.se,f.fi));
	    i = p;
	}
    }
    int t = mul(res.fi,2);
    res.se = mul(res.se,fpow(2,r - l + 1 - cnt));
    res.fi = mul(res.fi,fpow(2,minv - v));
    res.se = inc(res.se,inc(res.fi,MOD - t));
    return res; 
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {read(h[i]);}
    pii ans = Solve(1,N,0);
    out(ans.se);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

#include <stdio.h>


int main(){
  int n, m, i, j;
  char c[128], ch[128], a;

  while(1){
    //scanf("%d",&n);
    cin >> n;
    if(n == 0) break;
    for(i = 0 ; i < n ; i++){
      //scanf(" %c %c ",&c[i],&ch[i]);
      cin >> c[i] >> ch[i];
    }
    //scanf("%d",&m);
    cin >> m;
    for(i = 0 ; i < m ; i++){
      //scanf(" %c ",&a);
      cin >> a;
      for(j = 0 ; j < n ; j++){
	if(a == c[j]){
	  a = ch[j];
	  break;
	}
      }
      printf("%c",a);
    }
    printf("\n");
  }

  return 0;

}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0);
 
    int N, M;
    
    cin >> N >> M;
    
    // create adjacency list
    vector<vector<int>> adj(N+1, vector<int>());
    
    while(M--){
		int a, b;
		cin >> a >> b;
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
	}
	
	//for(int i=0; i<N+1; ++i) {
		//cout << i << ": ";
		//for(int j : adj[i]) {
			//cout << j << ", ";
		//}
		//cout << "\n";
	//}
	
	// start BFS from 1
	vector<int> vis(N+1, -1);
	
	queue<int> q;
	q.push(1);
	vis[1] = 1;
	vis[0] = 1;
	
	while(!q.empty()) {
		
		int node = q.front();
		q.pop();
		
		for(int n : adj[node]) {
			if(vis[n]==-1){
				vis[n] = node;
				q.push(n);
			}
		}
	}
	
	auto it = find(vis.begin()+2, vis.end(), -1);
	
	if(it != vis.end()){
		cout << "No";
		return 1;
	}
	
	cout << "Yes\n";
	for(int i=2; i<N+1; ++i) {
		cout << vis[i] << "\n";
	}
	
    return 0;
}

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

A = [[0]*M]*N
temp = [0]*(M+1)
C = [0]*N

for i in range(0,N):
    temp = list(map(int,input().split()))
    C[i] = temp[0]
    A[i] = [x for x in temp[1:M+1]]
    

clear = 0
hoge = [int(x) for x in range(0,N)]
min_total = sum(C)

for i in range(2**len(hoge)):
    bag = []
    for j in range (len(hoge)):
        if (i>>j)&1:
            bag.append(hoge[j])
    total =0
    
    skil=[0]*M
    master=[0]*M
#    print(bag)
    for b in bag:
        total += C[b]
        for m in range (0,M):
            skil[m] += A[b][m]
            if skil[m]>=X:
                master[m] +=1
        if 0 not in master :
            min_total = min(min_total,total)
            clear += 1
#        print(skil)
    
if clear >0:
    print(min_total)
else:
    print('-1')

Measured memory_bytes: 9280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define READ      freopen("input.txt", "r", stdin);
#define WRITE     freopen("output.txt", "w", stdout);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
const ll MAX = 1000004;
const ll INF = 1e18L + 5;

vll graph_directed[MAX];
ll indegree[MAX];
bool visited[MAX];
ll LPT[MAX];

void topologicalSort(ll allNodes) {
	queue<ll> inDegZero;
	rep(node, 1, allNodes + 1) {
		if (indegree[node] == 0) {
			inDegZero.push(node);
		}
	}
	while (!inDegZero.empty()) {
		ll nodeDegZero = inDegZero.front();
		inDegZero.pop();
		for (auto i : graph_directed[nodeDegZero]) {
			indegree[i]--;
			if (indegree[i] == 0) {
				inDegZero.push(i);
			}
			LPT[i] = max(LPT[i], 1 + LPT[nodeDegZero]);
		}
	}
}
int main() {

	_cin
	// READ
	// WRITE
	ll allNodes, edges;
	cin >> allNodes >> edges;
	rep(node, 0, edges) {
		ll from, to;
		cin >> from >> to;
		graph_directed[from].pb(to);
		indegree[to]++;
	}
	topologicalSort(allNodes);

	ll ans = 0;

	rep(i, 1, allNodes + 1) ans = max(ans, LPT[i]);

	cout << ans << endl;
}

Measured memory_bytes: 31696
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	ostringstream oss;

	string s;
	cin >> s;
	oss << s.front();
	cin >> s;
	oss << s.front();
	cin >> s;
	oss << s.front();

	cout << oss.str() << endl;

}		


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define showcon(v) {for(auto u : (v)) cerr << u << ' '; cout << '\n';}
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

const int mx = 1e5 + 5;

int vis1[mx], vis2[mx];
int dp1[mx], dp2[mx];
int sz[mx];
int n;
int mod;
int ans[mx];
vector<int> G[mx];
vector<int> pm[mx], rm[mx];

inline void mlt(int& a, int b){
    a = ll(a) * b % mod;
}

inline int vmlt(int a, int b){
    return ll(a) * b % mod;
}

void dfs1(int x){
    //cerr <<"dfs1(" << x << ")\n";
    vis1[x] = 1;
    dp1[x] = 1;
    int deg = G[x].size();
    pm[x].resize(deg + 2, 1);
    rm[x].resize(deg + 2, 1);
    for(int i = 1; i <= deg; i++){
        int u = G[x][i-1];
        if(vis1[u]) continue;
        dfs1(u);
        pm[x][i] = rm[x][i] = (1 + dp1[u]) % mod;
        mlt(dp1[x], 1 + dp1[u]);
    }
    /*
    cerr << "show(" << x << ")\n";
    showcon(pm[x]);
    showcon(rm[x]);
    */
}

void dfs2(int x){
    //cerr << "dfs2(" << x << ")\n";
    vis2[x] = 1;
    int deg = G[x].size();
    for(int i = 1; i <= deg; i++){
        int u = G[x][i-1];
        if(vis2[u]){
            pm[x][i] = rm[x][i] = (1 + dp2[u]) % mod;
        }
    }
    /*
    cerr << "before pprod\n";
    showcon(G[x]);
    showcon(pm[x]);
    showcon(rm[x]);
    */
    for(int i = 1; i <= deg; i++){
        mlt(pm[x][i], pm[x][i-1]);
        mlt(rm[x][deg+1-i],rm[x][deg+2-i]);
    }
    /*
    cerr << "after pprod\n";
    showcon(G[x]);
    showcon(pm[x]);
    showcon(rm[x]);
    */
    ans[x] = pm[x][deg];
    for(int i = 1; i <= deg; i++){
        int u = G[x][i-1];
        if(vis2[u]) continue;
        dp2[x] = vmlt(pm[x][i-1], rm[x][i+1]);
        dfs2(u);
    }
}

int main(){
    fio;
    cin >> n >> mod;
    for(int i = 1, a, b; i < n; i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(1);
    dfs2(1);
    for(int i = 1; i <= n; i++){
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, arr[nax];
bool salah=0;
unordered_map<int, int>book;

int main(){
	IOS
	cin >> n; 
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	for(int i=0;i<n-1;i++){
		if(arr[i]>arr[i+1]){
			if(!book[arr[i]]){
				if(arr[i]-1==arr[i+1]){
					arr[i]--;
					book[arr[i+1]]=1;
				}
				else{
					salah=1;
					break;
				}
			}
			else{
				salah=1;
				break;
			}
		}
	}
	if(salah){
		cout << "No" << '\n';
	}	
	else{
		cout << "Yes" << '\n';
	}
	return 0;
}


Measured memory_bytes: 6024
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;
using ld = long double;

template <std::uint_fast64_t Mod>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 val;

  constexpr ModInt(const u64 x = 0) noexcept : val(x % Mod) {}
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    val += rhs.val;
    if (val >= Mod) {
      val -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (val < rhs.val) {
      val += Mod;
    }
    val -= rhs.a;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    val = val * rhs.val % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const ll MOD = 1000000007;
using mint = ModInt<MOD>;

void solve(ll n, ll k) {
  auto lim = min(n, k + 1);
  vector<mint> nCk(1, 1);
  nCk.reserve(lim);
  mint ans = 1;
  for (auto i = 1; i != lim; ++i) {
    nCk.push_back(nCk[i - 1] * (n - i + 1) / i);
    ans += nCk[i] * nCk[i] * (n - i) / n;
  }

  cout << ans.val << endl;
}

int main() {
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  solve(n, k);
  return 0;
}


Measured memory_bytes: 1792
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    int n = cast(int)s.length;

    // dp[i][j] = i 番目と j 番目から始まる文字列の共通の長さ
    auto dp = new int[][](n, n);

    for (int i = n - 1; i >= 0; i--) {
        for (int j = n - 1; j >= 0; j--) {
            if (s[i] == s[j]) {
                if (i + 1 < n && j + 1 < n)
                    dp[i][j] = dp[i + 1][j + 1] + 1;
                else
                    dp[i][j] = 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans = max(ans, min(j - i, dp[i][j]));
        }
    }
    return ans;
}

void main() {
    readint;
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 102140