akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int a;
        cin>>a;
        int ans = a + (a*a) + (a*a*a);
        cout<<ans;

    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	map<int, lint> A;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
	}

	lint sum = 0;
	for (const auto& [key, cnt] : A) sum += key * cnt;

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {

		int b, c;
		cin >> b >> c;

		sum += (c - b) * A[b];
		A[c] += A[b];
		A[b] = 0;
		cout << sum << "\n";

	}

	return 0;
}



Measured memory_bytes: 9564
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int X, t, a;
	cin >> X >> t;
	a = X - t;
	if(a < 0){
		a = 0;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import bisect as bs
n = int(input())
a = sorted(list(map(int,input().split())))
max = a[len(a)-1]
idx  = bs.bisect_left(a,int(max/2))
if idx != 0 and max/2.0-a[idx-1] <= a[idx]-max/2.0:
    idx = idx-1
print(max,a[idx])

Measured memory_bytes: 14420
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

LL N;
vector<LL> P;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	for(int i=0; i<N; i++){
		LL p;
		cin >> p;
		P.push_back(p);
	}

	int c = 0;
	long long ans = 0;
	for(int i=0; i<P.size(); i++){
		if(P[i] == i+1){
			c++;
		}
		else{
			if(i > 0 && P[i-1] == i){
				if((c % 2) != 0){
					ans += ((c/2) + 1);
				}
				else{
					ans += (c/2);
				}
				c = 0;
			}
		}
	}
	if(c != 0){
		if((c % 2) != 0){
			ans += ((c/2) + 1);
		}
		else{
			ans += (c/2);
		}
	}

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

Measured memory_bytes: 4252
#include<stdio.h>
#include<iostream>
using namespace std;
int bubblesort(int A[],int N)
{
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++)
	{
		flag=0;
	{
		for(int j=N-1;j>=i+1;j--)
		if(A[j]<A[j-1])
		{
			swap(A[j],A[j-1]);
			flag=1;
			sw++;
		}
	}
    }
    return sw;
}
int main()
{
	int A[100],N,sw;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	scanf("%d",&A[i]);
	sw=bubblesort(A,N);
	for(int i=0;i<N;i++)
	{
		if(i)
		printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	return 0;
}

Measured memory_bytes: 3228
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll a,b,c,k;
 	cin>>a>>b>>c>>k;
 	ll ans=0;
 	ll cons = min(a,k);
 	k-=cons;
 	ans+=cons;
 	if(k>0)
 	{
 		cons = min(b,k);
	 	k-=cons;
 	}
 	if(k>0)
 	{
 		cons = min(c,k);
	 	k-=cons;
	 	ans-=cons;
 	}
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
import java.math.*;
class Main
{
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    public static void main(String args[])
    {
    	FastReader sc=new FastReader();
        int s=sc.nextInt();
        int w=sc.nextInt();
        if(w>=s)
        {
            System.out.println("unsafe");
        }
        else
        {
            System.out.println("safe");
        }
    }
}

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

int main(){
    int a,b; cin >> a >> b;
    int x,y,z;
    x = a+b;
    y=a-b;
    z=a*b;
    int ans=x;
    ans=max(ans,y);
    ans=max(ans,z);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 2e5 + 5, Mod = 1e9 + 7;
typedef ll arr[Maxn];
ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, A0, B0;
arr A, B;
ll ans, res, pw[Maxn];
struct str
{
	int sign;
	ll x, y;
	bool operator<(str A1) const
	{
		if (sign != A1.sign)
			return sign == 1;
		if (x != A1.x)
			return x < A1.x;
		return y < A1.y;
	}
} tmp;
ll gcd(ll x, ll y)
{
	ll z = x % y;
	while (z)
	{
		x = y;
		y = z;
		z = x % y;
	}
	return y;
}
str Trans(ll x, ll y)
{
	ll g = gcd(abs(x), abs(y));
	return (str){((x > 0) ^ (y > 0)) ? -1 : 1, abs(x / g), abs(y / g)};
}
map<str, int> S;
int main()
{
	pw[0] = 1;
	for (rg int i = 1; i <= 200000; i++)
		pw[i] = pw[i - 1] * 2 % Mod;
	cin >> n;
	for (rg int i = 1; i <= n; i++)
	{
		A[i] = read();
		B[i] = read();
		if (!A[i] && !B[i])
		{
			res++;
			i--;
			n--;
			continue;
		}
		if (!A[i])
			A0++;
		else if (!B[i])
			B0++;
		else
			S[Trans(A[i], B[i])]++;
	}
	ans = 1;
	rg map<str, int>::iterator it;
	for (it = S.begin(); it != S.end(); it++)
	{
		tmp = it->first;
		if (it->second != -1)
		{
			ans = ans * Add(pw[it->second], pw[S[{-tmp.sign, tmp.y, tmp.x}]] - 1) % Mod;
			S[{-tmp.sign, tmp.y, tmp.x}] = -1;
		}
	}
	res--;
	cout << Add(ans * Add(pw[A0], pw[B0] - 1) % Mod, res);
	return 0;
}
//E

Measured memory_bytes: 39336
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    string S;
    cin >> S;
    int diff = 10000;
    rep(i,0,S.size()-2){
        int X = (int)((char)S[i] - '0')*100 + (int)((char)S[i+1] - '0')*10 + (int)((char)S[i+2] - '0');
        if(abs(753 - X) < diff){
            diff = abs(753-X);
        }
    }
    cout << diff << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int n,A;
int a[110];
long long dp[51][5010];
long res = 0;

int main(void){
    // Your code here!
    cin >> n >> A;
    rep(i,n) {
        int value; cin >> value;
        a[i] = value-A;
    }
    
    memset(dp, 0, sizeof(dp));
    dp[0][2500] = 1;
    
    rep(i,n){
        rep(j,5001){
            dp[i+1][j] += dp[i][j];
            if(j >= a[i]) dp[i+1][j] += dp[i][j-a[i]];
        }
    }
    
    cout << dp[n][2500] -1 << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)

int main(){
 ll a, b, x;
 cin >> a >> b >> x;

 if(x < b){
   ll ans = (a*x)/b;
   cout << ans << endl;
 }
 else{
   ll ans = (a*(b-1))/b;
   cout << ans << endl;
 }
}

Measured memory_bytes: 3644
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n , k = IN()
	al = LIN()
	#s = input()
	rr = ['0']*(k+1)
	
	for i in range(k+1):
		if i < al[0]:
			rr[i]='l'
		
		for v in al:
			if v > i:
				pass
			if rr[i-v] == 'l':
				rr[i]='w'
				break
		else:
			rr[i]='l'
	ret = 'First' if rr[-1] == 'w' else 'Second'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 40304
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int n;
bool co[10]={false};
string in[10]={""};
int in1[10]={0};
int in2[10]={0};
int out[10]={0};
double mini=-1.0;
void solve(int a,vector<int>tmp){
	//cout<<a<<endl;
	//if(a==3)rep(i,n)cout<<" "<<co[i];
	if(a==n){
		double sum=0;
		double sum1=0;
		rep(i,n){
			sum+=(i+1)*in1[tmp[i]];
			sum1+=in1[tmp[i]];
		}
		double g=sum/sum1;
		if(mini<0||mini>g){
			mini=g;
			rep(i,n)out[i]=tmp[i];
		}
	}else{
	rep(i,n){
		if(co[i])continue;
		int sum=in1[i];
		bool h=true;
		for(int j=tmp.size()-1;j>=0;j--){
			if(in2[tmp[j]]<sum){h=false;break;}
			sum+=in1[tmp[j]];
		}
		if(h){
			tmp.pb(i);
			co[i]=true;
			solve(a+1,tmp);
			tmp.erase(tmp.begin()+tmp.size()-1);
			co[i]=false;
		}
	}}
	//cout<<a<<endl;
}
int main(){
	while(cin>>n,n){
		mini=-1.0;
		rep(i,n)co[i]=false;
		rep(i,n)cin>>in[i]>>in1[i]>>in2[i];
		vector<int>tmp;
		solve(0,tmp);
		rep(i,n)cout<<in[out[i]]<<endl;
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const ll MOD = 1e9 + 7;

// 繰り返し二乗法
ll modPow(ll x, ll a){
    if(a == 1) return x;
    // 指数aが奇数の時はx*x^(a-1)
    if(a % 2) return (x * modPow(x, a - 1)) % MOD;
    // 指数aが偶数の時はx^(a/2)
    ll t = modPow(x, a / 2);
    return (t * t) % MOD;
}

// フェルマーの小定理からxのMOD-2乗を計算
ll modInv(ll x){
    return modPow(x, MOD - 2);
}

// kまでの階乗計算
ll modPerm(ll n, ll k){
    ll ret = 1;
    for(int i = 0; i < k; i++){
        ret = (ret * (n - i)) % MOD;
    }
    return ret;
}

// 二項係数(n = 1e9, k = 1e7まで対応可能))
ll modComb(ll n, ll k){
    ll a, b;
    // n - k + 1からnまでの積
    a = modPerm(n, k);
    // k!
    b = modPerm(k, k);
    return (a * modInv(b)) % MOD;
}

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

    for(int i = 1; i <= k; i++){
        cout << modComb(n - k + 1, i) * modComb(k - 1, i - 1) % MOD << endl;
    }
}


Measured memory_bytes: 256
// ░█████╗░░░░░░░░░░░░░░░
// ██╔══██╗░░██╗░░░░██╗░░
// ██║░░╚═╝██████╗██████╗
// ██║░░██╗╚═██╔═╝╚═██╔═╝
// ╚█████╔╝░░╚═╝░░░░╚═╝░░
// ░╚════╝░░░░░░░░░░░░░░░
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( (a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)



ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	ll k,a,b;
	cin>>k>>a>>b;
	ll i,j;
	ll num=a/k;
	if(a%k==0){
		cout<<"OK\n";
		return;
	}
	else if(b%k==0){
		cout<<"OK\n";
		return;
	}
	else{
		num=(num+1)*k;
		if(num>=a&&num<=b){
			cout<<"OK\n";
			return;
		}
		else{
			cout<<"NG\n";
			return;
		}
	}


}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		int set_count = in.nextInt();
		
		int[] ary = new int[set_count];
		long sum = 0;
		int i = 0;

		for(i = 0; i < set_count; i++){
			ary[i] = in.nextInt();
			sum += ary[i];
		}
		Arrays.sort(ary);
		System.out.println(ary[0] + " " + ary[i-1] + " " + sum);

		
	}

}



Measured memory_bytes: 41648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n;
    string s,t,ans = {};
    cin >>n;
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
bool p[5001][5001];
int main(){
  while(cin>>n&&n){
    int px[5000],py[5001],an=0;
    for(int i=0;i<n;i++)cin>>px[i]>>py[i],p[px[i]][py[i]]=1;
    for(int i=0;i<n;i++)
      for(int j=i;j<n;j++){
	int dx=px[i]-px[j],dy=py[i]-py[j];
	int x1=px[i]-dy,y1=py[i]+dx,x2=px[j]-dy,y2=py[j]+dx;
	int x3=px[i]-dy,y3=py[i]+dx,x4=px[j]+dy,y4=py[j]-dx;
	if(0<=x1&&x1<=5000&&0<=y1&&y1<=5000&&p[x1][y1]&&0<=x2&&x2<=5000&&0<=y2&&y2<=5000&&p[x2][y2])an=max(an,dx*dx+dy*dy);
	if(0<=x3&&x3<=5000&&0<=y3&&y3<=5000&&p[x3][y3]&&0<=x4&&x4<=5000&&0<=y4&&y4<=5000&&p[x4]&&p[x4][y4])an=max(an,dx*dx+dy*dy);
      }
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 22648
#!/usr/bin/env python3

import re

n = int(input())
p = []
min = 1000000000000000

for i in range(5):
    x = int(input())
    p.append(x)
    if(min > x):
        min = x

if(n%min == 0):
    print(int(n/min) + 4)
else:
    print(int(n/min) + 5)


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int main() {
    ll n;
    cin>>n;
    int ans=0;
    for(ll i=2;i*i<=n;++i) {
        if(n%i==0) {
            int cnt=0;
            while(n%i==0) n/=i,++cnt;
            int k=1;
            while(cnt>=k) {
                cnt-=k;
                ++ans;
                k++;
            }
        }
    }
    if(n>1) ++ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
import sys
import math

H, W = map(int, input().split(' '))
S = [input() for i in range(H)]
M = [[10000]*W for i in range(H)]
M[0][0] = 0
for k in range(H*W):
    for i in range(H):
        for j in range(W):
            if M[i][j] == k:
                if i > 0 and M[i-1][j] > k+1 and S[i-1][j] == '.':
                    M[i-1][j] = k+1
                if i < H-1 and M[i+1][j] > k+1 and S[i+1][j] == '.':
                    M[i+1][j] = k+1
                if j > 0 and M[i][j-1] > k+1 and S[i][j-1] == '.':
                    M[i][j-1] = k+1
                if j < W-1 and M[i][j+1] > k+1 and S[i][j+1] == '.':
                    M[i][j+1] = k+1
if M[-1][-1] == 10000:
    print(-1)
    sys.exit()
minDis = M[-1][-1] + 1
numWhite = 0
for line in S:
    numWhite += line.count('.')
print(numWhite-minDis)

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

class Node{
	public:
		int location;
		int p,l,r;

		// コンストラクタ
		Node(){}
};

class Point{
	public:
		int id,x,y;

		Point(){}
		Point(int ID, int X, int Y){
			id=ID;	x=X;	y=Y;
		}

		bool operator < (const Point &p) const{
			return id<p.id;
		}

		void Print(){
			printf("%d\n", id);
		}

};

static const int MAX=1000000;
static const int NIL=-1;

int n;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2){ return p1.x<p2.x; }
bool lessY(const Point &p1, const Point &p2){ return p1.y<p2.y; }

int makeKDTree(int L, int R, int depth){
	if(!(L<R))return NIL;

	int mid=(L+R)/2;
	int t=np++;

	if(depth%2==0){
		// x
		sort(P+L, P+R, lessX);
	}else{
		// y
		sort(P+L, P+R, lessY);
	}

	T[t].location=mid;
	T[t].l=makeKDTree(L,mid,depth+1);
	T[t].r=makeKDTree(mid+1,R, depth+1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans){
	int x=P[T[v].location].x, y=P[T[v].location].y;

	if(sx<=x && x<=tx && sy<=y && y<=ty){
		ans.push_back(P[T[v].location]);
	}

	if(T[v].l != NIL){
		if(depth%2==0 && sx<=x) find(T[v].l, sx,tx,sy,ty, depth+1, ans);
		else if(depth%2&&sy<=y) find(T[v].l, sx,tx,sy,ty, depth+1, ans);
	}

	if(T[v].r != NIL){
		if(depth%2==0 && x<=tx) find(T[v].r, sx,tx,sy,ty, depth+1, ans);
		else if(depth%2&&y<=ty) find(T[v].r, sx,tx,sy,ty, depth+1, ans);
	}
}
int main(){
	int x,y;

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		P[i]=Point(i,x,y);
		T[i].l = T[i].r = T[i].p = NIL;
	}
	np=0;

	int root=makeKDTree(0,n,0);

	int q;	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i=0;i<q;i++){
		scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
		ans.clear();

		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(), ans.end());
		for(Point a : ans){
			a.Print();
		}printf("\n");
	}


	return 0;
}



Measured memory_bytes: 16444
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


x,a = map(int, input().split())

if x < a:
    print(0)
else:
    print(10)



Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  for(int i=0; i<3; i++) cin>>x[i];

  sort(x,x+3);
  if(x[1]-x[0]==x[2]-x[1]) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,a,b;
  
   scanf("%d%d",&a,&b);
 
  if(a>12)
    printf("%d",b);
  else if(6<=a&&a<=12)
    printf("%d",b/2);
  else if(a<=5)
    printf("0");
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int dp[6001][6001];
int main()
{
	int n, t, A, B;
	cin >> n >> t;
	vector<int> a(n), b(n);
	vector<pair<int, int>> data(n);
	rep(i, 0, n)cin >> A >> B, data[i] = {A, B};
	sort(all(data));
	rep(i, 0, n)a[i] = data[i].first, b[i] = data[i].second;
	vector<int> kouho;
	int M = 0;
	rep(i, 0, t) {
		rep(i2, 0, n) {
			if (i + a[i2] < t)dp[i2 + 1][i + a[i2]] = max(dp[i2][i] + b[i2], dp[i2 + 1][i + a[i2]]);
			else {
				M = max(max(dp[i2][i] + b[i2], dp[i2 + 1][i + a[i2]]), M);
			}
			dp[i2 + 1][i] = max(dp[i2][i], dp[i2 + 1][i]);
		}
	}
	printf("%d\n", M);
	return 0;
}

Measured memory_bytes: 50840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

inline int main1();

int main() {

	main1();

	return 0;
}

int is_yaki(char *s){

	return strncmp(s,"YAKI",4);

}

inline int main1() {

	int i;

	char input[10];

	cin >> input ;


	if(is_yaki(input)==0){
		cout << "Yes";
	}else{
		cout << "No";
	}


	return 0;

}


Measured memory_bytes: 256
import java.util.*;

class restaurant{
	int id;
	String city;
	int point;
	
	public restaurant(int id, String city, int point){
		this.id = id;
		this.city = city;
		this.point = point;
	}
	
	static int RestaurantCompare(restaurant r1, restaurant r2){
		if(StringCompare(r1.city, r2.city) != 0){
			return StringCompare(r1.city, r2.city);
		}
		else{
			if(r1.point > r2.point){
				return 1;
			}
			else if (r1.point < r2.point){
				return -1;
			}
			else{
				return 0;
			}
		}
	}
	
	static int StringCompare(String s1, String s2){
		String[] s1_split = s1.split("");
		String[] s2_split = s2.split("");
		int length = Math.min(s1_split.length, s2_split.length);
		int longer = 0;
		if(s1_split.length > s2_split.length){
			longer = -1;
		}
		else if(s1_split.length < s2_split.length){
			longer = 1;
		}
		else{
			longer = 0;
		}
		
		for(int i=0; i<length; i++){
			if(StrToNum(s1_split[i]) < StrToNum(s2_split[i])){
				return 1;
			}
			if(StrToNum(s1_split[i]) > StrToNum(s2_split[i])){
				return -1;
			}
		}
		return longer;
	}
	
	static int StrToNum(String s){
		switch(s){
			case "a":
				return 1;
			case "b":
				return 2;
			case "c":
				return 3;
			case "d":
				return 4;
			case "e":
				return 5;
			case "f":
				return 6;
			case "g":
				return 7;
			case "h":
				return 8;
			case "i":
				return 9;
			case "j":
				return 10;
			case "k":
				return 11;
			case "l":
				return 12;
			case "m":
				return 13;
			case "n":
				return 14;
			case "o":
				return 15;
			case "p":
				return 16;
			case "q":
				return 17;
			case "r":
				return 18;
			case "s":
				return 19;
			case "t":
				return 20;
			case "u":
				return 21;
			case "v":
				return 22;
			case "w":
				return 23;
			case "x":
				return 24;
			case "y":
				return 25;
			case "z":
				return 26;
		}
		return 0;
	}
	
	static void quick_sort(restaurant[] d, int left, int right) {
		if(left>=right){
				return;
		}
		restaurant p = d[(left+right)/2];
		int l = left, r = right;
		restaurant tmp;
		while(l<=r){
			while(RestaurantCompare(d[l], p) > 0){ l++; }
			while(RestaurantCompare(d[r], p) < 0){ r--; }
			if (l<=r) {
				tmp = d[l]; d[l] = d[r]; d[r] = tmp;
				l++;
				r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
}

public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		restaurant[] rs = new restaurant[n];
		
		for(int i=0; i<n; i++){
			rs[i] = new restaurant(i+1, sc.next(), sc.nextInt());
		}
		
		restaurant.quick_sort(rs, 0, n-1);
		
		for(int i=0; i<n; i++){
			System.out.println(rs[i].id);
		}
	}
}


Measured memory_bytes: 25428
s=input()
t=input()
slength=len(s)
tlength=len(t)
if slength+1!=tlength:
    print('No')
else:
    flag=True
    for i in range(slength):
        if s[i]!=t[i]:
            print('No')
            flag=False
            break
        else:
            continue
    if flag==True:
        print('Yes')
        

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;

  vector<long long> h(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    cin >> h[i];
  }

  long long dp[n + 1][n + 1];
  memset(dp, 0x3f, sizeof dp);

  dp[0][0] = dp[n][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int l = 0; l < i; ++l) {
        dp[i][j] = min(dp[i][j], max(0ll, h[i] - h[l]) + dp[l][j - 1]);
      } 
    }
  }

  long long mn = LLONG_MAX;
  for (int i = 1; i <= n; ++i) {
    mn = min(mn, dp[i][n - k]);
  }
  cout << mn << '\n';
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll N;
int main(){
    
    cin >> N;
    vector<ll> v;
    for(ll M = 1; M * M <= N; M++){
        if(N % M == 0){
            v.push_back(M);
        }
        if(M * M != N){
            v.push_back(N / M);
        }
    }
    ll sum = 0;
    for(ll a : v){
        if(N / a > 1){
            if(N / a - 1 > a){
                sum += N / a - 1;
                // cout << a << " " << N / a - 1 << endl;
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 10348
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
vll ans;
bool sosu(ll n){
	if(n==2){
		ans.pub(2);
		return true;
	}
	if(n%2==0){
		ans.pub(2);
		sosu(n/2);
		return false;
	}
	for(ll i=3;i*i<=n;i+=2)if(n%i==0){
		sosu(i);
		sosu(n/i);
		return false;
	}
	ans.pub(n);
	return true;
}
void solve(){
	ll n;cin>>n;
	cout<<n<<":";
	sosu(n);
	sort(ALL(ans));
	rep(i,0,ans.size())cout<<" "<<ans[i];
	cout<<kai;
}


Measured memory_bytes: 3212
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << "{"; for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi) { if (vi != v.begin()) os << ", "; os << *vi; } os << "}"; return os; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


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

    string S;
    cin >> S;

    while (S.size() >= 2 && S.substr(0, 2) == "hi")
        S = S.substr(2);

    cout << (S.empty() ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)
 
 
int main() {
    int N;
    cin >> N;
    int h[N];
    rep(i, N) cin >> h[i];
    int count = 1;
    int hMax = h[0];
    loop(i, 1, N) {
        if (h[i] >= hMax) {
            hMax = h[i];
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}


ll N;
llvec A;
llvec lmt;
ll prv;
ll ans=0;

void input() {
	cin>>N;
	init(A,N+1);
	lmt.resize(N+1,LLINF);
}

void solve() {
	lmt[0]=1ll;
	for(int i=0; i<N; i++) {
		lmt[i+1]=(lmt[i]-A[i])*2;
		if(lmt[i+1]>1e15) break;
		if(lmt[i+1]<0) {
			cout<<-1<<endl;
			return;
		}
	}
	if(lmt[N]-A[N]<0) {
		cout<<-1<<endl;
		return;
	}

	prv=ans=A[N];
	for(ll i=N-1; i>=0; i--) {
		prv=min(prv,lmt[i]-A[i])+A[i];
		ans+=prv;
	}
	cout<<ans<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


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

int main() {
  int N;
  int br;
  cin>>N;
  vector<int> data(N);
  for(int i=0;i<N;i++){
    cin>>data.at(i);
  }
  int i=0;
  int j=1;
  while(i<N){
    if(data.at(i)==j){
      j++;
    } else {
      br++;
    }
    i++;
  }
  if(j==1){
    cout<<-1<<endl;
  }else{
  cout<<br<<endl;
  }
}
   

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define MAX 2000000
int a[MAX],b[MAX],c[10010];
int main(){
    int i,n,sum;
    
    cin>>n;
    sum=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>sum)sum=a[i]+1;
        c[a[i]]++;
    }
    for(i=1;i<=sum;i++){
        c[i]+=c[i-1];
    }
    for(i=0;i<n;i++){
        b[--c[a[i]]]=a[i];
    }
    for(i=0;i<n;i++)i==n-1?cout<<b[i]<<endl:cout<<b[i]<<" ";
    return 0;
}

Measured memory_bytes: 18748
H,W = gets.split().map(&:to_i)
a = []

H.times do |i|
	if i == 0
		a[i] = gets.split().map{|c| c == "0" ? 1 : 0}
	else
		a[i] = gets.split().map.with_index do |c, j|
			c == "0" ? a[i-1][j]+1 : 0
		end
	end
	a[i] << 0
end

r = 0

H.times do |i|
	s = [[0,0]]
	(W+1).times do |j|
		c = a[i][j]
		pj = j
		while c < s[-1][0] do
			h, sj = s.pop
			q = h * (j-sj)
			r = q if q > r
			pj = sj
		end
		
		if c > s[-1][0]
			s << [c, pj]
		end
	end
end

p r

Measured memory_bytes: 29880
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    int K=scan.nextInt();
    int[] h=new int[N];
    for(int i=0;i<N;i++){
      h[i]=scan.nextInt();
    }
    int count=0;
    for(int i=0;i<N;i++){
      if(K<=h[i]){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 47916
#include<cstdio>
#include<cctype>

int main(){
 char ch;
 while(1){
  scanf("%c", &ch);
  
  if(isalpha(ch)){
   if(isupper(ch)) printf("%c", tolower(ch));
   else printf("%c", toupper(ch));
  }
  else printf("%c", ch);
  if(ch=='\n') break;
 }
 return 0;
}

Measured memory_bytes: 2632
using System;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] str = Console.ReadLine().Split(' ');
            int[] ue = new int[n];
            for (int i = 0; i < n; i++)
            {
                ue[i] = int.Parse(str[i]);
            }
            str = Console.ReadLine().Split(' ');
            int[] sita = new int[n];
            for (int i = 0; i < n; i++)
            {
                sita[i] = int.Parse(str[i]);
            }

            int maxP = 0;
            int ueSum = 0;
            int sitaSum = 0;

            for (int i = 0; i < n; i++)
            {
                ueSum = 0;
                sitaSum = 0;
                for (int j = 0; j <= i; j++)
                {
                    ueSum = ueSum + ue[j];
                }
                for (int j = i; j < n; j++)
                {
                    sitaSum = sitaSum + sita[j];
                }
                int t = sitaSum + ueSum;
                if (t > maxP)
                {
                    maxP = t;
                }
            }

            Console.WriteLine(maxP);
        }
        }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int N;
int a[100010];
bool d[100010];
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i+1];

    int now = 1;
    int ans = 0;
    while(!d[now]) {
        d[now] = true;
        if(now == 2) {
            cout << ans << endl;
            return 0;
        }
        ans++;
        now = a[now];
    }
    cout << -1 << endl;
}


Measured memory_bytes: 768
s = input()

e1 = ['R', 'U', 'D']
e2 = ['L', 'U', 'D']

ans = 'Yes'

for i, c in enumerate(s):
    if ((i+1) % 2 == 0 and c in e2) or ((i+1) % 2 == 1 and c in e1):
        pass
    else:
        ans = 'No'
        break

print(ans)



Measured memory_bytes: 3064
A = []
for i in range(3):
    a1,a2,a3 = list(map(int,input().split()))
    Ai = [a1,a2,a3]
    A.extend(Ai)
n = int(input())
ana = []
for i in range(n):
    b = int(input())
    if b in A:
        idx = A.index(b)
        ana.append(idx)
atari = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
judje = False
for i in range(len(atari)):
    if (atari[i][0] in ana and atari[i][1] in ana)  and atari[i][2] in ana:
        judje = True
        break
if judje == True:    
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll X, K, D; cin >> X >> K >> D;
	ll ans = 0;
	X = abs(X);
	if ((abs(X)+D-1)/D <= K) {
		ll p = abs(X) / D;
		if (p % 2 == K % 2)
			ans = abs(p * D - abs(X));
		else
			ans = abs((p + 1) * D - abs(X));
		//ans = min(abs((abs(X) / D) * D - abs(X)), abs((abs(X) + D - 1) / D) * D - abs(X));
		//cout << (abs(X) / D) % 2 <<" "<< K % 2 << endl;
	}
	else ans = abs(abs(X) - K * D);
	cout << ans << endl;
}


Measured memory_bytes: 3548
import java.util.Arrays;
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] a = new char[H][W];
		for (int i = 0; i < H; ++i) {
			a[i] = sc.next().toCharArray();
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (j != W - 1 && (j == 0 || a[i][j] == '#' || i % 2 == 0)) {
					System.out.print('#');
				} else {
					System.out.print('.');
				}
			}
			System.out.println();
		}

		System.out.println();

		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (j != 0 && (j == W - 1 || a[i][j] == '#' || i % 2 == 1)) {
					System.out.print('#');
				} else {
					System.out.print('.');
				}
			}
			System.out.println();
		}
		
	}

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


Measured memory_bytes: 51092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N,M;
    ll K;
    int A[200001],B[200001];
    cin >> N >> M >> K;
    REP(i,N){cin >> A[i];}
    REP(i,M){cin >> B[i];}

    //累積和か？
    vector<ll> AA,BB;
    AA.push_back(0);BB.push_back(0);
    REPD(i,1,N+1){AA.push_back(AA[i-1] + A[i-1]);}
    REPD(i,1,M+1){BB.push_back(BB[i-1] + B[i-1]);}
    //cout << "!";
    //できなくなるまで足して、一つずつ減らしていく
    int Anum,Bnum;
    REP(i,N+1){
        //cout << AA[i] << " " << K << endl;
        if(AA[i] < K && i == N){Anum = N;break;}
        if(AA[i] > K){Anum = i-1;break;}
    }
    //cout << "A:" << Anum << endl; 
    ll ans = 0;
    int mainj = 0;
    for (ll i = Anum; i >= 0; i--)
    {
        for(ll j = mainj; j <= M; j++){
            if(AA[i] + BB[j] <= K){
                //cout << "A:" << i << " B:" << j <<endl;
                ans = max(i+j,ans);
                mainj = j;
            }else{
                break;
            }
        }
    }
    fin(ans);
    
    return 0;
}

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll X;
  cin >> X;

  ll x = 0;
  ll i = 1;
  while(x<X){
    x += i;
    i++;
  }
  cout << i-1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef ll Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const ll inf = 100000000000;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, Q;
    cin >> a >> b >> Q;
    vector<ll> s(a), t(b);
    FORO(i, a)
        cin >> s[i];
    s.pb(-inf);
    s.pb(inf);
    FORO(i, b)
        cin >> t[i];
    t.pb(-inf);
    t.pb(inf);
    sort(ALL(s));
    sort(ALL(t));
    FORO(i, Q) {
        ll x;
        cin >> x;
        ll ls = abs(x - *(upper_bound(ALL(s), x) - 1));
        ll lt = abs(x - *(upper_bound(ALL(t), x) - 1));
        ll rs = abs(*lower_bound(ALL(s), x) - x);
        ll rt = abs(*lower_bound(ALL(t), x) - x);
       //cout << ls << " " << lt << " " << rs << " " << rt << endl;
        ll ans = inf;
        getMin(ans, 2LL * ls + rt);
        getMin(ans, 2LL * lt + rs);
        getMin(ans, 2LL * rt + ls);
        getMin(ans, 2LL * rs + lt);
        getMin(ans, max(ls, lt));
        getMin(ans, max(rs,rt));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2912
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, A, B;
  cin >> N >> A >> B;
  int a = max(A, B);
  int b = min(A, B);
  if(abs(B-A) % 2 == 0){
    int ans = abs(B-A);
    cout << ans/2 << endl;
  }
  else{
    int ans1 = (b-1)+1+((a-b)/2);
    int ans2 = (N-a)+1+((a-b)/2);
    cout << min(ans1, ans2) << endl;
  }


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

template<typename T>
int64_t merge(vector<T> &A, int32_t left, int32_t mid, int32_t right) {
    int32_t n1 = mid - left;
    int32_t n2 = right - mid;

    vector<T> L(n1+1);
    vector<T> R(n2+1);
    for (int32_t i = 0; i < n1; i++) {
        L[i] = A[left+i];
    }
    for (int32_t i = 0; i < n2; i++) {
        R[i] = A[mid+i];
    }
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;

    int32_t i = 0, j = 0;
    int64_t count = 0;
    for (int32_t k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
            count += n1 - i;
        }
    }

    return count;
}

template<typename T>
int64_t merge_sort(vector<T> &A, int32_t left, int32_t right) {
    if (left + 1 < right) {
        int32_t mid = left + (right - left) / 2;
        int64_t count1 = merge_sort(A, left, mid);
        int64_t count2 = merge_sort(A, mid, right);
        int64_t count3 = merge(A, left, mid, right);
        return count1 + count2 + count3;
    }

    return 0;
}

int main() {
    int32_t n;

    cin >> n;
    vector<int64_t> S(n);
    for (int32_t i = 0; i < n; i++) {
        cin >> S[i];
    }

    cout << merge_sort(S, 0, n) << endl;

    return 0;
}

Measured memory_bytes: 5980
from math import ceil, floor

k = int(input())
al = list(map(int, input().split()))
al = al[::-1]

l,r = -1,-1
if al[0] != 2:
    print(-1)
    exit()

l = 2
r = 3
for a in al[1:]:
    min_l = ceil(l/a)*a
    max_r = floor(r/a)*a
    if min_l > r:
        print(-1)
        exit()
    if max_r < l:
        print(-1)
        exit()
    l = min_l
    r = max_r + (a-1)

print(l,r)

Measured memory_bytes: 86096
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	c := make([]int, 2)
	for _, s := range S {
		c[s-'0']++
	}
	ans := c[0]
	if ans > c[1] {
		ans = c[1]
	}
	fmt.Println(ans * 2)
}


Measured memory_bytes: 1280