akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	
	int n;
	scanf("%d", &n);
	
	int divide = n/2;
	// printf("divide: %d\n", divide);
	char str[110];
	scanf("%s", str);
	
	if(n%2 != 0){
		printf("No");
		return 0;
	}

	for(int i = 0 ; str[i] != '\0' ; i++){
		if(i == divide){
			break;
		}
		if(str[i] != str[i+divide]){
			//printf("Indexing: %d\n", i+divide);
			//printf("Where: %d\n", i);
			printf("No\n");
			return 0;
		}
	}
	printf("Yes");
	
	return 0;
}

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

int main() {
  int A=0,B=0;
  int count = 0;
  
  cin >> A >> B;
  
  if( ( A < 10000 ) || ( A > 99999 ) ){
    return -1;
  }
  if( ( B < 10000 ) || ( B > 99999 ) ){
    return -1;
  }
  
  for(int i = A; i < B + 1; i++ ){
    if( ( i / 10000 ) == ( i % 10 ) ){
      if( ( ( i % 10000 ) / 1000 ) == ( ( i % 100 ) / 10 ) ){
        count++;
      }
    } 
  }
  
  cout << count << endl;
  
  return 0;
}


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

int main() {
  int A, N, S, X;
  cin >> N >> A;
  if (A == 0) {
    S = N % 500;
      if (S == 0) {
        cout << "Yes" << endl;
      }
    	else {
          cout << "No" << endl;
        }
  }
	else {
      
      S = N / 500;
      S = S * 500;
      X = N - S;
      	if (X <= A){
          cout << "Yes" << endl;
        }
      	else {
          cout << "No" << endl;
        }
    }
  
  
      
  // ここにプログラムを追記
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>g[1100];
int c[1100];
int deg[1100];
int grundy[1100];
void dfs(int a){
	vector<int> chi;
	for(int i=0;i<g[a].size();i++){
		if(!~deg[g[a][i]])dfs(g[a][i]);
		chi.push_back(deg[g[a][i]]);
	}
	std::sort(chi.begin(),chi.end());
	int next=0;
	for(int i=0;i<chi.size();i++){
		if(i&&chi[i]==chi[i-1])continue;
		if(chi[i]!=next)break;
		next++;
	}
	deg[a]=next;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
	}
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
	}
	for(int i=0;i<a;i++){
		deg[i]=-1;
	}
	for(int i=0;i<a;i++){
		if(!~deg[i]){
			dfs(i);
		}
	}
	for(int i=0;i<a;i++)grundy[deg[i]]^=c[i];
	for(int i=0;i<1100;i++)if(grundy[i]){printf("1\n");return 0;}
	printf("2\n");
}

Measured memory_bytes: 1152
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef pair<long long int, int> P;

long long int INF = 100000000000000000LL;

int main(){
	
	long long int K, A, B;
	cin >> K >> A >> B;
	
	if(K <= A){
		cout << "1" << endl;
		return 0;
	}
	K -= A;
	
	if(A <= B){
		cout << "-1" << endl;
		return 0;
	}
	
	cout << (K / (A - B) + (K % (A - B) != 0)) * 2 + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  string s[100];
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(i<50) s[i].push_back('.');
      else s[i].push_back('#');
    }
  }
  int cnt = 0;
  for(int i = 0; i < 50; i += 2){
    if(cnt == b-1) break;
    for(int j = 0; j < 100; j += 2){
      if(cnt == b-1) break;
      s[i][j] = '#';
      cnt++;
    }
  }
  cnt = 0;
  for(int i = 51; i < 100; i += 2){
    if(cnt == a-1) break;
    for(int j = 0; j < 100; j += 2){
      if(cnt == a-1) break;
      s[i][j] = '.';
      cnt++;
    }
  }
  cout << 100 << " " <<  100 << endl;
  for(int i = 0; i < 100; i++){
    cout << s[i] << endl;
  }

  return 0;
}


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

using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;
    map<long long, long long> count;
    for(int i = 0; i < N; i++){
        long long A;
        cin >> A;
        count[A]++;
    }
    for(int i = 0; i < M; i++){
        long long B, C;
        cin >> B >> C;
        while(B > 0){
            if(count.begin() -> first < C){
                int n;
                n = min(B, count.begin() -> second);
                B -= n;
                count.begin() -> second -= n;
                if(count.begin() -> second == 0) count.erase(count.begin() -> first);
                count[C] += n;
            }
            if(count.begin() -> first >= C) break;
        }
    }
    long long ans = 0;
    for(auto itr = count.begin(); itr != count.end(); itr++) ans += (itr -> first) * (itr -> second);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ULL;

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        /*
        vector<ULL> dp(11, 0);
        dp[0] = 0;
        dp[1] = 7;
        for(int i = 2; i <= 10; ++i) 
            dp[i] = 7 * (dp[i-1] + dp[i-2]);

        int arr[] = {0, 1, 2, 3, 5, 7, 8, 9};
        for(int i = 10; i >= 1; --i) {
            cout << arr[N / dp[i]];
            N %= dp[i];
        }
        cout << arr[N] << endl;
        */

        vector<int> digits;
        while(N) {
            digits.push_back(N % 8);
            N /= 8;
        }
        for(int i = digits.size()-1; i >= 0; --i) {
            cout << "01235789"[digits[i]];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 896
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    #b = list(map(int, input().split()))
    from itertools import combinations
    ans = 0
    for x,y,z in combinations(a, 3):
        if x == y or y == z:continue
        if x+y > z and x+z > y and y+z > x:
            ans += 1
    print(ans)


Measured memory_bytes: 67732
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    int h, w;
    int c[15][15];
    int d[15][15];
    int a[210][210];
     
    void warshall_floyd()
    {
    	for (int k = 0; k < 10; k++) {
    		for (int i = 0; i < 10; i++) {
    			for (int j = 0; j < 10; j++) {
    				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    			}
    		}
    	}
    }
     
    void dijkstra(int s)
    {
    	//priority_queue<int, vector<int>, greater<int>> q;
     
    }
     
    int main()
    {
    	cin >> h >> w;
    	for (int i = 0; i < 10; i++) {
    		for (int j = 0; j < 10; j++) {
    			cin >> c[i][j];
    			d[i][j] = c[i][j];
    		}
    	}
    	for (int i = 0; i < h; i++) {
    		for (int j = 0; j < w; j++) {
    			cin >> a[i][j];
    		}
    	}
    	//cout << "a" << endl;
    	ll sum = 0;
     
    	warshall_floyd();
    	/*
    	for (int i = 0; i < 10; i++) {
    		for (int j = 0; j < 10; j++) {
    			cout << d[i][j] << " ";
    		}
    		cout << endl;
    	}
    	*/
    	for (int i = 0; i < h; i++) {
    		for (int j = 0; j < w; j++) {
    			int k = a[i][j];
    			if (k != -1)sum += d[k][1];
    		}
    	}
    	cout << sum << endl;
     
     
    	return 0;
    }

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=505;
int a[N][N],H,W,h,w,lim=1e9,op,b[N];
void solve(int n,int l){
	b[1]=lim-1;
	rep(i,2,n){
		int sum=0;
		for(int j=i;j>=max(1,i-l+1);j--)sum+=b[j];
		if(i<l)b[i]=lim-1-sum;
		else b[i]=-1-sum;
	}
}
int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h==0 && W%w==0){puts("No");return 0;}
	if(W%w!=0)solve(W,w);
	else op=1,solve(H,h);
	
	if(!op){
		rep(i,1,H)rep(j,1,W)a[i][j]=b[j];
	}else{
		rep(j,1,W)rep(i,1,H)a[i][j]=b[i];
	}
	puts("Yes");
	rep(i,1,H){
		rep(j,1,W){printf("%d",a[i][j]);if(j!=W)printf(" ");}
		puts("");
	}
}

Measured memory_bytes: 3840
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let () = Scanf.scanf "%d\n" @@ fun t ->
  for i = 0 to t - 1 do
    Scanf.scanf "%d %d %d %d\n" @@ fun a b c d ->
      print_endline @@
      if a < b || d < b then "No"
      else if b < c then "Yes"
      else if
        let g = gcd b d in
        c < b - g + a mod g then "No"
      else "Yes"
  done



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

int main() {
    int N;
    cin >> N;
    switch(N % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            return 0;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            return 0;
        case 3:
            cout << "bon" << endl;
            return 0;
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,l,r,ans=0;
  cin >> n;
  REP(i,n) {
    cin >> l >> r;
    ans+=r-l+1;
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[300][300],d=0,f=0,g,h,j,i,k;
	char z[300][300];
	while(1){
		f=0;
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++)
			scanf("%s",z[i]);
		for(i=0;i<a;i++){
			for(j=0;j<a;j++){
				if(z[i][j]=='1'){
					for(k=0;k<a;k++){
						if(i-k==-1||j+k==a) break;
						if(z[i-k][j+k]=='1') d++;
						else break;
					}
					if(f<d) f=d;
					d=0;
					for(k=0;k<a;k++){
						if(i+k==a||j+k==a) break;
						if(z[i+k][j+k]=='1') d++;
						else break;
					}
					if(f<d) f=d;
					d=0;
					for(k=0;k<a;k++){
						if(i+k==a) break;
						if(z[i+k][j]=='1') d++;
						else break;
					}
					if(f<d) f=d;
					d=0;
					for(k=0;k<a;k++){
						if(j+k==a) break;
						if(z[i][j+k]=='1') d++;
						else break;
					}
					if(f<d) f=d;
					d=0;
				}
			}
		}
		printf("%d\n",f);
	}
	return 0;
}

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

int main() {
    int n, k, okashi_count[100] = {0}, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            a--;
            okashi_count[a]++;
        }
    }
    for(int i = 0; i < n; i++){
        if(okashi_count[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    cout<<(6.28318530717958623200*t);
    return 0;
}

Measured memory_bytes: 3792
N = int(input())
v_list = list(map(int,input().split()))

# 合成すると総価値が下がるので、価値の低いものから使っていくとダメージが少ないはず。。。
# N<50なので愚直にやっていいはず
v_list.sort()

s = v_list.pop(0)

for v in v_list :
    s = (s + v) / 2.0

print(s)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[110],b[110];
int main(){
	ll n,m;
	scanf("%lld%lld%lld%lld",&n,&m,a,b);
	rep(i,1,n+1)scanf("%lld",a+i);
	rep(i,1,m+1)scanf("%lld",b+i);
	sortup(a,n+1);
	sortup(b,m+1);
	puts(a[n]<b[0]?"No War":"War");
}

Measured memory_bytes: 128
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


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


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    a = LI()
    dp = [0] * N
    dp[1] = max(a[0], a[1])
    c = a[0]

    for i in range(2, N):
        if i % 2 == 0:
            c += a[i]
            dp[i] = max(dp[i-2] + a[i], dp[i-1])
        else:
            dp[i] = max(dp[i-2] + a[i], c)

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 102332
#include<stdio.h>
main(){
  int a,b,c;
  int meiji=1868,taisho=1912,showa=1926,heisei=1989;
  while(scanf("%d %d %d",&a,&b,&c)!=EOF){
    if((a<=1867)||(a==1868&&b<9)||(a==1868&&b==9&&c<=7)){
      printf("pre-meiji\n");
    }else if((a<=1911)||(a==1912&&b<7)||(a==1912&&b==7&&c<=29)){
      printf("meiji %d %d %d\n",a-meiji+1,b,c);
    }else if((a<=1925)||(a==1926&&b<12)||(a==1926&&b==12&&c<=24)){
      printf("taisho %d %d %d\n",a-taisho+1,b,c);
    }else if((a<=1988)||(a==1989&&b==1&&c<=7)){
      printf("showa %d %d %d\n",a-showa+1,b,c);
    }else {
      printf("heisei %d %d %d\n",a-heisei+1,b,c);
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

  string s;
  cin >> s;

  int n = s.length();

  int cnt_a, cnt_b, cnt_c;
  cnt_a = 0;
  cnt_b = 0;
  cnt_c = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i]=='a') cnt_a++;
    else if(s[i] == 'b') cnt_b++;
    else cnt_c++;
  }

  bool ok = true;

  int div3 = n/3;

  if(cnt_a < div3 || cnt_a > div3+1) ok = false;
  if(cnt_b < div3 || cnt_b > div3+1) ok = false;
  if(cnt_c < div3 || cnt_c > div3+1) ok = false;

  if(ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }


  return 0;
}


Measured memory_bytes: 512
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//  cout <<  s.at(1)-'0'-49  <<endl;
int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int maxcount=0; 

  for(int i=1;i<n;i++){
    vector<int>mae(26);
    vector<int>usi(26);
    int count=0;

    for(int j=0;j<i;j++){
      mae.at(s.at(j)-'0'-49) = 1;      
    }
    for(int k=i;k<n;k++){
      usi.at(s.at(k)-'0'-49) = 1;
    }

    for(int m=0;m<26;m++){
     if(mae.at(m) == 1 && usi.at(m) == 1) count++; 
    }
    maxcount = max(maxcount,count);
  }
  cout << maxcount <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n;
    scanf("%d", &n);
    long double te;
    vector< vector<long double> > dp(n+1, vector<long double>(n+1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i){
        scanf("%Lf", &te);
        dp[i][0] = dp[i-1][0]*(1-te);
        //cout << dp[i][0] << ' ';
        for (int j = 1; j <= i; ++j){
            dp[i][j] = dp[i-1][j-1]*te + dp[i-1][j]*(1-te);
            //cout << dp[i][j] << ' ';
        }
        //cout << endl;
    }
    te = 0;
    for (int i = n/2+1; i <= n; ++i)
        te += dp[n][i];
    printf("%0.10Lf", te);
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 141056
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    double res1 = W * H / 2.0;
    int res2;
    if(W/2.0 == x && H/2.0 == y) res2 = 1;
    else res2 = 0;
    cout << res1 << " " << res2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

bool flag[100000];
int i, n, a[100000], ans, curr;

int main()
{
    sf("%d", &n);
    for (i = 0; i < n; i++) {
        sf("%d", &a[i]);
        --a[i];
    }
    while (curr != 1 && flag[curr] == false) {
        ++ans;
        flag[curr] = true;
        curr = a[curr];
    }
    if (curr == 1) pf("%d\n", ans);
    else pf("-1\n");
    return 0;
}

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

int main(){
	double W,H,x,y;
	cin>>W>>H>>x>>y;
	double S;
	int ans;
	if((W/2==x) and (H/2==y))ans = 1;
	else ans = 0;
	S = W*H/2;
	cout<<S<<" "<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    int d[]={1000,100,10,1};
    char m[]={'m','c','x','i'};
    void run(){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	for(int attend=0;attend<n;attend++){
	    System.out.println(toMCXI(toDecimal(sc.next().toCharArray())+toDecimal(sc.next().toCharArray())));
	}
    }
    int toDecimal(char[] mcxi){
	int x=1;
	int decimalVal=0;
	for(int i=0;i<mcxi.length;i++){
	    if(Character.isDigit(mcxi[i]))x=mcxi[i]-'0';
	    else{
		for(int j=0;j<4;j++){
		    if(mcxi[i]==m[j])decimalVal+=x*d[j];
		}
		x=1;
	    }
	}
	//System.out.println(decimalVal);
	return decimalVal;
    }
    String toMCXI(int decimalVal){
	String mcxi=new String();;
	int temp;
           for(int j=0;j<4;j++){
	       temp=decimalVal/d[j];
	       if(temp>1)mcxi+=temp;
	       if(temp>=1)mcxi+=m[j];
	       decimalVal%=d[j];
	   }
	   return mcxi;
    }
    public static void main(String[] args){
	new Main().run();
    }
}
//imitated nanikaka's

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力1をnに入れる
		String s = sc.next();

		int n = s.length() -1;
		long ans = 0;

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

			//ビット全探索で文字列Sに"+"を挿入していく
			StringBuilder sb = new StringBuilder(s);
			for (int j=n-1; j>=0; j--) {
				if ((1 & i >> j) == 1) {
					sb.insert(j+1, "+");
				}
			}

			//"+"入りの文字列をsplitして足し合わせる
			String[] str = sb.toString().split("\\+",0);
			for (int j=0; j<str.length;j++) {
				ans += Long.parseLong(str[j]);
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
	long double l,m,ans;
    cin>>l;
    m=l/3;
    ans=m*m*m;
    cout<<setprecision(10)<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,c,d,p,x,y;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
    x=a*p;
    if(p<=c)
    {
        y=b;
    }
    else
    {
        y=b+(p-c)*d;
    }
    if(x<y)
    {
        printf("%d\n",x);
    }
    else
    {
        printf("%d\n",y);
    }
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define arr array

using namespace std;

const int e = 2e6 + 69;
const ll mod = 1e9 + 7;

ll a[e];
arr<int, 2>b[e];

//beginner 1999 128



int main()
{
     ll a;
     cin >> a;
     cout << a + a*a + a*a*a;
}


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

int N;
string s;
ll K;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> s >> K;
    N = s.length();

    char c = s[0];
    bool all = true;
    for (int i = 0; i < N; i++)
        if (s[i] != c)
            all = false;

    if (all)
    {
        ll ct = N * (ll) K;
        cout << ct / 2 << "\n";
        return 0;
    }

    int nlo = 0, nhi = N - 1;
    while (s[nlo] == c)
        nlo++;
    while (s[nhi] == c)
        nhi--;
    nhi = N - 1 - nhi;

    ll ans = (nlo / 2) + (nhi / 2);
    int cc = 1;
    for (int i = nlo + 1; i < N - nhi; i++)
    {
        if (s[i] == s[i-1])
        {
            cc++;
        }
        else
        {
            ans += K * (cc / 2);
            cc = 1;
        }
    }
    ans += K * (cc / 2);
    ans += (K - 1) * ((nlo + nhi) / 2);
    cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var numbers = new[] { 1, 2, 4, 8, 16, 32, 64, };
            var result = 0;

            foreach (var num in numbers)
            {
                if (num <= n)
                {
                    result = num;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool a[10];
int main() {
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		ll x;
		cin>>x;
		a[x]=true;
	}
	for(int i=n;;i++){
		ll now=i;
		bool ch=true;
		while(now!=0){
			ll sum=now%10;
			if(a[sum]){
				ch=false;
				break;
			}
			now/=10;
		}
		if(ch){
			cout << i;
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			list = new ArrayList<List<Pair>>();
			for (int i = 0; i < 6; i++) {
				list.add(new ArrayList<Pair>());
			}
			boolean[] b = new boolean[6];
			for (int i = 0; i < h; i++) {
				char[] cs = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (cs[j] == 'S') {
						sy = i;
						sx = j;
					} else if (cs[j] == 'G') {
						gy = i;
						gx = j;
					} else if (cs[j] != '.') {
						int c = Character.getNumericValue(cs[j]);
						list.get(c).add(new Pair(i, j));
						b[c] = true;
					}
				}
			}
			int sum = 0;
			for (int i = 1; i < 6; i++) {
				if (b[i])
					sum++;
			}
			min = Integer.MAX_VALUE;
			int index = -1;
			for (int i = 1; i < 6; i++) {
				int cos = slove(i, i == 1 ? 5 : i - 1);
				if (min > cos) {
					min = cos;
					index = i;
				}
			}
			System.out.println(index == -1 ? "NA" : index + " " + min);

		}

	}

	private int slove(int k, int g) {
		PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
		int s = k == 5 ? 1 : k + 1;
		for (int i = 0; i < list.get(s).size(); i++) {
			int y = list.get(s).get(i).y;
			int x = list.get(s).get(i).x;
			int dis = Math.abs(y - sy) + Math.abs(x - sx);
			int gdis = Math.abs(y - gy) + Math.abs(x - gx);
			pq.add(new Pair(y, x, dis, k + 1, dis + gdis));
		}
		while (!pq.isEmpty()) {
			Pair pair = pq.poll();
			int y = pair.y;
			int x = pair.x;
			int cost = pair.cost;
			int id = pair.id;
			int tmpid = id > 5 ? id - 5 : id;
			if (min <= pair.md)
				return Integer.MAX_VALUE;
			if (id == 10) {
				return cost;
			}
			if (tmpid != g) {
				for (Pair i : list.get(tmpid == 5 ? 1 : tmpid + 1)) {
					int dis = Math.abs(y - i.y) + Math.abs(x - i.x);
					int gdis = Math.abs(i.y - gy) + Math.abs(i.x - gx);
					pq.add(new Pair(i.y, i.x, cost + dis, id + 1, cost + dis
							+ gdis));
				}
			} else {
				int dis = Math.abs(y - gy) + Math.abs(x - gx);
				pq.add(new Pair(0, 0, cost + dis, 10, cost));
			}
		}
		return Integer.MAX_VALUE;
	}

	List<List<Pair>> list;
	int sy;
	int gy;
	int sx;
	int gx;
	int min;

	class Pair implements Comparable<Pair> {
		int y;
		int x;
		int cost;
		int id;
		int md;

		@Override
		public int compareTo(Pair o) {
			if (this.md == o.md)
				return o.id - this.id;
			return this.md - o.md;
		}

		public Pair(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

		public Pair(int y, int x, int cost, int id, int md) {
			super();
			this.y = y;
			this.x = x;
			this.cost = cost;
			this.md = md;
			this.id = id;
		}

	}
}

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

int main(void) {
  char C;
  cin >> C;

  cout << (char)(C + 1) << endl;
  
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2", "3 5 2", "4 5" ].parse.expand.solve == 9 );
	assert( [ "3", "5 6 3 8", "5 100 8" ].parse.expand.solve == 22 );
	assert( [ "2", "100 1 1", "1 100" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( as, bs );
}

auto solve( long[] as, long[] bs )
{
	auto ans = 0L;
	auto r = 0L;
	bs ~= 0;
	foreach( a, b; lockstep( as, bs ) )
	{
		auto m = min( a, r + b );
		r = b - max( 0, m - r );
		ans += m;
	}
	return ans;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>


using namespace std;

/////////////////////////////////////////////////////
#define INF 1e15
ll A,B,Q,s[101010],t[101010];
ll ab[101010], ba[101010];
ll ans,mk[10];
ll i, j, k;

ll bs(ll a,ll b,ll* v){
    ll l = 0, r = b - 1;
    while(l<=r){
        ll c = (l + r) / 2;
        if(v[c]>a){
            r = c-1;
        }else{
            l = c+1;
        }
    }
    return r;
}
inline ll dist(ll a,ll b,ll c){
    return abs(a - b) + abs(b - c);
}
inline ll minn(ll a,ll b){
    return a < b ? a : b;
}


int main(){
    scanf("%lld%lld%lld", &A,&B,&Q);
    fornum(i,0,A){
        scanf("%lld", &s[i+1]);
    }
    fornum(i,0,B){
        scanf("%lld", &t[i+1]);
    }
    s[0] = t[0] = -INF;
    s[A+1] = t[B+1] = INF;
    s[A + 2] = t[B + 2] = INF*2;
    A += 3;
    B += 3;
    j = 0;
    fornum(i,0,A){
        while(t[j+1]<s[i]){
            j++;
        }
        ba[i] = j;
    }
    j = 0;
    fornum(i,0,B){
        while(s[j+1]<t[i]){
            j++;
        }
        ab[i] = j;
    }

    fornum(i,0,Q){
        ll x;
        scanf("%lld", &x);
        ll aa = bs(x, A, s);
        ll bb = bs(x, B, t);
        ll ans = INF;
        ans = minn(ans, dist(x,s[aa],t[ba[aa]]));
        ans = minn(ans, dist(x,s[aa],t[ba[aa]+1]));
        aa++;
        ans = minn(ans, dist(x,s[aa],t[ba[aa]]));
        ans = minn(ans, dist(x,s[aa],t[ba[aa]+1]));

        ans = minn(ans, dist(x,t[bb],s[ab[bb]]));
        ans = minn(ans, dist(x,t[bb],s[ab[bb]+1]));
        bb++;
        ans = minn(ans, dist(x,t[bb],s[ab[bb]]));
        ans = minn(ans, dist(x,t[bb],s[ab[bb]+1]));
        printf("%lld\n", ans);
    }

    return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int x = max(max(a, b), c), ans = 0;
	while (a + 2 <= x)
		a += 2, ++ ans;
	while (b + 2 <= x)
		b += 2, ++ ans;
	while (c + 2 <= x)
		c += 2, ++ ans;
	int cnt = 0;
	if (a == x)
		++ cnt;
	if (b == x)
		++ cnt;
	if (c == x)
		++ cnt;
	if (cnt == 3)
		cout << ans << endl;
	else if (cnt == 2)
		cout << ans + 2 << endl;
	else if (cnt == 1)
		cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    s = input()
    q =int(input())
    ten = 0
    r = []
    l = []
    for _ in range(q):
        ls = tuple(map(str, sys.stdin.readline().split()))
        if len(ls)==1:
            ten +=1
        else:
            if ls[1] =='1':
                if ten%2 ==0:
                    l.append(ls[2])
                else:
                    r.append(ls[2])
            else:
                if ten%2 ==1:
                    l.append(ls[2])
                else:
                    r.append(ls[2])
    s = ''.join(reversed(l))+s+''.join(r)
    if ten%2 ==1:
        s = s[::-1]
    print(s)
if __name__ == '__main__':
    main()

Measured memory_bytes: 12072
#include <cstdio>
#include <algorithm>
using namespace std;

const int INF = 1 << 30;
int A[100010];
int main() {
    int N, C, K; scanf("%d%d%d", &N, &C, &K);
    for(int i=0; i<N; i++) {
        scanf("%d", &A[i]);
    }
    sort(A, A+N);

    int ans = 0, prev = -INF, cnt = 0;
    for(int i=0; i<N; i++) {
        int diff = A[i] - prev;
        if(diff > K) {
            ans++;
            prev = A[i];
            cnt = 1;
            fprintf(stderr, "New bus: idx = %d\n", i+1);
        }
        else {
            if(cnt == C) {
                ans++;
                prev = A[i];
                cnt = 1;
                fprintf(stderr, "New bus: idx = %d\n", i+1);
            }
            else {
                cnt++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    for(int a=0;a<K;a++){
        if(A<B&&C<B){
            B*=2;
        }
        else if(A<C&&B<C){C*=2;}
        else{A*=2;}
    }
    cout<<A+B+C<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    VLL A(N);
    map<ll, ll> B;
    rep(i,N){
        cin >> A[i];
        B[A[i]]++;
    }
    ll ans=0;
    stl_rep(i,B){
        if((i->F)>(i->S)){
            ans+=i->S;
        }
        else{
            ans+=(i->S)-(i->F);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7040
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll a, b; cin >> a >> b;
  fin(a * b);
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    char order[10];
    int j = 0;
    fgets(order, 10, stdin);
    if(order[0] == '1')
        j++;
    if(order[1] == '1')
        j++;
    if(order[2] == '1')
        j++;
    printf("%d\n", j);
    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	static int n, m;
	static long[] a;
	static int[] b;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		a = new long[m + 1];
		b = new int[m];
		for (int i = 0; i < m + 1; ++i) {
			a[i] = sc.nextLong();
		}
		for (int i = 0; i < m; ++i) {
			b[i] = sc.nextInt();
		}
		long[] ret = dfs(0, 1 << n, 0);
		System.out.println(ret[0]);
	}

	static long[] dfs(int l, int r, int depth) {
		int lIdx = binarySearch(a, l);
		int rIdx = lIdx + 1;
		if (a[lIdx] <= l && r <= a[rIdx]) {
			long[] ret = new long[n + 1];
			if (b[lIdx] > depth) {
				Arrays.fill(ret, (1L << (n - depth)) - (1L << (b[lIdx] - 1 - depth)));
			} else {
				Arrays.fill(ret, 1L << (n - depth));
				ret[b[lIdx]] -= 1;
			}
			return ret;
		} else {
			long[] lDp = dfs(l, (l + r) / 2, depth + 1);
			long[] rDp = dfs((l + r) / 2, r, depth + 1);
			long[] ret = new long[n + 1];
			Arrays.fill(ret, Long.MAX_VALUE / 16);
			for (int i = 0; i <= depth; ++i) {
				ret[i] = Math.min(lDp[depth + 1] + rDp[i], lDp[i] + rDp[depth + 1]);
			}
			return ret;
		}
	}

	// key??\?????????????????????????????????
	static int binarySearch(long[] arr, long key) {
		int left = 0;
		int right = arr.length;
		while (right - left > 1) {
			int middle = (left + right) / 2;
			if (arr[middle] <= key)
				left = middle;
			else
				right = middle;
		}
		return left;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return(0);
}

int main(void) {
    int a, b, x, y;
    
    cin >> a >> b;
    extgcd(a, b, x, y);
    cout << x << " " << y << endl;
    return(0);
}

Measured memory_bytes: 1164
w, h, n = map(lambda x: int(x), input().split(' '))
board = [[0] * h for i in range(w)]

for i in range(n):
    x, y, a = map(lambda x: int(x), input().split(' '))

    start_x = 0
    end_x = w
    start_y = 0
    end_y = h

    if a == 1:
        end_x = x
    if a == 2:
        start_x = x
    if a == 3:
        end_y = y
    if a == 4:
        start_y = y
    
    for j in range(start_x, end_x):
        for k in range(start_y, end_y):
            board[j][k] = 1

result = 0
for i in range(w):
    for j in range(h):
        if board[i][j] == 0:
            result += 1

print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(((n+x-1)/x) * t)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

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

int main(){
  
  int N,M,C;
  cin >>N>>M>>C;
  vector<int> B(M);
  for(int i=0;i<M;i++){
    int x;
    cin >> x;
    B[i] = x;
  }
  int ans;
  for(int i=0;i<N;i++){
    vector<int> A(M);
    int sum=0;
    for(int j=0;j<M;j++){
      int x;
      cin >> x;
      sum += x*B[j];
    }
    if(sum+C>0) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			n++;
		}
	}

	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/agc025/tasks/agc025_b
from functools import reduce
import operator as op

MOD = 998244353
mod_inv = [0, 1]


def init_mod_inv(n):
    for i in range(2, n + 1):
        ans = MOD - (MOD // i) * mod_inv[MOD % i] % MOD
        mod_inv.append(ans)


def main():
    n, a, b, k = map(int, input().split())

    init_mod_inv(n)
    nCr = [0] * (n + 1)
    nCr[0] = 1
    for i in range(1, n+1):
        nCr[i] = (nCr[i - 1] * (n - i + 1) * mod_inv[i]) % MOD

    ways = 0
    for x in range(0, n + 1):
        yb = k - a * x
        if yb >= 0 and yb % b == 0 and yb // b <= n:
            ways += nCr[x] * nCr[yb // b]
            ways %= MOD
    print(ways)


if __name__ == "__main__":
    main()


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

int main (){
    long long N;
    cin >> N;
    vector<char> abc(26);
    abc = {'z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
    vector<int> list(20,0);
    int i = 0;
    while(N>0){
        list.at(i) = N%26;
        i++;
        if(N%26 == 0){N--;}
        N /= 26;
    }
    for(int j = 0;j < i;j++){
        cout << abc.at(list.at(i-j-1));
    }
    cout << endl;

    
}

Measured memory_bytes: 3612