akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


void solve(){

  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}


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


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        x: i64,
        y: i64
    }

    let m = 4 * x - y;
    if m % 2 == 0 && m >= 0 && m <= 2 * x {
        println!("Yes");
    }
    else {
        println!("No");
    }
}


Measured memory_bytes: 2112
def is_odd(num):
    return num % 2 == 1


def divisors_count(num):
    return sum(num % i == 0 for i in range(1, num+1))


n = int(input())
print(sum([1 for i in range(1, n+1) if is_odd(i) and divisors_count(i) == 8]))


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

bool dp[80][80][12800];
void set_dp(int i, int j, int k) {
  if (k >= 0 && k < 12800) {
    dp[i][j][k] = true;
  }
}
int main() {
  int h, w;
  cin>>h>>w;
  int a[h][w], b[h][w];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin>>a[i][j];
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin>>b[i][j];
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      for (int k=0; k<12800; k++) {
        dp[i][j][k] = false;
      }
    }
  }
  set_dp(0, 0, a[0][0] - b[0][0] + 6400);
  set_dp(0, 0, b[0][0] - a[0][0] + 6400);
  for (int j=1; j<w; j++) {
    int c = a[0][j] - b[0][j];
    for (int k=0; k<12800; k++) {
      if (dp[0][j-1][k]) {
        set_dp(0, j, k+c);
        set_dp(0, j, k-c);
      }
    }
  }
  for (int i=1; i<h; i++) {
    int c = a[i][0] - b[i][0];
    for (int k=0; k<12800; k++) {
      if (dp[i-1][0][k]) {
        set_dp(i, 0, k+c);
        set_dp(i, 0, k-c);
      }
    }
  }
  for (int i=1; i<h; i++) {
    for (int j=1; j<w; j++) {
      int c = a[i][j] - b[i][j];
      for (int k=0; k<12800; k++) {
        if (dp[i][j-1][k]) {
          set_dp(i, j, k+c);
          set_dp(i, j, k-c);
        }
      }
      for (int k=0; k<12800; k++) {
        if (dp[i-1][j][k]) {
          set_dp(i, j, k+c);
          set_dp(i, j, k-c);
        }
      }
    }
  }
  int ans = 6400;
  for (int k=0; k<12800; k++) {
    if (dp[h-1][w-1][k]) {
      ans = min(abs(k-6400), ans);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int chnum(int c[])
{
	int res = 0;

	rep(i, 8)
	{
		res *= 10;
		res += c[i];
	}
	
	return res;
}

int main()
{
	int c[] = {1, 4, 1, 4, 1, 2, 1, 2};
	vint p(8);
	while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7])
	{
		int res = 1 << 30, cride = 1 << 30;
		rep(i, 8)
		{
			rotate(c, c + 1, c + 8);

			int buf = 0;
			rep(j, 8)
				buf += max(0, p[j] - c[j]);

			if(buf == cride)
				chmin(res, chnum(c));
			else if(buf < cride)
			{
				res = chnum(c);
		
				cride = buf;
			}
		}
		

		char ans[8] = {0};
		sprintf(ans, "%d", res);
		rep(i, 8)
			cout << ans[i] << (i != 7 ? " " : "\n");
	}
}

Measured memory_bytes: 0
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int r,g,b,n,ans;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  cin >> r >> g >> b >> n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(i*r+j*g>n)continue;
      int x = (n-i-j);
      if(  (n - i*r - j*g)%b==0 ){
        //cout << i << " " << j << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
return 0;
}
///....


Measured memory_bytes: 256
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

def dfs(now, prev):
    for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now)


n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])

dist = [0] * n
dfs(0, -1)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 184240
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int sumdigit(int N){
    int sum = 0;

    while(N > 0){
        sum += N % 10;
        N /= 10;
    }
    return sum;
}
int main() {
    int n; cin >> n;
    int ans = 0;
    int ans_min = N;

    for (int i = 1; i < n; ++i) {
        ans = sumdigit(i) + sumdigit(n - i);
        if(ans < ans_min)ans_min = ans;
    }
    print(ans_min);
}

Measured memory_bytes: 256
import math

n,m = map(int,input().split())

q = m // n

ret = 0
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        if i <= q and ret < i:
            ret = i
        p = m//i
        if m//i <= q and ret < p:
            ret = p
print(ret)


Measured memory_bytes: 3060
using System;
class Program
    {
        static void Main(string[] args)
        {
            short n = short.Parse(Console.ReadLine());
            long x = 100000;
            for (short i = 0; i < n; i++)
            {
                x = (long)Math.Ceiling(1.05 * x/1000)*1000;
            }
            Console.WriteLine(x);
            Console.ReadLine();
        }
    }

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

int main() {

int n ;
cin>>n;
int arr[n];

for(int i = 0 ; i<n; i++)
  cin>>arr[i] ;

int dp[n] ;

dp[0] = 0;

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

  int option1 = abs(arr[i] - arr[i-1]) + dp[i-1] ;
  int option2 =  i == 1 ? INT_MAX : (abs(arr[i] - arr[i-2]) + dp[i-2]) ;
  dp[i] = min(option1, option2) ; 
}

cout<<dp[n-1];

return 0;
}

Measured memory_bytes: 1024
const fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main(){
  const data = input
  const x = Number(data[0])
  console.log(x * x * x)
}


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

int main() {
  int n,k;
  string s;
  cin>>n>>k>>s;

  if(s[k-1]=='A') s[k-1]='a';
  else if(s[k-1]=='B') s[k-1]='b';
  else if(s[k-1]=='C') s[k-1]='c';
  cout<<s<<endl; 

  }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int min1;
int min2;

int ans[4];

int returnPay(int cost,int accept,int *state){
	if(cost>accept)return 10000000;

	int num = accept - cost;
//	cout<<"num= "<<num<<endl;

	int cnt=0;

	int data[4] ={500,100,50,10};
	int tmp[4];
	for(int i=0;i<4;i++){
		tmp[i]=0;
		while(num>=data[i]){
			cnt++;
			num-=data[i];
			tmp[i]++;
		}
	}

	int flag=0;
	int searchNum=-1;
	for(int i=0;i<4;i++){
		if(state[4-i-1]>0&&tmp[i]>0){
			return 10000000;
		}
	}


	//cout<<"num="<<accept-cost<<endl;
	return cnt;
}

void makePattern(int *state,int *data,int pos,int n,int cost){

	int okane[4]={500,100,50,10};

	if(pos==n){
		int sum=0;
		int maisuu=0;
		for(int i=0;i<n;i++){
			sum+=state[n-1-i]*okane[i];
			maisuu+=(data[n-1-i]-state[n-1-i]);
	//		cout<<state[i]<<" ";
		}
	//	cout<<endl;
	//	cout<<"sum= "<<sum<<endl;

		maisuu+=returnPay(cost,sum,state);
	//	cout<<"tmp= "<<tmp<<endl;
		if(maisuu<=min2){
			int flag=0;

			if(flag==0){
				min2=maisuu;
				for(int i=0;i<n;i++){
					ans[i]=state[i];
				}
			}
		}
	}


	else{
	for(int i=0;i<=data[pos];i++){
		state[pos]=i;
		makePattern(state,data,pos+1,n,cost);
	}
	}
}



int main(){

	int cnt=0;

	int num;
	int state[4];
	int data[4];
	int ten[4]={10,50,100,500};
	int unko=0;
	while(cin>>num){
		if(num==0)break;
		if(unko!=0)cout<<endl;
		min1=1000000;
		min2=10000;
		for(int i=0;i<4;i++){
			cin>>data[i];
			ans[i]=0;
			state[i]=0;
		}
		makePattern(state,data,0,4,num);

	//	cout<<min1<<endl;
		for(int i=0;i<4;i++){
			if(ans[i]==0)continue;
			cout<<ten[i]<<" "<<ans[i]<<endl;
		}
		unko++;
	}

	return 0;
}

Measured memory_bytes: 1160
N = input()
for i in xrange(N):
    ball = map(int, raw_input().split())
    a = [0]
    b = [0]
    for x in ball:
        if a[-1] < x:
            a.append(x)
        elif b[-1] < x:
            b.append(x)
        else:
            print "NO"
            break
    else:
        print "YES"

Measured memory_bytes: 6436
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    a,b,c = A[i],B[i],C[i]
    L = len(set([a,b,c]))
    ans += L-1

print(ans)


Measured memory_bytes: 39148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
ll const MOD=1e9+7;
 
int main(){
  int N;cin>>N;
  vi C;
  for (int i=0;i<N;++i){
    int c;cin>>c;C.push_back(c);
  }
 
  ll dp[200010];
  ll c_cum[200010];
  memset(c_cum, 0, sizeof(c_cum));
  dp[0]=1;c_cum[C[0]]=1;
  
  if(N!=1){
    for (int i=1;i<N;++i){
      if(C[i-1]!=C[i]) (c_cum[C[i]]+=dp[i-1])%=MOD;
      dp[i]=c_cum[C[i]];
    }
  }
 
  cout << dp[N-1] << endl;
  return 0;
}

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

int main()
{
    int x, k;
    cin >> x >> k;
    int r[100005];
    r[0] = 0, r[k + 1] = 1000000000;
    for(int i = 1; i <= k; i++) cin >> r[i];
    int d[100004], s[100004];
    s[0] = 0;
    for(int i = 0; i <= k; i++){
        if(i % 2) d[i] = r[i + 1] - r[i];
        else d[i] = r[i] - r[i + 1];
        s[i + 1] = s[i] + d[i];
    }
    int l[100004], u[100004], la[100004], ua[100004];
    l[0] = la[0] = 0, u[0] = ua[0] = x;
    for(int i = 1; i <= k; i++){
        if(i % 2){
            if(la[i - 1] + d[i - 1] < 0){
                l[i] = l[i - 1] + abs(la[i - 1] + d[i - 1]);
                la[i] = 0;
            }
            else{
                l[i] = l[i - 1];
                la[i] = la[i - 1] + d[i - 1];
            }
            u[i] = u[i - 1];
            ua[i] = max(0, ua[i - 1] + d[i - 1]);
        }
        else{
            if(ua[i - 1] + d[i - 1] > x){
                u[i] = u[i - 1] - (ua[i - 1] + d[i - 1] - x);
                ua[i] = x;
            }
            else{
                u[i] = u[i - 1];
                ua[i] = ua[i - 1] + d[i - 1];
            }
            l[i] = l[i - 1];
            la[i] = min(x, la[i - 1] + d[i - 1]);
        }
    }
    int q;
    cin >> q;
    while(q--){
        int t, a;
        cin >> t >> a;
        int i = upper_bound(r, r + k + 2, t) - r - 1;
        int ans = a + s[i];
        if(a < l[i]) ans = la[i];
        if(a > u[i]) ans = ua[i];
        if(i % 2) ans = min(x, ans + t - r[i]);
        else ans = max(0, ans - (t - r[i]));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
//Binary Indexed Tree
template<class T>
struct BIT{
    int n; //length of array
    vector<T> d; //each content of BIT node
    BIT(int n=0):n(n), d(n+1){} //d is initialized by 0.
    void add(int i, T x=1){ //add x to index i
        for(i++; i<=n; i+=i&-i){
            d[i] += x;
        }
    }
    T sum(int i){ //calculate the sum of index 0 - i.
        T ans=0;
        for(i++; i; i-=i&-i){
            ans+=d[i];
        }
        return ans;
    }
};
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]--;
    map<int,int> mp;
    rep(i,n) mp[p[i]] = i; //num2idx
    BIT<int> bit(n);
    int ans = 0;
    rep(i,n){
        int s = bit.sum(mp[i]);
        if(s==0) ans++;
        //cout << mp[i] << " " << s << endl;
        bit.add(mp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

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

        int N = sc.nextInt();
        int Z = sc.nextInt();
        int W = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a, Z, W));

        sc.close();
    }

    static int solve(int[] a, int Z, int W) {
        int N = a.length;

        int[] xScores = new int[N];
        int[] yScores = new int[N];
        for (int i = N - 1; i >= 0; --i) {
            xScores[i] = Integer.MIN_VALUE;
            for (int j = i; j < N; ++j) {
                int score;
                if (j == N - 1) {
                    score = Math.abs(a[N - 1] - ((i == 0) ? W : a[i - 1]));
                } else {
                    score = yScores[j + 1];
                }

                xScores[i] = Math.max(xScores[i], score);
            }

            yScores[i] = Integer.MAX_VALUE;
            for (int j = i; j < N; ++j) {
                int score;
                if (j == N - 1) {
                    score = Math.abs(a[N - 1] - ((i == 0) ? Z : a[i - 1]));
                } else {
                    score = xScores[j + 1];
                }

                yScores[i] = Math.min(yScores[i], score);
            }
        }

        return xScores[0];
    }
}

Measured memory_bytes: 27724
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n,k;cin>>n>>k;
    ll arr[n+1];
    arr[0]=0;
    repn(i,n)cin>>arr[i+1];
    ll dp[n+1]={0};
    // memset(dp,INT_MAX,sizeof(dp));
    repn(i,n+1)dp[i]=INT_MAX;
    // cout<<dp[2]<<endl;
    dp[0]=INT_MAX;
    dp[1]=0;
    rep(i,2,n){
        rep(j,1,min(i-1,k)){
            // cout<<i<<" "<<j<<" "<<dp[i]<<" "<<dp[i-j]<<" "<<abs(arr[i]-arr[i-j])<<endl;
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
            
        }
    }
    // repn(i,n)cout<<dp[i]<<" ";
    // cout<<endl;
    cout<<dp[n];
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define trace1(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 trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main(){
	FAST_IO;
    int n; 
    cin >> n; 
    int h[n]; 
    int dp[n]; 
    for(int i=0; i < n; i++){
        cin >> h[i];
    }
    dp[0] = 0; 
    if(n >=2){
        dp[1] = abs(h[1] - h[0]);
    }
    for(int i=2; i < n; i++){
        dp[i] = min((dp[i-1] + abs(h[i] - h[i-1])), (dp[i-2] + abs(h[i] - h[i-2])));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
const ll inf = 1e18;
const int nax = 2e6 + 7;

using namespace std;
string s;
//int fl1 , fl2;
int main(int argc,char ** argv){
	dhoom;
	int a , b;
	cin >> a >> b;
	for(int i = 0 ; i <= 100000 ; i++)
	{
		int x = i * 0.08;
		int y = i * 0.10;
		//cout << x << " " << y << endl;
		if(x == a && y == b){
			cout << i << endl;
			return 0;
		}
		
	}
	cout << -1 << endl;
	return 0;
}


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

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  auto calc=[](string s,Int f){
    Int n=s.size();
    Int res=0,x=0;
    vector<Int> J(n+1,0);
    vector<Int> O(n+1,0);
    vector<Int> I(n+1,0);
    for(Int i=0;i<n;i++){
      J[i+1]=J[i]+(s[i]=='J');
      O[i+1]=O[i]+(s[i]=='O');
      I[i+1]=I[i]+(s[i]=='I');
    }
    for(Int i=0;i<n;i++){
      if(s[i]=='O') res+=J[i]*(I[n]-I[i]);
      chmax(x,J[i]*(I[n]-I[i]));
    }
    return res+f*x;
  };
  Int n;
  string s;
  cin>>n>>s;
  cout<<max({calc(s,1),calc("J"+s,0),calc(s+"I",0)})<<endl;
  return 0;
}



Measured memory_bytes: 5620
s=input()
l,r=0,len(s)-1
cnt=0
while l<r:
    if s[l]==s[r]:
        l +=1
        r -=1
    elif s[l]=="x":
        l +=1
        cnt +=1
    elif s[r]=="x":
        r -=1
        cnt +=1
    else:print(-1);exit()
print(cnt)

Measured memory_bytes: 39664
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int n;

void koch(int d, double ax, double ay, double bx, double by){
	if(d == 0)
		cout << fixed << setprecision(4) << ax << ' ' << ay << endl;
	if(d == n){
		cout << bx << ' ' << by << endl;
		return;
	}
	double sx = (2*ax+bx)/3, sy = (2*ay+by)/3, tx = (ax+2*bx)/3, ty = (ay+2*by)/3;
	double ux = (tx-sx)*cos(M_PI*60/180)-(ty-sy)*sin(M_PI*60/180)+sx;
	double uy = (tx-sx)*sin(M_PI*60/180)+(ty-sy)*cos(M_PI*60/180)+sy;
	koch(d+1, ax, ay, sx, sy);
	koch(d+1, sx, sy, ux, uy);
	koch(d+1, ux, uy, tx, ty);
	koch(d+1, tx, ty, bx, by);
}

int main(){
	cin >> n;
	koch(0, 0, 0, 100, 0);
}


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

int main() {
	int n;
	cin >> n;
	vector<int> vec1(n);
	for (int i = 0; i < n; i++) {
		cin >> vec1.at(i);
	}
	int q;
	cin >> q;

	vector<int> vec2(q);
	for (int i = 0; i < q; i++) {
		cin >> vec2.at(i);
	}

	int result = 0;

	for (int j = 0; j < q; j++) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (vec1.at(i) == vec2.at(j)) {
				sum++;
			}
		}
		if (sum >= 1) {
			result++;
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 3100
S = raw_input()
N = len(S)
ans = [0 for i in range(N)]

stock = 0
for i in range(0, N):
    s = S[i]
    if s == 'R':
        stock += 1
    elif 0 < stock:
        ans[i-1] += stock / 2 + (stock % 2)
        ans[i] += stock / 2
        stock = 0

stock = 0
for i in range(0, N):
    j = N - 1 - i
    s = S[j]
    if s == 'L':
        stock += 1
    elif 0 < stock:
        ans[j+1] += stock / 2 + (stock % 2)
        ans[j] += stock / 2
        stock = 0

print ' '.join(map(str, ans))

Measured memory_bytes: 7036
let n, k = Scanf.scanf "%d %d" (fun n k -> n, k)
let v = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i))

let lm = min k n

let rec f l ans =
  if l = lm + 1 then ans
  else
    let rm = lm - l in
    let rec g r ans =
      if r = rm + 1 then ans
      else
        let rec h i j (s, q) =
          if i = j then s, q
          else
            let x = v.(i) in
            if x < 0 then
              h (i + 1) j (x + s, x :: q)
            else
              h (i + 1) j (x + s, q) in
        let s, q = h (n - r) n (h 0 l (0, [])) in
        let rec h i s = function
            e :: q ->
              if i = k - l - r then s
              else h (i + 1) (s - e) q
          | _ -> s in
        let s = h 0 s (List.sort (fun i j -> i - j) q) in
        g (r + 1) (max s ans) in
    f (l + 1) (g 0 ans)

let () = Printf.printf "%d\n"  (f 0 0)


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

int main(){
	int n, m;
	while(cin >> n >> m, n+m){
		string s[] = {"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};
		int v[20] = {0}; v[0] = 1;
		for(int i=0; i< m; i++){
			for(int j=19; 0 <= j; j--){
				v[j] *= n;
				v[j+1] += v[j]/10000;
				v[j] = v[j]%10000;
			}
		}
		for(int i = 19; 0 <= i; i--) if(v[i] != 0) cout << v[i] << s[i];
		cout << endl;
	}
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
    int n, m, sum=0;
    scanf("%d %d", &n, &m);
    
    int x[m];
    for(int i = 0; i < m; i++){
        scanf("%d", &x[i]);
    }
    if(n >= m){
        printf("%d", 0);
        return 0;
    }

    qsort(x, m, sizeof(int), asc);

    int dif[m-1];
    for(int i = 0; i < m-1; i++){
        dif[i] = x[i+1] - x[i];
    }
               
    qsort(dif, m-1, sizeof(int), asc);

    for(int i = 0; i < m-n; i++){
        sum += dif[i];
    }
               
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 1268
N, W = map(int, input().split())
wvs = [tuple(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(W+1)] for i in range(N)]

for i, wv in enumerate(wvs):
    for j in range(W+1):
        if i == 0:
            if wv[0] < j+1:
                dp[0][j] = wv[1]
        elif wv[0] < j+1:
            dp[i][j] = max(dp[i-1][j-wv[0]] + wv[1], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[-1][-1])

Measured memory_bytes: 171912
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long int LLI;
int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	int tmp, right = 0, left = 0, sum = 0;
	for(int i = 0; i < m; i++)
	{
		cin >> tmp;
		if( tmp == x )
			sum++;
		else if( tmp < x )
			left++;
		else
			right++;
	}
	if( left < right )
		cout << sum + left;
	else cout << sum + right;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main(){
	string s;
	cin>>s;
	int maks=0,count=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'){
			count++;
		}
		else{
			maks=max(count,maks);
			count=0;
		}
	}
	maks=max(count,maks);
	cout<<maks;
}



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


def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


ans = 0
for d in divisors(N):
    if d == 1:
        continue
    m = d - 1
    if N // m == N % m:
        ans += m
print(ans)

Measured memory_bytes: 39024
// Problem Code: abc174_d

#include <iostream>
#include <string>

using namespace std;

int alter_altar(int N, string& c) {
	int cnt, l, r;
	cnt = l = 0;
	r = c.length() - 1;

	while (l < r) {
		if (c[l] != 'W')
			l++;
		else if (c[r] != 'R')
			r--;
		else {
			cnt++;
			swap(c[l++], c[r--]);
		}
	}

	return cnt;
}

int main() {
	int N;
	string c;
	cin >> N >> c;
	cout << alter_altar(N, c);
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define LL long long
#define int LL
#define P pair<int, int>
#define Fengexian cout<<"WZY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl
const LL N = 2e5 + 10;
const LL mod = 998244353;
const LL inf = 0x3f3f3f3f;
const double eps = 1e-9;
using namespace std;
template <typename tp>
inline void read(tp &x)
{
	x = 0; char c = getchar(); bool f = 0;
	for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar()) ;
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()) ;
	if (f) x = -x;
}
LL ans;
int n,a[N];
int tree[N<<2];
void change(int now,int l,int r,int q,int k)
{
	if(l==r) { tree[now] = k; return;}
	int mid=(l+r)>>1;
	if(q<=mid) change(now<<1,l,mid,q,k);
	else change(now<<1|1,mid+1,r,q,k);
	tree[now]=max(tree[now<<1],tree[now<<1|1]);
} 
int query(int now,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr) return tree[now];
	if(ql>r||qr<l) return 0;
	int mid=(l+r)>>1;
	return max(query(now<<1,l,mid,ql,qr),query(now<<1|1,mid+1,r,ql,qr));
}
void clear(int now,int l,int r)
{
	tree[now]=n+1;
	if(l==r) return ;
	int mid=(l+r)>>1;
	clear(now<<1,l,mid);
	clear(now<<1|1,mid+1,r);
}
void change2(int now,int l,int r,int q,int k)
{
	if(l==r) { tree[now] = k; return;}
	int mid=(l+r)>>1;
	if(q<=mid) change2(now<<1,l,mid,q,k);
	else change2(now<<1|1,mid+1,r,q,k);
	tree[now]=min(tree[now<<1],tree[now<<1|1]);
} 
int query2(int now,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr) return tree[now];
	if(ql>r||qr<l) return n+1;
	int mid=(l+r)>>1;
	return min(query2(now<<1,l,mid,ql,qr),query2(now<<1|1,mid+1,r,ql,qr));
}
int l[N],r[N];
signed main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++)
	{
		l[i]=query(1,1,n,1,a[i]);
		change(1,1,n,a[i],i);
	}
	clear(1,1,n);
	for(int i=n;i>=1;i--)
	{
		r[i]=query2(1,1,n,1,a[i]);
		change2(1,1,n,a[i],i);
	}
	for(int i=1;i<=n;i++)
		ans+=a[i]*(i-l[i])*(r[i]-i);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 11136
import java.lang.IllegalArgumentException
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val length = sc.nextInt()
    val s = sc.next()

    var x = 0
    var answer = x

    s.forEach {
        answer = Math.max(x, answer)
        when (it) {
            'I' -> x++
            'D' -> x--
            else -> throw IllegalArgumentException("wrong args")
        }
        answer = Math.max(x, answer)
    }
    println(answer)
}

Measured memory_bytes: 29580
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>
#define _USE_MATH_DEFINES
#define ll long long int
using namespace std;
//mp.reserve(1024);
//mp.max_load_factor(0.25);
bool sortit(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return (a.first -a.second > b.first-b.second);
}

int main()
{
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    // freopen("mr_x_input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
	ll n;
	cin>>n;
	ll ans = 0;
	for(ll i=0,temp;i<n;i++){
		cin>>temp;
		ans += (temp&1&&((i+1)&1));
	}
	cout<<ans<<endl;

  	return 0;
}


Measured memory_bytes: 3564
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    print(first_distance[0])
else:
    element = gcd(first_distance[0], first_distance[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,first_distance[i])
        print(element)

Measured memory_bytes: 18448
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int h, w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    vector<vector<int>> cnt(h, vector<int>(w));
    rep(i, h){
        string _s; cin >> _s;
        rep(j, w) s[i][j] = _s[j];
    }

    rep(i, h)rep(j, w){
        rep(k, 8){
            int nx = dx2[k];
            int ny = dy2[k];

            if(0 <= j + nx && j + nx < w && 0 <= i + ny && i + ny < h)
                if(s[i+ny][j+nx] == '#') ++cnt[i][j];
        }
    }

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '.') cout << cnt[i][j];
            else cout << s[i][j];
        }
        cout << endl;
    }

return 0;
}

Measured memory_bytes: 3680
#include <stdio.h>

int main(void) {
	int N, K, i;
	long long int temp = 1, ans;
	
	scanf("%d %d", &N, &K);
	if(N == 1){
		printf("%d", K);
	}else{
		for(i=0; i<N-1;i++){
			temp *= K-1;
		}
		ans = K * temp;
		printf("%lld", ans);
	}	
	return 0;
}

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

int main(){
  // 入力
  int A, B;
  cin >> A >> B;
  
  int counter = 0;
  
  for(int i = A; i <= B; i++){
    if(i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10){
      counter++;
      //cout << i << endl;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int i,j,n,num[201],cnt=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d",&num[i]);
	}
	while(1) {
		for(j=0;j<n;j++)
			if(num[j]%2==1)
				goto end;
		cnt++;
		for(j=0;j<n;j++) {
			num[j]/=2;
			if(num[j]%2==1)
				goto end;
		}
	}
	end:
	printf("%d",cnt);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {

	if sc.Scan() {
		tmp := strings.Split(sc.Text(), " ")
		W, _ := strconv.Atoi(tmp[0])
		H, _ := strconv.Atoi(tmp[1])
		x, _ := strconv.Atoi(tmp[2])
		y, _ := strconv.Atoi(tmp[3])
		r, _ := strconv.Atoi(tmp[4])

		var isOver bool

		if x+r > W || x-r < 0 {
			isOver = true
		} else if y+r > H || y-r < 0 {
			isOver = true
		}

		if isOver {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}

	}
}



Measured memory_bytes: 1116
nmax = 10**6
mod = 10**9+7

fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod

ncr_pre()
n = int(input())
A = list(map(int,input().split()))
co = [0]*(n+2)
id2 = -1
for i in  range(n+1):
    a = A[i]
    co[a]+=1
    if co[a]==2:
        id2 = i
        break
id1 = A.index(a)
d = n-id2 +id1

for k in range(1,n+2):
    ans = ncr(n+1,k)
    if k-1<=d:
        ans -= ncr(d,k-1)
    print(ans%mod)


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

void printYes(){
	cout<<"Yay!"<<endl;
}
void printNo(){
	cout<<":("<<endl;
}

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	lli sum=0;
	REP(i,0,n){
		cin>>a[i];
		sum+=a[i];
	}
	lli left=0;
	lli ans=INF;
	REP(i,0,n-1){
		left+=a[i];
		lli right = sum-left;
		ans = min(ans,abs(right-left));
	}

	cout<<ans<<endl;





	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M, K := ReadInt(), ReadInt(), ReadInt()
	for a := 0; a <= M; a++ {
		for b := 0; b <= N; b++ {
			x := N*a + M*b - 2*a*b
			if x == K {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <stdio.h>
#include <stdlib.h>

typedef struct Node* NodePointer;

struct Node {
  NodePointer next[5];
};

int conv(char c) {
  switch(c) {
  case '\0':return 0;
  case 'A': return 1;
  case 'C': return 2;
  case 'G': return 3;
  case 'T': return 4;
  }
  return -1;
}

NodePointer makeNode() {
  int i;
  NodePointer p;
  p = malloc(sizeof(struct Node));
  for(i = 0; i < 5; ++i) {
    p->next[i] = NULL;
  }
  return p;
}
    
void insert(NodePointer p, char* s) {
  int a;
  a = conv(*s);
  if(p->next[a] == NULL) p->next[a] = makeNode();
  if(a != 0) insert(p->next[a], s+1);
}

int find(NodePointer p, char* s) {
  int a;
  a = conv(*s);
  if(p->next[a] == NULL) return 0;
  if(a == 0) return 1;
  return find(p->next[a], s+1);
}

int main() {
  int n;
  char s[100], t[100];
  NodePointer head;

  head = makeNode();
  scanf("%d", &n);
  while(n--) {
    scanf("%s %s", s, t);
    if(s[0] == 'i') {
      insert(head,t);
    } else {
      if(find(head,t))
        printf("yes\n");
      else
        printf("no\n");
    }
  }
  return 0;
}





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

int main(){
    int list[3];
    cin >> list[0] >> list[1] >> list[2];
    sort(list, list+3);
    int ab = list[2] - list[1], bc = list[2] - list[0];
    if(ab%2 == 0 && bc%2 == 0){
        cout << ab/2+bc/2 << endl;
    }else if(ab%2 == 1 && bc%2 == 1){
        cout << ab/2 + bc/2 + 1 << endl;
    }else{
        cout << ab/2 + bc/2 + 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d", &A);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    if(A % 111 == 0){
    ans = A / 111 * 111; 
    }else{
    ans = A / 111 * 111 + 111;
    }
    
    if(1 == 0){
      /* 真の場合の処理 */
    }else{
      /* 偽の場合の処理 */
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    printf("%d", ans); // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    string s;
    cin>>s;
    map<char,int>m;
    for(int i=0;i<s.size();++i){
    	if(m[s[i]]>0){
    		cout<<"no";
    		return 0;
    	}
    	++m[s[i]];
    }
    cout<<"yes";
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
ll gcd(double x, double y)
{
	ll m = (int)floor(x);
	ll n = (int)floor(y);
	ll r;

	do {
		r = m % n;
		m = n;
		n = r;
	} while (r != 0);

	return m;
}
int main(){
    int k;
    ll sum=0,ab=0;
    cin>>k;
    REP(i,k){
        REP(j,k){
            REP(l,k){
                ab=gcd(i+1,j+1);
                sum+=gcd(l+1,ab);
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5])
    cout<<"Yes";
    else
    cout<<"No";
    
    
    
} 

Measured memory_bytes: 256
def primeFactorize(n):
    res = []
    tmp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            res.append([i, cnt])
    if tmp != 1:
        res.append([tmp, 1])
    if len(res) == 0:
        res.append([n, 1])
    return res


def resolve():
    N, P = [int(i) for i in input().split()]
    p = primeFactorize(P)
    ans = 1
    for i, r in p:
        ans *= (i**(r // N))
    print(ans)


resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i, n) for (int i=0;i<(n);i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){ 
  int64_t N;
  cin >> N;
  int64_t t = 1;
  int64_t n = 1;
  int64_t e = 1;
  rep(i,N){
    t = t*10;
    t = t%MOD;

    n = n*9;
    n = n%MOD;

    e = e*8;
    e = e%MOD;

  }
  n = 2*n;
  n = n % MOD;
  t = t + e;
  t = t % MOD;
  t = t - n;
  t = t % MOD;
  if(t < 0) t += MOD;
  cout << t << endl;
}




Measured memory_bytes: 3584
#include <iostream>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
int main()
{
  long long N, Y;
  cin >> N >> Y;
  int x = -1, y = -1, z = -1;
  #pragma unroll
  for (int a = 0; a <= N; ++a)
  {
    for (int b = 0; b <= N - a; ++b)
    {
      for (int c = 0; c <= N - a - b; c++)
      {
          long long sum = 10000 * a + 5000 * b + 1000 * c;
        if ((a+b+c)==N&&sum == Y)
          x = a, y = b, z = c;
      }
    }
  }
  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int function(int n){
    if(n%2==0){
        //n is odd
        return n/2;
    }else{
        return 3 * n+1;

    }
}
int main(){
    int s;cin>>s;
    vector<int> a;
    a.push_back(s);
    for(int i = 0; i < INF; i++)
    {
        int a_new = function(a[i]);
        //cout<<a_new<<endl;
        if(count(a.begin(),a.end(),a_new)>0){
            cout<<i+2<<endl;
            return 0;
        }
        a.push_back(a_new);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[N];
    REP(i, N){
        cin >> A[i];
    }

    bool flag = true;
    REP(i, N){
        if (A[i]%2 == 0){
            if(A[i]%3 != 0 & A[i]%5 != 0){
                flag = false;
            }
        }
    }
    if (flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>

int N;
int X[200010], Y[200010];

signed main()
{
    cin >> N;
    rep(i, N)
    {
        int x, y;
        cin >> x >> y;
        X[i] = x + y;
        Y[i] = x - y;
    }

    sort(X, X + N);
    sort(Y, Y + N);

    cout << max(X[N - 1] - X[0], Y[N - 1] - Y[0]) << endl;

    return 0;
}


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

int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S==U){
    cout << A-1 << " " << B << endl;
  }else{
    cout << A << " " << B-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256