akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().ToCharArray();
            var n = str.Count();

            var ans = 0;

            for (int i = 0; i < n / 2; i++)
            {
                if (str[i] != str[n - i - 1]) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
using System;

public class hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		string[] s = Console.ReadLine().Trim().Split(' ');
		var ans = getTF(s[0], s[1]);
		if (n == 2) { Console.WriteLine(ans); goto end; }
		for (int i = 2; i < n; i++)
			ans = getTF(ans, s[i]);
		Console.WriteLine(ans);
	end:;
	}
	static string getTF(string a, string b) => a == "T" && b == "F" ? "F" : "T";
}



Measured memory_bytes: 19964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long N = scanner.nextLong();
		long K = scanner.nextLong();

		double ans = K * Math.pow((double)K-1,(double)N-1);

		System.out.println((long)ans);
		scanner.close();
	}

}


Measured memory_bytes: 20948
#include "bits/stdc++.h"
using namespace std;
long n, k;
 
int main() {
  cin >> n >> k;
  long num = 0;
  long h = 0;
  for(int i=0;i<n;i++){
    cin >> h;
    if(h >= k){
      num++;
    }
  }
  cout << num << endl;
}

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

int main() {
    int a, b, c, ans = 0; cin >> a >> b >> c;

    for (int i = 1; c > 0; i++) {
        ans++;
        c -= a;
        if (i % 7 == 0) {
            c -= b;
            if (c <= 0) break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3116
a=["4","6","9","11"]
b=["1","3","5","7","8","10","12"]

x,y=input().split()

if x==y=="2":
    print("Yes")

elif a.count(x)==a.count(y)==1:
    print("Yes")

elif b.count(x)==b.count(y)==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

const ll MX=100010;

vector<ll> uft(MX*3);

ll parent(ll a){return uft[a]==a?a:uft[a]=parent(uft[a]);}

void merge(ll a,ll b){uft[parent(b)]=parent(a);}

int main(){
    for(int i=0;i<MX*3;i++){uft[i]=i;}
    ll n;
    cin>>n;
    vector<pll> A(n);
    cin>>A;
    for(int i=0;i<n;i++){
        merge(i,n+A[i].F);
        merge(i,n+MX+A[i].S);
    }
    vector<vector<ll>> B(n);
    for(int i=0;i<n;i++){B[parent(i)].push_back(i);}
    ll ans=0;
    for(auto &I:B){
        set<ll> X,Y;
        for(auto &T:I){
            X.insert(A[T].F);
            Y.insert(A[T].S);
        }
        ans+=X.size()*Y.size();
    }
    cout<<ans-n<<endl;
    
    return 0;
}


Measured memory_bytes: 12020
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int p[111] = {0};
int main()
{
	int X = 0, N = 0;
	scanf("%d %d", &X, &N);
	int i = 0;
	for (i = 0; i < N; i++) {
		int a = 0;
		scanf("%d", &a);
		p[a] = 1;
	}
	if (N == 0) {
		printf("%d\n", X);
		return 0;
	}
	int p1 = 0;
	for (i = X; i >= 0; i--) {
		if (p[i] == 0) {
			p1 = i;
			break;
		}
	}

	int p2 = 0;
	for (i = X; i <= 110; i++) {
		if (p[i] == 0) {
			p2 = i;
			break;
		}
	}
	int ans = 0;
	if (abs(X - p1) > abs(X - p2)) {
		ans = p2;
	} else if (abs(X - p1) < abs(X - p2)) {
		ans = p1;
	} else {
		ans = MIN(p1, p2);
	}
	printf("%d\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N;
ll MAX = 100005;
vector<vector<llll>> G;
vector<ll> d(MAX, -1);
void dfs(ll v){
    for (llll next_v : G[v]){
        if(d[next_v.first] != -1) continue;
        d[next_v.first] = d[v] + next_v.second;
        dfs(next_v.first);
    }
}


int main(){
    cin >> N;
    G.resize(N);
    ll a, b, c;
    for (ll i = 0; i < N-1; i++) {
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }
    d.resize(N);
    ll Q, K;
    cin >> Q >> K;
    K--;
    d[K] = 0;
    dfs(K);
    ll x, y;
    for (ll i = 0; i < Q; i++) {
        cin >> x >> y;
        x--; y--;
        printf("%lld\n", d[x] + d[y]);
    }

}   

Measured memory_bytes: 15576
s = input()
s_str = set(list(s))
ans = 101
for char in s_str:
    t = s
    count = 0
    while len(set(list(t))) > 1:
        next_t = ''        
        for i in range(len(t) - 1):
            if (t[i] == char) | (t[i + 1] == char):
                next_t += char
            else:
                next_t += t[i]
        t = next_t
        count += 1
    ans = min(ans, count)
print(ans)

Measured memory_bytes: 3064
def solve():
    N = int(raw_input())
    arr = [int(_) for _ in raw_input().split()]
    neg_cnt = 0
    abs_sum = 0
    min_abs = 10**10
    for i in range(N):
        abs_sum += abs(arr[i])
        if abs(arr[i]) < min_abs:
            min_abs = abs(arr[i])
        if arr[i] < 0:
            neg_cnt += 1
    if neg_cnt % 2 == 0:
        ret = abs_sum
    else:
        ret = abs_sum - 2 * min_abs
    print str(ret)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 11860
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
b = [0 for i in range(n)]

for i in range(q):
    num_ans_person = a[i]-1
    b[num_ans_person] += 1

for i in range(n):
    if k-q+b[i]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 13656
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<pair<int,int> > ts;
		for(int i = 0; i < n; i++){
			int team;
			int m[4];
			int s[4];
			cin>>team>>m[0]>>s[0]>>m[1]>>s[1]>>m[2]>>s[2]>>m[3]>>s[3];
			int time=0;
			for(int i = 0; i < 4; i++){
				time+=m[i]*60;
				time+=s[i];
			}
			ts.push_back(make_pair(time,team));
		}
		sort(ts.begin(),ts.end());
		cout<<ts[0].second<<endl;
		cout<<ts[1].second<<endl;
		cout<<ts[ts.size()-2].second<<endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define V vector<ll>
#define ALL(sss) sss.begin(),sss.end()
#define arall(rr,n) rr+0,rr+n 
#define mod 1000000007
#define M 100
#define MAXN 1000000000

 
ll dp[101][100001];
int ans=INT_MAX;
ll n;
using namespace std;


void fileio(){
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}

ll fun(ll v[], ll ind, ll w[], ll W){
    
    //if(fl)cout<<ind<<" "<<W<<endl;
    
    if(ind>=n)return 0;
    if(dp[ind][W]!=-1)return dp[ind][W];
    
    ll b=INT_MIN,a=fun(v,ind+1,w,W);
    if(W>=w[ind])
    b=v[ind]+fun(v,ind+1,w,W-w[ind]);

    dp[ind][W]=max(a,b);
   
    return dp[ind][W];
}


int main(){


     fileio();
    
   
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  

    ll T=1,q;
    //cin>>T;
    while(T--){

        ll W;cin>>n>>W;
        ll w[n],v[n],st=0;
        for (int i = 0; i < n; ++i)
        {
            /* code */cin>>w[i]>>v[i];
        }

       // memset(dp,-1,sizeof(dp));
        //ll ans=fun(v,st,w,W);

        ll dp[n+1][W+1],z=0;
        

        for (int i = 0; i <= n; ++i)
        {
            /* code */for (int j=0;j<=W;j++)
            {
                /* code */dp[i][j]=0;
            }
        }
        
        for (ll i = 1; i <= n; ++i)
        {
            for(int j=0;j<=W;j++){
                dp[i][j]=dp[i-1][j];
                if(j>=w[i-1])
                dp[i][j]=max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
        }

        ll ans=0;
        for (int i = 0; i <= W; ++i)
        {
           // cout<<dp[n][i]<<endl;
            /* code */ans=max(ans,dp[n][i]);
        }

        cout<<ans<<endl;
       // cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

        // cout<<"Case #"<<q<<": "<<ans<<endl;
    }
    
//prllf("%.9f\n", x);//precision: 9 decimal places.

/*
    GP SUM:(
    (bk)-a)/k-1;//k is ratio and b is final term, a is initial term;

    Comparing two decimal numbers

    if (abs(a-b) < 1e-9) {
        // a and b are equal
    }
*/
    return 0;
}


Measured memory_bytes: 82436
import java.util.*;
class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
		  int a = sc.next().length();
      String out = "";
      for (int i = 0;i<a;i++){
        out+="x";
      }
      System.out.println(out);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define ll long long
int main(){
	string str1,str2;
	cin >> str1 >> str2;
	int i,j,flag;
	int max=str1.size();
	for(i=0;i<max;i++){
		flag=0;
        j=0;
		while((flag==0)&&(j<max)){
            if(str1[(i+j)%max]==str2[j]){
            	
            }else{
            	flag=1;
            }
            j++;
		}
        if(flag==0){
        	cout << "Yes";
        	return 0;
	    }
	}
	cout <<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int lose = 0;
  for(int i=0;i<S.size();i++){
    if(S.at(i) == 'x') lose++;
  }
  if(lose >= 8) cout << "NO" <<endl;
  else cout << "YES" <<endl;
}

Measured memory_bytes: 256
h,w,k = map(int,input().split())
s = [input() for i in range(h)]
ans = [[0]*w for i in range(h)]
c = 1
not_cherry = [] #イチゴがない列
ok = False
for i in range(h):
    if '#' in s[i]:
        cherry = 0
        for j in range(w):
            if s[i][j]=='#':
                if cherry==0:
                    ans[i][j] = c
                else:
                    c += 1
                    ans [i][j] = c
                cherry += 1
            else:
                ans[i][j] = c
        c += 1
        ok = False
    else:
        if ok:
            not_cherry[-1] += 1
        else:
            not_cherry.append(1)
        ok = True

i = 0
ind = 0
while i<h:
    if 0 in ans[i]:
        c = not_cherry[ind]
        for l in range(c):
            for j in range(w):
                if i+l<h-1 and i+c<h-1:ans[i+l][j] = ans[i+c][j]
                else:ans[i+l][j] = ans[i+l-1][j]
        i+=c
        ind += 1
    else:
        i+=1

for i in ans:
    print(*i)
      


Measured memory_bytes: 7552
#include <stdio.h>
int main(void)
{
    int i,H,N,A[100000];
    scanf("%d %d",&H,&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        H -= A[i];
    }
    if(H <= 0)printf("Yes");
    else printf("No");
	return 0;
}

Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
struct Node {
    int val;
    int num;
} a[maxn], b[maxn];


bool cmp(Node a, Node b) {
    return a.num > b.num;
}

int main() {
    int n;
    cin >> n;
    int tmp;
    for(int i = 0; i < n; i ++) {
        scanf("%d", &tmp);
        if(i % 2 == 0) {
            a[tmp].num++;
            a[tmp].val = tmp;
        }
        else {
            b[tmp].num++;
            b[tmp].val = tmp;
        }
    }
    sort(a, a + maxn, cmp);
    sort(b, b + maxn, cmp);
    int ans = 0;
    if(a[0].val != b[0].val) 
        ans = n - a[0].num - b[0].num;
    else 
        ans = n - max(a[0].num + b[1].num, a[1].num + b[0].num);
    cout << ans <<endl;
}





Measured memory_bytes: 3328
N = int(input())
A = list(map(int,input().split()))

calc = 0

for i in range(0,len(A),2) :
    calc += A[i]
for i in range(1,len(A),2) :
    calc -= A[i]

p = calc//2

X = [0 for i in range(N)]
X[0] = p

for i in range(1,len(X)) :
    X[i] = A[i-1] - X[i-1]

ans = [x*2 for x in X]
print(*ans)


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	int k[m];
	vector<vector<int>> s(m);
	rep(i, m) {
		cin >> k[i];
		rep(j, k[i]) {
			int s_in;
			cin >> s_in;
			s_in--;
			s[i].push_back(s_in);
		}
	}
	int p[m];
	rep(i, m) {
		cin >> p[i];
	}
	
	ll sum = 0;
	rep(i, 1 << n) {
//		cout << i << endl;
		int cnt[m];
		rep(j, m) {
			int ecnt = 0;
			for (int es: s[j]) {
//				cout << es << " ";
				if (i >> es & 1) {
					ecnt++;
				}
			}
//			cout << ecnt << endl;
			cnt[j] = ecnt;
		}
		bool ok = true;
		rep(j, m) {
			if (cnt[j] % 2 != p[j]) {
				ok = false;
			}
		}
		if (ok) sum++;
	}
	
	cout << sum << endl;
	
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(v) v.begin(), v.end()
#define MOD 1e7
const long long INF = 1LL<<60;

int main() {
	// your code goes here
	int n;cin>>n;
	vector<ll> x1(n), x2(n);
	rep(i, n)   cin>>x1[i]>>x2[i];
	sort(all(x1));
	sort(all(x2));
	if(n%2==0) {
	    ll ma = x1[n/2-1]+x1[n/2];
	    ll mb = x2[n/2-1]+x2[n/2];
	    cout<<mb-ma+1<<endl;
	} else {
	    ll ma = x1[n/2], mb = x2[n/2];
	    cout<<mb-ma+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6420
#include <stdio.h>
    int main(void){
        
        long long int k,a,b;
        
        scanf("%lld %lld %lld",&k,&a,&b);
        long long int bis=1;
        
        for(long long int i=k;i>0;i--){
            if(i==1)bis++;
            else if(b<a+2)bis++;
            else if(bis<a)bis++;
            else{bis+=(b-a),i--;}
        }
        
        printf("%lld\n",bis);
        
        return 0;
        
    }

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll h, w;
	cin >> h >> w;
	ll ans = 1e9;
	for (int i = 1;i < h;i++) {
		ll s1 = i * w, s2 = w / 2 * (h - i), s3 = h * w - s1 - s2;
		ll a = max(s1, max(s2, s3));
		ll b = min(s1, min(s2, s3));
		ans = min(ans, a - b);
		ll t1 = i * w, t2 = (h - i) / 2 * w, t3 = h * w - t1 - t2;
		ll c = max(t1, max(t2, t3));
		ll d = min(t1, min(t2, t3));
		ans = min(ans, c - d);
	}
	for (int i = 1;i < w;i++) {
		ll s1 = i * h, s2 = h / 2 * (w - i), s3 = h * w - s1 - s2;
		ll a = max(s1, max(s2, s3));
		ll b = min(s1, min(s2, s3));
		if (a - b >= 0)ans = min(ans, a - b);
		ll t1 = i * h, t2 = (w - i) / 2 * h, t3 = h * w - t1 - t2;
		ll c = max(t1, max(t2, t3));
		ll d = min(t1, min(t2, t3));
		if (c - d >= 0)ans = min(ans, c - d);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int dis[maxn],k,vis[maxn];
int to[maxn*10],w[maxn*10],ne[maxn*10];
int po[maxn],id;
queue<int> q;
inline void add(int x,int y,int z)
{
	to[++id]=y;w[id]=z;ne[id]=po[x];po[x]=id;
}
int main()
{
	memset(dis,0x3f3f3f3f,sizeof(dis));
	cin>>k;
	for (int i=0;i<k;i++)
		for (int j=0;j<=9;j++)
		add(i,(i*10+j)%k,j);
	for (int i=1;i<=9;i++)
	{
		q.push(i);dis[i]=i;vis[i]=1;
	}
	while (!q.empty())
	{
		int u,v;
		u=q.front();q.pop();vis[u]=0;
		for (int i=po[u];i;i=ne[i])
		{
			v=to[i];
			if (dis[u]+w[i]<dis[v])
			{
				dis[v]=dis[u]+w[i];
				if (!vis[v]) 
				{
					q.push(v);
					vis[v]=1; 
				} 
			}
		} 
	}
	printf("%d\n",dis[0]);
	return 0;
}  

Measured memory_bytes: 13568
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n == 0 && x == 0) break;
            int count = 0;
            for(int i = 1; i <= n-2; i++) {
                for(int j = i+1; j <= n-1; j++) {
                    for(int k = j+1; k <= n; k++) {
                        if(i + j + k == x) count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll a,b;
  cin>>a>>b;
  if (a>b)
    swap(a,b);
  ll d = b-a;
  if (d%2==0){
    cout<<a+d/2<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}


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

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

    int N = S.size();
    vector<int> children(N);
    int i = 0;
    while (i < N) {
        int j = i;
        while (S[j] != 'L' && j < N) j++;
        int r = j - 1, l = j;
        while (S[j] != 'R' && j < N) j++;
        for (int k = i; k < j; k++) {
            if (k % 2 == r % 2) children[r]++;
            else children[l]++;
        }
        i = j;
    }

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << children[i];
    }
    cout << endl;
}

Measured memory_bytes: 3840
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M,X = map(int, input().split())
    ca = []
    res = sys.maxsize
    for _ in range(N):
        ca.append(list(map(int, input().split())))
    for i in range(2 ** N):
        tmp = [0]*M
        tmpres = 0
        for j in range(N):
            if ((i >> j) & 1):
                tca = ca[N-1-j]
                tmpres += tca[0]
                for k in range(M):
                    tmp[k] += tca[1+k]
        tassei = True
        for a in tmp:
            if a < X:
                tassei = False
                break
        if tassei:
            res = min(res,tmpres)
    if res != sys.maxsize:
        print(res)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10592
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <assert.h>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    // cin.tie(0);
    // int freq[13];
    // for(int i = 0; i<13; i++){
    //     freq[i] = 0;
    // }
    // int n;
    // cin >> n;
    // for(int i = 0; i<n; i++){
    //     int x;
    //     cin >> x;
    //     assert(x<=12);
    //     freq[x]++;
    // }
    // vector<int> def;
    // vector<int> li;
    // if(freq[0]>0){
    //     cout << 0 << endl;
    //     return 0;
    // }
    // def.push_back(0);
    // for(int i = 1; i<13; i++){
    //     if(freq[i]==0){
    //         continue;
    //     }
    //     else if(freq[i]==1){
    //         li.push_back(i);
    //     }
    //     else{
    //         def.push_back(i);
    //         def.push_back(24-i);
    //     }
    // }
    // int nn = li.size();
    // int len = (1<<nn);
    // int ans = -1;
    // int defs = 12;
    // for(int i = 0; i<def.size(); i++){
    //     for(int j = i+1; j<def.size(); j++){
    //         int ab = abs(def[i]-def[j]);
    //         ab = min(ab,24-ab);
    //         defs = min(defs,ab);
    //     }
    // }
    // ans = -1;
    // for(int ma = 0; ma<len; ma++){
    //     vector<int> temp;
    //     for(int j = 0; j<nn; j++){
    //         bool on = ((1<<j)&ma)!=0;
    //         if(on){
    //             temp.push_back(li[j]);
    //         }
    //         else{
    //             temp.push_back(24-li[j]);
    //         }
    //     }
    //     int now = defs;
    //     for(int i = 0; i<nn; i++){
    //         for(int j = i+1; j<nn; j++){
    //             int ab = abs(temp[i]-temp[j]);
    //             ab = min(ab,24-ab);
    //             now = min(now,ab);
    //         }
    //     }
    //     for(int i =0 ; i<nn; i++){
    //         for(int j = 0; j<def.size(); j++){
    //             int ab = abs(temp[i]-def[j]);
    //             ab = min(ab,24-ab);
    //             now = min(now,ab);
    //         }
    //     }
    //     ans = max(ans,now);
    // }
    // assert(ans>=0);
    // cout << ans << endl;
    int n;
    cin >> n;
    vector<int> li;
    for(int i = 0; i<n; i++){
        int x;
        cin >> x;
        li.push_back(x);
    }
    sort(li.begin(),li.end());
    for(int now = 12; now>=0; now--){
        bool ok = true;
        int l = 0;
        int r = 24;
        for(int i = 0; i<li.size(); i++){
            if(li[i]-l>=now && min(r-li[i],24-(r-li[i]))>=now){
                l = li[i];
            }
            else if(r-(24-li[i])>=now && min((24-li[i])-l,24-((24-li[i])-l))>=now){
                r = 24-li[i];
            }
            else{
                ok = false;
                break;
            }
        }
        if(!ok){
            continue;
        }
        cout << now << endl;
        return 0;
    }
    assert(false);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> even;
	vector<long long> odd;

	long long a;
	for (long long i = 1; i <= N; i++) {
		cin >> a;
		if (i % 2 == 1) {
			odd.push_back(a);
		}
		else {
			even.push_back(a);
		}
	}

	vector<long long> b;
	if (N % 2 == 1) {
		for (long long i = odd.size() - 1; i >= 0; i--) {
			b.push_back(odd[i]);
		}
		for (long long i = 0; i < even.size(); i++) {
			b.push_back(even[i]);
		}
	}
	else {
		for (long long i = even.size() - 1; i >= 0; i--) {
			b.push_back(even[i]);
		}
		for (long long i = 0; i < odd.size(); i++) {
			b.push_back(odd[i]);
		}
	}

	for (long long i = 0; i < b.size(); i++) {
		cout << b[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 6916
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;

int main() {
  cin >> N;
  vector<pair<int, int>> pos, neg;
  rep(i, 0, N) {
    string s;
    cin >> s;

    int m = 0, sum = 0;
    int left = 0, right = 0;
    for (int j = 0; j < int(s.size()); ++j) {
      if (s[j] == '(') {
        ++left;
        ++sum;
      } else {
        ++m;
        --sum;
        if (left > right) {
          ++right;
        }
      }
    }
    m -= right;
    if (sum >= 0) {
      pos.push_back(make_pair(m, sum));
    } else {
      neg.push_back(make_pair(m + sum, sum));
    }
  }

  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end(), greater<pair<int, int>>());

  int ss = 0;
  for (auto e : pos) {
    int mm = e.first;
    int ssum = e.second;
    if (mm > ss) {
      cout << "No" << endl;
      return 0;
    }
    ss += ssum;
  }

  for (auto e : neg) {
    int ssum = e.second;
    int mm = e.first - ssum;
    if (mm > ss) {
      cout << "No" << endl;
      return 0;
    }
    ss += ssum;
  }

  if (ss != 0) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 11128
n, m, x = [int(i) for i in input().split()]
as_ = []
for _ in range(n):
    as_.append([int(i) for i in input().split()])
suc = []
for i in range(2**n):
    ms = [0]*m
    c = 0
    for ind, b in enumerate(bin(i)[2:][::-1]):
        if b == '1':
            c += as_[ind][0]
            for i_ in range(m):
                i_ += 1
                ms[i_-1] += as_[ind][i_]
    fl = [1 for m_ in ms if m_ >= x]
    if sum(fl) == m:
        suc.append(c)
if suc:
    print(min(suc))
else:
    print(-1)


Measured memory_bytes: 74712
/////////////////////////////////////////////////
/////             Give me AC!!!!            /////
/////////////////////////////////////////////////
//↑これじゃ気合いが足りない！
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////             お願いしますACをくださいそうじゃないと僕泣きますお願いしますACをくださいJudge様....            /////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const int MOD = 1000000007;
const int MAX = 100000;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
ld rad(ld a) {return a * 180 / PI;}
const int dx[4] = {1, 0, -1, 0};//2次元グリッド上のx軸方向
const int dy[4] = {0, 1, 0, -1};//2次元グリッド上のy軸方向

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

map<ll,ll> factorize_list;

void prime_factorize(ll N) {
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        factorize_list[a] = ex;
    }

    // 最後に残った数について
    if (N != 1) factorize_list[N] = 1;
    return ;
}

//dpTable
vector<ll> dp(100,MAX);

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

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

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

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}
char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 10000000000;
struct edge{ll to, cost;};

int main(){
    int N;
    cin >> N;
    bool ans = false;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if (a % 2 != 0) ans = true;
    }
    cout << (ans ? "first" : "second") << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int abs(int x){
    return x >= 0 ? x : -x;
}

int main(){
    int n; cin >> n;
    string a,b,c; cin >> a >> b >> c;

    int cnt = 0;
    rep(i,n){
        if(a[i] == b[i] and b[i] == c[i] and a[i] == c[i]){
            continue;
        }

        if(a[i] == b[i] or b[i] == c[i] or a[i] == c[i]){
            cnt++;
            continue;
        }

        cnt += 2;
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
A, B, M = map(int, input().split())

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

x=[]
y=[]
c=[]

for i in range(M):
    j,k,l = map(int, input().split())
    x.append(j)
    y.append(k)
    c.append(l)
    

min_buy = min(a)+min(b)

for i in range(M):
    price = a[x[i]-1] + b[y[i]-1] - c[i]
    if min_buy > price:
        min_buy = price
        
print(min_buy)






Measured memory_bytes: 24804
# coding: utf-8
# Your code here!
count = 0
num = int(input())
li = list(map(int,input().split()))
graph_li =[]
for i in range(1,101):
    graph = []
    for j in li:
        if j >= i:
            graph.append("1")
        else:
            graph.append("0")
    graph_li.append(graph[:])
for i in graph_li:
    if "1" in i:
        count += len(list(filter(lambda x:len(x)>0 ,"".join(i).split("0"))))
print (count)


Measured memory_bytes: 3192
n = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0
ans += A.pop()
count = n-2
for i in range(n):
    num = A.pop()
    if count == 0:
        break
    if count == 1:
        ans += num
        break

    ans += num*2
    count -= 2

print(ans)



Measured memory_bytes: 31548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

long N, M;
long A[100001];
long B[100001];

int main() {
	long i, j;
	long ans = 0;
	
	sl(N);
	for(i=1;i<=N;i++) {
		sl(A[i]); sl(B[i]);
	}
	
	for(i=N;i>0;i--) {
		if((A[i] + ans) % B[i] != 0) {
			ans += (B[i] - (A[i] + ans) % B[i]);
		}
	}
	
	pl(ans);
	
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,i;
    while(cin>>n>>i){
        cout<<(n+1)-i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  vector<int> a(5);
  int res;
  rep(i,5){
    int temp; cin >> temp;
    if(temp==0){
      cout << i+1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std ;
 
 int main()
 {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
  sort(a,a+n);
  float z=(a[0]+a[1])/2.0;
    for(int i=2;i<n;i++)
    {   
      
       z=(z+a[i])/2.0;
        }
        cout<<fixed<<showpoint;
        cout<<setprecision(9)<<z<<endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct mystr{
	int minn = 500000;
	int cnt = 0;
};

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

	int N;
	cin>>N;
	mystr tmp[26];
	for (int i = 0; i < N; i++) {
		int cnttmp[26] = {0};
		int count[26] = {0};
		string s;
		cin>>s;
		for (int j = 0; j < s.size(); j++) {
			cnttmp[s[j] - 'a'] = 1;
			count[s[j] - 'a']++;
		}
		for (int j = 0; j < 26; j++) {
			tmp[j].minn = min(tmp[j].minn, count[j]);
			tmp[j].cnt += cnttmp[j];
		}
	}
	for (int i = 0; i < 26; i++) {
		if(tmp[i].cnt==N){
			for (int j = 0; j < tmp[i].minn; j++) {
				printf("%c", 'a' + i);
			}
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mod2 998244353
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,l,k,r,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    int a,b;
    // long double a,b;
    cin>>a>>v>>b>>w>>t;
    int dist=abs(a-b);
    if(v*t>=dist+w*t)
    {
        cout<<"YES";
    }
    else cout<<"NO";
}



signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    int T=0;
    while(t--)
    {
        T++;
        // cout<<"Scenario #"<<T<<":\n";
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> vec(N+1, 0);
    for(int n=0; n<N; n++) {
        double p;
        cin >> p;
        p = (p*(p+1)/2)/p;
        vec[n+1] = vec[n]+p;
    }
    
    double mx=0;
    for(int n=0; n+K<=N; n++) {
        mx = max(mx, vec[n+K]-vec[n]);
    }
    cout << setprecision(15) << mx << endl;


    return 0;
    
}


Measured memory_bytes: 1792
M=3
n,c=gets.split.map(&:to_i)
d=c.times.map{gets.split.map(&:to_i)}
color=n.times.map{gets.split.map{|l|l.to_i-1}}
k=[*0...M].map{Array.new(c,0)}
n.times{|i|n.times{|j|k[(i+j)%M][color[i][j]]+=1}}
s=M.times.map{|m|c.times.map{|post_color|
  c.times.map{|pre_color|
    pre_color==post_color ? 0 : k[m][pre_color]*d[pre_color][post_color]
  }.inject(:+)
}}

puts [*0...c].permutation(M).map{|perm|
  perm.each_with_index.map{|x,idx|s[idx][x]}.inject(:+)
}.min

Measured memory_bytes: 4728
#include<cstdio>
int n,a,b,ans;
int sum(int x){
  int res=0;
  while(x)res+=x%10,x/=10;
  return res;
}
int main(){
  scanf("%d%d%d",&n,&a,&b);
  for(int i=1;i<=n;++i){
      int t=sum(i);
      if(t>=a&&t<=b)ans+=i;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int x, y;
	scanf("%d %d%*c", &x, &y);
	int total = 0;
	if(x < 4) total += 4-x;
	if(y < 4) total += 4-y;
	if(x*y == 1) total += 4;
	printf("%d", total*100000);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    ll x;
    cin >> x;
    ll ans = 100;
    ll cnt = 0;
    while(ans < x){
        ans += (ans/100);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	long long int n;
	cin >> n;

	vector<long long int> a(n + 1, 0);
	vector<long long int> b = a;

	vector<long long int> c;
	long long int aa, bb;
	aa = bb = 1;
	
	while (aa <= 100000) {
		aa *= 6;
		bb *= 9;
		c.push_back(aa);
		c.push_back(bb);
	}

	for (long long int i = 0; i <= n; i++) {
		a[i] = i;
	}
	b = a;
	for (int i = 0; i < c.size(); i++) {
		for (long long int j = 0; j + c[i] <= n; j++) {
			if (b[j + c[i]] > b[j] + 1) {
				b[j + c[i]] = b[j] + 1;
			}
		}
	}

	cout << b[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll n,m;
  cin >> n >> m;
  ll sum = 0;
  rep(i,m){
    ll x; cin >> x;
    sum += x;
  }
  if(n<sum){
    cout << -1 << endl;
  } else {
    cout << n-sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <stack>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
const int mxn = 1e6+10;
int a[mxn];

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

	int n; cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];

	map<long long, int> f;
	long long ans = 0, cur = 0;
	for(int i=1; i<=n; i++) {
		cur+=1ll*a[i];
		if(cur==0) ans++;
		ans+=f[cur];
		f[cur]++;
	}

	cout << ans << '\n';


	return 0;
}
//comparator function in sorting
//swapping arguments
//missing cases in dp
//dividing in modulo
//Beware of overflow and modulo
//Be mindful of overflow
//s is a matrix but forget
//length of ranges
//working with bit using ull

Measured memory_bytes: 16856
#include<iostream>
#include<string.h>
using namespace std;

int main(){
	char s[100001];
	int k;
	cin>>s>>k;
	
	int i, tmp, len;
	len=strlen(s);
	for(i=0;i<len;i++){
		if(s[i]=='a'&&i!=len-1) continue;
		tmp=s[i];
		if((123-tmp)<=k&&i!=len-1){
			k-=(123-tmp);
			s[i]='a';
		}   
		else if(i==len-1){
			k%=26;
			tmp=s[i];
			tmp+=k;
			if(tmp>=123) {tmp-=123; tmp+=97;}
			s[i]=tmp;
		}
	}	
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 384
# input here
_INPUT = """\
4 5
0 5
-2 4
3 4
4 -4
"""

def main():
    # -*- coding: utf-8 -*-
    # スペース区切りの整数の入力
    N, D = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(N)]
    
    answer = []

    for j in range(len(xy)):
        # 距離求める
        distance = math.sqrt((xy[j][0]**2 + xy[j][1]**2))

        # Dとdistance比較する
        if D >= distance:
            answer.append(distance)

    print(len(answer))

if __name__ == '__main__':
    import io
    import sys
    import math

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 115928
#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);
    int N;
    cin >> N;
    int a=N%100%10;
    if(a==2 || a==4 || a== 5 || a==7 || a==9){
        cout << "hon" << endl;
    }
    else if(a==0 || a==1 || a==6 || a==8){
        cout << "pon" << endl;
    }
    else if(a==3){
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3648