akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())

X = math.floor(N/1.08)
X2 = math.floor(X*1.08)

#print(X,X2)
while(N>X2):
  X=X+1
  X2 = math.floor(X*1.08)

#print(X2)
if N==X2:
  print(X)
  
else:
  print(":(")

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(M), b(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
	}
	vector<int> count(N, 0);
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < M; j++) {
			if (i == a[j] || i == b[j]) {
				count[i - 1]++;
			}
		}
		cout << count[i - 1] << endl;
	}

	return 0;
}

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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

LL fib(int n) 
{ 
    
  LL f[n + 2];  
  LL i; 

  // 0th and 1st number of the  
  // series are 0 and 1 
  f[0] = 2; 
  f[1] = 1; 

  for(i = 2; i <= n; i++) 
  { 
    f[i] = f[i - 1] + f[i - 2]; 
  } 
  return f[n]; 
} 

int tt = 1;
void solve() {
  int n;
  cin >> n;
  cout << fib(n) << endl;
  //cout << fib(86) << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int high[n];
    for(int i=0; i<n; i++){
        cin >> high[i];
    }
    int M=high[0];
    int ans=1;
    for(int i=1; i<n; i++){
        if(M<=high[i]){
            ans++;
            M=high[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

typedef pair<string, ii> ps;
const int N = 101;
ps arr[N];

bool cmp(ps a, ps b) {
	if(a.ff != b.ff) return a.ff < b.ff;
	return a.ss.ff > b.ss.ff;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;cin>>n;
    FOR(i, 0, n) {
    	cin>>arr[i].ff>>arr[i].ss.ff;
    	arr[i].ss.ss = i;
    }
    sort(arr, arr+n, cmp);
    FOR(i, 0, n) {
 		cout<<arr[i].ss.ss+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  s = get_strs
  a = s[0].to_i
  b = s[1].to_i
  x = s[2].to_f
  x = x / a
  if x >= (a * b / 2.0)
    tan_z = 2.0 * (a * b - x) / (a * a * 1.0)
  else
    tan_z = b * b / (2.0 * x)
  end
  rad_z = Math.atan(tan_z)
  z = rad_z * 180.0 / Math::PI
  puts z
end

if __FILE__ == $0
  main
end

Measured memory_bytes: 1788
#!/usr/bin/env python3
import sys


def solve(L: int, R: int, d: int):
    ans = 0
    for i in range(L, R+1):
        if i % d == 0:
            ans += 1
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    print(solve(L, R, d))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9060
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, list(input().rstrip())))


def contains(n):
    t = n&-n
    return t.bit_length()


def solve1(A, D):
    is1 = False
    cmb_e = 0
    for i, a in enumerate(A):
        if a and cmb_e == 0:
            is1 = not is1
        cmb_e += contains(D-1-i) - contains(i+1)
    return is1

B = [abs(A[i]-A[i+1]) for i in range(N-1)]
if 1 in set(B):
    C = [b%2 for b in B]
    is1 = solve1(C, N-1)
    print(1 if is1 else 0)
else:
    C = [b//2 for b in B]
    is2 = solve1(C, N-1)
    print(2 if is2 else 0)

Measured memory_bytes: 149940
#include <stdio.h>
#include <string.h>
#define N 100005
#define M 1000000007
typedef long long LL;

char s[N];
LL p3[N];

int main()
{		
	int i, l, j, t;
	LL ans = 1, tt;
	
	scanf("%s", s);
	l = strlen(s);
	for(i = 1, p3[j = 0] = 1; i < l; j = i++){
		p3[i] = p3[j] * 3 % M;
	}
	for(i = 1, j = 0, tt = 0; i < l; j = i++){
		tt += p3[j];
	}
	ans = (ans + tt * 2) % M;
	
	for(i = 1, tt = 2, j = l - 2; i < l; i++, j--){
		if(s[i] == 48) continue;
		ans += tt * p3[j] % M;
		tt <<= 1;
		if(tt >= M) tt -= M; 
	}
	ans = (ans + tt) % M;
	printf("%lld\n", ans);
			
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int gcd(int n,int m){
	int min,max;
	if (n<m){
		min=n;
		max=m;
	}else{
		min=m;
		max=n;
	}
	if (min==0) return max;
	else{
		return gcd(max%min,min);
	}
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int>l(n),r(n);
	l[0]=a[0];
	r[n-1]=a[n-1];
	for(int i=1;i<n;i++){
		l[i]=gcd(l[i-1],a[i]);
		r[n-i-1]=gcd(r[n-i],a[n-i-1]);
	}
	int max=0,result;
	for(int i=0;i<n;i++){
		if (i==0) result=r[1];
		else if (i==n-1) result=l[n-2];
		else{
		result=gcd(l[i-1],r[i+1]);
		}
		if(max<result) max=result;
	}
	cout<<max<<endl;


	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int ans = 0;
	for (i = 1; i < n; i++)
	{
		if (a[i - 1] > a[i])
		{
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
#include <array>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    scanf("%d",&n);
    array<int,100100> mp={};
    int tmp;
    while(n--){
        scanf("%d", &tmp);
        mp[tmp]++;
        mp[tmp+2]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x);
    }
    cout << result << endl;
    return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int a=1;
  	for (int i = 0; i < N; i++) {
    	if (a*2 <= a + K){
        	a *= 2;
        }
        else{
        	a += K;
        }
    }
   cout << a << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n;
  cin >> n;
  cout << n * (n + 1) / 2 - n << endl;
}

Measured memory_bytes: 384
<?php
declare(strict_types=1);

fscanf(STDIN, "%d %d", $n, $k);
$p = explode(" ", trim(fgets(STDIN)));
sort($p);

$count = 0;

$sum = 0;
foreach ($p as $item) {
    if ($count >= $k) {
        break;
    }

    $sum = $sum + $item;
    $count++;

}

echo $sum;


Measured memory_bytes: 16128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    Task solver = new Task();
    solver.solve(1, in, out);
    out.close();
  }

  static class Task {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int r = Integer.parseInt(in.next());
      out.println(r * r * 3);
    }

  }
}



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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int check_num(const vi& w, const int p, const int k) {
    int i = 0;
    int n = w.size();

    rep(track, 0, k) {
        int sum = 0;
        while (w[i] + sum <= p) {
            sum += w[i];
            ++i;
            if (i == n) return n;
        }
    }
    return i;
}

int binary_search(const vi& w, const int k, const int max_w) {
    int left = 0, right = w.size() * max_w;

    while (left < right) {
        int mid = (left + right) / 2;
        if (check_num(w, mid, k) < w.size()) { left = mid + 1; }
        else { right = mid; }
    }
    return left;
}

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

    int max_w = 0;
    vi w(n);
    rep(i, 0, n) {
        cin >> w[i];
        max_w = max(w[i], max_w);
    }

    int ans = binary_search(w, k, max_w);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    vector<ll> d;
    rep(i, n)
    {
        ll now = 0;
        rep2(j, i, n)
        {
            now += a[j];
            d.push_back(now);
        }
    }
    ll co = 40;
    ll ans = 0;
    vector<bool> ex(d.size(), true);
    while (co >= 0)
    {
        ll now = 0;
        rep(i, d.size())
        {
            if (d[i] >> co & 1)
            {
                if (ex[i])
                {
                    now++;
                }
            }
        }
        if (now >= k)
        {
            ans += (1LL << co);
            rep(i, d.size())
            {
                if (!(d[i] >> co & 1))
                {
                    ex[i] = false;
                }
            }
        }
        co--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 7456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

class UnionFind {
  public:
  // 親の番号を格納。ルートだった場合は-(その集合のサイズ)
  vector<ll> parents;

  UnionFind(ll N) {
    parents = vector<ll>(N, -1);
  }

  // iがどのグループに属しているか
  ll root(ll i) {
    if (parents[i] < 0) {
      return i;
    } else {
      return parents[i] = root(parents[i]);
    }
  }

  // iが属しているグループの大きさ
  ll size(ll i) {
    return -parents[root(i)];
  }

  // root(a)とroot(b)を接続する
  bool connect(ll a, ll b) {
    ll rootA = root(a);
    ll rootB = root(b);
    if (rootA == rootB) {
        return false;
    } else {
      // 大きいほう(a)に小さいほう(b)をくっつける
      // 大小が逆の場合はスワップ
      if (size(rootA) < size(rootB)) {
        swap(rootA, rootB);
      }

      // aグループのサイズを増やす
      parents[rootA] += parents[rootB];
      // bの親をaのルートに変更する
      parents[rootB] = rootA;

      return true;
    }
  }

};

int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (ll i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  vector<ll> ans(M);
  // 橋が全部崩落した
  ans[M-1] = N*(N-1)/2;

  UnionFind Uni(N);
	for (int i = M - 1; i >= 1; i--) {
		//繋がってなかったのが繋がった時
		if (Uni.root(A[i]) != Uni.root(B[i])) {
			ans[i - 1] = ans[i] - Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		} else {
         ans[i-1]=ans[i]; 
        }
	}
  for (ll i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		int[] deck = new int[9];
		for (int i = 0; i < t; i++) {
			int isOK = 1;
			for (int j = 0; j < 9; j++) {
				deck[j] = in.nextInt();
			}
			int colorSum = 0;
			for (int j = 0; j < 9; j++) {
				String color = in.next();
				deck[j] += ("R".equals(color)) ? 0x100
						: ("G".equals(color)) ? 0x10000 : 0x1000000;
				colorSum += deck[j];
			}
			colorSum /= 0x100;
			int xFF = 0xFF;
			for (int j = 0; j < 3; j++) {
				if ((colorSum & xFF) % 3 != 0) {
					isOK = 0;
					break;
				}
				xFF <<= 8;
			}
			if (isOK == 1) {
				Arrays.sort(deck);
				int j = 0;
				while (j < 9) {
					if (deck[j] + 2 < deck[j + 2]) {
						isOK = 0;
						break;
					}
					if ((deck[j] == deck[j + 1] && deck[j + 1] == deck[j + 2])
							|| (deck[j] + 1 == deck[j + 1] && deck[j] + 2 == deck[j + 2])) {
						j += 3;
					} else if (j <= 3 && deck[j] + 1 == deck[j + 2]
							&& deck[j] + 2 == deck[j + 4]
							&& deck[j + 1] + 1 == deck[j + 3]
							&& deck[j + 1] + 2 == deck[j + 5]) {
						j += 6;
					} else {
						isOK = 0;
						break;
					}
				}
			}
			System.out.println(isOK);
		}
	}
}

Measured memory_bytes: 20792
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
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; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int ans=0;;
    int n;
    int a,b;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        string hoge=to_string(i);
        int sum=0;
        rep(j,hoge.size())sum+=hoge[j]-'0';
        if(a<=sum&&sum<=b)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N,K = list(map(int,input().split()))

A = list(map(int,input().split()))

A.sort()

mod = 10**9 + 7

pow_list = [1,1]
p = 1

for i in range(2,N+1):
    p*=i
    p%=mod
    pow_list.append(p)

ans = 0

K_inv =  pow(pow_list[K-1],mod-2,mod)

#print(K_inv)

for i in range(N-K+1):
    coef = A[N-i-1] - A[i] + mod
    comb = pow_list[N-i-1] * pow(pow_list[N-K-i],mod-2,mod)
    comb%=mod
    comb*=K_inv
    comb%=mod
    ans += coef*comb
    ans %= mod

print(ans)

Measured memory_bytes: 64552
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define F first
#define S second

const int N=50+7;
const int x[4]={1, 0, -1, 0};
const int y[4]={0, 1, 0, -1};

int mp[N][N];// 0 = white ,  1 = black
queue<pii>  que;
bool inque[N][N];
int dist[N][N];

main()
{
	int h, w;
	cin >> h >> w;
	int cnt=0;
	for (int i=1; i<=h; i++)  {
		for (int j=1; j<=w; j++)  {
			char tmp;
			cin >> tmp;
			if (tmp=='.')  {
				mp[i][j]=0;
				cnt++;
			}
			else  {
				mp[i][j]=1;
				inque[i][j]=true;
			}
		}
	}
	for (int i=0; i<N; i++)  {
		mp[0][i]=1;
		mp[i][0]=1;
		inque[0][i]=true;
		inque[i][0]=true;
		mp[h+1][i]=1;
		mp[i][w+1]=1;
		inque[h+1][i]=true;
		inque[i][w+1]=true;
	}
	que.push({1, 1});
	inque[1][1]=true;
	dist[1][1]=1;
//	int ptr=1;
	while (!que.empty())  {
//		cout << ptr++ << endl;
		pii tmp=que.front();
		que.pop();
		int a=tmp.F, b=tmp.S;
//		inque[a][b]=true;
		for (int i=0; i<4; i++)  {
			if (!inque[a+x[i]][b+y[i]])  {
				dist[a+x[i]][b+y[i]]=dist[a][b]+1;
				que.push({a+x[i], b+y[i]});
				inque[a+x[i]][b+y[i]]=true;
			}
		}
	}
	if (dist[h][w]==0)  cout << -1 << endl;
	else  cout << cnt-dist[h][w] << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
$p=array();
while(1){
  list($a,$o,$b)=explode(' ',trim(fgets(STDIN)));
  if($o=='?')break;
  elseif($o=='+')$p[]=$a+$b;
  elseif($o=='-')$p[]=$a-$b;
  elseif($o=='*')$p[]=$a*$b;
  elseif($o=='/')$p[]=floor($a/$b);
}
print implode(PHP_EOL,$p);
?>

Measured memory_bytes: 15460
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var NL = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var s = new string[NL[0]];
            for (var i = 0; i < NL[0]; i++)
                s[i] = Console.ReadLine();

            Array.Sort(s);
            Console.WriteLine(string.Join("", s));
        }
    }
}


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

int main() {
    int x, y;
    cin >> x >> y;

    bool flag = false;

    for (int i = 0; i <= x; i++) {
        if (2*i + 4*(x-i) == y) flag = true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int wordsN = scanner.nextInt();
        String[] shiritoriW = new String[wordsN];
        String ans="Yes";
        shiritoriW[0] = scanner.next();
        checkLoop:
        for(int i=1;i<wordsN;i++){
            shiritoriW[i] = scanner.next();
            if(!(shiritoriW[i].charAt(0)==shiritoriW[i-1].charAt(shiritoriW[i-1].length()-1))){
                ans="No";
              break;
            } else {
                for(int j=i-1;j>=0;j--){
                    if(shiritoriW[i].equals(shiritoriW[j])){
                        ans = "No";
                        break checkLoop;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}


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

using namespace std;

int main() {
    vector<int> nums;

    string S;
    while (cin >> S) {
        if (isdigit(S[0])) {
            nums.push_back(stoi(S));
        } else {
            int tmp = nums.back();
            nums.pop_back();
            if (S == "+") {
                nums.back() += tmp;
            } else if (S == "-") {
                nums.back() -= tmp;
            } else if (S == "*") {
                nums.back() *= tmp;
            }
        }
    }

    cout << nums.back() << endl;
    return 0;
}



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

long long SumOfDigits(long long n) {
    long long sum = 0LL;
    while (n) {
        sum += n%10LL;
        n /= 10LL;
    }
    return sum;
}

int main() {
    long long N;
    cin >> N;
    cout << (N%SumOfDigits(N) == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int INF = 100010;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    int need[10];
    need[1]=2; need[2]=5; need[3]=5;
    need[4]=4; need[5]=5; need[6]=6;
    need[7]=3; need[8]=7; need[9]=6;
    int dp[n];
    rep(i,n+1) dp[i] = -INF;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        rep(j,m){
            if(i-need[a[j]]>=0){
                dp[i] = max(dp[i],dp[i-need[a[j]]]+1);
            }
        }
    }
    string ans = "";
    int rem=dp[n];
    int match=n;
    sort(a.begin(),a.end(),greater<int>());
    while(rem>0){
        rep(i,m){
            if(match-need[a[i]]>=0){
                if(dp[match-need[a[i]]] == rem-1){
                    string s = to_string(a[i]);
                    ans += s;
                    match -= need[a[i]];
                    rem--;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	line := s.Text()

	sped := strings.Split(line, " ")
	a, b, t := stoi(sped[0]), stoi(sped[1]), stoi(sped[2])

	sum := 0
	for i := 0; i < t; i++ {
		if (i+1)%a == 0 {
			sum += b
		}
	}
	fmt.Println(sum)
}

func stoi(s string) int {
	res, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return res
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<"\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#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 all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
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;
}


int main() {
    int n;
    char c;
    cin >> n;
    set<char> d;
    rep(i,n) {
        cin >> c;
        d.insert(c);
    }
    if (d.size() == 4) {
        cout << "Four" << "\n";
    } else {
        cout << "Three" << "\n";
    }
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(N-2):
  if P[i] > P[i+1] and P[i+1] > P[i+2] or P[i] < P[i+1] and P[i+1] < P[i+2]:
    ans += 1

print(ans)


Measured memory_bytes: 9124
N, K = map(int, input().split())

snuke = {}
for i in range(N):
    snuke[i] = 0

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for j in range(d):
        snuke[A[j]-1] += 1

ans = 0
for i in range(N):
    if snuke[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9140
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ',') {
			s[i] = ' ';
		}
	}
	cout << s << endl;
	return 0;
}



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

// #include "debug.h"
#define debug(...) 42

void solve() {
   int x;
   cin >> x;
   int cur = 8;
   int curScore = 400;
   int ans = cur;
   for(int curScore = 400; curScore < 2000; curScore += 200) {
      if(x >= curScore) {
         ans = cur;
      }
      cur--;
   }
   cout << ans << endl;
} 

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;

   for(int i = 0; i < testcase; i++) {
      solve();
   }
   return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if ((a <= c && c <= b) || (b <= c && c <= a))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	;
	vector<int> A(N);
	map<int, int> count;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		count[A.at(i)]++;
	}
	
	int Q;
	cin >> Q;

	vector<int> B(Q), C(Q);
	for (int i = 0; i < Q; i++) {
		cin >> B.at(i) >> C.at(i);
	}

	long long S = 0;
	for (int i = 0; i < N; i++)
		S += A.at(i);

	for (int i = 0; i < Q; i++) {
		S += ((long long)C.at(i) - (long long)B.at(i)) * (long long)count[B.at(i)];
		cout << S << endl;
		count[C.at(i)] += count[B.at(i)];
		count[B.at(i)] = 0;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  sort(an.begin(),an.end());
  reverse(an.begin(),an.end());
  ll ans = an[0];
  for(int i=2; i<n; ++i){
    ans += an[i/2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#define MOD 10000000
#define int long long
using namespace std;

signed main(){
	int m,mx[200],my[200],n,posn[1000];
	while(cin >> m,m){
	for(int i = 0;i < m;i++) {
		cin >> mx[i] >> my[i];
	}
	cin >> n;
	for(int i = 0;i < n;i++) {
		int x,y;
		cin >> x >> y;
		posn[i] = x * MOD + y;
	}
	sort(posn,posn + n);
	for(int i = 0;i < n;i++){
		bool flag = true;
		for(int j = 1;j < m;j++){
			int x = posn[i] / MOD + mx[j] - mx[0],y = posn[i] % MOD + my[j] - my[0];
			if(x >= 0 && x <= 1000000 && y >= 0 && y <= 1000000){
				int num = upper_bound(posn,posn + n,x * MOD + y) - lower_bound(posn,posn + n,x * MOD + y);
				if(num == 0) flag = false;
			}else flag = false;
		}
		if(flag){
			int nx = posn[i] / MOD,ny = posn[i] % MOD;
			cout << nx - mx[0] << " " << ny - my[0] << endl;
			break;
		}
	}
	}
	return 0;
}

Measured memory_bytes: 3156
N = int(input())
P = list(map(int, input().split()))
A = list(range(1, N + 1))

cnt = 0
for i in range(N) :
    if(P[i] != A[i]) :
        cnt += 1
    else :
        pass

if(cnt == 0 or cnt == 2) :
    print("YES")
else :
    print("NO")



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


using namespace std;

int main()
{
    int n ; cin>>n;
    vector<int>v(n);
    double s = 0.0;
    for(int& i : v){
        cin>>i;
        s += i;
    }
    int mid = round(s / (1.0 * n));
    int ans = 0;
    for(int& i : v){
        ans += (i - mid) * (i - mid);
    }
    cout<<ans<<"\n";
    
}


Measured memory_bytes: 256
d,g=map(int,input().split())
l=[list(map(int,input().split())) for i in range(d)]
#print(l)
ans=float('inf')
for i in range(1<<d):
    all_bits=[]
    for j in range(d):
        all_bits.append((i>>j)&1)
    cnt=0
    score=0
    maxscore_problem=0
    for k in range(d):
        if all_bits[k]==1:
            score+=100*(k+1)*l[k][0]+l[k][1]
            cnt+=l[k][0]
        else:
            maxscore_problem=k
    if g<=score:
        ans=min(ans,cnt)
    elif -(-(g-score)//(100*(maxscore_problem+1)))<l[maxscore_problem][0]:
        ans=min(ans,cnt+(-(-(g-score)//(100*(maxscore_problem+1)))))
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>

bool solve(int n, int m, std::vector<int> a) {
  std::vector<int> order(m + 1, -1), seq;
  std::vector<int> len(n, 0), cnt(m + 1, 0);
  int idx = 0;
  for (auto &v: a) {
    if (order[v] == -1) order[v] = ++idx, seq.push_back(v);
    if (cnt[v] == n) continue;
    if (len[cnt[v]] == order[v] - 1) ++len[cnt[v]], ++cnt[v];
  }
  int mx = len.back();
  cnt.assign(m + 1, 0);
  for (int i = 0; i < mx; ++i) cnt[seq[i]]++;
  std::vector<int> u;
  for (int i = 1; i <= m; ++i) if (cnt[i] == 0) {
    u.push_back(i);
  }
  for (int i = mx; i < idx; ++i) {
    if (u[i - mx] != seq[i]) return false;
  }
  return true;
}

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  std::vector<int> a(q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &a[i]);
  }
  std::reverse(a.begin(), a.end());
  if (solve(n, m, a)) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 3320
import sys
input = sys.stdin.readline
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for _ in range(n):
    a = list(map(int, input().split()))
    temp = 0
    for i in range(m):
        temp += a[i] * b[i]
    if temp + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import static java.util.Arrays.deepToString;

import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.ArrayBlockingQueue;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int sy = sc.nextInt();
			int sx = sc.nextInt();
			if (sx == 0 && sy == 0) break;
			int n = sc.nextInt();
			int[] px = new int[n];
			int[] py = new int[n];
			for (int i = 0; i < n; i++) {
				py[i] = sc.nextInt();
				px[i] = sc.nextInt();
			}
			
			int[] dx = {-2, -2, -2, -1, 0, +1, +2, +2, +2, +1, 0, -1};
			int[] dy = {+1, 0, -1, -2, -2, -2, -1, 0, +1, +2, +2, +2};
			Queue<State> q = new ArrayDeque<State>();
			q.add(new State(-1, sx, sy));
			boolean[][][] mark = new boolean[10][10][11];
			boolean success = false;
			while (!q.isEmpty()) {
				State state = q.poll();
				if (state.step == n) {
					success = true;
					break;
				}
				for (int i = 0; i < dx.length; i++) {
					int nx = state.x + dx[i];
					int ny = state.y + dy[i];
					int ns = state.step + 1;
//					tr(nx, ny, ns);
					if (0 <= nx && nx < 10 && 0 <= ny && ny < 10 && 
						(ns >= n || d(nx, ny, px[ns], py[ns]) <= 1)) {
						if (!mark[nx][ny][ns]) {
							q.add(new State(ns, nx, ny));
							mark[nx][ny][ns] = true;
						}
					}
				}
			}
			System.out.println(success ? "OK":"NA");
		}
	}
	
	static int d(int x1, int y1, int x2, int y2) {
		return Math.max(Math.abs(x1 - x2), Math.abs(y2 - y1));
	}
	
	static class State {
		int step;
		int x;
		int y;
		public State(int step, int x, int y) {
			this.step = step;
			this.x = x;
			this.y = y;
		}
	}
	
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  if(n%1000!=0){
  	cout << 1000-n%1000 << endl;
  }
  else{
    cout << "0" << endl;
  }
  return 0;
}




Measured memory_bytes: 3692
#include <iostream> 

using namespace std;

int main(void)
{
	int n, a, ans = 0;
	bool count = false;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		if (i + 1 == a){
			if (!count){
				ans++;
				count = true;
			}
			else count = false;
			
		}
		else count = false;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  string text;
  cin >> text;
  int tmp1 = text.size();
  if (tmp1 == 2) {
    cout << text << endl;
  }
  else if (tmp1 == 3) {
    cout << text.at(2) << text.at(1) << text.at(0) << endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<P>p(n);
  rep(i,n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());
  ll t=0;
  rep(i,n){
    t += p[i].second;
    if(t > p[i].first) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1920
function bubbleSort(A){
   var N=A.length;
   var flag=1;
   var i=0;
   var cnt=0;
   while(flag==1){
      flag=0;
      for(var j=N-1;j>=i+1;j--){
         if(A[j]<A[j-1]){
         var m=A[j];
         A[j]=A[j-1];
         A[j-1]=m;
         flag=1;
         cnt++;
         }
      }
      i++;   
   }
   return [A,cnt];
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
var arr=Arr[0].split(" ").map(Number);
var result=bubbleSort(arr);
console.log(result[0].join(" "));
console.log(result[1]);

Measured memory_bytes: 7904
#include <bits/stdc++.h>
#define For( i, j, k ) for( int i = j; i <= k; ++i )
inline int rdi( )
{
 int x = 0;
 char ch = getchar( );
 while( !isdigit( ch ) ) ch = getchar( );
 while( isdigit( ch ) ) x = x * 10 + ch - '0',ch = getchar( );
 return x;
}
void print( int x )
{
 if( x < 0 ) putchar( '-' ), x = -x;
 if( x < 10 ) { putchar( x + 48 ); return; }
 print( x / 10 ), putchar( x % 10 + 48 );
}
const int N = 5e5 + 1;
int n, m, L, R, cnt, a, lst[ N ], rt[ N ], ls[ N * 40 ], rs[ N * 40 ], sum[ N * 40 ];
int Query( int k, int pre, int l, int r, int pos )
{
 if( r <= pos ) return sum[ k ] - sum[ pre ];
 int mid = l + r >> 1;
 return pos <= mid ? Query( ls[ k ], ls[ pre ], l, mid, pos ) : sum[ ls[ k ] ] - sum[ ls[ pre ] ] + Query( rs[ k ], rs[ pre ], mid + 1, r, pos );
}
void Insert( int &k, int pre, int l, int r, int pos )
{
 k = ++cnt, ls[ k ] = ls[ pre ], rs[ k ] = rs[ pre ], sum[ k ] = sum[ pre ] + 1;
 if( l == r ) return;
 return pos <= ( l + r ) / 2 ? Insert( ls[ k ], ls[ pre ], l, ( l + r ) / 2, pos ) : Insert( rs[ k ], rs[ pre ], ( l + r ) / 2 + 1, r, pos );
}
int main( )
{
 n = rdi( ), m = rdi( ); For( i, 1, n ) a = rdi( ), Insert( rt[ i ], rt[ i - 1 ], 1, n, lst[ a ] + 1 ), lst[ a ] = i;
 For( i, 1, m ) L = rdi( ), R = rdi( ), print( Query( rt[ R ], rt[ L - 1 ], 1, n, L ) ), putchar( '\n' );
 return 0;
}

Measured memory_bytes: 125108
let dfs vs n =
  let d = Array.make n 0 in
  let f = Array.make n 0 in
  let rec search i time =
    d.(i) <- time;
    let time =
      List.fold_left (fun time v ->
        if d.(v-1) = 0 then search (v-1) time else time)
        (time + 1) vs.(i) in
    f.(i) <- time;
    time + 1 in
  Array.fold_left (fun (i, time) e ->
    (i + 1, if e = 0 then search i time else time))
    (0, 1) d |> ignore;
  (d, f)

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let vs = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> vs.(u-1) <- l
    | _ -> assert false
  done;
  let (d, f) = dfs vs n in
  for i = 0 to n - 1 do
    Printf.printf "%d %d %d\n" (i + 1) d.(i) f.(i)
  done

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)

void solve();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

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

void solve() {
    int length = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int j = i;
        while (true) {
            if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C') {
                j++;
            }else {
                length = max(length, j - i);
                break;
            }
        }
    }
    cout << length << "\n";
}


Measured memory_bytes: 3612
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

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


int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  
  if(L > R){
    cout << "Left" << endl;
  }else if(L == R){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  
  
  
  
  
  
}

Measured memory_bytes: 3600
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		int x = S[i] - 'A';
		x = (x + N) % 26;
		cout <<(char)('A' + x);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

const ll MAX_E = 2010;
const ll MAX_V = 1010;

struct edge
{
    ll from;
    ll to;
    ll cost;
}; // 頂点fromから頂点toへのコストcostの辺

edge es[MAX_E]; // 辺
ll d[MAX_V];    // 最短距離
ll V, E;        // Vは頂点数,Eは辺の数

// s番目の頂点から各頂点への最短距離を求める
bool bellman_ford(ll s)
{
    for (ll i = 0; i < V; i++)
    {
        d[i] = INF;
    }
    d[s] = 0;

    for (ll i = 0; i < V; i++)
    {
        for (ll j = 0; j < E; j++)
        {
            edge e = es[j];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost)
            {
                d[e.to] = d[e.from] + e.cost;
                if (i == V - 1 && e.to == V - 1)
                {
                    return false;
                }
            }
        }
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    for (ll i = 0; i < E; i++)
    {
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;
        es[i].to--;
        es[i].cost *= -1;
    }
    bool flg = bellman_ford(0);
    if (!flg)
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << -d[V - 1] << endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			char[] s = sc.scanString().toCharArray();
			char[] t = sc.scanString().toCharArray();
			boolean good = true;
			int[] map_s = new int[26];
			int[] map_t = new int[26];
			for (int i = 0; i < 26; ++i) {
				map_s[i] = -1;
				map_t[i] = -1;
			}

			for (int i = 0, n = s.length; i < n; ++i) {
				int cs = s[i] - 'a';
				int ct = t[i] - 'a';
				if (map_s[cs] == -1 && map_t[ct] == -1) {
					map_s[cs] = ct;
					map_t[ct] = cs;
				} else {
					if (map_s[cs] != ct || map_t[ct] != cs) {
						good = false;
						break;
					}
				}
			}

			System.out.println(good ? "Yes" : "No");
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 36116
#include <stdio.h>
int main(void){
  int n,i,l,r,ans=0;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d%d",&l,&r);
    ans+=r-l+1;
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
	int n;	cin>>n;
	vector<int> h(n);

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

	for(int i=0;i+1<n;i++){
		if(h[i]>=h[i+1]){
			x[i+1]=x[i]+1;
		}
	}

	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,x[i]);
	}
	cout<<ans<<endl;



	return 0;
}


Measured memory_bytes: 1024
// C - Sum of product of pairs
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i = x;i<n;i++)
#define loopr(i,x,n) for(ll i = n-1;i>=x;i--)
#define S(v) sort(v.begin(), v.end());
#define ff first
#define ss second
const ll mod = 1E9+7;
ll f(ll a, ll b){
    ll ans = 0;
    a %= mod;
    while(b){
        if(b%2)ans = (ans+a)%mod;
        a = (2*a)%mod;
        b = b/2;        
    }
    return ans;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n), suffixsum(n, 0);
    loop(i,0,n)cin>>v[i];
    loopr(i,0,n){
        if(i == n-1)suffixsum[i] = v[i];
        else suffixsum[i] = v[i] + suffixsum[i+1];
    }
    ll ans = 0;
    loop(i,0, n-1){
        ans += f(v[i], suffixsum[i+1])%mod;
    }
    cout<<ans%mod<<endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<double> v(N);
  
  for(int i=0; i<N ;i++){
    cin >> v.at(i);
  }
  
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  
  vector<long long int> kaijou(N);
  kaijou.at(0) = 1;
  
  long double sum=0;
  
  for(int i=1; i<N ;i++){
    kaijou.at(i) = kaijou.at(i-1)*2;
    long double x=0;
    x = v.at(i-1)/kaijou.at(i);
    
    sum = sum + x;
  }
  
  sum = sum + v.at(N-1)/kaijou.at(N-1);
  
  cout << fixed << setprecision(10);
  cout << sum << endl;
  
}



Measured memory_bytes: 3764
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x=0ll,i=0ll;
    cin>>x;
    while(true)
    {
    	lli sum=(1ll*i*(i+1ll))/2ll;
    	if(sum>=x)
    		break;
    	++i;
    }
    cout<<i<<endl;
}

Measured memory_bytes: 256