akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll X;
    cin >> X;
    ll N = 2;
    REP(i, X)
    {
        N = N + N + 1 + 1;
    }
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ll cnt = 0;
    rep(i,n){
        cnt = 0;
        REP(j,i+1,n){
            if(a[i] > a[j]) cnt++;
        }
        ans += cnt * k;
        ans %= MOD;
    }
    vl b(n);
    rep(i,n){
        cnt = 0;
        rep(j,n){
            if(a[i] > a[j]) cnt++;
        }
        b[i] = cnt % MOD;
    }
    ll K = (k*(k-1)/2) % MOD;
    rep(i,n){
        ans += (b[i] * K) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
var SEG=[
[1,1,1,1,1,1,0].reverse(),
[0,1,1,0,0,0,0].reverse(),
[1,1,0,1,1,0,1].reverse(),
[1,1,1,1,0,0,1].reverse(),
[0,1,1,0,0,1,1].reverse(),
[1,0,1,1,0,1,1].reverse(),
[1,0,1,1,1,1,1].reverse(),
[1,1,1,0,0,1,0].reverse(),
[1,1,1,1,1,1,1].reverse(),
[1,1,1,1,0,1,1].reverse()
];
var n=Arr[0];
var seg=[];
for(var i=1;i<Arr.length;i++){
   if(n==0){
      if(i==0)continue;
      var arr=[0,0,0,0,0,0,0];
      seg.forEach(function(v){
         var V=SEG[v];
         var str="";
         for(var i=0;i<7;i++){
            str+=(V[i]==arr[i])?"0":"1";
         }
         console.log(str);
         arr=V.slice();
      });
      if(Arr[i]==-1)break;
      seg=[];
      n=Arr[i];
   }else{
      n--;
      seg.push(Arr[i]);
   }
}

Measured memory_bytes: 9232
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

a,b = inputIL()

dic = {
  1:1,
  2:3,
  3:1,
  4:2,
  5:1,
  6:2,
  7:1,
  8:1,
  9:2,
  10:1,
  11:2,
  12:1,
}

if dic[a] == dic[b]:
  print("Yes")
else:
  print("No")


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

void solve(std::string c){
    string vowel = "aiueo";
    bool ans = false;
    REP(i, vowel.size()) {
        if (c[0] == vowel[i]) {
            ans = true;
            break ;
        }
    }
    if (ans) cout << "vowel" << '\n';
    else cout << "consonant" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string c;
    std::cin >> c;
    solve(c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <list>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <random>
#include <queue>
#include <fstream>
#include <iterator> // std::back_inserter
#include <chrono>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <float.h>
#include <cassert>
#include <functional>

using namespace std;

int main(int argc, char *argv[])
{
    int N;
    cin >> N;

    int a[N];

    for(int i=0; i<N; i++){
        cin >> a[i];
    }

    int ans = 0;
    int now = 0;

    for(int i=0; i<N; i++){
        if(a[i] >= now){
            ans += 1;
            now = a[i];
        }
    }

    

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())

m = 100
d4 = int(m / 4)
d7 = int(m / 7)

ys = set()
for i in range(0, d4 + 1):
    for j in range(0, d7 + 1):
        y = 4 * i + 7 * j
        if y > 100:
            continue
        ys.add(y)

if n in ys:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
vector<string>s(3);
for(int i=0;i<3;i++){
    cin>>s[i];
}
if((s[0].at((s[0].size())-1)==s[1].at(0))&&s[1].at((s[1].size())-1)==s[2].at(0))cout<<"YES";
else cout<<"NO";
  return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n, a, b;
	cin >> n >> a >> b;

	string s;
	cin >> s;

	int all = 0;
	int fore = 0;

	rep(i, n){
		if(s[i] == 'a'){
			if(all < a + b){
				cout << "Yes" << endl;
				all++;
			}else{
				cout << "No" << endl;
			}
		}else if(s[i] == 'b'){
			if(all < a + b && fore < b){
				cout << "Yes" << endl;
				all++;
				fore++;
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 848
N= int(input())
C = input()
red = 0
white = 0
for i in range(N):
    if C[i] == "W":
        white +=1
    else:
        red += 1
c = 0
for i in range(red):
    if C[i] == "W":
        c +=1
print(c)

Measured memory_bytes: 9472
class Heap
  def initialize(xs = [], &block)
    @que = xs
    @size = xs.size
    @cmp = block || lambda{ |a,b| a < b }
  end

  def push(x)
    i = @size
    while i > 0 do
      j = (i - 1) / 2
      break unless @cmp.call(x, @que[j])
      @que[i] = @que[j]
      i = j
    end
    @que[i] = x
    @size += 1
  end

  def replace
    m = @que[0]
    x = yield m
    i = 0
    while (ii = i * 2 + 1) < @size do
      j1 = ii
      j2 = ii + 1
      j1 = j2 if j2 < @size && @cmp.call(@que[j2], @que[j1])
      break unless @cmp.call(@que[j1], x)
      @que[i] = @que[j1]
      i = j1
    end
    @que[i] = x
    m
  end
end

def get_target(l, h, n, fs)
  r = 0
  fs.each do |f| r += h / f end

  # t0 = (l*h/r).ceil, t = (l*h/(r+n)).ceil
  lh = l * h
  t0 = (lh + r - 1) / r
  t = (lh + r + n - 1) / (r + n)

  raise if (t0 >= t + 2)

  t
end

n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
fs = gets.split.map(&:to_i)
 
l = as.inject(:+) - k

if (l <= 0)
  p 0
  exit
end

# O(n * log(n))
afs = as.sort.zip(fs.sort.reverse).sort_by do |item| item[0]*item[1] end

acc = 0
# O(n)
a_sums = afs.map do |a,_| acc += a end

# O(n * log(n))
m = (0...n).bsearch do |i|
  a_i, f_i = afs[i]
  af = a_i * f_i

  s = a_sums[i]
  (i+1...n).each do |j| s += af / afs[j][1] end
  s > l
end

if (m > 0)
  afs = afs.drop(m)
  n -= m
  l -= a_sums[m-1]
end

max_f = 0

# O(n)
fs = afs.map do |a, f|
  max_f = f if f > max_f
  f
end

# O(n)
t = get_target(l, l * max_f * max_f, n, fs)

max_af = 0

# O(n)
xs = fs.map do |f|
  l -= (a = t / f)
  af = a * f
  max_af = af if af > max_af
  [af + f, f]
end

if (l == 0)
  p max_af
else
  # O(n * log(n))
  xs = xs.sort_by do |item| item[0] end
  # O(n * log(n))
  q = Heap.new(xs) do |a,b| a.first < b.first end

  raise if (l > 2*n)

  # O(n * log(n))
  af, = q.replace do |a| [a[0] + a[1], a[1]] end while (l -= 1) >= 0
  p af
end

Measured memory_bytes: 63868
#include<iostream>
#include<math.h>
using namespace std;
int n,x,y,h,w,d,e,s,v;
  
double j(int a,int b){return sqrt(a*a+b*b+0.0);}
int main(){
    while(1){
		bool ok=1;
        cin>>n>>h>>w>>d>>e;
        if(!n)break;
		cin>>s>>v;
		if(j(h-s,w-v)>=j(d-s,e-v))ok=0;
        for(int i=1;i<n;i++){
            cin>>x>>y;
			if(j(h-s,w-v)+j(s-x,v-y)>=j(d-x,e-y))ok=0;
        }
        if(ok) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]
jump = [0]*N
ans = 0
for i in range(N-1):
    if H[i] >= H[i + 1]:
        jump[i + 1] = jump[i] + 1
        if jump[i + 1] > ans:
            ans = jump[i+1]
print(ans)


Measured memory_bytes: 14252
from itertools import accumulate as acc
import sys


def main():
    s = sys.stdin.readlines()
    N, M, Q = map(int, s[0].split())
    LR = [[0]*N for _ in [0]*N]
    for l, r in (map(int, e.split()) for e in s[1:M + 1]):
        LR[l - 1][r - 1] += 1

    S = [tuple(acc(reversed(s))) for s in zip(*(acc(x) for x in LR))]
    print('\n'.join(map(str, (S[q - 1][N - p] for p, q in (map(int, e.split()) for e in s[M + 1:])))))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38468
n = input()
a = list(map(int, input().split()))

c = [0, 0, 0, 0, 0, 0, 0, 0]
max = 0
for i in a:
    if i <= 399:
        c[0] += 1
    elif i <= 799:
        c[1] += 1
    elif i <= 1199:
        c[2] += 1
    elif i <= 1599:
        c[3] += 1
    elif i <= 1999:
        c[4] += 1
    elif i <= 2399:
        c[5] += 1
    elif i <= 2799:
        c[6] += 1
    elif i <= 3199:
        c[7] += 1
    else:
        max += 1

min = 0
for i in range(8):
    if c[i] != 0:
        min += 1

max += min
if min == 0:
    print(1, max)
else:
    print(min, max)

Measured memory_bytes: 3064
#重み付きUnion-Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        px = find(par[x])
        wei[x] += wei[par[x]]
        par[x] = px
        return px

#xの根から距離
def weight(x):
    find(x)
    return wei[x]


#w[y]=w[x]+wとなるようにxとyを併合
def unite(x,y,w):
    w += wei[x]-wei[y]
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
            w = -w
        par[x] += par[y]
        par[y] = x
        wei[y] = w
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#x,yが同じ集合に属するときのwei[y]-wei[x]
def diff(x,y):
    return weight(y)-weight(x)

n,m = map(int,input().split())

#初期化
#par:根なら-size,子なら親の頂点
#wei:親からの距離,根なら0
par = [-1]*n
wei = [0]*n

for i in range(m):
    l,r,d = map(int,input().split())
    l,r = l-1,r-1
    if same(l,r):
        if d != diff(l,r):
            print('No')
            exit()
    else:
        unite(l,r,d)
print('Yes')
        


Measured memory_bytes: 8968
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N, A[MAXN], freq[1000005];

vi get_factors(int x){
	vector<int> factors;
	FOR(i,1,x/i){
		if (x%i==0) {
			factors.pb(i);
			factors.pb(x/i);
		}
	}
	return factors;
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	//N = 200000;
	FOR(i,1,N) {
		cin>>A[i];
		//A[i] = 720000;
		freq[A[i]]++;
	}
	int ans = 0;
	FOR(i,1,N){
		vi flist = get_factors(A[i]);
		freq[A[i]]--;
		bool ok = 1;
		for (auto f:flist){
			if (freq[f]) ok =0;
		}
		if (ok) {
			ans++;
		}
		freq[A[i]]++;
	}
	cout<<ans;
	
}


Measured memory_bytes: 8260
package main

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

func main() {
	S := getStdin() // 文字列入力
	T := getStdin() // 文字列入力

	if S == T[:len(S)] {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}

var sc = bufio.NewScanner(os.Stdin)

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinInt64() int64 {
	sc.Scan()
	rtn, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}


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

using namespace std;

int main()
{
  vector<int> a(3);
  for (int i = 0; i < 3; i++) cin >> a[i];
  int x = a[2];
  sort(a.begin(), a.end());
  if (a[1] == x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     string s;
     cin>>s;
     if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";
     else cout<<"No";
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

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

int keta(int n) {
    int res;
    for(int i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        int num = i + 1;
        if(num % 2 == 1 && a[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3548
module Main where

import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust, mapMaybe)
import Control.Monad (replicateM, forM_, foldM)
import qualified Data.Vector.Mutable as MV
import Data.List (sortOn)
import Debug.Trace

readTuple2 :: IO (Int, Int)
readTuple2 = do
    [x, y] <- readInts
    pure (x, y)

readInts :: IO [Int]
readInts = do
    is <- BC.words <$> BC.getLine
    pure $ fst <$> mapMaybe BC.readInt is

main = do
    (n, m) <- readTuple2
    as <- readInts
    let ats = zip (repeat 1) as
    bcs <- replicateM m readTuple2
    let cards = sortOn (((negate 1)*) . snd) $ ats ++ bcs
    let acc = (n, 0) -- rem cards, point
    print $ snd $ foldl (\(acc_num, acc_point) (c_num, c_point) ->
        if acc_num < c_num then
            (0, acc_point + acc_num * c_point)
        else
            (acc_num - c_num, acc_point + c_num * c_point)
         ) acc cards

Measured memory_bytes: 107900
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

ll const MAX = 305;
double dp[MAX][MAX][MAX] = {};

double f_dp(ll i, ll j, ll k) {
	if (i < 0 || j < 0 || k < 0) {
		return 0;
	}
	else {
		return dp[i][j][k];
	}
}

void fill_dp(ll n, ll a, ll b, ll c) {
	REP(k, 0, c) {
		REP(j, 0, b + c) {
			REP(i, 0, a + b + c) {
				if (i == j && j == k && k == 0) {
					continue;
				}
				dp[i][j][k] = (n + i * f_dp(i - 1, j, k) + 
					j * f_dp(i + 1, j - 1, k) + k * f_dp(i, j + 1, k - 1)) / (i + j + k);
			}
		}
	}
}

int main() {
	cout.precision(12);
	ll n;
	cin >> n;
	ll a, b, c;
	a = b = c = 0;
	REP(i, 1, n) {
		ll x;
		cin >> x;
		if (x == 1) { a++; }
		else if (x == 2) { b++; }
		else { c++; }
	}
	fill_dp(n,a,b,c);
	cout << dp[a][b][c] << endl;
}

Measured memory_bytes: 219392
//Created by Young Charlie
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int(a.size())

int main(){
	int ans = 1003, T, n; cin>>n>>T;
	while(n--){
		int c, t; cin>>c>>t;
		if(t <= T){
			ans = min(ans, c);
		}
	}		
	if(ans == 1003) cout<<"TLE\n"; else cout<<ans<<endl;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vary(ll,v,3,0);
  ll a = 0,b = 0,c = 0,d = 0;
  while(1){
    cin >> v[0] >> v[1] >> v[2];
    sort(all(v));
    if(! (v[2] < v[0] + v[1])){
      cout << a << " " << b << " " << c << " " << d << endl;
      break;
    }
    else if(v[0] * v[0] + v[1] * v[1] == v[2] * v[2]) ++b;
    else if(v[0]*v[0] + v[1]*v[1] > v[2] * v[2]) ++ c;
    else if(v[0]*v[0] + v[1]*v[1] < v[2] * v[2]) ++ d;
    ++a;
  }
  return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl



int main(){
	
	int W,H;
	cin>>W>>H;
	
	vector<pair<ll,int>> edges;

	REP(i, W+H){
		ll p;
		cin>>p;
		edges.push_back(pair<ll,int>(p,i));
	}


	sort(edges.begin(),edges.end());

	ll A = W+1;
	ll B = H+1;
	ll res = 0;

	for(int i = 0; i  < edges.size(); i++){
		
		if(edges[i].second < W){
			res += edges[i].first * B;
			A--;
		}
		else{
			res += edges[i].first * A;
			B--;
		}
	}
	cout<<res<<endl;
	// vector<vector<ll>> dp(W+1,vector<ll>(H+1,INF));
    //
	// REP(i,W)cin>>arr_p[i];
	// REP(i,H)cin>>arr_q[i];
	//
	// dp[0][0] = 0;
	// REP(i,W){
	// 	dp[i+1][0] = dp[i][0] + arr_p[i];
	// }
	// REP(j,H){
	// 	dp[0][j+1] = dp[0][j] + arr_q[j];
	// }
	// dp[0][1] = arr_q[0];
	// dp[1][0] = arr_p[0];
    //
	// for(ll i = 0; i < W; i++ ){
	// 	for(ll j = 0; j < H; j++){
	// 		dp[i + 1][j + 1] =dp[i+1][j] + dp[i][j+1] - dp[i][j] + min(arr_p[i],arr_q[j]);
	// 	}
	// }
	//
	// cout<<dp[W][H]<<endl;
	return 0;
}


Measured memory_bytes: 6512
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		String w[]=new String[n];
		char c[]= new char[10];
		char last[]=new char[10];
		w[0]=sc.next();

		boolean rule=true;

		for (int i=1;i<n && rule == true;++i){
			w[i]=sc.next();
			if (w[i-1].charAt(w[i-1].length()-1) == w[i].charAt(0));
			else rule = false;

			for (int j=0;j<i;++j){
				if (w[i].equals(w[j]) == true) rule = false;
			}
		}

		if (rule == true ) System.out.println("Yes");
		else System.out.print("No");
	}
}

Measured memory_bytes: 23760
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import Control.Applicative

bubbleSort :: Ord a => [a] -> (Int,[a])
bubbleSort = bubbleSort' . (0,)

bubbleSort' :: Ord a => (Int, [a]) -> (Int,[a])
bubbleSort' (n,xs) =
    let (fl,n',xs') = f False n xs
        f :: Ord a => Bool -> Int -> [a] -> (Bool,Int,[a])
        f b m [] = (b,m,[])
        f b m [x] = (b,m,[x])
        f b m (x:y:rest) = if x > y
                              then y <:> f True (m+1) (x:rest)
                              else x <:> f b m (y:rest)
        in
        if fl then bubbleSort' (n',xs')
              else (n',xs')

(<:>) :: forall t t1 a. a -> (t, t1, [a]) -> (t, t1, [a])
(<:>) x (a,b,xs) = (a,b,x:xs)

main = do
    _ <- getLine
    ns <- map (read :: String -> Int) . words <$> getLine
    let (n,sorted) = bubbleSort ns
    putStrLn . unwords . map show $ sorted
    print n

Measured memory_bytes: 4232
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    used = []
    for _ in range(N):
        W = input()
        if W in used:
            print(No)
            return

        if len(used) != 0 and used[-1][-1] != W[0]:
            print(No)
            return

        used.append(W)

    print(Yes)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

ans = 0
(a+1).times do |ai|
  (b+1).times do |bi|
    (c+1).times do |ci|
      ans += 1 if 500*ai + 100*bi + 50*ci == x
    end
  end
end

puts ans


Measured memory_bytes: 1788
let hour s = s / 3600

let minute s = s / 60 mod 60

let second s = s mod 60

let main s = Printf.printf "%i:%i:%i\n" (hour s) (minute s) (second s)

(* ;; print_string "input: " *)
;; Scanf.sscanf (read_line ()) "%d" main

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,a[200005],nt[200005],t[200005];
LL m;
#define INF 0x3f3f3f3f
vector<int>g[200005];
bool f[200005];
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		g[a[i]].push_back(i);
	}
	for(int i=1;i<=n;i++)
		if(!f[a[i]])
		{
			f[a[i]]=1;
			int x=a[i];
			for(int j=1;j<g[x].size();j++)
				nt[g[x][j-1]]=g[x][j];
			nt[*(g[x].end()-1)]=g[x][0];
		}
	int x=1;
	LL k=0;
	while(1)
	{
		int x1=nt[x];
		if(x1<=x)
			k+=n-x+1+x1;
		else
			k+=x1-x+1;
		if(x1==n)
			break;
		x=x1+1;
	}
	m=m*n%k;
	x=1,k=0;
	while(m)
	{
		int x1=nt[x];
		if(x1<=x)
		{
			k+=n-x+1+x1;
			if(k>=m)
			{
				k-=n-x+1+x1;
				break;
			}
		}
		else
		{
			{
				k+=x1-x+1;
				if(k>=m)
				{
					k-=x1-x+1;
					break;
				}
			}
		}
		x=x1+1;
		if(x>n)
			x-=n;
	}
	m-=k;
	memset(f,0,sizeof(f));
	int sta=0;
	if(m==0)
		return 0;
	m--;
	t[++sta]=a[x];
	f[a[x]]=1;
	while(m)
	{
		m--,x++;
		if(x>n)
			x-=n;
		if(!f[a[x]])
			f[a[x]]=1,t[++sta]=a[x];
		else
		{
			while(t[sta]!=a[x])
				f[t[sta--]]=0;
			f[t[sta--]]=0;
		}
	}
	for(int i=1;i<=sta;i++)
		printf("%d ",t[i]);
}



Measured memory_bytes: 14976
from itertools import permutations

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = list(permutations([A,B,C,D,E]))
ans = 999
for order in orders:
    tmp = 0
    for h,i in enumerate(order):
        tmp += i
        if h == 4:
            break
        if tmp % 10 != 0:
            tmp += 10 - (tmp % 10)
    if ans > tmp:
        ans = tmp
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int ans = 0;
// vector<int> vec;
array<int,100001> vec = {};

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> m;
    vec[m-1]++;
    vec[m]++;
    vec[m+1]++;
  }
  ans = *max_element(all(vec));
  print(ans);
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int N = s.nextInt();

		int num1 = N / 100000000;
		int num2 = N % 100000000 / 10000000;
		int num3 = N % 10000000 / 1000000;
		int num4 = N % 1000000 / 100000;
		int num5 = N % 100000 / 10000;
		int num6 = N % 10000 / 1000;
		int num7 = N % 1000 / 100;
		int num8 = N % 100 / 10;
		int num9 = N % 10;

		int fx = num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9;

		if (N % fx == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,d,aa[1100][1100],cnt=0,cnta=0;
pair<int,int> p[220000];
string s;
char c;
signed main(){
    cin>>n>>d;
    rep(i,n){
        rep(j,d){
            cin>>aa[i][j];
        }
    }
    rep(i,n){
        rep(j,i){
            rep(k,d){
                cnta+=(aa[i][k]-aa[j][k])*(aa[i][k]-aa[j][k]);
            }
            int a=sqrt(cnta);
            if(a*a==cnta){
                cnt++;
            }
            cnta=0;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;cin>>n;
    ll x=n%10;
    if(x==2|| x==4 || x==5 || x==7 || x==9)
        cout<<"hon"<<endl;
    else if( x==0 || x==1 || x==6 || x==8)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include<cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
#ifdef getchar_unlocked
#define mygc(c) (c)=getchar_unlocked()
#else
#define mygc(c) (c)=getchar()
#endif
#ifdef putchar_unlocked
#define mypc(c) putchar_unlocked(c)
#else
#define mypc(c) putchar(c)
#endif
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
/////////
using namespace::std;
/////////
#ifdef _DEBUG
#define DEBUG_BOOL(b) assert(b)
#else
#define DEBUG_BOOL(b) 
#endif
/////数値読み込み
#define ENABLE_READER_ON(T)	\
inline void reader(T &x){\
	int k;x = 0;bool flag = true;\
	while(true){\
		mygc(k);\
		if( k == '-'){\
			flag = false;break;\
		}\
		if('0' <= k && k <= '9'){\
			x = k - '0';break;\
		}\
	}\
	if( flag ){\
		while(true){\
			mygc(k);\
			if( k<'0' || '9'<k)break;\
			x = x * 10 + (k - '0');\
		}\
	}else{\
		while(true){\
			mygc(k);\
			if( k<'0' || '9'<k)break;\
			x = x * 10 - (k-'0');\
		}\
	}\
}
//整数
ENABLE_READER_ON(int)
ENABLE_READER_ON(long)
ENABLE_READER_ON(long long)
ENABLE_READER_ON(unsigned int)
ENABLE_READER_ON(unsigned long)
ENABLE_READER_ON(unsigned long long)

//////
//文字読み込み
inline int reader(char c[]){int i,s=0;
for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}
c[s++]=i;
for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}
c[s]='\0';return s;
}

inline int reader(string& c,int size=100){int i;c.reserve(size);
for(;;){mygc(i);if(i != ' '&&i != '\n'&&i != '\r'&&i != '\t'&&i != EOF)break;}
c.push_back(i);
for(;;){mygc(i);if(i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF)break;c.push_back(i);}
return c.size();}

/////////
//数値出力
#define ENABLE_WRITER_ON(T)	\
inline void writer(T x){char f[20];int s = 0;\
if (x<0){mypc('-');while(x){f[s++] = ~(x%10)+1,x /= 10;}}\
else{while(x){f[s++] = (x % 10), x /= 10;}}\
if (!s)f[s++] = 0;while (s--)mypc(f[s] + '0');}

ENABLE_WRITER_ON(int)
ENABLE_WRITER_ON(long)
ENABLE_WRITER_ON(long long)
ENABLE_WRITER_ON(unsigned int)
ENABLE_WRITER_ON(unsigned long)
ENABLE_WRITER_ON(unsigned long long)
/////////
inline void writer(const char c[]){for (int i = 0; c[i] != '\0'; i++)mypc(c[i]); }
inline void writer(const string str){writer( str.c_str() );}

inline void solve(){
	int N;
	cin >> N;
	string str;
	cin >> str;
	int X,MAX;
	X = 0;
	MAX = 0;
	for(int i=0;i<N;++i){
		if( str[i] == 'I'){
			++X;
		}else{
			--X;
		}
		MAX = max(MAX,X);
	}
	cout << MAX << endl;

}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//小数を10進数表示
    //cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();

	return 0;
}


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

#define ll long long

ll x,y,a,b,c,v,A,B,ans;
vector<ll>green,red,colorless;

int main()
{
//    freopen("a.in","r",stdin);
    cin>>x>>y>>a>>b>>c;
    for(ll i=0;i<a;i++)
    {
        cin>>v;
        red.push_back(v);
    }
    for(ll i=0;i<b;i++)
    {
        cin>>v;
        green.push_back(v);
    }
    for(ll i=0;i<c;i++)
    {
        cin>>v;
        colorless.push_back(v);
    }
    sort(red.begin(),red.end());
    reverse(red.begin(),red.end());
    sort(green.begin(),green.end());
    reverse(green.begin(),green.end());
    for(ll i=0;i<x;i++)
        colorless.push_back(red[i]);
    for(ll i=0;i<y;i++)
        colorless.push_back(green[i]);
    sort(colorless.begin(),colorless.end());
    reverse(colorless.begin(),colorless.end());
    for(ll i=0;i<x+y;i++)
        ans+=colorless[i];
    cout<<ans;
}




Measured memory_bytes: 7664
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int cnt[10000001]={-1};
/*Main function*/
int main()
{
    int op=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        for(int j=i;j<=n;j+=i){
            //divi[j].push_back(i);op++;
            ++cnt[j];
        }
    }
    unsigned long long ans=0;
    for(unsigned long long i=1;i<=n;++i){
        ans+=i*cnt[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 42644
#include<stdio.h>
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
	if(n<1200)	printf("ABC\n");
	if(n>=1200&&n<2800)	printf("ARC\n");
	if(n>=2800)	printf("AGC\n");
		
		
	}
	
	
	
	
	
	
	
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i in range(N,0,-1):
  s = A[i-1]
  k = i*2
  while k<=N:
    s ^= B[k-1]
    k += i
  if s==1:
    B[i-1] = s
if sum(B)==0:
  print(0)
else:
  print(sum(B))
  for i in range(N):
    if B[i]==1:
      print(i+1,end=' ')

Measured memory_bytes: 7100
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, m;
    ll res;
    cin >> n >> m;

    if(n > 2 && m > 2){
        cout << (n-2)*(m-2) << endl;
    }else{
        if(n == 2 || m == 2){
            cout << 0 << endl;
        }else{
            if(n == 1 && m == 1){
                cout << 1 << endl;
            }else if(n == 1){
                cout << m-2 << endl;
            }else if(m == 1){
                cout << n-2 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n;
void Main(){   
    cin>>n;
    ll A=0,B=0;
    vector<ll> a(n),b(n);
    For(i,0,n) {
      cin>>a.at(i);
      A+=a.at(i);
    }
    For(i,0,n) {
      cin>>b.at(i);
      B+=b.at(i);
    }
    ll dist=B-A;
    ll cnt=0;
    For(i,0,n){
      if(a.at(i)<b.at(i)){
        cnt+=(b.at(i)-a.at(i)+1)/2;
      }
    }
    if(cnt<=dist)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int ans=0;
  string s;
  cin >> s;
  for(int i=0; i<6; i++) {
    if(s[i]=='1') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

bool check(const vector<char>& zoo, const string& s) {
    const int N = s.size();
    string SW = "SW";
    string ox = "ox";
    rep(i, N) {
        int before = ((i - 1) < 0 ? (i - 1) % N + N : (i - 1) % N),
            after = (i + 1) % N;
        int index = (zoo[i] == 'S' ? 0 : 1);
        if (zoo[before] == zoo[after]) {
            if (s[i] != ox[index]) return false;
        } else {
            if (s[i] != ox[1 - index]) return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<string> cand = {"SS", "SW", "WS", "WW"};
    rep(j, 4) {
        vector<char> zoo = {cand[j][0], cand[j][1]};
        for (int i = 1; i < N - 1; i++) {
            if (zoo[i] == 'S') {
                if (s[i] == 'o')
                    zoo.push_back(zoo[i - 1]);
                else {
                    if (zoo[i - 1] == 'S')
                        zoo.push_back('W');
                    else
                        zoo.push_back('S');
                }
            } else {
                if (s[i] == 'x')
                    zoo.push_back(zoo[i - 1]);
                else {
                    if (zoo[i - 1] == 'S')
                        zoo.push_back('W');
                    else
                        zoo.push_back('S');
                }
            }
        }
        assert((int)zoo.size() == N);
        if (check(zoo, s)) {
            rep(i, N) cout << zoo[i];
            // cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 668
#include <stdio.h>
#include <string.h>

int main(void) {
	char a[102] = { 0 }, b[102] = { 0 };
	int len_a, len_b, i;

	scanf("%s %s", a, b);

	len_a = strlen(a);
	len_b = strlen(b);

	if (len_a > len_b) {
		printf("GREATER\n");
		return 0;
	}
	else if (len_a < len_b) {
		printf("LESS\n");
		return 0;
	}

	for (i = 0; i < len_a; i++) {
		if (a[i] > b[i]) {
			printf("GREATER\n");
			return 0;
		}
		else if (a[i] < b[i]) {
			printf("LESS\n");
			return 0;
		}
	}

	printf("EQUAL\n");

	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())

l = [list(map(int,input().split())) for i in range(m)]

max_l = -1*float('INF')
min_r = float('INF')
for i in range(m):
    max_l = max(max_l,l[i][0])
    min_r = min(min_r,l[i][1])

ans = min_r - max_l + 1

if(ans < 0):
    print(0)
    exit()

if(ans <= n):
    print(ans)
else:
    print(n)


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

typedef long long ll;
using namespace std;

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> acum_g(n);
    acum_g[0] = a[0];
    for (int i = 1; i < n; i++) {
        acum_g[i] = gcd(acum_g[i - 1], a[i]);
    }
    vector<int> acum_g_rev(n);
    acum_g_rev[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        acum_g_rev[i] = gcd(acum_g_rev[i + 1], a[i]);
    }
    int ans = -1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = max(ans, acum_g_rev[i + 1]);
        } else if (i == n - 1) {
            ans = max(ans, acum_g[i - 1]);
        } else {
            ans = max(ans, gcd(acum_g[i - 1], acum_g_rev[i + 1]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
void main()
{
    long[] tmp = rdRow;
    long h = tmp[0], w = tmp[1], d = tmp[2];
    coord[] lists = new coord[h*w+1];
    foreach (i; 0 .. h)
    {
        long[] a = rdRow;
        foreach (j; 0 .. w)
        {
            lists[a[j]].y = i, lists[a[j]].x = j;
        }
    }

    long[] dp = new long[h*w+1];
    foreach (i; d+1 .. h*w+1)
    {
        dp[i] = dp[i-d] + abs(lists[i].y - lists[i-d].y) + abs(lists[i].x - lists[i-d].x);
    }

    long q = rdElem;
    foreach (i; 0 .. q)
    {
        long[] test = rdRow;
        long l = test[0], r = test[1];
        writeln(dp[r] - dp[l]);
    }
}

alias coord = Tuple!(long, "y", long, "x");

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;

int a[N],to[N << 1],nex[N << 1],beg[N],tot[N],Hash[N],vis[N];
int e,ans = 0;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

inline void dfs(int x,int fa) {
	vis[x] = true;
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		dfs(to[i],x);
		int val = min(tot[x],tot[to[i]]);
		ans += val;
		tot[x] -= val,tot[to[i]] -= val;
	}
}

int main() {

	int n = read();
	For(i,1,n) Hash[i] = a[i] = read();
	sort(Hash + 1,Hash + n + 1);
	int cnt = unique(Hash + 1,Hash + n + 1) - Hash - 1;
	For(i,1,n) tot[a[i] = lower_bound(Hash + 1,Hash + cnt + 1,a[i]) - Hash]++;

	For(i,1,cnt) For(j,1,30) {
		int val = (1 << j) - Hash[i];
		int pos = lower_bound(Hash + 1,Hash + cnt + 1,val) - Hash;
		if(Hash[pos] == val && (i ^ pos)) add(i,pos);
	}

	For(i,1,cnt) if(!vis[i]) dfs(i,0);
	For(i,1,cnt) {
		bool flag = false;
		For(j,0,30) if(Hash[i] == (1 << j)) flag = true;
		if(flag) ans += tot[i] / 2;
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    vl x(5);
    vl r(5);
    rep(i,5){
        cin >> x[i];
        r[i] = 10 - x[i] % 10;
        if(r[i] == 10) r[i] = 0;
    }
    sort(r.rbegin(), r.rend());
    ll ans = 0;
    rep(i,5){
        if(i==0) ans += x[i];
        else ans += x[i] + r[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
if n==0:
    print('0')
    exit()
ans = ''
while n != 0:
    if n%(-2) == 0:
        ans = '0' + ans
        n /= -2
    else:
        ans = '1' + ans
        n = (n-1)/(-2)
print(ans)

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

int main()
{
    while (true)
    {
        int n;
        cin>>n;
        if(n==0)break;

        vector<ll> dp(n+1);
        dp[0]=dp[1]=1;
        dp[2]=2;
        for (int i = 3; i < dp.size(); i++)
        {
            dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
        }
        int d,a,b;
        d=ceil(dp[n]/10);
        a=d/365;
        b=d%365;
        if(a>0)
        {
            if(b>0) a++;
            cout<<a<<endl;
        }
        else cout<<1<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 3092