akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

int main( void ) {
	int a, b, c;
	scanf( "%d%d%d", &a, &b, &c );
	if( a % 2 && b % 2 && c % 2 ) {
		int maks = a;
		if( b > maks ) maks = b;
		if( c > maks ) maks = c;
		if( a == maks ) printf( "%lld\n", ( long long)b * c );
		else if( b == maks ) printf( "%lld\n", ( long long )a * c );
		else printf( "%lld\n", ( long long )a * b );
	}
	else printf( "0\n" );
	return 0;
}


Measured memory_bytes: 256
// @samaranand
//
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define int64 long long
#define VI vector < int >
#define VII vector < vector < int > >
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define pii pair < int , int >
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define sz size()
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
//const long long biGinf = 9e+18;
const char nwl = '\n';

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	//ur code
	int n;
	cin >> n;

	int t = n % 10;
	if (t == 2 or t == 4 or t == 5 or t == 7 or t == 9 )
		cout << "hon";
	else if (t == 1 or t == 6 or t == 8 or !t)
		cout << "pon";
	else
		cout << "bon";
	return 0;
}

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

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

int main(){

	int n;
	cin>>n;
	int a[n];
	ll x[100*1000+1]={};
	ll ans=0;
	rep(i,n){
		cin>>a[i];
		ans=ans+a[i];
		x[a[i]]++;
	}
	sort(a,a+n);

	int q;
	cin>>q;
	int b,c;
	rep(i,q){
		cin>>b>>c;
		if(x[b]!=0){
			ans=ans-x[b]*b+x[b]*c;
			x[c] += x[b];
			x[b]=0;
		}
		cout<<ans<<endl;
	}
	

	return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}
const int N = 1e5 + 9, MOD = 1e9 + 7;
vector<int> adj[N];
ll mem[N][2];
void add(int &a, int b) {
	if ((a += b) >= MOD)
		a -= MOD;
}

//color = current color of node
ll solve(int node, int par, bool color) {
	ll &rt = mem[node][color];
	if (~rt)
		return rt;
	rt = 1;
	for (int ch : adj[node])
		if (ch != par)
			rt = (rt * (solve(ch, node, 0) + (color == 0) * solve(ch, node, 1)))
					% MOD;
	return rt;
}

int main() {
	run();
	memset(mem, -1, sizeof(mem));
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cout << (solve(1, -1, 0) + solve(1, -1, 1)) % MOD << endl;
}


Measured memory_bytes: 14208
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pll
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<ll,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< tri,vector<tri> ,greater< tri > >

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);
pdqueue pq;
ll c[55],d[55],dist[55][3005];
vector<vl>adj(55),cost(55),wt(55);
pii par[55][3005];
int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	double clk=clock();
	ll n,m,s,u,v,a,b,i,j,dis,x,y,ans,y1;
	tri p;
	cin>>n>>m>>s;
	rep(i,m){
		cin>>u>>v>>a>>b;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		cost[u].pb(a);
		cost[v].pb(a);
		wt[u].pb(b);
		wt[v].pb(b);
	}
	rep(i,n){
		cin>>c[i]>>d[i];
	}
	s=min(s,2502LL);
	ll iinf=inf;
	iinf*=inf;
	rep(i,n){
		rep(j,2503){
			dist[i][j]=iinf;
		}
	}
	dist[0][s]=0;
	pq.push(mp(dist[0][s],mp(0,s)));
	while(!pq.empty()){
		p=pq.top();
		dis=p.ff;
		x=p.ss.ff;
		y=p.ss.ss;
		pq.pop();
		if(dist[x][y]<dis){
			continue;
		}
		rep(i,adj[x].size()){
			if(y>=cost[x][i]){
				if(dist[adj[x][i]][y-cost[x][i]]>dis+wt[x][i]){
					par[adj[x][i]][y-cost[x][i]]=mp(x,y);
					dist[adj[x][i]][y-cost[x][i]]=dis+wt[x][i];
					pq.push(mp(dist[adj[x][i]][y-cost[x][i]],mp(adj[x][i],y-cost[x][i])));
				}
			}
		}
		y1=y;
		dis+=d[x];
		y+=c[x];
		while(y<2503){
			if(dist[x][y]>dis){
				par[x][y]=mp(x,y1);
				dist[x][y]=dis;
				pq.push(mp(dis,mp(x,y)));
			}
			dis+=d[x];
			y+=c[x];
		}
	}
	//cout<<dist[0][3]<<endl;
	f(i,1,n){
		ans=iinf;
		rep(j,2503){
			ans=min(ans,dist[i][j]);
		}
		cout<<ans<<endl;
	}
	//cerr<<(clock()-clk)/CLOCKS_PER_SEC<<endl;
	return 0;
} 


Measured memory_bytes: 101916
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll w,h,x,y;cin >> w >> h >> x >> y;
    cout << setprecision(10) << ((double)(w*h))/2;
    if(w%2==0 and h%2==0 and x==w/2 and y==h/2)cout << " 1";
    else cout << " 0";
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 6666;
int n,m,a[N],b[N],c[N],top;
void ins(int x, int y, int z){top++;a[top]=x+1;b[top]=y+1;c[top]=z;}
int main() {
	int l;read(l);n=20;
	rep(i,0,17)ins(i,i+1,0),ins(i,i+1,1<<i);
	rep(i,0,19)if((l>>i)&1){
		int now=l&(((1<<20)-1)^((1<<(i+1))-1));
		if(i<19)ins(max(i,0),19,now);
		else ins(18,19,now),ins(18,19,now+(1<<18));
	}
	
	printf("%d %d\n",n,top);
	rep(i,1,top)printf("%d %d %d\n",a[i],b[i],c[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  int n,k,x,y,sum=0;
    cin>>n>>k>>x>>y;
    if(k>=n){
        cout<<(n*x)<<endl;
        return 0;
    }
    else{
        sum=(k*x)+((n-k)*y);
    cout<<sum<<endl;
    return 0;
    }
}


Measured memory_bytes: 3584
import sys


A, B, C = [int(x) for x in input().split(" ")]
K = int(input())

for i in range(K + 1):
    j = K - i
    if A < B * (2 ** i) and B * (2 ** i) < C * (2 ** j):
        print("Yes")
        sys.exit(0)
print("No")

Measured memory_bytes: 9180
k = int(input())

l = [i for i in range(1,10)]
for i in range(k):
    if l[i]%10 != 0:
        l.append(10*l[i]+l[i]%10-1)
    l.append(10*l[i]+l[i]%10)
    if l[i]%10 != 9:
        l.append(10*l[i]+l[i]%10+1)
print(l[k-1])

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

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

const int mod = 998244353;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  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();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

#define maxn 3030
mint dp[maxn][maxn];

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // input
  ll N,S;cin >> N >> S;
  vector<ll> a(N);
  for(int i=0;i<N;i++)cin >> a[i];
  
  dp[0][0] = 1;
  for(int i = 0;i < N;i++){
    for(int j = 0;j <= S;j++){
      if(j + a[i] <= S) dp[i+1][j+a[i]] += dp[i][j];
      dp[i+1][j] += mint(2)*dp[i][j];
    }
  }
  cout<<dp[N][S]<<'\n';
}


Measured memory_bytes: 75388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
    static int count = 0;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br);
        koch(0, 0, 100, 0, n);
        System.out.format("%.4f %.4f\n", 100f, 0f);

    }

    public static void koch(double x1, double y1, double x2, double y2, int n) {
        if (n <= 0) {
            System.out.printf("%.4f %.4f\n", x1, y1);
        } else {
            double xs = (2 * x1 + x2) / 3;
            double ys = (2 * y1 + y2) / 3;
            double xt = (x1 + 2 * x2) / 3;
            double yt = (y1 + 2 * y2) / 3;
            double l = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) / 3;
            double theta = Math.atan2(y2 - y1, x2 - x1) + Math.PI / 3;
            double xu = xs + l * Math.cos(theta);
            double yu = ys + l * Math.sin(theta);

            koch(x1, y1, xs, ys, n - 1);
            koch(xs, ys, xu, yu, n - 1);
            koch(xu, yu, xt, yt, n - 1);
            koch(xt, yt, x2, y2, n - 1);
        }
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(BufferedReader br) throws IOException {
        String[] lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static int ip(BufferedReader s) throws IOException {
        return Integer.parseInt(s.readLine());
    }
}

class Point {
    double x;
    double y;

    Point(double x, double y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 41288
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		ArrayList<String> list = new ArrayList<String>();
		
		//-1 -1 -1?????\?????????????????§??°?????????
		while(true) {
			
			//list???????´???????
			list.add(sc.nextLine());
			if(list.get(list.size() - 1).equals("-1 -1 -1")) {
				break;
			}
		}
		
		//?????±???int???????????????2?¬??????????????§?????????????
		int [][] data = new int[list.size() - 1][3];
		for(int i = 0; i < list.size() - 1; i++) {
			String s = list.get(i);
			String [] ary = s.split(" ");
			for(int j = 0; j < ary.length; j++) {
				data[i][j] = Integer.parseInt(ary[j]);
			}
		}
		
		//???????????¨?????????
		for(int i = 0; i < data.length; i++) {
			int sum = 0;
			for(int j = 0; j < data[i].length - 1; j++) {
				sum += data[i][j];
			}
			if(data[i][0] == -1 || data[i][1] == -1) {
				System.out.println("F");
			}else if(sum >= 80) {
				System.out.println("A");
			}else if(sum >= 65) {
				System.out.println("B");
			}else if(sum >= 50) {
				System.out.println("C");
			}else if(sum >= 30){
				if(data[i][2] >= 50){
					System.out.println("C");
				}else {
					System.out.println("D");
				}
			}else {
				System.out.println("F");
			}
		}
	}

}

Measured memory_bytes: 26168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main() {
  int d,n; cin >> d >> n;
  int s=pow(100,d);

  if (n < 100) COUT(s*n);
  else COUT(s*101);
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split(' '))
h = list(map(int,input().split(' ')))
ansList = [1]*n
numlist = []

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        #ansList[a-1] = ma
        numlist.append(b-1)
    elif h[a-1] == h[b-1]:
        numlist.append(a-1)
        numlist.append(b-1)
    else:
        numlist.append(a-1)
for i in list(set(numlist)):
    ansList[i] = 0
print(ansList.count(1))

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

#define MAXN (200010)

int n, k, nowA;
char str[MAXN];
std::deque<int> dq;

int main(){
	scanf("%d%d%s", &n, &k, str);
	for(int i = 0; i < n; ++ i){
		dq.push_back(str[i] - 'A');
	}
	if(k > (n << 1)){
		k = (n << 1) + (k & 1);
	}
	for(int i = 1; i <= k; ++ i){
		if(dq.front() == nowA){
			dq.pop_front();
			dq.push_front(nowA ^ 1);
		}
		else{
			dq.pop_front();
			nowA ^= 1;
			dq.push_back(nowA);
		}
	}
	for(int v : dq){
	    putchar(v == nowA ? 'A' : 'B');
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 1536
#include  <stdio.h>
int main(){
  int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);

int bus,train;
if(a>=b){
  train=b;
}
else{
  train=a;
}

if(c>=d)
{
  bus=d;
}
else{
  bus=c;
}

printf("%d\n",train+bus);

return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

constexpr long long MAX = 2000 + 1;
using ll = long long;

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

ll comb(ll n, ll r) {
  return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

int main()
{
  long long N, K;
  std::cin >> N >> K;
  fact[0] = 1;
  for (int i = 0; i < N; ++i)
    fact[i + 1] = fact[i] * (i + 1) % MOD;
  fact_inv[N] = power(fact[N], MOD - 2);

  for (int i = N - 1; 0 <= i; --i)
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;

  for (int i = 1; i <= K; ++i)
  {
    if (N - K + 1 < i)
      std::cout << 0 << "\n";
    else
      std::cout << (comb(N - K + 1, i) * comb(K - 1,i - 1)) % MOD << "\n";
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  
  if (a >= 13) cout << b << endl;
  else if (a >= 6 && a <= 12) cout << b/2 << endl;
  else if (a <= 5) cout << 0 << endl;
}
  

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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for(int i=0; i<N; i++){
    cin >> card.at(i);
  }
  
  int A=0, B=0, pt=0;
  int turn;
  sort(card.begin(),card.end(),greater<int>());
  int ans;
  
  for(int i=0; i<N; i++){
    turn = i % 2;
    pt = card.at(i);
    if(turn==0){
      A += pt;
    }
    if(turn==1){
      B += pt;
    }
  }
  
  ans = A-B;
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

constexpr ll inf = ll(1e18)+9;
int main() {
    // input
    int n, m, l; scanf("%d%d%d", &n, &m, &l);
    vector<int> k(n); repeat (i, n) { scanf("%d", &k[i]); -- k[i]; }
    vector<int> s(m); repeat (i, m) scanf("%d", &s[i]);
    // solve
    sort(whole(k));
    vector<ll> s_acc(m + 1);
    repeat (i, m) s_acc[i + 1] = s_acc[i] + s[i];
    auto penalty = [&](int a, int b) { if (a > b) swap(a, b); return (s_acc[k[b] + 1] - s_acc[k[a]]) / l; };
    auto dp = vectors(n, n, inf);
    dp[1][0] = penalty(0, 1);
    repeat (a, n - 1) {
        repeat (b, a) {
            setmin(dp[a + 1][a], dp[a][b] + penalty(b, a + 1));
            setmin(dp[a + 1][b], dp[a][b] + penalty(a, a + 1));
        }
    }
    ll result = inf;
    repeat (c, n - 1) {
        setmin(result, dp[n - 1][c] + penalty(n - 1, c));
    }
    // output
    printf("%lld\n", result);
    return 0;
}

Measured memory_bytes: 34948
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.*; 
import java.util.StringTokenizer; 
import java.io.PrintWriter;
import java.io.*;
import java.util.stream.Collectors.*;
import java.lang.*;
import static java.util.stream.Collectors.*;
import static java.util.Map.Entry.*;
public class Main
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
  
    static long modpower(long a, long b,long c)
    {
      if(b==0)
        return 1L;
      long res=modpower(a,b/2,c);
      res*=res;
      res%=c;

      if(b%2==1)
        res=(res*a)%c;

      return res;
    }
 
    
    public static void main(String args[] ) throws Exception 
    {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */
        FastReader sc=new FastReader();
       // String s=sc.next();
        PrintWriter out=new PrintWriter(System.out);
        long n=sc.nextInt();
        long k=sc.nextInt();
        long[] dp=new long[(int)(k+1)];
        long mod=1000000007;

        for(long x=k;x>=1;x--)
        {
          dp[(int)x]=modpower(k/x, n, mod);
          for(long j=2;x*j<=k;j++)
          {
            dp[(int)x]-=dp[(int)(j*x)];
            dp[(int)x]=(dp[(int)x]+mod)%mod;
          }         
        }

        long ans=0;
        for(int i=1;i<=k;i++)
        {
          //System.out.println(dp[i]);
          ans+=(i*dp[i]);
          ans+=mod;
          ans%=mod;
        }

        System.out.println(ans);
    }
 }


Measured memory_bytes: 33876
import Control.Monad (unless)

primes :: Integral a => [a]
primes = 2 : sieve [3] [3, 5 ..]
    where
        sieve (x : xs) ys = let (ps, qs) = span (< x * x) ys
            in ps ++ sieve (xs ++ ps) [z | z <- qs, mod z x /= 0]

sumOfPrimes :: Int -> Int
sumOfPrimes = sum . flip take primes

main :: IO ()
main = do
    n <- readLn
    unless (n == 0) $ do
        (putStrLn . show . sumOfPrimes) n
        main

Measured memory_bytes: 7572
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<string,int>mp;
int main(){
mp["SAT"]=1;
mp["SUN"]=7;
mp["MON"]=6;
mp["TUE"]=5;
mp["WED"]=4;
mp["THU"]=3;
mp["FRI"]=2;
string s;
cin>>s;
cout<<mp[s]<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

A, B, C = sorted(map(int, input().split()))
# print(A, B, C)
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
    print(0)
else:
    # all odd
    ans = float('inf')
    ans = min(B*C*((A//2)+1) - B*C*(A//2), ans)
    A, C = C, A
    ans = min(B*C*((A//2)+1) - B*C*(A//2), ans)
    A, B = B, A
    ans = min(B*C*((A//2)+1) - B*C*(A//2), ans)
    print(ans)


Measured memory_bytes: 3064
c=input()
while c!='-':
    #print(c)
    C=list(c)
    #print(C)
    l=int(input())
    #print(l)
    for i in range(l):
        n=int(input())
        for j in range(n):
            C.append(C[j])
        del C[0:n]
        #print(C)
    print(''.join(C))
    c=input()


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int n, m;

void solve() {
	vl v(n);
	ll mx = -1;
	rep(i, n) {
		cin >> v[i];
	}
	sort(all(v));
	rep(i, n) {
		range(j, i+1, n) {
			if (v[i] + v[j] <= m)mx = max(v[i] + v[j], mx);
		}
	}
	cout<<(mx != -1 ? to_string(mx) : "NONE" ) << endl;
}

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

	while (cin >> n >> m,n) {
		solve();
	}
}



Measured memory_bytes: 3224
#include <iostream>
//#define int long long
//#define _DEBUG
#include <vector>
using namespace std;
int const infty = -1, none = -9;

//input
int N, T[107][107]; //T[i][j]:i->T[i][j]の辺

int /*D[107], */t, d[107], f[107];
bool visited[107];
void dfs(int cur){
    visited[cur] = true;
    d[cur] = t;
    t++;
    //cerr << "Visiting " << cur << " " << t << endl;
    for(int j=0; j<107; j++){
        if(T[cur][j]==none) break;
        if(!visited[T[cur][j]]/* || (D[T[cur][j]]!=infty || D[T[cur][j]]>D[cur])*/){
            //D[T[cur][j]] = D[cur]+1;
            dfs(T[cur][j]);
        }
    }
    f[cur] = t;
    t++;
}
void solve(){
    t = 1;
    //D[0] = 0;
    for(int i=0; i<N; i++){
        if(!visited[i]) dfs(i);
    }
}
void get(){
    cin >> N;
    //fill(D, D+N, infty);
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            T[i][j] = none;
        }
    }

    for(int i=0; i<N; i++){
        int _i, k;
        cin >> _i >> k;
        for(int j=0; j<k; j++){
            int vj;
            cin >> vj;
            T[i][j] = vj-1;
        }
    }
    fill(visited, visited+N, false);
}

signed main(){
    get();
    solve();
    /*for(int i=0; i<N; i++){
        cout << i+1 << " " << D[i] << endl;
    }*/
    for(int i=0; i<N; i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,n;
    cin>>k>>n;
    int a[n],d[n];
    cin>>a[0];
    for(int i=1; i<n; i++){
        cin>>a[i];
        d[i]=a[i]-a[i-1];
    }
    d[0]=k+a[0]-a[n-1];
    sort(d,d+n);
    cout<<k-d[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5164
#include<cstdio>
using namespace std;
int main(){
	for(int n;scanf("%d",&n),n;){
		int cnt[10]={};
		while(n--){
			int a;	scanf("%d",&a);
			cnt[a]++;
		}
		for(int i=0;i<10;i++){
			for(int j=0;j<cnt[i];j++)	putchar('*');
			puts(cnt[i]?"":"-");
		}
	}
}


Measured memory_bytes: 2484
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
using namespace std;
typedef long long int ll;
ll ans=1e18;
ll answer[2100];
ll upcost[2100][2100];
ll cost[2100];
int n;
ll x;

void prepr(void)
{
	int i, j;
	for(i=1 ; i<=n ; i++)
	{
		upcost[i][0]=cost[i];
		for(j=1 ; j<=n ; j++)
		{
			upcost[i][j]=min(upcost[i][j-1],cost[(i-j-1+n)%n+1]);
		}
	}
}
ll getthat(int move)
{
	int i, j;
	ll ret=0;
	ret+=move*x;
	for(i=1 ; i<=n ; i++)
	{
		ret+=upcost[i][move];
	}
	return ret;
}

int main(void)
{
	cin>>n>>x;
	int i, j;
	for(i=1 ; i<=n ; i++)
	{
		scanf("%lld",&cost[i]);
	}
	prepr();
	for(i=0 ; i<=n ; i++)
	{
		answer[i]=getthat(i);
	}
	for(i=0 ; i<=n ; i++)
	{
		ans=min(ans,answer[i]);
	}
	cout<<ans<<endl;
}

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

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


using namespace std;



int main(){
    int n, a, b;
    cin >> n >> a >> b;

    a--; b--;

    string o = "Draw";
    rep(i, 3*n){
        if(a+1 == b){
            if(a-1 == -1){
                o = "Borys";
                break;
            }
            else a--;
        }
        else if(a+1 < n) a++;
        else{
            o = "Borys";
            break;
        }

        if(b-1 == a){
            if(b+1 == n){
                o = "Alice";
                break;
            }
            else b++;
        }
        else if(0 <= b-1) b--;
        else{
            o = "Alice";
            break;
        }

    }

    cout << o << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int t,n;
    for (int i = 0; i < 4; i++)
    {
        cin >> t >> n;
        if (t == 1)
        {
            cout << 6000 * n << endl;
        }
        else if (t == 2)
        {
            cout << 4000 * n << endl;
        }
        else if (t == 3)
        {
            cout << 3000 * n << endl;
        }
        else if (t == 4)
        {
            cout << 2000 * n << endl;
        }
    }
   
    return 0;
}

Measured memory_bytes: 1160
n = int(input())
a, b = 1, 0
for i in range(n) :
    q, x = map(int, input().split())
    if q == 1 :
        a *= x
        b *= x
    elif q == 2 :
        b += x
    elif q == 3 :
        b -= x
print(-b, a)


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime 1000000007

using namespace std;

#define INF 1000000000

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll r;
	cin >> r;
	cout << r*r << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b;
    b+=a*3;
    Cout(b/2);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String s3 = s.substring(2, 3);
		String s4 = s.substring(3, 4);
		String s5 = s.substring(4, 5);
		String s6 = s.substring(5, 6);
		if (s3.equals(s4) && s5.equals(s6)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}

}

Measured memory_bytes: 21716
import math as m

a, b, c = map(float, input().split())
cos_c =  m.cos(m.radians(c))
d = m.sqrt(a ** 2 + b ** 2 - (2 * a * b) * cos_c)

s = (1 / 2) * a * b * m.sin(m.radians(c))
l = a + b + d
h = (2 * s) / a

print(s, l, h, sep="\n")



Measured memory_bytes: 5692
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int ans;
int solve(){
    int n,s=0; cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        s+=a[i];
    }
    int x=s/n,y=s/n+1;
    int m1=0,m2=0;
    for (int i = 0; i < n; ++i)
    {
        m1+=(a[i]-x)*(a[i]-x);
        m2+=(a[i]-y)*(a[i]-y);
    }
    cout<<min(m1,m2);
    return 0;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

using LL = long long;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

	int n; cin >> n;
	string s; cin >> s;
	vector<vector<int>> prv(n + 1);
	prv[0].assign(10, 0);
	for (int i = 1; i <= n; i++) {
		prv[i] = prv[i - 1];
		prv[i][s[i - 1] - '0'] = i;
	}

	int ans = 0;
	for (int x = 0; x < 1000; x++) {
		string t = to_string(x);
		while (t.size() < 3u) t.insert(t.begin(), '0');

		int i = n + 1;
		for (char ch: t) {
			if (i > 0) i = prv[i - 1][ch - '0'];
		}
		if (i > 0) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	string s;
	long long int r = 0, g = 0, b = 0;
	cin >> n;
	cin >> s;
	for(long long int i = 0;i < n;i++){
		if(s[i] == 'R'){
			r++;
		}else if(s[i] == 'G'){
			g++;
		}else{
			b++;
		}
	}
	long long int ans = r * g * b;
	for(long long int i = 0;i < n - 2;i++){
		for(long long int j = i + 1;j < n;j++){
			if((i + j) % 2 == 0){
				if(s[i] != s[j] && s[i] != s[(i + j) / 2] && s[j] != s[(i + j) / 2]){
					ans--;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N,E[3];
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		for(int j=0;j<3;j++) scanf("%d",&E[j]);
		sort(E,E+3);
		printf(((E[2]*E[2])==(E[0]*E[0]+E[1]*E[1]))?"YES\n":"NO\n");
	}
}

Measured memory_bytes: 1024
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sat Jan 18 17:10:29 2020
//
package main

import "fmt"

var N, M int

func main() {
	fmt.Scan(&N, &M)

	acs := make([]bool, N)
	was := make([]int, N)
	for i := 0; i < M; i++ {
		var p int
		var s string
		fmt.Scan(&p, &s)
		if s == "WA" {
			if !acs[p-1] {
				was[p-1]++
			}

		} else {
			acs[p-1] = true
		}
	}

	numAC := 0
	for i := range acs {
		if acs[i] {
			numAC++
		}
	}
	numWA := 0
	for i := range was {
		if acs[i] {
			numWA += was[i]
		}
	}
	fmt.Println(numAC, numWA)
}


Measured memory_bytes: 5504
# coding:utf-8

import sys
from collections import deque, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    G = defaultdict(list)
    for _ in range(n - 1):
        a, b = LI_()
        G[a].append(b)
        G[b].append(a)

    def DFS(start):
        stack = deque([start])
        dist = [INF] * n
        dist[start] = 0
        max_dist = 0
        farthest_v = start
        while stack:
            curr = stack.pop()

            for next in G[curr]:
                if dist[next] != INF:
                    continue
                dist[next] = dist[curr] + 1
                stack.append(next)
                if dist[next] > max_dist:
                    max_dist = dist[next]
                    farthest_v = next

        return farthest_v, max_dist

    v, d = DFS(0)
    u, d = DFS(v)

    # print(v + 1, u + 1, d)
    if d == 1: d = 0
    print('First' if d % 3 != 1 else 'Second')
    # print('First' if d % 2 else 'Second')

if __name__ == '__main__':
    main()


Measured memory_bytes: 119744
//状态:
//题号:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
#include <list>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+";
	else if(a*b==15)cout<<"*";
	else cout<<"x";
	return 0;
}


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

bool CMP(pair<int, int>bp, pair<int, int>rp);

int main(){
	int N;
	cin >> N;
	vector<pair<int, int>>RedP(N), BlueP(N);
	vector<pair<int, int>>Lines; //(青, 赤)
	for (int i = 0; i < N; i++) {
		int ai, bi;
		cin >> ai >> bi;
		RedP[i] = make_pair(ai, bi);
	}
	for (int i = 0; i < N; i++) {
		int ci, di;
		cin >> ci >> di;
		BlueP[i] = make_pair(ci, di);
		for (int j = 0; j < N; j++) {
			if (CMP(BlueP[i], RedP[j]))Lines.push_back(make_pair(i, j));
		}
	}
    priority_queue<tuple<int, int, int>>Q; //-青x座標, 赤y座標, Lines添字
    for(int i=0; i<Lines.size(); i++){
        Q.push(make_tuple(-BlueP[Lines[i].first].first, RedP[Lines[i].second].second, i));
    }
    int c=0;
    while(!Q.empty()){
        c++;
        tuple<int, int, int>lp=Q.top();
        int ersrp = Lines[get<2>(lp)].second, ersbp = Lines[get<2>(lp)].first;
	    queue<int>el;
	    for (int i = 0; i < (int)Lines.size(); i++) {
	    	if (Lines[i].first == ersbp || Lines[i].second == ersrp)el.push(i);
	    }
	    int ersc = 0;
	    while (!el.empty()) {
	    	Lines.erase(Lines.begin() + el.front() - ersc);
	    	el.pop();
	    	ersc++;
	    }
        priority_queue<tuple<int, int, int>>newQ;
        for(int i=0; i<Lines.size(); i++){
            newQ.push(make_tuple(-BlueP[Lines[i].first].first, RedP[Lines[i].second].second, i));
        }
        newQ.swap(Q);
    }
    cout << c;
    return 0;
}

bool CMP(pair<int, int>bp, pair<int, int>rp) {
	return (rp.first < bp.first) && (rp.second < bp.second);
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
	int x;
	cin >> x;
	int pleasure = 0;
	int f = x / 500;
	x -= f * 500;
	pleasure += 1000 * f;
	
	f = x / 5;
	x -= f * 5;
	pleasure += 5 * f;
	
	cout << pleasure << endl;
}

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

int Hash[16777216];
char s[13];

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

int getKey(){
  int sum=0,p=1;
  for(int i=0;i<strlen(s);i++){
    sum+=p*(getChar(s[i]));
    p*=4;
  }
  return sum;
}

int main(){
  int n;
  char com[7];
  scanf("%d",&n);
  while(n--){
    scanf("%s %s",com,s);
    if(com[0]=='i'){
      Hash[getKey()]=1;
      // printf("%d\n",getKey());
    }else{
      if(Hash[getKey()]){
        puts("yes");
      }else{
        puts("no");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 7152
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n);
  rep(i, n) cin >> as[i];

  vll cuml(n), cumr(n);
  rep(i, n) {
    if (i == 0) {
      cuml[i] = as[i];
      cumr[n - 1 - i] = as[n - 1 - i];
    } else {
      cuml[i] = gcd(cuml[i - 1], as[i]);
      cumr[n - 1 - i] = gcd(cumr[n - i], as[n - 1 - i]);
    }
  }

  ll ans = 1;
  rep(i, n) {
    if (i == 0)
      chmax(ans, cumr[i + 1]);
    else if (i == n - 1)
      chmax(ans, cuml[i - 1]);
    else
      chmax(ans, gcd(cuml[i - 1], cumr[i + 1]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5624
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int x;
rep3(j,5){
  cin>>x;
  if(x==0){
    cout<<j<<endl;
  }
}


return 0;
}




Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

public class Main {

    public static final int NA = -1;

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        final int q = in.readLineAsInt();
        for (int i = 0; i < q; i++) {
            String A = in.readLine();
            String B = in.readLine();
            System.out.println(lcsRoot(A, B));
        }
    }


    private int lcsRoot(String a, String b) {
        int[][] memo = new int[a.length() + 1][b.length() + 1];
        for (int i = 0; i < memo.length; i++) {
            Arrays.fill(memo[i], NA);
        }
        return lcs(a, b, a.length(), b.length(), memo);
    }

    private int lcs(String a, String b, int i, int j, int[][] memo) {
        if (memo[i][j] != NA) {
            return memo[i][j];
        } else if (i == 0 || j == 0) {
            memo[i][j] = 0;
            return 0;
        } else {
            int lcs = 0;
            if (a.charAt(i - 1) == b.charAt(j - 1)) {
                lcs = lcs(a, b, i - 1, j - 1, memo) + 1;
            } else {
                lcs = Math.max(lcs(a, b, i - 1, j, memo), lcs(a, b, i, j - 1, memo));
            }
            memo[i][j] = lcs;
            return lcs;
        }
    }

    static class CustomReader extends BufferedReader {

        //private static final int DEFAULT_BUF_SIZE = 2048;
        private static final int DEFAULT_BUF_SIZE = 4096;
        //private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }


        public int readLineAsInt() throws IOException {
            return Integer.parseInt(this.readLine());
        }


        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}


Measured memory_bytes: 64480
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> V;

int main() {
    int n;
    cin >> n;
    V p = V(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int s = 0;
    for (int i = 0; i < n; i++) {
        if (i == n - 1) {
            s += p[i] / 2;
        } else {
            s += p[i];
        }
    }
    cout << s << "\n";
}

Measured memory_bytes: 256
def gcd(a,b):
  x=max(a,b)
  y=min(a,b)
  while y>0:
    x=x%y
    x,y=y,x
  return x

n=int(input())
t=[int(input()) for _ in range(n)]
lcm=t[0]
for i in range(1,n):
  lcm=(lcm*t[i])//gcd(lcm,t[i])
print(lcm)

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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define fi first
#define se second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 205000;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);
int dp[3010][3010];

int main()
{
	run_forrest_run;
 	string s,t;
 	cin >> s >> t;
 	for (int i = 0; i <= sz(s); i++)
 	{
 		for (int j = 0; j <= sz(t); j++)
 		{
 			if (s[i] == t[j])
 				dp[i+1][j+1] = dp[i][j]+1;
 			else
 				dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
 		}
 	}
 	int i = sz(s);
 	int j = sz(t);
 	string ans;
 	while(i != 0 && j != 0)
 	{
 		if (dp[i-1][j] != dp[i][j] && dp[i][j-1] != dp[i][j])
 		{
 			ans.pb(s[i-1]);
 			i--;
 			j--;
 		}
 		else if (dp[i-1][j] != dp[i][j])
 			j--;
 		else 
 			i--;
 	}
 	for (int i = sz(ans)-1; i >= 0; i--)
 		cout << ans[i];


}


Measured memory_bytes: 41344