akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define double long double
double prb[20];
int n;
double k;
double chance = 0.0, base;
signed main(){
	prb[0] = 1.0;
	for(int i = 1 ; i <= 19 ; i ++)
		prb[i] = prb[i - 1] * 0.5;
	cin >> n >> k;
	base = (double)1/n;
	for(int i = 1 ; i <= n ; i ++){
		if(i >= k) chance += base;
		else {
			double f2 = 1.0;
			for(int j = 0 ; ; j ++){
				if(i * f2 >= k){
					chance += base * prb[j];
					break;
				}
				f2 *= 2.0;
			}
		}
	}
	cout << setprecision(12) << chance;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(c > a-b){
			System.out.println(c-(a-b));
		}
		else{
		System.out.println(0);
		}
	}

}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vci vector<ll>
#define vcs vector<string>
#define vcp vector<pair<ll, ll>>
#define vct vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n;
	cin >> n;
	vci v(n);
	REP(i, n) cin >> v[i];
	ll n4=0, n2=0;
	REP(i,n)
	{
		if (v[i] % 4 == 0) n4++;
		else if (v[i] % 2 == 0) n2++;
	}
	n4 = 2 * n4 + 1;
	n -= n4;
	if (n < n2||n==0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

Measured memory_bytes: 2684
/********************    I am only one, but still I am one.    **************************************/
/**************    I cannot do everything, but still I can do something.    *************************/
/***   And because I cannot do everything I will not refuse to do the something that I can do.    ***/
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;


int l = 1e18;
string ans,s;
int nxt[200010][26],dp[200010],tmp[26];
int n;

int solve(int i){
	if( i == n ) return 1;
	int & ans = dp[i];
	if( ans != -1 )return ans;
	ans = 1e18;
	for(int c = 0 ; c < 26; c++ ){
		ans = min( ans , 1+solve(nxt[i][c]) );
	}
	return ans;
}
int32_t main(){
	IOS
	cin >> s;
	n = s.length();
	for(int i=0;i<26;i++){
		tmp[i]=n;
	}
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<26;j++){
			nxt[i][j]=tmp[j];
		}
		tmp[s[i]-'a']=i;
	}
	memset(dp,-1,sizeof(dp));
	
	int j = 0;
	for(int i = 0; i < 26; i++ ){
		if( solve(tmp[i]) < solve(tmp[j]) ){
			j = i;
		}
	}
	int N =  solve(tmp[j]);
	int i =  tmp[j];
	while( N-- ){
		cout << ( char( j + 'a' ) );
		int newj = 0;
		for(int c = 0 ; c < 26; c++ ){
			if( solve(nxt[i][c]) < solve(nxt[i][newj]) ){
			   newj = c;
		    }
		}
		j = newj;
		i = nxt[i][j];
	}
	
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 46268
#include<bits/stdc++.h>
#define LL long long 
using namespace std;

const LL maxn=1e5+5;

LL ans,tot,n,m,a[maxn],b[maxn],fa[maxn],xo[maxn];
LL nw,u,v,w1,w2;
bool vis[maxn];

LL getfather(LL k)
{
	if(fa[k]==k)return k;
	return fa[k]=getfather(fa[k]);
}

int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		fa[i]=i;
		xo[i]=a[i];		
	}
	for(int i=0;i<m;i++)
	{
		scanf("%lld%lld",&u,&v);
		w1=getfather(u);
		w2=getfather(v);
		if(w1==w2)continue;
		fa[w1]=w2;
		xo[w1]=min(xo[w1],xo[w2]);
		xo[w2]=min(xo[w1],xo[w2]);
	}
	for(int i=0;i<n;i++)if(fa[i]==i)
	{
		b[tot]=xo[i];
		tot++;
		ans+=xo[i];
	}
	//cout<<tot<<endl;
	if(tot*2-2>n)
	{
		printf("Impossible\n");
		return 0;
	}
	if(tot==1)
	{
		printf("0\n");
		return 0;
	}
	if(tot==2)
	{
		printf("%lld\n",ans);
		return 0;
	}
	sort(b,b+tot);
	sort(a,a+n);
	nw=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]<b[nw])continue;
		vis[i]=true;nw++;
		if(nw==tot)break;
	}
	nw=0;
	for(int i=0;i<n;i++)if(!vis[i])
	{
		ans+=a[i];
		nw++;
		if(nw==tot-2)break;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MAX=1000040,MAX2=200;
char s[MAX],s1[MAX],s2[MAX];
ll li[MAX],li2[MAX],len,len1,len2,cnt[MAX2][26],fib[MAX2],ans[MAX],l,r;
void build_cnt(ll x,ll lim,ll w){
    for(int i=0;i<lim;i++){
        if(x<=fib[i]){
            if(i==1){
                for(int j=0;j<x;j++) ans[s2[j]-'a']+=w;
                return;
            }
            if(i==0){
                for(int j=0;j<x;j++) ans[s1[j]-'a']+=w;
                return;
            }
            for(int j=0;j<26;j++) ans[j]+=cnt[i-1][j]*w;
            build_cnt(x-fib[i-1],i-1,w);
            return;
        }
    }
}
int main(){
    scanf(" %s %lld %lld",s,&l,&r);

    len=strlen(s);
    for(ll i=1,j=0;i<len;i++){
        while((s[i]!=s[j]&&j!=0)) j=li[j];
        if(s[i]==s[j]) li[i+1]=++j;
    }
    for(ll i=2,j=0;i<len;i++){
        while((s[i]!=s[j]&&j!=0)||i+1<=2*(j+1)) j=li[j];
        if(s[i]==s[j]) li2[i+1]=++j;
    }
    for(ll i=0;i<len-li2[len]-li[len-li2[len]];i++) s2[i]=s[i];
    for(ll i=0;i<li[len-li2[len]];i++) s1[i]=s[i+len-li2[len]-li[len-li2[len]]];
    len1=strlen(s1),len2=strlen(s2);
    fib[0]=len1,fib[1]=len2;
    for(ll i=0;i<len1;i++) cnt[0][s1[i]-'a']++;
    for(ll i=0;i<len2;i++) cnt[1][s2[i]-'a']++;
    for(ll i=2;i<MAX2;i++) {
        fib[i]=fib[i-1]+fib[i-2];
        for(ll j=0;j<26;j++) cnt[i][j]=cnt[i-1][j]+cnt[i-2][j];
    }
    build_cnt(r,MAX2,1);
    build_cnt(l-1,MAX2,-1);
    //printf("%d\n",strlen(s)/2);
    //printf("%s %s\n",s1,s2);
    for(ll i=0;i<26;i++) printf("%lld ",ans[i]);
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     rfl(a, b, c)       for(int a= c-1 ;a>=b;i--)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     CLR(a,b)          memset(a,b,sizeof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")


int main()
{
    string v;
    cin>>v;
    int n = v.length();
    int lans = 0, rans = 0;
    fl(i,0,n){
        if(i%2 == 0){
            if(v[i] == '1') continue;
            else lans++;
        }
        else{
            if(v[i] == '0') continue;
            else lans++;

        }

    }
    fl(i,0,n){
        if(i%2 == 0){
            if(v[i] == '0') continue;
            else rans++;
        }
        else{
            if(v[i] == '1') continue;
            else rans++;

        }

    }
  // D(lans);
  // D(rans);
    cout<<min(lans,rans)<<endl;




    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  //int n, i, m;
  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int sum = 0;
  int m_sum = 0;
  rep(i, n) sum += A[i];
  //rep(i, m) m_sum += A[i];
  int m4 = 4*m;
  int tmp;
  if(sum%m4==0) tmp = sum/m4;
  else tmp = sum/m4 + 1;
  //tmp = sum/m4;
  //sort(A.begin(), A.end());
  //cout << tmp << endl;
  if(A[m-1]<tmp) cout << "No" << endl;
  else cout << "Yes" << endl;
}



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

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; }

const long long INF = 1LL << 60;

int main ()
{
    int a,b;    cin >> a >> b;
    if(a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

     



Measured memory_bytes: 256
N = int(input())
s = []
now = 0
simekiri = 0
flag = 0
for i in range(N):
    a,b = map(int,input().split())
    s.append([b,a])
s.sort()
for i in range(N):
    now += s[i][1]
    simekiri = s[i][0]
    if now>simekiri:
        print("No")
        flag = 1
        break
if flag == 0:
    print("Yes")

Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    if(S=="AAA" || S=="BBB"){
        cout << "No" << endl;
        return 0;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

int main() {
  int N,M,i,j,k;
  cin >> N >> M;
  vector<int> a(M*2);
  for(k=0;k<N;k++){
  j=0;
  for(i=0;i<M*2;i++){
  cin >> a.at(i);
  if(k+1==a.at(i)){
  j++;
  }
  }
  cout << j << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

long long mod = 1000000007;

void dfs(int p, int prev, vector<int> &a, vector<int> &dp, int dpl, vector<vector<int>> &v, vector<int> &res)
{
    int l = -1, r = dpl, mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        if (dp[mid] >= a[p])
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    int temp = dp[r];
    dp[r] = a[p];
    if (temp == -1)
    {
        dpl++;
    }
    res[p] = dpl;
    for (int i = 0; i < v[p].size(); i++)
    {
        if (v[p][i] == prev)
        {
            continue;
        }
        dfs(v[p][i], p, a, dp, dpl, v, res);
    }
    dp[r] = temp;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<vector<int>> v(n);
    for (int i = 0; i < n - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x - 1].push_back(y - 1);
        v[y - 1].push_back(x - 1);
    }
    vector<int> dp(n, -1);
    vector<int> res(n);
    dfs(0, -1, a, dp, 0, v, res);
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << '\n';
    }




    return 0;
}


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


int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    int x;
    int ans = 0;
    cin >> n;
    int maxx = 0;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        ans += x;
        maxx = max(maxx, x);
    }
    cout << ans - maxx/2 << endl;
    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;
const int N = 3e6 + 123;
int	r1, r2, c1, c2, f[N], ans;

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

int add(int a, int b)
{
	a += b;
	if(a < 0) a += mod;
	if(a >= mod) a %= mod;
	return a;
}

int binpow(int w, int h)
{
	if(h == 0) return 1;
	if(h % 2 == 1) return mult(binpow(w, h - 1), w);
	else
	{
		int m = binpow(w, h / 2);
		return mult(m, m);
	}
}

int c(int n, int k)
{
	int num = f[n];
	int den = mult(f[k], f[n - k]);
	return mult(num, binpow(den, mod - 2));
}

main()
{
	cin >> r1 >> c1 >> r2 >> c2;
	f[0] = 1;
	for(int i = 1; i <= 3e6; i++) f[i] = mult(f[i - 1], i);
	for(int i = r1; i <= r2; i++)
	{
		ans = add(ans, c(c2 + i + 1, c2));
		ans = add(ans, -c(i + c1, c1 - 1));
	}
	cout << ans % mod;
}

Measured memory_bytes: 11904
#include <stdio.h>
#include <string.h>

#define MIN(A,B) (A)<(B)?(A):(B)
#define MAX(A,B) (A)>(B)?(A):(B)

#define N 5

int main(){
  int n, a, b, c=0, i;
  char S[N], T[N];
  scanf("%s", S);
  scanf("%s", T);
  for (i=0; i<3; i++){
    if (S[i]==T[i]) c++;
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

l = [A - B for A,B in zip(a,b)]
if sum(l) < 0:
    print(-1)
    exit()

nega = [i for i in l if i < 0]
posi = [i for i in l if i > 0]
nega.sort()
posi.sort()

p = 0
ans = 0
for n in nega:
    ans += 1
    p += n
    if p <= 0 and posi:
        # 補給
        p += posi.pop()
        ans += 1

print(ans)

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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    string s;
    cin >> s;
    int q; cin >> q;
    bool reverse = false;
    for (int i = 1; i <= q; i++) {
        int x; cin >> x;
        if (x == 1) reverse = !reverse;
        if (x == 2) {
            int pos; cin >> pos;
            char c; cin >> c;

            if (not reverse) {
                if (pos == 1) s.insert(0, 1, c);
                if (pos == 2) s.append(1, c);
            }
            if (reverse) {
                if (pos == 2) s.insert(0, 1, c);
                if (pos == 1) s.append(1, c);
            }
        }
    }   

    if (reverse) {
        for (int i = s.length()-1; i >= 0; i--) cout << s[i];
    } else cout << s;

    cout << endl;


    return 0; 
}



Measured memory_bytes: 3928
#include<iostream>
#include<array>
using namespace std;
 
main(){
  int n,f;
  array<int, 3> arr{0,0,0};
  cin >> n;
  for(int i=0; i<n;i++){
    cin>>f;
    if(f%4==0) arr[2] +=1;
    else if (f%2==0) arr[1] +=1;
    else arr[0]+=1;
  }
  if(arr[1] == 0){
    if(arr[0]<=arr[2]+1) cout<< "Yes"<<endl;
    else cout<< "No"<<endl;
  }
  else{
    if(arr[0]<=arr[2]) cout<< "Yes"<<endl;
    else cout<< "No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
 
#define pii pair<LL,LL>
#define mem(v, x) memset(v, x, sizeof v)
 
#define si(x) scanf("%d", &x)
#define sii(x, y) scanf("%d %d", &x, &y)
#define siii(x, y, z) scanf("%d %d %d", &x, &y, &z)
 
#define sf(x) scanf("%lf", &x)
#define endl '\n'

#define FOR(i , N) for(int i = 0  ; i < N ; i++)
#define FOR1(i , N) for(int i = 1  ; i <= N ; i++)

using namespace std;
 
typedef long long LL;
 
int SET(int N,int pos){return N=N | (1<<pos);}
int RESET(int N,int pos){return N= N & ~(1<<pos);}
bool CHECK(int N,int pos){return (bool)(N & (1<<pos));}

int main()
{

#ifndef ONLINE_JUDGE // dont use this in toph/codemarshal
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    int N;
    cin >> N;
    int arr[N];
    int dp[N + 1];
    FOR(i , N) cin >> arr[i];
    FOR(i , N) {
      if(i == 0) dp[0] = 0;
      else if(i == 1) dp[1] = abs(arr[1] - arr[0]);
      else dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
    }

    cout << dp[N - 1] << endl;
}

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

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
using std::vector;

struct Edge{
	Edge(int t=0,int v=0):to(t),vis(v){}
	int to, vis;
}edges[100005<<1];
vector<int> nodes[100005];
vector<int>simpleG[100005];
int edgeCnt = 0;
void dfs(int cid){
	//printf("begin dfs %d\n", cid);
	for(auto ln:nodes[cid])	{
		if (edges[ln].vis)continue;
		edges[ln].vis = 1;
		edges[ln ^ 1].vis = 1;
		int nid = edges[ln].to,lst=cid;
		for(;nodes[nid].size()==2;){
			int p = nodes[nid][0],q = nodes[nid][1];
			
			if(edges[p].to==lst)
				lst = nid,
				nid = edges[q].to,
				edges[q].vis=1,
				edges[q^1].vis=1;
			else
				lst = nid,
				nid = edges[p].to,
				edges[p].vis=1,
				edges[p^1].vis=1;
		}
		//edgeCnt += 2;
		//printf("  %d\n", nid);
		//simpleG[nid].push_back(cid);
		//simpleG[cid].push_back(nid);

		if (cid != nid)
		{
			edgeCnt++;
			dfs(nid);
		}
		else edgeCnt += 2;
	}
}

int cntEdge(){
	
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int x, y;
	for (int i = 1; i<=m; i++) {
		scanf("%d%d", &x, &y);
		edges[i << 1].to = x;
		edges[(i << 1) | 1].to = y;
		nodes[y].push_back(i << 1);
		nodes[x].push_back((i << 1 )| 1);
	}
	int dfsStart=-1;
	for(int i=1,sz;i<=n;i++)
	{
		sz = nodes[i].size();
		if(sz&1)	{
			printf("No"); return 0;
		}
		if (sz>2)dfsStart=i;
	}

	if (dfsStart==-1)printf("No");
	else	{
		dfs(dfsStart);
		if (edgeCnt > 4)printf("Yes");
		else printf("No");
	}
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll n;
    cin>>n;
    if(n%2 == 1) print(0);
    else {
        ll x = n/2;
        ll ans = 0;
        ll z = 5;
        while(x/z > 0){
            ans += x/z;
            z = z*5;
        }
        print(ans);
    }
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll H, W, K;

vector<pll> div_choc(ll bs)
{
  vector<pll> res;
  ll div = 0;
  for (ll i = 0; i < H; ++i) {
    if (bs & (1 << i)) {
      res.push_back({div + 1, i + 1});
      div = i + 1;
    }
  }
  res.push_back({div + 1, H});
  return res;
}

int main()
{
  cin >> H >> W >> K;
  vector<vector<ll>> sum(H + 2, vector<ll>(W + 2, 0));
  for (ll i = 0; i < H; ++i) {
    string s;
    cin >> s;
    for (ll j = 0; j < W; ++j) {
      sum.at(i + 1).at(j + 1) = (s[j] - '0');
    }
  }
  for (ll i = 0; i <= H; ++i) {
    for (ll j = 0; j <= W; ++j) {
      sum.at(i + 1).at(j) += sum.at(i).at(j);
    }
  }
  for (ll i = 0; i <= H; ++i) {
    for (ll j = 0; j <= W; ++j) {
      sum.at(i).at(j + 1) += sum.at(i).at(j);
    }
  }


  // for (ll i = 0; i <= H; ++i) {
  //   for (ll j = 0; j <= W; ++j) {
  //     cout << sum.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }

  ll ans = INF;
  for (ll i = 0; i < (1 << (H - 1)); ++i) {
    ll temp = __builtin_popcount(i);
    vector<pll> bar = div_choc(i);
    // for (ll i = 0; i < bar.size(); ++i) {
    //   cout << bar.at(i).first << " " << bar.at(i).second << endl;
    // }
    ll before = 1;
    bool inp = false;
    for (ll j = 1; j <= W; ++j) {
      for (ll k = 0; k < bar.size(); ++k) {
        ll up = bar.at(k).first, down = bar.at(k).second;
        ll white = sum.at(down).at(j);
        white -= sum.at(down).at(before - 1) + sum.at(up - 1).at(j);
        white += sum.at(up - 1).at(before - 1);
        if (white > K) {
          if (before == j) {
            inp = true;
          }
          before = j;
          temp += 1;
          // cout << j << endl;
          break;
        }
      }
      // cout << endl;
    }
    if (!inp) {
      ans = min(ans, temp);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import sys
a=input()
c=a.split(" ")
c[0]=int(c[0])
c[1]=int(c[1])
b=[input().split(" ") for x in range(c[0])]

for i in range(len(b)):
    for x in range(2):
        b[i][x]=int(b[i][x])



b.sort(key=lambda x:x[1])


if c[1] < b[0][1]:
    print("TLE")
    sys.exit()

b.sort(key=lambda x:x[0])

mini=10000000000
for i in range(len(b)):
    if b[i][1] <= c[1]:
        if b[i][0] <= mini:
            mini=i
print(b[mini][0])


Measured memory_bytes: 3064
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var Q = Number(lines[0].split(" ")[1]);

    var S = lines[1].split("")

    lines.shift();
    lines.shift();

    var lr = lines.map(value => value.split(" ").map(value => Number(value)));

    var sum = Array(N).fill(0);

    for (var i = 1; i < N; i++) {
        if (S[i - 1] === "A" && S[i] === "C") { sum[i]++; }
        sum[i] += sum[i - 1]
    }

    for (var i = 0; i < Q; i++) {
        var l = lr[i][0]; var r = lr[i][1];
        console.log(sum[r - 1] - sum[l - 1]);
    }

});

Measured memory_bytes: 57032
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    vertex = [[0] * N for i in range(N)]

    for i in range(M):
        vertex[a[i]-1][b[i]-1] += 1
        vertex[b[i]-1][a[i]-1] += 1

    import itertools
    ans = 0
    for x in itertools.permutations(range(N)):
        if(x[0] != 0):
            break
        plus = 1
        for i in range(N-1):
            plus = plus * vertex[x[i]][x[i+1]]

        ans += plus
             
    print(ans)
    return
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    llong ans = 1;
    for (int i = 0; i < n-1; i++){
        int k = i;
        while (k < n-1 && a[k+1] == a[i]){
            k++;
        }
        if (a[k+1] > a[i]){
            while (i < n-1 && a[i+1] >= a[i]){
                i++;
            }
            if (i == n-1){
                break;
            }else{
                ans++;
                continue;
            }
        }
        if (a[k+1] < a[i]){
            while (i < n-1 && a[i+1] <= a[i]){
                i++;
            }
            if (i == n-1){
                break;
            }else{
                ans++;
                continue;
            }
        }
    }
    cout << ans << endl;

    return 0;
}













Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct H
{
	int m, a, b;
};

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<pint> v;

		rep(i, n)
		{
			int a, b, m;
			cin >> m >> a >> b;

			v.push_back(mp(a, m));
			v.push_back(mp(b, -m));
		}

		sort(ALL(v));

		int m = 0;
		rep(i, v.size())
		{
			m += v[i].second;
			for(; v[i].first == v[i + 1].first && i +  1 < v.size(); i++)
				m += v[i + 1].second;
			

			if(150 < m)
			{
				cout << "NG" << endl;
				goto ng;
			}
		}

		cout << "OK" << endl;
ng:
		;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif  
 // taskkill -im new.exe -f
  double n,k ,sum=0;
  cin>>n;
  vector <double> arr(n);
  for(ll i=0;i<n;i++)
  {
    cin>>arr[i];
    sum = sum + arr[i];
  }
  double p =round( sum / n) ,ans=0;
//  cout<<p<<" ";

  for(ll i=0;i<n;i++)
  {
    ans = ans + (arr[i] - p)*(arr[i] - p);
  }

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

Measured memory_bytes: 3776
#include <stdio.h>
#define MAX 100001

int h(char a){
  return (int)a-'a';
}

int main(){
  int i,j,slen,tlen,list[MAX][26],first[26],last[26],ex[26],r;
  long long c;
  char s[MAX],t[MAX];
  
  scanf("%s",s);
  scanf("%s",t);
  
  for(i=0;s[i]!='\0';i++);
  slen = i;
  for(i=0;t[i]!='\0';i++);
  tlen = i;
  
  for(i=0;i<26;i++)first[i] = -1;
  for(i=0;i<26;i++)last[i] = -1;
  for(i=0;i<slen;i++){
    r = h(s[i]);
    if(first[r] == -1)first[r]=i;
    if(last[r] != -1)
      for(j=last[r];j<i;j++)list[j][r] = i;
    else
      for(j=0;j<i;j++)list[j][r] = i;
    last[r] = i;
  }
  
  for(i=0;i<26;i++)ex[i]=1;
  for(i=0;i<26;i++){
    if(first[i] != -1)
      for(j=last[i];j<slen;j++)list[j][i] = first[i];
    else
      ex[i] = 0;
  }
  
  c=0;
  i=slen-1;
  for(j=0;j<tlen;j++){
    r = h(t[j]);
    if(!ex[r]){
      printf("-1");
      return 0;
    }
    if(list[i][r] <= i)c++;
    i = list[i][r];
  }
  printf("%lld",(c-1)*slen+i+1);
  return 0;
}

Measured memory_bytes: 10496
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//おまじない



int main() {

	char a[10], b[101], c[10];
	cin >> a >> b >> c;

	cout << a[0] << b[0] << c[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  vector<vector<int>> g(n);

  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  queue<P> que;
  que.push(P(1, 0));
  que.push(P(2, n - 1));

  vector<bool> used(n, false);
  int f = 1, s = 1;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    REP(i, g[p.second].size()) {
      if(!used[g[p.second][i]]) {
        que.push(P(p.first, g[p.second][i]));
        used[g[p.second][i]] = true;
        if(p.first == 1) f++;
        else s++;
      }
    }
  }

  cout << (f > s ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;
typedef pair<char, char> P;

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    int n = sz(s);
    map<char, char> mp1, mp2;

    rep(i, n) {
        auto ite = mp1.find(s[i]);
        if (ite == mp1.end()) {
            mp1.insert(P(s[i], t[i]));
        }
        else {
            if (ite->second != t[i]) {
                cout << "No" << endl;
                return 0;
            } else {
                continue;
            }
        }
    }

    rep(i, n) {
        auto ite = mp2.find(t[i]);
        if (ite == mp2.end()) {
            mp2.insert(P(t[i], s[i]));
        }
        else {
            if (ite->second != s[i]) {
                cout << "No" << endl;
                return 0;
            } else {
                continue;
            }
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 776
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#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 endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    long long s;
    cin >> s;
    cout << 0 << " " << 0 << " ";
    long long t = sqrt(s) + 1;
    while(t*t > 1000000000000000000ll)
    {
        t--;
    }
    if(t*t >= s)
    cout << t << " " << 1 << " " << t * t - s << " " << t ;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	long long k=c/__gcd(c,d)*d;
	long long e=b/c+1-(a+c-1)/c,f=b/d+1-(a+d-1)/d,g=b/k+1-(a+k-1)/k;
	cout<<b-a+1-e-f+g<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

bitset<4000001> b;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n = 2000;
  cin >> n;
  vi a(n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  b.set(0);
  for (int i = 0; i < n; ++i) {
    b |= b << a[i];
  }
  for (int i = (s+1)/2; i <= s; ++i) if (b.test(i)) {
    cout << i << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 1792
import math
n = int(input())
MAX = 55555
primes = [i for i in range(MAX)]
primes[1] = 0
for prime in primes:
    if prime > math.sqrt(MAX): break
    if prime == 0: continue
    for non_prime in range(2 * prime, MAX, prime): primes[non_prime] = 0
primes = [prime for prime in primes if prime != 0]
count = 0
index = 0
ans = []
while(count < n):
    all_list = []
    if(primes[index] % 10 == 1):
        ans.append(primes[index])
        count += 1
    index += 1
a = ""
for x in ans:
    a += str(x) + " "
print(a.rstrip(" "))


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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

struct do_elem {
    ll min = LL_INF;
    ll to_change = -1;
};
vector<do_elem> st(404040);

void propagate(ll node) {
    if (st[node].to_change != -1) {
        st[node * 2].min = st[node].to_change;
        st[node * 2].to_change = st[node].to_change;
        st[node * 2 + 1].to_change = st[node].to_change;
        st[node * 2 + 1].min = st[node].to_change;
        st[node].to_change = -1;
    }
}


ll change_seg(ll node, ll l, ll r, ll tl, ll tr, ll change) {
    if (l > r) {
        return LL_INF;
    }
    if (tl != tr) {
        propagate(node);
    }
    if (tl == l && tr == r) {
        st[node].min = change;
        st[node].to_change = change;
        return st[node].min;
    }
    ll mid = (tl + tr) / 2;
    ll left_res = change_seg(node * 2, l, min(r, mid), tl, mid, change);
    ll right_res = change_seg(node * 2 + 1, max(mid + 1, l), r, mid + 1, tr, change);
    st[node].min = min(st[2 * node + 1].min, st[2 * node].min);
    return st[node].min;
}

ll get_seg(ll node, ll l, ll r, ll tl, ll tr) {
    if (l > r) {
        return LL_INF;
    }
    if (tl != tr) {
        propagate(node);
    }
    if (tl == l && tr == r) {
        return st[node].min;
    }
    ll mid = (tl + tr) / 2;
    ll left_res = get_seg(node * 2, l, min(r, mid), tl, mid);
    ll right_res = get_seg(node * 2 + 1, max(mid + 1, l), r, mid + 1, tr);
    return min(left_res, right_res);
}

struct elem {
    ll l;
    ll r;
    ll c;
};

int main() {
    IOS

    ll n, m;
    cin >> n >> m;
    vector<elem> v(m);
    for (int i = 0; i < m; ++i) {
        cin >> v[i].l >> v[i].r >> v[i].c;
    }

    sort(all(v), [](elem l, elem r) {
        if (l.r != r.r) {
            return l.r < r.r;
        } else if (l.l != r.l) {
            return l.l < r.l;
        } else
            return l.c < r.c;
    });
    change_seg(1, 1, 1, 1, n, 0);
    ll mx = 1;
    for (int i = 0; i < m; ++i) {
        if (v[i].l > mx)
            continue;
        ll mi = get_seg(1, v[i].l, min(mx, v[i].r - 1), 1, n) + v[i].c;
        ll last = get_seg(1, v[i].r, v[i].r, 1, n);

        if (last > mi) {
            change_seg(1, v[i].r, v[i].r, 1, n, mi);
        }
        mx = v[i].r;
    }
    ll ans = get_seg(1, n, n, 1, n);
    if (ans < LL_INF)
        cout << ans;
    else
        cout << -1;

    return 0;
}

Measured memory_bytes: 8960
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for s in range(N):
    S = input()
    if S == 'AC':
        ac +=1
    if S == 'WA':
        wa +=1
    if S == 'TLE':
        tle +=1
    if S == 'RE':
        re +=1

print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 9204
//Tuvshee
 
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define I int
#define D double
#define F float
#define C char
#define S string
#define B bool
#define L long long
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define whL while
#define eL endl
#define oR ||
#define rtn return
#define pause system("PAUSE")
#define Max 300
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)
 
int main()
{
	I x;
	for(int i=1;;i++){
		cin>>x;
		if(x==0)break;
		cout<<"Case "<<i<<": "<<x<<eL;
	}
	rtn 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  rep(i, 1250){
    if (((i+1) * 8 / 100) == A && ((i+1) * 10 / 100) == B){
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

#ifdef LOCAL
#include "local.h"
#endif

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

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


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

    const ll inf = ten(10);
    vector<int> pos;
    map<int, vector<pint> > g;
    rep(i, n)
    {
        int p, d, t;
        cin >> p >> d >> t;
        g[p].push_back(pint(p + d, t));
        pos.push_back(p);
        pos.push_back(p + d);
    }
    pos.push_back(0);
    pos.push_back(l);
    uniq(pos);
    rep(i, sz(pos) - 1)
        g[pos[i]].push_back(pint(pos[i + 1], pos[i + 1] - pos[i]));

    map<int, ll> dp;
    rep(i, pos.size())
    {
        int p = pos[i];
        dp[p] = inf;
    }
    dp[0] = 0;
    rep(i, pos.size())
    {
        int p = pos[i];
        ll c = dp[p];
        assert(c < inf);
        rep(j, g[p].size())
        {
            pint& e = g[p][j];
            int np = e.first, cost = e.second;
            upmin(dp[np], c + cost);
        }
    }
    cout << dp[l] << endl;
}


Measured memory_bytes: 1564
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

char field[50][50];
int h,w;
int d[50][50];

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

void bfs()
{
    queue<P> que;
    que.push(P(0,0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            d[i][j] = INF;
        }
    }
    d[0][0] = 0;
    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == h-1 && p.second == w-1){
            break;
        }
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == INF && field[nx][ny] != '#'){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return ;
}

int main()
{
    cin >> h >> w;
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> field[i][j];
            if(field[i][j] == '#'){
                cnt++;
            }

        }
    }
    bfs();
    if(d[h-1][w-1] == INF){
        cout << -1 << endl;
    }else{
        cout << h * w - d[h-1][w-1] - 1 - cnt << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	int a,b;
	cin>>a>>b;
	if(a>b){
	cout<<"a > b"<<endl;
	}else if(a<b){
	cout<<"a < b"<<endl;
	}else if(a==b){
	cout<<"a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		
		int right = str.length();
		
		while(right > 0) {
			if(right >= 7 && str.substring(right - 7, right).equals("dreamer")) {
				right -= 7;
			}
			else if(right >= 6 && str.substring(right - 6, right).equals("eraser")) {
				right -= 6;
			}
			else if(right >= 5){
				String tmp = str.substring(right - 5, right);
				
				if(tmp.equals("dream") || tmp.equals("erase")) {
					right -= 5;
				}
				else {
					System.out.println("NO");
					return;
				}
			}
			else {
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");
	}

}


Measured memory_bytes: 27700
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,i,j;
	cin>>a>>b>>c;
	if(b-a==c-b){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

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

  string S; cin >> S;
  vector<string> AKI(16);
  string A = "AKIHABARA";

  for (ll i = 0; i < 16; i++) {
    for (ll j = 0; j < A.size(); j++) {
      if (A[j] != 'A') AKI[i] += A[j];
      else if (j == 0 && ((i >> 0) & 1)) AKI[i] += 'A';
      else if (j == 4 && ((i >> 1) & 1)) AKI[i] += 'A';
      else if (j == 6 && ((i >> 2) & 1)) AKI[i] += 'A';
      else if (j == 8 && ((i >> 3) & 1)) AKI[i] += 'A';
    }
  }

  for (ll i = 0; i < 16; i++) {
    if (AKI[i] == S) {
      cout << "YES" << '\n';
      return 0;
    }
  }
  cout << "NO" << '\n';
  return 0;
}

Measured memory_bytes: 256