akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define Re register
#define pb push_back
#define F first
#define S second
#define ll long long
#define lowbit(x) (x & -x)
#define N 100005
ll n, ans;
struct node {
    ll a, b;
    friend bool operator < (node a, node b)
    {
        return a.a + a.b > b.a + b.b;
    }
}t[N];
int main ()
{
    scanf("%lld", &n);
    fo (i, 1, n) scanf("%lld %lld", &t[i].a, &t[i].b);
    std::sort(t + 1, t + n + 1);
    fo (i, 1, n)
    {
        if (i & 1)
            ans = ans + t[i].a;
        else
            ans = ans - t[i].b;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 1e9+7, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;
 
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */

int n, a[101];
vector<int> segs;
int main() {
	iostream_optimize();
	cin >> n;
	fori(i, 0, n-1) cin >> a[i];
	int last = 0;
	fori(i, 1, n-1) {
		if(a[i] != a[last]) segs.pb(i-last), last = i;
	}
	segs.pb(n - last);
	int ans = 0;
	foreach(x, segs) ans += x/2;
	cout << ans;
}

Measured memory_bytes: 256
#from math import * 
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)

ans=1
for _ in range(int(input())):
    ans=lcm(ans,int(input()))
print(ans)

Measured memory_bytes: 3060
<?php
$bingo = false;
$ans = [];
$nums[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
$nums[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
$nums[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
for ($i = 0; $i < 3; $i++) {
    $ans[$i] = [];
    foreach ($nums[$i] as $value) {
        $ans[$i][$value] = 0;
    }
}

fscanf(STDIN, '%d', $cnt);
for ($i = 0; $i < $cnt; $i++) {
    fscanf(STDIN, '%d', $ball);
    for ($j = 0; $j < 3; $j++) {
        foreach ($ans[$j] as $key => $value) {
            if ($ball === $key) {
                $ans[$j][$key] = 1;
            }
        }
    }
}
for ($i=0; $i < 3; $i++) { 
    $ans[$i] = array_values($ans[$i]);
}
if (array_sum($ans[0]) === 3 || array_sum($ans[1]) === 3 || array_sum($ans[2]) === 3) {
    $bingo = true;
} elseif ($ans[0][0] + $ans[1][0] + $ans[2][0] === 3 || $ans[0][1] + $ans[1][1] + $ans[2][1] === 3 || $ans[0][2] + $ans[1][2] + $ans[2][2] === 3) {
    $bingo = true;
} elseif ($ans[1][1] === 1 && (($ans[0][0] === 1 && $ans[2][2] === 1) || ($ans[0][2] === 1 && $ans[2][0] === 1))) {
    $bingo = true;
}
echo $bingo ? "Yes" : "No";
echo "\n";


Measured memory_bytes: 4604
from itertools import combinations_with_replacement as comb_rplc
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
	a[i],b[i],c[i],d[i]=map(int,input().split())
ans=0

def dfs(A):
	ans=0
	if len(A)==n:#数列が完成
		score1=0
		for i in range(q):
			if A[b[i]-1]-A[a[i]-1]==c[i]:
				score1+=d[i]
		return score1
	else:
		for i in range(A[-1],m+1):
			A_next=A+(i,)
			score=dfs(A_next)
			ans=max(ans,score)
	return ans
	
score=dfs((1,))
ans=max(ans,score)
print(ans)

Measured memory_bytes: 9196
#include<stdio.h>
#include<math.h>
#define N 10000

int prime(int);

int main()
{
  int A[N], i, p, number, count=0;
  scanf("%d", &number);
  for( i=0 ; i<number ; i++ ){
    scanf("%d", &A[i]);
    p = prime(A[i]);
    if( p==1 ) count++;
  }
  
  printf("%d\n", count);
  return 0;
}
int prime(int a)
{
  int i;
  if( a==2 ) return 1;
  if( a<2 || a%2==0 ) return 0;
  i = 3;
  while( i<=sqrt(a) ){
    if( a%i==0 ) return 0;
    i = i+2;
  }
  return 1;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 200011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n, Ans, Xor, Sum, a[N];
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i] = read();
		for (int l = 1, r = 1; l <= n; ++l) {
			if (l > r) ++r, Sum = Xor = 0;
			else Sum -= a[l - 1], Xor ^= a[l - 1];
			if (l == r) Sum = Xor = a[l];
			while (r <= n) {
				++r;
				if ((Sum + a[r]) ^ (Xor ^ a[r])) 
					{--r; break;} 
				Sum += a[r], Xor ^= a[r];
			}
			if (r > n) --r;
			Ans += (r - l + 1);
		} return wln(Ans), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 1792
N, K = map(int, input().split())
H = [int(x) for x in input().split()]

dp = [10**20] * N  # dp[i]: 足場i+1に到達するための最小コスト
dp[0] = 0
for i in range(N-1):
    for j in range(1, K+1):
        if i+j <= N-1:
            dp[i+j] = min(dp[i+j], dp[i]+abs(H[i+j]-H[i]))

answer = dp[-1]
print(answer)


Measured memory_bytes: 53728
n = int(input())

dp = [[0]*n for i in range(3)]
for i in range(n):
    if i==0:
        dp[0][0], dp[1][0], dp[2][0] = map(int, input().split())
        continue
    a, b, c = map(int, input().split())
    dp[0][i] = max(dp[1][i-1]+a, dp[2][i-1]+a)
    dp[1][i] = max(dp[0][i-1]+b, dp[2][i-1]+b)
    dp[2][i] = max(dp[0][i-1]+c, dp[1][i-1]+c)
    
print(max(dp[0][n-1], dp[1][n-1], dp[2][n-1]))

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

int extgcd(int a, int b, int& x, int& y){
	  int d = a;
	  if(b!=0) {
			d = extgcd(b,a%b,y,x);
			y -= (a/b)*x;
	  }
	  else{
			x = 1; y = 0;
	  }
	  return d;
}

int main(){
	  int a,b;
	  cin >> a >> b;
	  int x,y;
	  extgcd(a,b,x,y);
	  cout << x << " " << y << endl;

}

Measured memory_bytes: 1164
import sys

n = int(input())
data = [tuple(map(int, input().split())) for i in range(n)]

for d in data:
    if d[2] != 0:
        _x = d[0]
        _y = d[1]
        _h = d[2]

for x in range(101):
    for y in range(101):
        h = _h + abs(_x-x) + abs(_y-y)
        for d in data:
            tmp_x = d[0]
            tmp_y = d[1]
            tmp_h = d[2]
            if tmp_h != max(h - abs(tmp_x-x) - abs(tmp_y-y), 0):
                break
        else:
            print(x, y, h)
            sys.exit(0)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
string s;
int main() {
	cin >> s;
	int numberofC = 0;
	bool possible = true;
	for (int i = 2; i < s.length() - 1; i++) {
		if (s[i] == 'C')
			numberofC++;
	}
	for (int i = 1; i < s.length(); i++) {
		if (!(s[i] >= 97 && s[i] <= 122) && s[i] != 67) {
			possible = false;
		}
	}
	if (numberofC == 1 && s[0] == 'A' && possible)
		cout << "AC\n";
	else cout << "WA\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 1e5;
int a[N];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int jug = 0;
    if (sum % (4 * m) == 0)
    {
        jug = sum / (4 * m);
    }
    else
    {
        jug = sum / (4 * m) + 1;
    }
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] >= jug)
        {
            count++;
        }
    }
    if (count < m)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }
    return 0;
}

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

int main(){
   int num1,num2,num3;
   cin >> num1 >> num2 >> num3;

   if (num1<num2 && num2<num3){
      cout << "Yes\n";
   }
   else{
      cout << "No\n";
   }

   return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  ll x, y;
  cin >> x >> y;
  ll tmp = x;
  ll ans = 0;
  while(tmp <= y){
    tmp = tmp + tmp;
    ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long
using namespace std;
int mod = 1e9+7;
int f[200005];
int mult(int x,int y){
    return ((x % mod) * (y % mod)) % mod;
}
int sub(int x,int y){
    int fi = x%mod;
    int yi = y%mod;
    fi-=yi;
    while(fi <0)
        fi+=mod;
    fi%=mod;
return fi;
}
int fastpow(int x,int y){
if(!y)return 1LL;
if(y == 1)  return x%mod;
int cur = fastpow(x,y/2);
cur%=mod;
cur = ((cur % mod) * (cur % mod))%mod;
if(y & 1)cur = ((cur % mod) * (x % mod) )%mod;
return cur;

}
int inverse(int x){
    return fastpow(x,mod-2);
}
int c(int x,int y){
    if(x < 0 || y < 0 || y > x)   return 0L;
    return mult(f[x],inverse(mult(f[y],f[x-y])));
}
int solv(int x,int y){
    int cur = 1,bot = 1;
    for(int i = 1; i<=y; i++,x--)
        cur = mult(cur,x),bot = mult(bot,i);
        bot = inverse(bot);
     return mult(cur,bot);
}
 main()
{
    int n,a,b;
    cin>>n>>a>>b;
    f[0] = 1;
    for(int i = 1; i<=2e5; i++)
        f[i] = ((f[i-1] % mod) * (i % mod))%mod;

    int ans = fastpow(2,n)- 1LL;
    ans%=mod;
    ans = sub(ans,solv(n,a));
    ans = sub(ans,solv(n,b));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> vec(10);
    rep(i,K){
        int D;
        cin >> D;
        vec[D]++;
    }
    int ans = 100000;
    for (int i = N; i < 100000; i++){
        bool possible = true;
        if (vec[0] == 1){
            if (i % 10 == 0) possible = false;
            if (i >= 10){
                if ((i / 10) % 10 == 0) possible = false;
            }
            if (i >= 100){
                if ((i / 100) % 10 == 0) possible = false;
            }
            if (i >= 1000){
                if ((i / 1000) % 10 == 0) possible = false;
            }
        }
        for (int j = 1; j <= 9; j++){
            if (vec[j] == 1){
                if (i % 10 == j) possible = false;
                if ((i / 10) % 10 == j) possible = false;
                if ((i / 100) % 10 == j) possible = false;
                if ((i / 1000) % 10 == j) possible = false;
                if ((i / 10000) % 10 == j) possible = false;
            }
        }
        if (possible){
            ans = min(ans,i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int num[10] = {100, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[10050];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	rep(i,m) cin >> a[i];
	sort(a.rbegin(), a.rend());
	rep(i,n+1){
		dp[i] = -1e9;
	}
	dp[0] = 0;
	rep(i,n){
		rep(j,m){
			chmax(dp[i+num[a[j]]], dp[i] + 1);
		}
	}
	vector<int> ans;
	int p = n;
	while(p > 0){
		rep(i,m){
			if(p >= num[a[i]] && dp[p - num[a[i]]] == dp[p] - 1){
				ans.push_back(a[i]);
				p -= num[a[i]];
				break;
			}
		}
	}
	sort(ans.rbegin(), ans.rend());
	for(auto q : ans){
		cout << q;
	}
	cout << endl;
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    ll l,r;
    vll X(N);
    Rep(i,N){
        Scll2(l,r);
        X[i].first = l+r;
        X[i].second = l-r;
    }

    sort(X.begin(),X.end());

    int ans = 0;
    ll len = -INF;
    Rep(i,N){
        if( X[i].second >= len ) {
            len = X[i].first;
            ans++;
        }
    }

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

    return 0;
}



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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (i == 0) ans *= k;
    else ans *= (k-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
l=[input() for i in range(n)]
target_song = input()

total = 0

ff = False

for i in l:
    s, t = i.split(" ")

    if s == target_song:
        ff = True
        continue
        
    if ff == True:
        total +=  int(t)

print(total)



Measured memory_bytes: 2940
// C++ program to compute LCM of array elements modulo M 
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 

typedef long long ll; 
const int mod = 1000000007; 

int prime[MAX]; 
unordered_map<ll, ll> max_map; 

// Function to return a^n 
ll power(ll a, ll n) 
{ 
	if (n == 0) 
		return 1; 
	ll p = power(a, n / 2) % mod; 
	p = (p * p) % mod; 
	if (n & 1) 
		p = (p * a) % mod; 
	return p; 
} 

// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
	prime[0] = prime[1] = 1; 
	for (int i = 2; i < MAX; i++) { 
		if (prime[i] == 0) { 
			for (int j = i * 2; j < MAX; j += i) { 
				if (prime[j] == 0) { 
					prime[j] = i; 
				} 
			} 
			prime[i] = i; 
		} 
	} 
} 

// Function to return the LCM modulo M 
ll lcmModuloM(const ll* ar, ll n) 
{ 

	for (int i = 0; i < n; i++) { 
		ll num = ar[i]; 
		unordered_map<ll, ll> temp; 

		// Temp stores mapping of prime factor to 
		// its power for the current element 
		while (num > 1) { 

			// Factor is the smallest prime factor of num 
			int factor = prime[num]; 

			// Increase count of factor in temp 
			temp[factor]++; 

			// Reduce num by its prime factor 
			num /= factor; 
		} 

		for (auto it : temp) { 

			// Store the highest power of every prime 
			// found till now in a new map max_map 
			max_map[it.first] = max(max_map[it.first], it.second); 
		} 
	} 

	ll ans = 1; 

	for (auto it : max_map) { 

		// LCM is product of primes to their highest powers modulo M 
		ans = (ans * power(it.F, it.S)) % mod; 
	} 

	return ans; 
} 

// Driver code 
int main() 
{ 
	sieve(); 
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	//cout << lcmModuloM(a, n); 
	ll l = lcmModuloM(a,n);
	ll sum=0;
	for(int i=0;i<n;i++)
	{
	    sum = (sum+l*power(a[i],mod-2))%mod;
	}
	cout<<sum<<endl;
	return 0; 
} 


Measured memory_bytes: 39808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
#define range(i,s,c) for(ll i=(s);i<(s+c);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main()
{
	in(n);
	ins(s);
	char ch=0;
	ll ans = 0;
	rep(i,n){
		if(ch!=s[i]){
			ch = s[i];
			ans++;
		}
	}
	out(ans);
}

Measured memory_bytes: 512
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  string s; cin >>s; int ans;
  vector<string> v={"SAT","FRI","THU","WED","TUE","MON","SUN"};
  rep(i,7) if(s==v.at(i))ans=i+1;
  cout << ans;

}

/// confirm df==0 ///


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#include<stdio.h>

int main() {
	int n, i, x, j = 0, min;
	long long int y[1000];
	scanf("%d", &n);

	for (j = -100;j <= 100;j++)y[j + 100] = 0;

	for (i = 0;i < n;i++) {
		scanf("%d", &x);
		for (j = -100;j <= 100;j++) {
			y[j + 100] += (x - j)*(x - j);

		}

	}

	y[999] = 9999999999;
	min = 999;
	for (j = -100;j <= 100;j++) {
		if (y[min] > y[j + 100]) {
			min = j + 100;

		}

	}

	printf("%d\n", y[min]);

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func check(s string) bool {
	x, _ := strconv.Atoi(s)
	return 1 <= x && x <= 12
}

func main() {
	var s string
	fmt.Scan(&s)
	a := s[:2]
	b := s[2:]

	aa, bb := check(a), check(b)
	if aa && bb {
		fmt.Println("AMBIGUOUS")
	} else if aa {
		fmt.Println("MMYY")
	} else if bb {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 512
#-*- coding: utf-8 -*-#
n, y = map(int,input().split())  # お札の枚数と合計金額の変数を作る 
a = -1  # 10000円札の枚数を入れる変数を作る 
b = -1  # 5000円札の枚数 
c = -1  # 1000円札の枚数 
for i in range(n+1):     
    for g in range(n+1):
        if y == 10000*i + 5000*g + 1000*(n - i - g) and n - i - g >= 0:
            a = i             
            b = g        
            c = n - i - g   
print (a,b,c) 


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

int main() {
  string s;
  cin >> s;
  int n = sz(s);
  int count=0;
  vector<char> vec(n);
  rep(i,n){
    vec[i] = s[i];
  }
  rep(i,n-1){
    if(s[i]==s[i+1]){
      if(i==n-3){
        i += 2;
        count += 1;
      }else if(i==n-2){
        i += 2;
      }else{
        i += 2;
        count += 2;
      }
    }else{
      count++;
    }
  }
  cout << count+1 << endl;
  return 0;
}

Measured memory_bytes: 772
#include<stdio.h>
int main(){
	long long a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	if(a<=b)printf("1\n");
	else if(b<=c)printf("-1\n");
	else	printf("%lld\n",(a-b-1)/(b-c)*2+3);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int count = 0;
    for(int i = 0;i<s.length();i++){
      if(s.substring(i,i+1).equals(t.substring(i,i+1))){

      }else{
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 55180
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long long dp[1010][1010],x[1010],y[1010],z[1010];

int main(){
	int i,j,k,l,v,u,n,m;
	long long a[2] = {-1,1},b[2] = {-1,1},c[2] = {-1,1};
	
		cin >> n >> m;
	for(i=1;i<=n;i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	
	long long ans=0;
	
	for(l=0;l<2;l++){
		for(k=0;k<2;k++){
			for(v=0;v<2;v++){
				for(u=0;u<=n;u++){
					dp[u][0] = 0;
				}
				for(i=1;i<=n;i++){
					for(j=1;j<=m;j++){
						if(j<i){
							dp[i][j] = max(dp[i-1][j],dp[i-1][j-1]+a[l]*x[i]+b[k]*y[i]+c[v]*z[i]);
						}else{
							dp[i][j] = dp[i-1][j-1] + a[l]*x[i]+b[k]*y[i]+c[v]*z[i];
						}
					}
				}
				ans = max(ans,dp[n][m]);
			}
		}
	}
	
	ans = max(ans,dp[n][m]);
	
	
	
	cout << ans << endl;
}
	

Measured memory_bytes: 8192
s = input()
s = s[::-1]
while s != "":
    if s[:5] == "esare" or s[:5] == "maerd":
        s = s[5:]
    elif s[:6] == "resare":
        s = s[6:]
    elif s[:7] == "remaerd":
        s = s[7:]
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
struct node{
	int to,nxt;
	int w;
}e[maxn];
int head[maxn];
int ans[maxn];
int cnt;
void add(int u,int v,int w){
	e[++cnt]=(node){v,head[u],w};
	head[u]=cnt;
}
void dfs(int u,int fa){
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa)
			continue;
		if(e[i].w%2)
			ans[v]=ans[u]^1;
		else ans[v]=ans[u];
		dfs(v,u);
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i,u,v,w;i<n-1;i++){
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
		add(v,u,w);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 9620
N = int(input())
H = list(map(int, input().split()))
# print(N, H)

if N == 1:
    print('Yes')
    exit()

s = H[0]
for i in range(1, N):
    h = H[i]
    if s <= h:
        s = h
    else:
        if s - h > 1:
            # print(i, s, h)
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 63856
x = gets.chomp.to_i

i = 0

arr = []

while 1
  num = i ** 5
  arr << [num, i]
  arr << [-1 * num, -1 * i]
  break if num > 10**18
  i += 1
end


n = arr.size

n.times do |i|
  n.times do |j|
    if arr[i][0] - arr[j][0] == x
      puts "#{arr[i][1]} #{arr[j][1]}"
      exit
    end
  end
end


Measured memory_bytes: 14632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll X, Y, Z;
  cin >> X >> Y >> Z;

  cout << Z << " " << X << " " << Y << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[10];
int v1,v2;
int main(){
	while(~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",a,a+1,a+2,a+3,a+4,a+5,a+6,a+7,a+8,a+9,&v1,&v2)){
		int s=0;
		for(int i=0;i<10;i++)s+=a[i];
		double t=(double)s*(double)(v1)/(double)(v1+v2);
		double now=0;
		int ret=1;
		for(int i=0;i<10;i++){
			now+=a[i];
			if(now<t)ret++;
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, C = MAP()
L = [LIST() for i in range(N)]
# oa, ob
A = [0] * N
B = [0] * N

X = []
V = []
for x, v in L:
    X.append(x)
    V.append(v)

tmp_v = 0
for i in range(N):
    tmp_v += V[i]
    A[i] = tmp_v - X[i]

tmp_v = 0
for i in range(N-1, -1, -1):
    tmp_v += V[i]
    B[i] = tmp_v - (C - X[i])

gA = [0] * N
gA[0] = A[0]

for i in range(1, N):
    gA[i] = max(gA[i-1], A[i])

gB = [0] * N
gB[N-1] = B[N-1]

for i in range(N-2, -1, -1):
    gB[i] = max(gB[i+1], B[i])

a = max(A)
b = max(B)
c, d = 0, 0
if N > 1:
    c = max([A[i] - X[i] + gB[i+1] for i in range(0, N-1)])
    d = max([B[i] - (C - X[i]) + gA[i-1] for i in range(N-1, 0, -1)])    
print(max(a, b, c, d, 0))

Measured memory_bytes: 45560
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int n;  cin >> n;
  vi vec(n), cache(n);
  REP(i, n) {
    cin >> vec[i];
    cache[i] = vec[i];
  }
  sort(ALL(cache));
  REP(i, n){
    if(vec[i]==cache[n-1])  cout << cache[n-2] << endl;
    else cout << cache[n-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, l;
  cin>>n>>l;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  bool ans = false;
  int s = -1;
  for(int i=0;i<n-1;i++) if(a[i]+a[i+1]>=l) ans = true, s = i;
  if(ans) {
    cout<<"Possible"<<endl;
    for(int i=1;i<=s;i++) cout<<i<<endl;
    for(int i = n-1;i>=s+2;i--) cout<<i<<endl;
    cout<<s+1<<endl;
  }
  else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S;cin>>S;

  int ans=INF;
  REP(i,0,S.size()-2){
      int target=stol(S.substr(i,3));
      ans=min(ans,abs(target-753));
  }
  print(ans);

}


Measured memory_bytes: 256
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans1 = a * x + b * y
    ans2 = -1
    if x < y:
        ans2 = 2 * c * x + b * (y - x)
    else:
        ans2 = 2 * c * y + a * (x - y)
    ans3 = 2 * c * max(x, y)
    print(min(ans1, ans2, ans3))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61960
#include<stdio.h>
int main(void){
int i;
int count = 0;
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
for(i = a;i <= b;i++){
	if(c % i == 0){
		count++;
	}
}
printf("%d\n",count);
return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int H, W, N;
    cin >> H >> W >> N;
    cout << min((N+H-1)/H, (N+W-1)/W) << endl;
}

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

void lcs(char s[], char t[], int m, int n)
{
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int index= dp[m][n];
   // cout<<" length "<<dp[m][n]<<endl;
    char l[index+1];
    l[index] = '\0';
    
    int i,j;
    i=m,j=n;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            l[index-1]=s[i-1];
            //cout<<s[i-1]<<" "<<t[j-1]<<endl;
            i--;
            j--;
            index--;
        }
        else if(dp[i][j-1]>dp[i-1][j])
            j--;
        else
            i--;
    }
    cout<<l<<endl;
}

int main()
{
    char s[3010], t[3010];
    cin>>s>>t;
    int m,n;
    m=strlen(s);
    n=strlen(t);
    
    lcs(s,t,m,n);
    
    return 0;
    
    
}

Measured memory_bytes: 35456
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	int a[105];
	memset(a, 0, sizeof(a));
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n-2; i++)
	{
		for (int j = i + 1; j <= n - 1; j++)
		{
			if (a[i] == a[j])continue;
			int k = n;
			while (a[i] + a[j] <= a[k])k--;
			while (k > j)
			{
				if (a[k] == a[j])
				{
					k--;
					continue;
				}
				k--;
				ans ++;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
//#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect 

string s;

void solve(int lst, int n) {
    if (n == s.size()) {
        cout << s << "\n";
        return;
    }
    loop(i, lst) {
        s.pb('a' + i);
        solve(lst, n);
        s.pop_back();
    }
    s.pb('a' + lst);
    solve(lst + 1, n);
    s.pop_back();
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    int n; cin >> n; solve(0, n);
    return 0;
}


Measured memory_bytes: 1536
import heapq
from collections import defaultdict

INF = 10 ** 16

class edge:
    def __init__(self, to, yen, snuuk):
        self.to = to
        self.cost = [yen, snuuk]

def main():
    mon = 10 ** 15
    N, M, S, T = (int(_) for _ in input().split())
    E = defaultdict(list)
    for _ in range(M):
        u, v, a, b = (int(_) for _ in input().split())
        E[u].append(edge(v, a, b))
        E[v].append(edge(u, a, b))

    def dijkstra(s, y):
        que = list()
        heapq.heapify(que)
        newd = [INF] * (N+1)
        newd[s] = 0
        heapq.heappush(que, [newd[s], s])

        while que:
            p = heapq.heappop(que)
            v = p[1]
            if newd[v] < p[0]: continue
            for e in E[v]:
                if newd[e.to] > newd[v] + e.cost[y]:
                    newd[e.to] = newd[v] + e.cost[y]
                    heapq.heappush(que, [newd[e.to], e.to])
        return newd

    ds = dijkstra(S, 0)
    dt = dijkstra(T, 1)
    output = []
    ret = -1
    for i in range(1, N+1)[::-1]:
        ret = max(ret, mon - (ds[i] + dt[i]))
        output.append(ret)
    print(*output[::-1], sep='\n')
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 102808
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;


int main() {
  ll n; cin >> n;
  Vl v1(n/2), v2(n/2);
  rep(i, 0, n/2){
    cin >> v1[i] >> v2[i];
  }
  map<ll, ll> ma1, ma2;
  rep(i, 0, n/2){
    ma1[v1[i]]++;
    ma2[v2[i]]++;
  }
  set<ll> se1, se2;
  rep(i, 0, n/2){
    se1.insert(v1[i]);
    se2.insert(v2[i]);
  }
  vector<pair<ll, ll>> w1 = {}, w2 = {};
  for(auto se : se1){
    w1.push_back(make_pair(ma1[se], se));;
  }
  for(auto se : se2){
    w2.push_back(make_pair(ma2[se], se));
  }
  sort(ALL(w1), greater<pair<ll, ll>>());
  sort(ALL(w2), greater<pair<ll, ll>>());

  if(w1[0].second != w2[0].second){
    cout << n - w1[0].first - w2[0].first << endl;
  }else{
    cout << min(n-w1[0].first-w2[1].first, n-w1[1].first-w2[0].first) << endl;
  }



  return 0;
}


Measured memory_bytes: 14324
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, a int
	n = nextInt()
	set := make(map[int]struct{})
	dame := make(map[int]struct{})
	for i := 0; i < n; i++ {
		a = nextInt()
		if _, ok := set[a]; ok {
			dame[a] = struct{}{}
			continue
		}
		set[a] = struct{}{}
	}

	keys := make([]int, len(set))
	i := 0
	for key := range set {
		keys[i] = key
		i++
	}
	sort.Ints(keys)
	set = make(map[int]struct{})
	for _, key := range keys {
		set[key] = struct{}{}
	}

	for x := range set {
		if _, ok := dame[x]; ok {
			delete(set, x)
		}
		for i := 2; x*i < 1000005; i++ {
			delete(set, x*i)
		}
	}

	fmt.Println(len(set))
}


Measured memory_bytes: 14824
#include <stdio.h>

int LinearSearch(int *X, int n, int key)
{
  int i = 0;
  X[n] = key;
  while(X[i] != key) i++;
  if(i != n) return 1;
  else return 0;
}

int main()
{
  int i, n, S[10000+1], q, T[500], C = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
    if(LinearSearch(S, n, T[i]) == 1) C++;
    else ;
  }

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  string s;
  cin>>s;
 
  int c[256]={},ans=0;
  for(int i=0;i<s.size();i++){
    c[s[i]]++;
  }
 
  for(int i='a';i<='z';i++)
    ans+=(c[i])%2;
 
  cout<<ans/2<<endl;
 
  return 0;
}

Measured memory_bytes: 3192
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

op = ['+', '-']

def check(A, B, C, D):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x = A+op[i]+B+op[j]+C+op[k]+D
                if eval(x) == 7:
                    return x

print(check(A, B, C, D)+'=7')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24460
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

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

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

const int MX=1e5+10;
int V,E; 
int memo[MX];
vi adj[MX];


int solve(int i){
	if(memo[i]!=-1) return memo[i];
	int ans=0;
	for(auto j: adj[i]) ans=max(ans,solve(j)+1);
	return memo[i]=ans;
}

int32_t main(){
   boost;
   IO();

   memset(memo,-1,sizeof(memo));
   /*cin>>N>>W;
   for(int i=0; i<N;i++) cin>>w[i]>>v[i];

   for(int i=100000; i>=0; i--) if(solve(0,i)<=W){cout << i << endl; return 0;}*/

   cin>>V>>E;
   for(int i=0; i<E; i++){
   	int u,v; cin>>u>>v;
   	adj[u].pb(v);
   }

   int ans=0;
   for(int i=1; i<=V; i++) ans=max(ans,solve(i));
   cout << ans << endl;


   return 0;
}



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

namespace abc129
{
    class A
    {
        static void Main(string[] args)
        {
            var input = Input.IntArray();
            int P = input[0];
            int Q = input[1];
            int R = input[2];

            int res = 0;

            if (P > Q) {
                res += Q;
                if (P > R) {
                    res += R;
                } else {
                    res += P;
                }
            } else {
                res += P;
                if (Q > R) {
                    res += R;
                } else {
                    res += Q;
                }
            }

            Console.WriteLine(res);
        }

        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] charArray() => Input.Str().ToCharArray();
        }

    }
}

Measured memory_bytes: 13268
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K = ir()
A = lr()[::-1]
left = 2
right = 2
for x in A:
    left += (-left) % x
    right -= right % x
    right += x - 1

if left > right:
    print(-1)
else:
    print(left, right)
# 05


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

typedef vector<ll> vec;
typedef vector<vec> mat;

mat operator*(const mat& a,const mat& b){
  mat res(3,vec(3,0));
  rep(i,3)rep(j,3)rep(k,3)(res[i][j]+=a[i][k]*b[k][j]%mod)%=mod;
  return res;
}

mat mpow(mat a,ll n){
  mat res(3,vec(3,0));
  rep(i,3)res[i][i]=1;
  while(n>0){
    if(n&1)res=res*a;
    a=a*a;
    n>>=1;
  }
  return res;
}

ll n,m;
ll X[100010];

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

  cin>>n>>m;
  repl(i,1,m+1){
    cin>>X[i];
  }
  X[m+1]=n; m+=2;

  mat m1(3,vec(3,0)),m2(3,vec(3));
  m1[0][0]=2; m1[0][1]=1; m1[0][2]=1;
  m1[1][0]=2; m1[1][1]=1; m1[1][2]=0;
  m1[2][0]=1; m1[2][1]=1; m1[2][2]=1;

  m2[0][0]=1; m2[0][1]=0; m2[0][2]=0;
  m2[1][0]=2; m2[1][1]=1; m2[1][2]=0;
  m2[2][0]=1; m2[2][1]=1; m2[2][2]=1;

  mat res(3,vec(3,0));
  rep(i,3)res[i][i]=1;
  rep(i,m-1){
    mat p=mpow(m1,X[i+1]-X[i]-1);
    res=res*p;
    if(i<m-2)res=res*m2;
  }
  ll ans=0;
  rep(i,3)(ans+=res[i][0])%=mod;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if(n*a>b)
	{
		cout<<b<<endl;
		return 0;
	}
	else
	{
		cout<<n*a<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll X; cin >> X;
	
	ll A, B;
	ll n = sqrt(X);
	for (A = -120; A <= 120;A++) {
		for (B = -120; B <= 120; B++) {
			if (pow(A, 5) - pow(B, 5) == X) {
				cout << A << " " << B <<  endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 11032
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    string ss;
    cin >> ss;
    ss.replace(5, 1, " ");
    ss.replace(13, 1, " ");
    cout << ss << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
d = [[] for _ in range(N+1)]
for i in range(M):
    P, Y = map(int, input().split())
    d[P].append((Y, i))

dd = [""] * M

for P in range(1, N + 1):
    j = 1
    for (Y, i) in sorted(d[P]): 
        dd[i] = '{:06}{:06}'.format(P, j)
        j += 1
print(*dd, sep="\n")

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

#define FOR(i,n) for(int i=0;i<(n);i++)
#define FOR1(i,n) for(int i=1;i<=(n);i++)
typedef long long LL;

using namespace std;

const int N = 1e5+10;
char buf[N];

int main(){
  cin >> buf;
  int len = strlen(buf);
  char mid_char = buf[(len+1)/2 - 1];
  int mid_idx = (len+1)/2 - 1;
  int res = 0;
  for(int i = 0; i<(len+1)/2; i++) {
    if(mid_char != buf[mid_idx - i]) break;
    if(mid_char != buf[len - 1 - mid_idx + i]) break;
    res ++;
  }
  cout << res + len/2 << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str.
   builtin functions :
   __builtin_popcount(n) : no. of set bits in n.
   __builtin_parity(n) : parity of no. of set bits
   __builtin_clz(n) : no. of leading zeros before 1
   __builtin_ctz(n) : no of zeros from last to first occurrence of 1
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll binlen(ll a)
{
	ll v = 0;
	for(ll i=0;i<61;++i)
	{
		v += (1ll<<i);
		if(a<=v) return i;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	string str,qtr;
	cin >> str;
	cin >> qtr;

	n = str.size();
	m = qtr.size();

	if(n == m-1 && qtr.substr(0,n) == str)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3616