akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 2e2 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m, k;
int a[]={11,2,5};

int main(){
    ios;
    cin>>n;
    ll cnt=1, p=7, q=10;
    while(1){
        if(p%n==0) return cout<<cnt, 0;
        p=(p+7*q)%n;
        q=q*10%n;
        ++cnt;
        if(cnt==1e7) return cout<<-1,0;
    }
    return 0;
}

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

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

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 or i % 5 == 0);
        else {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<vector>
#include <stdio.h>

using namespace std;

#define mod 1000000007LL
#define pi 3.141592653589793238462643383279;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Draw";
    }
    else if(a==1)
    {
        cout<<"Alice";
    }
    else if(b==1)
    {
        cout<<"Bob";
    }
    else if(a>b)
    {
        cout<<"Alice";
    }
    else
        cout<<"Bob";
   // int acc;cin>>acc;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#define inf 1000000000

using namespace std;

struct edge{
	int to, cost;
	edge(){}
	edge(int a, int b){
		to = a, cost = b;
	}
};

int n, k, s;
int x[2005], y[2005], z[2005];

bool used[2005];
vector<edge> G[2005];

int dfs(int v, int prev, int k)
{
	if(k == 0){
		for(int i = 0; i < G[v].size(); i++){
			if(used[G[v][i].to] && G[v][i].to != prev) return G[v][i].cost;
		}
		return 0;
	}
	used[v] = true;
	
	int ret = -inf;
	for(int i = 0; i < G[v].size(); i++){
		if(used[G[v][i].to]) continue;
		ret = max(ret, G[v][i].cost + dfs(G[v][i].to, v, k-1));
	}
	used[v] = false;
	return ret;
}

int main(void)
{
	while(1){
		cin >> n >> k >> s;
		if(n == 0 && k == 0 && s == 0) break;
		for(int i = 1; i <= n; i++){
			cin >> x[i] >> y[i] >> z[i];
		}
		
		for(int i = 1; i <= n; i++) G[i].clear();
		int dx, dy, dz, w;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				if(i >= j) continue;
				dx = s - abs(x[i] - x[j]);
				dy = s - abs(y[i] - y[j]);
				dz = s - abs(z[i] - z[j]);
				if(dx < 0 || dy < 0 || dz < 0) continue;
				w = 2 * (dx*dy + dy*dz + dz*dx);
				G[i].push_back( edge(j, w) );
				G[j].push_back( edge(i, w) );
			}
		}
		
		int ans = -inf;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++) used[j] = false;
			ans = max(ans, dfs(i, -1, k-1));
		}
		
		if(ans < 0) cout << -1 << endl;
		else cout << 6*s*s*k - ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
int main()
{
	int t,n,i;
	for(i=0;i<4;i++){
		scanf("%d%d",&t,&n);
		switch(t){
		case 1:
			printf("%d\n",6000*n);
			break;
		case 2:
			printf("%d\n",4000*n);
			break;
		case 3:
			printf("%d\n",3000*n);
			break;
		default:
			printf("%d\n",2000*n);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
main(){
//int x,y;cin>>x>>y;
//if((y-2*x)>=0&&(y-2*x)%2==0&&(4*x-y)>=0&&(4*x-y)%2==0)puts("Yes");
//else puts("No");
int x,n;
cin>>x>>n;
map<int,int>m;
int a[n];for(int i=0;i<n;i++) cin>>a[i],m[a[i]]=1;
sort(a,a+n);
int mn=100000,mnnum;
for(int i=-200;i<=200;i++){
    if(mn>abs(i-x)&&m[i]==0) mn=abs(i-x),mnnum=i;
    else if(mn==abs(i-x)&&m[i]==0) mnnum=min(mnnum,i);
}
cout<<mnnum;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define forn(i,n) for(int i=0;i<(int) n;i++)
#define Forn(i,n) for(int i=1;i<=(int) n;i++)
lli a[100005];
lli b[100005];
int main()
{
   lli n,i;
   cin>>n;
   n++;
   for(i=1;i<=n;i++) cin>>a[i];

   for(i=1;i<n;i++) cin>>b[i];
   lli sum=0;
   for(i=1;i<n;i++)
   {
       if(a[i]>=b[i])
       {
            sum+=b[i];
           a[i]-=b[i];
           b[i]-=b[i];

       }
       else if(a[i]<b[i])
       {
           sum+=a[i];
           b[i]-=a[i];

       }
       if(b[i])
       {
           if(a[i+1]>b[i])
           {
               sum+=b[i];
               a[i+1]-=b[i];
           }
           else
           {
               sum+=a[i+1];
               a[i+1]=0;

           }
       }

   }
   cout<<sum;

}






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


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

    int odd = 0, not4 = 0, four = 0;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        if (a % 4 == 0) {
            ++four;
            continue;
        }
        if (a & 1) ++odd;
        else ++not4;
    }
    
    odd += (not4 & 1);

    puts(odd <= four + 1 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w, m;
    cin >> h >> w >> m;
    //vector<vector<bool>> hw(h, vector<bool>(w, false));
    set<pair<int, int>> st;
    vector<int> hnum(h, 0);
    vector<int> wnum(w, 0);
    rep(i, m) {
        int hh, ww;
        cin >> hh >> ww;
        --hh, --ww;
        st.insert(make_pair(hh, ww));
        ++hnum[hh];
        ++wnum[ww];
    }
    int hnum_max = *max_element(hnum.begin(), hnum.end());
    int wnum_max = *max_element(wnum.begin(), wnum.end());
    vector<int> hmax_idx;
    vector<int> wmax_idx;
    rep(i, h) {
        if (hnum[i] == hnum_max) hmax_idx.push_back(i);
    }
    rep(i, w) {
        if (wnum[i] == wnum_max) wmax_idx.push_back(i);
    }
    if ((ll)(hmax_idx.size()) * (ll)(wmax_idx.size()) > m) {
        cout << hnum_max + wnum_max << endl;
        return 0;
    }
    int ans = 0;
    for (auto hidx: hmax_idx) {
        for  (auto widx: wmax_idx) {
            if (st.count(make_pair(hidx, widx)) != 0) {
                ans = max(ans, hnum_max + wnum_max - 1);
            }
            else {
                ans = max(ans, hnum_max + wnum_max);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23680
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;

int to[100005],nxt[100005],hed[100005] = {0},ec = 0;
void add_edge(int f,int t){
	ec ++; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

int n,k,a[100005],ans = 0;

int dfs(int v,int dep){
	int tmp = dep;
	for(int i = hed[v];i;i = nxt[i]){
		tmp = max(tmp,dfs(to[i],dep + 1));
	}
	if(a[v] != 1 && tmp - dep == k - 1){
		a[v] = 1;
		ans ++;
		return -1;
	}
	return tmp;
}

int main(){
	scanf("%d %d",&n,&k);
	scanf("%d",&a[1]); if(a[1] != 1) ans ++; a[1] = 1;
	for(int i = 2;i <= n;i ++){
		scanf("%d",&a[i]);
		add_edge(a[i],i);
	}
	dfs(1,0);
        cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int max_1=0, max_2=0;
	int a[N];
	rep(i, N)
	{
		cin >> a[i];
		if (a[i] > max_1)
		{
			max_2 = max_1;
			max_1 = a[i];
		}
		else if (a[i] > max_2)
		{
			max_2 = a[i];
		}
	}

	rep(i, N)
	{
		if (a[i] == max_1)
		{
			cout << max_2 << endl;
		}
		else
		{
			cout << max_1 << endl;
		}
		
	}
	
	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

char A[2020],B[2020],C[2020];
ll An, Bn, Cn;
ll i, j, k;
bool mkab[20202], mkac[20202], mkbc[20202];

void mkcalc(char *sa,char *sb,bool *mk){
    ll i,j;
    for (i = 0; sa[i];++i){
        for (j = 0; sb[j];++j){
            if(sa[i]!='?'&&sb[j]!='?'&&sa[i]!=sb[j]){
                mk[i - j + 10101] = true;
            }
        }
    }
}

int main(){
    scanf("%s%s%s", A, B, C);
    An = strlen(A);
    Bn = strlen(B);
    Cn = strlen(C);
    mkcalc(A, B, mkab);
    mkcalc(A, C, mkac);
    mkcalc(B, C, mkbc);

    ll ans = 101010;
    fornum(i,-4040,4040){
        fornum(j,-4040,4040){
            if(!mkab[i+10101]&&!mkac[j+10101]&&!mkbc[j-i+10101]){
                ans = min(ans, max(An, max(i + Bn, j + Cn)) - min(0ll, min(i, j)));
            }
        }
    }
    printf("%lld", ans);

    return 0;
}

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

typedef string::const_iterator Iterator;
bool val[256];
bool table[3][2][2] = {
	{0, 0, 0, 1},
	{0, 1, 1, 1},
	{1, 1, 0, 1}
};

bool equation(Iterator &);
bool expr(Iterator &);
bool number(Iterator &);
bool term(Iterator &);

bool equation(Iterator &it)
{
	bool lhs = expr(it);
	++it;
	bool rhs = expr(it);
	return lhs == rhs;
}

bool expr(Iterator &it)
{
	if (isalpha(*it)){
		return number(it);
	}
	
	return term(it);
}

bool number(Iterator &it)
{
	bool res = val[*it];
	++it;
	return res;
}

bool term(Iterator &it)
{
	if (*it == '-'){
		++it;
		return !expr(it);
	}
	
	++it;
	bool lhs = expr(it);
	int op = [&](){
		int res;
		if (*it == '*') res = 0;
		if (*it == '+') res = 1;
		if (*it == '-') res = 2;
		it += (res == 2) ? (2) : (1);
		return res;
	}();
	bool rhs = expr(it);
	++it;
	
	return table[op][lhs][rhs];
}

int main()
{
	val['T'] = true;
	
	string str;
	while (cin >> str, str != "#"){
		bool res = true;
		
		for (int bit = 0; bit < (1 << 11); bit++){
			for (int i = 0; i < 11; i++){
				val['a' + i] = (bit >> i) & 1;
			}
			
			Iterator it = str.begin();
			if (!equation(it)){
				res = false;
				break;
			}
		}
		
		puts(res ? "YES" : "NO");
	}
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int main(void){
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	cout << ((e-a>k)?":(":"Yay!") << endl;
	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 rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string o, e;
    cin >> o >> e;
    if (o.size() == e.size())
    {
        rep(i, o.size())
        {
            cout << o[i] << e[i];
        }
        cout << "\n";
    }
    else
    {
        rep(i, e.size())
        {
            cout << o[i] << e[i];
        }
        cout << o.back() << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
const ll MOD = (ll) 1e9 + 7;

vb vis;
// xx = weiss, yy = schwarz
vector<pll> dp;
vvl adj;

pll dfs(ll pos) {
	if (vis[pos]) {
		return {1,1};
	}
	vis[pos] = true;

	ll weiss = 1;
	ll schwarz = 1;
	FOR(i,0,sz(adj[pos])) {
		if (!vis[adj[pos][i]]) {
			pll next = dfs(adj[pos][i]);
			weiss = (weiss * (next.xx + next.yy)) % MOD;
			schwarz = (schwarz * (next.xx)) % MOD;
		}
	}
	dp[pos].xx = weiss;
	dp[pos].yy = schwarz;

	return dp[pos];
}

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

	ll n; cin >> n;

	adj.assign(n,vl());

	FOR(i,0,n-1) {
		ll x,y; cin >> x >> y;
		x--; y--;

		adj[x].pb(y);
		adj[y].pb(x);
	}
	vis.assign(n,false);
	dp.assign(n,mp(-1,-1));

	pll erg = dfs(0);
	cout << (erg.xx + erg.yy) % MOD << endl;

	return 0;
}


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

const int INF = 1001001001;
vector<int> to[100005];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i,n) {
        if (i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10644
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Z-Algorithm or ローリングハッシュが想定解？
 * http://drken1215.hatenablog.com/entry/2019/09/16/014600
 * LCP(Longest Common Prefix)配列をどう求めるかで方針が異なる．
 * LCP Array: https://blog.shibayu36.org/entry/2017/01/06/103956
 */
public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        // test();
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String S = sc.next();

        int ans = solveDP(N, S);

        System.out.println(ans);
    }
  
    private static int solveDP(int N, String S) {
        int count = 0;
        // dp[i][j]: i文字目からとj文字目からとで一致する文字列長
        int[][] dp = new int[N+1][N+1];


        for (int i=N-1; i>=0; i--) {
            for (int j=N-1; j>i; j--) {
                if (S.charAt(i) == S.charAt(j)) {
                    dp[i][j] = Math.max(dp[i][j], dp[i+1][j+1]+1);
                }

                count = Math.max(count, Math.min(dp[i][j], j-i));
            }
        }

        return count;
    }
}

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, alphabet_cnt[51][26] = {};
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, s.size()) {
            ++alphabet_cnt[i][s[j] - 'a'];
        }
    }

    int minimum_alphabet_cnt[26] = {};
    rep(i, 26) {
        int min_cnt = 51;
        rep(j, n) {
            min_cnt = min(min_cnt, alphabet_cnt[j][i]);
        }
        minimum_alphabet_cnt[i] = min_cnt;
    }

    string ans = "";
    rep(i, 26) {
        string tmp(minimum_alphabet_cnt[i], 'a' + i);
        ans += tmp;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main()
{
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> a(n),b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    for(int i = x+1; i <= y; i++){
        if(a.back() < i && i <= b.front()){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    LL N, M;
    cin >> N >> M;

    LL ans = 0;
    if(N == 1 && M == 1){
        ans = 1;
    }else if(N == 1){
        ans = M - 2;
    }else if(M == 1){
        ans = N - 2;
    }else{
        ans = (N-2)*(M-2);
    }
    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 3592
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7

S = input()

ans = 0
for i in range(len(S)):
    if i % 2 == 0 and S[i] in 'RUD':
        continue
    elif i % 2 == 1 and S[i] in 'LUD':
        continue
    else:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string func(vector<int> &n_abcd, int index, int count, string formula) {
    if (index >= 3) {
        // ベースケース
        if (count == 7) {
            return formula;
        }
        else {
            return formula.substr(0, formula.size() - 2);
        }
    }
    else {
        //再帰ケース
        formula = func(n_abcd, index + 1, count + n_abcd.at(index + 1), formula += "+" + to_string(n_abcd.at(index + 1)));
        if (formula.size() == 7) {
            return formula;
        }
        formula = func(n_abcd, index + 1, count - n_abcd.at(index + 1), formula += "-" + to_string(n_abcd.at(index + 1)));
        if (formula.size() == 7) {
            return formula;
        }
        return formula.substr(0, formula.size() - 2);
    }
}

int main()
{
    string abcd;
    cin >> abcd;


    int num = stoi(abcd);
    vector<int> n_abcd(4);

    for (int i = 0; i < 4; i++) {
        n_abcd.at(i) = num % 10;
        num /= 10;
    }
    reverse(n_abcd.begin(), n_abcd.end());

    string result = func(n_abcd, 0, n_abcd.at(0), to_string(n_abcd.at(0)));
    cout << result + "=7" << endl;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

void push(ll to, ll cost, priority_queue<P, vector<P>, greater<> > &pque, unordered_map<ll, ll> &dist){
    if(dist[to] == 0 || dist[to] > cost){
        dist[to] = cost;
        pque.emplace(cost, to);
    }
}

int main() {
    cin>>Q;
    const ll dflt = 1000;
    const vec d = {2, 3, 5};
    rep(_, Q){
        vec cost(4);
        cin>>N;
        rep(i,4) cin>>cost[i];
        priority_queue<P, vector<P>, greater<> > pque;
        unordered_map<ll, ll> dist;
        pque.emplace(dflt, N);
        dist[N] = dflt;
        while(!pque.empty()){
            P p = pque.top(); pque.pop();
            //cout<<_<<' '<<p.fi - dflt<<' '<<p.se<<endl;
            if(p.se == 0) {
                cout<<p.fi - dflt<<endl;
                break;
            }
            if(dist[p.se] < p.fi) continue;
            rep(i, 3){
                ll plus, to;
                if(p.se%d[i] == 0){
                    to = p.se / d[i];
                    plus = cost[i];
                    if((p.se - p.se / d[i]) < INF / cost[3]) chmin(plus, (p.se - p.se / d[i]) * cost[3]);
                    push(to, p.fi + plus, pque, dist);
                }else{
                    to = p.se - (p.se % d[i]); plus = cost[3] * (p.se % d[i]);
                    push(to, p.fi + plus, pque, dist);
                    to = d[i] + to; plus = cost[3] * (to - p.se);
                    push(to, p.fi + plus, pque, dist);
                }
            }
        }
    }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

int main() {
	int N;
	cin >> N;
	
	vector< lint > p(N + 1, 0);
	for_(i,2,N+1) {
		if (p[i] == 1) {
			for (int j = 2 * i; j <= N; j += i) p[j] = -1;
		}
	}
	
	for_(x,2,N+1) {
		int y = x;
		for_(i,2,N+1) {
			while (p[i] >= 0 && y % i == 0) {
				y /= i;
				++p[i];
			}
		}
	}
	
	lint ans = 1, MOD = (lint)1e9 + 7;
	for_(i,2,N+1) {
		if (p[i] >= 0) {
			ans *= (p[i] + 1);
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int rank,n,i,S[14]={0},H[14]={0},C[14]={0},D[14]={0},j;
	char kind;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d",&kind,&rank);
		getchar();
    	if(kind=='S'){
			S[rank]=1;
    	}
    	if(kind=='H'){
      		H[rank]=1;
    	}
    	if(kind=='C'){
      		C[rank]=1;
    	}
    	if(kind=='D'){
      		D[rank]=1;
		}
	}
	
	for(j=1;j<=13;j++){
		if(S[j]==0){
			printf("S %d\n",j);
		}
	}
	for(j=1;j<=13;j++){
		if(H[j]==0){
			printf("H %d\n",j);
		}
	}
	for(j=1;j<=13;j++){
		if(C[j]==0){
			printf("C %d\n",j);
		}
	}
	for(j=1;j<=13;j++){
		if(D[j]==0){
			printf("D %d\n",j);
		}
	}
	
	return 0;
}

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


const int MAX_N = 8;
vector<vector<int> > Graph(MAX_N + 1);
int N;
int ans;

void dfs(vector<bool> searched, int target, int depth) {
    searched[target] = true;
    if (depth == N) {
        ans++;
        return;
    } else {
        for (int to:Graph[target]) {
            if (!searched[to]) {
                dfs(searched, to, depth + 1);
            }
        }
    }
}

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

    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }

    vector<bool> s(M + 1, false);
    ans = 0;
    
    dfs(s, 1, 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

struct D{
    double L, a, b;
};

inline double sqr(double lhs, double rhs) {
    return (lhs - rhs) * (lhs - rhs);
}
inline double operator+(D lhs, D rhs) {
    return sqr(lhs.L, rhs.L) + sqr(lhs.a, rhs.a) + sqr(lhs.b, rhs.b);
}

int n, m;

int main(void){
    cin >> n >> m;
    vector<D> vd(n);
    for (int i = 0; i < n; i++) cin >> vd[i].L >> vd[i].a >> vd[i].b;
    
    double ans = 0;
    for (int x = 0; x < (1 << n); x++) {
        int c = 0;
        for (int i = 1; i < (1 << n); i <<= 1) if (x & i) c++;
        if (c != m) continue;
        
        double sum = 0;
        for (int i = 0;(1 << i) < x ; i++) {
            if ((1 << i) & x) {
                for (int j = i+1; (1 << j) < x; j++) {
                    if ((1 << j) & x) {
                        sum += vd[i] + vd[j];
                    }
                }
            }
        }
        ans = max(ans, sum);
    }
    printf("%.8lf\n", ans);
    
    return 0;
}

Measured memory_bytes: 3280
#include <stdio.h>

typedef struct{
	int p;
	int left;
	int right;
}Tree;

void preparse(int);
void inparse(int);
void postparse(int);

Tree tree[100];
int n;

int main(){
	int i,root,p,left,right;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		tree[i].p = -1;
	}
	for(i=0;i<n;i++){
		scanf("%d%d%d",&p,&left,&right);
		tree[p].left = left;
		tree[p].right = right;
		if(left != -1)tree[left].p = p;
		if(right != -1)tree[right].p = p;
	}

	for(i=0;i<n;i++){
		if(tree[i].p == -1)root = i;
	}

	printf("Preorder\n");
	preparse(root);
	printf("\nInorder\n");
	inparse(root);
	printf("\nPostorder\n");
	postparse(root);
	printf("\n");
	return 0;
}

void preparse(int u){
	if(u== -1)return ;
	printf(" %d", u);
	preparse(tree[u].left);
	preparse(tree[u].right);
}

void inparse(int u){
	if(u==-1)return ;
	inparse(tree[u].left);
	printf(" %d",u);
	inparse(tree[u].right);
}

void postparse(int u){
	if(u==-1)return ;

		postparse(tree[u].left);
		postparse(tree[u].right);
		printf(" %d", u);
	
}

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

int main() {

    int N;
    int A;
    int B;

    int sum = 0;
    string n_str;

    cin >> N >> A >> B;

    for (int i = 1; i <= N; i++) {

        n_str = to_string(i);

        //cout << "n_str: " <<  n_str << endl;

        int tmp = 0;
        for (int j = 0; j < n_str.size(); j++) {

            tmp = tmp + (int)n_str[j] - 48;
            //cout << "tmp: " << tmp << endl;
        }

        if (tmp >= A && tmp <= B){
            sum = sum + i;
        }
    }

    cout <<  sum << endl;

    return 0;

}

Measured memory_bytes: 3688
#include<stdio.h>

int main()
{
  int a,b,c,d;
  int max,min;
  int ans;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a>=c){
    max=a;
  }
  else max=c;
  if(b<d){
    min=b;
  }
  else min=d;
  ans=min-max;
  if(ans<=0) ans=0;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1692
program nextPrime
    implicit none
    integer(16):: x

    read*, x
    do while(.true.)
        call judge_prime(x)
        x = x + 1
    end do

contains
    subroutine judge_prime(x)
        integer(16):: x, i

        do i=2,int(sqrt(real(x)))
            if (mod(x,i) == 0) then
                return
            endif
        end do
        print*, x
        stop
    end subroutine


end program nextPrime

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(){
  cin >> n >> s >> t;
  rep(i,n) cout << s[i] << t[i];
  cout << "\n";
  // vector<int> v = {};
  // while(t--){}
  // rep(i,v.size()) cout << v[i] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a,b;
  cin >> a >> b;
  long i;
  vector<long> power(41),abin(41),bbin(41);
  long tmp = 1;
  for(i=0;i<41;i++){
    power[i] = tmp;
    tmp *= 2;
  }
  
  for(i=0;i<41;i++){
    abin[40-i] = a/power[40-i];
    a %= power[40-i];
    bbin[40-i] = b/power[40-i];
    b %= power[40-i]; 
  }
  for(i=2;i<41;i++){
    abin[i] = abin[i] * ((abin[0])%2);
    bbin[i] = bbin[i] * ((bbin[0]+1)%2);
  }
  if(abin[0] == abin[1]) {
  }else if(abin[0] == 0 && abin[1] == 1){
    abin[0] = 1;abin[1] = 0;
  }else{
    abin[0] = 0;abin[1] = 0;
  }
  if(bbin[1] == 0){
  }else if(bbin[0] == 0){
    bbin[0] = 1;
  }else{
    bbin[0] = 0;bbin[1] = 0;
  }
  long ans=0;
  for(i=0;i<41;i++){
    ans += ((abin[i] + bbin[i])%2) * power[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int sum = 0;
        int count = 0;
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=n;++j){
                if(i%j == 0){
                    sum = sum + 1;
                }
            }
            if(sum==8 && i%2==1){
                count = count + 1;
            }
            sum = 0;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35748
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
int a[N];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    ll ans = 0;
    unordered_map<int, int> ma;
    for(int i = 1; i <= n; i++) {
        if(ma.count(i - 1 - a[i])) {
            ans += ma[i - 1 - a[i]];
        }
        ma[i - 1 + a[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 12064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

long long gcd(long long a, long long b){return (b == 0)? a : gcd(b, a % b);}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll x; cin >> x;
	ll g = gcd(x, 360);
	print(360 / g)
	
	return 0;
}

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

int main(){
  int N, Q; cin >> N >> Q;
  map<int, set<int>> mp;
  for (int i=0; i<N-1; i++){
    int a, b;
    cin >> a >> b;
    mp[a].insert(b);
    mp[b].insert(a);
  }
  vector<int> score(N+1,0);
  for (int i=0; i<Q; i++){
    int p, x;
    cin >> p >> x;
    score[p] += x;
  }
  vector<int> ans(N+1,-1);
  ans[1] = score[1];
  queue<int> que;
  que.push(1);
  while(!que.empty()){
    int check = que.front();
    que.pop();
    for (auto k: mp[check]){
      if (ans[k]==-1){
        ans[k] = ans[check] + score[k];
        que.push(k);
      }
    }
  }
  for (int i=1; i<=N; i++){
    if (i>1) cout << ' ';
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 42112
import math
n, a, b = map(int, input().split())
mod = 10**9 + 7

ans = pow(2, n, mod) - 1

x = 1
y = 1
for i in range(a):
  x = x*(n - i)%mod
  y = y*(i + 1)%mod
ans -= x*pow(y, mod - 2, mod)%mod
  
x = 1
y = 1
for i in range(b):
  x = x*(n - i)%mod
  y = y*(i + 1)%mod
ans -= x*pow(y, mod - 2, mod)%mod
  
print(ans%mod)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define long long long
const int MOD=1e9+7;

int mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n, long k){
  if(n<=k) return 1;
  return (n*mfact(n-1,k))%MOD;
}

long minv(long k){
  if(k<=1) return 1;
  return (mpow(k, MOD-2)*minv(k-1))%MOD;
}
long mcomb(long n,long k){
  return (mfact(n,n-k)*minv(k))%MOD;
}

int main(){
  long n, a, b;
  cin >> n >> a >> b;
  long ans = mpow(2,n);
  ans = (ans-mcomb(n,a))%MOD;
  ans = (ans-mcomb(n,b))%MOD;
  ans--;
  if(ans<0) ans+=MOD;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main () {
	int n;
	scanf("%d", &n);
	if (n % 1000 == 0) {
		printf("0\n");
		return 0;
	}
	for (int i = 1; i <= 1000; i++)
		if ((n + i) % 1000 == 0) {
			printf("%d\n", i);
			return 0;
		}
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#define MAX 10000000
using namespace std;

int main(){
  int n,m;
  int go[101][101];
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++) go[i][j] = MAX;
  }
  cin >> n;
  for(int i=0;i<n;i++){
    int r,k,tmp;
    cin >> r >> k;
    for(int j=0;j<k;j++){
      cin >> tmp;
      go[r][tmp] = 1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
	go[j][k] = min(go[j][k],go[j][i] + go[i][k]);
      }
    }
  }
  cin >> m;
  while(m--){
    int s,d,ttl;
    cin >> s >> d >> ttl;
    if(go[s][d]+1 > ttl) cout << "NA" << endl;
    else cout << go[s][d]+1 << endl;
  }
}

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

int main(void) {
    long long N, H, W;
    cin >> N >> H >> W;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        long long A, B;
        cin >> A >> B;
        if (H <= A && W <= B) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

class Main{

    int INF = Integer.MAX_VALUE;
    int[] pos = {INF, 0, 1, 2, 0, INF, 2, 0, 1, 2};

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            String line = sc.next();
            if(line.equals("#")) break;
            char[] step = line.toCharArray();
            int n = step.length;

            int[][] dp = new int[n][2];
            for(int i=0; i<n; i++) Arrays.fill(dp[i], INF);

            dp[0][0] = 0; dp[0][1] = 0;
            for(int i=0; i<n-1; i++){
                int idx1 = step[i+1]-'0', idx2 = step[i]-'0';
                
                if(checkRL(idx2, idx1)) dp[i+1][0] = dp[i][1];
                else if(dp[i][0]!=INF) dp[i+1][0] = Math.min(dp[i+1][0], dp[i][0]+1);
                
                if(checkRL(idx1, idx2)) dp[i+1][1] = dp[i][0];
                else if(dp[i][1]!=INF) dp[i+1][1] = Math.min(dp[i+1][1], dp[i][1]+1);
            }

            System.out.println(Math.min(dp[n-1][0], dp[n-1][1]));
        }
    }

    boolean checkRL(int r, int l){
        if(pos[l]>pos[r]) return false;
        return true;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 43344
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int n, p[1009], x[1009], dp[1009]; bool f = true; vector<int> g[1009];
void dfs(int pos) {
	vector<vector<int> > dp2(g[pos].size() + 1, vector<int>(x[pos] + 1, inf));
	fill(dp2[0].begin(), dp2[0].end(), 0);
	for (int i = 0; i < g[pos].size(); i++) {
		int p = g[pos][i];
		dfs(p);
		for (int j = x[pos]; j >= x[p]; j--) dp2[i + 1][j] = min(dp2[i + 1][j], dp2[i][j - x[p]] + dp[p]);
		for (int j = x[pos]; j >= dp[p]; j--) dp2[i + 1][j] = min(dp2[i + 1][j], dp2[i][j - dp[p]] + x[p]);
	}
	int ret = *min_element(dp2[g[pos].size()].begin(), dp2[g[pos].size()].end());
	if (ret == inf) f = false;
	dp[pos] = ret;
}
int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> p[i], p[i]--;
		g[p[i]].push_back(i);
	}
	for (int i = 0; i < n; i++) cin >> x[i];
	dfs(0);
	cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 13292
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N=sc.nextLong();
        boolean one = false;
        if(N==1) {
            one=true;
        }

        List<Integer[]> numbers = new ArrayList<Integer[]>();


        for(int i=2; i<1000000; i++) {
            int count=0;
            while(N%i==0) {
                N/=i;
                count++;
            }
            if(count!=0) {
                Integer[] prime = {i,count};
                numbers.add(prime);
            }
        }

        if(one) {
            System.out.println(0);
        }else if(numbers.isEmpty()) {
            System.out.println(1);
        }else{
            int count=0;
            for(Integer[] inside : numbers) {
                int minus = 1;
                while(true) {
                    if(inside[1]>=minus) {
                        count++;
                        inside[1]-=minus;
                        minus++;
                    }else {
                        break;
                    }
                }
            }
            if(N==1) {
                System.out.println(count);
            }else {
                System.out.println(count+1);
            }
        }

    }

}


Measured memory_bytes: 35820
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,a,i,d[100010];
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<n;i++)d[i]=N[hout()];
  a=1e9;
  for(i=m-1;i<n;i++){
    if(a>d[i]-d[i-m+1])a=d[i]-d[i-m+1];
  }
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;

class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        string s = ReadLineStr();
        int length = s.Length;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            sb.Append(ary[n + Array.IndexOf(ary, s.Substring(i, 1))]);
        }
        Console.WriteLine(sb.ToString());
    }

    static string[] ary = new string[] {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}

    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 13280
#--Echo

N = int(input())
S = list(input())
number = len(S)

if(number % 2 != 0):
  print("No")
  exit()
else:
  pass

harf = int(N / 2)

if(S[0:harf] == S[harf:N]):
  print("Yes")
else:
  print("No")



Measured memory_bytes: 2940
#include<cstdio>
long long x;
int main(){
//	freopen("arc.in","r",stdin);
	scanf("%lld",&x);long long x1=x/11;x1<<=1;
	int left=x%11;if(left>6) x1+=2;else if (left) x1++;
	printf("%lld",x1);
	return 0;
}

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

int main(void) {
    long long A, B;
    
    cin >> A >> B;
    
    int i = 1;
    long long ans;
    while (1) {
        ans = A * i;
        if (ans % B == 0) {
            break;
        }
        i ++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n) {
        int a;
        cin >> a;
        if(a%2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}


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

int N, M;
int a, b;
bool teikibin1[200000 + 1], teikibin2[200000 + 1];

int main(){
	scanf("%d %d", &N, &M);
	for(int i = 1; i <= M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1) teikibin1[b] = true;
		if(b == N) teikibin2[a] = true;
	}
	bool def = false;
	for(int i = 1; i <= N; i++){
		if(teikibin1[i] == true && teikibin2[i] == true) def = true;
	}
	if(def) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 640
#define n'   '
L[n],p;F[n],X[n];i;long D[n*4],Z[n*4],A[n],x;long f(a,k,l,r,b){return(Z[k]+=!(b=a>l|-r<~i)*x)+(D[k]=l<=i&a<r&b?fmax(f(a,2*k,l,b),f(a,2*k+1,b=l+r>>1,r)):D[k]);}main(j){for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];for(;p?:(p=F[++i],f(i,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],1,0,n);printf("%ld",x);}

Measured memory_bytes: 141440
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()


void bfs(vector<vector<int>> &g, vector<ll> &x, int s, int par=-1){
  for(auto y: g[s]){
    if(y==par) continue;
    x[y] += x[s];
    bfs(g,x,y,s);
  }
}


void solve(){
  int n, q; cin >> n >> q;
  vector<vector<int>> g(n);
  vector<ll> x(n,0);
  FOR(i,0,n-1){
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  FOR(i,0,q){
    int a, b;
    cin >> a >> b;
    --a;
    x[a] += b;
  }
  bfs(g,x,0);
  FOR(i,0,n) cout << x[i] << ' ';
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 30464
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for(long long i = (n-1);i>=0;i--)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  string s;
  
  cin >> n >> s;
  vector <int>SW[4];
  
  REP(i,4)
    SW[i].resize(n);
  
  SW[0][0] = SW[0][1] = SW[1][0] = SW[2][1] = 1; // S
  SW[1][1] = SW[2][0] = SW[3][0] = SW[3][1] = -1; // W
  
  //最初２匹を決め打ち
  REP(i,4){
    FOR(j,1,n-1){
      if(s[j] == 'o'){
        if(SW[i][j] == 1) SW[i][j+1] = SW[i][j-1];
        else		      SW[i][j+1] = -SW[i][j-1];
      }
      else{
        if(SW[i][j] == 1) SW[i][j+1] = -SW[i][j-1];
        else			  SW[i][j+1] = SW[i][j-1];
      }
    }
    //矛盾チェック; n番目と1番目
    if(   SW[i][n-1] == 1 && s[n-1] == 'o' && SW[i][n-2] == SW[i][0]
        ||SW[i][n-1] == 1 && s[n-1] == 'x' && SW[i][n-2] != SW[i][0]
        ||SW[i][n-1] == -1 && s[n-1] == 'o' && SW[i][n-2] != SW[i][0]
        ||SW[i][n-1] == -1 && s[n-1] == 'x' && SW[i][n-2] == SW[i][0]) {

      if( SW[i][0] == 1 && s[0] == 'o' && SW[i][n-1] == SW[i][1]
        ||SW[i][0] == 1 && s[0] == 'x' && SW[i][n-1] != SW[i][1]
        ||SW[i][0] == -1 && s[0] == 'o' && SW[i][n-1] != SW[i][1]
        ||SW[i][0] == -1 && s[0] == 'x' && SW[i][n-1] == SW[i][1]){
        
      REP(j,n){
        if(SW[i][j] == 1) cout << "S";
        else		   cout << "W";
      }
      cout << endl;
      return 0;
    }
  }
  }
  
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <cstdlib>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;

char cShiftchar(char ch)
{
    if(isalpha(ch))
    {
        ch++;
        if(ch > 'z') ch = ch - 'z' + 'a' -1;
    }

    return ch;
}

string sDecode(string str)
{
    string ans;
    while( -1 == str.find("the")
            && -1 == str.find("this")
            && -1 == str.find("that")
         )
    {
        transform(str.begin(), str.end(), str.begin(), cShiftchar);

    }
    return str;
}

int main()
{
    string str;
    while(getline(cin, str))
    {
        cout << sDecode(str) << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1188
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

l,r = inpl()
if r-l > 2019:
    print(0)
else:
    res = INF
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%2019)
    print(res)

Measured memory_bytes: 77084
N=int(input())

mod=10**9+7

FACT=[1]
for i in range(1,10**6+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(10**6,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0
MINUS=0

def k_perm(k):
    return Combi(k-1,N-k-1)*FACT[k]*FACT[N-k-1]%mod

for k in range(N):
    ANS=(ANS+(k_perm(k)-k_perm(k-1))*k)%mod

print(ANS)


Measured memory_bytes: 108500