akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

int main(void) 
{
   ll a;
   long double b;
   cin >> a >> b;
   long double tmp = a*b;
   string s = to_string(tmp);
   int i = s.find('.');
   cout << s.substr(0,i)<< endl;
}

Measured memory_bytes: 3832
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
ans = len(make_divisors(n - 1)) - 1
for x in make_divisors(n):
  if x == 1:
    continue
  m = n
  while m % x == 0:
    m //= x
  if m % x == 1:
    ans += 1
print(ans)

Measured memory_bytes: 3188
from itertools import accumulate

N = int(input())
A = sorted(list(map(int,input().split())))
acmA = list(accumulate(A))
ans = 1
for i in range(N-2,-1,-1):
  if acmA[i]*2>=A[i+1]: ans += 1
  else:break
print(ans)

Measured memory_bytes: 64636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
def main():
    grid = []
    for i in range(3):
        grid.append(list(map(int,input().split())))

    n = int(input())
    nums = set()
    for i in range(n):
        b = int(input())
        nums.add(b)

    for i in range(3):
        found = True
        for j in range(3):
            if grid[i][j] not in nums:
                found = False
                break

        if found:
            print('Yes')
            return

    for i in range(3):
        found = True
        for j in range(3):
            if grid[j][i] not in nums:
                found = False
                break

        if found:
            print('Yes')
            return

    found = True
    for i in range(3):
        if grid[i][i] not in nums:
            found = False
            break

    if found:
        print('Yes')
        return

    found = True
    for i in range(3):
        if grid[i][3-i-1] not in nums:
            found = False
            break

    if found:
        print('Yes')
        return

    print('No')

main()


Measured memory_bytes: 3064
// Aizu Vol-2 0143   Altair and Vega
// 2017.8.8

#include <stdio.h>

int atSameSide(int x1, int y1, int x2, int y2, int xa, int ya, int xb, int yb)
{
	long long sa, sb;

	sa = (x2 - x1) * (ya - y1) + (y2 - y1) * (x1 - xa);
	sb = (x2 - x1) * (yb - y1) + (y2 - y1) * (x1 - xb);
	if (sb == 0 || sa == 0) while (1);  		 // xb,yb in line
	return (sa * sb > 0);            // xa,ya xb,yb at same side
}

int main()
{
	int n;
	int x1, y1, x2, y2, x3, y3, xk, yk, xs, ys;
	int kin, sin;

	scanf("%d", &n);
	while (n-- > 0) {
		scanf("%d%d%d%d%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3, &xk, &yk, &xs, &ys);
		kin = atSameSide(x1, y1, x2, y2, x3, y3, xk, yk) &
			  atSameSide(x2, y2, x3, y3, x1, y1, xk, yk) &
			  atSameSide(x3, y3, x1, y1, x2, y2, xk, yk);
		sin = atSameSide(x1, y1, x2, y2, x3, y3, xs, ys) &
		  	  atSameSide(x2, y2, x3, y3, x1, y1, xs, ys) &
			  atSameSide(x3, y3, x1, y1, x2, y2, xs, ys);
		puts((kin & 1) ^ (sin & 1) ? "OK" : "NG");
	}
	return 0;
}

Measured memory_bytes: 584
#標準入力の受け取り
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

#Aの各値を二進数にした時の桁ごとに配列にまとめる
bit_lis = [0] * 61
for i in range(61):
    bit_lis[i] = np.count_nonzero(A & 1)
    A >>=1
        
#各桁について値を計算する
ans = 0
bit_1 = 0
mod = 10 ** 9 + 7
for i in range(61):
    bit_1 = bit_lis[i]
    if bit_1 == 0:
        continue
    ans += pow(2, i, mod) * bit_1 * (N-bit_1) 
    ans = ans % mod
print(ans)

Measured memory_bytes: 48824
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int64_t X;

struct TItem {
    int64_t b;
    int64_t l;
    int64_t r;
    int64_t sum;
    TItem(int _b, int _l, int _r) : b(_b), l(_l), r(_r), sum(r * (X - b) + b * l)
    {}
};

inline int64_t getsum(const vector<int64_t>& sums, const int idx, const int my) {
    auto result = sums[idx];
    if (my < idx) {
        result = sums[idx + 1];
        result -= sums[my + 1] - sums[my];
    }
    return result;
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n >> X;

    vector<TItem> a;
    int64_t need = 0;
    for (int i = 0; i < n; ++i) {
        int64_t b,l,u;
        cin >> b >> l >> u;
        a.emplace_back(b, l, u);
        need += b * l;
    }

    sort(begin(a), end(a), [](const TItem& lhs, const TItem& rhs) {return lhs.sum > rhs.sum;});

    vector<int64_t> sums(n + 1, 0);
    for (int i = 1; i <= n; ++i)
        sums[i] = sums[i - 1] + a[i - 1].sum;

    int64_t l = -1;
    int64_t r = X * n;

    while (r - l > 1) {
        auto mid = (l + r) >> 1;
        int64_t rest = mid % X;
        int64_t best = 0;
        for (int i = 0; i < n; ++i) {
            int64_t cur = rest * a[i].l;
            if (rest > a[i].b)
                cur = a[i].r * (rest - a[i].b) + a[i].b * a[i].l;
            cur += getsum(sums, mid/X, i);
            best = max(best, cur);
        }
        if (best >= need)
            r = mid;
        else
            l = mid;
    }
    cout << r << endl;
}


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

using namespace std;

constexpr int mod = 2019;

int main() {
  string s;
  cin >> s;
  vector<int> cnt(2020);
  cnt.at(0)++;
  int cur = 0;
  int pow = 1;
  reverse(s.begin(), s.end());
  for (char c : s) {
    int tmp = (int)(c - '0');
    cur = (cur + tmp * pow) % mod;
    pow = (pow * 10) % mod;
    cnt.at(cur)++;
  }
  int res = 0;
  for (int i=0; i<2020; ++i) {
    res += cnt.at(i) * (cnt.at(i) - 1) / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>> vp(n);
    rep(i,n)cin >> vp[i].second >> vp[i].first;
    sort(begin(vp),end(vp));
    ll time = 0;
    for(auto a : vp){
        if(time + a.second > a.first){
            cout << "No\n";
            return 0;
        }else{
            time += a.second;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3328
<?php

const MOD = 1000000007;
bcscale(36);

fscanf(STDIN, "%d", $N);
$p_count = 0;
$n_count = 0;
$ans = 1;
$ans_list = [];
$ans_list[0] = 0;
$p_list =[];
$n_list= [];
$zero_count = 0;
$a_zero = 0;
$b_zero = 0;
for($i=1;$i<=$N;$i++){
    $ans *= 2;
    $ans_list[$i] = ($ans - 1) %MOD;

    $ans %= MOD;

    fscanf(STDIN, "%d%d", $a, $b);
    $map[$i] = [$a, $b];
    if($a == 0 && $b == 0){
        $zero_count++;
    }elseif($a == 0){

        $p_list[0][] = $i;
        $p_count++;

    }elseif($b == 0){

        $n_list[0][] = $i;
        $n_count++;
    }else {

        if (($a > 0 && $b > 0) || $a < 0 && $b < 0) {
            $div = md5(bcdiv($b, $a));

            $p_list[$div][] = $i;
            $p_count++;
        } else{
            $n_list[md5(bcdiv(abs($a), abs($b)))][] = $i;
            $n_count++;
        }
    }
}
$diff = $N;
$ans = 1;
    foreach($p_list as $key => $value){
        if(isset($n_list[$key])){
            $p = count($p_list[$key]);
            $n = count($n_list[$key]);
            $ans = $ans * (($ans_list[$p] + $ans_list[$n] + 1) %MOD) % MOD;
            $diff -= ($p + $n);
        }
    }

    $diff-=$zero_count;
    if($ans == 0){
        $ans += MOD;
    }
$ans = (($ans * (($ans_list[$diff]+1) )  -1) %MOD + $zero_count) %MOD;
echo $ans;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t;
  int q;
  cin >> s >> t >> q;
  
  vector<int> x(s.size() + 1), y(t.size() + 1);
  for (int i = 1; i <= s.size(); i++) {
    if (s.at(i - 1) == 'A') x.at(i) = 1;
    else x.at(i) = 2;
    x.at(i) += x.at(i - 1);
  }
  for (int i = 1; i <= t.size(); i++) {
    if (t.at(i - 1) == 'A') y.at(i) = 1;
    else y.at(i) = 2;
    y.at(i) += y.at(i - 1);
  }
  
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((x.at(b) - x.at(a - 1)) % 3 == (y.at(d) - y.at(c - 1)) % 3) cout << "YES\n";
    else cout << "NO\n";
  }
}

Measured memory_bytes: 1744
import java.util.Scanner;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println((A % 2 == 1 & B%2 == 1)? "Yes":"No");
        sc.close();
    }
}

Measured memory_bytes: 22100
using System;
using System.Collections.Specialized;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        // 解
        //int ans = 0;
        string ans = string.Empty;
        //long ans = 0;
        //double ans = 0;

        // 入力
        string inp = MyConsole.ReadStr();

        // 処理
        char[] chrs = inp.ToCharArray().Where((elm, idx) => (idx + 1) % 2 == 1).ToArray();
        ans = new string(chrs);

        // 出力
        MyConsole.WriteLine(ans);
    }
}

class MyConsole
{
    // 文字列または数値の入力
    public static string ReadStr() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Console.ReadLine()); }
    public static long ReadLong() { return long.Parse(Console.ReadLine()); }
    public static string[] ReadStr(char sep) { return Console.ReadLine().Split(sep); }
    public static int[] ReadInt(char sep) { return Console.ReadLine().Split(sep).Select(x => int.Parse(x)).ToArray(); }
    public static long[] ReadLong(char sep) { return Console.ReadLine().Split(sep).Select(x => long.Parse(x)).ToArray(); }

    public static void WriteLine(object param) { Console.WriteLine(param); }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        final int N = s.nextInt();

        String nStr = String.valueOf(N);
        int nStrOne = Integer.parseInt(nStr.substring(nStr.length() - 1));
        //System.out.println(nStrOne);
        if (nStrOne == 2
                || nStrOne == 4
                || nStrOne == 5
                || nStrOne == 7
                || nStrOne == 9) {
            System.out.println("hon");
        } else if (nStrOne == 0
                || nStrOne == 1
                || nStrOne == 6
                || nStrOne == 8) {
            System.out.println("pon");
        } else {
            System.out.println("bon");
        }
    }
}

Measured memory_bytes: 27080
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
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; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int X, K, D; cin >> X >> K >> D;
	X = abs(X);
	if ( X/K >= D) {
		print(X - K * D);
	}
	else {
		int ok = X / D;
		int a = X - ok * D;
		int r = K - ok;
		if (r & 1) {
			print(abs(a - D));

		}
		else print(a);
	}
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    Rep (i, H) {
        cin >> S[i];
    }

    mat s(H, vec(W+1, 0));
    Rep (i, H) {
        Rep (j, W) {
            s[i][j+1] += s[i][j] + (S[i][j] == '1');
        }
    }

    ll ans = inf;

    Rep (i, 1 << (H-1)) {
        ll tmp = 0;
        Rep (j, H-1) {
            if (i & (1 << j)) {
                tmp++;
            }
        }
        mat cnt(tmp+1, vec(W+1, 0));
        ll now = 0;
        Rep (j, H) {
            Rep (k, W+1) {
                // cout << now << "\n";
                cnt[now][k] += s[j][k];
            }
            if (i & (1 << j)) {
                now++;
            }

        }

        // cout << i << "\n";
        // Rep (j, tmp+1) {
        //     Rep (k, W+1) {
        //         cout << cnt[j][k] << " \n"[k==W];
        //     }
        // }

        ll a = tmp + 1;
        ll left = 0;
        while (left < W) {
            ll right = inf;
            Rep (j, a) {
                auto e = upper_bound(cnt[j].begin(), cnt[j].end(), cnt[j][left] + K);
                chmin(right, e - cnt[j].begin());
            }
            // cout << i << " " << left << " " << right << "\n";
            if (left + 1 == right) {
                tmp = inf;
                break;
            }
            if (right < W+1) {
                tmp++;
                left = right - 1;
            } else if (right == W+1) {
                left = right - 1;
            }
        }

        chmin(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// ????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		// ??£?¨?
		String line = "";
		char temp;
		// 26???????????¨?????????
		int[] array = new int[26];
		while (sc.hasNext()) {
			// ??±????????????
			line = sc.nextLine();
			// ??¨???????????????????°??????????????????????
			String lower = line.toLowerCase();
			// System.out.println(lower);
			// ?????????char ??????
			for (int i = 0; i < lower.length(); i++) {
				temp = lower.charAt(i);
				// System.out.println(temp);
				// ??\?????????????????¨a?????¢???????????????????????°?????§??????
				// if(Character.isLetter('a')){
				if ('a' <= temp && temp <= 'z') {
					array[temp - 'a']++;
				}
			}
		}
		for (int i = 0; i < array.length; i++) {
			System.out.println((char) ('a' + i) + " : " + array[i]);
		}
	}
}

Measured memory_bytes: 26012
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>

using namespace std;

int main()
{
    int angle, X, K;

    scanf("%d", &X);
    K = 1;
    angle = X;
    while(angle){
        ++K;
        angle = (angle + X) % 360;
    }
    printf("%d", K);

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define int long long
using namespace std;
int z,d,ans,sum;
map<int,int>mp;
signed main(){
    cin>>z>>d;
    mp[0]++;
    while(z--){
        int x;
        cin>>x;
        sum+=x;
        sum%=d;
        ans += mp[sum];
        mp[sum]++;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 4224
import bisect
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
#b, c = [], []
bc = []
heapq.heapify(a)

for i in range(m):
    bc.append(list(map(int, input().split())))
    # v1, v2 = map(int, input().split())
    # b.append(v1)
    # c.append(v2)
bc.sort(key = lambda x: x[1], reverse=True)

for i in range(m):
    cnt = 0
    while True:
        if cnt == bc[i][0]:
            break
        minV = heapq.heappop(a)
        #print('# minV: ' + str(minV))
        if minV >= bc[i][1]:
            heapq.heappush(a, minV)
            break
        else:
            heapq.heappush(a, bc[i][1])
        cnt += 1

#print(a)
print(sum(a))




Measured memory_bytes: 100360
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import numpy as np


# In[2]:


H, W = map(int, input().split())
S = np.ones((H, W), dtype=np.bool)
for i in range(H):
    S[i] = [s == "." for s in input()]


# In[3]:


up = np.zeros((H, W), dtype=np.int16)
down = np.zeros((H, W), dtype=np.int16)
left = np.zeros((H, W), dtype=np.int16)
right = np.zeros((H, W), dtype=np.int16)

# up
up[0, :] = S[0, :]
for h in range(1, H):
    up[h, :] = up[h - 1, :] + 1
    up[h, :] *= S[h, :]

# down
down[H - 1, :] = S[H - 1, :]
for h in reversed(range(0, H - 1)):
    down[h, :] = down[h + 1, :] + 1
    down[h, :] *= S[h, :]

# left
left[:, 0] = S[:, 0]
for w in range(1, W):
    left[:, w] = left[:, w - 1] + 1
    left[:, w] *= S[:, w]

# right
right[:, W - 1] = S[:, W - 1]
for w in reversed(range(0, W - 1)):
    right[:, w] = right[:, w + 1] + 1
    right[:, w] *= S[:, w]

ans = np.max(up + down + left + right - 3)
print(ans)


# In[ ]:






Measured memory_bytes: 70244
#include<iostream>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int a, b, ans;

int main() {
    cin >> a >> b;
    REP(i, a, b+1) {
        string now = to_string(i);
        if (now[0] == now[4] && now[1] == now[3]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

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

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

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

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

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

  int N, K;
  cin >> N >> K;

  int ans = 1;
  for(int i = 0; i < N; i++){
    if(ans < K){
      ans *= 2;
    }else{
      ans += K;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();

		A -= K;
		if(A < 0){
			B += A;
			A = 0;
		}
		if(B < 0){
			B = 0;
		}
		System.out.println(A +" "+ B);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1)
    a = 100;
  if(b == 1)
    b = 100;

  if(a > b)
    P("Alice");
  else if(a == b)
    P("Draw");
  else
    P("Bob");

  ret 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
int main()
{
    int q;scanf("%d",&q);
    while(q--)
    {
        scanf("%lld%lld",&a,&b);
        ll s=a*b,ans;
        ll t=sqrt(s);
        if(t*(t+1)<s) ans=2*(t-1)+1;
        else ans=2*(t-1);
        if(t*t==s&&a!=b) ans--;
        if(a*b==4) ans=1;
        printf("%lld\n",ans);
    }
}


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



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

	int S, W;
	cin >> S >> W;
	if(W >= S){
		cout << "unsafe" << endl;
	}
	else{
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3640
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    uintmax_t X;
    uintmax_t a = 100, y = 0;

    scanf("%ju", &X);

    while (a < X) {
        a += a / 100;
        y++;
    }

    printf("%ju\n", y);

    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int x, pp;
bool f;

int main() {
	cin >> x >> pp;
	double p = (double)pp / 100;

	f = x & 1;
	int zan = x / 2;

	double ret;
	if (f) {
		ret = (1/p) * (p * zan + (1-p) * (zan + 1)) + 1;
	} else {
		ret = (1/p) * zan;
	}

	printf("%.8f\n", ret);
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> score(N);
   int A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    score.at(i) = A;
  }

  for (int i = 0; i < N-K; i++) {
    if (score.at(i) < score.at(i+K))
      cout << "Yes" << endl;
    else if (score.at(i) >= score.at(i+K))
      cout << "No" << endl;
  }
}


Measured memory_bytes: 4048
M,x=10**9+7;*I=r=j=1;eval"N,*Z="+`dd`.split*?,;Z.map{|k|x=$*[k]||x&&x+1;$*[k]=$.+=1}.map{|i|I<<s=i<2?1:M/i*-I[M%i];p (-j+r=r*(N+2-i)*s%M)%M;j=j*(x-i)*s%M}

Measured memory_bytes: 46468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int myGCD(int a, int b) {
	while(1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {
	int n;
	double m;
	cin >> n >> m;
	vector<int> a(n);
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	double check = sum * (1 / (4 * m));
	sort(a.begin(), a.end(), greater<int>());
	int count = 0;
	for (int i = 0; i < m; i++) {
		if (a[i] >= check) {
			count++;
		}
	}

	if (count == m) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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 b = n % 10;
        
        if (b == 2 || b == 4 || b == 5 || b == 7 || b == 9) {
            System.out.println("hon");
        } else if (b == 0 || b == 1 || b == 6 || b == 8) {
            System.out.println("pon");
        } else {
            System.out.println("bon");
        }
    }
}

Measured memory_bytes: 27088
import collections
N = int(input())
S = []
for i in range(N):
    S.append(input())

S=collections.Counter(S)
S=S.most_common()
result = []
result.append(S[0][0])
i=1
while i <len(S):
    if S[0][1] == S[i][1]:
        result.append(S[i][0])
    
    elif S[0][1] < S[i][1]:
        break
    i+=1
result.sort()
[print(i) for i in result]


Measured memory_bytes: 43476
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w, i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[200005], z[200005];
char s[500005], t[500005];
bool used[3005][3004];
P table[500005];

int main(){
    /*
    cin.tie(0);
    ios::sync_with_stdio(false);
    */
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> a >> b;
        table[i].first = a + b;
        table[i].second = a - b;
    }
    sort(table, table + n);

    ll ans = 0, t = -INF;
    for(ll i=0;i<n;i++){
        if(t <= table[i].second){
            ans ++;
            t = table[i].first;
        }
    }
    p(ans);
    return 0;
}
 
 











Measured memory_bytes: 1792
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	long[] arr;
	arr ~= RD;
	arr ~= RD;
	arr ~= RD;
	arr ~= RD;
	arr ~= RD;
	arr.sort!"(a-1) % 10 > (b-1) % 10"();
	long cnt;
	foreach (i; 0..4)
	{
		cnt += arr[i] / 10;
		cnt += arr[i] % 10 != 0 ? 1 : 0;
	}
	cnt += arr[4] / 10;
	
	writeln(cnt * 10 + (arr[4] % 10));
	stdout.flush();
	debug readln();
}

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

int gcd(int a,int b){//最大公約数 (a>bであること。)
  int r = a % b;
  a = b;
  b = r;
  r = a % b;
  if(r == 0)return b;
}

int lcd(int a,int b){//最小公倍数
  return (a*b)/gcd(a,b);
}

int main(){
  int a,b,c;cin >> a >> b >> c;
  if(a == 5 && b == 5 && c == 7)cout << "YES" << endl;
  else if(a == 5 && b == 7 && c == 5)cout << "YES" << endl;
  else if(a == 7 && b == 5 && c == 5)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll d,g; cin>>d>>g;
  
  vll p(d), c(d);
  rep(i,d) cin>>p[i]>>c[i];
  
  ll ans=1000;
  for(ll bit=0; bit<(1<<d); bit++){
    ll cnt=0, sum=0;
    rep(i,d){
      if(bit&(1<<i)){
        cnt+=p[i];
        sum+=c[i]+100*(i+1)*p[i];
      }
    }
    if(sum>=g){
      chmin(ans,cnt);
      continue;
    }
    
    ll rem=g-sum;
    rrep(i,d){
      if(bit&(1<<i)) continue;
      ll d=(rem+(100*(i+1)-1))/(100*(i+1));
      if(d<=p[i]){
        cnt+=d;
        chmin(ans,cnt);
        break;
      }else{
        sum-=(100*(i+1))*p[i];
      }
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int A,B;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		A=sc.nextInt();
		String s=sc.next();
		B=sc.nextInt();
		
		if(s.equals("+"))System.out.println(A+B);
		else System.out.println(A-B);
		
	}
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<bool> vec(N);
  for (int i=0; i<K; i++){
    int d;
    cin >> d;
    for (int j=0; j<d; j++){
      int A;
      cin >> A;
      vec.at(A-1) = true;
    }
  }
  int count = 0;
  for (int i=0; i<N; i++){
    if (!(vec.at(i))) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<queue>

using namespace std;

int main() {
	string S;
	S.reserve(1e6);
	cin >> S;
	int N;
	cin >> N;
	bool reverse = false;
	string front;
	for (int i = 0; i < N; i++) {
		int T;
		cin >> T;
		if (T == 1) {
			reverse = !reverse;
		}
		else {
			int F;
			char c;
			cin >> F >> c;
			if (F == 1) {
				if (reverse) {
					S.push_back(c);
				}
				else {
					front.push_back(c);
				}
			}
			else {
				if (reverse) {
					front.push_back(c);
				}
				else {
					S.push_back(c);
				}
			}
		}
	}
	if (reverse) {
		for (int i = 0; i < S.size(); i++) {
			cout << S[S.size() - 1 - i];
		}		
		cout << front << endl;
	}
	else {
		for (int i = 0; i < front.size(); i++) {
			cout << front[front.size() - 1 - i];
		}
		cout << S << endl;
	}
	return 0;
}

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

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define REP(i,a,b) for(int i = a ; i <= b ; ++i) 
# define Rep(i,a,b) for(int i = a ; i < b ; ++i) 
# define Rrep(i,a,b) for(int i = b ; i >= a ; --i) 
# define FOR(i,b) for(int i = 0 ; i <= b ; ++i)
# define For(i,b) for(int i = 0 ; i < b ; ++i)
# define Rfor(i,b) for(int i = b ; i >= 0 ; --i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

const ll inf = 1e18 ; 
const int MxN = 200005; 
const ll mod = 1e9+7 ; 

void pe(int a) { cout << a << "\n" ; }
void pe(ll a) {	cout << a << "\n" ; }
void pe(string a) {	cout << a << "\n" ; }
void ps(int a) {	cout << a << ' ' ; }
void ps(string a) {	cout << a << " " ; }
void ps(ll a) {	cout << a << " " ; }
void umax(int &a,int &b) { a = max(a,b); } ; 
void umax(ll &a , ll &b) {a = max(a,b);} ; 
void umin(int &a,int &b) { a = min(a,b);} ; 
void umin(ll &a , ll &b) {a = min(a,b);} ; 

ll nCr(ll n,ll r){
	ll res=1;
	if(r>n) return 0;
	if(r>n-r) r=n-r;
	for(ll i=0;i<r;i++) {
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}

int  n ; 
vt<ld> a(MxN) ; 
ld cache[3000][3000] ; 

ld dp(int idx , int heads , int tails) {
	if(idx == n) {
		if(heads > tails ) 
			return 1 ; 
		else 
			return -1 ;
	}
	ld &tmp = cache[idx][heads] ;
	if(tmp != -1) return tmp ;  
	ld ans = 0.0 ; 
	ld t1 = a[idx] * dp(idx + 1, heads + 1, tails) ; 
	ld t2 = (1 - a[idx]) * dp(idx + 1, heads ,tails +1 ) ; 
	if(t1 > 0) ans += t1 ; 
	if(t2 > 0) ans += t2 ; 
	return tmp = ans ; 
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 
	cin >>n ; 
	For(i,n) cin >> a[i] ;
	For(i,3000) {
		For(j,3000) 
			cache[i][j] = -1.0 ; 
	}
	cout << fixed << setprecision(10) << dp(0,0,0) ; 

	return 0 ; 	
}




Measured memory_bytes: 147400
ABC = list(map(int, input().split()))
ABC.sort()

diff = (ABC[2] - ABC[1]) + (ABC[2] - ABC[0])

ans = 0
if diff % 2 == 0:
    ans = int(diff / 2)
else:
    ans = int(diff // 2 + 2)

print(ans)

Measured memory_bytes: 3060
N = int(input())
a = list(map(int, input().split()))

for a_n in a:
    if a_n % 2 == 0:
        if a_n % 3 == 0 or a_n % 5 == 0:
            continue
        else:
            print('DENIED')
            break
else:
    print('APPROVED')

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// (a/b)%P の場合は，(a%P)*modinv(b)%P とする
ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}
// xのn乗%modを計算
ll mod_pow(ll x,ll n,ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

ll comb(ll n, ll r){
    r=min(r,n-r);
    ll res=1;
    for(int i=0;i<r;i++){
        res*=n-i;
        res%=MOD;
        res=res*modinv(i+1)%MOD;
    }
    return res;
}

int main(void) {

    ll n,a,b;
    cin>>n>>a>>b;
    ll N=mod_pow(2,n,MOD);
    ll A=comb(n,a);
    ll B=comb(n,b);
    cout<<((N-1-A+MOD)%MOD-B+MOD)%MOD<<endl;
}

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

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 {
    cout << "Balanced" << endl;
  }
}

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

int main() {
  string s, t;
  cin >> s;
  for (int i = 0; i < (int) s.length(); i++) if (!i || s[i] != s[i - 1]) t += s[i];
  vector<int> c(3);
  for (int i = 0; i < (int) t.length(); i++) c[t[i] - 'A']++;
  int A = 'A', B = 'B', C = 'C';
  if (c[0] > c[1]) swap(c[0], c[1]), swap(A, B);
  if (c[1] > c[2]) swap(c[1], c[2]), swap(B, C);
  if (c[0] > c[1]) swap(c[0], c[1]), swap(A, B);
  int x = 0, y = 0;
  string w = "";
  for (int i = 0, front = 1; i <= (int) t.length(); i++) {
    if (i == (int) t.length() || t[i] == A) {
      if (w[0] == B || w.length() >= 2) x++;
      if (!front && i != (int) t.length() && w.length() == 1 && w[0] == C) y++;
      front = 0;
      w = "";
    } else {
      w += t[i];
    }
  }
  int deal = max(0, y - x);
  w = s = "";
  for (int i = 0, front = 1; i <= (int) t.length(); i++) {
    int ok = 1;
    if (i == (int) t.length() || t[i] == A) {
      if (!front && i != (int) t.length() && w.length() == 1 && w[0] == C && deal) {
        ok = 0;
        deal--;
      }
      front = 0;
      w = "";
    } else {
      w += t[i];
    }
    if (i != (int) t.length() && ok && (s == "" || s.back() != t[i])) {
      s += t[i];
    }
  }
  int ka = 0, kb = 0, kc = 0;
  for (int i = 0; i < (int) s.length(); i++) {
    if (s[i] == A) ka++;
    if (s[i] == B) kb++;
    if (s[i] == C) kc++;
  }
  w = t = "";
  for (int i = 0, front = 1; i <= (int) s.length(); i++) {
    int ok = 1;
    if (i == (int) s.length() || s[i] == A) {
      if (!front && i != (int) s.length() && w.length() == 1 && w[0] == C) {
        ok = 0;
      }
      if (ok) {
        if (kc > kb && w != "" && w.back() == C) w.pop_back(), kc--;
        reverse(w.begin(), w.end());
        if (kc > kb && w != "" && w.back() == C) w.pop_back(), kc--;
        reverse(w.begin(), w.end());
      }
      t += w;
      if (i != (int) s.length()) t += char(A);
      front = 0;
      w = "";
    } else {
      w += s[i];
    }
  }
  w = s = "";
  for (int i = 0, front = 1; i <= (int) t.length(); i++) {
    if (i == (int) t.length() || t[i] == A) {
      int limit = front || i == (int) t.length() ? 2 : 3;
      while (kb > ka && (int) w.length() >= limit) {
        w.pop_back();
        w.pop_back();
        kb--;
      }
      s += w;
      if (i != (int) t.length()) s += char(A);
      front = 0;
      w = "";
    } else {
      w += t[i];
    }
  }
  cout << s << endl;
}


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

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

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

  void run() {
    for (; ; ) {
      int N = ni();
      int M = ni();
      if ((N | M) == 0) {
        break;
      }
      int r = ni();
      int[][] imos = new int[1261][M + 1];
      for (int i = 0; i < r; ++i) {
        int t = ni();
        int n = ni();
        int m = ni();
        int s = ni();
        imos[t][m] += 2 * s - 1;
      }
      int q = ni();
      for (int i = 0; i < q; ++i) {
        int ts = ni();
        int te = ni();
        int m = ni();
        int use = 0;
        int time = 0;
        for (int t = 0; t < te; ++t) {
          use += imos[t][m];
          if (t >= ts && use > 0) {
            ++time;
          }
        }
        System.out.println(time);
      }
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 206732
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,H,W = inputMap()
    AB = []
    for i in range(N):
        a,b = inputMap()
        AB.append((a,b))
        
    ans = 0
    for i,val in enumerate(AB):
        a,b = val
        if a >= H and b >= W:
            ans += 1
    
    print(ans)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define N 1000000
int facs[N+1];
int pri[N+1];
vector<vector<int>> divi(N);

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) {
          ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  if(ret.size() == 2)pri[n]++;
  return (ret);
}

int main(){
    int n;
    int i;
    cin >> n;
    vector<int> a(n);
    //div[i]:a[i]の素因数が入る
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        divi[i] = (divisor(a[i]));
        facs[a[i]]++;
    }
    int j;
    int res = 0;
    
    for(i=0;i<n;i++){
        if(facs[a[i]]>1)continue;
        else {
            int k = divi[i].size();
            bool f=true;
            for(j=0;j<k;j++){
                if(divi[i][j]!=a[i] && facs[divi[i][j]]>0){
                    f=false;
                }
            }
            if(f)res+=1;
        }
    }
    //for(i=0;i<30;i++)cout << facs[i] << " ";
    cout << res << endl;
    return 0;

    


}

Measured memory_bytes: 80456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<p> A(N);
    rep(i,N){
        int a;
        cin >> a;
        A[i] = p(a,i);
    }
    sort(A.begin(),A.end(),greater<p>());
    rep(i,N){
        int now = 0;
        while(true){
            if(A[now].second!=i)break;
            now ++;
        }
        cout << A[now].first << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
n=int(input())
a=[]
for _ in range(n):
  a.append([int(i) for i in input().split()])
b=[0,0,0]
for i in range(n):
  minC=abs(a[i][1]-b[1])+abs(a[i][2]-b[2])
  if a[i][0]-b[0]<minC or (a[i][0]-b[0]-minC)%2==1:
    print("No")
    break
  b=a[i]
else:
  print("Yes")

Measured memory_bytes: 25544