akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n;
    long long zoj=0,rob=0;
    long long a[100010];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%4==0)
        {
            rob++;
        }
        if(a[i]%2==0)
        {
            zoj++;
        }
    }
    zoj=zoj-rob;
    n=n-(zoj+rob);
    if (zoj!=0)
    {
        if(rob>=n)
        {
        cout<<"Yes";
        return 0;
        }

    }
   else
    {
        if(rob!=0 and(rob+1>=n))

        {
        cout<<"Yes";
        return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

ll mod = 1e9+7;

vector <string> number;

void generate(ll d,string s = ""){
	if (number.size() >= 1e5) return;
	if (d == 0){
		number.push_back(s);
		return;
	}
	if (s.size() == 0){
		for (int z=1;z<=9;z++){
			s += to_string(z);
			generate(d-1,s);
			s.pop_back();
			if (number.size() >= 1e5) return;
		}
	} else {
		ll i = s[s.size()-1]-'0';
		for (int z=max(ll(0),i-1);z<=min(ll(9),i+1);z++){
			s += to_string(z);
			generate(d-1,s);
			s.pop_back();
			if (number.size() >= 1e5) return;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll i = 1;
	while (number.size() < 1e5){
		generate(i);
		i++;
	}
	cout << number[n-1] << endl; 
}

Measured memory_bytes: 6900
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

struct Point{
	double x, y;
};

void koch(int n, Point a, Point b){
	if(n == 0){
		return;
	}
	
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x)/3.0;
	s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
	t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
	t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n-1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n-1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n-1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n-1, t, b);
	
	
}

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

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}



Measured memory_bytes: 3172
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		String s=nextLine();
		int n=s.length();
		int a[]=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=s.charAt(i-1)-'0';

		int dp[]=new int[n+1];
		for(int i=1;i<=n;i++)
			dp[i]=(dp[i-1]*10+a[i])%2019;

		HashMap<Integer,Integer> map=new HashMap<>();
		int pow=1;
		long ans=0;
		for(int i=n;i>=1;i--)
		{
			int curr=(dp[i]*pow)%2019;
			int x=map.getOrDefault(curr,0);
			ans+=x;
			map.put(curr,x+1);
			pow=(pow*10)%2019;
		}
		ans+=map.getOrDefault(0,0);
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 45960
#include <iostream>
#include <stdio.h>
int main(void){
    int month,day,chek;
    while(std::cin >> month >> day,month){ int year = 2004;
    if(month == 1 || month == 2){year--;month+=12;}
    chek = ((year+ year/4-year/100+year/400+(13*month+8)/5+day)%7);
    switch (chek) {case 0:puts("Sunday");break; case 1:puts("Monday");break; case 2:puts("Tuesday");break; case 3:puts("Wednesday");break;
        case 4:puts("Thursday");break; case 5:puts("Friday");break; case 6:puts("Saturday");break; }}return 0;}

Measured memory_bytes: 1116
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local unpack = table.unpack or unpack
local insert = table.insert or insert
local max = math.max
----
local MOD = math.floor(10^9) + 7
local H, W = read.nnl()
local G = {}
for h=1,H do
    G[h] = read.l():totable()
end
local tbl = array(2, 0)
for h=1,H do
    for w=1,W do
        if h==1 and w==1 then
            tbl[h][w] = 1
        else
            if G[h][w] == '.' then
                tbl[h][w] = (tbl[h-1][w] + tbl[h][w-1]) % MOD
            end
        end
    end
end
print(tbl[H][W])

Measured memory_bytes: 33784
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
from bisect import bisect_left
ans = 0
for i in range(n):
  for j in range(i+1, n):
    t = l[i]+l[j]
    idx = bisect_left(l, t)
    ans += max(0, idx-j-1)
print(ans)

Measured memory_bytes: 3316
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	ll sum=0;
	ll sum1=0;
	READAR(A,N);
	FORI(i,0,N)
	{
		sum+=A[i];
		if (i%2==1)
		{
			sum1+=A[i];
		}
	}
	sum=sum/2;
	ll x0=sum-sum1;
	cout<<2*x0<<" ";
	FORI(i,0,N-1)
	{
		x0=A[i]-x0;
		cout<<2*x0<<" ";
	}
	cout<<endl;

	return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  r(i,n)cin>>l.at(i);


  sort(l.rbegin(),l.rend());
  int sum=0;
  r(i,k)sum+=l.at(i);
  cout<<sum<<endl;




return 0;

}


Measured memory_bytes: 256
from collections import deque

H, W = [int(a) for a in input().split()]

S = [None for _ in range(H)]


for i in range(H):
    S[i] = list(input())

# print("H = {}, W = {}".format(H, W))
# print(S)

INF = -1

dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)



def bfs(sx, sy):
    dist = [[INF for _ in range(W)] for _ in range(H)]
    que = deque() # 座標
    que.append((sx, sy))
    dist[sy][sx] = 0

    # print("S = {}".format(S))
    # print("dist = {}".format(dist))
    while(len(que) > 0):
        # print("que = {}".format(que))
        x, y = que.popleft()
        for i in range(4): # 上下左右に移動
            nx = x + dx[i]
            ny = y + dy[i]

            # print("nx = {}, ny = {}".format(nx, ny))
            if (0 <= nx < W) and (0 <= ny < H) and S[ny][nx] == '.' and dist[ny][nx] == INF:
                que.append((nx, ny))
                dist[ny][nx] = dist[y][x] + 1
    return( max( [max(dist[i]) for i in range(H)]))

m = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            m = max(m, bfs(j, i))

print(m)


Measured memory_bytes: 3316
from itertools import accumulate
n, m, k = map(int, input().split())
Acum = [0]+list(accumulate(map(int, input().split())))
Bcum = [0]+list(accumulate(map(int, input().split())))

ans = 0
b = m
for a in range(n+1):
    if k < Acum[a]:
        break
    while k < Acum[a]+Bcum[b]:
        b -= 1
    if ans < a+b:
        ans = a+b
print(ans)


Measured memory_bytes: 48308
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define show(x) std::cerr << #x << "=" << x << std::endl
using namespace std;
typedef long long ll;
const double eps=1e-8;
const int maxn = 2e5+5;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int t;
int n,m;
int a[maxn];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>a[i];
    sort(a+1,a+1+n);
    ll sum = 0;
    for(int i=1;i<=m;++i) sum+=a[i];
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3624
A,B,C,X,Y= map(int, input().split())
ans=0
ans=A*X+B*Y

z=min(X,Y)
x=X-z
y=Y-z
ans=min(ans,x*A+y*B+C*2*z)

z=max(X,Y)
ans=min(ans,C*2*z)
print(ans)

Measured memory_bytes: 61724
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    cout << max(a-2*b,0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 200005;

int n;
long long sum;
char s[MAXN];

int main() {
	scanf ("%s", s + 1);
	for (int i = 1; i <= strlen(s + 1); i++) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) printf ("Yes\n");
	else printf ("No\n");
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define o_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
#define trav(it, v) for(auto &it : v)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 	return r;
}


void solve()
{
	int n; string s;	
	cin >> n >> s;
	int e = 0, w = 0;
	rep(i, n) if(s[i] == 'E') ++e; else ++w;
	int pre = 0;
	int res = inf;
	rep(i, n) {
		if(s[i] == 'E') --e;
		else --w;
		res = min(res, pre + e);
		if(s[i] == 'W') pre++;
 	}
 	cout << res;
}

int main()
{
    Red;
    // freopen("black.in", "r", stdin);
	// freopen("black.out", "w", stdout);
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i) {
    	// cout << "Case #" << i << ": ";
    	solve();
  	}
  	return 0;

}

Measured memory_bytes: 3884
class Dice:
    same_dice_index = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 3, 1, 4, 2, 5),
                       (0, 4, 3, 2, 1, 5), (1, 0, 3, 2, 5, 4), (1, 2, 0, 5, 3, 4),
                       (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (2, 0, 1, 4, 5, 3),
                       (2, 1, 5, 0, 4, 3), (2, 4, 0, 5, 1, 3), (2, 5, 4, 1, 0, 3),
                       (3, 0, 4, 1, 5, 2), (3, 1, 0, 5, 4, 2), (3, 4, 5, 0, 1, 2),
                       (3, 5, 1, 4, 0, 2), (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),
                       (4, 3, 0, 5, 2, 1), (4, 5, 3, 2, 0, 1), (5, 1, 3, 2, 4, 0),
                       (5, 2, 1, 4, 3, 0), (5, 3, 4, 1, 2, 0), (5, 4, 2, 3, 1, 0))

    def __init__(self, str_list):
        self.faces = str_list

    def is_same(self, dice):
        for i in Dice.same_dice_index:
            for n, j in enumerate(i):
                if dice.faces[n] != self.faces[j]:
                    break
            else:
                return True
        return False

    def is_unique(self, dices_list):
        for i in dices_list:
            if self.is_same(i):
                return False
        return True

import sys

n = int(sys.stdin.readline())

dices = []

for i in range(n):
    str_list = sys.stdin.readline().split()
    new_dice = Dice(str_list)
    if not new_dice.is_unique(dices):
        print('No')
        break
    dices.append(new_dice)
else:
    print('Yes')

Measured memory_bytes: 7856
#include<iostream>
#include<string>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
using namespace std;
typedef pair<int,int> Node;
int main(){
	int n,q,m;
	LOOP:
	while(cin>>n,n){
		string b; int p,s,t,d;
		
		map<string,int> tbl[n];
		map<string,int> minPrice;
		int k[n],ad[n+1][n+1];
		rep(i,n){
			cin>>k[i];
			rep(j,k[i]){
				cin>>b>>p,tbl[i][b]=p;
				if(minPrice.find(b)==minPrice.end()||minPrice[b]>p)minPrice[b]=p;
			}
		}
		cin>>q;
		string req[q];
		rep(i,q)cin>>req[i];
		cin>>m;
		rep(i,n+1)rep(j,n+1)ad[i][j]=0;
		rep(i,m)cin>>s>>t>>d,ad[s][t]=ad[t][s]=d;
		
		//goods check
		int sum=0;
		rep(i,q){
			if(minPrice.find(req[i])==minPrice.end()){
			cout<<"impossible"<<endl;goto LOOP;
			}
			sum+=minPrice[req[i]];
		}
		//BFS
		queue<Node> Q; int C[n+1][1<<q];
		Q.push(make_pair(0,0)); rep(i,n+1)rep(j,1<<q)C[i][j]=1<<20;
		C[0][0]=0;
		while(!Q.empty()){
			int c=Q.front().first,cbit=Q.front().second,nbit=cbit;
			Q.pop();
			if(c>0)rep(i,q)
			if(tbl[c-1].find(req[i])!=tbl[c-1].end()&&tbl[c-1][req[i]]==minPrice[req[i]])
			nbit|=1<<i;
			rep(i,n+1)if(ad[c][i]&&(C[i][nbit]==1<<20||C[i][nbit]>C[c][cbit]+ad[c][i]))
			Q.push(make_pair(i,nbit)),C[i][nbit]=C[c][cbit]+ad[c][i];
		}
		cout<<sum<<" "<<C[0][(1<<q)-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from functools import reduce

# 入力
N = int(input())
gA, sA, bA = map(int, input().split())
gB, sB, bB = map(int, input().split())

A = (gA, sA, bA)
B = (gB, sB, bB)


# 各貴金属について、買う／売る可能性のある取引所は一意に定まることを用いて
# 全探索により解を求める
def f(n, r):
    R = len(r)
    if R == 0:
        return n
    elif R == 1:
        return n + (r[-1][1] - r[-1][0]) * (n // r[-1][0])
    elif R == 2:
        return reduce(
            max,
            (
                n + (r[0][1] - r[0][0]) * x +
                (r[-1][1] - r[-1][0]) * ((n - r[0][0] * x) // r[-1][0])
                for x in range(n // r[0][0] + 1)
            ),
            n
        )
    else:
        res = 0
        for x in range(n // r[0][0] + 1):
            m = n - r[0][0] * x
            for y in range(m // r[1][0] + 1):
                res = max(
                    res,
                    n + (r[0][1] - r[0][0]) * x + (r[1][1] - r[1][0]) * y +
                    (r[-1][1] - r[-1][0]) * ((m - r[1][0] * y) // r[-1][0])
                )
        return res


ans = f(
    f(
        N,
        [
            (a, b)
            for a, b in zip(A, B)
            if a < b
        ]
    ),
    [
        (b, a)
        for b, a in zip(B, A)
        if a > b
    ]
)

# 出力
print(ans)


Measured memory_bytes: 40556
#include<stdio.h>

int main()
{
long long int p[10000000];
long long int b,i,k=0;
long long int m=1000000000000000000;
unsigned long long mul=1;  

scanf("%lld",&b);

for(i=0;i<b;i++)
{
scanf("%lld\n",&p[i]);

}

for(i=0;i<b;i++)
{
if(p[i]==0)
{
k=1;
break;
}
if(mul<=m/p[i])
{
mul=mul*p[i];
}
else
k=2;
}
if(k==1)
{
printf("0\n");
}
else if(k==2)
{
printf("-1\n");
}
else if(k==0)
printf("%llu\n",mul);

return 0;
} 



Measured memory_bytes: 2508
#include<cstdio>
#include<vector>
#include<map>
#include<climits>
#include<algorithm>
#include<iostream>
using namespace std;
typedef pair<int,int> Pt;
#define MAX 1000001
#define fr first
#define sc second
int main(){
  string s;
  int ans = 0;
  cin >> s;
  for(int i=0;i<s.size();){
    int a = 0,b = 0,c = 0;
    for(;s[i]=='J';a++) i++;
    for(;s[i]=='O';b++) i++;
    for(;s[i]=='I';c++) i++;
    if(a>=b && b<=c) ans = max(ans,b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2052
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        solve();
    }

    private static void solve() {

        int n = scanner.nextInt();

        Map<Integer, Long> count = new HashMap<>();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            arr[i] = a;
            long c = count.getOrDefault(a, 0l);
            count.put(a, c + 1);
        }

        long total = 0;

        for (Map.Entry<Integer, Long> e : count.entrySet()) {
            total += e.getValue() * (e.getValue() - 1) / 2;
        }

        for (int a : arr) {
            long c = count.get(a);
            long res = total - c + 1;
            System.out.println(res);
        }
    }
}

Measured memory_bytes: 101204
N = int(input())
l, r = [0 for _ in range(N)], [0 for _ in range(N)]
for i in range(N):
    l[i], r[i] = map(int, input().split())


if N%2 == 1:
    lm = sorted(l)[(N+1)//2-1]
    rm = sorted(r)[(N+1)//2-1]
    print(rm - lm + 1)
else:
    lm = sum(sorted(l)[N//2-1:N//2+1])/2
    rm = sum(sorted(r)[N//2-1:N//2+1])/2
    # 0.5 刻みで増えることに注意
    print(int((rm-lm+0.5)*2))


Measured memory_bytes: 26972
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = Long.parseLong(sc.next());
        long yokin = 100;
        long ans = 0;
        while(X > yokin) {
            yokin = (long)(1.01 * yokin);
            ans++;
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 35648
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
int main(){
  int N;
  rd(N);
  wt_L(divup_L(N,2));
  wt_L('\n');
  return 0;
}
// cLay varsion 20200227-1

// --- original code ---
// {
//   int N;
//   rd(N);
//   wt(N/+2);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b+a); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

void resolver(int keta, ll value, vector<ll> &all) {
  all.push_back(value);

  if (keta == 10) return;

  // keta + 1 を列挙する
  // value = 1 だったら
  // 10, 11, 12
  // value = 23 だったら
  // 231, 232, 233
  rep(i, -1, 3) {
    int add = (value%10) + i;
    if (add >= 0 && add <= 9) {
      resolver(keta+1, value*10+add, all);
    }
  }
}

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

  int k;
  cin >> k;

  vector<ll> all;

  // 最初の桁が 1~9のものを全列挙する
  rep(i,1,9) {
    resolver(1, i, all);
  }

  sort(all(all));

  cout << all[k-1] << endl;

  return 0;
}


Measured memory_bytes: 5328
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    ll N; cin >> N;
    vl divs;
    ll ans = 0;
    FOR(i, 1, (int)(sqrt(N)+1)){
        if (N % i == 0){
            divs.push_back(i);
            if (i != (int)(N / i)){
                divs.push_back((int)(N/i));
            }
        }
    }

    REP(i, divs.size()){
        // cout << divs[i] << endl;
        ll m = N / divs[i] - 1;
        if (N/divs[i] > 2 && m > divs[i]){
            ans += N/divs[i] - 1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int a[3];

void init()
{
	rep(i, 3) cin >> a[i];
}

void solve()
{
	sort(a, a+3);
	PRINT(a[0] + a[1] == a[2]);
}



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

const function<int(int, int)> minQ = [](int l, int r) { return min(l, r); };

template <typename T>
class node {
public:
	T val, lazy;
	ll size;
	node<T> *l, *r;
	node() {}
	node(T val_, T lazy_, ll size_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : val(val_), lazy(lazy_), size(size_), l(l_), r(r_) {}
	void init(T val_, T lazy_, ll size_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		lazy = lazy_;
		size = size_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicLazySegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id1, id2;
	func_t merge1, merge2;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node(ll size) {
		pool[it].init(id1, id2, size);
		return &pool[it++];
	}
	node<T> *push(node<T> *t) {
		if (t == nullptr || t->lazy == id2) return t;
		if (t->size > 1) {
			if (t->l == nullptr) t->l = new_node(t->size / 2);
			if (t->r == nullptr) t->r = new_node(t->size / 2);
			t->l->lazy = merge2(t->l->lazy, t->lazy);
			t->r->lazy = merge2(t->r->lazy, t->lazy);
		}
		t->val = merge2(t->val, t->lazy);
		t->lazy = id2;
		return t;
	}
	node<T> *suc(ll l, ll r, node<T> *t, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return t;
		if (t == nullptr) t = new_node(ub - lb);
		if (l <= lb && ub <= r) {
			t->lazy = merge2(t->lazy, val);
			return t;
		}
		t = push(t);
		int c = (lb + ub) / 2;
		t->l = suc(l, r, t->l, lb, c, val);
		t->r = suc(l, r, t->r, c, ub, val);
		t->val = merge1(t->l == nullptr ? id1 : merge2(t->l->val, t->l->lazy), t->r == nullptr ? id1 : merge2(t->r->val, t->r->lazy));
		return t;
	}
	T sub(ll l, ll r, node<T> *t, ll lb, ll ub) {
		if (t == nullptr || ub <= l || r <= lb) return id1;
		t = push(t);
		if (l <= lb && ub <= r) return t->val;
		int c = (lb + ub) / 2;
		return merge1(sub(l, r, t->l, lb, c), sub(l, r, t->r, c, ub));
	}
public:
	DynamicLazySegmentTree(ll n_, T id1_, T id2_, func_t merge1_, func_t merge2_, int PMAX = 1e7)
		: n(size(n_)), id1(id1_), id2(id2_), merge1(merge1_), merge2(merge2_), root(nullptr), pool(PMAX), it(0) {}
	void update(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int n, q, com, s, t, x;
	cin >> n >> q;
	DynamicLazySegmentTree<int> lst(n, INT_MAX, -1, minQ, [](int l, int r) { return r != -1 ? r : l; }, 3e5);
	while (q--) {
		cin >> com;
		if (com) {
			cin >> s >> t;
			printf("%d\n", lst.find(s, t));
		}
		else {
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 8952
#include <cassert>
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define rep(i,n) for(int i=0;i<int(n);i++)

string concat(const vector<string>& ss,char sep)
{
	string res;
	rep(i,ss.size()){
		res+=ss[i];
		if(i<ss.size()-1) res+=sep;
	}
	return res;
}

string parse(const map<string,set<string>>& files,const string& path)
{
	vector<string> dirs(1,"");
	for(int i=0,j=1;i<path.size();i=j++)
		for(;;j++) if(j==path.size() || path[j]=='/'){
			string basename=path.substr(i+1,j-(i+1));
			if(j==path.size()){
				if(basename=="" || basename=="." || basename==".."){
					if(basename==".."){
						dirs.pop_back();
						if(dirs.empty())
							throw "not found";
					}
					basename="index.html";
					if(!files.at(concat(dirs,'/')).count(basename))
						throw "not found";
					dirs.push_back(basename);
					if(files.count(concat(dirs,'/')))
						throw "not found";
					return concat(dirs,'/');
				}
				else{
					if(!files.at(concat(dirs,'/')).count(basename))
						throw "not found";
					dirs.push_back(basename);
					if(!files.count(concat(dirs,'/')))
						return concat(dirs,'/');
					else{
						if(!files.at(concat(dirs,'/')).count("index.html"))
							throw "not found";
						dirs.push_back("index.html");
						if(files.count(concat(dirs,'/')))
							throw "not found";
						return concat(dirs,'/');
					}
				}
			}
			else{
				if(basename==".")
					;
				else if(basename==".."){
					dirs.pop_back();
					if(dirs.empty())
						throw "not found";
				}
				else{
					dirs.push_back(basename);
					if(!files.count(concat(dirs,'/')))
						throw "not found";
				}
			}
			break;
		}
	assert(0);
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		map<string,set<string>> files;
		rep(_,n){
			string path; cin>>path;
			for(int i=0,j=1;i<path.size();i=j++)
				for(;;j++) if(j==path.size() || path[j]=='/'){
					string dirname=path.substr(0,i);
					string basename=path.substr(i+1,j-(i+1));
					files[dirname].insert(basename);
					break;
				}
		}
		
		for(int i=0;i<m;i++){
			string path1,path2; cin>>path1>>path2;
			try{
				path1=parse(files,path1);
				path2=parse(files,path2);
				cout<<(path1==path2?"yes":"no")<<endl;
			}
			catch(const char* message){
				cout<<message<<endl;
			}
		}
	}
}

Measured memory_bytes: 1304
using System;

public class AtCoderB
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string s;
        string t;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            s = words[0];
            t = words[1];
        }

        string answer = "";

        for (int i = 0; i < n; i++)
        {
            answer += s.Substring(i, 1) + t.Substring(i, 1);
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13140
import copy
s=list(input())
mylist=[""]*(len(s)+(len(s)-1))
for i in range(0,len(s)):
    mylist[2*i]=s[i]
ans=0
for i in range(2**(len(s)-1)):
    l=copy.deepcopy(mylist)
    for j in range(len(s)-1):
        if (i>>j&1):
            l[2*j+1]="+"
    ans+=eval("".join(l))
print(ans)

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

using namespace std;

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

using ll = long long;
const int N = 1e7;

class LinearSieve {
    public:
        vector<int> lp, pr;
        LinearSieve() {}
        LinearSieve(int n) {
            lp.resize(n + 1);
            lp[0] = -1, lp[1] = -1;
            init(n);
        }

        void init(int x) {
            FOR (i, 2, x + 1) {
                if (lp[i] == 0) {
                    lp[i] = i;
                    pr.push_back(i);
                }
                for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && (ll)i * pr[j] <= x; ++j) {
                    lp[i * pr[j]] = pr[j];
                }
            }
        }

        bool isPrime(int x) {
            return lp[x] == x;
        }

        vector<int> factorList(int x) {
            vector<int> res;
            while (x != 1) {
                res.push_back(lp[x]);
                x /= lp[x];
            }

            return res;
        }

        vector<pair<int, int> > factorize(int x) {
            vector<int> p = factorList(x);
            if (p.size() == 0) return {};
            vector<pair<int, int> > res(1, make_pair(p[0], 0));
            rep (i, p.size()) {
                if (res.back().first == p[i]) {
                    res.back().second++;
                } else {
                    res.emplace_back(p[i], 1);
                }
            }

            return res;
        }
};

int main() {
    LinearSieve ls = LinearSieve(N);
    vector<int> sum(N + 10);
    FOR (i, 1, N + 1) if (ls.isPrime(i) && ls.isPrime((i + 1) / 2)) sum[i]++;
    FOR (i, 1, N + 1) sum[i] += sum[i - 1];
    int q;
    cin >> q;
    rep (_, q) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 82412
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

U = 10**6
is_prime = np.zeros(U, np.bool_)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, U, 2):
    if p * p >= U:
        break
    if is_prime[p]:
        is_prime[p+p::p] = 0

primes = is_prime.nonzero()[0]


def factor(N):
    div = primes[N % primes == 0]
    for p in div:
        e = 0
        while N % p == 0:
            e += 1
            N //= p
        yield (p, e)
    if N != 1:
        yield (N, 1)


A = np.zeros(100, np.int32)
for i in range(14):
    k = i * (i + 1) // 2
    A[k] = i
np.maximum.accumulate(A, out=A)

x = 0
for p, e in factor(N):
    x += A[e]
print(x)


Measured memory_bytes: 29084
from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    # init
    input = sys.stdin.readline
    h,w,d = map(int,input().split())
    dic = defaultdict(list)
    for i in range(h):
        nums = [int(x) for x in input().split()]
        for j,num in enumerate(nums):
            dic[int(num)] = [i,j]
    # memo
    ls = [0 for i in range(w*h+1)]
    for i in range(d+1,w*h+1):
        before,after = dic[i-d],dic[i]
        diff = abs(after[0]-before[0]) + abs(after[1]-before[1])
        ls[i] = ls[i-d]+ diff
    # ans
    q = int(input())
    for i in range(q):
        l,r = map(int,input().split())
        print(ls[r]-ls[l])
if __name__ == "__main__":
    main()

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

int main(){   
   int n,m;
   cin >> n >> m;
   int ans = 0;
   ans += n*(n-1)/2;
   ans += m*(m-1)/2;
   cout << ans << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
int a[123456];
signed main() {
	string s; cin >> s;
	int r = 0, l = 0, m = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			r++;
			if (s[i + 1] == 'L') {
				a[i] += (r+1) / 2;
				a[i + 1] += r / 2;
				r = 0; m = i;
			}
		}
		else if (s[i] == 'L') {
			l++;
			if (i == s.size() - 1 || s[i + 1] == 'R') {
				a[m] += l / 2;
				a[m + 1] += (l + 1) / 2;
				l = 0;
			}
		}
	}
	for (int i = 0; i < s.size(); i++) {
		if (i)cout << ' ';
		cout << a[i];
	}cout << endl;
}

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

 
int main() {
   int n;
   cin>>n;
   ll sum=0;

   vector<pair<ll,ll>> BA(n);
   rep(i,n){
      cin>>BA[i].second>>BA[i].first;
   }
   sort(BA.begin(),BA.end());
   rep(i,n){
       sum+=BA[i].second;
       if(sum>BA[i].first){
           cout<<"No"<<endl;
           return 0;
       }

   }
   cout<<"Yes"<<endl;
}

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

int main(){
    int X;
    std::cin >> X;
    
    int num500, mun5;
    num500 = X / 500;
    X = X % 500;
    mun5 = X / 5;
    
    int ans = num500 * 1000 + mun5 * 5;
    std::cout << ans << std::endl;
}



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

long long segTree[300000] = {};
long long lazy[300000] = {};
int segSize = 1;

int n, q;

void init(){
  while(segSize <= n) segSize *= 2;
  return;
}

void eval(int k, int l, int r){

  if(lazy[k] != 0){
    segTree[k] += lazy[k];

    if(r-l > 1){
      lazy[2*k+1] += lazy[k] / 2;
      lazy[2*k+2] += lazy[k] / 2;
    }

    lazy[k] = 0;
  }

  return;
}

void add(int a, int b, long long x, int k = 0, int l = 0, int r = -1){

  if(r == -1) r = segSize;

  eval(k,l,r);

  if(r <= a || b <= l) return;

  if(a <= l && r <= b){
    lazy[k] += (r-l) * x;
    eval(k,l,r);
  }else{
    add(a, b, x, 2*k+1, l, (l+r)/2);
    add(a, b, x, 2*k+2, (l+r)/2, r);
    segTree[k] = segTree[2*k+1] + segTree[2*k+2];
  }
  return;
}


long long getSum(int a, int b, int k = 0, int l = 0, int r = -1){
  if(r == -1) r = segSize;

  eval(k, l, r);

  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return segTree[k];
  return getSum(a, b, 2*k+1, l, (l+r)/2) + getSum(a, b, 2*k+2, (l+r)/2, r);
}

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

  init();

  int p, a, b, c;
  for(int i = 0;i < q;i++){
    cin >> p;
    if(p == 0){
      cin >> a >> b >> c;
      add(a, b+1, c);
    }else{
      cin >> a >> b;
      cout << getSum(a, b+1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6264
#!/usr/bin/env python3
import sys
from collections import deque

def solve(N: int, S: str):
    rp = 0
    gp = 0
    bp = 0
    rsum = [0]*(N+1)
    bsum = [0]*(N+1)
    gsum = [0]*(N+1)

    for i, x in enumerate(S[::-1]):
        if x ==  "R": rp = 1
        elif x =="G": gp = 1
        else: bp = 1
        rsum[N-1-i] = rsum[N-1-i+1] + rp
        gsum[N-1-i] = gsum[N-1-i+1] + gp
        bsum[N-1-i] = bsum[N-1-i+1] + bp
        rp = 0
        gp = 0
        bp = 0
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if S[i] != S[j]:
                if j+j-i<N: k = S[j+j-i]
                else: k = ""
                if (S[i] == "R" and S[j] == "B") or (S[j] == "R" and S[i] == "B"):
                    ans += gsum[j] - (k=="G")*1
                elif (S[i] == "R" and S[j] == "G") or (S[j] == "R" and S[i] == "G"):
                    ans += bsum[j] - (k=="B")*1
                elif (S[i] == "G" and S[j] == "B") or (S[j] == "G" and S[i] == "B"):
                    ans += rsum[j] - (k=="R")*1

    print(ans)
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 69292
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int N, x[100], i, ans = 1000000000, p, tai;
    cin >> N;
    for (i=0; i<N;i++){
        cin >> x[i];
    }
    for (p=1; p<=100; p++){
        tai = 0;
        for (i=0; i<N;i++){
            tai += (x[i]-p)*(x[i]-p);
        }
        if (ans >= tai) ans = tai;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
def create_array(n,ary)
  return ary[n] = 1 if n == 0
  ary[n] = create_array(n-1,ary)*2
  ary[n]
end
ary = []
create_array(7,ary)
ary.each_cons(2) {|a,b| puts a if (a...b).include?(n)}


Measured memory_bytes: 14320
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		String s;
		Stack<Character> stack = new Stack<Character>();
		W:while (true) {
			stack.clear();
			s = sc.nextLine();
			if (s.equals(".")) break;
			char[] letters = s.toCharArray();
			for (int i = 0; i < letters.length-1; i++) {
				switch(letters[i]) {
				case '(':
					stack.add('('); break;
				case ')':
					if (stack.isEmpty() || stack.pop() != '(') {
						out.println("no");
						continue W;
					}
					break;
				case '[':
					stack.add('['); break;
				case ']':
					if (stack.isEmpty() || stack.pop() != '[') {
						out.println("no");
						continue W;
					}
					break;
				}
			}
			if (stack.isEmpty())
				out.println("yes");
			else
				out.println("no");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 34264
#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;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int a,b;cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> P(N), Q(N);
    for (int& x : P) cin >> x;
    for (int& x : Q) cin >> x;
    vector<int> X(N);
    iota(X.begin(), X.end(), 1);
    int a, b;
    int i = 0;
    do {
      if (X == P) a = i;
      if (X == Q) b = i;
      ++i;
    } while (next_permutation(X.begin(), X.end()));
    int res = abs(a - b);
    cout << res << endl;
  }
  return 0;
}


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

int main()
{
  int n;
  cin>>n;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<vector<int>> v(n,vector<int>(3));
  for(vector<int>&x: v)
  cin>>x[0]>>x[1]>>x[2];

  //dp[1]=abs(v[1]-v[0]);
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<3;j++)
    v[i][j]+=max(v[i-1][(j+1)%3],v[i-1][(j+2)%3]);
  }
  int maxm=max(v[n-1][0],max(v[n-1][1],v[n-1][2]));
  cout<<maxm<<endl;
  return 0;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int s[3][100010];

int dp[3][100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) cin >> s[0][i] >> s[1][i] >> s[2][i];
    dp[0][0] = s[0][0];
    dp[1][0] = s[1][0];
    dp[2][0] = s[2][0];
    rep(i, N - 1) {
        rep(j, 3) {
            dp[j][i + 1] = s[j][i + 1] + max(dp[(j + 1) % 3 ][i], dp[(j + 2) % 3][i]);
        }
    }
    cout << max({dp[0][N - 1], dp[1][N - 1], dp[2][N - 1]}) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	char s[302][302];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> s[i][j];
		}
	}
	int ans = 0;
	for (int t = 0; t < n; t++) {
		bool flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				flag &= s[i][(j + t) % n] == s[j][(i + t) % n];
			}
		}
		if (flag) ans += n;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    vector<int> vs(26);
    vector<int> vt(26);
    
    for(int i=0; i<(int)s.size(); i++){
        int index_s = s.at(i) - 97;
        int index_t = t.at(i) - 97;
        vs.at(index_s) += 1;
        vt.at(index_t) += 1;
    }
    sort(vs.begin(),vs.end());
    sort(vt.begin(),vt.end());
    for(int i=0; i<26; i++){
        if(vs.at(i) != vt.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3924
def digit6(n):
  return ("000000" + str(n))[-6:]

def main():
  N, M = list(map(lambda n: int(n), input().split(" ")))
  CITY = []
  for i in range(M):
    tmp = input().split(" ")
    CITY.append({
      "pref": int(tmp[0]),
      "year": int(tmp[1]),
      "no": i + 1
    })
    
  CITY.sort(key=lambda c: (c["pref"], c["year"]))
  
  order = 0
  pref = ""
  for c in CITY:
    if pref != c["pref"]:
      pref = c["pref"]
      order = 1
    else:
      order += 1
    c["id"] = digit6(pref) + digit6(order)
  
  CITY.sort(key=lambda c: c["no"])
  for i in range(len(CITY)):
    print(CITY[i]["id"])
      
    
  
main()

Measured memory_bytes: 50924
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();

		int cnt = 0;
		for(int i = a; i >= 0; i--) {
			int suma = i * 500;
			if(suma == x) {
				cnt++;
				continue;
			} else if(suma > x) {
				continue;
			}
			for(int j = b; j >= 0; j--) {
				int sumb = suma + j * 100;
				if(sumb == x) {
					cnt++;
					continue;
				} else if(sumb > x) {
					continue;
				}

				for(int k = c; k >= 0; k--) {
					int sumc = sumb + k * 50;
					if(sumc == x) {
						cnt++;
						continue;
					} else if(sumc > x) {
						continue;
					} else {
						break;
					}
				}
			}
		}

		System.out.println(cnt);
	}
}

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

using namespace std;
using ll = long long;

int main()
{
	int n, i, t, c = 0;;
	vector<int> a;
	ll sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n * 3; i++) {
		scanf("%d", &t);
		a.push_back(t);
	}

	sort(a.begin(), a.end());

	for (i = n * 3 - 2; c < n; i -= 2) {
		sum += a[i];
		c++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 2420
import numpy as np

H,W=map(int,input().split())
S=np.array([list(input()) for _ in range(H)])=='.'
D=np.zeros((H,W),dtype=int)
U=np.zeros((H,W),dtype=int)
L=np.zeros((H,W),dtype=int)
R=np.zeros((H,W),dtype=int)

for i in range(H):
  U[i]=(U[i-1]+1)*S[i]
  D[-i-1]=(D[-i]+1)*S[-i-1]
for i in range(W):
  L[:,i]=(L[:,i-1]+1)*S[:,i]
  R[:,-i-1]=(R[:,-i]+1)*S[:,-i-1]
#print(L)
print(np.max(U+D+L+R)-3)

Measured memory_bytes: 219832
n, k = gets.chomp.split(" ").map{|i|i.to_i}

def souwa(n)
  return n*(n+1)/2
end

cnt = 0
k.upto(n+1) do |i|
  min = souwa(i-1)
  max = souwa(n) - souwa(n-i)
  cnt += max - min + 1
end

puts cnt  % ((10**9)+7)
  

Measured memory_bytes: 14324