akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define lint long long
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
#define P pair<int, int>
#define D pair<double, double>
#define DI pair<double, int>
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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;
}

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

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

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int main() {
	int n, m;
	cin >> n >> m;
	cout<<n*m<<endl;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define SIZE 100333
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

int main () {
	ll n;
	scanf("%lld",&n);
	printf("%lld\n",800*n - n/15*200 );
}

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

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  char *s = (char *) calloc (n + 1, sizeof (char));
  scanf ("%s", s);
  i32 cnt = 0;
  for (i32 i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      cnt++;
    } else {
      cnt--;
    }
  }
  puts (cnt > 0 ? "Yes":"No");
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

pii fit(const vvi& window, const vvi& pic, int y, int x)
{
	int m = pic.size();
	pii ans(-1, -1);
	rep(i, m) rep(j, m){
		if(pic[i][j] == -1)
			continue;
		
		if(window[y+i][x+j] != pic[i][j]){
			return pii(-1, -1);
		}else if(ans.first == -1)
			ans = pii(y+i, x+j);
	}
	return ans;
}

void rotate(vvi& p)
{
	int m = p.size();
	vvi next(m, vi(m));
	rep(i, m) rep(j, m)
		next[i][j] = p[m-j-1][i];
	
	p.swap(next);
}

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		vvi window(n, vi(n));
		rep(i, n) rep(j, n)
			scanf("%d", &window[i][j]);
		
		vvi pic(m, vi(m));
		rep(i, m) rep(j, m)
			scanf("%d", &pic[i][j]);
		
		pii ans(-1, -1);
		rep(i, n-m+1) rep(j, n-m+1){
			rep(k, 4){
				ans = fit(window, pic, i, j);
				if(ans.first != -1){
					i=n-m+1;
					j=n-m+1;
					break;
				}
				rotate(pic);
			}
		}
		
		if(ans.first == -1)
			puts("NA");
		else
			printf("%d %d\n", ans.second+1, ans.first+1);
	}
	
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
char c;
int main()
{
    cin>>c;
    switch(c)
    {
    case 'A':
        {
            cout<<'T';
            break;
        }
    case 'C':
        {
            cout<<'G';
            break;
        }
    case 'G':
        {
            cout<<'C';
            break;
        }
    case 'T':
        {
            cout<<'A';
            break;
        }
    }
    return 0;
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), f(N, 1);
    rep(i, N) {
        cin >> A[i];
        A[i] += 1e9;
    }
    sort(A.begin(), A.end());
    rep(i, N - 1) f[i + 1] = (f[i] * (i + 1)) % MOD;
    ll ans = 0;
    rep(i, N - K + 1) {
        ll x = A[i] * f[N - 1 - i];
        x %= MOD;
        x *= mod_pow(f[K - 1], MOD - 2, MOD);
        x %= MOD;
        x *= mod_pow(f[N - i - K], MOD - 2, MOD);
        x %= MOD;
        ans = (ans - x + MOD) % MOD;
        x = A[N - 1 - i] * f[N - 1 - i];
        x %= MOD;
        x *= mod_pow(f[K - 1], MOD - 2, MOD);
        x %= MOD;
        x *= mod_pow(f[N - i - K], MOD - 2, MOD);
        x %= MOD;
        ans = (ans + x) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
n=int(input())
val1 = input().split(" ")
val2=[int(i) for i in val1]

w = 0

while True:
    v = 0
    for i in range(n):
        if val2[i] % 2 == 1:
            v = 1
    if v ==1:
        break
    if v ==0:
        for i in range(n):
            val2[i] = val2[i]/2
        w += 1

print(w)

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

#define MAX 100

int A[MAX][MAX];


int main(){
    int n, u, k, v;
    cin >> n;

    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < MAX; j++){
            A[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--; //0オリジンに変換
        for(int j = 0; j < k; j++){
            cin >> v;
            v--; //0オリジンに変換
            A[u][v] = 1;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
ll a,b,c,d;
map<ll,ll> dp;
ll solve(ll n){
	if(n == 0)return 0;
	if(n == 1)return d;
	if(dp[n])return dp[n];
	ll res = 1e18;
	if(n < res/d){
		res = d*n;
	}
	ll a1 = (n)/2 * 2;
	ll a2 = (n+1)/2 * 2;
	ll b1 = (n)/3 * 3;
	ll b2 = (n+2)/3 * 3;
	ll c1 = (n)/5 * 5;
	ll c2 = (n+4)/5 * 5;
	res = min(res,a+solve(a1/2)+abs(a1-n)*d);
	res = min(res,a+solve(a2/2)+abs(a2-n)*d);
	res = min(res,b+solve(b1/3)+abs(b1-n)*d);
	res = min(res,b+solve(b2/3)+abs(b2-n)*d);
	res = min(res,c+solve(c1/5)+abs(c1-n)*d);
	res = min(res,c+solve(c2/5)+abs(c2-n)*d);
	dp[n] = res;
	return res;  
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		cin>>a>>b>>c>>d;
		cout<<solve(n)<<"\n";
		dp.clear();
	}
	return 0;
}

Measured memory_bytes: 4432
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

有向グラフ
トポロジカルソートみたいなもの
※トポロジカルソートみたいなものは先日の日経予選にもあり

ソース、シンクを考えると、題意のパスはどれかのソースからどれかのシンクに至っている

入次数を調べることでソースたちを見つける
他の点にもすべて入次数を持たせておく

ソースから幅優先探索
ソースの値は0とする
自分の子たちに自分の値＋１をつける
ただしすでに値がある場合は、改善される場合だけ上書き
いずれにしてもこれらをされた子は入次数を減らす
入次数が残り0になった子はその子から続きの探索をする

*/

class Node{
	Node[] kids;
	int parentcount;
	int value;
	int id;
	this(int id){
		this.id = id;
	}
}

void main(){
	int n = read.to!int;
	int m = read.to!int;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);
	
	foreach(j; 0 .. m){
		int x = read.to!int - 1;
		int y = read.to!int - 1;
		nodes[x].kids ~= nodes[y];
		nodes[y].parentcount += 1;
	}
	
	Node[] queue;
	int iq;
	foreach(nd; nodes) if(nd.parentcount == 0){
		nd.value = 0;
		queue ~= nd;
	}
	
	while(iq < queue.length){
		Node nd = queue[iq];
		foreach(kid; nd.kids){
			kid.value = nd.value + 1;
			kid.parentcount -= 1;
			if(kid.parentcount == 0) queue ~= kid;
		}
	
	iq ++;
	}
	
	int ans = 0;
	foreach(nd; nodes) if(ans < nd.value) ans = nd.value;
	
	ans.writeln;
}


Measured memory_bytes: 21756
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ng = 0, ok = n;
	while (ok - ng > 1) {
		int mid = (ng + ok) / 2;
		vector<P> p;
		bool flag = true;
		rep(i, n) {
			if (i == 0) p.pb(P(1, a[i]));
			else if (a[i - 1] < a[i]) {
				if (p[p.size() - 1].first == 1) {
					p[p.size() - 1].second += a[i] - a[i - 1];
				}
				else {
					p.pb(P(1, a[i] - a[i - 1]));
				}
			}
			else {
				int prev = a[i - 1];
				int num;
				while (prev >= a[i]) {
					prev -= p[p.size() - 1].second;
					num = p[p.size() - 1].first;
					p.pop_back();
				}
				if (num == mid) {
					if (p.size() == 0) {
						flag = false;
						break;
					}
					int pf = p[p.size() - 1].first;
					int ps = p[p.size() - 1].second;
					p.pop_back();
					if (ps > 1) p.pb(P(pf, ps - 1));
					if (p.size() > 0 && p[p.size() - 1].first == pf + 1) p[p.size() - 1].second++;
					else p.pb(P(pf + 1, 1));
					p.pb(P(1, a[i] - prev));
				}
				else {
					if (prev + 1 < a[i]) {
						p.pb(P(num, a[i] - prev - 1));
						p.pb(P(num + 1, 1));
					}
					else {
						if (p[p.size() - 1].first == num + 1) p[p.size() - 1].second++;
						else p.pb(P(num + 1, 1));
					}
				}
			}
		}
		if (flag) ok = mid;
		else ng = mid;
	}
	cout << ok << '\n';
}

Measured memory_bytes: 1152
def find(x, U, r, w): #x: ノード名、U:前のノードの配列 w:前のノードからの距離の配列、r:深さ
  if x == U[x]:
    return (x, w[x])
  else:
    k = find(U[x], U, r, w)
    #付け替え処理
    w[x] += w[U[x]]
    U[x] = k[0]
    #print(k)
    return (U[x],w[x])

def merge(a, b, U, r, w, w_add): #w_add　aにbを付け加える時、距離をwはなす
  a = find(a, U, r, w)[0]
  b = find(b, U, r, w)[0]
  if a == b:#何もしない
    return  
  """
  if r[a] < r[b]:
    a, b = b, a #a（深い）にb（浅い）をくっつける
  U[b] = a  
  if r[a] == r[b]:#もともと同じ深さの時だけ、結合後の深さが１増えるため
    r[a] += 1
  """
  U[b] = a
  r[a] = max(r[a], r[b]+1)
  w[b] += w_add
  return

N, M = map(int,input().split())
U = [i for i in range(N)]#前のノード（自分が先頭の時は自分の値）
w = [0 for _ in range(N)]#前のノードとの距離
r = [0 for _ in range(N)]#自分の木の深さ（自分が先頭の時のみ）

ans = True
for _ in range(M):
  
  L, R, D = map(int,input().split())
  L -= 1
  R -= 1
  t1 = find(L, U, r, w)
  t2 = find(R, U, r, w)
  #print(U,w)
  if t1[0] == t2[0] and not(t2[1] - t1[1] == D):
    ans = False 
    break
  if not(t1[0] == t2[0]):
    D -= t2[1] - t1[1]
    if r[L] < r[R]:
      L, R = R, L
      D = -D
    merge(L, R, U, r, w, D)
  
print("Yes" if ans else "No")

Measured memory_bytes: 16236
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    y, m, d = map(int, input().split("/"))

    for a, b in [(y, 2019), (m, 4), (d, 30)]:
        if a < b:
            print("Heisei")
            return
        elif a > b:
            print("TBD")
            return

    if y == 2019 and m == 4 and d == 30:
        print("Heisei")
    else:
        print("TBD")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>
#include <bitset>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    bitset<30> Kb(K);
    vector<pair<bitset<30>, ll>> AB;
    loop(i, N){
        scanInt(Ai);
        scanInt(Bi);
        AB.emplace_back(Ai, Bi);
    }
    ll result = 0;
    {
        // cout << Kb << endl;
        const bitset<30> nKb = ~Kb;
        ll temp = 0;
        for (auto& ab : AB){
            if ((nKb & ab.first).none()){
                temp += ab.second;
            }
        }
        result = max(result, temp);
    }
    for (int b = 1; b < 30; ++b){
        if (!Kb[b]) continue; // 0はNO
        bitset<30> L = Kb;
        L[b] = false;
        L |= bitset<30>((1 << b) - 1);
        // cout << L << endl;
        L = ~L;
        ll temp = 0;
        for (auto& ab : AB){
            if ((L & ab.first).none()){
                temp += ab.second;
            }
        }
        result = max(result, temp);
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 3444
N=int(input())
A=[]

for i in range(N):
    s,t=map(str,input().split())
    A.append([s,int(t)])

X=str(input())
result=0
flg=0

for i in range(N):
    if flg==1:
        result+=A[i][1]

    if A[i][0]==X:
        flg=1

print(result)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String sa[]=br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int[] dices= new int[n];
		sa = br.readLine().split(" ");
		double[] exp = new double[n];
		for(int i = 0 ; i< n ;i++) {
			dices[i] = Integer.parseInt(sa[i]);					
			exp[i] = ((double) dices[i]+1)/2;
		}
		double result = 0,current = 0;
		for(int i = 0 ; i < n ; i++) {
			current += exp[i];
			if(i >= k) {
				current -= exp[i-k];
			}
			result = Double.max(result, current);
		}
		System.out.println(result);
		
	}

}


Measured memory_bytes: 51284
from collections import deque


h, w = map(int, input().split())
Ch, Cw = map(lambda x: int(x)-1, input().split())
Dh, Dw = map(lambda x: int(x)-1, input().split())
dy, dx = (-1, 0, 1, 0), (0, -1, 0, 1)
maze = [[float('inf') if x == '.' else -float('inf') for x in input()] for _ in range(h)]
maze[Ch][Cw] = 0
que = deque()
que.append((0, Ch, Cw))
while que:
    c, y, x = que.popleft()
    
    if c > maze[y][x]:
        continue
    
    if y == Dh and x == Dw:
        break
    
    for i in range(4):
        y2, x2 = y + dy[i], x + dx[i]
        if 0 <= y2 < h and 0 <= x2 < w and c < maze[y2][x2]:
            maze[y2][x2] = c
            que.appendleft((c, y2, x2))
            
    for i in range(-2, 3):
        for j in range(-2, 3):
            y3, x3, c2 = y + i, x + j, c+1
            if 0 <= y3 < h and 0 <= x3 < w and c2 < maze[y3][x3]:
                maze[y3][x3] = c2
                que.append((c2, y3, x3))

ans = maze[Dh][Dw]
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 106332
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
int main(){
  ll A,B;
  cin>>A>>B;
  vector<ll> X;
  X.push_back(1);
  for(int i=0;;i++){
    ll Y=2*X[i];
    if(Y<100000000000000) X.push_back(Y);
    else break;
  }
  ll ans=0;
  if(B-A+1<128){
    rep(i,B-A+1) ans^=A+i;
  }else{
    ll Z1=X[lower_bound(all(X),A)-X.begin()];
    ll Z2=X[lower_bound(all(X),B)-X.begin()-1];
    if(Z1>Z2){
      rep(i,(A+4)/4*4-A) ans^=A+i;
      rep(i,B-B/4*4+1) ans^=B-i;
    }else{
    rep(i,(Z1-A)%4) ans^=A+i;
    rep(i,(B-Z2+1)%4) ans^=B-i;
    }
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] d = new int[n];
        for(int i = 0; i < n; i++) d[i] = scan.nextInt();
        Arrays.sort(d);
        System.out.println((d[n / 2] - d[n / 2 - 1]));
        scan.close();
    }
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1L << 60;

int main() {
    int N; cin >> N;
    vector<int> h(N);
    REP(i, 0, N) cin >> h[i];

    vector<ll> dp(N, INF);
    dp[0] = 0;
    REP(i, 1, N) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll t1,t2,a1,b1,a2,b2;cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	ll dist1 = t1 * a1 - t1 * b1, dist2 = t2 * a2 - t2 * b2;
	if(dist1 == 0 || dist2 == 0){
		if(dist1 == 0 && dist2 != 0) cout << 1 << endl;
		else if(dist1 == dist2) cout << "infinity" << endl;
		else cout << 0 << endl;
		return 0;
	}
	if((dist1 > 0 && dist2 > 0) || (dist1 < 0 && dist2 < 0)){
		cout << 0 << endl;
		return 0;
	}
	ll dist3 = abs(dist1 + dist2);
	if(dist3 == 0){
		cout << "infinity" << endl;
		return 0;
	}
	if(abs(dist1) > abs(dist2)){
		cout << 0 << endl;
		return 0;
	}
	dist1 = abs(dist1);
	ll ans = (dist1 + dist3 - 1) / dist3 * 2;
	if(dist1 % dist3 != 0) ans--;
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll MOD = 1000000000 + 7;

int main()
{
	double w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << fixed << setprecision(6) << w * h / 2.0 << " " << (w / 2 == x && h / 2 == y ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, dead_code)]
use proconio::fastout;
use proconio::input;
use rand::Rng;

#[fastout]
fn main() {
    input! {
        D:usize,
        C:[i32;26],
        S:[[i32;26];D]
    }
    let mut ans = 0;
    let mut rng = rand::thread_rng();
    let mut T = vec![0; D];
    let mut Tmax = vec![0; D];
    let start = std::time::Instant::now();
    // let mut cnt = 0;
    loop {
        // cnt += 1;
        for i in 0..D {
            T[i] = rng.gen::<usize>() % 26;
        }
        let mut last = vec![vec![0i32; 26]; D];
        for d in 0..D {
            let i = T[d];
            last[d][i] = d as i32 + 1;
            for e in d + 1..D {
                if T[e] != i {
                    last[e][i] = d as i32 + 1;
                } else {
                    break;
                }
            }
        }
        let mut x = 0;
        for d in 0..D {
            let i = T[d];
            x += S[d][i];
            //println!("ss{}", x);
            for j in 0..26 {
                x -= C[j] * (d as i32 + 1 - last[d][j]);
                //println!("C[{}]={} -> {}", j, C[j], x);
            }
        }
        if ans < x {
            for k in 0..D {
                ans = x;
                Tmax[k] = T[k];
            }
        }
        let duration = start.elapsed();
        if duration > std::time::Duration::from_millis(1900) {
            break;
        }
    }
    //println!("cnt:{}", cnt);
    for i in 0..D {
        println!("{}", Tmax[i] + 1);
    }
    //println!("cnt:{}, point:{}", cnt, ans);
}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;

int n, a[N], f[N], ans = 0;

inline void ck_max( int &a, int b ) { if( a < b ) a = b; }

int main()
{
	scanf( "%d", &n );
	
	for( int i = 1; i <= n; i ++ )
		scanf( "%d", &a[i] );
	
	memset( f, 0, sizeof( f ) );
	for( int i = 1; i <= n; i ++ )
		f[ a[i] ] = f[ a[i] - 1 ] + 1, ck_max( ans, f[ a[i] ] );
		
	printf( "%d\n", n - ans );
	
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  string s,t;
  cin>>n>>s>>t;
  int m=0;
  for (int i = 1; i <= n; ++i)
  {
    string tmp="";
    for (int j = 0; j < i; ++j)
    {
      tmp+=t[j];
    }
    bool flag=true;
    for (int j = 0; j < tmp.size(); ++j)
    {
      if(tmp[j]!=s[n-tmp.size()+j])
      {
        flag=false;
        break;
      }
    }
    if(flag)
    {
      m=tmp.size();
    }
  }
  cout<<2*n-m<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int n; ll k; cin>>n>>k;
    vector<int> a(n+1);
    for(int i = 1; i<=n; i++) cin>>a[i];
    
    bool vis[n+1];
    memset(vis, 0, sizeof(vis));
    vector<int> town;
    int t = 1, i;

    while(1){
        if(vis[t]) break;
        town.push_back(t);
        vis[t] = 1;
        t = a[t];
    }

    n = town.size();
    for(i = 0; i<n && town[i]!=t; i++);

    if(k<i) cout<<town[k];
    else{
        k -= i;
        k = k%(n-i);
        cout<<town[i+k];
    }
    return 0;
}

Measured memory_bytes: 5272
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	ll n;
	cin >> n;
	vector<ll>t(n);
	rep(i, n) {
		cin >> t[i];
	}
	ll ans = 1;
	rep(i, n) {
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MROW (101)

int main() {
	int N;
	cin >> N;
	int E[MROW][MROW];
	for (int n1 = 1; n1<=N; ++n1) {
		for (int n2 = 1; n2<=N; ++n2) {
			E[n1][n2] = 0;
		}
	}
	for (int n=0;n<N;++n) {
		int u, K;
		cin >> u >> K;
		for (int k=0;k<K;++k) {
			int v;
			cin >> v;
			E[u][v] = 1;
		}	
	}
	for (int i=1;i<=N;++i) {
		for (int j=1;j<=N;++j) {
			if (j>1) cout << " ";
			cout << E[i][j];
		}
		cout << endl;
	}
	return 0;
}



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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
map<int,int>num;
rep(i,n){
    cin>>a[i];
    num[a[i]]++;
}
int res=0;
for(auto v:num){
    if(v.first<v.second){
        res+=v.second-v.first;
    }
    else if(v.first>v.second){
        res+=v.second;
    }
}
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 7996
import collections as cl
import math
N=int(input())

result_=[]
for i in range(N):
    s= ''.join(sorted(input()))
    result_.append(s)

result=list(cl.Counter(result_).values())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans=0
for j in range(len(result)):
    if result[j]==1:
        continue
    else:
        ans+=combinations_count(result[j],2)

print(ans)

Measured memory_bytes: 19752
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	int n,y,m,d,s,a[1005],i,p;
	cin >> n;
	for(i=0; i<n; i++)
	{
		s=0;
		cin >> y >> m >> d;
		p=y/3;
		if(y%3==0)
		{
			s+=200*(p-1);
			s+=195*(y-p);
		}
		else 
		{
			s+=200*p;
			s+=195*(y-p-1);
		}
		if(y%3==0) s+=20*(m-1)+d;
		else 
		{
			for(int j=1; j<m; j++)
			{
				if(j%2==1) s+=20;
				else s+=19;
			}
			s+=d;
		}
		a[i]=196470-s+1;
	}
	for(i=0; i<n; i++)
	cout << a[i] <<endl;
}



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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , k;
ll r , s , p;

void solve(int testCase){

    scanf("%d %d" , &n , &k);
    scanf("%lld %lld %lld" , &r , &s , &p);
    string str;
    cin >> str;

    ll ans = 0;
    for(int i = 0 ; i < n ; i ++){
            if(str[i] == 'r')ans += p;
            if(str[i] == 's')ans += r;
            if(str[i] == 'p')ans += s;
    }


    for(int i = k ; i < n ; i ++){
            if(str[i] == str[i-k]){
                    if(str[i] == 's')ans -= r;
                    if(str[i] == 'p')ans -= s;
                    if(str[i] == 'r')ans -= p;
                    str[i] = '?';
            }
    }

    printf("%lld\n" , ans);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 512
A=list(map(int,input().split()))
Fi=sorted(A)[2]
Se=sorted(A)[1]
Th=sorted(A)[0]
if (Se-Th)%2 == 0:
   ans=(2*Fi-Se-Th)//2
else:
   ans=(2*Fi-Se-Th+3)//2
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=100000000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main() {
    int n;ll l;
    cin>>n>>l;
    ll a[100010];
    bool f=false;
    int s;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>0&&a[i]+a[i-1]>=l){
            f=true;
            s=i-1;
        }
    }
    if(!f){
        cout<<"Impossible"<<endl;
        return 0;
    }
    cout<<"Possible"<<endl;
    for(int i=0;i<s;i++){
        cout<<i+1<<endl;
    }
    for(int i=n-1;i>=s+1;i--){
        cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 1536
N, x = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
res = 0
count = x
for i in range(N):
    count -= l[i]
    res += 1
    if count == 0:
        break
    if count < 0:
        res -= 1
        break

if sum(l) - x < 0:
    res -= 1

        
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	ll m;
	cin >> n >> m;
	ll a[n], s[n+1];
	map<ll, ll> d;
	for(int i=0; i<n; i++) cin >> a[i];
	s[0]=0;
	d[s[0]]++;
	for(int i=1; i<=n; i++){
		s[i]=(s[i-1]+a[i-1])%m;
		d[s[i]]++;
	}
	ll ans=0;
	for(map<ll, ll>::iterator it=d.begin(); it!=d.end(); it++){
		ans+=it->second*(it->second-1)/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
N = int(input())
B = list(map(int, input().split()))
A = []
A.append(B[0])
for n in range(1, N):
    if n < N-1:
        A.append(min(B[n-1], B[n]))
    else :
        A.append(B[n-1])
print(sum(A))


Measured memory_bytes: 3060
using System;

namespace abc0818
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            double bunbo = 0;
            foreach(string a in Console.ReadLine().Split(' '))
            {
                bunbo += 1.0 / int.Parse(a);
            }
            Console.WriteLine(1 / bunbo);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



ll comb(int n, int r) {
	static vector<vector<ll>> memo(51, vector<ll>(26));
	if (r > n / 2) return comb(n, n - r);
	if (memo[n][r]) return memo[n][r];
	if (r == 0) memo[n][0] = 1;
	else memo[n][r] = comb(n - 1, r - 1) + comb(n - 1, r);
	return memo[n][r];
}

class question {
public:
	int N, P;
	int odd = 0;
	void gets() {
		cin >> N >> P;
		REP(i, N) {
			int a;
			cin >> a;
			odd += a % 2;
		}
	}
	void ans() {
		ll res = 0;
		if (P == 0) {
			for (int i = 0;i <= odd;i += 2) {
				res += comb(odd, i);
			}
		}
		else {
			for (int i = 1;i <= odd;i += 2) {
				res += comb(odd, i);
			}
		}
		res *= ((ll)1 << (N - odd));
		cout << res << "\n";
	}
};



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.gets();
	q.ans();
	
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[55][55];

int main() {
  clr(dp,0);
  ll n,m,l;
  cin>>n>>m>>l;
  vector<ll> va;
  vector<ll> vb;
  vector<ll> vc;
  rep(i,0,m){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    va.pb(a*(n+1)+b);
    vb.pb(c-1);
    vc.pb(d);
  }
  rep(i,1,53){
    rep(j,0,53){
      rep(k,0,va.sz){
        if(i==va[k]){
          dp[i+vb[k]][j+1] = max(dp[i+vb[k]][j+1],dp[i-1][j]+vc[k]);
        }
      }
      dp[i][j] = max(dp[i][j],dp[i-1][j]);
    }
  }
  ll mx = 0;
  rep(i,0,53){
    rep(j,0,l+1){
      mx = max(mx,dp[i][j]);
    }
  }

  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 1260
s = input()
if s[0] == s[1]:
    if s[1] != s[2] and s[2] == s[3]:
        print("Yes")
    else:
        print("No")
else:
    if (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2]):
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	int n;
	cin >> n;
	map<string, int>s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string in;
		cin >> in;
		s[in]++;
		ans = max(ans, s[in]);
	}
	for (auto iter = s.begin(); iter != s.end(); iter++) {
		if (iter->second == ans) {
			cout << iter->first << endl;
		}
	}
}


Measured memory_bytes: 25984
from itertools import product
from collections import defaultdict
def resolve():
    s = input()
    K = int(input())
    dp = defaultdict(int)
    dp[0, 0, 0] = 1
    for i, less, k in product(range(len(s)), (0, 1), range(K+1)):
        max_d = 9 if less else int(s[i])
        max_d = 0 if k == K else max_d
        for d in range(max_d+1):
            less_ = less or d < max_d
            k_ = k + 1 if d > 0 else k
            dp[i + 1, less_, k_] += dp[i, less, k]
    print(sum(dp[len(s), less, K] for less in (0, 1)))
resolve()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;


int main(void) {
  string s;
  cin >> s;
  int cnt0 = 0,cnt1 = 0;
  for(int i = 0;i < (int)s.size();++i){
    if(s[i] == '0') {
      ++cnt0;
    } else {
      ++cnt1;
    }
  }
  cout << 2 * min(cnt0,cnt1) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>

using namespace std;
int N;

int main() {
  cin >> N;
  vector<long> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }

  long sum1 = 0;
  long sum2 = 0;

  long pos = 0;
  for (int i=0; i<N; i++) {
    if (pos <= 0) {
      pos += a.at(i);
      if (pos < 1) {
        sum1 += 1-pos;
        pos = 1;
      }
    } else {
      pos += a.at(i);
      if (pos > -1) {
        sum1 += pos+1;
        pos = -1;
      }
    }
  }
  pos = 0;
  for (int i=0; i<N; i++) {
    if (pos < 0) {
      pos += a.at(i);
      if (pos < 1) {
        sum2 += 1-pos;
        pos = 1;
      }
    } else {
      pos += a.at(i);
      if (pos > -1) {
        sum2 += pos+1;
        pos = -1;
      }
    }
  }

  cout << min(sum1, sum2) << endl;
}


Measured memory_bytes: 1024
N = input()
A, B, C, D = N[0], N[1], N[2], N[3]
def fn(op1, op2, op3):
    msg = A + op1 + B + op2 + C + op3 + D
    if eval(msg) == 7:
        print(msg + "=7")
        exit()

for op1 in ('+', '-'):
    for op2 in ('+', '-'):
        for op3 in ('+', '-'):
            fn(op1, op2, op3)

Measured memory_bytes: 3060
N = int(input())
v = list(map(int, input().split()))
v1 = sorted(v, reverse = True)
sum1 = 0

for i in range(N-1):
  value = v1[i]/(2 ** (i+1))
  sum1 += value

sum1 += v1[-1]/(2 ** (N-1))

print(sum1)

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

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

int main() {

    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;

    int sum = 0;
    while (a >= b) {
        b *= 2;
        sum++;
    }

    while (b >= c) {
        c *= 2;
        sum++;
    }

    if (k >= sum) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 3628
#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>;
const int INF = 1e9;
int main() {
    int N; cin >> N;
    int X[N];
    rep(i, N) cin >> X[i];
    int ans = INF;
    rep(i, 101){
        int tmp = 0;
        rep(j, N){
            tmp += (i - X[j]) * (i - X[j]);
        }
        if(ans > tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    double l;
    cin>>l;

    double x=l/3;

    cout<<x*x*x<<endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
int n, a[111][2], b[111][2];
bool mp[111][111];
int vis[111], cur, link[111];
int dfs(int u){
    for(int v = 1; v <= n; ++v) if(mp[u][v]) {
        if(vis[v] != cur){
            vis[v] = cur;
            if(link[v] == 0 || dfs(link[v])){
                link[v] = u;
                return 1;
            }
        }
    }
    return 0;
}
int main(){
   // IN;
    SC(n);
    FF(i, 1, n){
        SCC(a[i][0], a[i][1]);
    }
    FF(i, 1, n){
        SCC(b[i][0], b[i][1]);
    }
    FF(i, 1, n)
    FF(j, 1, n){
        if(a[i][0] < b[j][0] && a[i][1] < b[j][1]) mp[i][j] = 1;
    }
    int ans = 0;
    for(cur = 1; cur <= n; ++cur){
        if(dfs(cur)){
            ++ans;
        }
    }
    PR(ans);
    return 0;
}


Measured memory_bytes: 256
h1, m1,  h2, m2, k= list(map(int, input().split()))

if m2 < m1:
    h2 -= 1
    m2 += 60

h = max(h2 - h1, 0) * 60
m = max(m2 - m1, 0)
print(h + m - k)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  UnionFind uf(n);
  vvll langs(m);
  rep(i,n){
    ll k; cin>>k;
    rep(j,k){
      ll l; cin>>l;
      l--;
      langs[l].push_back(i);
    }
  }
  rep(i,m){
    if(langs[i].size()==0) continue;
    ll f=langs[i][0];
    irep(j,1,langs[i].size()){
      uf.connect(langs[i][j],f);
    }
  }
  bool ok=true;
  rep(i,n-1){
    if(!uf.isSame(i,i+1)) ok=false;
  }
  if(ok) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
vector<int> a;

bool binarySearch(int x,vector<int> m,int n) {
	int mark;
	int begin = 0;
	int last = n;
	while (begin < last) {
		mark = (begin + last) / 2;
		if (x == m[mark]) return true;
		else if (x < m[mark])
		{
			last = mark;

		}
		else if (x > m[mark]) {
			begin = mark + 1;
		}
	}
	return false;
}

int main()
{
	int n, q,num;
	while (cin >> n) {
		int m;
		num = 0;
		for (int i = 0; i < n; i++) {
			cin >> m;
			a.push_back(m);
		}

		cin >> q;
		for (int i = 0; i < q; i++) {
			cin >> m;
			if (binarySearch(m, a, n))
				num++;
		}

		cout << num << endl;
	}
    return 0;
}



Measured memory_bytes: 3692