akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())

jdg = True

for h in range(math.ceil(N/4), 3501):
    for n in range(h, 3501):
        num = 4*h*n - N*h - N*n
        if num > 0:
            if (N * n * h) % num == 0:
                jdg = False
                break
    if not jdg: break

w = N*h*n//(num)
print(*[h, n, w])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,N;
  cin>>X>>N;
  vector<int>v;
  v.push_back(0);
  for(int i=1;i<=101;i++){
    v.push_back(i);
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    v.erase(std::remove(v.begin(), v.end(), x), v.end());
  }
  int MIN=0;
  for(int i=0;i<v.size();i++){
    if(abs(v[i]-X)<=abs(X-MIN))MIN=v[i];
  }
  cout<<MIN<<endl;





}

Measured memory_bytes: 3636
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X, Y = map(int, input().split())

def solve(X, Y):
    tmp = Y - 2 * X
    if tmp % 2:
        return False
    b = (Y - 2 * X) // 2

    tmp = 4 * X - Y
    if tmp % 2:
        return False
    a = (4 * X - Y) // 2

    if a >= 0 and b >= 0:
        return True
    else:
        return False

if solve(X, Y):
    print("Yes")
else:
    print("No")





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

int n, m, w[101], v[101], dp[101][101][301], ans;

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%d%d", w + i, v + i);
	for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
			for(int k = 0; k < w[i] - w[1]; k++) dp[i][j][k] = dp[i - 1][j][k];
			for(int k = w[i] - w[1]; k <= 3 * n; k++){
                dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - w[i] + w[1]] + v[i]);
			}
        }
	}
	for(int i = 1; i <= n; i++){
		if(m - i * w[1] < 0) break;
		for(int j = 0; j <= min(3 * n, m - i * w[1]); j++){
			ans = max(ans, dp[n][i][j]);
		}
	}
	printf("%d\n", ans);
}


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

int main() {
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)
{
cin>>a[i];
}
ll ans=0;
for(ll i=0;i<n;i++)
{  ll count=0;
  while(i+1<n && a[i+1]<=a[i])
  {
    count++;
      i++;
  }
  ans=max(ans,count);

}
cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
  
using namespace std;

typedef long long ll;

class Point {
public:
  ll x, y;
  
  Point () {}
  Point ( ll x = 0, ll y = 0 ) : x(x), y(y) {}
  
  Point operator - ( const Point &p ) const { return Point(x - p.x, y - p.y); }
};
  
typedef Point Vector;
  
typedef vector<Point> Polygon;
  
ll dot( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; }
ll cross( Vector a, Vector b ) { return a.x*b.y - a.y*b.x; }

enum { IN, ONSEG, OUT };
#define curr(G, i) (G[i])
#define next(G, i) (G[(i+1)%n])

int
pointInPolygon(const Polygon &G, const Point &p) {
  
  int n = G.size();
  bool in = false;
  
  for(int i=0; i<n; i++) {
    Vector V1 = curr(G, i) - p, V2 = next(G, i) - p;
    
    if( V1.y > V2.y ) swap(V1, V2);
    if( V1.y <= 0 && 0 < V2.y && cross(V1, V2) > 0 ) in = !in;
    if( cross(V1, V2) == 0 && dot(V1, V2) <= 0 ) return ONSEG;
  }
  return in ? IN : OUT;
}
  
int
main() {
  int n, q;
  ll x, y;
    
  Polygon G;
  cin >> n;
    
  for(int i=0; i<n; i++) {
    cin >> x >> y;
    G.push_back(Point(x, y));
  }
    
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> x >> y;
    int res = pointInPolygon(G, Point(x, y));
    if(res == IN)    cout << 2 << endl;
    if(res == ONSEG) cout << 1 << endl;
    if(res == OUT)   cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
int n, m, ac=0, wa=0, wap[nax];
bool acp[nax];

int main(){
	IOS
	cin >> n >> m;
	while(m--){
		int a;
		string b;
		cin >> a >> b;
		if(acp[a]){
			continue;
		}
		if(b=="AC"){
			ac++;
			wa+=wap[a];
			acp[a]=1;
		}
		else{
			wap[a]++;
		}
	}
	cout << ac << ' ' << wa << '\n';
}


Measured memory_bytes: 4096
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


s = input()
stack = list()
for c in s:
    if c == 'B':
        if len(stack) > 0:
            stack.pop()
    else:
        stack.append(c)
print(''.join(stack))


Measured memory_bytes: 38256
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
    

l_2d = factorization(N)

cnt = 0
for l in l_2d:
    p = l[0]
    e = l[1]
    if p == 1:
        continue
    for i in range(1, 10 ** 7):
        if e < i:
            break
        cnt += 1
        e -= i
print(cnt)

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if (s.length() > k)
    {
        cout << s.substr(0, k) + "..." << endl;
    }
    else
    {
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>

using namespace std;
 
int A,B,C,D;
int main() {
  	cin >> A >> B >> C >> D;
	while(1){
		C -= B;
		if(C <=0){
			cout << "Yes\n";
			return 0;
		}
		A -= D;
		if(A <=0){
			cout << "No\n";
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll cnt[200001];
int main()
{
	int n;
	cin>>n;
	for(int i=0; i<n-1; i++)
	{
		int a;
		cin>>a;
		cnt[a]++;
	}
	for(int i=1; i<=n; i++)
	{
		cout<<cnt[i]<<endl;
	}


}

Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(-a + b <= 0){
			System.out.println("delicious\n");
		} else if (-a + b <= x) {	
		System.out.println("safe\n");
		} else {
			System.out.println("dangerous\n");
		}
		}
	}


Measured memory_bytes: 23636
N = 50
K = int(input())
x = K%N
ls = [0]
for i in range(N-1):
  ls += [ls[-1]+1]
for i in range(x):
  ls[i] += N
  for j in range(N):
    if j!=i:
      ls[j] -= 1
ans = [(K-x)//N+c for c in ls]
print(N)
print(*ans)


Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();

		Scanner scanner = new Scanner(System.in);
		int len = Integer.parseInt(scanner.nextLine());
		for (int i = 0; i < len; i++) {
			int n = scanner.nextInt();
			if (map.get(n) == null) {
				map.put(n, 1);
			} else {
				map.put(n, map.get(n) + 1);
			}
		}

		int ans = 0;
		java.util.List<Integer> list =map.keySet().stream()
				.filter(key -> map.get(key) - key != 0)
				.collect(Collectors.toList());

		for (Integer i : list) {
			int n = map.get(i);
			if (n>i) {
				ans+=n-i;
			}else{
				ans+=n;
			}
		}

		
		System.out.println(ans);
		scanner.close();
	}

}


Measured memory_bytes: 65216
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl //[l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<endl;out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n,m;
string s,t;

map<int, int> prime_factor(int n){
    map<int, int> ret;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

signed main(){
    io();

    in(n,m);
    in(s);
    in(t);
    if(s[0]!=t[0]){
        out(-1);
        return 0;
    }
    map<int,int> np=prime_factor(n);
    map<int,int> mp=prime_factor(m);
    map<int,int> lcm;
    for(auto e:np){
        lcm[e.fs]=max(lcm[e.fs],e.sc);
    }
    for(auto e:mp){
        lcm[e.fs]=max(lcm[e.fs],e.sc);
    }
    int res=1;
    for(auto e:lcm){
        res*=pow(e.fs,e.sc);
        //show(e.fs,e.sc);
    }
    map<int,char> table;
    rep(i,n){
        table[i*res/n+1]=s[i];
    }
    rep(i,m){
        if(!table[i*res/m+1]) continue;
        if(table[i*res/m+1]!=t[i]){
            out(-1);
            return 0;
        }

    }/*
    for(auto e:table){
        show(e.fs,e.sc);
    }*/

    out(res);

    return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    int k=0;
    while(true){
        if((double)sum/(double)(4*m)>(double)a[k])break;
        k++;
        if(k==m)break;
    }
    if(k==m)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = []
c = 0
O = "ossible"
P = "P" + O
I = "Imp" + O

for i in range(H):
    a = input()
    A.append(a)
    c += a.count("#")

if H+W-1==c:
    print(P)
else:
    print(I)


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

using namespace std;
typedef long long ll;

int main() {
		int N, M;
		int P[100000], Y[100000];
		vector<int> yd[100001];

		cin >> N >> M;
		for ( int i = 0; i < M; i++ ) {
				cin >> P[i] >> Y[i];
				yd[P[i]].push_back(Y[i]);
		}

		for ( int i = 0; i < N; i++ ) {
				sort(yd[i+1].begin(), yd[i+1].end());
		}

		for ( int i = 0; i < M; i++ ) {
				printf("%012lld\n", ll(P[i])*1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
		}
		
		return 0;
}


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

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

    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    int count = 0;
    for(int i=0; i<n; i++){
        //cout << i << endl;
        if(p[i] == i+1){
            count += 1;
            i += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var n = Console.ReadLine();
        if (n == "1") {
            Console.WriteLine("Hello World");
        } else {
            var a = Int16.Parse(Console.ReadLine());
            var b = Int16.Parse(Console.ReadLine());
            Console.WriteLine((a + b).ToString());
        }
    }
}


Measured memory_bytes: 11092
fun main(arr:Array<String>) {
    val card = (0..2).map { readLine()!!.split(" ").map { it.toInt() } }
    val check = (0..2).map { (0..2).map { false }.toMutableList() }
    val logCount = readLine()!!.toInt()
    val log = (1..logCount).map { readLine()!!.toInt() }
    log.forEach {num ->
        (0..2).forEach{rowIndex ->
            (0..2).forEach { colIndex ->
                if(card[rowIndex][colIndex] == num) {
                    check[rowIndex][colIndex] = true
                }
            }
        }
    }
    var isBingo = (0..2).any { idx->
        check[idx].all { it }
    }
    isBingo = isBingo || (0..2).any { idx ->
        check.map { it[idx] }.all { it }
    }
    isBingo = isBingo || (0..2).all { check[it][it] }
    isBingo = isBingo || (0..2).all { check[it][2-it] }
    println(if(isBingo) "Yes" else "No")
}

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

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
    int A,B,C,X,Y;
    cin  >> A >> B >> C >> X >> Y;
    int D = 2*C;
    int Z = max(X,Y);
    int money = A*X+B*Y;
    rep(i,Z+1){
        if(i <= min(X,Y) ){
        int sum = A*(X-i)+B*(Y-i)+D*i;
        money = min(sum,money);
        }
        else if(i <= X && i > Y) {
        int sum = A*(X-i)+D*i;
        money = min(sum,money);
        }
        else {
        int sum = B*(Y-i)+D*i;
        money = min(sum,money);
        }
    }
    cout << money <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> X(N), Y(N);
	for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
	int ans = N;
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) if(i != j) {
		cat p = X[j]-X[i], q = Y[j]-Y[i];
		cat l = p*p+q*q;
		vector< pair<cat, cat> > V(N);
		for(int k = 0; k < N; k++) V[k] = {X[k]*q-Y[k]*p, X[k]*p+Y[k]*q};
		sort(begin(V), end(V));
		int cur = 0, pos = 0;
		for(int k = 0; k < N; k++) {
			while(pos < k && V[pos].ff != V[k].ff) pos++;
			while(pos < k && V[pos].ss < V[k].ss-l) pos++;
			if(V[pos].ff != V[k].ff || V[pos].ss != V[k].ss-l) cur++;
		}
		ans = min(ans, cur);
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


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

int main()
{
  string s, t;
  int ans = 0;

  cin >> s >> t;

  for(int i=0; i < s.size(); i++)
  { 
    if(s[i] != t[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
ll n,a[100005][5];
ll dp[100005][4];

ll fun(int pos, int p)
{
    if (pos==n) return 0;
    if (dp[pos][p]!=-1) return dp[pos][p];

    ll ret1=0;
    ll ret2=0;
    if (p==0)
    {
        ret1=a[pos][1]+fun(pos+1,1);
        ret2=a[pos][2]+fun(pos+1,2);

    }
    else if (p==1)
    {
        ret1=a[pos][0]+fun(pos+1,0);
        ret2=a[pos][2]+fun(pos+1,2);

    }

    else
    {
        ret1=a[pos][1]+fun(pos+1,1);
        ret2=a[pos][0]+fun(pos+1,0);

    }

    return dp[pos][p]=max(ret1,ret2);
}

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

    cin>>n;
    memset(dp,-1,sizeof(dp));
    for (int i=0;i<n;i++)
    {
        cin>>a[i][0];
        cin>>a[i][1];
        cin>>a[i][2];
    }

    ll ans=fun(0,0);
     ans=fun(0,1);
     ans=fun(0,2);
    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]))<<endl;


    return 0;
}


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

int main(){
int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b){
  cout << c <<endl;
  }else if(b==c){
  cout << a << endl;
  }else{
  cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int i, j, n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    for(i = 0; i < n; i++){
       cin >> c[i];
      for(j = 0; j < m; j++){
         cin >> a[i][j];
      }
    }

    int cSum, mSum[m], answer = INT_MAX;
    bool flag;
    for(int bit = 0; bit < ( 1<<n ); bit++){
        vector<int> S;
        for(i = 0; i < n; i++){
            if(bit & (1<<i)) {
                S.push_back(i);
            }
        }
        cSum = 0;
        fill(mSum, mSum + m, 0);
        flag = true;
        for(i = 0; i < (int)S.size(); i++){
            cSum += c[S[i]];
            for(j = 0; j < m; j++)
                mSum[j] += a[S[i]][j];
        }
        for(j = 0; j < m; j++){
            if(mSum[j] < x)
                flag = false;
        }

        if(flag)
            answer = min(answer, cSum);
    }
    if(answer == INT_MAX)
        answer = -1;

    cout << answer << endl;
    return 0;
}

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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i< N; i++)cin >> A[i];
    ll S = A[0] + A[1], X = 0;
    for(int i = 2;i< N;i++)X ^= A[i];
    if(S - X < 0 || ((S - X) % 2)){cout << -1 << endl;}
    else {
        ll a = 0, D = (S - X) / 2;
        const int MX_BIT = 63;
        bool ok = true;
        for (int i = 0; i < MX_BIT; i++) {
            if ((D & (1ll << i)) && !(X & (1ll << i)))a += (1ll << i);
            if ((D & (1ll << i)) && (X & (1ll << i))){ok = false;break;}
        }
        if(!ok)cout << -1 << endl;
        else {
            for (int i = MX_BIT - 1; i >= 0; i--) {
                if (!(D & (1ll << i)) && (X & (1ll << i))) {
                    if (a + (1ll << i) <= A[0])a += (1ll << i);
                }
            }
            if(0 < a && a <= A[0])cout << A[0] - a << endl;
            else cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

int par[110000];
int dist[110000];
vector<vector<int>> vv;
void dfs(int from, int now)
{
  for (auto to : vv[now]) {
    if (to != from) {
      par[to] = now;
      dist[to] = dist[now] + 1;
      dfs(now, to);
    }
  }
}

int sumup(int from, int now)
{
  int ret = 0;
  for (auto to : vv[now]) {
    if (to != from) ret += sumup(now, to);
  }
  return ret + 1;
}

int main()
{
  int N;
  cin >> N;
  vv.resize(N);
  REP(i, N-1) {
    int a, b; cin >> a >> b;
    a--, b--;
    vv[a].PB(b);
    vv[b].PB(a);
  }
  dfs(0, 0);
  int now = N - 1;
  vector<int> v;
  while (now != 0) {
    v.PB(now);
    now = par[now];
  }
  v.PB(now);

  int b = 0, w = 0;
  REP(i, v.size()) {
    if (i < v.size() / 2) {
      cerr << "white " << v[i] << " :" << endl;
      for (auto to : vv[v[i]]) {
        if ((i > 0 && to == v[i - 1]) || (i < N - 1 && to == v[i + 1])) continue;
        cerr << "  " << v[i] << ' ' << to << endl;
        w += sumup(v[i], to);
      }
    } else {
      cerr << "black " << v[i] << " :" << endl;
      for (auto to : vv[v[i]]) {
        if ((i > 0 && to == v[i - 1]) || (i < N - 1 && to == v[i + 1])) continue;
        cerr << "  " << v[i] << ' ' << to << endl;
        b += sumup(v[i], to);
      }
    }
  }
  SHOWX(b); SHOWX(w);
  if (v.size() % 2 == 1) {
    if (b >= w) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
  } else {
    if (b > w) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
  }

  return 0;
}

Measured memory_bytes: 11772
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    int t1 = 0; int t2 = 0;int jishu = 0;
    for (int i = 0; i < n; i++){
        cin>>x;
        if (x%4==0) t2++;
        if (x%2==0&&x%4!=0) t1++;
    if (x%2!=0) jishu++;
    }

    if (t1!=0) jishu++;
   // cout<<jishu<<endl<<t2<<endl;
    if (jishu-t2>1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

int main()
{



        long long H, W;

        cin >> H >> W;

        if (H == 1 || W == 1) {
                cout << 1 << endl;
                return 0;
        }

        long long ki = 0;
        long long guu = 0;
        if (W % 2) {

                ki = W / 2;
                ki++;
                guu = ki - 1;

        }
        else {
                ki = W / 2;
                guu = ki;
        }


        long long ki_row = 0;
        long long guu_row = 0;
        if (H % 2) {

                ki_row = H / 2;
                ki_row++;
                guu_row = ki_row - 1;
        }
        else {
                ki_row = H / 2;
                guu_row = ki_row;
        }
        long long ans = (ki_row * ki)+ (guu_row * guu);
        cout << ans << endl;

}


Measured memory_bytes: 384
nm=input("").split(" ")
n=int(nm[0])
m=int(nm[1])
lists=[-1]*n
ss=0
if(n==1):
    tt=-1
    for i in range(m):
        sc=input("").split(" ")
        s=int(sc[0])
        c=int(sc[1])
        if(tt==-1):
            tt=c
        elif(tt==c):
            None
        else:
            ss=1
    if(ss==1):
        print(-1)
    elif(m==0):
        print(0)
    else:
        print(tt)
        

else:
    for i in range(m):
        sc=input("").split(" ")
        s=int(sc[0])
        c=int(sc[1])
        if(s==1 and c==0):
            ss=1
        elif(lists[s-1]==-1):
            lists[s-1]=c
        elif(lists[s-1]==c):
            None
        else:
            ss=1
    if(ss==1):
        
            
        print(-1)
        
    else:

        pp=""
        for i in range(n):
            if(lists[i]==-1 and i!=0):
                pp+="0"
            elif(lists[i]==-1):
                pp+="1"
            else:
                pp+=str(lists[i])
        print(int(pp))
            


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

const int maxn=2e5+10;
const int mo=1e9+7;

int n,root,Ans=1,tote=1,edge;
int fa[maxn],fw[maxn],tmp[maxn];
int fac[maxn],ifac[maxn],vis[maxn],q[maxn];
int FIR[maxn],TO[maxn*2],NEXT[maxn*2],W[maxn*2];
bool vise[maxn*2];

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

void addedge(int u,int v,int w)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	W[tote]=w;
	FIR[u]=tote;
}

void dfs1(int u,int F)
{
	if (vis[u]==1) {root=u; return;}
	vis[u]=1;
	q[++q[0]]=u;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (v==F) continue;
		if (!vise[p]) edge++,vise[p]=vise[p^1]=1;
		dfs1(v,u);
	}
}

void dfs2(int u)
{
	if (vis[u]==2) return;
	vis[u]=2;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p],w=W[p];
		if (v==fa[u]) continue;
		fa[v]=u;
		fw[v]=w;
		dfs2(v);
	}
}

namespace Tree{
	int n,fa[maxn],dp[maxn],sz[maxn];
	int tote,FIR[maxn],TO[maxn<<1],NEXT[maxn<<1];

	void addedge(int u,int v)
	{
		TO[++tote]=v;
		NEXT[tote]=FIR[u];
		FIR[u]=tote;
		fa[v]=u;
	}

	bool dfs(int u)
	{
		if (dp[u]) return 0;
		sz[u]=0;
		dp[u]=1;
		for (int p=FIR[u];p;p=NEXT[p])
		{
			int v=TO[p];
			if (!dfs(v)) return 0;
			sz[u]+=sz[v];
			dp[u]=(LL)dp[u]*dp[v]%mo;
			dp[u]=(LL)dp[u]*ifac[sz[v]]%mo;
		}
		dp[u]=(LL)dp[u]*fac[sz[u]]%mo;
		sz[u]++;
		return 1;
	}

	void solve(int &Ans)
	{
		int i,u;
		for (i=1;i<=q[0];i++)
		{
			u=q[i];
			if (!fa[u]) addedge(0,u);
		}
		for (i=1;i<=q[0];i++) u=q[i];
		if (!dfs(0)) {Ans=0; return;}
		(Ans+=dp[0])%=mo;
		for (i=1;i<=q[0];i++)
			u=q[i],FIR[u]=fa[u]=dp[u]=sz[u]=0;
		FIR[0]=fa[0]=dp[0]=sz[0]=0;
		tote=0;
	}
};

void dfs3(int u)
{
	if (vis[u]==3) return;
	vis[u]=3;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p],w=W[p];
		if (w<fw[u]) Tree::addedge(u,v);
		dfs3(v);
	}
}

void dfs4(int u)
{
	if (vis[u]==4) return;
	vis[u]=4;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p],w=W[p];
		if (w<fw[u]) Tree::addedge(u,v);
		dfs4(v);
	}
}

int main()
{
	int i,u,v;
	scanf("%d",&n);
	fac[0]=1;
	for (i=1;i<=n+n;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	ifac[n+n]=power(fac[n+n],mo-2);
	for (i=n+n;i>=1;i--)
		ifac[i-1]=(LL)ifac[i]*i%mo;
	for (i=1;i<=n+n;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,n+v,u+v);
		addedge(n+v,u,u+v);
	}
	for (i=1;i<=n+n;i++)
		if (!vis[i])
		{
			q[0]=0;
			root=0;
			edge=0;
			dfs1(i,0);
			if (!root||edge!=q[0]) {puts("0"); return 0;}
			dfs2(root);
			int Sum=0;
			dfs3(root);
			Tree::solve(Sum);
			for (u=root;;u=fa[u])
			{
				tmp[fa[u]]=fw[u];
				if (fa[u]==root) break;
			}
			for (u=root;;u=fa[u])
			{
				fw[u]=tmp[u];
				if (fa[u]==root) break;
			}
			dfs4(root);
			Tree::solve(Sum);
			Ans=(LL)Ans*Sum%mo;
			Ans=(LL)Ans*ifac[q[0]]%mo;
		}
	Ans=(LL)Ans*fac[n+n]%mo;
	printf("%d\n",Ans);
}


Measured memory_bytes: 18816
#include <cstdio>

#define MOD 1000000007
#define ll long long

int main() {
    ll n, m;
    scanf("%lld%lld", &n, &m);
    ll rez;
    if (m <= 2 * n)
        rez = m / 2;
    else {
        rez = n;
        m = m - 2 * n;
        rez = rez + m / 4;
    }
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
		    b[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
		    c[i] = sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		
		// 計算
		long result = 0;
		for(int i = 0; i < n; i++){
		    int indexA = lowerBound(a, b[i])-1;
		    int indexC = upperBound(c, b[i]);
		    result += (long)(indexA+1)*(n-indexC);
		}
		
		// 出力
		System.out.println(result);
	}

	static int upperBound(int[] array, int n){
		int index = 0;
		int l = -1;
		int r = array.length;
		while(r-l > 1){
		    int c = (r + l)/2;
		    
		    if(n < array[c]){
		        r = c;
		    }else{
		        l = c;
		    }
		}
		index = r;
		return index;
	}
	
	static int lowerBound(int[] array, int n){
		int index = 0;
		int l = -1;
		int r = array.length;
		while(r-l > 1){
		    int c = (r + l)/2;
		    
		    if(n <= array[c]){
		        r = c;
		    }else{
		        l = c;
		    }
		}
		index = r;
		return index;
	}
}



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

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl; 
  }else{
    cout << "Odd" << endl; 
  }
}

Measured memory_bytes: 3636
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

temperature = [abs((T-h*0.006)-A) for h in H]

ans = 0

for p,q in enumerate(temperature):
  if q == min(temperature):
    ans = p+1
    break
print(ans)

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

int main()
{
  int N ;
  cin>>N ;
  char W[N][11] ;
  for(int i=0;i<N;i++) cin>>W[i] ;
  
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(strcmp(W[i],W[j])==0){
        cout<<"No"<<endl ;
        return 0 ;
      }
    }
    if(W[i][strlen(W[i])-1]!= W[i+1][0]){
        cout<<"No"<<endl ;
        return 0 ;
    }
    
  }
  
  cout<<"Yes"<<endl ;
  
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void f(string s, i64 N){
  if(s.size()==N){
    cout << s << "\n";
    return;
  }
  char c_m = 'a';
  rep(i,s.size()){
    if(s.at(i)>c_m) c_m = s.at(i);
  }
  if(s!="") c_m++;
  for(char c = 'a'; c <= c_m; c++){
    s.push_back(c);
    f(s,N);
    s.pop_back();
  }
  return;
}

void Main()
{
  i64 N;
  cin >> N;
  f("",N);
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1536
import collections
N = int(input())
a = list(map(int, input().split()))
a_tmp = set(a)
if len(a_tmp) == 1:
    print(N//2)
    exit()
kisu = []
guu = []
for i in range(N):
    if i %2 ==0:
        guu.append(a[i])
    else:
        kisu.append(a[i])
kisu_c = collections.Counter(kisu)
guu_c = collections.Counter(guu)

kisu_max = kisu_c.most_common()[0][0]
guu_max = guu_c.most_common()[0][0]

if kisu_max == guu_max:
    tmp = len(a)-kisu.count(kisu_c.most_common()[0][0])-guu.count(guu_c.most_common()[1][0])
    tmp2 = len(a)-kisu.count(kisu_c.most_common()[1][0])-guu.count(guu_c.most_common()[0][0])
    if tmp < tmp2:
        print(tmp)
    else:
        print(tmp2)
    exit()

print(len(a)-kisu.count(kisu_max)-guu.count(guu_max))

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

int main() {
  long long H,W,N;
  cin >>H>>W;
  long long Sa,Sb,Sc,ans;
  ans=100000000;
 for(int i=1;i<H;i++){
   Sa=i*W;
   Sb=(H-i)*(W/2);
   Sc=(H-i)*(W-(W/2));
   ans=min(ans,abs(max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc))));
 }
   for(int i=1;i<H;i++){
   Sa=i*W;
   Sb=((H-i)/2)*W;
   Sc=(H-i-(H-i)/2)*W;
   ans=min(ans,abs(max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc))));
 }
   for(int i=1;i<W;i++){
   Sa=i*H;
   Sb=(W-i)*(H/2);
   Sc=(W-i)*(H-(H/2));
   ans=min(ans,abs(max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc))));
 }
     for(int i=1;i<W;i++){
   Sa=i*H;
   Sb=((W-i)/2)*H;
   Sc=(W-i-(W-i)/2)*H;
   ans=min(ans,abs(max(Sa,max(Sb,Sc))-min(Sa,min(Sb,Sc))));
 }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//ABC109A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int ans = (a-1)*(b-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main (void) {
	int n = 0, m = 0, sum = 0, i = 0, cnt = 0;
	fscanf(stdin, "%d %d", &n, &m);
	int a[n];
	
	
	for (i=0; i < n; i++) {
		fscanf(stdin, "%d", &a[i]);
		sum = sum + a[i];
	}
	
	
	for (i = 0; i < n; i++) {
		if ((float) a[i] >= (float) sum / (4* (float) m)) {
			cnt++;
		}
	}
		
	if (cnt >= m) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}		
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  int n;
  cin >> n;
  int zoro = 0;
  int max = 0;
  int d1, d2;
  REP(i,n){
    cin >> d1 >> d2;
    if( d1 == d2 ){
      zoro++;
    } else {
      if( zoro > max ){
        max = zoro;
      }
      zoro = 0;
    }
  }
  if( zoro > max ){
    max = zoro;
  }
  if( max >= 3 ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  cout << accumulate(all(p), 0) - *max_element(all(p))/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<ll, ll>> vp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    vp.at(i) = {a+b, a-b};
  }
  ll u =-1e9, d = 1e9, l = 1e9, r = -1e9;
  for(auto p : vp){
    if(p.first > u) u = p.first;
    if(p.first < d) d = p.first;
    if(p.second < l) l = p.second;
    if(p.second > r) r = p.second;
  }
  ll ans = max(u-d, r-l);
  cout << ans << endl;
  return 0;
}

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

int32_t main()
{


	int n, x, t;
	cin >> n >> x >> t;

	int res;
	if (n % x == 0)
		res = (n / x) * t;
	else
	{
		res = (n / x) + 1;
		res = res * t;
	}
	cout << res << endl;
}



Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long ans=0;
int tr[26][1000005],cnt=1,tg[1000005],fz[26][1000005],als[26][1000005];
char s[1000005];
int u,n,m,le;
void dfs(int p)
{
	for(int i=0;i<26;i++)if(tr[i][p]&&tg[tr[i][p]]==1)als[i][p]++;
	if(tg[p]==1)
	{
		for(int i=0;i<26;i++)ans+=als[i][fz[i][p]];//printf("%d %d %d\n",p,i,ans);
		//printf("%d %d\n",p,ans);
	}
	for(int i=0;i<26;i++)
	{
		if(tr[i][p]==0)continue;
		for(int j=0;j<26;j++)fz[j][tr[i][p]]=fz[j][p],als[j][tr[i][p]]=als[j][p];
		fz[i][tr[i][p]]=p;
		dfs(tr[i][p]);
	}
}
int main()
{
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%s",s+1);
		n=strlen(s+1);
		u=1;
		for(int i=n;i;i--)
		{
			le=s[i]-'a';
			if(tr[le][u]==0)tr[le][u]=++cnt;
			u=tr[le][u];
		}
		tg[u]=1;
	}
	dfs(1);
	ans-=m;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 368456
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int a,b,c,d;
int main()
{
    cin >> a >> b >> c >> d;
    bool _check = true;
    while (a > 0 && c > 0)
    {
        if (_check == true)
            c = c - b;
        else a = a - d;
        if (_check == true) _check = false;
        else _check = true;
    }
    if (a <= 0) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int n;
    scanf("%d", &n);
    vector<int> dish(n);
    rep(i,n) scanf("%d", &dish.at(i));
    vector<int> good(n);
    rep(i,n) scanf("%d", &good.at(i));
    vector<int> godd(n-1);
    rep(i,n-1) scanf("%d", &godd.at(i));
    int score=0, prev=(-1);
    for (auto x: dish) {
        score+=good.at(x-1);
        if (x==prev+1) score+=godd.at(prev-1);
        prev=x;
    }
    printf("%d\n", score);
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;


int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n)
        cin>>a[i];

    sort(ALL(a));
    int s=a[0],l=a[a.size()-1];
    if(l-s>1) 
    { 
        cout<<"No"<<endl;
        return 0;
    }
    if(s==l)
    {
        if(n==l+1)
            cout<<"Yes"<<endl;
        else if(l<=0)
            cout<<"No"<<endl;
        else if(n>=l*2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
    {

        int sc=0,lc=0;
        REP(i,n)
        {
            if(s==a[i])
                sc++;
            if(l==a[i])
                lc++;
        }
        l-=sc;

        if(l<=0) 
            cout<<"No"<<endl;
        else if(lc>=l*2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    }
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int a,b,c; cin >> a >> b >> c;

    if(b > c) swap(b,c);
    if(a > b) swap(a,b);
    if(b > c) swap(b,c);

    if(a+b == c) cout << "Yes" <<endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1; 
    while(t--){
	    vector<int> x(5);
	    for(auto & it : x) cin>>it;
	    for(int i=0;i<(int) x.size(); i++){
		    if(x[i]==0){
			    cout<<i+1;
			    break;
		    }
	    }
	    
    
    }
    return 0;
} 


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

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> players(n);
	
	for (int i = 0; i < n; i++) {
		players[i] = k - q;
	}

	while (q--) {
		int x; cin >> x;
         x--;
         players[x]++;
	}
	for (int i = 0; i < n; i++) {
		if (players[i] > 0) {
			cout << "Yes" << "\n";
		} 
		else {
			cout << "No" << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.*;

public class Main {

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

    String p = "";
    String q = "";
    String r = "";

    for (int i = 0; i < s.length()/2; i++) {
      p += s.charAt(i);
      q += s.charAt(s.length()-i-1);
    }

    for (int i = 0; i < q.length(); i++) {
      r += q.charAt(q.length()-i-1);
    }

    if (p.equals(r)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 23764
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var k = int.Parse(Console.ReadLine().Trim());
        var x = int.Parse(Console.ReadLine().Trim());
        var y = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(n > k ? k * x + (n - k) * y : n * x);
    }
}


Measured memory_bytes: 11092
fun main(args:Array<String>) {
    val (N,L) = readLine()!!.split(" ").map(String::toInt)
    val tastes = (1..N).map {
        L + it - 1
    }

    val total = tastes.fold(0) {sum,ele -> sum+ele}

    tastes.indices.minBy {
        val ts = tastes[it]
        Math.abs(ts)
    }!!.let {
        total - tastes[it]
    }.run(::println)
}
 

Measured memory_bytes: 37616
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    vector<int> v(n);
    multiset<int> st;

    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        st.insert(v[i]);
    }

    for(int i = 0; i < n; ++i) {
        int x = v[i];
        auto it = st.find(x);
        st.erase(it);
        cout << *(st.rbegin()) << endl;
        st.insert(x);
    }

    return 0;
}


Measured memory_bytes: 13364
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;

vector<string> bubble(vector<string> &a) {
    rep(i, 0, n) {
        eper(j, n-1, i+1) {
            if (a[j][1] < a[j-1][1]) 
                swap(a[j], a[j-1]);
        }
    }
    return a;
}

vector<string> selection(vector<string> &a) {
    rep(i, 0, n) {
        int minj = i;
        rep(j, i, n) {
            if (a[j][1] < a[minj][1])
                minj = j;
        }
        swap(a[i], a[minj]);
    }
    return a;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vector<string> a(n), b(n);
    rep(i, 0, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    auto bs = bubble(a);
    auto ss = selection(b);
    bool flag = true;
    rep(i, 0, n) {
        if (bs[i] != ss[i]) flag = false;
    }
    rep(i, 0, bs.size()) cout << bs[i] << (i != bs.size()-1 ? " " : "\n");
    cout << "Stable" << endl;
    rep(i, 0, ss.size()) cout << ss[i] << (i != ss.size()-1 ? " " : "\n"); 
    if (flag) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3224
N, M = gets.split.map &:to_i
A = gets.split.map &:to_i
HA = A.map { |a| a / 2 }

exist = A.map { |a|
    buf = a
    count = 0
    while buf.even?
        buf /= 2
        count += 1
    end
    count
}.uniq.size == 1
if not exist
    p 0
else
    l = HA.inject(1) { |a, b| a.lcm(b) }
    p (M / l / 2) + (M / l % 2)
end

Measured memory_bytes: 14220
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
    // A+1文字目と数字以外の文字数の判定
    // O(10)くらい
    int[] num = inta();
    string word = rstr();
    string ans = "Yes";
    
    if(word[num[0]] != '-'){
        ans = "No";
    }
    for(int i=0;i<10;i++){
        word = word.Replace(i.ToString(),"");
    }
    if(word.Length >1 ){
        ans = "No";
    }
    WriteLine(ans);
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
}

Measured memory_bytes: 13140
from math import pow
N = int(input())
MAX_INT = 2**32 - 1

candidate_numbers_set = set()
candidate_numbers_set.add(1)

current_num = 6
while current_num <= N:
    candidate_numbers_set.add(current_num)
    current_num *= 6

current_num = 9
while current_num <= N:
    candidate_numbers_set.add(current_num)
    current_num *= 9

dp = [MAX_INT] * (N + 1)
dp[0] = 0
dp[1] = 1

for i in range(2, N + 1):
    dp[i] = min([dp[i - withdrawal] for withdrawal in candidate_numbers_set if i - withdrawal >= 0]) + 1

print(dp[N])


Measured memory_bytes: 3828
import sys

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

for i in range(N + 1):
	for j in range(N - i + 1):
		if (10000 * i + 5000 * j + 1000 * (N - i - j)) == Y:
			print(i, j, N - i - j)
			sys.exit(0)

print("-1 " * 3)

Measured memory_bytes: 3060