akhauriyash/Code-Regression huggingface dataset:
// ref. https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
    }

    let mut flag = "No";
    for i in 1..10{
        for j in 1..10{
             if i*j == n {
                flag = "Yes";
                break;
            }
        }
    }

    println!("{}", flag);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

struct team{
	int id;
	int point;
	int time;
};

bool y[55][11];
int f[55][11];
team s[55];

bool comp(team a, team b){
	return ((a.point==b.point)?((a.time==b.time)?(a.id>b.id):(a.time<b.time)):(a.point>b.point));
}

int main(void){
	int M,T,P,R,m,t,p,j,i;
	while(true){
		cin >> M >> T >> P >> R;
		if(!(M || T || P || R)){
			break;
		}
		for(i=0; i<T; ++i){
			s[i].id=(i+1);
			s[i].point=0;
			s[i].time=0;
		}
		fill(y[0],y[55],true);
		fill(f[0],f[55],0);
		for(i=0; i<R; ++i){
			cin >> m >> t >> p >> j;
			--t; --p;
			if(j && y[t][p]){
				++f[t][p];
			}else if(!j){
				s[t].point += 1;
				s[t].time += m;
				s[t].time += 20*f[t][p];
				y[t][p] = false;
			}
		}
		sort(s,s+T,comp);
		for(i=0; i<T; ++i){
			cout << ((i)?((s[i-1].point==s[i].point&&s[i-1].time==s[i].time)?"=":","):"") << s[i].id;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3140
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	tmp := make([]int, len(nums))
	copy(tmp, nums)
	sort.Ints(tmp)
	l := tmp[n/2-1]
	r := tmp[n/2]
	for i := 0; i < n; i++ {
		v := nums[i]
		if l < v {
			fmt.Println(l)
		} else {
			fmt.Println(r)
		}
	}
}


Measured memory_bytes: 8912
#include <stdio.h>
int n;
int ten[10]={1,10,100,1000,10000,100000,1000000,10000000,100000000};
int aaa[4]={3,5,7};
int result=0;


int main(){
	long long int a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	
	if(k%2==0)
	{
		printf("%lld",a-b);
	}else
	{
		printf("%lld",b-a);
	}
	}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
'import sys'
d=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=[int(j) for j in input().split()]
    d[b-1][f-1][r-1]+=v
for i, b in enumerate(d):
    for f in b:
        for r in f:
            print(" {}".format(r),end="")
        print()
    if i< 3:
        print("#"*20)

Measured memory_bytes: 7756
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N >> M;
    if(N + M >= 10) {
    	cout << "error\n";
    }
    else {
    	cout << N + M << "\n";
    }

    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Curtain
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        int a = sc.nextInt();   // 窓の実際の横の長さ
        int b = sc.nextInt();   // カーテン１枚の横の長さ

        int length = b * 2;

        if( length >= a ) {
            System.out.println( "0" );
        }
        else {
            System.out.println( a - length );
        }

        sc.close();
    }
}

Measured memory_bytes: 23892
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) {
  cout << (N%2 ? 2*N : N) << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
#include "stdlib.h"

int digit(int A,int B);

int main(void)
{
  int N;
  scanf("%d",&N);
  int A,B,tmp;
  int min = 114514810;

  for(int i = 1;i <= N;i++)
    {
      A = i;
      B = N - i;
      tmp = digit(A,B);
      if(min > tmp)
	min = tmp;
    }
  if(min == 1 && N != 1)
    min = 10;
  printf("%d\n",min);
}

int digit(int A,int B)
{
  int Adigitsum,Bdigitsum;
  Adigitsum = 0;
  Bdigitsum = 0;
  Adigitsum += A / 10000 != 0 ? A / 10000 : 0;
  Bdigitsum += B / 10000 != 0 ? B / 10000 : 0;
  A = A % 10000;
  B = B % 10000;
  Adigitsum += A / 1000 != 0 ? A / 1000 : 0;
  Bdigitsum += B / 1000 != 0 ? B / 1000 : 0;
  A = A % 1000;
  B = B % 1000;
  Adigitsum += A / 100 != 0 ? A / 100 : 0;
  Bdigitsum += B / 100 != 0 ? B / 100 : 0;
  A = A % 100;
  B = B % 100;
  Adigitsum += A / 10 != 0 ? A / 10 : 0;
  Bdigitsum += B / 10 != 0 ? B / 10 : 0;
  A = A % 10;
  B = B % 10;
  Adigitsum += A / 1 != 0 ? A / 1 : 0;
  Bdigitsum += B / 1 != 0 ? B / 1 : 0;
  return Adigitsum + Bdigitsum;
}



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

int H, W;
char field[110][110];
bool checked[100][100];

void dfs(int y, int x, char ch){
	if(checked[y][x]) return;
	
	checked[y][x] = true;
	
	if(x > 0 && field[y][x - 1] == ch) dfs(y, x - 1, ch);
	if(y > 0 && field[y - 1][x] == ch) dfs(y - 1, x, ch);
	if(x + 1 < W && field[y][x + 1] == ch) dfs(y, x + 1, ch);
	if(y + 1 < H && field[y + 1][x] == ch) dfs(y + 1, x, ch);
}

int main(){
	int res;
	
	while(true){
		scanf("%d%d", &H, &W);
		if(H == 0 && W == 0) return 0;
		
		for(int i = 0; i < H; i++) scanf("%s", field[i]);
		
		for(int y = 0; y < H; y++){
			for(int x = 0; x < W; x++){
				checked[y][x] = false;
			}
		}
		
		res = 0;
		for(int y = 0; y < H; y++){
			for(int x = 0; x < W; x++){
				if(checked[y][x]) continue;
				
				dfs(y, x, field[y][x]);
				res++;
			}
		}
		
		printf("%d\n", res);
	}
}

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

int main() {
  long long X;
  cin>>X;
  long long Y;
  Y=X/500;
  long long Z;
  Z=X-Y*500;
  long long z;
  z=Z/5;
  cout<<1000*Y+5*z<<endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e2 + 7;
const int mod = 1e9 + 7;

int n, a[N];
double ans;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
    }
    sort( a, a + n );
    ans = a[0];
    for ( int i = 1; i < n; i++ ) {
        ans = ( ans + a[i] );
        ans /= 2;
    }
    cout << ans;
}



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

using namespace std;

int main(){
    int w,h,n;
    cin>>w>>h>>n;
    vector<pair<int,int> > xy(n);
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y>>a[i];
        xy[i]=make_pair(x,y);
    }
    int x_1=0,x_2=w,y_1=0,y_2=h;
    for(int i=0;i<n;i++){
        switch (a[i]) {
        case 1:
            x_1 = max(x_1,xy[i].first);
            break;
        case 2:
            x_2=min(x_2,xy[i].first);
            break;
        case 3:
            y_1=max(y_1,xy[i].second);
            break;
        case 4:
            y_2=min(y_2,xy[i].second);
            break;
        }
    }
    if(x_2-x_1<=0||y_2-y_1<=0)
        cout<<"0"<<endl;
    else
        cout<<(x_2-x_1)*(y_2-y_1);
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


#define all(x) x.begin(),x.end()
#define ip vector<int,pair<int,int>>
#define vii vector<pair<int,int>>
#define vi  vector<int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define tt int t; cin>>t;while(t--)
#define FOR(i,j,k) for(int i=0;i<j;i++)
#define endl "\n"
#define pb push_back
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);






signed main(){
	
	string s,t;
	cin>>s>>t;
	int cn=0;
	for(int i=0;i<s.size();i++)
		cn+=(s[i]!=t[i]);
	cout<<cn<<endl;	

}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <stack>
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

/*Xを前から見ていって、Sの１個以上の連続箇所があれば、それ以降の部分で
Tが何個連続しているかを見る
各連続箇所で、連続回数の少ない方*2をカウント
*/
int main(){
  string x;
  cin >> x;
  int n=x.size();
  stack<char> s;
  for(int i=0;i<n;++i){
    if(x[i]=='S'){
      s.push(x[i]);
    }else if(x[i]=='T'){
      if(s.empty()){
        s.push(x[i]);
      }else if(s.top()=='S'){
        s.pop();
      }else if(s.top()=='T'){
        s.push(x[i]);
      }
    }
  }
 
  cout << s.size() << endl;

}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	priority_queue<ll> pq;
	rep (i, n) {
	  ll a;
	  cin >> a;
	  pq.push(a);
	}
	rep (i, m) {
	  ll p = pq.top();
	  pq.pop();
	  p /= 2;
	  pq.push(p);
	}
	ll res = 0;
    while (!pq.empty()) {
	  res += pq.top();
	  pq.pop();
	}
	cout << res << endl;
	
    return 0;
}



Measured memory_bytes: 4280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int a,b; cin >> a >> b;
	cout << max({a+b,a-b,a*b}) << endl;
}


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

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	ll sum = 0;
	for(int i=0;i<N;i++) {
		cin >> a[i];
		sum += a[i];
	}
	vector<ll> ans(N,0);
	ans[0] = sum;
	for(int i=1;i<N;i+=2)
	{
		ans[0] -= 2*a[i];
	}
	for(int i=0;i<N;i++) {
		ans[(i+1)%(N)] = 2*a[i] - ans[i];
	}

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

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{int n;
 cin>>n;
 int a[n];
 float s=0.0;
 for(int i=0;i<n;i++)
 cin>>a[i];
 sort(a,a+n);
 for(int i=1;i<n;i++)
 s=s+(float)(pow(2,i-1)*a[i]);
 s=(float)(s+a[0])/pow(2,n-1);
 cout<<s;
return 0;}             
             

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
		ans = 0;
	}
	else if (a == b&&b == c) {
		ans = -1;
	}
	else {
		int x, y, z;
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			x = a;y = b;z = c;
			a = (y + z) / 2;
			b = (x + z) / 2;
			c = (x + y) / 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num + 1 >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T &a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    auto sgt = segtree<int>(v,accumulate(all(v),1LL,[](int a, int b){return lcm(a,b);}),[](int a, int b){return gcd(a,b);});
    int ans = -INF;
    for(int i = 0; i < n; ++i){
        cmax(ans,gcd(sgt.query(0,i),sgt.query(i+1,n)));
    }
    cout << ans << endl;
}




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

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


int main() {
    long long int x,a=100;
    cin>>x;
    for(long int i=1;;i++)
    {
        a+=(a/100);
        if(a>=x)
        {
            cout<<i;
            break;
        }
    }
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
string s;
int main()
{
	cin>>s;
	int x;
	char chr;
	chr=s[0];
	x=1;
	for (int i=1;i<s.length();++i)
	{
		if (x==3)
		{
			cout<<"Yes\n";
			return 0;
		}
		if (chr==s[i])
		{
			x++;
		}
		else
		{
			chr=s[i];
			x=1;
		}
	}
	if (x==3)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c;
  cin>>c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout<<"vowel"<<'\n';
  }else{
    cout<<"consonant"<<'\n';
  }
    return(0);
  }


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

struct Card {char suit, value;};

void BubbleSort(struct Card c[], int n){
    for(int i = 0; i < n; i++){
        for(int j = n - 1; j > i; j--){
            if(c[j].value < c[j - 1].value){
                Card tmp = c[j];
                c[j] = c[j - 1];
                c[j - 1] = tmp;
            }
        }
    }
}

void SelectionSort(struct Card c[], int n){
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(c[j].value < c[minj].value) minj = j;
        }
        Card tmp = c[i];
        c[i] = c[minj];
        c[minj] = tmp;
    }
}

void print(struct Card c[], int n){
    for(int i = 0; i < n; i++){
        if(i == 0) cout << c[i].suit << c[i].value;
        else cout << " " << c[i].suit << c[i].value;
    }
    cout << endl;
}

bool isStable(struct Card c1[], struct Card c2[], int n){
    for(int i = 0; i < n; i++){
        if(c1[i].suit != c2[i].suit) return false;
    }
    return true;
}

int main(){
    Card card1[50], card2[50];
    int N;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> card1[i].suit >> card1[i].value;
    }

    for(int i = 0; i < N; i++) card2[i] = card1[i];

    BubbleSort(card1, N);
    SelectionSort(card2, N);
    
    print(card1, N);
    cout << "Stable" << endl;

    print(card2, N);
    if(isStable(card1, card2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
int i,j,k;
int n=0;
char s[81];
while(scanf("%s",s)!=-1){
for(i=0;i<strlen(s);i++){
if('1'<=s[i]&&s[i]<='9'){
for(j=i+1;j<strlen(s);j++){
if(s[j]<'0'||'9'<s[j])
break;
}
for(k=0;k<j-i;k++)
n+=(s[i+k]-'0')*pow(10,j-i-k-1);
i=j;
}
}
}
printf("%d\n",n);
return 0;
}

Measured memory_bytes: 580
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
r_list = {}
all_list = set()
for i in range(m):
	a, b = map(int, input().split())
	all_list.add(a)
	all_list.add(b)
	if a in r_list.keys():
		r_list[a].add(b)
	else:
		r_list[a] = {b}
	if b in r_list.keys():
		r_list[b].add(a)
	else:
		r_list[b] = {a}
count = n - len(all_list)
for key in r_list.keys():
	r_set = r_list[key]
	heights = list(map(lambda i: h_list[i-1], r_set))
	height = h_list[key - 1]
	if height > max(heights):
		count += 1
print(count)

Measured memory_bytes: 124236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  int cnt = 0;
  rep(i,n) {
    if (s[i] == 'D') cnt = cnt-1;
    else cnt++;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

int main(){
	int n;cin>>n;
	vector <int> dp(3);
	for(int day = 0; day < n; day ++){
		vector <int> new_dp(3, 0);
		vector <int> c(3);
		
		for(int i = 0; i < 3; i ++){
			cin>>c[i];
		}
		
		for(int i = 0; i < 3; i ++){
			for(int j = 0; j < 3; j++){
				if(i != j){
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}dp = new_dp;
	}
	printf("%d\n", max({dp[0], dp[1], dp[2]}));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,N,k=0;
    int a[81];
    for(i=1;i<10;i++)
    {
        for(j=1;j<10;j++)
        {
            a[k++]=i*j;
        }
    }

    scanf("%d",&N);
    for(i=0;i<81;i++)
    {
        if(N==a[i])
        {
            printf("Yes");
            break;
        }
    }
    if(i==81)
        printf("No");
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1] == b[0]){
    if(b[b.size()-1] == c[0]){
      cout<<"YES"<<endl;
      return ;
    }
  }

  cout<<"NO"<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;

int main() {
    ll n, m, d;
    scanf("%lld %lld %lld", &n, &m, &d);

    double ans;
    if (d == 0) {
        ans = (double)((n - 2 * d) * 1) / (n * n) * (m - 1);
    } else if (n / 2 >= d) {
        ans = ((double)((n - 2 * d) * 2) / (n * n) + (double)((2 * d) * 1) / (n * n)) * (m - 1);
    } else {
        ans = (double)((n - d) * 1) / (n * n) * (m - 1);
    }
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(c-a+b>=0)
  cout<<c-a+b<<endl;
  else cout<<0<<endl;
}








Measured memory_bytes: 256
import java.util.Scanner;

public class Main {        
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int left = 1;
        int right = n;

        for (int i = 0; i < m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            left = Math.max(left, l);
            right = Math.min(right, r);
        }
        System.out.println(Math.max(0, right - left + 1));
    }
}

Measured memory_bytes: 65256
#include<stdio.h>
typedef long long ll;
#define mod (long long)(1e9+7)
	ll a[300005],ans=0,b=1;
	int n,i;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int k=0;k<60;k++)
	{
		long long c=0;
		for(i=1;i<=n;i++)
		{
			if(a[i]&1)c++;
			a[i]>>=1;
		}
		ans+=((c*(n-c)%mod)*b)%mod;
		b*=2;
		b%=mod;
	}
	printf("%lld\n",ans%mod);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main(){
	FAST_IO;
    int n; 
    cin >> n; 
    long double ph[n], pt[n]; 
    for(int i=0; i < n; i++){
        cin >> ph[i]; 
        
        pt[i] = (1 - ph[i]);
    }
    int reqd = n; 
    long double dp[reqd+1][n+1];

    dp[0][0] = 0; 
    for(int i=0; i <= reqd ; i++){
        for(int j= 0 ; j <= n; j++){
            if(i > j){
                dp[i][j] = 0; 
            }
        }
    } 
    dp[0][1] = pt[0];
    for(int i=2; i <= n; i++){
        dp[0][i] = dp[0][i-1]*(pt[i-1]); 
    }
    dp[1][1] = ph[0]; 

    for(int i = 1; i <= reqd; i++){
        for(int j = 2; j <= n; j++){
            dp[i][j] = (dp[i][j-1] *pt[j-1]) + (dp[i-1][j-1]*ph[j-1]); 
        }
    }

    for(int i = 0; i <= reqd; i++){
        for(int j = 0; j <= n; j++){
            //cout << dp[i][j] << " " << "(" << i << "," <<  j << ") "  ;
        }
       // cout << endl;
    }

    long double ans = 0; 
    int strt = (n/2)+1; 
    //trace1(strt);
    for(int i=strt; i <= n; i++){
        ans += dp[i][n];
    }

    cout << setprecision(10) << ans << endl;
    return 0; 
}

Measured memory_bytes: 140928
import statistics

n=int(input())
a=[]
c=[]
for i in input().split():
    a.append(int(i))
    c.append(a[-1]-len(a))

b=round(statistics.median(c))
k=0

for i in range(n):
    k+=abs(a[i]-b-1-i)
print(k)

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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf  1e18
#define mk(arr,n,type) type *arr=new type[n];
#define ti(arr,n) for(ll i=0;i<n;++i)cin>>a[i];
#define ot(arr,n) for(ll i=0;i<n;++i)cout<<a[i]<<" ";
#define str(a) string a;cin>>a;
#define w(x) int x;cin>>x;while(x--)
int main()
{
   int n,x,t;cin>>n>>x>>t;
   int no=(int)(n/x);
   if(n%x!=0)
   ++no;
   cout<<no*t;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    vector<ll> cnt(60);
    rep(i,60){
        rep(j,n){
            if((v[j]>>i)&1) cnt[i]++; 
        }
    }
    ll ans = 0;
    rep(i,60){
        ll now = cnt[i]*(n-cnt[i])%mod;
        rep(j,i){
            now *= 2;
            now %= mod;
        }
        now %= mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		//標準入力取得
		int windowLength = sc.nextInt();
		int curtainLength = sc.nextInt();

		System.out.println(Math.max(0, windowLength - (curtainLength * 2)));

		sc.close();
	}
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    rep(i, S.length()) cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,k;
	char st[4],nd[4],rd[4];
	for (i=0;i<3;i++)
		scanf(" %c",&st[i]);
		
	for (j=0;j<3;j++)
		scanf(" %c",&nd[j]);
		
	for (k=0;k<3;k++)
		scanf(" %c",&rd[k]);
	printf("%c%c%c",st[0],nd[1],rd[2]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int[] a = new int[n];
			int[] b = new int[n];
			int[] c = new int[n-1];

			//Input

			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			for(int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}
			for(int i = 0; i < n - 1; i++) {
				c[i] = sc.nextInt();
			}

			//けーさん
			int ans = 0;
			for(int i = 0; i < n; i++) {
				ans +=b[a[i] - 1];
			}
			for(int i = 0; i < n -1; i++) {
				if(a[i] + 1 == a[i+1]) {
					ans += c[a[i] - 1];
				}
			}



			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 35720
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る事前計算
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<int> prime_factor(int n){
	vector<int>res;
	for (int i = 2;i*i <= n; ++i) {
		while (n % i == 0) {
			res.push_back(i);
			n /= i;
		}
	}
	if (n != 1)res.push_back(n);
	return res;
}

int main(){
	int n, m;
	cin >> n >> m;
	if(m == 1){puts("1");return 0;}
	vector<int>v = prime_factor(m);
	COMinit();
	int cnt = 1, p = v[0];
	long long res = 1;
	for(int i = 1; i < v.size(); ++i){
		if(p != v[i])res *= COM(n - 1 + cnt, n - 1), p = v[i], cnt = 0;
		cnt++;
		res %= MOD;
	}
	res *= COM(n - 1 + cnt, n - 1);
	res %= MOD;
	cout << res << endl;
}

Measured memory_bytes: 12160
S = list(input())
n = len(S)
a = []

sbox = []


for i in S:
    a.append(int(i))

def dfs(i,box,k):
    if i == n-1:
        box += k
        sbox.append(box)
    else:
        dfs(i+1,box+k,a[i+1])
        dfs(i+1,box,10*k+a[i+1])

dfs(0, 0, a[0])
print(sum(sbox))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();
        int Q = scanner.nextInt();

        String S = scanner.next();

        boolean flag = false;
        char[] charArray = S.toCharArray();
        int count = 0;
        int[] ret = new int[N];
        for (int i = N-1; i >= 0; i--) {
            char c = charArray[i];
            if (c == 'C') {
                flag = true;
            } else if (c == 'A') {
                if (flag) {
                    count++;
                }
                flag = false;
            } else {
                flag = false;
            }
            ret[i] = count;
        }

        for (int i = 0; i < Q; i++) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();

            System.out.println(ret[l-1]-ret[r-1]);
        }
    }

}


Measured memory_bytes: 65796
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a+b)>(c+d)) cout<<"Left"<<endl;
    else if((a+b)<(c+d)) cout<<"Right"<<endl;
  else if((a+b)==(c+d)) cout<<"Balanced"<<endl;
    return 0;
}

Measured memory_bytes: 384
#![allow(unused_imports)]
use proconio::*;
use num::Integer;

#[fastout]
fn main() {
   input! {
      k: usize,
   }
   let mut ans = 0;
   for a in 1..(k+1) {
       for b in 1..(k+1) {
           for c in 1..(k+1) {
               ans += a.gcd(&b).gcd(&c);
           }
       }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
#define ll long long
#define N 200005
#define M 998244353
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll n,m,k;
ll bigmod(ll a,ll b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%M;
    ll ans=bigmod(a,b/2);
    ans=(ans*ans)%M;
    if(b%2==1)
    {
        ans=(ans*a)%M;
    }
    return ans;
}
ll fact[N];
ll C(ll n,ll r)
{
    ll up=fact[n];
    ll down=(fact[r]*fact[n-r])%M;
    down=bigmod(down,M-2);
    up=(up*down)%M;
    return up;
}

main()
{
    fact[0]=1;
    for(ll i=1;i<N;i++)
    {
        fact[i]=(fact[i-1]*i)%M;
    }
    ll tot=0;
    cin>>n>>m>>k;
    for(ll i=n-1;i>=0;i--)
    {
        if(n-1-i<=k)
        {
            ll plot=i+1;
            ll ans=m*bigmod(m-1,i);
            ans%=M;
            ans=(ans*C(n-1,i));
            tot=(tot+ans)%M;
        }
    }
    cout<<tot;
}


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

//// D
int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    int ans=0;
    rep(b,n) rep(a,b){
        int ab = v[a]+v[b];
        int r = lower_bound(v.begin(), v.end(), ab) - v.begin();
        int l = b+1;
        ans += max(0, r-l);
    }
    cout << ans;
}

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

int main(){
  int N , M , X;
  cin >> N >> M >> X;
  vector <int> A(M);
  for(int i = 0; i < M; i++){
    cin >> A.at(i);
  }
  int P = 0;
  int Q = 0;
  for(int i = 0; i < M; i++){
    if(A.at(i) > X){
      Q++;
    }
    else{
      P++;
    }
  }
  cout << min(P , Q) << endl;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
s=input()
sum_a=0
sum_b=0
for c in list(s):
    if c=='a':
        if sum_a+sum_b < a+b:
            sum_a+=1
            print('Yes')
        else:
            print('No')
    elif c=='b':
        if sum_a+sum_b < a+b and sum_b<b:
            sum_b+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
int main() {
  bool ans = false;
  int N,M;
  cin >> N >> M;
  vector<vector<char> > A(N, vector<char>(N));
  vector<vector<char> > B(M, vector<char>(M));
  vector<vector<bool> > F(N - M + 1, vector<bool>(N - M + 1,true));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B[i][j];
    }
  }
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A[i + k][j + l] != B[k][l]) {
             F[i][j] = false;
            }
          }
        }
      }
    }
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
        if (F[i][j] == true) {
          ans = true;
        }
      }
    }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,a.size()){
        cin>>a[i];
    }
    int ans = 0;
    rep(i,1,a.size()){
        if ( a[i] < a[i-1] ){
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 4776
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int n;
int Ask(int x){
	cout<<x<<endl;
	fflush(stdout);
	string res;
	cin>>res;
	if (res=="Vacant")
		exit(0);
	return res=="Male";
}
void Solve(int lv,int rv,int L,int R){
	int mid=(L+R)>>1,lenL=mid-L,lenR=R-mid;
	int v=Ask(mid);
	if ((lv^v)==(lenL&1))
		Solve(lv,v,L,mid-1);
	else
		Solve(v,rv,mid+1,R);
}
int main(){
	n=read();
	int s=Ask(0);
	Solve(s,s,1,n-1);
	return 0;
}

Measured memory_bytes: 852
using System;

class C
{
	static void Main(string[] args)
	{
		var input1Line = Console.ReadLine();
		var k = int.Parse(input1Line);
		var intArray = new int[k + 1];
		intArray[1] = 7 % k;
		for (int i = 2; i <= k; i++)
		{
			intArray[i] = (intArray[i - 1] * 10 + 7) % k;
		}

		for (int i = 1; i <= k; i++)
		{
			if (intArray[i] == 0)
			{
				Console.WriteLine(i);
				return;
			}
		}
		Console.WriteLine(-1);
	}
}


Measured memory_bytes: 31104
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 2e5+10,MAX = 5000000;

int main()
{
    ll n,w,i,j,s=0;
    cin>>n>>w;
    ll wt[n],val[n];
    f(n) {
        cin>>wt[i]>>val[i];
        s+= val[i];
    }

    vector<ll> v(s+1,INF);
    v[0] = 0;
    for(i=0;i<n;i++)
    {
        for(j = s;j>0;j-- )
        {
            if(j>=val[i])
            v[j] = min(v[j],wt[i]+v[j-val[i]]);
        }
    }
    ll ans = 0;
    for(i=s;i>=0;i--)
    {
        if(v[i]<=w)
        {
            ans = i;
            break;
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 1024
#include<stdio.h>

int cnt1[100005]={0},cnt2[100005]={0};
int main(){
	int n;
	int ai;
	scanf("%d",&n);
	for(int i=0;i<n;i+=2){
		scanf("%d",&ai);cnt1[ai]++;
		scanf("%d",&ai);cnt2[ai]++;
	}
	int f1=0,f2=0,s1=0,s2=0;
	for(int i=0;i<=100000;i++){

		if(cnt1[i]>cnt1[f1]){
			s1=f1;f1=i;
		}
		else if(cnt1[i]>cnt1[s1]){
			s1=i;
		}
		if(cnt2[i]>cnt2[f2]){
			s2=f2;f2=i;
		}
		else if(cnt2[i]>cnt2[s2]){
			s2=i;
		}
	}
	int ans=0;
	if(f1!=f2){
		ans=n-cnt1[f1]-cnt2[f2];
	}
	else {
		ans=n-cnt1[f1]-cnt2[s2];
		if(ans>n-cnt1[s1]-cnt2[f2])ans=n-cnt1[s1]-cnt2[f2];
	}
	printf("%d\n",ans );
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
void solve()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int suff[n+1]={};
    for(int i=n-1;i>=0;i--)
    {
        suff[i]=suff[i+1]+arr[i];
    }
    int ans=0;
    int mod=pow(10,9)+7;
    for(int i=0;i<n;i++)
    {
        int x=suff[i+1];
        x%=mod;
        arr[i]*=x;
        arr[i]%=mod;
        ans+=arr[i];
        ans%=mod;
    }
    cout<<ans<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
    return 0;
}


Measured memory_bytes: 6740