akhauriyash/Code-Regression huggingface dataset:
//F
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, S, E, cnt, ans;
arr fir, sum, fa, deep, dep, to;
struct
{
	int to, last;
} e[Maxn << 1];
void con(int u, int v)
{
	e[++cnt].to = v;
	e[cnt].last = fir[u];
	fir[u] = cnt;
}
int DFS(int x)
{
	if (x == S)
		to[x] = x;
	for (int next = fir[x], nx; next; next = e[next].last)
	{
		nx = e[next].to;
		if (nx == fa[x])
			continue;
		dep[nx] = dep[x] + 1;
		fa[nx] = x;
		if (DFS(nx))
			to[x] = nx;
		deep[x] = max(deep[x], deep[nx] + 1);
	}
	return to[x];
}
int main()
{
	rg int a, b;
	cin >> n >> S >> E;
	for (int i = 1; i < n; i++)
	{
		a = read();
		b = read();
		con(a, b);
		con(b, a);
	}
	DFS(E);
	while (dep[S] - dep[E] > 2)
	{
		S = fa[S];
		E = to[E];
		ans++;
	}
	ans += dep[S] - dep[E] - 1;
	cout << ans + deep[S] << '\n';
	return 0;
}

Measured memory_bytes: 7680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reversing_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] array = Console.ReadLine().Split(' ');

            Array.Reverse(array);

            for (int i = 0; i < num-1; ++i)
            {
                Console.Write(array[i] + " ");
            }

            Console.Write(array[array.Length - 1]);
            Console.WriteLine();
        }
    }
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, C, K;
    cin >> N >> C >> K;
    vector<pll> T(N);
    REP(i,0,N) {
        cin >> T[i].first;
        T[i].second = T[i].first + K;
    }

    ll cnt = 0;
    ASC(T);
    REP(i,0,N) {
        ll c = 1;
        while(i+c < N && c < C && T[i].second >= T[i+c].first) ++c;
        ++cnt;
        i += c - 1;
    }
    PR(cnt);



    return 0;
}

/*



*/

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

int main() {
  int n;
  cin >> n;
  map<ll, ll> cnt;
  ll total = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    cnt[a]++;
    total += a;
  }


  int q;
  cin >> q;
  vector<ll> ans;
  rep(i, q) {
    int b, c;
    cin >> b >> c;
    total += c * cnt[b];
    total -= b * cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    ans.push_back(total);
  }

  for (ll v : ans) {
    cout << v << endl;
  }

  return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; vector<int>v(2 * n); rep(i, 0, 2 * n)cin >> v[i];
	sort(v.begin(), v.end());
	int ans = 0;
	rep(i, 0, n) {
		ans += min(v[i * 2], v[i * 2 + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	double max,min,m;
	scanf("%lf",&m);
	max = m;min = m;
	for(;;){
		if(scanf("%lf",&m) == EOF){break;}
		if(m>max){max = m;}
		if(m<min){min = m;}
	}
	printf("%.1lf\n",max-min);
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
B = []
C = []
for k in range(N):
    if k%2 == 0:
        B.append(A[k])
    else:
        C.append(A[k])

if N%2 == 0:
    print(" ".join(map(str, C[::-1]+B)))
else:
    print(" ".join(map(str, B[::-1]+C)))

Measured memory_bytes: 31164
D, G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]

cs = [100*(i+1)*p + c for i, (p, c) in enumerate(pc)]
ans = float("inf")

for i in range(1<<D):
    flag = [False] * D
    score = 0
    num = 0
    for j in range(D):
        # 100jを解ききる
        if (i >> j) & 1:
            flag[j] = True
            score += cs[j]
            num += pc[j][0]

    if score >= G:
        ans = min(ans, num)
        continue

    last = -1
    for j in range(D)[::-1]:
        if not flag[j]:
            last = j
            break

    for _ in range(pc[j][0]-1):
        score += 100*(j+1)
        num += 1
        if score >= G:
            ans = min(ans, num)
            break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
    int a, b;
    char op;
    while(cin >> a >> op >> b, op != '?')
    {
        if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else if (op == '/') cout << a / b << endl;
    }
}



Measured memory_bytes: 3100
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

const MOD: usize = 1_000_000_007;

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    let mut small: usize = 0;
    let mut large: usize = 0;
    for i in 1..=(n + 1) {
        small += i - 1;
        large += n - (i - 1);
        if i >= k {
            ans += large - small + 1;
            ans %= MOD;
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 2100
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    s_b = [1 if si == 'B' else 0 for si in s]
    cnt = 0
    ans = 0
    for b in s_b:
        if b == 1:
            cnt += 1
        else:
            ans += cnt
    print(ans)

if __name__ == '__main__':
    main()

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

ll zyo(ll x){
    int z=x;
    rep(i,4){
        x *=z;
    }
    return x;
}

int main(){
    ll X; cin >> X;
    ll ue = 1e9;
    
    for(int i=0; i<ue; i++){
        //cout << i << " ";
        for(int j=0; j<i; j++){
            //cout << zyo(i) << "-" << zyo(j) << endl;
            if(zyo(i) - zyo(j) == X){
                cout << i <<" "<< j << endl;
                return 0;
            }else if(zyo(i) - zyo(-j) == X){
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] input = new int[N];
		int maxPotision = 0;
		int maxValue = 0;
		int secondValue = 0;
		boolean maxDup = false;
		for (int i = 0; i < N; i++) {
			int tmp = sc.nextInt();
			input[i] = tmp;
			if (tmp == maxValue) {
				maxDup = true;
			} else if (tmp > maxValue) {
				secondValue = maxValue;
				maxValue = tmp;
				maxPotision = i;
				maxDup = false;
			} else if (tmp > secondValue) {
				secondValue = tmp;
			}
		}
		if (maxDup) {
			for (int i = 0; i < N; i++) {
				System.out.println(maxValue);
			}
		} else {
			for (int i = 0; i < N; i++) {
				if (i == maxPotision) {
					System.out.println(secondValue);
				} else {
					System.out.println(maxValue);
				}
			}
		}
	}
}

Measured memory_bytes: 90256
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())
n_list = make_divisors(N)
move_list = list()
for i in n_list:
    a = N / i
    move_list.append(a+i-2)
move_list.sort()
print(int(move_list[0]))

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

int main() {
    int n; cin>>n;
    int a[6]={};
    while(n--){
        double t; cin>>t;
        if(t<165.0){
            a[0]++;
        }else if(t<170.0){
            a[1]++;
        }else if(t<175.0){
            a[2]++;
        }else if(t<180.0){
            a[3]++;
        }else if(t<185.0){
            a[4]++;
        }else{
            a[5]++;
        }
    }
    for(int i=0; i<6; i++){
        cout << i+1 << ":" << string(a[i],'*') << endl;
    } 
}

Measured memory_bytes: 1244
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

#define MAX 100010
int N,D,F[MAX];
ll t[MAX];

bool debug = false;

int main(){
  cin >> N >> D;
  rep(i,N) cin >> t[i] >> F[i];
  if( t[0] < F[0]-1 ) {
    puts("-1");
    return 0;
  }
  ll flr = 1;
  ll tm  = 0;
  ll cnt = 0;
  ll cost = 0;
  rep(i,N) {
    if( debug ) {
      puts("");
      cout << i << "-th" << endl;
      cout << "FLR  = " << flr << endl;
      cout << "time = " << tm << endl;
      cout << "cnt  = " << cnt << endl;
      cout << "cost = " << cost << endl;
    }
    // ???????????¨?????????????¬????????????????
    ll need = (ll)abs(F[i]-flr);
    if(debug){
      cout << "need = " << need << endl;
      cout << tm << " + " << need << " > " << t[i] << endl;
    }
    if( tm + need > t[i] ) {
      puts("-1");
      return 0;
    }

    // ?§????
    tm += need;
    cost += need * cnt;
    flr = F[i];

    // ??????
    ll wait = t[i] - tm;
    if( wait >= 1LL ) {
      cost += wait * cnt;
      tm += wait;
    }

    // ??????
    ++cnt;

    // ??°?????????
    bool ret = false;
    if( cnt && i + 1 < N ) {
      need = flr - 1;
      need += ( F[i+1] - 1 );
      if( tm + need > t[i+1] ) {
	if( cnt >= D ) {
	  puts("-1");
	  return 0;
	} else {


	  if( debug ) {
	    cout << "---END " << i << "--- (RETURN FAILED)" << endl;
	    cout << "need = " << need << endl;
	    cout << tm  << " + " << need << " > " << t[i+1] << endl;
	    cout << "FLR  = " << flr << endl;
	    cout << "time = " << tm << endl;
	    cout << "cnt  = " << cnt << endl;
	    cout << "cost = " << cost << endl;
	  }


	  continue;
	}
      }
      ret = true;
      cost += (ll)(flr-1) * cnt;
      flr = 1;
      tm += (ll)(flr-1);
      cnt = 0;
    }


    if( debug ) {
      cout << "---END " << i << "---" << ( ret ? "(RETURN)" : "" ) << endl;
      cout << "FLR  = " << flr << endl;
      cout << "time = " << tm << endl;
      cout << "cnt  = " << cnt << endl;
      cout << "cost = " << cost << endl;
    }
    
  }
  cost += (ll)(flr-1) * cnt;
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

template <typename T>
vector<T> longest_increasing_subsequence(vector<T> const & xs) {
    vector<T> l; // l[i] is the last element of the increasing subsequence whose length is i+1
    l.push_back(xs.front());
    for (auto && x : xs) {
        auto it = lower_bound(l.begin(), l.end(), x);
        if (it == l.end()) {
            l.push_back(x);
        } else {
            *it = x;
        }
    }
    return l;
}

int main() {
    // input
    int lx, ly, rx, ry, n; scanf("%d%d%d%d%d", &lx, &ly, &rx, &ry, &n);
    int h = abs(ry - ly);
    int w = abs(rx - lx);
    vector<pair<int, int> > f;
    repeat (i, n) {
        int x, y; scanf("%d%d", &x, &y);
        x = lx <= rx ? x - lx : lx - x;
        y = ly <= ry ? y - ly : ly - y;
        if (0 <= x and x <= w and 0 <= y and y <= h) {
            f.emplace_back(x, y);
        }
    }
    // solve
    vector<int> lis;
    if (not f.empty()) {
        vector<int> g;
        sort(whole(f));
        for (auto it : f) g.push_back(it.second);
        lis = longest_increasing_subsequence(g);
    }
    double result = 100.0 * (h + w) - (20 - 5 * M_PI) * lis.size();
    if (lis.size() == min(w, h) + 1) {
        result += 5 * M_PI;
    }
    // output
    printf("%.15lf\n", result);
    return 0;
}

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

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

  if(a-d <= c && c <= a+d){
    cout << "Yes" << endl;
  }else if(a-d <= b && b <= a+d){
    if(b-d << c && c <= b+d){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 5, mod = 1e9 + 7;

int n, dp[N][2][2], vis[N][2][2];

ll add(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

ll mul(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a * b) % mod;
}

ll solve(int idx, bool x, bool y){
    if(idx == n) return (x + y == 2);
    if(vis[idx][x][y]) return dp[idx][x][y];
    vis[idx][x][y] = 1;
    ll op1 = solve(idx + 1, x, y);
    ll op2 = solve(idx + 1, 1, y);
    ll op3 = solve(idx + 1, x, 1);
    op1 = mul(8, op1);
    return dp[idx][x][y] = add(op1, add(op2, op3));
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    cout << solve(0, 0, 0);



    return 0;
}


Measured memory_bytes: 97344
int main()
{
  char s[4];
  scanf("%s", s);
  int i;
  int cnt = 0, ans = 0, flg = 0;
  for (i = 0; s[i] != '\0'; i++)
  {
    if (s[i] == 'S')
      flg = 0;
    else if (s[i] == 'R')
    {
      if (flg == 0)
        cnt = 0;
      cnt++;
      flg = 1;
      if (cnt > ans)
        ans = cnt;
    }
  }
  printf("%d", ans);
}

Measured memory_bytes: 1684
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int num[4002] = {0};
  for(int i = 0 ; i <= 1000 ; i++ )
    for(int j = 0 ; j <= 1000 ; j++ ){num[i+j]++;num[(i+j)+2001]++;}
  int n;
  while(cin >> n){
    int m = (n > 2000) ? n-2000:0;
    int res = 0;
    for(int i = m ; i <= n ; i++ ){
      if(!(i > 2000 || n-i > 2000)){
	res += num[i]*num[n-i];
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	int A = x - a;
	int B = x - b;

	if (A < 0)
	{
		A = -A;
	}

	if (B < 0)
	{
		B = -B;
	}

	if (A < B)
	{
		cout << "A";
	}
	else {
		cout << "B";
	}

	return 0;
}

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

sa =[A[0]+K-A[N-1]]
for i in range(1,N):
    dammy = A[i] - A[i-1]
    sa.append(dammy)

out = K - max(sa)

print(out)


Measured memory_bytes: 86268
def main(s):
    isEven = int(len(s)%2)
    ran = int((len(s)-1)/2 if isEven else (len(s)/2))
    count = 0
    for i in range(ran):
        if s[i] != s[-(i+1)]:
            count += 1
    return count

s = input()
print(main(s))

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

int main() {	

	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if ( (s[i] - 'A') + n  < 26) {
			s[i] = (char)(s[i] + n);
		}
		else {
			s[i] = (char)('A' + (s[i] - 'A') + n - 26);
		}

	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string A,B;
  cin>>A>>B;
  if(A.size()>B.size()){
    print("GREATER");
    re 0;
  }
  if(A.size()<B.size()){
    print("LESS");
    re 0;
  }
  if(A>B)print("GREATER");
  else if(A<B)print("LESS");
  else print("EQUAL");

}


Measured memory_bytes: 256
n, m = map(int, raw_input().strip().split())
lis = map(int, raw_input().strip().split())
lis = sorted(lis)
lol = []
for i in range(1, m):
    lol.append(lis[i] - lis[i-1])
lol = sorted(lol)
ans = lis[-1] - lis[0]
idx = len(lol) - 1
if idx >= 0:
    for i in xrange(n-1):
        ans -= lol[idx]
        idx-=1
        if idx == -1:
            break
print ans

Measured memory_bytes: 11276
import java.{util => ju}
import scala.collection.{mutable => mu}
import MyPredef._


object Main extends App {
  import java.util.Arrays
  val p = new java.io.PrintWriter(System.out)

  val n = MyPredef.nextInt
  val X = Array.fill(n)(MyPredef.nextInt)
  val Xs = X.clone()
  Arrays.sort(Xs)
  val halfB = Xs(n / 2 - 1) // before
  val halfA = Xs(n / 2) // after

  MyPredef.rep(n, i => {
    if (X(i) <= halfB) {
      p.println(halfA)
    } else {
      p.println(halfB)
    }
  })
  p.flush()
}


object MyPredef {
  @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }
  @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }

  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}


Measured memory_bytes: 39696
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for(i=a;i<b;i++)

ll power(ll a,ll b, ll mod)
{
	ll p = 1;
	a = a%mod;
	while(b>0)
	{
		if(b%2==1)
			p=((p%mod)*(a%mod))%mod;
		b=b>>1;
		a=((a%mod)*(a%mod))%mod;
	}
	return p;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k;
	ll temp = 0;
	ll flag = 0;
	cin>>k;
	for(i=0;i<1000001;i++)
	{
		temp = (temp%k + (7*power(10, i, k))%k)%k;
		if(temp == 0)
		{
			flag = 1;
			break;
		}
	}
	if(!flag)
		cout<<-1<<endl;
	else
		cout<<i+1<<endl;
	return 0;
}

Measured memory_bytes: 3640
A,B,C,D,E,F = map(int,input().split())
mizu = 0
satou = 0
noudo = 0
for i in range(0,F//(100*A)+1):
  for j in range(0,F//(100*B)+1):
    curmizu = (A*i+B*j)*100
    for k in range(0,(curmizu*E//(100*C))+1):
      for l in range(0,(curmizu*E//(100*D))+1):
        cursatou = k*C+l*D
        if curmizu+cursatou <= F:
          if cursatou <= curmizu*E/100:
            if curmizu+cursatou != 0:
              if 100*(cursatou)/(curmizu+cursatou) >= noudo:
                mizu = curmizu
                satou = cursatou
                noudo = 100*(cursatou)/(curmizu+cursatou)
print(mizu+satou,satou)

Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string s;
    ll K;
    cin>>s>>K;
    ll n=s.size();
    ll N=min(n,K);
    map<string,int> m;
    rep(i,n){
        rep(j,N){
            m[s.substr(i,j+1)]++;
        }
    }
    ll c=0;
    string ans;
    for(auto p:m){
        c++;
        if(c==K){
            ans=p.first;
            break;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4708
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000100;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
char s[N],t[N];
int n,i,f[N],g[N];
int main(){
	//freopen("1.out","w",stdout);
	n=read();
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(i=2;i<=n;i++){
		f[i]=f[i-1];
		while(f[i]&&t[f[i]+1]!=t[i])f[i]=f[f[i]];
		f[i]+=(t[f[i]+1]==t[i]);
	}
	for(i=1;i<=n;i++){
		g[i]=g[i-1];
		while(g[i]&&t[g[i]+1]!=s[i])g[i]=f[g[i]];
		g[i]+=(t[g[i]+1]==s[i]);
	}
	printf("%d\n",n+n-g[n]);
	return 0;
}

Measured memory_bytes: 4224
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(" ");

			double ax0 = Double.parseDouble(nico[0]);
			double ay0 = Double.parseDouble(nico[1]);
			double ax1 = Double.parseDouble(nico[2]);
			double ay1 = Double.parseDouble(nico[3]);
			double bx0 = Double.parseDouble(nico[4]);
			double by0 = Double.parseDouble(nico[5]);
			double bx1 = Double.parseDouble(nico[6]);
			double by1 = Double.parseDouble(nico[7]);

			if ((ax0 <= bx1) && (bx0 <= ax1) && (ay0 <= by1) && (by0 <= ay1)) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 26404
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int f(int round, int num, int K) {
  num %= (round + 1);
  if (num == 0)
    return round;

  int t = (round + 1 - num) / K;
  int x = (round + 1 - num) % K;
  if (x == 0)
    return round - t;
  round -= t;
  return f(round - 1, K - x, K);
}


int main() {
  int N, SG = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A, K;
    cin >> A >> K;
    int t = f(A / K, A % K, K);
    debug("t = %d\n", t);
    SG ^= t;
  }
  if (SG == 0)
    puts("Aoki");
  else
    puts("Takahashi");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N; cin >> N;
    for(ll i = 1; i <= 3500; ++i) {
        for(ll j = 1; j <= 3500; ++j) {
            if((4 * i * j - N * i - N * j) != 0) {
                if((N * i * j) % (4 * i * j - N * i - N * j) == 0 && (N * i * j) / (4 * i * j - N * i - N * j) > 0) {
                    cout << i << ' ' << j << ' ' << (N * i * j) / (4 * i * j - N * i - N * j) << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	 int N = sc.nextInt();
         int L[]= new int[N];
         int set=0;
         int total =0;
         int hoge =0;
         for(int i = 0;i<N;i++){
        	 L[i]=sc.nextInt();
        	 hoge = L[0];
           if(L[i]>set){
        	   total += set;
        	   set = L[i];

           }else{
        	   total += L[i];
           }
         }

         if(total>set){
        	 System.out.println("Yes");
         }else{
        	 System.out.println("No");
         }






    }

}

Measured memory_bytes: 24916
X = int(input())
#A**5 - B**5 = X
def return_AB(X):
    for i in range(-300,300,1):
        #print ("i=",i)
        for j in range(-300,300,1):
            #print ("j=",j)
            Y = i**5 - j**5
            
            if X == Y:
                return i,j
    else:
        return None, None

A,B = return_AB(X=X)
print("{} {}".format(A,B))


Measured memory_bytes: 9112
class UnionFind:
    def __init__(self,size):
        self.par = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]
        self.size = [1 for _ in range(size)]
        
    # xの根を返す
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            return self.find(self.par[x])
            
    # xとyを同じグループに
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
        else:
            self.par[x] = y
            self.size[y] += self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
        
    # xとyが同じグループか判定
    def same(self,x,y):
        return self.find(x) == self.find(y)
    
N,M = map(int,input().split())
s = N*(N-1)//2
ans = []
ab = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

tree = UnionFind(N)

for index, bridge in enumerate(ab[::-1]):
    if tree.same(bridge[0],bridge[1]):
        ans.append(s)
    else:
        d = tree.size[tree.find(bridge[0])] * tree.size[tree.find(bridge[1])]
        tree.union(bridge[0],bridge[1])
        ans.append(s)
        s -= d
        
print("\n".join(map(str, ans[::-1])))

Measured memory_bytes: 42672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int N,X;
  cin >> N>>X;
  int ans=N;
  vector<int> m(N,0);
  for(int i=0;i<N;i++){
    cin >> m.at(i);
    X -= m.at(i);
  }
  sort(m.begin(),m.end());
  ans += X/m.at(0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  int lamp[n];
  REP(i,n){
    cin >> lamp[i];
  }
  
  int ans = 0,l = 0;
  while(ans <= n){
    l = lamp[l] -1;
    ans++;
    if(l == 1) {
      cout << ans << endl;
      return 0;
    }
  }
   
  cout << -1 << endl;

 return 0;
}

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

using namespace std;

int main(){
    int n=0,x=0,t=0;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<((n/x)*t);
    }
    else{
        n=(n/x)+1;
        cout<<n*t;
    }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;
const int mx = 1e5+10;
void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> adj[n+1];
    li heights[n+1];
    vector<bool> vis(n+1,false);
    for(int i=1;i<=n;i++) {
        cin >> heights[i];
    }
    for(int i=0;i<m;i++) {
        int u,v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) {
        int h = heights[i];
        bool valid = true;
        for(int child : adj[i]) {
            if(heights[child]>=h) {
                valid=false;
                break;
            }
        }
        if(valid)   
            ans++;
    }
    cout << ans << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 9556
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>

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

using namespace std;

int main(){
	string s,t; cin>>s>>t;

	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());

	cout<<(s<t?"Yes":"No")<<endl;

	return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, m;

long modpow(ll a, ll p){
    if(p==0) return 1;
    if(p%2==0){
        ll halfp=p/2;
        ll half=modpow(a, halfp);
        return half*half%mod;
    }
    else{
        return a*modpow(a, p-1)%mod;
    }
}

ll comb(ll a, ll b){
    if(b>a-b) return comb(a, a-b);

    ll ansMul=1;
    ll ansDiv=1;
    REP(i, 0, b){
        ansMul*=(a-i);
        ansDiv*=(i+1);
        ansMul%=mod;
        ansDiv%=mod;
    }

    ll ans = ansMul*modpow(ansDiv, mod-2)%mod;

    return ans;
}

int main() {
    cin>>n>>m;

    ll ans=1;
    ll res=m;
    for(ll i=2; i*i<=res; i++){
        if(res%i==0){
            ll cnt=0;
            while(res%i==0){
                cnt++;
                res/=i;
            }
            ans*=comb(n+cnt-1, n-1);
            ans%=mod;
        }
    }

    if(res!=1){
        ans*=comb(n, n-1);
        ans%=mod;
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
A = int(input())

if 1 <= A < 10:
  ans = len(range(1, A + 1))
elif 10 <= A < 100:
  ans = 9
elif 100 <= A < 1000:
  ans = 9 + len(range(100, A + 1)) 
elif 1000 <= A < 10000:
  ans = 9 + 900
elif 10000 <= A < 100000:
  ans = 9 + 900 + len(range(10000, A + 1))
else:
  ans = 9 + 900 + 90000

print(ans)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	double W,H,x,y;
	cin >> W >> H >> x >> y;
	cout << setprecision(18) << W*H/2.0 << endl;
	if(x == W/2.0 && y == H/2.0) cout << 1 << endl;
	else cout << 0 << endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

vector<vector<int>> v(111111);

int dfs(int now, int pre, int s, int t){
	if(now == s)return 1;
	if(now == t)return 0;
	REP(i, v[now].size())if(v[now][i] != pre)return dfs(v[now][i], now, s, t);
	return 0;
}

int seica(int s, int t){
	int ret = 0;
	REP(i, 4)ret += dfs(v[s][i], s, s, t);
	return ret;
}

int main(){

	int n, m;cin >> n >> m;
	REP(i, m){
		int a, b;cin >> a >> b;
		a--;b--;
		v[a].EB(b);
		v[b].EB(a);
	}

	vector<int> four;
	int six = 0;

	REP(i, n){
		if(v[i].size() % 2){
			cout << "No" << endl;
			return 0;
		}

		if(v[i].size() == 4)four.PB(i);
		if(v[i].size() > 4)six++;
	}

	if(six > 0 || four.size() > 2){
		cout << "Yes" << endl;
		return 0;
	}

	if(four.size() < 2){
		cout << "No" << endl;
		return 0;
	}

	if(seica(four[0], four[1]) == 2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 6016
#include<iostream>

using namespace std;

int main(void)

{
    int a,b,c=0,h,n;
    cin>>h>>n;
    for(a=0;a<n;a++){
        cin>>b;
        c+=b;
    }
    if(h-c<=0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int ans;
    if (K%2 == 0)
      ans = (K/2)*(K/2);
    else
      ans = (K/2)*(K/2+1);
    System.out.println(ans);
  }
}  

Measured memory_bytes: 35724
#ABC128-C
n,m=map(int,input().split())
k=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    l=[0]*n
    for j in range(n):
        if ((i>>j)&1):
            l[j]=1
        else:
            l[j]=0
    
    all_s=0
    for x in range(m):
        on=0
        for y in k[x][1:]:
            on+=l[y-1]
            
            
        if on%2==p[x]:#各スイッチがついてるかどうか
            all_s+=1
        else:
            all_s=0
            break
            
    if all_s==m:
        ans+=1
        
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < s.length();i++){
			if(i%2==0){
				sb.append(c[i]);
			}
		}

		System.out.println(sb.toString());
	}
}


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

using namespace std;

int main() {

    int N;
    int K;
    cin >> N >> K;
    int count = 0;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        int distA = x;
        int distB = K - x;
        if (distB < 0) distB = -distB;
        if (distA < distB) {
            count += 2 * distA;
        } else {
            count += 2 * distB;
        }
    }
    cout << count << endl;



}

Measured memory_bytes: 3600
from sys import stdin
n = int(input())
data = {}
for i in range(n):
  key, val = input().split()
  if key not in data:
    data[key] = {}
  data[key][int(val)] = i+1
# print(data)

keys = sorted(data.keys())
for key in keys:
  li = sorted(data[key], reverse=True)
  for j in li:
    print(data[key][j])

Measured memory_bytes: 3060
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){

	ll h, w, d;
	cin >> h >> w >> d;
	vector<vector<ll>> a(h, vector<ll>(w));
	for(auto& x : a)
		for(auto& y : x)
			cin >> y;

	vector<pair<ll,ll>> v(h * w);
	for(ll i = 0; i < h; ++i)
		for(ll j = 0; j < w; ++j)
			v[a[i][j] - 1] = make_pair(i, j);

	vector<ll> cost(h * w, 0);
	for(ll i = d; i < h * w; ++i)
		cost[i] = cost[i - d] + abs(v[i].first - v[i - d].first) + abs(v[i].second - v[i - d].second);

	ll q;
	cin >> q;
	vector<ll> l(q), r(q);
	for(ll i = 0; i < q; ++i){
		cin >> l[i] >> r[i];
		--l[i], --r[i];
		cout << cost[r[i]] - cost[l[i]] << endl;
	}

}


Measured memory_bytes: 5504
#include <iostream>

using namespace std;

int main()
{
    int n1=0;
    cin>>n1;
    int arr1[n1];
    int arr2[n1];
    int s=0;
    for(int i=0;i<n1;i++)
    {
        cin>>arr1[i];
        cin>>arr2[i];
    }
    for(int i2=0;i2<n1;i2++)
    {
        if(arr1[i2]-arr2[i2]>=0)
        {
            s=s+(arr1[i2]-arr2[i2])+1;
        }
        else if(arr1[i2]-arr2[i2]<0)
        {
            s=s+(arr2[i2]-arr1[i2])+1;
        }
    }
    cout <<s;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm> 
#include<iterator> 
#define sizeVector 20

using std::cout;
using std::cin;
using std::endl;
using std::vector;

void inputPlace(vector<vector<int> > &map, int N);
void update(vector<vector<int> > &map, char dire, int dist, int &x, int &y); 
void movement(vector<vector<int> > &map); 
int check(vector<vector<int> > &map); 

int main() {
    int N;
    cin >> N; 
    while (N != 0) {
    vector<vector<int> > map(sizeVector+1, vector<int>(sizeVector+1, 0));
    inputPlace(map, N);
    movement(map);
    if (check(map) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
     cin >> N; 
    }
    return 0;
}

void inputPlace(vector<vector<int> > &map, int N) {
    int x;
    int y;
    for (int times = 0; times < N; times ++) {
        cin >> x >> y; 
        map[x][y] = 1;
    }
}

void update(vector<vector<int> > &map, char dire, int dist, int &x, int &y) {
    if (dire == 'E') {
        for (int i = 0; i < dist; i ++) {
            map[x + i + 1][y] = 0;
        }
        x += dist;
    } else if (dire == 'W') {
        for (int i = 0; i < dist; i ++) {
            map[x - i - 1][y] = 0;
        }
        x -= dist;
    } else if (dire == 'N') {
        for (int i = 0; i < dist; i ++) {
            map[x][y + i + 1] = 0;
        }
        y += dist;
    } else if (dire == 'S') {
        for (int i = 0; i < dist; i ++) {
            map[x][y - i - 1] = 0;
        }
        y -= dist;
    } else {
        cout << "error" << endl;
    }

}

void movement(vector<vector<int> > &map) {
    int M;
    cin >> M; 
    int x = 10;
    int y = 10;
    char dire; // direction
    int dist; // distance
    for (int times = 0; times < M; times ++) {
        cin >> dire >> dist;
        update(map, dire, dist, x, y);
    }
}

int check(vector<vector<int> > &map) {
    for (int i = map.size() - 1; i >= 0; i --) {
        for (int j = 0; j < map[i].size(); j ++) {
            if (map[i][j] != 0) {
                return 1;
            }
        }
    }
    return 0;
}

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

const int N = 2e5 + 7;

int dp[N], p1[N], p2[N];

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	dp[0] = 0;
	for(int i = 1; i < N; i++) {
		int k = __builtin_popcount(i);
		dp[i] = 1 + dp[i % k];
	}
	int n, cnt = 0; string str; cin >> n >> str;
	for(auto ch: str) {
		cnt += ch == '1';
	}

	int x = cnt + 1, y = cnt - 1, s1 = 0, s2 = 0;

	p1[0] = p2[0] = 1;

	for(int i = 1; i <= n; i++) {
		p1[i] = (p1[i - 1] * 2) % x;
		if(y > 0) {
			p2[i] = (p2[i - 1] * 2) % y;
		}
	}

	for(auto ch: str) {
		s1 = (s1 * 2 + (ch == '1')) % x;
		if(y > 0) {
			s2 = (s2 * 2 + (ch == '1')) % y;
		}
	}
	int len = 0;
	for(auto ch: str) { ++len;
		if(ch == '1') {
			if(cnt - 1 == 0) {
				cout << 0 << endl;
			} else {
				int s22 = (s2 - p2[n - len] + y) % y;
				cout << 1 + dp[s22] << endl;
			}
		} else {
			int s11 = (s1 + p1[n - len]) % x;
			cout << 1 + dp[s11] << endl;
		}
	}

}

Measured memory_bytes: 6112
#include<stdio.h>
int main(void){
	int m,f,b,a;
	scanf("%d %d %d",&m,&f,&b);
	if(b<m){
		printf("0\n");
	}
	else if(b<=m+f){
		a=b-m;
		printf("%d\n",a);
	}
	else{
		printf("NA\n");
	}
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<long, long>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007
#define NINF -1e14


/*bool dfs(vector<vector<pii>> &G,vb &seen,vb &finish,vector<long> &dis,long v,long pv){
  seen.at(v) = true;
  //cout << v << endl;
  for(pii nP : G.at(v)){
    long nv = nP.first;
    if(nv == pv || finish.at(nv)) continue;
    long cost = nP.second;
    if(dis.at(nv) != NINF && dis.at(nv) != dis.at(v) + cost) return true;
    else if(dis.at(nv) != NINF && dis.at(nv) == dis.at(v) + cost) return false;
    dis.at(nv) = dis.at(v) + cost;
    if(dfs(G,seen,finish,dis,nv,v)) return true;
  }
  finish.at(v) = true;
  return false;
}*/

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<pii>> G(n);
  //vector<bool> start(n,true);
  rep(i,m){
    long l,r,d;
    cin >> l >> r >> d;
    l--;r--;
    G.at(l).push_back(pii(r,d));
    G.at(r).push_back(pii(l,-d));
    //start.at(r) = false;
  }
  //vector<bool> seen(n,false);
  //vector<bool> finish(n,false);
  vector<long> dis(n,NINF);
  queue<pii> que;
  rep(i,n){
    if(dis.at(i) == NINF){
      dis.at(i) = 0;
      que.push(pii(i,0));
    }
    while(que.size()){
      pii P = que.front();
      que.pop();
      long v = P.first;
      long pos = P.second;
      if(dis.at(v) != NINF && dis.at(v) != pos){
        cout << "No" << endl;
        return 0;
      }
      for(pii nP : G.at(v)){
        long nv = nP.first;
        long cost = nP.second;
        if(dis.at(nv) == dis.at(v) + cost) continue;
        if(dis.at(nv) == NINF){
          dis.at(nv) = dis.at(v) + cost;
          que.push(pii(nv,dis.at(v) + cost));
          continue;
        }
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 14448
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    ll res = 0; 
    rep(i,n)res += (i+1) * (n/(i+1)+1) * (n/(i+1)) /2;
    cout << res << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{for(T&x:v)i>>x;return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;for(T&x:v)s<<' '<<x;return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int l, n;
  scanf("%d%d",&l,&n);
  int sum = 0;
  rep(i,n) {
    int w, x;
    scanf("%d%d",&w,&x);
    sum -= x*w;
  }
  if (sum == 0) {
    cout<<0<<endl;
  } else if (sum < 0) {
    cout<<1<<endl;
    cout<<-1<<" "<<-sum<<endl;
  } else {
    cout<<1<<endl;
    cout<<1<<" "<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3232