akhauriyash/Code-Regression huggingface dataset:
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int f[N],n,m;
int dis[N],vis[N],front[N],cnt;
struct node{int to,nxt,w;}e[N<<1];
set<int>se[N];
queue<int>Q;
void Add(int u,int v,int w){e[++cnt]=(node){v,front[u],w};front[u]=cnt;}
int find(int x){if(f[x]!=x)f[x]=find(f[x]);return f[x];}
void SPFA(){
	Q.push(1);memset(dis,63,sizeof(dis));dis[1]=0;
	while(!Q.empty()){
		int u=Q.front();Q.pop();vis[u]=0;
		for(int i=front[u];i;i=e[i].nxt){
			int v=e[i].to,W;
			if(se[u].find(e[i].w)!=se[u].end())W=0;
			else W=1;
			if(dis[v]>dis[u]+W){
				dis[v]=dis[u]+W;se[v].clear();se[v].insert(e[i].w);
				if(!vis[v]){vis[v]=1;Q.push(v);}
			}
			else if(dis[v]==dis[u]+W){if(se[v].find(e[i].w)==se[v].end()){if(!vis[v]){vis[v]=1;Q.push(v);}}se[v].insert(e[i].w);}
		}
	}
}
int main(){
	n=gi();m=gi();
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=m;i++){
		int u=gi(),v=gi(),w=gi();
		f[find(u)]=find(v);Add(u,v,w);Add(v,u,w);
	}
	if(find(1)!=find(n))return puts("-1"),0;
	SPFA();printf("%d\n",dis[n]==dis[n+1]?-1:dis[n]);
	return 0;
}
//%HYJ,Not Good!!!
//% M _ s e a, G o o d ! ! !
//%xgzc,sb!

Measured memory_bytes: 27008
n, d = map(int, input().split())
p = list(list(map(int, input().split())) for _ in range(n))

cnt = 0
for i in range(n):
  dis = (p[i][0]**2 + p[i][1]**2)**0.5
  if dis <= d:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 45756
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

struct state {
	int p, m, c;
	state(int p, int m, int c) : p(p), m(m), c(c) {};
	bool operator< (const state &o) const {
		return c < o.c;
	}
};

int main() {
	int n, m, c;
	while(cin >> n >> m >> c, n) {
		vvi path(n, vi(n, INF));
		int f, t, cc;
		REP(i, m) {
			cin >> f >> t >> cc;
			path[f-1][t-1] = min(cc, path[f-1][t-1]);
		}

		vvi cost(n, vi(m+1, INF));
		cost[0][0] = 0;

		priority_queue<state> Q;
		Q.push(state(0, 0, 0));
		int ans = INF;
		while(!Q.empty()) {
			state st = Q.top();
			Q.pop();
			int cp = st.p, cm = st.m, cc = st.c;
			
			if(cp == n-1) {
				if(cc <= c) {
					ans = min(ans, cm);
				}
				continue;
			}

			if(c < cc) {
				continue;
			}

			if(ans < cm) {
				continue;
			}

			REP(i, n) {
				if(i != cp && path[cp][i] != INF) {
					int nc = cc + path[cp][i];
					if(cost[i][cm] > nc) {
						cost[i][cm] = nc;
						Q.push(state(i, cm, nc));
					}
					if(cm+1 <= m && cost[i][cm+1] > cc) {
						cost[i][cm+1] = cc;
						Q.push(state(i, cm+1, cc));
					}
				}
			}
		}

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

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;

    int a[100000];
    rep(i, n) {
        cin >> a[i];
    }
    int count = 0;
    rep(i, n) {
        int tmp;
        if(i == 0){
            tmp = a[0];
        }
        else {
            tmp = a[tmp-1];
        }
        count++;
        if (tmp == 2) {
            cout << count;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


//


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




int main() {
ll n,k;
cin>>n>>k;

ll h[n+1];
rep(i,n){
    cin>>h[i];
}

ll dp[n+1];
rep(i, n){
    dp[i]=0;
}

dp[1]=0;
  

for(ll i=2;i<=n;i++){
    ll val=10000000000;
for(ll j=1;i-j>=1&&j<=k;j++){
val=min(dp[i-j]+abs(h[i]-h[i-j]),val);

}
dp[i]=val;
}



cout<<dp[n]<<endl;
return 0;



}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
#define ll long long
#define pii pair<int,int>
int cnt[5];
bool flag = true;
int main(){
    for(int i = 0; i < 3; i++){
        int a, b;
        cin >> a >> b;
        cnt[a]++, cnt[b]++;
    }
    for(int i = 1; i <= 4; i++){
        if(cnt[i] > 2) flag = false;
        if(cnt[i] == 0) flag = false;
    }
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}

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

int main(){
    ll N;
    cin>>N;
    string s = to_string(N);
    ll d = s.length();
    for(ll i=1; i<d; i++){
        s[i] = '9';
    }
    if(stoll(s) > N) s[0] = s[0] - 1;
    ll sum=0;

    rep(i, d) sum+=s[i] - '0';
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, from, to) for(int i=from; i<to; ++i)
using namespace std;

static const int M = 1046597;
static const int L = 14;
char T[M][L];
char com[6], word[L];

int getChar(char ch) {
  if (ch == 'A') {
    return 1;
  } else if (ch == 'C') {
    return 2;
  } else if (ch == 'G') {
    return 3;
  } else {
    return 4;
  }
}

int getKey(char str[]) {
  int key = 0;
  rep(i,0,(int) strlen(str))
  {
    key += getChar(str[i]);
    key *= 5; //左シフト(5進数)
  }
  return key;
}

int hash1(int key) {
  return key % M;
}

int hash2(int key) {
  return 1 + (key % (M - 1));
}

int hash_double(int key, ll i) {
  return (hash1(key) + i * hash2(key)) % M;
}

bool find(char str[]) {
  int key = getKey(str);
  for (ll i = 0;; ++i) {
    int h = hash_double(key, i);
    if (strcmp(T[h], str) == 0) {
      return true;
    } else if (strlen(T[h]) == 0) {
      return false;
    }
  }
  return false;
}

bool insert(char str[]) {
  int key = getKey(str);
  for (ll i = 0;; ++i) {
    int h = hash_double(key, i);
    if (strcmp(T[h], str) == 0) {
      return false;
    } else if (strlen(T[h]) == 0) {
      strcpy(T[h], str);
      return true;
    }
  }
  return false;
}

void solve() {
  rep(i,0,M)
  {
    T[i][0] = '\0'; //すべて空文字列で初期化
  }
  int n;
  scanf("%d", &n);
  rep(i,0,n)
  {
    scanf("%s %s", com, word);
    if (com[0] == 'i') {
      insert(word);
    } else {
      if (find(word)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
}

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



Measured memory_bytes: 17468
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int n1 = S.size(), n2 = T.size();
    RREP(i, n1 - n2) {
        bool same = true;
        REP(j, n2) {
            char s = S[i + j], t = T[j];
            same &= (s == t || s == '?');
        }
        if (!same) {
            continue;
        }
        S.replace(i, n2, T);
        replace(S.begin(), S.end(), '?', 'a');
        cout << S << endl;
        return 0;
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0;i < N;i++){
        ans += i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//package AtCoder.ABC155;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        int a= in.NI(); int b = in.NI(); int c = in.NI();
        int fl = 0;
        if (a==b && a!=c) fl=1;
        if (a==c && a!=b) fl=1;
        if (b==c && b!=a) fl=1;
        if (fl==1){
            out.println("Yes");
        } else {
            out.println("No");
        }
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 21972
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	a, b := readFloat64(), readFloat64()
	x := math.Ceil(a / 0.08)

	for math.Floor(x*0.08) == a {
		if math.Floor(x*0.1) == b {
			fmt.Println(x)
			return
		}
		x++
	}

	fmt.Println(-1)
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
// Best practice

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

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

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    char c;
    cin >> c;
    if(c=='A')cout << 'T' << endl;
    if(c=='C')cout << 'G' << endl;
    if(c=='G')cout << 'C' << endl;
    if(c=='T')cout << 'A' << endl;
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;

vector<PL> prime_factorize(LL N)
{
	vector<PL> res;
	for(LL a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		LL ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(PL(a,ex));
	}
	if(N!=1)res.push_back(PL(N,1));
	return res;
}

LL tri(LL x){
  return (sqrt(8*x+1)-1)/2;
}
int main(){
  LL n;
  cin>>n;
  vector<PL> po=prime_factorize(n);
  LL ans=0;
  for(auto p:po){
    ans+=tri(p.second);
  }
  cout<<ans<<endl;    
  return 0;
}

Measured memory_bytes: 3720
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	
	long[char] cnt;
	cnt['M'] = 0;
	cnt['A'] = 0;
	cnt['R'] = 0;
	cnt['C'] = 0;
	cnt['H'] = 0;

	foreach (i; 0..N)
	{
		auto name = RD;
		auto c = cnt.get(name[0], -1);
		if (c != -1) ++cnt[name[0]];
	}
	long ans = 0;
	auto keys = cnt.keys;
	foreach (i; 0..5)
	{
		foreach (j; i+1..5)
		{
			foreach (k; j+1..5)
			{
				ans += cnt[keys[i]] * cnt[keys[j]] * cnt[keys[k]];
			}
		}
	}

	writeln(ans);
	stdout.flush();
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back
const int mod = 998244353;
#define lc (i<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)

int const M = 200005;
int t[4*M];
int n, k;
int query(int i, int l, int r, int ql, int qr){
    if(ql > r || qr < l) return 0;
    if(ql <= l && qr >= r) return t[i];
    return (query(lc, l, mid, ql, qr) + query(rc, mid+1, r, ql, qr)) % mod;
}
void update(int i, int l, int r, int j, int v){
    if(l == r) {t[i] = v; return;}
    if(mid >= j) update(lc, l, mid, j, v);
    else update(rc, mid + 1, r, j, v);
    t[i] = (t[lc] + t[rc]) % mod;
} 
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    int l[k], r[k];
    for (int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
    }
    vector<int> dp(n + 1, 0);
    dp[n - 1] = 1;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < k; j++) {
            dp[i] += query(1, 1, n, i + l[j], i + r[j]);
            dp[i] %= mod;
        }
        update(1, 1, n, i, dp[i]);
    }
    cout << dp[0] << endl;
    return 0;
}



Measured memory_bytes: 9008
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        string O = Console.ReadLine();
        string E = Console.ReadLine();
        string outp = "";
        for (int i = 0; i < Math.Max(O.Length, E.Length); i++) {
            if (i < O.Length) {
                outp += O.Substring(i, 1);
            }
            if (i < E.Length) {
                outp += E.Substring(i, 1);
            }
        }
        Console.WriteLine(outp);
    }
}

Measured memory_bytes: 13140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

vector<vector<pii> > to;
ll cost[100010];

void dfs(int v,int p=-1,ll c=0){
  cost[v]=c;
  rep(i,to[v].size()){
    int nv=to[v][i].first;
    int nc=to[v][i].second;
    if(nv==p) continue;
    dfs(nv,v,c+nc);
  }
}

int main(){
  int n; cin >> n;
  to.resize(n);
  rep(i,n-1){
    int a,b; ll c;
    cin >> a >> b >> c;
    a--; b--;
    to[a].push_back(pii(b,c));
    to[b].push_back(pii(a,c));
  }
  int q,k; cin >> q >> k;
  k--;
  dfs(k);
  vector<ll> ans(q);
  rep(i,q){
    int a,b;
    cin >> a >> b;
    a--; b--;
    ans[i]=cost[a]+cost[b];
  }
  rep(i,q){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 18176
n, a = map(int, input().split())
x = list(map(int, input().split()))
x = [0] + x
dp = [[[0 for _ in range(max(x)*n+1)] for _ in range(n+1)] for _ in range(n+1)]
x.sort()
for j in range(n+1):
    for k in range(n+1):
        for s in range(max(x)*n+1):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
            else:
                dp[j][k][s] = 0

ans = 0
for k in range(1, n+1):
    try:
        ans += dp[n][k][k*a]
    except:
        pass

print(ans)

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

vector<int> v[200000];
int n;

int visited[200000] = {};
int count_red(int i, int color) {
	if (visited[i])
		return 0;
	visited[i] = color;
	int r = color == 2 ? 1 : 0;
	for(int a: v[i]) {
		r += count_red(a, 3 - color);
	}
	return r;
}


void print_color(int color) {
	int pm = 3, pr = 1;
	int exhausted = 0;
	for(int i = 0; i < n; i++) {
		if (i) cout << " ";
		if (!exhausted && visited[i] == color) {
			cout << pr;
			pr += pr % 3 == 1 ? 1 : 2;
			if (pr > n)
				exhausted = 1;
		} else {
			cout << pm;
			pm += 3;
		}
	}
}

int main() {
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		v[a - 1].push_back(b - 1);
		v[b - 1].push_back(a - 1);
	}
	int rc = count_red(0, 1);
	int bc = n - rc;
	if (rc >= n / 3 * 2 + n % 3) {
		print_color(2);
	} else if (bc >= n / 3 * 2 + n % 3) {
		print_color(1);
	} else {
		int exhausted1 = 0, exhausted2 = 0;
		int pm = 3, pr1 = 1, pr2 = 2;
		for(int i = 0; i < n; i++) {
			if (i) cout << ' ';
			if (!exhausted1 && visited[i] == 1) {
				cout << pr1;
				pr1 += 3;
				if (pr1 > n)
					exhausted1 = 1;
			} else if (!exhausted2 && visited[i] == 2) {
				cout << pr2;
				pr2 += 3;
				if (pr2 > n)
					exhausted2 = 1;
			} else {
				cout << pm;
				pm += 3;
			}
		}
	}
	cout << endl;
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 3005;
const int MOD = 998244353;

int n, s;
int a[N], cache[N][N];

int dp(int idx, int s)
{
	if(s == 0)
		return (n - idx + 2);
	if(s < 0)
		return 0;
	if(idx > n)
		return 0;
	int &ans = cache[idx][s];
	if(ans != -1)
		return ans;
	ans = dp(idx + 1, s) + dp(idx + 1, s - a[idx]);
	ans %= MOD;
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> n >> s;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans += dp(i, s);
	ans %= MOD;
	cout << ans;
	return 0;
}

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

int main()
{
    ll n,t,a,b,c,d,e,p,q,cnt=0;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;
    ll ac=0,tle=0,wa=0,re=0;
   cin>>s;
   ll sum=0;
    for(ll i=0;i<s.length();i++){
        sum+=s[i]-'0';
    }

    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;






}


Measured memory_bytes: 3716
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, M, X, Y;
        cin >> N >> M >> X >> Y;

        vector<int> x(N);
        vector<int> y(M);
        for (int i = 0; i < N; i++)
        {
                cin >> x[i];
        }
        for (int i = 0; i < M; i++)
        {
                cin >> y[i];
        }

        x.push_back(X);
        sort(x.begin(), x.end());
        y.push_back(Y);
        sort(y.begin(), y.end());

        if (x.back() < y.front())
        {
                cout << "No War" << endl;
        }
        else
        {
                cout << "War" << endl;
        }
        return 0;
}


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

using namespace std;

int a[3][123];
int dp[3][123];

main () {
  int n; scanf("%d", &n);
  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    dp[1][i] = dp[1][i - 1] + a[1][i];
  }
  for (int i = 1; i <= n; i++) {
    dp[2][i] = max(dp[1][i], dp[2][i - 1]) + a[2][i];
  }
  cout << dp[2][n];
}


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

ll euclidean_gcd(ll a, ll b) {
  if (a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N;
  cin >> N;
  ll t = 10;
  ll ans = 0;
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (t <= N) {
    ans += N / t;
    t *= 5;
  }
  cout << ans << endl;
  return 0;
}

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

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

    bool P = false;
    bool W = false;
    bool G = false;
    bool Y = false;

    rep(i, N) {
        string S;
        cin >> S;

        if (S == "P") {
            P = true;
        } else if (S == "W") {
            W = true;
        } else if (S == "G") {
            G = true;
        } else if (S == "Y") {
            Y = true;
        }
    }

    if (P && W && G) {
        if (Y) {
            cout << "Four" << endl;
        } else {
            cout << "Three" << endl;
        }

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int d[31]={},a;
	rep(i,0,28){
		cin>>a; d[a]=1;
	}
	rep(i,1,31){
		if(d[i]==0) o(i);
	}
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

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

	map<LL, LL> tbl;

	REP(i, N) {
		LL A, B;
		cin >> A >> B;
		tbl[A] += B;
	}

	LL ans = 0;
	for (auto e : tbl) {
		LL value = e.first;
		LL limit = e.second;

		if (M <= limit) {
			ans += M * value;
			break;
		}
		else {
			ans += limit * value;
			M -= limit;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

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

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

  double mother = 0;
  for(int i=0; i<N; i++)
    {
      mother += 1.0/A[i];
      //cout << mother << endl;
    }

  cout << setprecision(13);
  cout << 1/mother << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n;
    cin>>n;
    ll cnt=0;
    map<int,bool>m;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(m[a]){
            m[a]=false;
            cnt--;
        }else{
            m[a]=true;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int dp[3141][6141];
signed main(){
	int n,s;
	cin>>n>>s;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++){ cin>>a[i]; }
	dp[0][0] = 1;
	int ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<s;j++){
			dp[i][j] += dp[i-1][j];
			dp[i][j] %= inf;
			if( j == 0 ){
				dp[i][ j+a[i] ] += i * dp[i-1][j] ;
				dp[i][ j+a[i] ] %= inf;
			}
			else{
				dp[i][ j+a[i] ] += dp[i-1][j];
				dp[i][ j+a[i] ] %= inf;
			}
		}
		ans += ( n - i + 1 ) * dp[i][s];
		ans %= inf;
	}
	cout<<ans<<Endl;
	return 0;
}

Measured memory_bytes: 144896
#include<iostream>
using namespace std;
 
int main(){
	int n,k;
   	int a[200000];
  	cin>>n>>k;
  	for(int i=0;i<n;i++){
    	cin>>a[i];
    }
  	int x,b;
  	for(int j=0;j<n-k;j++){
      	
      	
      	
        	if(a[j]<a[j+k]){
            	cout<<"Yes"<<endl;
            }
          	else{
            	cout<<"No"<<endl;
            }
        
      	
    }
  return 0;
}

Measured memory_bytes: 4396
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;


int main(int argc, const char * argv[]) {
  int n, m;
  cin >> n >> m;
  int k;
  vector<vector<int>> pat(1<<n,vector<int>(n));
  for(int i = 0; i < 1 << n; i++){
    for(int j = 0; j < n; j++){
      if(i & 1 << j){
        pat.at(i).at(j) = 1;
      }
      else{
        pat.at(i).at(j) = 0;
      }
    }
  }

  vector<vector<int>> s(m);
  for(int i = 0; i < m; i++){
    cin >> k;
    vector<int> st(k);
    for(int j = 0; j < k; j++){
      cin >> st.at(j);
    }
    s.at(i) = st;
  }
  vector<int> p(m);
  for(int i = 0; i < m; i++){
    cin >> p.at(i);
  }

  int ans = 0;
  for(int i = 0; i < 1 << n; i++){
    bool check = true;
    for(int j = 0; j < m; j++){
      int sum = 0;
      for(int k = 0; k < s.at(j).size(); k++){
        sum += pat.at(i).at(s.at(j).at(k)-1);
      }
      if(sum % 2 != p.at(j)){
        check = false;
      }
    }
    if(check){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long;
using vl = vector<ll>; using vll = vector<vl>;
ll MOD = 998244353;
int main() {
	ll N, S;
	cin >> N >> S;
	vl A(N);
	for (ll i = 0; i < N; i++) cin >> A[i];
	vll dp(N + 1, vl(S + 1, 0));
	// 「0個目まで見て和が0」のみ1
	dp[0][0] = 1;
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j <= S; j++) {
			(dp[i + 1][j] += dp[i][j] * 2) %= MOD;
			if (j + A[i] <= S) (dp[i + 1][j + A[i]] += dp[i][j]) %= MOD;
		}
	}
	cout << dp[N][S];
}

Measured memory_bytes: 73676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll n,m; cin>>n>>m;
    vector<ll> a(n), c(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end(), greater<ll>());
    c=a;
    sort(c.begin(), c.end());
    vector<ll> b(n+1, 0);
    rep(i,n) b[i+1]=a[i]+b[i];
    ll left=0, right=1e12, last=0;
    while(right-left>1){
        ll mid=(left+right)/2;
        ll tmp=0;
        rep(i,n){
            auto itr = lower_bound(c.begin(), c.end(), mid-a[i]);
            tmp += c.end()-itr;
        }
        if(tmp >= m) left=mid;
        else right=mid;
    }

    rep(i,n){
        auto itr = lower_bound(c.begin(), c.end(), left-a[i]);
        last += c.end()-itr;
    }


    ll res=0;
    rep(i,n){
        auto itr=lower_bound(c.begin(), c.end(), left-a[i]);
        ll ind = c.end()-itr;
        res+=(ind)*a[i] + b[ind];
    }
    if(last>m){
        res-=left * (last-m);
    }

    cout<<res<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int K;
    string s;
    cin >> K >> s;

    if (s.size() > K) s = s.substr(0, K) + "...";
    cout << s << newl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
inline void end(void){cout << "WA" << endl;}
int main(void){
  int i,b=0;
  string s;
  cin >> s;
  for (i=2;s[i+1];i++){
    if ((int)s[i]<=(int)'Z'){
      if (s[i]=='C') b++;
      else{
        end();
        return 0;
      }
    }
  }
  if (b!=1){
    end();
    return 0;
  }
  if (s[0]!='A'||(int)s[1]<=(int)'Z'||(int)s[i]<=(int)'Z'){
    end();
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 201
#define MOD 1000000007
#define INF 1000000000000000000
#define lim 20

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}




void solve(){
    ll n, m;
    cin >> n  >> m;
    if(n == m) cout << "Yes\n";
    else cout << "No\n";

}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int d[32][32], C[3][32];

void solve() {
  int n, c; scanf("%d%d", &n, &c);
  for (int i = 1; i <= c; ++i) {
    for (int j = 1; j <= c; ++j) {
      scanf("%d", d[i]+j);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int x, j = 1; j <= n; ++j) {
      scanf("%d", &x);
      ++C[(i+j)%3][x];
    }
  }
  int ans = 2e9;
  for (int i = 1; i <= c; ++i) {
    for (int j = 1; j <= c; ++j) {
      for (int k = 1; k <= c; ++k) {
	if (i == j || j == k || i == k) continue;
	int cur = 0;
	for (int col = 1; col <= c; ++col) {
	  cur +=
	      C[0][col]*d[col][i]
	    + C[1][col]*d[col][j]
	    + C[2][col]*d[col][k];
	}
	ans = min(ans, cur);
      }
    }
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main() {
    int n, k,ans=0; cin >> n >> k;
    vector<int> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    rep (i,k) ans+=s[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int m,n,ans=0;
    bool flag=false;
    string s;
    string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
    cin >> n;
    cin >> s;

    for(int i=0;s[i]!='\0';i++){
        for(int j=0;j<26;j++){
            if(s[i] == alp[j]){
                s[i] = alp[(j+n)%26];
                break;
            }
        }
    }
    
    
    //cout << (!flag ? "Yes" : "No");
    //cout << ans;
    cout << s;
    //printf("%.10f",ans_d);

    cout << endl;
}


Measured memory_bytes: 256
import bisect
S = input()
T = input()

Spos = [[] for _ in range(26) ]
ord_a = ord('a')
for i in range(len(S)):
    Spos[ord(S[i])-ord_a].append(i)

for t in set(T):
    if len(Spos[ord(t)-ord_a]) == 0:
        print(-1)
        exit()

copy = 0
pos = -1
for t in T:
    array = Spos[ord(t)-ord_a]
    p = bisect.bisect_right(array, pos)
    if p == len(array):
        copy += 1
        pos = array[0]
    else:
        pos = array[p]

ans = copy * len(S) + (pos + 1)
print(ans)

Measured memory_bytes: 51824
a = str(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if int(a[-1]) in hon:
	print("hon")
    
if int(a[-1]) in bon:
	print("bon")
    
if int(a[-1]) in pon:
	print("pon")

Measured memory_bytes: 9192
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 17:47:56 2019
//
package main

import "fmt"

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var N int
	fmt.Scan(&N)

	ans := 1
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		ans = ans * (a / gcd(ans, a))
	}
	fmt.Println(ans)
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i=0; i<N; ++i) {
    int in;
    cin >> in;
    a[i] = in;
  }
  
  int tmp = a[0];
  for(int i=1; i<N; ++i) {
    tmp = tmp ^ a[i];
  }
  
  if(tmp==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

    //input
    int d = sc.nextInt();
    int[] c = new int[26]; //array of decrease
    for(int i = 0; i < c.length; i++){
      c[i] = sc.nextInt();
    }
    int[][] s = new int[d][26]; //two dimensional array of increase
    for(int row = 0; row < s.length; row++){ //day
      for(int col = 0; col < s[row].length; col++){ //contest number
        s[row][col] = sc.nextInt();
      }
    }
    /*
    int[] t = new int[d]; //array of contest numbers of the day
    for(int i = 0; i < t.length; i++){
      t[i] = sc.nextInt();
    }
    */

    //output
    int largestNum = s[0][0];
    int largestNumRow = 0;
    int largestNumCol = 0;
    for(int row = 0; row < s.length; row++){
      for(int col = 0; col < s[row].length; col++){
        if( s[row][col] > largestNum ){
          largestNum = s[row][col];
          largestNumRow = row;
          largestNumCol = col;
        }
      }
    }
    for(int i = 0; i < d; i++){
      //System.out.println((int)(Math.random()*26+1));
      System.out.println(largestNumCol+1);
    }

    /*
    int value = 0;
    for(int i = 0; i < t.length; i++){
      int contestNum = t[i]-1;
      int day = i+1;
      value += s[day-1][contestNum]; //increase
      for(int j = 0; j < c.length; j++){
        if( !(j == contestNum) ){
          int daySinceLast = day;
          for(int m = 0; m < i; m++){
            if( j == t[m]-1 ){
              daySinceLast = day-m-1;
            }
          }
          value -= c[j]*(daySinceLast); //decrease (amount of decrease * days since last one)
        }
      }
      System.out.println(value);
    }
    */

  }
}


Measured memory_bytes: 38128
N = int(input())
if N >= 64:
    print(64)
elif N >= 32:
    print(32)
elif N >= 16:
    print(16)
elif N >= 8:
    print(8)
elif N >= 4:
    print(4)
elif N >= 2:
    print(2)
else:
    print(1)

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

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

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int num;
    cin >> num;
    cout << num * num * num << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		int left = Math.max(a, c);
		int right = Math.min(b, d);
		
		if (right <= left) System.out.println(0);
		else System.out.println(right - left);
	}
}

Measured memory_bytes: 21460
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

s=get_nsp
s.shift(4)
s.unshift(["2","0","1","8"])
puts s.join("")

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

int main() {
  int N,M,sum=0; cin>>N;
  M=N;
  for(int i=0; i<8; i++){
    sum+=N%10; N/=10;
  }
  if(M%sum==0) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 111 != 0)
            System.out.println(n + 111 - n % 111);
        else
            System.out.println(n);
    }
}

Measured memory_bytes: 23636
#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>;

short dp[3003][3003];
int main() {
  string s, t;
  cin >> s >> t;
  int ss, ts;
  ss = s.size();
  ts = t.size();
//  int dp[ss+1][ts+1];
  rep(i, ts+1) dp[0][i] = 0;
  rep(i, ss+1) dp[i][0] = 0;
  rep(i, ss) {
    rep(j, ts) {
      if ((s[i] == t[j]) && (dp[i][j] == dp[i][j+1]) && (dp[i][j] == dp[i+1][j])) {
        dp[i+1][j+1] = dp[i][j] + 1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }
//  rep(i, ss+1) {rep(j, ts+1) cout << dp[i][j]; cout << endl;}
  if (dp[ss][ts] == 0) cout << "" << endl;
  else {
    string ans = "";
    for (int i = ss, j = ts; (i > 0) && (j > 0);) {
//      cout << ss-si << "," << ts-ti << endl;
      if (dp[i][j] == dp[i-1][j]) i--;
      else if (dp[i][j] == dp[i][j-1]) j--;
      else {ans = t[j-1] + ans; i--; j--; if (dp[i][j] <= 0) break;}
    }
    cout << ans << endl;
  }
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;

struct Data{
  int id,stamp;
  bool operator < ( const Data& data ) const {
    if( stamp != data.stamp ) return stamp > data.stamp;
    return id > data.id;
  }
};

vector<ii> cycle[110];
int n,m,run_time[110],indices[110],charger,charge_id;
bool inQueue[110];

int simulate(){

  rep(i,n) run_time[i] = cycle[i][0].first, indices[i] = 0, inQueue[i] = false;
  charger = 0, charge_id = -1;
  priority_queue<Data> Q;
  int ret = 0;
  rep(_,m){

    rep(i,n) {
      if( run_time[i] <= 0 && !inQueue[i] ) {
        Q.push((Data){i,_});
        inQueue[i] = true;
      }
      run_time[i]--;
    }

    if( charger == 0 && !Q.empty() ) {
      charge_id = Q.top().id; Q.pop();
      charger = cycle[charge_id][indices[charge_id]].second;
    } 

   if( charger ) {
      --charger;
      if( charger <= 0 ) {
        inQueue[charge_id] = false;
        ( indices[charge_id] += 1 ) %= (int)cycle[charge_id].size();
        run_time[charge_id] = cycle[charge_id][indices[charge_id]].first;
      }
    } 

    ret += (int)Q.size();

  }

  return ret;
}

int main(){
  while( cin >> n >> m, n | m ){
    rep(i,n) {
      int a,b;
      cycle[i].clear();
      while( cin >> a , a ){
        cin >> b;
        cycle[i].push_back(ii(a,b));
      }
    }

    cout << simulate() << endl;

  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
 
typedef long long ll;
ll n, c, s, ans, a[N], b[N], mx[N], mx2[N];
int main()
{
	ll i, j;
	cin >> n >> c;
	for (i = 0; i < n; i++) {
		scanf ("%lld %lld", &a[i], &b[i]);
	}
	for (i = n - 1; i >= 0; i--) {
		s += b[i];
		mx[i] = max(mx[i + 1], s - (c - a[i]));
		mx2[i] = max(mx2[i + 1], s - (c - a[i]) * 2);
	}
	ans = max(mx[0], mx2[0]);
	s = 0;
	for (i = 0; i < n; i++) {
		s += b[i];
		ans = max(ans, s - a[i] * 2 + mx[i + 1]);
		ans = max(ans, s - a[i] + mx2[i + 1]);
	}
	cout <<ans;
    return 0;
}


Measured memory_bytes: 3328
def main():
    c_list = [list(input()) for _ in range(2)]
    if c_list[0][0] == c_list[1][2] and c_list[0][1] == c_list[1][1] and c_list[0][2] == c_list[1][0]:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61780