akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct event
{
	ll pos, st, en;
};

template <typename Monoid>
class SegmentTree {
public:
	SegmentTree(ll n, Monoid pr) {
		size = pow(2, ceil(log2(n)));
		vec.resize(2 * size - 1, pr);
	}

	void Update(ll L, ll R, ll index, ll begin, ll end, Monoid M) {
		if (vec[index] == -1) {
			vec[index] = M;
		}
		else if (M != -1) {
			vec[index] = min(vec[index], M);
		}
		if (index >= size - 1) return;
		Update(L, R, index * 2 + 1, begin, (begin + end) / 2, vec[index]);
		Update(L, R, index * 2 + 2, (begin + end) / 2, end, vec[index]);
		return;
	}

	void Update(ll _N) {
		Update(0, _N, 0, 0, size, -1);
	}

	void Query(ll L, ll R, ll index, ll begin, ll end, Monoid M) {
		if (end <= L || R <= begin) {
			return;
		}
		if (L <= begin && end <= R) {
			if (vec[index] == -1) {
				vec[index] = M;
			}
			else {
				vec[index] = min(vec[index], M);
			}
			return;
		}
		Query(L, R, index * 2 + 1, begin, (begin + end) / 2, M);
		Query(L, R, index * 2 + 2, (begin + end) / 2, end, M);
		return;
	}

	void Query(ll L, ll R, Monoid M) {
		Query(L, R, 0, 0, size, M);
		return;
	}

	void Output(ll N) {
		rep(i, N) cout << vec[size - 1 + i] << endl;
	}

private:
	vector<Monoid> vec;
	ll size;
};

void solve() {
	ll N, Q;
	cin >> N >> Q;
	SegmentTree<ll> ST(Q, -1);
	vector<event> ev(N);
	rep(i, N) {
		ll st, en, pos;
		cin >> ev[i].st >> ev[i].en >> ev[i].pos;
	}

	vector<ll> human(Q);
	rep(i, Q) cin >> human[i];

	rep(i, N) {
		ll start, end;
      
		ll L = 0, R = human.size();
		while (L != R) {
			ll F = (L + R) / 2;
			bool judge = false;

			if (human[F] >= ev[i].en - ev[i].pos) judge = true;

			if (judge) { R = F; }
			else { L = F + 1; }

		}
		end = R;

		L = 0, R = human.size();
		while (L != R) {
			ll F = (L + R) / 2;
			bool judge = false;

			if (human[F] >= ev[i].st - ev[i].pos) judge = true;

			if (judge) { R = F; }
			else { L = F + 1; }

		}

		start = R;

		ST.Query(start, end, ev[i].pos);

	}

	ST.Update(Q);

	ST.Output(Q);

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 12288
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  ll x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b << endl;

  return 0;
}


Measured memory_bytes: 256
dice = list(map(int, input().split()))

lis = [1,2,3,4,5,6]

def dicing(lis, inst):
    if inst == 'N':
        ans_lis = [lis[1],lis[5],lis[2],lis[3],lis[0],lis[4]]
    if inst == 'W':
        ans_lis = [lis[2],lis[1],lis[5],lis[0],lis[4],lis[3]]
    if inst == 'S':
        ans_lis = [lis[4],lis[0],lis[2],lis[3],lis[5],lis[1]]
    if inst == 'E':
        ans_lis = [lis[3],lis[1],lis[0],lis[5],lis[4],lis[2]]
    
    return(ans_lis)

inst = list(input())
N = len(inst)

for i in range(N):
    lis = dicing(lis, inst[i])

print(dice[(lis[0]-1)])


Measured memory_bytes: 5612
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1791791791;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    //freopen("input.txt", "r", stdin);
#endif
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a + b) cout << min(a, k) << endl;
    else cout << min(a, k) - (k - a - b) << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a = 2, b = 1;
  int n; cin >> n;
  n -= 1;
  for(int i = 0; i < n; i++){
    b += a;
    a = b - a;
  }
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 384
n, c = map(int, input().split())
program = [list(map(int, input().split())) for _ in range(n)]

table = [[0 for _ in range(c)] for _ in range(10 ** 5)]

for p in program:
	for i in range(p[0] - 1, p[1]):
		table[i][p[2]-1] = 1

ans = 1

for i in range(10 ** 5):
	s = sum(table[i])
	if ans < s:
		ans = s

print(ans)

Measured memory_bytes: 62676
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque

def gcd(a, b):
    """最大公約数"""
    a, b = (a, b) if a >= b else (b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, A):
    L = [0] * N
    L[0] = A[0]
    for i in range(1, N):
        L[i] = gcd(A[i], L[i - 1])
    R = [0] * N
    R[-1] = A[-1]
    for i in range(1, N):
        R[-(i + 1)] = gcd(A[-(i + 1)], R[-i])
    ans = 0
    for i in range(N):
        if i == 0:
            ans = max(ans, R[i + 1])
        elif i == N - 1:
            ans = max(ans, L[i - 1])
        else:
            ans = max(ans, gcd(L[i - 1], R[i + 1]))
    print(ans)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, A)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 20672
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b&&b < c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
int n;
string str;
int cnt[26];
int ans[26];
int main(){
	for(int i = 0 ; i < 26 ; ++i){
		ans[i] = 1e6 + 6;
	}
	cin >> n;
	while(n--){
		cin >> str;
		memset(cnt , 0 , sizeof(cnt));
		for(char c : str){
			++cnt[c - 'a'];
		}
		for(int i = 0 ; i < 26 ; ++i){
			ans[i] = min(ans[i] , cnt[i]);
		}
	}
	for(int i = 0 ; i < 26 ; ++i){
		while(ans[i]--){
			putchar('a' + i);
		}
	}
	putchar('\n');
}

Measured memory_bytes: 256
#include<stdio.h>


int main() {
	
	char s[4];
	int cheak=0;

	scanf("%s", s);

	if (s[0] == s[1])
		cheak = 1;
	if (s[2] == s[1])
		cheak = 1;
	if (s[3] == s[2])
		cheak = 1;
	
	
	if (cheak == 1)
		printf("Bad");
	if (cheak == 0)
		printf("Good");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdlib.h>
using namespace std;

struct point{ int n,c[106],l[106],d[64],cl;};
 point p[109];
 
 void ans() {
	 int i,j,k,f,m;
	 f=1;
	 while (f==1) {
		 f=0;
		 for (i=0;i<108;i++) {
			 if (p[i].n==0) continue;
			 for (j=0;j<p[i].n;j++) {
				 for (k=0;k<64;k++) {
					 if (p[i].d[k]>=99999) continue;
					 m=k; 
					 if (i>100 && i<107) m= k | (1 << (i-101));
					 if  (p[i].c[j]>100 && p[i].c[j]<107) if (((1 << (p[i].c[j]-101)) & k)>0) continue;
					 if (p[i].d[k]+p[i].l[j]-p[i].cl<p[p[i].c[j]].d[m]) { p[p[i].c[j]].d[m]=p[i].d[k]+p[i].l[j]-p[i].cl; f=1;}
				}
			}	 
		}
	} 
 }
 
 
 int main() {
	 int a[2],b,i,j,m,n,k,d,l,s;
	 char c[2][5];
	 while(cin >> m >> n >> k >> d && m>0) {
		 for (i=0;i<108;i++) { p[i].n=p[i].cl=0; for (j=0;j<64;j++) p[i].d[j]=99999;}
		 for (i=0;i<m;i++) cin >> p[101+i].cl;
		 for (i=0;i<d;i++) {
			 cin >> c[0] >> c[1] >> l;
			 for (j=0;j<2;j++) {
				 if (c[j][0]=='H') a[j]=0; else if (c[j][0]=='D') a[j]=107; else {
					 if (c[j][0]=='C') b=100; else b=0;
					 c[j][0]='0';
					 a[j]=b+atoi(c[j]);
				 }
			 }
			 p[a[0]].c[p[a[0]].n]=a[1]; p[a[0]].l[p[a[0]].n]=l*k;
			 p[a[1]].c[p[a[1]].n]=a[0]; p[a[1]].l[p[a[1]].n]=l*k;
			 p[a[0]].n++; p[a[1]].n++;   
			}
		p[0].d[0]=0; s=99999; 
		ans();
		for (i=0;i<64;i++) if (s>p[107].d[i]) s=p[107].d[i];
		cout << s << endl; 
		}
	return 0;
 }

Measured memory_bytes: 1288
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void) {

	int a;

	std::cin >> a;

	if (a % 2 == 0) {
		std::cout << a << std::endl;
	}
	else {
		std::cout << a * 2 << std::endl;
	}



	return 0;
}

Measured memory_bytes: 256
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

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

typedef long long ll;
int main ()
{
    ll k;
    ll ara[52];
    cin>>k;
    ll t=k/50;
    for (int i=0;i<50;i++) ara[i]=i+t;
    t=k%50;
    for (int i=0;i<t;i++) {
        ara[i]+=50;
        for (int j=0;j<50;j++) if (j!=i) ara[j]--;
    }
    cout<<50<<endl;
    for (int i=0;i<50;i++) cout<<ara[i]<<' ';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a)){
		cout<<"Yes";
	} 
	else{
		cout<<"No";
	}
	re 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

vector<ll> fac(2001); //n!(mod M)
vector<ll> ifac(2001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

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

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<2000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    int c=1;
    int sum=0;
    while(s-c*3>=0){
        int tmp=s-c*3;
        if(c==1) {
            sum++;
        }else{
            if(tmp==0){
                sum= (sum+1)%M;
                break;
            }
            sum= (sum+comb(tmp+c-1,tmp))%M;
        }
        c++;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  string S;
  cin >> S;

  long result = 0;

  for (long i = 0; i < N; i++) {
    string foo = S.substr(0, i);
    string bar = S.substr(i, N-i);

    set<char> fooset, barset;
    for (auto it: foo) fooset.insert(it);
    for (auto it: bar) barset.insert(it);

    long tmp = 0;
    for (auto it: fooset) if (barset.count(it)) tmp++;
    result = max(result, tmp);
  }

  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
priority_queue <int> pq;
int A, N, M;
 
int main () {
 
    cin >> N >> M;
    for (int i = 0; i < N; i++){
        cin >> A;
        pq.push(A);
    }
 
    for (int i = 0; i < M; i++){
        int X = pq.top();
        pq.pop();
        pq.push(X/2);
    }
  
  	long long cost = 0;
 
    while(!pq.empty()){
        cost += pq.top();
        pq.pop();
    }
 
    cout << cost << "\n";

    return 0;
 
}


Measured memory_bytes: 892
'''
Created on 2020/08/19

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N,A,B=map(int,pin().split())
  S=pin()[:-1]
  cnt=0
  cn=0
  for i in range(N):
    if S[i]=="a" and cnt<A+B:
      cnt+=1
      print("Yes")
    elif S[i]=="b" and cnt<A+B and cn<B:
      cnt+=1
      cn+=1
      print("Yes")
    else:
      print("No")
  return 

main()


Measured memory_bytes: 9164
package main

import "fmt"

func main() {
	// Code for B - Hina Arare
	var N int
	fmt.Scanf("%d", &N)
	var S string
	var flag int = 0

	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S)
		if S[0] == 'Y' {
			flag = 1
		}
	}

	if flag == 1 {
		fmt.Println("Four")
	} else {
		fmt.Println("Three")
	}
}


Measured memory_bytes: 1836
import collections
n=int(input())
l=list(input().split())
c=collections.Counter(l)
if n%2==0:
  f=all(x==2 for x in c.values())
else:
  g=c.pop("0")==1
  f=all(x==2 for x in c.values()) and g
print(2**(n//2)%1000000007 if f==True else 0)

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

int main(){

ll n;
cin>>n;
ll a[10005]={0};
for(ll i=1;i<=105;i++){
    for(ll j=1;j<=105;j++){
        for(ll k=1;k<=105;k++){
            ll v=i*i+j*j+k*k+i*j+i*k+j*k;
            if(v<10005)
                a[v]+=1;
        }
    }
}

for(ll i=1;i<=n;i++)
    cout<<a[i]<<"\n";
return 0;
}


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

int main(){
    int n;
    int A[100000];
    long long int width,height;
    long long int sum;

    cin>>n;

    for(int i=0;i<n;i++) cin>>A[i];

    sort(A,A+n);

    for(int i=0;i<n-1;i++){
        if(A[i+1]==A[i]){
            width=A[i];
        }
    }

for(int i=0;i<n-1;i++){
        if(A[i+1]==A[i]){
            if(A[i+1]!=width){
               height=A[i];
            }
            else if(A[i+3]==A[i+2]&&A[i+2]==A[i+1]){
                height=A[i];
            }
            
        }
    }

sum=width*height;

cout<<sum<<endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int a,b,c,d[100],e[3];
	for(int i=0;i<3;i++){
		e[i]=0;
	}
	cin>>a>>b>>c;
	for(int i=0;i<a;i++){
		cin>>d[i];
		if(b>=d[i]){
			e[1]++;
		}
		else if(c>=d[i]){
			e[2]++;
		}
		else{
			e[3]++;
		}
		}
		if(e[1]<=e[2]&&e[1]<=e[3])
			cout<<e[1]<<endl;
		
		else if(e[2]<=e[1]&&e[2]<=e[3])
			cout<<e[2]<<endl;
		
		else
			cout<<e[3]<<endl;
		
		return 0;
	}


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

ll dp[100005], cost[105], value[105];

int main(){
    ll n, w; scanf("%lld %lld", &n, &w);
    for(ll i = 1; i <= n; i++)
        scanf("%lld %lld", &cost[i], &value[i]);
    for(ll i = 1; i <= 1e5; i++)
        dp[i] = 1e15;
    
    for(ll i = 1; i <= n; i++)
        for(ll j = 1e5-value[i]; j >= 0; j--)
            dp[j+value[i]] = min(dp[j+value[i]], dp[j] + cost[i]);
    ll res = 0;
    for(ll i = 1; i <= 1e5; i++)
        if(dp[i] <= w)
            res = i;
    printf("%lld\n", res);
	return 0;
}


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

int main() {
  vector<int> s(3);
  cin >> s[0] >> s[1] >> s[2];
  sort(s.begin(), s.end());
  cout << ((s[0] == 5 && s[1] == 5 && s[2] == 7) ? "YES" : "NO") << endl;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    long long x = (long long)a * b * 4;
    long long y = (long long) c - a - b;
    y = y * y;
    if (c - a - b < 0) cout << "No" << endl;
    else if (x < y) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef pair<ll,int> LL_IP;

#define ARRAY_MAX 100005


int main(){

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n),b(n);
    map<ll,ll> mp;
    REP(i,n){
        cin >> a[i] >> b[i];
        mp[a[i]] += b[i];
    }
    
    ll cnt = 0,ans = 0;
    for(auto itr:mp){
        cnt += itr.second;
        //cout << cnt << endl;
        if(cnt >= k){
            ans = itr.first;
            break;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 5760
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

vector<vector<int>> adj;
vector<bool> vis;
vector<int> dis;

void dfs(int k){
    vis[k]=true;
    for(auto it: adj[k]){
        if(!vis[it]){
            dfs(it);
        }
        dis[k]=max(dis[k],dis[it]+1);//distance of node is one more then distance of chield
    }
}

signed main() {
   tezz
   
   int n,m,p,q;
   cin >> n >> m;
   adj=vector<vector<int>> (n);
   for(int i=0; i<m; i++){
       cin >> p >> q;
       p--;
       q--;
       adj[p].push_back(q);
   }
   vis = vector<bool> (n,false);
   dis = vector<int> (n,0);
   for(int i=0; i<n; i++){
       if(!vis[i]){
           dfs(i);
       }
   }
//   vis = vector<bool> (n,false);
//   for(int i=0; i<n; i++){
//       if(!vis[i]){
//           dfs(i);
//       }
//   }

   int ans=0;
   for(int i=0; i<n; i++){
       ans=max(ans,dis[i]);
       //cout << i+1 << "  -->  " << dis[i] << endl;
   }
   cout << ans << endl;
   

   return 0;
}


Measured memory_bytes: 8576
import java.util.*;

class Main {
    public static void main(String[] args) {
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         int b = scan.nextInt();

         if (a>b) System.out.println("a > b");
         else if (a<b) System.out.println("a < b");
         else System.out.println("a == b");

     }
}

Measured memory_bytes: 26032
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 1

#define lli unsigned long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

string operate(string str){
	char *tmpStr;
	lli size = str.size();
	tmpStr = new char[size];
	tmpStr[0] = str[size-1];
	for(int i=1;i<size;i++){
		tmpStr[i] = str[i-1];
	}
	string rStr(tmpStr);
	return rStr;
}

int eqaulC(char *a,char *b,int size){
	for(int i=0;i<size;i++){
		if(a[i]!=b[i]){
			return 0;
		}
	}
	return 1;
}

int main(){

	string s;
	string t;
	cin>>s>>t;

	char *cS,*cT;
	char *nextS;

	cS = new char[s.size()];
	cT = new char[s.size()];
	nextS = new char[s.size()];

	for(int i=0;i<s.size();i++){
		cS[i]=s[i];
		cT[i]=t[i];
		nextS[i]=s[i];
	}


	for(int i=0;i<s.size()*2;i++){
		//あってる?
		if(eqaulC(nextS,cT,s.size())) {
			cout<<"Yes"<<endl;
			return 0;
		}
		//操作
		nextS[0]=cS[s.size()-1];
		for(int j=1;j<s.size();j++){
			nextS[j] = cS[j-1];
		}
		for(int j=0;j<s.size();j++){
			cS[j]=nextS[j];
		}
	}

	cout<<"No"<<endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


// youtube editorial
// ゾロ目を列挙

void solve() {
    string s;
    cin >> s;
    
    rep(i, 9) {
        string t;
        rep(j, 3) t += '0' + i + 1;
        if (t >= s) {
            cout << t << endl;
            return;
        }
    }
    
}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}




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

int main(){
  int A,B; cin >> A >> B;
  int score = 0;
  if(A>B){
    score += A;
    A--;
  }
  else if(A<=B){
    score += B;
    B--;
  }
  if(A>B) score += A;
  else if(A<=B) score += B;
  
  cout << score << endl;
  
  return 0;
}

Measured memory_bytes: 256
// Example program
#include <iostream>
#include <string>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char s[20];
  cin.get(s,20);
  for(int i=1;i<=3;i++)
    if(s[i]==s[i-1])
        {
            cout<<"Bad";
            return 0;
        }
  cout<<"Good";
  return 0;
  
  
  
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll cmin = INF, cmax = -INF, sum = 0;
	REP(i, n) {
		ll a;
		cin >> a;
		cmin = min(cmin, a);
		cmax = max(cmax, a);
		sum += a;
	}
	cout << cmin << " " << cmax << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN];
string str;
int main()
{
    cin>>str;
    n=(int)str.size();
    int ans=1;
    int last=1,now=1;
    while(now<n)
    {
        if(last==2||str[now]!=str[now-1]) {last=1; now++; ans++;}
        else
        {
            last=2; now+=2;
            if(now<=n) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  string ans;
  rep(i,s.size()){
    if(s[i]=='1') ans.push_back('1');
    if(s[i]=='0') ans.push_back('0');
    if(s[i]=='B' && ans.size()>=1) ans.pop_back();
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#define maxn 200010
#define LL long long
using namespace std;
int a[maxn],n;
LL ans;
map<int,int> mp;
int main(){
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		if(i-a[i]>0)mp[i-a[i]]++;
	for(i=1;i<=n;i++)
		if(mp[a[i]+i])ans+=mp[a[i]+i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 14148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll>red(a);
    vector<ll>green(b);
    vector<ll>no;
    rep(i,a) cin >> red[i];
    rep(i,b) cin >> green[i];
    rep(i,c){
        ll r;
        cin >> r;
        no.push_back(r);
    }
    sort(all(red));
    sort(all(green));
    reverse(all(red));
    reverse(all(green));
    rep(i,x){
        no.push_back(red[i]);
    }
    rep(i,y){
        no.push_back(green[i]);
    }
    sort(all(no));
    reverse(all(no));
    ll ans=0;
    rep(i,x+y){
        ans+=no[i];
    }
    cout << ans << endl;
    return 0;
}


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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;


void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    vector<int> dp(n, INT_MAX);
    dp[0]=0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j < k+1; ++j) {
            if (i+j<n) {
                dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
            }
        }
    }

    dbg(dp);
    cout << dp[n-1] << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);
#define MAX 100000

static int a[MAX+1], b[MAX+1];

int main(void) {
	int A,B,M,i,min=MAX,tmp;
    int c[4],x,y;

	i_cin(A); i_cin(B); i_cin(M);
	x = min;
	for (i = 0; i < A; i++) {
		i_cin(a[i]);
		if (a[i] < x)x = a[i];
	}
	y = min;
	for (i = 0; i < B; i++) {
		i_cin(b[i]);
		if (b[i] < y)y = b[i];
	}

	min = MAX*2;
	for (i = 0; i < M; i++) {
		i_cins(3, c);
		tmp = a[c[0]-1] + b[c[1]-1] - c[2];
		if (min > tmp) min = tmp;
	}
	
	if (x+y < min) min = x+y;
	i_cout(min);
	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (100006)
ll n, s, ans;
vector<ll> v;
vector<pi> l, r;
int main(){
	FAST
	cin>>n>>s;
	FOR(i,1,n){
		ll x,p;
		cin>>x>>p;
		if(x < s) l.eb(x,p);
		else r.eb(x,p);
	}
	reverse(all(l));
	ll acc=0, p=0;
	while(l.size()||r.size()){
		if(l.empty()){
			v.eb(r.back().f), r.pop_back();
			continue;
		}
		if(r.empty()){
			v.eb(l.back().f), l.pop_back();
			continue;
		}
		if(p == 0){
			if(l.back().s < r.back().s){
				v.eb(l.back().f), acc += l.back().s, l.pop_back();
				p=1;
			}else{
				v.eb(r.back().f), acc += r.back().s, r.pop_back();
				p=2;
			}
		}else{
			if((p==1&&l.back().s<acc+r.back().s)||r.back().s>acc+l.back().s){
				v.eb(l.back().f), acc += l.back().s, l.pop_back();
				p=1;
			}else{
				v.eb(r.back().f), acc += r.back().s, r.pop_back();
				p=2;
			}
		}
	}
	while(v.size())ans+=llabs(s-v.back()),s=v.back(),v.pop_back();
	cout<<ans<<'\n';
} 


Measured memory_bytes: 6868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();//競技数
		int M = sc.nextInt();//委員の人数
		int A[] = new int[N];//費用
		int B[] = new int[M];//各委員の審査基準
		int Ap[] = new int[N];//人気競技への投票数
		int i,j;
		int result = 0;
		
		for(i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		for(j = 0; j < M; j++){
			B[j] = sc.nextInt();
		}
		
		for(j = 0; j < M; j++){
			for(i = 0; i < N; i++){
				if(A[i] <= B[j]){
					Ap[i]++;
					break;
				}
			}
		}
		
		int a = Ap[0];
		for(i = 1; i < N; i++){
			if(a < Ap[i]){
				a = Ap[i];
				result = i;
			}
		}
		System.out.println(result + 1);
	
	
	}
	

}

Measured memory_bytes: 25144
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int N,sea=1,MAXX;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N;i++) {
		cin >> H.at(i);
	}
	MAXX = H.at(0);
	for (int i = 1; i < N; i++) {
		if (MAXX <= H.at(i)) {
			sea++;
		}
		MAXX = max(H.at(i), MAXX);
	}

	cout << sea << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		
		boolean[][] bool = new boolean[H + 2][W + 2];
		String[] lines = new String[H];
		sc.nextLine();
		for (int i = 0; i < H; i++) {
			lines[i] = sc.nextLine();
		}
		
		String[][] grid = new String[H + 2][W + 2];
		for (int i = 0; i < H; i++){
			String line = lines[i];
			for (int j = 0; j < W; j++) {
				if (j == line.length() - 1) {
					grid[i + 1][j + 1] = line.substring(j);
				} else {
					grid[i + 1][j + 1] = line.substring(j, j + 1);
				}
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if ("#".equals(grid[i][j])) {
					if ("#".equals(grid[i + 1][j]) || "#".equals(grid[i - 1][j]) || "#".equals(grid[i][j + 1]) || "#".equals(grid[i][j - 1])) {
						bool[i][j] = true;
					}
				}
			}
		}
		boolean existsFalse = false;
		out:for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if ("#".equals(grid[i][j])) {
					if (!bool[i][j]) {
						existsFalse = true;
						break out;
					}
				}
			}
		}
		if (existsFalse) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23892
#include<cstring>
#include <limits.h>
#include<iostream>
#include<map>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin>>n;
	cin.ignore(256,'\n');
	string w[n];
	for (int i = 0; i < n; ++i)
	{
		/* code */
		getline(cin,w[i]);
	}

	map<string, int> m;
	char prev='~';
	int f = 0;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if(m.find(w[i])!=m.end()){
			f=1;
			cout << "No";
			break;
		}else{
			if(prev=='~'){
				prev = w[i][w[i].length()-1];
				m[w[i]] = 1;
			}else{
				if(prev != w[i][0]){
					f=1;
					cout << "No"<< endl;
					break;
				}
				else{
					m[w[i]] = 1;
					prev = w[i][w[i].length()-1];
				}
			}
		}
	}
	if(f==0)
		cout << "Yes"<< endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int minimumCost = Integer.MAX_VALUE;
			int stepCount = k;
			if(stepCount > i) {
				stepCount = i;
			}
			for(int j =1; j <= stepCount; j++ ) {
				int cost = minimumCostInfo[i-j] + Math.abs(stepInfo[i]-stepInfo[i-j]);
				if(cost < minimumCost) {
					minimumCost = cost;
				}
			}
			minimumCostInfo[i] = minimumCost;
		}

		System.out.println(minimumCostInfo[n-1]);

	}
}

Measured memory_bytes: 59328
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    ll o = 0, pr = 0;
    for(int q=0; q<a; q++){
        ll x; cin>>x;
        o += max(0LL, pr-x);
        pr = max(pr, x);
    }
    cout<<o;
}

Measured memory_bytes: 3656
//
// Created by yuu on 2019-04-16.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int A;
    cin>>A;
    vector<int> H;
    for (int i = 0; i < A; ++i) {
        int temp;
        cin>>temp;
        H.push_back(temp);
    }
    int ans = 0;
    int max=-1;
    for (int j = 0; j < H.size(); ++j) {
        if(max<=H[j]){
            ans++;
            max = H[j];
        }
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
using System;

class Program {
    static void Main() {
        var leftSight = new int[4];
        var rightSight = new int[4];
        for (string line; (line = Console.ReadLine()) != null;) {
            var l = line.Split(' ');
            var left = double.Parse(l[0]);
            var right = double.Parse(l[1]);

            leftSight[SightRank(left)]++;
            rightSight[SightRank(right)]++;
        }
        for (var i = 0; i < 4; i++) {
            Console.WriteLine(leftSight[i] + " " + rightSight[i]);
        }
    }

    static int SightRank(double sight) {
        if (sight >= 1.1)
            return 0;
        if (sight >= 0.6)
            return 1;
        if (sight >= 0.2)
            return 2;
        return 3;
    }
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 200003;
ll POW(ll a, ll b, ll MMM=MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

int a[200003],pos[200003];
void fft(vector<base> &a, bool inv){
	int n = a.size(), j = 0;
	vector<base> roots(n/2);
	for(int i=1; i<n; i++){
		int bit = (n >> 1);
		while(j >= bit){
			j -= bit;
			bit >>= 1;
		}
		j += bit;
		if(i < j) swap(a[i], a[j]);
	}
	double ang = 2 * acos(-1) / n * (inv ? -1 : 1);
	for(int i=0; i<n/2; i++){
		roots[i] = base(cos(ang * i), sin(ang * i));
	}
	for(int i=2; i<=n; i<<=1){
		int step = n / i;
		for(int j=0; j<n; j+=i){
			for(int k=0; k<i/2; k++){
				base u = a[j+k], v = a[j+k+i/2] * roots[step * k];
				a[j+k] = u+v;
				a[j+k+i/2] = u-v;
			}
		}
	}
	if(inv) for(int i=0; i<n; i++) a[i] /= n;
}
 
vector<ll> multiply(vector<ll> &v, vector<ll> &w){
	vector<base> fv(v.begin(), v.end()), fw(w.begin(), w.end());
	int n = 2; while(n < v.size() + w.size()) n <<= 1;
	fv.resize(n); fw.resize(n);
	fft(fv, 0); fft(fw, 0);
	for(int i=0; i<n; i++) fv[i] *= fw[i];
	fft(fv, 1);
	vector<ll> ret(n);
	for(int i=0; i<n; i++) ret[i] = (ll)round(fv[i].real());
	return ret;
}
int main(){
	a[0]=1;
	pos[1]=0;
	fup(i,1,MOD-1,1){
		a[i]=(a[i-1]<<1)%MOD;
		pos[a[i]]=i;
	}
	Vll v(MOD);
	int n;
	scanf("%d",&n);
	ll ans=0;
	fup(i,0,n-1,1){
		int x;
		scanf("%d",&x);
		ans-=(1LL*x*x)%MOD;
		if(x!=0)v[pos[x]]++;
	}
	Vll res=multiply(v,v);
	int cur=1;
	fup(i,0,(int)res.size()-1,1){
		ans+=res[i]*cur;
		cur=(cur<<1)%MOD;
	}
	printf("%lld\n",ans/2);
}

Measured memory_bytes: 27264
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long ll;



int main () {
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<int> arr(3,0);
    for(int i=0;i<s.size();i++)
    {
        arr[s[i]-'a']++;
    }
    int mini=*min_element(arr.begin(), arr.end());
    arr[0]-=mini;
    arr[1]-=mini;
    arr[2]-=mini;
    if(arr[0]>1 ||arr[1]>1||arr[2]>1)
        cout<<"NO";
    else
        cout<<"YES";
   
    return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int d[10];
	for (int i = 0; i < k; i++)cin >> d[i];

	int ans = 0;
	while (!ans) {
		int a = n;
		int flg = 1;
		string s = to_string(a);
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < k; j++) {
				char c = '0' + d[j];
				if (s[i] == c)flg = 0;
			}
		}
		if (flg)ans = n;
		n++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>

using namespace std;

#define MAX 1000000
int p[MAX];

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b - a <= 0) {
	cout << "delicious" << endl;
  }
  else if (b - a >= x + 1) {
	cout << "dangerous" << endl;
  }
  else {
	cout << "safe" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc084_b();
        }

        static void abc084_b()
        {
            // B - Postal Code
            int[] digits = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            string code = Console.ReadLine().Trim();
            bool valid = true;
            double num;
            if (! double.TryParse(code.Substring(0, digits[0]), out num)) valid = false;
            if (! code.Substring(digits[0], 1).Equals("-")) valid = false;
            if (! double.TryParse(code.Substring(digits[0]+1), out num)) valid = false;
            if (valid) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

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

typedef long long ll;

ll n,p[200010];
pair<ll,ll> v[200010],u[200010];
vector<pair<ll,pair<ll,ll> > > vec;

inline ll Find(ll x)
{
	return p[x]==x?x:p[x]=Find(p[x]);
}

inline ll unite(ll x,ll y)
{
	ll fx=Find(x),fy=Find(y);
	if(fx==fy) return true;
	else{p[fx]=fy;return false;}
}

int main()
{
	cin>>n;
	for(ll i=1;i<=n;i++) scanf("%I64d%I64d",&v[i].first,&u[i].first);
	for(ll i=1;i<=n;i++) v[i].second=i,u[i].second=i;
	sort(v+1,v+n+1);
	sort(u+1,u+n+1);
	for(ll i=2;i<=n;i++){
		ll vcost=v[i].first-v[i-1].first;
		ll ucost=u[i].first-u[i-1].first;
		vec.push_back(make_pair(vcost,make_pair(v[i].second,v[i-1].second)));
		vec.push_back(make_pair(ucost,make_pair(u[i].second,u[i-1].second)));
	}
	for(ll i=1;i<=n;i++) p[i]=i;
	ll road=0,sum=0;
	sort(vec.begin(),vec.end());
	for(ll i=0;i<vec.size()&&road<n-1;i++){
		if(unite(vec[i].second.first,vec[i].second.second)) continue;
		sum+=vec[i].first;
		road++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 14192