akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
ab = [input().split() for i in range(n)]
x = input()
res = 0
f = False
for i in range(n):
    a,b = ab[i]
    b = int(b)
    if a == x:
        f = True
        continue
    if f:
        res += b
print(res)

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

using namespace std;

#define int long long

struct Node
{
	long long lazy;
	Node(){}
}Tree[400001];

int n,q;
int arr[100001];

template <typename T>
inline void Read(T& x)
{
    bool Neg = false;
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') Neg = !Neg;
    x = c - '0';
    for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    if (Neg) x = -x;
}

template <typename T>
inline void Write(T x)
{
    if (x < 0)
    {
        putchar('-'); x = -x;
    }
    T p = 1;
    for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
    for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
}

void diffuse(int node,int l,int r)
{
	if (l != r)
	{
		Tree[node*2].lazy += Tree[node].lazy;
		Tree[node*2 + 1].lazy += Tree[node].lazy;
	}
	else
		arr[l] += Tree[node].lazy;
	Tree[node].lazy = 0;			
}

void update(int node,int l,int r,int ll,int rr,int val)
{
	if (r < ll || rr < l)
		return;
	if (ll <= l && r <= rr)
	{
		Tree[node].lazy += val;
		return;
	}	
	int mi = (l + r) / 2;
	update(node*2,l,mi,ll,rr,val);
	update(node*2+1,mi+1,r,ll,rr,val);
	return;
}

int query(int node,int l,int r,int x)
{
	diffuse(node,l,r);
	if (l == r && l == x)
		return arr[l];	
	int mi = (l + r) / 2;
	if (x <= mi) return query(node*2,l,mi,x);
	return query(node*2+1,mi+1,r,x);
}

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

	Read(n);
	Read(q);
	//cin >> n >> q;
	while(q--)
	{
		int r;
		int p;
		Read(r);
		Read(p);
		//cin >> r >> p;
		while(p)
		{
			int pos = r;
			int L = 1, R = r;
    		while(L <= R)
    		{
    			int mi = (L + R) / 2;
    			if (query(1,1,n,mi) == query(1,1,n,r))
    			{
    				pos = mi;
    				R = mi - 1;
    			}
    			else
    				L = mi + 1;
    		}
    		if (pos != 1)
    		{
    			int val_r = query(1,1,n,r);
    			int b = query(1,1,n,pos-1);
				int z = (r - pos + 1) * (b - val_r);
				if (p <= z)
				{
					int z = (r - pos + 1);
					int zz = p / z;
					update(1,1,n,pos,r,zz);
					p -= (zz*z);
					if (p)
						update(1,1,n,pos,pos + p - 1,1);
					p = 0; 
				}
				else
				{
					p -= z;
					update(1,1,n,pos,r,b - val_r);
				}	
			}
			else
			{
				int z = (r - pos + 1);
				int zz = p / z;
				update(1,1,n,1,r,zz);
				p -= (zz*z);
				if (p)
					update(1,1,n,1,p,1);
				p = 0;
			}	
		}
	}
	for (int i=1;i<=n;i++)
	{
		Write(query(1,1,n,i));
		putchar('\n');
		//cout << query(1,1,n,i) << ' ';
	}	
}

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

int main(void){
    int N;
    cin>>N;
    int a[N],cnt=0,next=1;
    for(int i=0;i<N;i++)
        cin>>a[i];

    for(int i=0;i<N;i++){
        next=a[next-1];
        cnt++;
        if(next==2){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 640
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

inline void setmin(int &x, int y) { if (y < x) x = y; }
inline void setmax(int &x, int y) { if (y > x) x = y; }
inline void setmin(ll &x, ll y) { if (y < x) x = y; }
inline void setmax(ll &x, ll y) { if (y > x) x = y; }

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 52;

inline void add(int &x, int y) {
    x += y;
    if (x >= MOD2) {
        x -= MOD2;
    }
}

int dp[2 * 2000 + 1][2 * 2000 + 1];

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    string s;
    cin >> s;
    int n = sz(s);
    int prefR[n];
    rep(i, 0, n) {
        if (s[i] == '0') {
            prefR[i] = 2;
        } else if (s[i] == '1') {
            prefR[i] = 1;
        } else {
            prefR[i] = 0;
        }
        if (i > 0) {
            prefR[i] += prefR[i - 1];
        }
    }
    dp[0][0] = 1;
    rep(i, 0, n * 2) {
        rep(cr, 0, n * 2 + 1) {
            if (dp[i][cr] == 0) {
                continue;
            }
            int cb = i - cr;
            int tr = prefR[min(n - 1, i)], tb = min(n, i + 1) * 2 - tr;
            if (cr < tr) {
                add(dp[i + 1][cr + 1], dp[i][cr]);
            }
            if (cb < tb) {
                add(dp[i + 1][cr], dp[i][cr]);
            }
        }
    }
    int ans = 0;
    rep(i, 0, n * 2 + 1) {
        add(ans, dp[n * 2][i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 60544
#include<stdio.h>
int main(void){
  int m,f,r,k;
  for(k=1;k!=0;k++){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1){
      break;
    }else if(m==-1||f==-1){
      printf("F\n");
    }else if(m+f>=80){
      printf("A\n");
    }else if(65<=m+f&&m+f<80){
      printf("B\n");
    }else if(50<=m+f&&m+f<65){
      printf("C\n");
    }else if(30<=m+f&&m+f<50){
      if(r<50){
        printf("D\n");
      }else {
        printf("C\n");
      }
    }else{
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
q,h,s,d=map(int,input().split())
n=int(input())
Q,H,S,D=q*8,h*4,s*2,d
if min(Q,H,S,D)==Q:
    print(n*4*q)
elif min(Q,H,S,D)==H:
    print(n*2*h)
elif min(Q,H,S,D)==S:
    print(n*s)
else:
    if n%2==0:
        print((n//2)*d)
    else:
        print(((n//2)*d)+min(q*4,h*2,s))

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> fact(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(fact[0] != 1){
		fact[0] = 1;
		for(long long i = 1;i < MAX_K;i++)fact[i] = (fact[i-1] * i) % MOD;
	}
    long long ret = fact[n];
	long long tmp = (fact[r] * fact[n-r]) % MOD;
    return mod_div(ret,tmp);
}

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

	ll n, k;cin >> n >> k;
	ll blue = k;
	ll red = n - k;
	for(ll i = 1;i <= k;i++){
		cout << combination(blue - 1, (i - 1)) * combination(red + 1, i) % MOD << endl;;
	}

	return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
  int N;
  int ac=0,wa=0,tle=0,re=0;
  string A;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A;
    if(A=="AC")
      ac++;
    else if(A=="WA")
      wa++;
    else if(A=="TLE")
      tle++;
    else if(A=="RE")
      re++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};


int main() {
    int n;
    cin >> n;
    vector<ll> points(n);
    rep(i, n) cin >> points[i];

    sort(points.rbegin(), points.rend());

    if (n == 1) {
        cout << mint(points[0]) * 2 << endl;
        ret();
    }

    mint res = 0;
    mint n2 = mint(2).pow(n - 2);
    mint n1 = mint(2).pow(n - 1);

    rep(i, n) {
        mint fac = n2 * i + n1;
        res += fac * points[i];
    }

    mint ans = res * mint(2).pow(n);

    cout << ans << endl;


}

Measured memory_bytes: 1792
n, X = open(0).read().split()
n = int(n)
x = int(X, 2)
X = list(map(int, X))

def popcount(n):
    return bin(n).count('1')

ma = 2 * 10**5 + 1
dp = [0] * ma
for i in range(1, ma):
    dp[i] = dp[i % popcount(i)] + 1

c = popcount(x)
a = x % (c+1)
if c == 1:
    for i in range(n):
        if X[i]:
            print(0)
        else:
            print(dp[(a + pow(2, n-i-1, c+1)) % (c+1)] + 1)
else:
    b = x % (c-1)
    for i in range(n):
        if X[i]:
            print(dp[(b - pow(2, n-i-1, c-1)) % (c-1)] + 1)
        else:
            print(dp[(a + pow(2, n-i-1, c+1)) % (c+1)] + 1)

Measured memory_bytes: 12872
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Long> map = new HashMap<>();
        for(int i = 0;i < n;i++) {
            char[] tmp = sc.next().toCharArray();
            Arrays.sort(tmp);
            String str = String.valueOf(tmp);
            Long count = map.get(str);
            if(count == null) map.put(str, 1L);
            else map.put(str, count + 1);
        }

        System.out.println(map.keySet().stream().map(map::get).mapToLong(e -> (e * (e - 1) / 2)).sum());
    }

}


Measured memory_bytes: 56360
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> graph[N];
long long ans[N],forp[N];

void dfs(int u,int p,int m){
	ans[u]=1;
	for(auto x:graph[u]){
	if(x==p)continue;
	dfs(x,u,m);
	ans[u]=(ans[u]*(ans[x]+1))%m;
}
}






void dfs2(int u,int p,int m){
	vector <long long> suff(graph[u].size(),1);
	for(int i=graph[u].size()-1;i>-1;i--){
		if(graph[u][i]==p){
if(i!=graph[u].size()-1)suff[i]=suff[i+1];
continue;
}
	if(i!=graph[u].size()-1)
	suff[i]=((ans[graph[u][i]]+1)*suff[i+1])%m;
	else suff[i]=(ans[graph[u][i]]+1)%m;
}
long long running=1;
	for(int i=0;i<graph[u].size();i++){
		int x=graph[u][i];
		if(x==p)continue;
		if(i!=graph[u].size()-1)
		forp[x]=(running*suff[i+1])%m;
		else forp[x]=running;	
		forp[x]=((forp[u]+1)*forp[x])%m;
running=(running*(ans[x]+1))%m;
		dfs2(x,u,m);
}
}


int main(){
	int n,m;cin>>n>>m;
	for(int i=0;i<n-1;i++){
	int x,y;cin>>x>>y;
	graph[x].push_back(y);
	graph[y].push_back(x);
}
dfs(1,0,m);
dfs2(1,0,m);
for(int i=1;i<=n;i++){
	long long currans=(1+forp[i])%m;
	currans=(currans*(ans[i]))%m;
	cout<<currans<<"\n";
}
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string S; cin >> S;
  string ok[16] = {
    "AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHABR",
    "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR",
    "KIHABARA", "KIHABAR", "KIHABRA", "KIHABR",
    "KIHBARA", "KIHBAR", "KIHBRA", "KIHBR"    
  };
  string result = (find(ok,ok+16,S)!=ok+16) ? "YES" : "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll dp[2010][2010];

int main()
{
	ll n,x;
	cin >> n >> x;
	
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	
	REP(i,n)
	{
		ll tmp = v[i];
		REP(j,n)
		{
			tmp = min(tmp,v[(i+j)%n]);
			dp[i][j] = tmp;
		}
		
	}
	
	
	ll ans = 1000000000000000;
	REP(i,n)
	{
		ll tmp = 0;
		REP(j,n)
		{
			tmp += dp[j][i];
		}
		ans = min(ans ,tmp+x*i);
	}
	
		
		cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 31616
N, M = map(int, input().split())
H = list(map(int, input().split()))
connections = (list(map(int, input().split())) for _ in range(M))
winner_nodes = [1 for x in range(N)]
for pair in connections:
  a = pair[0]-1
  b = pair[1]-1
  if H[a]>=H[b]: winner_nodes[b] = 0
  if H[b]>=H[a]: winner_nodes[a] = 0
print(sum(winner_nodes))

Measured memory_bytes: 20032
import re

s = list(input())

def error_out():
    print('WA')
    exit()

if s[0] != 'A':
    error_out()
else:
    s[0] = 'a'

count = 0
for i in range(2, len(s) - 1):
    if s[i] == 'C':
        s[i] = 'c'
        count = 1
        break

if count != 1:
    error_out()

if re.search('[A-Z]', ''.join(s)):
    print('WA')
else:
    print('AC')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
const int maxn=1e5+5;
int a[maxn],b[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++)
        scanf("%d",&a[i]);
    ll col=0,res=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        res=min(a[i],b[i]);
        b[i]-=res;
        col+=res;
        res=min(b[i],a[i+1]);
        a[i+1]-=res;
        col+=res;
    }
    printf("%lld",col);
    return 0;
}


Measured memory_bytes: 1024
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 156 -B
int main(void) {
	int  n,k,a=1,i;

	scanf("%d %d", &n,&k);

	for (i = 1;; i++) {
		a *= k;
		if (a > n) break;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int f,l,buf,count,i,j,k,minj,a[100];

  count = 0;

  scanf("%d",&l);
  for(j = 0; j < l; j++)
    scanf("%d",&a[j]);
  for(i = 0; i < l; i++){
    minj = i;
    f = 1;
      for(j = i; j < l; j++){
	if(a[j] < a[minj]){
	  minj = j;
	  if(f == 1){
	    count++;
	    f = 0;
	  }
	}
      }
      buf = a[i];
      a[i] = a[minj];
      a[minj] = buf;
  }
  
  for(i = 0; i < l - 1; i++)
    printf("%d ",a[i]);
  printf("%d\n%d\n",a[l - 1],count);
  
  return 0;
}



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

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) {
		is >> x;
	}
	return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

bool isContained(int n, vector<int> A) {
	for (auto a : A) {
		if (n == a) {
			return true;
		}
	}
	return false;
}

int main(void) {
	int s_size;
	cin >> s_size;
	vector<int> S(s_size);
	cin >> S;
	int q_size;
	cin >> q_size;
	vector<int> Q(q_size);
	cin >> Q;
	
	int count = 0;
	for (auto q : Q) {
		if (isContained(q, S)) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3160
<?php
fscanf(STDIN,"%d",$n);
$p=explode(" ", rtrim(fgets(STDIN)));
 
$result=0;
for($i=0;$i<$n-1;$i++)
{
	if($i+1==$p[$i])
	{
		$temp=$p[$i];
		$p[$i]=$p[$i+1];
		$p[$i+1]=$temp;
		$result++;
	}
}
if($p[$n-1]==$n)
    $result++;
 
echo($result);

Measured memory_bytes: 12792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
const int MN=200000;
int N,A,B;
vector<int> Ga[MN],Gb[MN];
bool vis[MN];	//Ga
typedef pair<int,int> P;


const int MAX_V=MN;
const int LOGV=18;
int par[MAX_V][LOGV],depth[MAX_V];
void dfs(int v,int p){
	if(p<0) depth[v]=0;
	else depth[v]=depth[p]+1;
	par[v][0]=p;
	for(int u:Gb[v]){
		if(u!=p) dfs(u,v);
	}
}
void genlca(int N){
	dfs(0,-1);
	for(int i=1;i<LOGV;i++){
		rep(v,N){
			if(par[v][i-1]==-1) par[v][i]=-1;
			else par[v][i]=par[par[v][i-1]][i-1];
		}
	}
}
int lca(int u,int v){
	if(depth[u]<depth[v]){
		swap(u,v);
	}
	int d=depth[u]-depth[v];
	rep(i,LOGV){
		if((d>>i)&1) u=par[u][i];
	}
	if(u==v) return u;
	for(int i=LOGV-1;i>=0;i--){
		if(par[u][i]!=par[v][i]){
			u=par[u][i];
			v=par[v][i];
		}
	}
	return par[v][0];
}


int distB(int x,int y){
	int w=lca(x,y);
	return depth[x]+depth[y]-2*depth[w];
}
int up(int v,int d){
	rep(i,LOGV) if((d>>i)&1) v=par[v][i];
	return v;
}
int toclose(int x,int tar){
	assert(x!=tar);
	int w=lca(x,tar);
	if(w!=x) return par[x][0];
	int d=depth[tar]-depth[x];
	return up(tar,d-1);
}

int solve(){
	cin>>N>>A>>B;
	A--,B--;
	rep(i,N-1){
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		Ga[x].pb(y);
		Ga[y].pb(x);
	}
	rep(i,N-1){
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		Gb[x].pb(y);
		Gb[y].pb(x);
	}

	genlca(N);

	int d=-1;
	queue<P> que;
	que.push(P(-1,-1));
	que.push(P(A,B));
	vis[A]=1;
	int ans=0;
	while(!que.empty()){
		P p=que.front();que.pop();
		if(p.sc==-1){
			if(que.empty()) break;
			que.push(P(d+1,-1));
			d++;
//			show(d);
			continue;
		}
		int a=p.fs,b=p.sc;
//		printf("a=%d,b=%d\n",a,b);
		chmax(ans,(d+distB(a,b))*2);
		for(int na:Ga[a]) if(!vis[na]){
			if(distB(a,na)>=3){
				return -1;
			}
			vis[na]=1;
			if(b==na) continue;//?
			int nb=toclose(b,na);
			if(nb==na) continue;
			que.push(P(na,nb));
		}
	}
	return max(ans,d*2);
}
int main(){
	cout<<solve()<<endl;
}

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

int main () {

    int n, m;
    priority_queue< double > q;

    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        q.push(a);
    }

    while(m--) {
        double t = q.top(); q.pop();
        if(t == 0) break;
        q.push(t / 2.0);
    }

    long long sum = 0;
    while(!q.empty()) {
        int t = q.top(); q.pop();
        sum += t;
    }

    cout << sum << endl;

}


Measured memory_bytes: 1400
import sys
# sys.setrecursionlimit(100000)


class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, m = input_int_list()
    union = UnionFind(n)
    for _ in range(m):
        a, b = input_int_list()
        # 0-indexed
        a -= 1
        b -= 1
        union.unite(a, b)
    cnt = 0
    for p in union.parents:
        if p < 0:
            cnt += 1
    print(cnt - 1)

    return


if __name__ == "__main__":
    main()


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

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int j = 1;j<=n;j++){
        printf("%d",a[n-j]);
         if(j != n){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3220
#pragma region Macros
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos ) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos ) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos ) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos ) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos ) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos ) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7792
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            99999999999999


void solve()
{
  double x;
  cin>>x;
  cout<<fixed<<setprecision(2)<<(2.00)*(3.1416)*(x)<<endl;

}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}


Measured memory_bytes: 3756
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto i = readNums!int;
  auto w = i[0], h = i[1], x = i[2], y = i[3];

  double s = w.to!double * h.to!double / 2.0;
  int m;
  if(w % 2 == 0 && h % 2 == 0 && w / 2 == x && h / 2 == y) m = 1;

  writeln(s, " ", m);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())
    numbers1 = list()
    numbers2 = list()

    for i in range(1, 1250 + 1):
        if int(i * 0.08) == a:
            numbers1.append(i)

    for i in range(1, 1000 + 1):
        if int(i * 0.1) == b:
            numbers2.append(i)

    c = set(numbers1) & set(numbers2)

    if len(c) == 0:
        print(-1)
    else:
        print(min(c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll n;
    ll p[100];
    cin>>n;
    rep(i,n){
        cin>>p[i];
    }
    sort(p,p+n);
    ll ans=0;
    rep(i,n){
        if(i!=n-1) ans+=p[i];
        else ans+=p[i]/2;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

n,a,b=map(int,input().split())

def nCr(N,R,DIV):
  f=lambda x,y:x*y%DIV
  X=reduce(f,range(N-R+1,N+1))
  Y=reduce(f,range(1,R+1))
  return X*pow(Y,DIV-2,DIV)%DIV

DIV=10**9+7
ans=pow(2,n,DIV)-1
ans-=nCr(n,a,DIV)
ans-=nCr(n,b,DIV)
print(ans%DIV)

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

using namespace std;


typedef long long ll;

bool foo(string s){
    for (int i=0; i<s.size(); i++){
        if (s[i]!='A' && s[i]!='C' &&s[i]!='G' &&s[i]!='T' )return 0;
    }
    return 1;
}
int main()
{
    //freopen("", "r", stdin);freopen("", "w", stdout);
    int n, q;
    cin>>n>>q;
    string s;
    cin>>s;
    s="#"+s;
    n=s.size();
    vector<int>a(n, 0);
    for (int i=1; i<n; i++){
        if (s[i]=='C' && s[i-1]=='A'){
            a[i]=a[i-1]+1;
        }
        else {
            a[i]=a[i-1];
        }
    }
    while(q--){
        int l, r;
        cin>>l>>r;
        int ans=a[r]-a[l-1];
        if (s[l]=='C' && s[l-1]=='A')ans--;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n-1; i++) cin >> a.at(i);

  vector<int> res(n);
  for(int i=0; i<n-1; i++){
    res.at(a.at(i)-1)++;
  }

  for(int i=0; i<n; i++){
    cout << res.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll s;cin>>s;
    ll x=1000000000-s%1000000000;
    x%=1000000000;
    ll y=(x+s)/1000000000;
    cout<<0<<' '<<0<<' '<<1000000000<<' '<<1<<' '<<x<<' '<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int a,b;
double aa,bb;

int main(){
    cin>>a>>b;
    aa=a;
    bb=b;
    printf("%d %d %.8lf\n",a/b,a%b,aa/bb);
    return 0;
}


Measured memory_bytes: 3160
#include "bits/stdc++.h"
#define ll long long
using namespace std;
static const int INF = (1 << 21);

int maxi = 0,save=0;
int N;
int s[100], f[100] = { 0 };


void dfs(int u) {
 
}

int main() {
	
    cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> s[i]; f[i] = 1;
	}
	sort(s, s + N);

	for (int i = 0;i < N;i++) maxi += s[i];

	if (maxi % 10) {
		cout << maxi << endl;
		return 0;
	}

	for (int i = 0;i < N;i++) {
		if (s[i] % 10) {
			maxi -= s[i];
			break;
		}
	}
    
	if (maxi % 10 == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << maxi << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S1 = sc.next();
        String S2 = sc.next();
        String S3 = sc.next();
        boolean test = true;
        String ans = "";
        char ch = 'a';
        
        while(test){
            if(ch == 'a'){
                if(S1.length()>1){
                    ch = S1.charAt(0);
                    S1 = S1.substring(1,S1.length());
                    //System.out.println(ch+":"+S1);
                }else if(S1.length()==1){
                    ch = S1.charAt(0);
                    S1 = "";
                    //System.out.println(ch+":"+S1);
                }else{
                    ans = "A";
                    test = false;
                }
            }else if(ch == 'b'){
                if(S2.length()>1){
                    ch = S2.charAt(0);
                    S2 = S2.substring(1,S2.length());
                    //System.out.println(ch+":"+S2);
                }else if(S2.length()==1){
                    ch = S2.charAt(0);
                    S2 = "";
                    //System.out.println(ch+":"+S2);
                }else{
                    ans = "B";
                    test = false;
                }
            }else{
                if(S3.length()>1){
                    ch = S3.charAt(0);
                    S3 = S3.substring(1,S3.length());
                    //System.out.println(ch+":"+S3);
                }else if(S3.length()==1){
                    ch = S3.charAt(0);
                    S3 = "";
                    //System.out.println(ch+":"+S3);
                }else{
                    ans = "C";
                    test = false;
                }
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
  int a;
  cin >> a;
  if (a==25)
    cout << "Christmas" << endl;
  else if (a==24)
    cout << "Christmas Eve" << endl;
  else if (a==23)
    cout << "Christmas Eve Eve" << endl;
  else if (a==22)
    cout << "Christmas Eve Eve Eve" << endl;
  return 0;
  
}

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

int main() { 
  int A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  
  long long int dist = max(A-B,0) + max(B-A,0);
  long long int speed = V-W;//1秒間でどれだけ距離を詰められるか？
  
  if( speed <= 0) cout << "NO" << endl;//おいつけない
  else if( speed * T >= dist ) cout << "YES" << endl;//時間内に追いつける
  else cout << "NO" << endl;//時間が足りない
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

//----------------------------------------------------------------
ll gcd(ll x, ll y){
  if(x<y){return gcd(y,x);}
  if(y==0 || x==y) {return x;}
  else {return gcd(y, x%y);}
}

int main(void) {
  int n;
  cin >> n;
  vecll a(n);
  rep(i,n){
    cin >> a[i];
  }

  if(n==2){
    prt(max(a[0], a[1]));
    return 0;
  }

  vecll l(n), r(n);
  l[0]=a[0], r[0]=a[n-1];
  REP(i,1,n){
    l[i] = gcd(l[i-1], a[i]);
    r[i] = gcd(r[i-1], a[n-i-1]);
  }
/*
  prt("l");
  rep(i,l.size()){
    prt(l[i]);
  }
  prt("r");
  rep(i,r.size()){
    prt(r[i]);
  }
*/
  ll max=0;
  rep(i,n){
    ll tmp = 0;
    if(i==0){
      tmp = r[n-2];
      if(max<tmp){
        max = tmp;
      }
    } else if(i==n-1){
      tmp = l[n-2];
      if(max<tmp){
        max = tmp;
      }
    } else {
      tmp = gcd(l[i-1],r[n-i-2]);
      if(max<tmp){
        max = tmp;
      }
    }
  }

  prt(max);
}


Measured memory_bytes: 2560
main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  print $ solve h w

solve :: Int -> Int -> Int
solve h w 
  | h `mod` 3 == 0 = 0
  | w `mod` 3 == 0 = 0
  | otherwise =
    -- Hで全探査
    let 
      hm = minimum [min (max3 a b1 c1 - min3 a b1 b1)  (max3 a b2 c2 - min3 a b2 c2)| 
         h'<-[1..(h-1)], 
         let a = h' * w,
         let b1 = (h-h')`div`2*w,
         let c1 = ((h-h')`div`2 + (h-h')`mod`2)*w,
         let b2 = (h-h')*(w`div`2),
         let c2 = (h-h')*(w`div`2 + w`mod`2)  ]  
      
      -- Wで全探査
      wm = minimum [min (max3 a b1 c1 - min3 a b1 b1)  (max3 a b2 c2 - min3 a b2 c2)| 
         w'<-[1..(w-1)], 
         let a = h * w',
         let b1 = (w-w')`div`2*h,
         let c1 = ((w-w')`div`2 + (w-w')`mod`2)*h,
         let b2 = (w-w')*(h`div`2),
         let c2 = (w-w')*(h`div`2 + h`mod`2)  ]  
    in 
      min hm wm
    where
      max3 a b c = max (max a b) c
      min3 a b c = min (min a b) c


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

int main() {
  int l;
  cin >> l;
  int ans = 0;
  string s;
  cin >> s;

  int k = s.size();
  vector<int> table(k+1);
  table.at(0) = 0;

  for (int i=0; i < s.size(); i++) {
    if (s.at(i) == 'I')  {
      table.at(i+1) = table.at(i) + 1;
    }
    else table.at(i+1) = table.at(i) - 1;
}
  for (int i=0; i < k+1; i++) {
  ans = max(ans,table.at(i));
  }
  cout << ans << endl;

}




Measured memory_bytes: 256
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int l[105],r[105],n;
int c[105],d[105];
ll dfs(int cur)
{
	ll le=1,ri=1;
	if(c[cur]) le=dfs(c[cur]);
	if(d[cur]) ri=dfs(d[cur]);
	ll x=le/__gcd(le,1LL*r[cur]);
	ll y=ri/__gcd(ri,1LL*l[cur]);
	ll base=1LL*x/__gcd(x,y)*y;
	return base*(l[cur]+r[cur]);
}
int main()
{
	srand((unsigned int)time(NULL));
	while(1)
	{
		scanf("%d",&n); if(!n) return 0;
		bool sub[105]={};
		for(int i=1;i<=n;i++)
		{
			int a,b;
			scanf("%d %d %d %d",&a,&b,&c[i],&d[i]);
			sub[c[i]]=sub[d[i]]=true;
			int x=__gcd(a,b);
			l[i]=a/x;
			r[i]=b/x;
		}
		ll ret=0;
		for(int i=1;i<=n;i++)
		{
			if(!sub[i]) ret+=dfs(i);
		}
		printf("%lld\n",ret);
	}
}

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


const int MOD = 1e9 + 7;


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

    int n, k;
    std::vector<int> boundary;
    std::cin >> n >> k;

    for (int x = 1, y; x <= n; x = y + 1) {
        y = n / (n / x);
        boundary.push_back(y - x + 1);
        x = y + 1;
    }

    static long long dp[105][70005];
    dp[0][0] = 1;
    for (int i = 1; i <= k; ++i) {
        long long temp = 0LL;
        for (int j = boundary.size() - 1; j >= 0; --j) {
            temp = (temp + dp[i - 1][boundary.size() - j - 1]) % MOD;
            dp[i][j] = temp * boundary[j] % MOD;
        }
    }

    long long ans = 0LL;
    for (int i = 0, i_END_ = boundary.size(); i < i_END_; ++i)
        ans = (ans + dp[k][i]) % MOD;
    std::cout << ans << std::endl;
    return 0;
}

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

int main(){
    string S;
    cin >> S;

    if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
        cout << "Yes" << endl;
    }
    else if(S.at(1) == S.at(2) && S.at(2) == S.at(3)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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


int solve( int x ){
    if( x == 0 )return 1;
    if( x < 0 )return 0;

    rep(i,6){
        return solve( x - 100 - i );
    }
}

int dp[ 100000 ];
int main(){
    ll x,y;
    cin >> x >> y;
    ll res = 0;

    while(x <= y){
        x *= 2;
        res++;
    }
    
    cout << res << endl;
}

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

int main(){
   int n,m; cin>>n>>m;
   vector<int> ans(m);
   for(int i=0;i<n;i++){
      int k; cin>>k;
      for(int j=0;j<k;j++){
         int a; cin>>a;
         for(int l=1;l<=m;l++){
            if(a==l) ans[l-1]++;
         }
      } 
   }
   int cnt=0;
   for(int i=0;i<m;i++){
      if(ans[i]==n) cnt++;
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int length(char x[]){
	int i;
	
	for(i = 0;x[i]!='\0';i++){
	
	}

	return i;
}

void toUpperOrLowerCase(char x[]){
	int i;

	for(i = 0;x[i]!='\0';i++){
		if((x[i] >= 65 && x[i] <= 90) || (x[i] >= 97 && x[i] <= 122)){
			x[i] = (x[i] % 64 + 32) % 64 + 64;
		}
	}
}

int main(void){
	char x[1200];
	FILE *fp;


	gets(x);	
	toUpperOrLowerCase(x);
	printf("%s\n",x);
	
	return 0;

}

Measured memory_bytes: 524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = CinT();
            int[] A = new int[n];
            int max = 0;
            int SubMax = -1;
            for (int i = 0; i < n; i++)
            {
                A[i] = CinT();
                if(max < A[i])
                {
                    max = A[i];
                }
                else
                {
                    SubMax = Math.Max(SubMax, A[i]);
                }
            }
            for (int i = 0; i < n; i++)
            {
                if(A[i] != max)
                {
                    Cout(max);
                }
                else
                {
                    Cout(SubMax);
                }
            }
            Cin();
        }

        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void OYes() { Cout("Yes"); }
        static void ONo() { Cout("No"); }
        static void Cout(object s) { WriteLine(s); }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 17096