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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    n /= 2;

    while (n > 0) {
        ans += n / 5;
        n /= 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

int cnt[13];
void err() {
	cout << 0 << endl;
	exit(0);
}

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

	cnt[0]++;
	rep(i,0,n) {
		int d;
		cin >> d;
		cnt[d]++;
	}

	if (cnt[0] > 1 || cnt[12] > 1)err();



	int ma = -1;
	for (int i = 0; i < (1 << 11); i++) {
		vector<int>time(24,0);
		int mi = 101010;

		rep(j,0,13) {
			if (j == 0 || j == 12) {
				if (cnt[j] == 1)time[j]++;
			}
			else {
				if (cnt[j] > 2)err();
				else if (cnt[j] == 2) {
					time[j]++;
					time[24 - j]++;
				}
				else if(cnt[j] == 1){
					if (i &(1 << j - 1))time[j]++;
					else time[24 - j]++;
				}
			}
		}

		rep(j,0,24) {
			if (time[j] != 0) {
				rep(k, 0, 24) {
					if (k != j && time[k] != 0) {
						int dt = abs(k-j);
						mi = min(mi,min(dt,24-dt));
					}
				}
			}
		}

		ma = max(ma,mi);
	}

	cout << ma << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int better(int a, int b)
{
	int better;
	if (a < b)
	{
		better = b;
	}
	else
	{
		better = a;
	}
	return better;
}

int main()
{
	int a[100100];
	int b[100100];
	int c[100100];
	int N = 0;
	int sumA;
	int sumB;
	int sumC;
	int data = 0;
	int subA, subB, subC;
	int Nlimit = pow(10.0,5.0);
	int abcLimit = pow(10.0, 4.0);
	int allSum;

	if (scanf("%d", &N) != 1)
	{
		exit(1);
	}
	if (1 <= N  || N <= Nlimit)
	{
	}
	else
	{
		exit(1);
	}


	for (int i = 0; i < N; i++)
	{
		if (scanf("%d%d%d", &a[i], &b[i], &c[i]) != 3)
		{
			exit(1);
		}
		if (1 <= a[i] || 1 <= b[i] || 1 <= c[i])
		{
		}
		else
		{
			exit(1);
		}

		if (a[i] <= abcLimit || b[i] <= abcLimit || c[i] <= abcLimit)
		{
		}
		else
		{
			exit(1);
		}

		if (i < 1)
		{
			subA = a[i];

			subB = b[i];

			subC = c[i];
		}
		else
		{
			subA = a[i] + better(sumB, sumC);

			subB = b[i] + better(sumA, sumC);

			subC = c[i] + better(sumA, sumB);
		}

		sumA = subA;
		sumB = subB;
		sumC = subC;

	}

	if (sumB <= sumA)
	{
		if (sumC <= sumA)
		{
			allSum = sumA;
		}
		else
		{
			allSum = sumC;
		}
	}
	else if(sumA <= subB)
	{
		if (sumC <= sumB)
		{
			allSum = sumB;
		}
		else
		{
			allSum = sumC;
		}
	}
	else if(sumB <= sumC)
	{
		if (sumA <= sumC)
		{
			allSum = sumC;
		}
		else
		{
			sumA;
		}
	}

	printf("%d", allSum);

	return 0;

}

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

int     main() {
  string S;
  cin >>S;
  for (int i=0; i<3; i++) {
    if (S[i]=='1') S[i]='9';
    else S[i]='1';
  }
  cout <<S <<endl;
  return 0;
}

Measured memory_bytes: 256
from queue import Queue

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

l = [[] for _ in range(n)]
for a, b in ab:
    l[a-1].append(b-1)
    l[b-1].append(a-1)

q = Queue()
ans = [0] * n
ans[0] = 1
f = [0] * n
f[0] = 1
for v in l[0]:
    q.put((v, 0))
    f[v] = 1
    
cnt = 0
x = 0
while not q.empty():
    i = q.get()
    ans[i[0]] = i[1]+1
    for v in l[i[0]]:
        if f[v] == 0:
            q.put((v, i[0]))
            f[v] = 1

if 0 not in ans:
    print("Yes")
else:
    print("No")
    exit()

for v in ans[1:]:
    print(v)

Measured memory_bytes: 127988
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6+5,M=5e6+5;
const int INF=2000000000;
int n,V;
int x[N];
int cnt[25];
int l[25][N],r[25][N];
int f1[M],f2[M];
bool ans[N];
void Init(){
    for(int i=0;i<M;i++)
        f1[i]=0,f2[i]=INF;
}
int Upfind(int id,int pos){
    pos++;
    int p=upper_bound(l[id]+1,l[id]+cnt[id]+1,pos)-l[id]-1;
    if(p<=0)
        return pos;
    return max(r[id][p],pos-1);
}
int Lowfind(int id,int pos){
    pos--;
    int p=lower_bound(r[id]+1,r[id]+cnt[id]+1,pos)-r[id];
    if(p>=cnt[id]+1)
        return pos;
    return min(l[id][p],pos+1);
}
int main()
{
    Init();
    scanf("%d%d",&n,&V);
    for(int i=1;i<=n;i++)
        scanf("%d",&x[i]);
    x[n+1]=INF;
    x[0]=-INF;
    int logV=0;
   while(1<<(logV+1)<=V)
        logV++;
    int v=V*2;
    for(int t=0;t<=logV+1;t++){
        v>>=1;
        cnt[t]=1;
        l[t][1]=1;
        for(int i=1;i<=n;i++){
            r[t][cnt[t]]=i;
            if(x[i+1]-x[i]>v){
                cnt[t]++;
                l[t][cnt[t]]=i+1;
            }
        }
        cnt[t]--;
    }
    if(cnt[0]>logV+2){
        for(int i=1;i<=n;i++)
			puts("Impossible");
		return 0;
    }
    int tot=1<<(logV+2);
    f1[0]=0,f2[0]=n+1;
    for(int s=0;s<tot;s+=2)
        for(int i=0;i<=logV+1;i++){
            if(!(s&(1<<i)))
                continue;
            f1[s]=max(f1[s],Upfind(i,f1[s^(1<<i)]));
            f2[s]=min(f2[s],Lowfind(i,f2[s^(1<<i)]));
        }
    for(int i=1;i<=cnt[0];i++){
        int ln=l[0][i],rn=r[0][i];
        for(int s1=0;s1<tot;s1+=2){
            int s2=tot-1-s1-1;
            int lpos=f1[s1];
            int rpos=f2[s2];
            if(lpos>=ln-1&&rpos<=rn+1){
                ans[i]=true;
                break;
            }
        }
    }
    int pos=1;
    for(int i=1;i<=n;i++){
        if(ans[pos]==true)
            puts("Possible");
        else
            puts("Impossible");
        if(x[i+1]-x[i]>V)
            pos++;
    }
}


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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int A, B, C;
    cin >> A >> B >> C;
    int can = B / A;
    if (can >= C) {
        cout << C << endl;
    } else {
        cout << can << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {

	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		String[] str = input.split(" ");
		ArrayList <Integer> result = new ArrayList<Integer>();
		for(int i = 0; i < str.length; i++){
			result.add(Integer.parseInt(str[i]));
		}
		
		int W = Integer.parseInt(str[0]);
		int H = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);
		int y = Integer.parseInt(str[3]);
		int r = Integer.parseInt(str[4]);
		
		if( x+r<=W && x-r>=0 && y+r<=H && y-r>=0 ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24428
use whiteread::parse_line;

fn main() {
    let s: usize = parse_line().unwrap();
    let mut prime: Vec<bool> = vec![true; s * 2];
    prime[0] = false;
    prime[1] = false;

    for i in 0..s * 2 {
        if i as f64 > ((s * 2) as f64).sqrt() {
            break;
        }
        if prime[i] {
            for k in (i * 2..s * 2).step_by(i) {
                prime[k] = false;
            }
        }
    }
    for i in s..s * 2 {
        if prime[i] {
            println!("{}", i);
            break;
        }
    }
}


Measured memory_bytes: 2328
# -*- Coding: utf-8 -*-

n = int(input())
trial_num = 0

n_reminder = n % 11

if(n_reminder == 0):
    print(n//11 * 2)
elif(0 < n_reminder <= 6):
    print((n//11)*2 + 1)
elif(7 <= n_reminder <= 11):
    print((n//11)*2 + 2)

Measured memory_bytes: 3060
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string S;
    cin >> S;
    int cnt[200] = {};
    for (int i = 0; i < (int)S.size(); i++){
        cnt[(int)S[i]]++;
    }
    string ans = "None";
    for (int i = (int)'a'; i <= (int)'z'; i++){
        if (cnt[i] == 0){
            ans = (char)i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int n, i, f[50];
  scanf("%d", &n);
  f[0] = 1;
  f[1] = 1;
  for (i = 2; i <= n; i++)
    f[i] = f[i-1] + f[i-2];
  printf("%d\n", f[n]);
}


Measured memory_bytes: 2012
R, G, B, N = map(int, input().split())

ans = 0
for i in range(int(N / R) + 1):
    for j in range(int((N - i * R) / G) + 1):
        if ((N - (i * R + j * G)) % B == 0):
            ans += 1
print(ans)


Measured memory_bytes: 2940
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=200010;

struct DSU // Disjoint Set Union
{
	int par[maxn],rnk[maxn];
	
	inline void clear(int n)
	{
		for(int i=1;i<=n;i++) par[i]=i,rnk[i]=1;
	}

	inline int find(int u)
	{
		return par[u]==u?u:par[u]=find(par[u]);
	}

	inline void merge(int u,int v)
	{
		u=find(u);v=find(v);
		if(u==v) return;
		
		if(rnk[u]>rnk[v]) swap(u,v); // make rnk[u]<rnk[v]
		par[u]=v;rnk[v]+=rnk[u];
	}

	inline bool same(int u,int v)
	{
		return find(u)==find(v);
	}
} st;

int n,m,ans;

int main()
{
	SF("%d%d",&n,&m);st.clear(n);
	for(int i=1;i<=m;i++)
	{
		int u,v;SF("%d%d",&u,&v);
		st.merge(u,v);
	}

	for(int i=1;i<=n;i++) if(st.par[i]==i) ans=max(ans,st.rnk[i]);

	cout<<ans;

	return 0;
}

Measured memory_bytes: 5320
from collections import deque

N = int(input())
E = [[] for i in range(N+1)]
edge_order = []
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    edge_order.append(b)
queue = deque([1])
color = [0] * (N+1)
while queue:
    V = queue.popleft()
    c = 1
    for i in E[V]:
        if c == color[V]:
            c += 1
        color[i] = c
        c += 1
        queue.append(i)
print(max(color))
for i in edge_order:
    print(color[i])

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 13;

int n;
char res[N];
string s;
map<char, char> rh;

bool check()
{
	for (int i = 1; i < n - 2; i ++ )
		if (res[i] == 'S')  // sheep
		{
			if (s[i] == 'o') res[i + 1] = res[i - 1];
			else res[i + 1] = rh[res[i - 1]];
		}
		else  // wolf
		{
			if (s[i] == 'x') res[i + 1] = res[i - 1];
			else res[i + 1] = rh[res[i - 1]];
		}
		
	for (int i = n - 2; i < s.size(); i ++ )
		if (res[i] == 'S')
		{
			if (s[i] == 'o' && res[i - 1] != res[(i + 1) % n]) return false;
			else if (s[i] == 'x' && res[i - 1] == res[(i + 1) % n]) return false;
		}
		else
		{
			if (s[i] == 'x' && res[i - 1] != res[(i + 1) % n]) return false;
			else if (s[i] == 'o' && res[i - 1] == res[(i + 1) % n]) return false;
		}
	return true;
}

bool solve(char c)
{
	memset(res, 0, sizeof res);
	res[0] = c;
	if (c == 'S')  // sheep
	{
		if (s[0] == 'o')  // same
		{
			res[1] = res[n - 1] = 'S';
			if (check()) return true;
			res[1] = res[n - 1] = 'W';
			if (check()) return true;
		}
		else  // dif
		{
			res[1] = 'W', res[n - 1] = 'S';
			if (check()) return true;
			res[1] = 'S', res[n - 1] = 'W';
			if (check()) return true;
		}
	}
	else  // wolf
	{
		if (s[0] == 'o')  // dif
		{
			res[1] = 'W', res[n - 1] = 'S';
			if (check()) return true;
			res[1] = 'S', res[n - 1] = 'W';
			if (check()) return true;
		}
		else  // same
		{
			res[1] = res[n - 1] = 'S';
			if (check()) return true;
			res[1] = res[n - 1] = 'W';
			if (check()) return true;
		}
	}
	return false;
}

int main()
{
	cin >> n >> s;
	
	rh['W'] = 'S', rh['S'] = 'W';
	
	if (solve('S') || solve('W')) cout << res << endl;
	else puts("-1");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define S(v) sort(v.begin(), v.end())
#define SS(v) sort(v.begin(), v.end(), greater<int>())
#define print(v) for(auto i:v)cout<<i<<" "


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// freopen("in.txt","r", stdin);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		ll ans =0;
		loop(a,1,n){
			ans+=n/a;
			if(n%a==0)ans--;
		}
		cout<<ans;
	}
	
} 





Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>

using namespace std;

int N, Ma,Mb,a[50], b[50], c[50];

int dp[45][414][414];

int main(void) {

	cin >> N >> Ma >> Mb;
	int tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; a[i] = tmp;
		cin >> tmp; b[i] = tmp;
		cin >> tmp; c[i] = tmp;
	}

	for (int i = 0; i <= N; i++) {
		for (int n = 0; n <= 400; n++) {
			for (int m = 0; m <= 400; m++) {
				dp[i][n][m] = 999999;
			}
		}
	}

	dp[0][0][0] = 0;

	for (int i = 1; i <= N; i++) {
		dp[i-1][0][0] = 0;
		for (int n = 0; n <= 400; n++) {
			for (int m = 0; m <= 400; m++) {
				dp[i][n][m] = min(dp[i][n][m], dp[i - 1][n][m]);
			}
		}
		for (int n = 0; n <= 400; n++) {
			for (int m = 0; m <= 400; m++) {
				dp[i][n + a[i]][m + b[i]] = min(dp[i - 1][n][m] + c[i], dp[i - 1][n + a[i]][m + b[i]]);
			}
		}
	}

	int ans = 9999;
	for (int n = 1; n <= 400; n++) {
		for (int m = 1; m <= 400; m++) {
			if (m*Ma == n*Mb) { ans = min(ans, dp[N][n][m]); }
		}
	}

	

	if (ans == 9999) { cout << -1 << endl; }
	else { cout << ans << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 28928
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

sum_s = [[], []]

for y in range(H):
	count, line = 0, []
	for x in range(W):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[0] += [line]

for x in range(W):
	count, line = 0, []
	for y in range(H):
		if STAGE[y][x] == ".":
			count += 1
		else:
			if 0 < count:
				line += [count] * count
			line += [0]
			count = 0
	else:
		if 0 < count:
			line += [count] * count
	sum_s[1] += [line]
"""
for line in sum_s[0]:
	print(*line)
print()
for line in sum_s[1]:
	print(*line)
"""
max_score = 0
for y in range(H):
	for x in range(W):
		max_score = max(max_score, sum_s[0][y][x] + sum_s[1][x][y] - 1)

print(max_score)


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s; cin>>s;
	deque<char> dq(s.begin(), s.end());
	bool flg = true;
	int q; cin>>q;
	int t, f; char ch;
	while(q--){
		cin>>t;
		if(t == 1)flg = !flg;
		else{
			cin>>f>>ch;
			if(f == 1){
				if(flg)dq.push_front(ch);
				else dq.push_back(ch);
			}else{
				if(!flg)dq.push_front(ch);
				else dq.push_back(ch);
			}
		}
	}
	if(!flg)reverse(dq.begin(), dq.end());
	for(auto ch : dq){
		cout<<ch;
	}

	return 0;
}

Measured memory_bytes: 976
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())

ab_list = [list(map(int,list(input().split()))) for _ in range(N-1)]  
px_list = [list(map(int,list(input().split()))) for _ in range(Q)]  

graph = [[] for _ in range(N+1)]
point_list = [0] * (N+1)

for a, b in ab_list:
    graph[a].append(b)
    graph[b].append(a)
    
for p, x in px_list:
    point_list[p] += x
    
def add_point(num, root, point):    
    point_list[num] += point   
    for g in graph[num]:
        if g == root:
            continue
        add_point(g, num, point_list[num])

add_point(1, 0, 0)
 
print(*(point_list[1:]))

Measured memory_bytes: 300120
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    int s, w; cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


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

int main() {
int h, m, s, a;
cin >> a;
h = a / 3600;
m = (a % 3600) / 60;
s = ((a % 3600) % 60);
cout << h << ":" << m << ":" << s << endl;
return 0;
}

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

using namespace std;

vector<double> ms;
int main() {
    double m;
    while (cin >> m) {
        ms.push_back(m);
    }
    cout << (*max_element(ms.begin(), ms.end()) - *min_element(ms.begin(), ms.end())) << endl;
    return 0;
}
    

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    let max = a.iter().max();
    let min = a.iter().min();
    match (max, min) {
        (Some(a), Some(b)) => println!("{}", a - b),
        _ => println!("")
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	int best = a[n - 1] - a[0];
	for (int i = 1; i < n; i++) {
		best = min(best, k - (a[i] - a[i - 1]));
	}
	cout << best;
}

Measured memory_bytes: 1024
N,A,B=map(int,input().split())
X=list(map(int,input().split()))

L=[0]*(N-1)
s=0
for i in range(N-1):
    L[i]=X[i+1]-X[i]
    if(A*L[i]>=B):
        s+=B
    else:
        s+=A*L[i]
print(s)

Measured memory_bytes: 62704
def solve():
    p, q, r = map(int, input().split())
    ab = min(p, r+q)
    bc = min(q, p+r)
    ca = min(r, p+q)
    result = min(ab + bc, bc + ca, ca + ab)
    print(result)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    string s; cin >> s;
    int cnt = 0;
    string ans = s;
    for (int i = 0; i < n; i++){
        if (s[i] == '(') cnt += 1;
        else {
            if (cnt == 0) ans = '(' + ans;
            else cnt -= 1;
        }
    }
    if (cnt > 0){
        for (int i = 0; i < cnt; i++) ans += ')';
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int K, X;
    cin >> K >> X;
    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    int ans = 0;
    rep(i, 4) {
        if (S[i] == '+') {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    output(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
string s;
vector<string> ok = {
    "KIHBR",
    "AKIHBR",
    "KIHABR",
    "KIHBAR",
    "KIHBRA",
    "AKIHABR",
    "AKIHBAR",
    "AKIHBRA",
    "KIHABAR",
    "KIHABRA",
    "KIHBARA",
    "AKIHABAR",
    "AKIHABRA",
    "AKIHBARA",
    "KIHABARA",
    "AKIHABARA"
  };
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>s;
  ll i;
  bool flg = false;
  rep(i,ok.size()) if(ok[i] == s) flg = true;
  if(flg) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
int main(){
  solve();
  return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a[3] ;
    loopcin(3 , a) ;
    sort(a , a + 3) ;
    cout << (a[0] == a[1] ? a[2] : a[0]) ;


    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let keyence = "keyence".chars().collect::<Vec<char>>();
    let mut count: usize = 0;
    for ch in s.iter() {
        if count == keyence.len() {
            break;
        } else if ch == &keyence[count] {
            count += 1;
        } else {
            break;
        }
    }
    for ch in &s[(s.len() - (keyence.len() - count))..(s.len())] {
        if count == keyence.len() {
            break;
        } else if ch == &keyence[count] {
            count += 1;
        } else {
            break;
        }
    }
    if count == keyence.len() {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}


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

enum { OPEN = 1, CLOSE = 2 };
int bracket[128];
char match[128];

string str;
int idx;

char getc() { return idx < str.size() ? str[idx] : '#'; }
void expr() {
	while(bracket[getc()] == OPEN) {
		const char c = getc();
		++idx;
		expr();
		if(match[c] != getc()) throw "parse error!";
		++idx;
	}
}

bool parse() {
	try {
		idx = 0;
		expr();
		return idx == str.size();
	} catch(const char * s) {
		return false;
	}
}

int main() {
	bracket['('] = bracket['['] = OPEN;
	bracket[')'] = bracket[']'] = CLOSE;
	match['('] = ')';
	match['['] = ']';

	const auto rm = [&](char c) { return !bracket[c]; };
	while(getline(cin, str) && str != ".") {
		str.erase(remove_if(begin(str), end(str), rm), end(str));
		cout << (parse() ? "yes" : "no") << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
struct node 
{
    int x,y;
}s[100010];

int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&s[i].x);
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d",&s[i].y);
        int t=s[i].x-s[i].y;
        if(t>0) ans+=t;
    }
    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;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
    int s;
    cin >> s;
    int x = s/3;
    mint ans = 0;
    combination c(2005);
    for (int i = 1; i <= x; i++) {
        ans += c(s-3*i+i-1, i-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
import math
n = int(input())
nlist = [0]*n
for x in range(1,math.ceil(math.sqrt(n-1)-1)):
    for y in range(1,math.ceil(math.sqrt(n-1)-1)):
        for z in range(1,math.ceil(math.sqrt(n-1)-1)):
            temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if temp > n:
                break
            else:
                nlist[temp-1] +=1

for num in nlist:
    print(num)


Measured memory_bytes: 9368
#include <iostream>
//#include <string>
//#include <algorithm>
#include <cstring>
#include <cstdio>
//#include <cmath>
//#include <queue>
//#include <set>
//#include <map>
//#include <list>
//#include <vector>
//#include <stack>
#define mp make_pair
//#define P make_pair
#define MIN(a,b) (a>b?b:a)
//#define MAX(a,b) (a>b?a:b)
typedef long long ll;
typedef unsigned long long ull;
const int MAX=2e5+5;
const int INF=1e8+5;
using namespace std;
//const int MOD=1e9+7;
typedef pair<ll,int> pii;
const double eps=0.00000001;
int n,k,da;
int a[MAX];
int Gcd(int a, int b)
{
    while(b != 0)
    {
        int r = b;
        b = a % b;
        a = r;
    }
    return a;
}
int main()
{
    scanf("%d%d",&n,&k);
    da=0;

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        da=max(da,a[i]);
    }
    int gcd=a[1];
    if(k>da)
        return 0*printf("IMPOSSIBLE\n");
    for(int i=1;i<n;i++)
        gcd=Gcd(gcd,a[i+1]);
    if(k%gcd==0)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	vector<ll> A(100001);
	ll an = 0;
	rep(i, N) {
		ll a;
		cin >> a;
		an += a;
		A.at(a)++;
	}
	ll Q;
	cin >> Q;
	vector<ll> AN(Q);
	rep(i, Q) {
		ll B, C;
		cin >> B >> C;
		an -= A.at(B) * B;
		an += A.at(B) * C;
		A.at(C) += A.at(B);
		A.at(B) = 0;
		AN.at(i) = an;
	}
	rep(i, Q) {
		cout << AN.at(i) << endl;
	}
}


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

#define Bye return 0
#define ll long long
const ll MAX = 1e2;

void solve(){
    string a, b; cin>>a>>b;
    if(a == b) printf("EQUAL");
    else if(a.size() > b.size() || (a[0]-'0') > (b[0]-'0') &&
       a.size() == b.size())
        printf("GREATER");
    else printf("LESS");
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public 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 = (a+b)*c/2;
		System.out.println(d);
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
#include<numeric>
using namespace std;

int main(void)
{
    int N, Q;
    cin >> N >> Q;

    string s;
    cin >> s;

    vector<int> v(N,0);
    long num{0};
    for(int i=1; i<s.size(); ++i){
        if(s[i-1]=='A' and s[i]=='C')
            v[i] = v[i-1] + 1;
        else
            v[i] = v[i-1];
    }

    int start, end;

    for(int q=0; q<Q; ++q){
        cin >> start >> end;
        cout << v[end-1] - v[start-1] << endl;
    }

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,p;

struct Node
{
    int x,y;
};
const int maxn=3000+10;
vector<Node>s[maxn];
vector<int>w[maxn];

int ans=0;
int vis[maxn];
int dis[maxn];
int cnt[maxn];
int f=0;
int reachable[maxn];
void dfs(int x)
{
    reachable[x]=1;
    for(int i=0; i<w[x].size(); i++)
    {
        if(reachable[w[x][i]])
            continue;
        dfs(w[x][i]);
    }
}
bool SPFA()
{
    for(int i=2; i<=n; i++)
        dis[i]=-inf;
    vis[1]=1;
    queue<int>que;
    que.push(1);
    cnt[1]=1;
    while(!que.empty())
    {
        int top=que.front();
        que.pop();
        vis[top]=0;
       if(!reachable[top]||dis[top]==-inf)
            continue;
        for(int i=0; i<s[top].size(); i++)
        {
            Node no=s[top][i];
            int v=no.x;
            if(!reachable[v])//reachable
                continue;
            if(dis[v]<dis[top]+no.y)
            {
                dis[v]=dis[top]+no.y;
                if(vis[v]==0)
            {
                vis[v]=1;
                que.push(v);
                if(++cnt[v]>n)
                return false;
            }
            }
    }
    }
    return true;
}
bool bellman_ford(){
	for(int i=2;i<=n;i++){
		dis[i] = -inf;
	}
	for(int k=0;k<=n;k++){
		bool updated = false;
		for(int i=1;i<=n;i++){
			int l = s[i].size();
			if(!reachable[i]||dis[i]==-inf) continue;
			for(int j=0;j<l;j++){
				int v = s[i][j].x;
				if(!reachable[v]) continue;
				int c = s[i][j].y;
				if(dis[v]<dis[i]+c){
					updated = true;
					dis[v] = dis[i]+c;
				}
			}
		}
		if(!updated) return true;
	}
	return false;
}

int main()
{

    std::ios::sync_with_stdio(false);

    cin>>n>>m>>p;
    for(int i=0; i<m; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        w[y].push_back(x);
        s[x].push_back({y,z-p});
    }
    dfs(n);
    bool flag=SPFA();
   // bool flag=bellman_ford();
    if(flag)
        cout<<max(0,dis[n])<<'\n';
    else
        puts("-1");

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using vi = std::vector<int>;
using vvi = std::vector<vi>;
const int mod = (int)1e9+7, NMAX = 100100;
int n;
int dp[2][NMAX];
vi adj[NMAX];
int solve(int u, int p, int color) {
    if (dp[color][u] != -1) {
        return dp[color][u];
    }
    int res = 1;
    for (int v : adj[u]) {
        if (v == p) continue;
        int tmp = solve(v,u,1-color);
        if (color == 0) {
            tmp += solve(v,u,color);
            if (tmp >= mod) tmp -= mod;
        }
        res = int(1LL * res * tmp % mod);
    }
    return dp[color][u] = res;
}
int main() {
    std::fill(&dp[0][0], &dp[0][0]+2*NMAX,-1);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cin >> n;
    for (int i = 1, x, y; i < n; i++) {
        std::cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    std::cout << (solve(1,0,0) + solve(1,0,1)) % mod << std::endl;
    return 0;
}

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

using namespace std;


void insert(vector<int> &p_q,int last,int val){
    p_q.push_back(val);
    last++;
    int last_p = (last-1)/2;
    while(last >= 0 && p_q[last] > p_q[last_p]){
        swap(p_q[last],p_q[last_p]);
        last = last_p;
        last_p = ((last-1)/2);
    }
}

void make_heap(vector<int> &p_q,int size,int idx){
    int left  = 2*idx+1;
    int right = left+1;

    int max_i = idx;
    if(left < size && p_q[left] > p_q[idx])
        max_i = left;
    if(right < size && p_q[right] > p_q[max_i])
        max_i = right;
    
    if(max_i != idx){
        swap(p_q[idx],p_q[max_i]);
        make_heap(p_q,size,max_i);
    }
}

void extract(vector<int> &p_q){
    int size = p_q.size();
    if(size < 1) return;
    int ret = p_q[0];
    p_q[0] = p_q[size-1];
    p_q.pop_back();
    make_heap(p_q,size,0);

    cout << ret << endl;
}

void print_queue(vector<int> &p_q){
    for(int i=0;i<p_q.size();i++)
        cout << p_q[i] << " ";
    cout << endl;
}

int main(){
    string order;
    int val;
    vector<int> p_queue;

    while(1){
        cin >> order;
        if(order == "insert"){
            cin >> val;
            insert(p_queue,p_queue.size()-1,val);
        }
        else if(order == "extract"){
           extract(p_queue);
        }
        else if(order == "end")
            break;
        else print_queue(p_queue);

    }

}


Measured memory_bytes: 6904
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
num1=(n-2)//2
num2=(n-2)%2
ans=a[0]
ans+=sum(a[1:num1+1])*2
if num2==1:
    ans+=a[num1+1]
print(ans)


Measured memory_bytes: 31620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  string s; cin >> s;
  if (s[5] == '0' &&  (s[6] == '1' || s[6] == '2' || s[6] == '3' || s[6] == '4'))
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}


Measured memory_bytes: 764
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;
void main() {
        string s;
        int ch=0,hi=0;
        while( (s=readln().strip()).length != 0 ){
                auto input = s.split(',').map!(to!int)().array();
                int a = input[0];
                int b = input[1];
                int c = input[2];
                if(a==b)hi++;
                if(a*a+b*b==c*c) ch++;
        }
        writeln(ch);
        writeln(hi);
}

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

int gcd(int a, int b){
	return !b?a:(gcd(b,a%b));
}
int32_t main() {
	int a,b;
	cin>>a>>b;
	int g = gcd(a,b);
	int ans=1;
	for(int i=2;i<=sqrt(g);i++){
		if(g%i !=0) continue;
		ans++;
		do g /= i; while(g%i == 0);
	}
	if(g>1) ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int a,b,c;

    scanf("%d%d%d",&a,&b,&c);

    int ary[101] = {}; //配列を0で初期化

    ary[a] = 1;
    ary[b] = 1;
    ary[c] = 1;

    int d = 0;

    for(int i=0; i<=100; i++){
        if(ary[i] == 1){
            d++;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

bool IsPalin(string S) {
  int N = S.size();
  for (int i = 0; i < N; ++i) {
    if (S[i] != S[N - 1 - i]) {
      return false;
    }
  }
  return true;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  string T = S.substr(0, N / 2);
  string U = S.substr(N / 2 + 1, N / 2);
  if (IsPalin(S) and IsPalin(T) and IsPalin(U)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    int a,b,c;
    int temp;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    if(b>c)
    {
        temp = b;
        b = c;
        c = temp;
    }
    if(a>b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    int hasil1 = a-b;
    if(hasil1<0) hasil1 = hasil1*-1;
    int hasil2 = b-c;
    if(hasil2<0) hasil2 = hasil2*-1;
    printf("%d\n",hasil1+hasil2);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(a[i] >= k)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 60;
Int dp[max_n][max_n][max_n*max_n];

int main(void) {
    Int n,k;
    cin>>n>>k;

    dp[0][0][0] = 1;

    if(k & 1) {
        cout<<0<<endl;

        return 0;
    }

    for(Int i = 0;i < n;i++) {
        for(Int j = 0;j < i+1;j++) {
            for(Int s = 0;s < k/2+1;s++) {
                Int nj;

                //both connect
                nj = j;
                dp[i+1][nj][s+nj] += dp[i][j][s];
                dp[i+1][nj][s+nj] %= MOD;

                //both rest
                nj = j+1;
                dp[i+1][nj][s+nj] += dp[i][j][s];
                dp[i+1][nj][s+nj] %= MOD;

                //connect one side
                nj = j;
                Int x = j*2;
                dp[i+1][nj][s+nj] += dp[i][j][s]*x%MOD;
                dp[i+1][nj][s+nj] %= MOD;

                if(j > 0) {
                    Int nj = j-1;
                    Int x = j*j;
                    dp[i+1][nj][s+nj] += dp[i][j][s]*x%MOD;
                    dp[i+1][nj][s+nj] %= MOD;
                }
            }
        }
    }

    cout<<dp[n][0][k/2]%MOD<<endl;

    return 0;
}


Measured memory_bytes: 84224