akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
}
int main()
{
	Mohammed_Atef_Hassan
		int n; ll w;
	cin >> n >> w;
	vector<pair<ll, ll>>v(n);
	for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
	vector<ll>mem(1e5 + 10, LLONG_MAX);
	mem[0] = 0;
	set<int>st{ 0 };
	vector<int>vv;
	for (int i = 0; i < n; i++)
	{
		vv.clear();
		for (set<int>::reverse_iterator j=st.rbegin();j!=st.rend();j++)
		{
			if (*j + v[i].second <= 1e5)
				mem[*j + v[i].second] = min(mem[*j + v[i].second], v[i].first+mem[*j]),vv.push_back(*j+v[i].second);
		}
		for (auto j : vv)st.insert(j);
	}
	for (int i = 1e5; i>=0; i--)
	{
		if(mem[i]<=w)ex(i);
	}
}

Measured memory_bytes: 3708
#include<iostream>
#define ll long long
#define MOD 1000000007

using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int n=(int)s.length();
    int m=(int)t.length();
    int **dp=new int*[n+1];
    for(int i=0;i<=n;i++)
        dp[i]=new int[m+1]();
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            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 mylen=dp[n][m];
    string output;
    int i=n;
    int j=m;
    while(mylen>0)
    {
        if(s[i-1]==t[j-1])
        {
            output+=s[i-1];
            i--;
            j--;
             mylen--;
        }
        else
        {
            if(dp[i][j-1]>dp[i-1][j])
            {
                
                j--;
            }
            else
            {
                i--;
            }
        }
       
    }
    reverse(output.begin(),output.end());
    cout<<output<<endl;
}


Measured memory_bytes: 38276
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    if k == 1:
        print(0)
    else:
        print(n-k)

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

const int MX = 100005;
const int MM = 1000000007;

map<ll, ll> L;
vector<ll> X;
ll A[MX];

int main()
{
	int N, Q, q;
	scanf("%d%d", &N, &Q);
	X.push_back(N);
	for(int i = 1; i <= Q; i++){
		ll a;
		scanf("%lld", &a);
		while(X.size() && X.back() >= a ) X.pop_back();
		X.push_back(a);
	}
	L[X.back()] = 1;
	
	while(X.size()){
		ll p = L.rbegin()->first, q = L.rbegin()->second;
		while(X.size() && X.back() >= p ) X.pop_back();
		if( X.empty() ) break;
		L.erase(--L.end());
		ll r = X.back();
		L[r] += q * (p/r);
		if( p%r ) L[p%r] += q;
	}
	for(auto c : L){
		A[0] += c.second;
		A[c.first+1] -= c.second;
	}
	for(int i = 1; i <= N; i++) A[i] += A[i-1];
	for(int i = 1; i <= N; i++) printf("%lld\n", A[i]);
}


Measured memory_bytes: 9460
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<cassert>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<unordered_set>
#include<iomanip>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int dx=tx-sx,dy=ty-sy;
    string s="";
    rep(i,dy)s+="U";
    rep(i,dx)s+="R";
    rep(i,dy)s+="D";
    rep(i,dx)s+="L";
    s+="L";
    rep(i,dy+1)s+="U";
    rep(i,dx+1)s+="R";
    s+="DR";
    rep(i,dy+1)s+="D";
    rep(i,dx+1)s+="L";
    s+="U";
    cout << s << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int tate,yoko;
    const int max_int32 = 2147483647;

    scanf("%d%d", &tate,&yoko);

    if (yoko <= max_int32 / tate) {
        printf("%d %d\n", tate * yoko, 2 * (tate + yoko));
    } else {
        printf("overflow\n");
    }

    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(void){
	int N=0,b=0,cnt=0;
  	scanf("%d",&N);
  	for(int i=1000;i>=1;i=i/10)
    {
    	b=N/i;
      if(b==2){cnt++;}
      N=N-(b*i);
    }
  	printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

bool check(int* A, int N){
	    rep(i,N){
		    if (A[i] == A[i + 1]) {
			    return false;
		    }
	    }
	return true;
}

int main(){
	int N;cin >> N;
	int A[N];
	int flag= 0;

	rep(i,N){
		cin >> A[i];
	}

	sort(A, A+N);
	if(check(A,N)  == true){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  if(a<b){
    cout<<"a < b"<<endl;
  }else if(a>b){
    cout<<"a > b"<<endl;
    }else{
      cout<<"a == b"<<endl;
      }
 }

Measured memory_bytes: 1156
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    N = int(input())
    S = input()
    abc = ""
    ret = 0
    for i in range(len(S)):
        if S[i] == "A":
            abc = "A"
        elif S[i] == "B" and abc == "A":
            abc = "AB"
        elif S[i] == "C" and abc == "AB":
            ret += 1
            abc = ""
        else:
            abc = ""
    print(ret)
    return


if __name__ == "__main__":
    main()

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

int main(){
    int a, b;
    cin >> a >> b;
    char mat[100][100];
    string s = "#.";
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            mat[i][j] = s[i/50];
        }
    }
    a--, b--;
    for(int i = 0; i < 50; i++){
        for(int j = 1 + i%2; a > 0 && j < 100; j += 3){
            mat[i][j] = '.';
            a--;
        }
    }
    for(int i = 51; i < 100; i++){
        for(int j = 1 + i%2; b > 0 && j < 100; j += 3){
            mat[i][j] = '#';
            b--;
        }
    }
    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << mat[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)

void solve()
{
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=t[i])ans++;
  }
  cout<<ans<<ln;
}
 
int  main()
{
  fast_cin();
  ll t=1;
  //cin>>t;
  while(t--)solve();
  return 0;
} 

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

int main() {
    char C;
    cin >> C;
    char D = C+1;
    cout << D << endl;
    return 0;
}


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

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


    for ( int i = 0; i < n; i++ ) {
        std::cout << s.substr(i, 1) << t.substr(i, 1);
    }

    return 0;
}

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

using namespace std;
#define BUF (100005)
#define ll long long 

int n;
int a[BUF];
int cnt[BUF];

map<int,int> m;

int main(void){
	cin >> n;
	for(int i=1;i<=n;i++){
		int tmp;
		cin >> tmp;
		a[i] = tmp;
		m[tmp]++;
	}


	int ans=0;
	for(int i=1;i<=n;i++){
		if( m[ a[i] ] < a[i] ){
			ans+=m[a[i]];
		}else if(m[a[i]]>a[i]){
			ans+=m[a[i]]-a[i];
		}
		m[a[i]]=0;
	}

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


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 1e6+10;

int a[N];
bool marked[N];

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

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

for(int i=0;i<N;i++) {
    marked[i]=false;
}

sort(a,a+n);

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

    for(int j=1;j*a[i]<N;j++) {
        marked[j*a[i]]=true;
    }
    if(!(i<n-1 and a[i]==a[i+1])){
        ans++;
    }
}

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

Measured memory_bytes: 5400
n,m=list(map(int,input().split(" ")))
l=[]
l=[list(map(int,input().split(" "))) for i in range(n)]
have=0
yen=0
i=0
l.sort(key=lambda x: x[0])
while have<m:
    pri=l[i][0]
    num=l[i][1]
    i+=1
    have+=num
    yen+=pri*num
if have>m:
    yen-=(have-m)*pri
print(yen)

Measured memory_bytes: 28956
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    ll ans=0;
    
    FOR(i,K,N+2){
        ans+=i*(N-i+1)+1;
        ans%=MOD;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll unsigned long long
#define endl '\n'

using namespace std;

ll n;

ll ans;

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

    cin >> n;
    for(ll i=1; i <= n; ++i) {
        for(ll j=1; j <= n; ++j) {
            for(ll k=1; k <= n; ++k) {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>         // abs
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back
using Graph = vector<vector<int>>;

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < s.length()-1; i++){
        if(s[i] == s[i+1]){
            if(s[i] == '0'){
                s[i+1] = '1';
                cnt++;
            }else{
                s[i+1] = '0';
                cnt++;
            }
        }
    } 
    cout << cnt << endl; 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,x;
  cin>>N>>A>>B;
  x=N*A;
  if(x>B){
  cout<<B<<endl;
  }
  if(x<=B){
  cout<<x<<endl;
  }
}

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

int main(){
	// sengen
	int n;
	string s;
	// nyuryoku
	cin >> n >> s;
	// keisan
	long long sum = 0;
	long long r=0,g=0,b=0;
	for(int i=0;i<n;i++){
		if(s[i] == 'R'){
			r++;
		}else if(s[i] == 'G'){
			g++;
		}else{
			b++;
		}
	}

	sum = r*g*b;

	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			int k = 2*j - i;
			if(k<n){
				if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]){
					sum--;
				}
			}
		}
	}

	cout << sum;
}

Measured memory_bytes: 3596
#include <stdio.h>
 
int main()
{
	int i,j,k;
	int n,x;
	int count;
	while(1){
		scanf("%d %d", &n, &x);
		if(n==0&&x==0){
			break;
		}
		count=0;
		for(i=1; i<=n; i++){
			for(j=1; j<=n; j++){
				for(k=1; k<=n; k++){
					if(i+j+k==x){
						if(i!=j&&j!=k&&k!=i){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count/6);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    int cnt[10][10] = {};
    REP(i, 1, 10) {
        REP(j, 1, 10) {
            if (i == j) cnt[i][j]++;

            int multiple = 10;
            while (multiple * i + j <= N) {
                if (multiple * (i + 1) + j <= N) {
                    cnt[i][j] += multiple / 10;
                } else {
                    cnt[i][j] += (N - (multiple * i + j)) / 10 + 1;
                }
                multiple *= 10;
            }
        }
    }


    ll ans = 0;
    REP(i, 1, N + 1) {
        int last = i % 10;
        if (last == 0) continue;

        int first = i;
        while (first >= 10) {
            first /= 10;
        }

        ans += cnt[last][first];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> dp(1,1000000000);
  vector<int> sequence(n);
  REP(i,n){
    cin >> sequence[i];
    if(dp[dp.size()-1] > sequence[i]){
      REP(j,dp.size())
	if(dp[j] == sequence[i])break;
	else if(dp[j]>sequence[i]){
	  dp[j] = sequence[i];
	  break;
	}
    }else if(dp[dp.size()-1] < sequence[i]){
      dp.push_back(sequence[i]);
    }
    /*    REP(j,dp.size())cout << dp[j] << " ";
	  cout << endl;*/
  } 
  cout << dp.size() << endl;

  return 0;
}
 

Measured memory_bytes: 3768
N, M = map(int, input().split())
k = [i[1:] for i in [list(map(int, input().split())) for i in range(N)]]
k_1 = [flatten for inner in k for flatten in inner]
count_k = 0
for i in range(1, M + 1):
    if k_1.count(i) == N:
        count_k += 1

print(count_k)

Measured memory_bytes: 3060
from fractions import gcd
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a_max = max(a)

agcd = a[0]
for item in a[1:]:
    agcd = gcd(agcd, item)

if k > a_max:
    print("IMPOSSIBLE")
elif agcd == 1:
    print("POSSIBLE")
elif k % agcd != 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

int main() {
  int N;
  cin >> N;
  vector<double> a(N + 1), b(N + 1), c(N);
  for (int i = 1; i <= N; i++) cin >> a[i];
  for (int i = 1; i <= N; i++) cin >> b[i];
  for (int i = 1; i < N; i++) cin >> c[i];

  int prev = -1;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += b[a[i]];
    if (a[i] == prev + 1) ans += c[prev];
    prev = a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <tuple>

using namespace std;

long long MOD = 1000000007;

void bfs(int root, vector<pair<int, int> > &vec, vector<int> &cnt, vector<vector<int> > &edges){
    deque<tuple<int, int, int> > que;
    que.push_back(make_tuple(0, 0, root));
    while((int) que.size()>0){
        int r=get<0>(que.front());
        int p=get<1>(que.front());
        int now=get<2>(que.front());
        que.pop_front();
        cnt[now]--;

        if(vec[now].first < r){
            vec[now]=make_pair(r,p);
        }
        if(cnt[now]>0)continue;

        for(int i=0; i<(int)edges[now].size(); i++){
            int next_=edges[now][i];
            que.push_back(make_tuple(r+1, now, next_));
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int> > edges(N,vector<int>(0));
    vector<pair<int, int> > vec(N,make_pair(0,-1));
    vector<int> cnt(N,0);
    for(int i=0; i<N+M-1; i++){
        int A, B;
        cin >> A >> B;
        A--;B--;
        edges[A].push_back(B);
        vec[B]=make_pair(-2,-2);
        cnt[B]++;
    }
    
    for(int i=0; i<N; i++){
        if(vec[i].second==-1){
            bfs(i, vec, cnt, edges);
            break;
        }
    }
    for(int i=0; i<N; i++){
        //cout << vec[i].first << ' ';
        cout << vec[i].second+1 << endl;
    }
}

Measured memory_bytes: 7424
package main

import (
	"fmt"
)

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

var dp [][]int

func main() {
	var n int
	fmt.Scan(&n)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, 3)
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, 3)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				chmax(&dp[i+1][j], dp[i][k]+a[i][k])
			}
		}
	}

	ans := 0
	for i := 0; i < 3; i++ {
		chmax(&ans, dp[n][i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 12928
// AOJ 2425: A Holiday of Miss Brute Force
// 2017.12.30 bal4u@uu

#include <stdio.h>
#include <string.h>
 
#define QMAX 10000
typedef struct { int t, x, y, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int x, int y, int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].x = x, que[i].y = y, que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x30303030
#define BASE 100

char map[202][202];
int dist[202][202][6];
int mv[2][6][2] = {{{1,0},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1}},
				   {{1,0},{1,1},{ 0,1},{-1,0},{ 0,-1},{1,-1}}};
char buf[30], *p;

int in()
{
	int n = 0;
	if (*p == '-') { p++; while (*p >= '0') n = 10*n + (*p++ & 0xf); n = -n; }
	else while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

void dijkstra(int sx, int sy, int lx, int ly)
{
	int i, x, y, t, x2, y2, t2, d, e;

	memset(dist, INF, sizeof(dist));
	dist[sy][sx][0] = 0;
	qsize = 0;
	enq(sx, sy, 0, 0);
	while (qsize) {
		x = que[0].x, y = que[0].y, t = que[0].s, deq();

		d = (x-BASE)*(y-BASE)*t; if (d < 0) d = -d;	d %= 6;
		t2 = t+1; if (t2 == 6) t2 = 0;

		// ????????´????????????
		if (dist[y][x][t2] > dist[y][x][t]+1) {
			dist[y][x][t2] = dist[y][x][t]+1;
			enq(x, y, t2, dist[y][x][t2]);
		}

		// ?????????????§??????????
		for (i = 0; i < 6; i++) {
			x2 = x + mv[x&1][i][1], y2 = y + mv[x&1][i][0];
			e = dist[y][x][t] + (i!=d);
			if (-lx <= x2-BASE && x2-BASE <= lx && -ly <= y2-BASE && y2-BASE <= ly && !map[y2][x2]) {
				if (dist[y2][x2][t2] > e) {
					dist[y2][x2][t2] = e;
					enq(x2, y2, t2, e);
				}
			}
		}
	}
}

int main()
{
	int sx, sy, gx, gy, n, lx, ly, i, x, y, ans;

	fgets(p=buf, 30, stdin);
	sx = BASE+in(), sy = BASE+in(), gx = BASE+in(), gy = BASE+in();
	fgets(p=buf, 10, stdin), n = in();
	while (n--) {
		fgets(p=buf, 15, stdin), x = BASE+in(), y = BASE+in();
		map[y][x] = 1;
	}
	fgets(p=buf, 15, stdin), lx = in(), ly = in();

	dijkstra(sx, sy, lx, ly);
	ans = INF;
	for (i = 0; i < 6; i++) if (ans > dist[gy][gx][i]) ans = dist[gy][gx][i];
	if (ans == INF) puts("-1");
	else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2824
n,k = map(int,input().split())
m = min(k,n-1)
mod = 10**9+7

A = [0]*(m+1)
B = [0]*(m+1)

for i in range(m+1):
    if i == 0:
        A[0] = 1
        B[0] = 1
    else:
        A[i] = ((A[i-1]*(n-i+1))*pow(i,mod-2,mod)) % mod
        B[i] = ((B[i-1]*(n-i))*pow(i,mod-2,mod)) % mod

ans = 0
for i in range(m+1):
    ans = (ans+A[i]*B[i]) % mod

print(ans % mod)

Measured memory_bytes: 78644
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
 
int main(void){
	int x;
	int b=2;
	int max=1;
	int p=2;

	cin >> x ;


	while( b <= x ){
		while(pow(b,p) <= x){
			if (pow(b,p) >= max)
				max = pow(b,p);
			p++;
		}

		b++;
		p=2;
	}

	cout << max;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int ok = 0;

  for (int i = 0; i <= n; i++) {
    int tmp = k - m * i;
    int mod = (n - 2 * i);
    if (mod == 0) ok = (tmp == 0);
    else {
      if (tmp % mod == 0) if (tmp / mod >= 0 && tmp / mod <= m) ok = 1;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, d);
    Cout(800*d - 200*(d/15));
    //Cout(() ? "Yes" : "No");
    //Cout(() ? "YES" : "NO");
}

Measured memory_bytes: 256
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

-- 
--
--

main = do
    i <- getI
    putStrLn . show $ sum [1..i]


Measured memory_bytes: 508
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    n,k = map(int,ipt().split())
    if n == 1:
        print(k)
        exit()
    d = [True]*(n+1)
    v = [k-2]*(n+1)
    ans = k*(k-1)
    for i in range(n-1):
        a,b = map(int,ipt().split())
        if d[a]:
            d[a] = False
        else:
            ans *= v[a]
            ans %= mod
            v[a] -= 1
        a = b
        if d[a]:
            d[a] = False
        else:
            ans *= v[a]
            ans %= mod
            v[a] -= 1

    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 77056
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	ll l=0;
	ll r=sum;
	ll ans=1e16;
	for(ll i=0;i<n-1;i++)
	{
		// cout<<l<<r<<" ";
		l+=a[i];
		r-=a[i];
		ans=min(ans,abs(l-r));
	}
	cout<<ans;
    }
    return 0;
}


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

vector<int> gra[505];
int n;
bool vis[505];
int p[505];
bool find(int s)
{
	for(int i=0;i<gra[s].size();i++)
		if(vis[gra[s][i]]==0&&p[gra[s][i]]!=s)
		{
			vis[gra[s][i]]=1;
			if(p[gra[s][i]]==0 || find(p[gra[s][i]]))
			{
				p[gra[s][i]]=s;
				return 1;
			}
		}
	return 0;
}
int max_match()
{
	int ans=0;
	memset(p,0,sizeof(p));
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		ans+=find(i);
	}
	return ans;
}

int rx[505],ry[505];
int bx[505],by[505];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d",rx+i,ry+i);
    for(int i=0;i<n;i++)
        scanf("%d%d",bx+i,by+i);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if(rx[i]<bx[j]&&ry[i]<by[j])
            {
                gra[i+1].push_back(j+1);
            }
    printf("%d\n",max_match());
	return 0;
}



Measured memory_bytes: 256
n=int(input())
s=input()
s=[int(x=='B') for x in s]
mod=10**9+7
# sの要素をすべて0にする
d=[-1]*(2*n-1)
for i in range(2*n-1):
    if s[i]==s[i+1]:
        d[i]=1
    else:
        d[i]=0
op=[True]
# True:Left
for x in d:
    if x:
        op.append(not op[-1])
    else:
        op.append(op[-1])
if s[0]==0 or s[-1]==0 or op[-1] or sum(op)!=n:
    print(0)
    exit()
ans=1
lcnt=0
for i,x in enumerate(op):
    if x:
        lcnt+=1
    else:
        ans*=lcnt
        ans%=mod
        lcnt-=1
for i in range(1,n+1):
    ans*=i
    ans%=mod
print(ans)



Measured memory_bytes: 92716
#include <iostream>
#include <set>
#include <string>

using namespace std;

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

    set<string> memo;
    string Wi_ = "";
    string ans = "Yes";
    for (int i = 0; i < N; ++i) {
        string Wi;
        cin >> Wi;
        if (Wi_ != "") {
            if (Wi.front() != Wi_.back() ||
                memo.find(Wi) != memo.end()) {
                ans = "No";
            }
        }
        Wi_ = Wi;
        memo.insert(Wi_);
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  int s;
  cin >> s;
  map<int,int> m;
  for (int i = 1;; i++) {
    if (m[s]) {
      cout << i << endl;
      return 0;
    } else {
      m[s]++;
    }
    if (s % 2 == 0) {
      s /= 2;
    } else {
      s = 3 * s + 1;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
using namespace std;
int d[1025][1025][10];
struct node
{
    int ti;
    int r, c, time;
    node(int ti = 1, int r = 0, int c = 0, int time = 0) : ti(ti),r(r),c(c),time(time){}
};
int m,n,ying;
char a[1025][1025];
int used[1025];
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
bool is_walk(int r, int c)
{
    return r >= 0 && r < m && c >= 0 && c < n && a[r][c] != 'X';
}
int bfs(int r, int c)
{
    d[r][c][1] = 0;
    queue<node> q;
    q.push(node(1,r,c,0));
    while(q.size()){
        node m = q.front(); q.pop();
        if(a[m.r][m.c] - '0' == ying && used[ying]) return m.time;
        for(int i = 0; i < 4; i++){
            int x = m.r + dx[i], y = m.c + dy[i], ti = m.ti,time = m.time;
            if(!is_walk(x,y) || !d[x][y][ti]) continue;
            d[x][y][ti] = 0;
            if(isdigit(a[x][y])){
                if(a[x][y] - '0' == ti)
                  ti++ , used[a[x][y]-'0']++;
            }
            q.push(node(ti,x,y,time+1));
        }
    }
    return -1;
}
int solve()
{
    memset(d,-1,sizeof(d));
    memset(used,0,sizeof(used));
    for(int i = 0; i < m; i++)
        for(int j = 0; j < n; j++)
            if(a[i][j] == 'S'){
                return bfs(i,j);
            }
}
int main()
{
    while(scanf("%d%d%d",&m,&n,&ying) == 3){
        for(int i = 0; i < m; i++)
            scanf("%s",a[i]);
        printf("%d\n",solve());
    }
    return 0;
}

Measured memory_bytes: 43104
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);

    final int n = scanner.nextInt();
    scanner.nextLine();

    final boolean[] dislikes = new boolean[11];
    for (String s : scanner.nextLine().split(" ")) {
      dislikes[Integer.parseInt(s)] = true;
    }

    int pay = n;
    int cursor = 1;
    while (cursor <= pay) {
      if (dislikes[(pay / cursor) % 10]) {
        pay = (int) Math.floor(pay / cursor) * cursor + cursor;
        cursor = 1;
        continue;
      }

      cursor *= 10;
    }

    System.out.println(pay);
  }
}

Measured memory_bytes: 21844
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int N, D; scanf("%d%d", &N, &D);
    int X[1000][2]; rep(i, N) rep(j, 2) scanf("%d", &X[i][j]);
    two_sat G(N);
    rep(i, N) rep(j, i) {
        if (abs(X[i][0] - X[j][0]) < D) G.add_clause(i, false, j, false);
        if (abs(X[i][0] - X[j][1]) < D) G.add_clause(i, false, j, true);
        if (abs(X[i][1] - X[j][0]) < D) G.add_clause(i, true, j, false);
        if (abs(X[i][1] - X[j][1]) < D) G.add_clause(i, true, j, true);
    }
    bool ok = G.satisfiable();
    printf(ok ? "Yes\n" : "No\n");
    if (ok) {
        auto ans = G.answer();
        rep(i, N) printf("%d\n", ans[i] ? X[i][0] : X[i][1]);
    }

    return 0;
}

Measured memory_bytes: 3860
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

cds t n
  | q<t = []
  | r==0 = if q==t then [t] else t : (cds (t+1) n) ++ [q] 
  | otherwise = cds (t+1) n
  where (q,r) = divMod n t


main = getLine >> getInts >>= mapM_ print . cds 1 . foldl1 gcd

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

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

  int ans = 0;
  int now = 7;
  while ( ans++ < 1e7 ) {
    if ( now%k == 0 ) {
      cout << ans << endl;
      return 0;
    }
    now *= 10;
    now += 7;
    now %= k;
  }

  cout << -1 << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  int x = 1900*M+100*(N-M);
  double p = 1/pow(2, M);
  /*
  かかる時間の期待値をEとする
  まず、最低でも1回は提出しないと成功しないので
    E = x + ?
  1回目で成功した場合、その後にかかる時間は0なので
    E = x + p*0 + ?
  1回目で成功しなかった場合、2回目から再度スタートする
  何回連続で失敗しても、次の回で成功する確率はpなので
  2回目からスタートして終わるまでにかかる時間の期待値もEとなる
  よって
    E = x + p*0 + (1-p)*E
  これを変形すると
  　E = x/p
  となる
  */
  cout << x/p << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[20];

bool exhaustiveSearch(int i, int m) {
  if (m < 0 || i >= n) return false;
  if (m == A[i]) return true;
  else return exhaustiveSearch(i + 1, m) || exhaustiveSearch(i + 1, m - A[i]);
}

int main() {
  int q, m;
  
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( int i = 0; i < q; i++ ) {
    scanf("%d", &m);
    exhaustiveSearch(0, m) ? printf("yes\n") : printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2628
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = n-1; i > 0; i--) cout << a[i] << " ";
    cout << a[0] << endl;
    return 0;
}



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

using namespace std;

void Main()
{
    int d;
    cin >> d;
    string ret = "Christmas";
    for (int i = d; i < 25; ++i)
        ret += " Eve";

    cout << ret;
}

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

    //std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import *
n = int(input())
a = list(map(int, input().split()))

left = a[:n]
right = a[2*n:]
heapify(left)
l = [sum(left)]
r = [sum(right)]
sl = sum(left)
sr = sum(right)
for i in range(n):
    k = heappop(left)
    sl -= k
    heappush(left, max(k, a[n+i]))
    sl += max(k, a[n+i])
    l.append(sl)

right = [-i for i in right]
heapify(right)
for i in range(n):
    k = -heappop(right)
    sr -= k
    mini = min(k, a[2*n-1-i])
    heappush(right, -mini)
    sr += mini
    r.append(sr)

r.reverse()
ans = -10**15
for i in range(n+1):
    ans = max(l[i] - r[i], ans)

print(ans)


Measured memory_bytes: 37212
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String w,t,n;
    int co=0;
        n = "END_OF_TEXT";
           w = s.next();
           while(true){
               t = s.next();
               if(t.equalsIgnoreCase(w))co++;
               else if(t.equals(n))break;
           }
           System.out.println(co);
    }
}


Measured memory_bytes: 26320
def isR(st):
    f=True
    for x in range(len(st)):
        if st[x]!=st[-x-1]:f=False
    return f

s=input()
if isR(s) and isR(s[:(len(s)-1)//2]) and isR(s[(len(s)+3)//2-1:len(s)]):
    print("Yes")
else:print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string s;
    cin >> s;
    ll ans = linf;

    
    rep(i,0,2){
	int n = i;
	ll t = 0;
	rep(j,0,sz(s)){
	    if(s[j] != (char)('0' + n))t++;
	    n++;
	    if(n == 2)n = 0;
	}
	ans = min(ans,t);
    }


    P(ans);
    return  0;
}


Measured memory_bytes: 512
import java.util.Scanner;

/**
 * https://abc059.contest.atcoder.jp/tasks/arc072_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		sc.close();
		
		String ans = Math.abs(x-y) <= 1 ? "Brown" : "Alice";
		System.out.println(ans);

	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int f[100010][3],a[100010][3];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<=n;++i)for(int j=0;j<3;++j)a[i][j]=gi();
	for(int i=0;i<3;++i)f[1][i]=a[1][i];
	for(int i=1;i<n;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<3;++k)
				if(j!=k)cxk(f[i+1][k],f[i][j]+a[i+1][k]);
	int ans=0;for(int i=0;i<3;++i)cxk(ans,f[n][i]);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,n;
    cin >> n;
    ll a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n, greater<ll>());
    ll ans = a[0];
    for(int i=1; i<n-1; i++)
    {
        ans += a[(i+1)/2];
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 5176
n = int(input())
a = []
for i in range(2**n):
    a.append(int(input()))

for i in range(n):
    delta = 2**(i+1)
    half = delta // 2
    for j in range(0, 2**n, delta):
        p = a[j]; q = a[j + half]
        if p == q:
            continue
        else:
            a[j] = abs(p - q)

print(a[0])

Measured memory_bytes: 13472
#include<stdio.h>
int main()
{
    int n, tt;
    scanf("%d %d", &n, &tt);
    int i;
    int c[102], t[102];
    for (i = 0; i < n; i++)
        scanf("%d %d", &c[i], &t[i]);
    int ans = 2000000000;
    for (i = 0; i < n; i++)
        if (c[i] < ans && t[i] <= tt)
            ans = c[i];
    if (ans == 2000000000)
        printf("TLE\n");
    else
        printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int x[105], y[105];
int n;
double p1 = 0, p2 = 0, p3 = 0, pinf = 0;
int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> x[i];
    for(int i = 1; i <= n; ++i) cin >> y[i];
    
    for(int i = 1; i <= n; ++i){
        p1 += fabs(x[i] - y[i]);
        p2 += (x[i] - y[i]) * (x[i] - y[i]);
        p3 += fabs(x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
        pinf = pinf >= fabs(x[i] - y[i]) ? pinf : fabs(x[i] - y[i]);
    }
    cout << fixed << setprecision(6) << p1 << endl;
    cout << fixed << setprecision(6) << sqrt(p2) << endl;
    cout << fixed << setprecision(6) << cbrt(p3) << endl;   //或pow(p3, 1.0 / 3.0)
    cout << fixed << setprecision(6) << pinf << endl;
    return 0;
}


Measured memory_bytes: 3428