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

using namespace std;


int main(){
  int n;
  
  cin >> n;
  vector<int> arr1(n);
  vector<int> arr2(n);
  for (int i=0; i<n; i++){
    cin >> arr1[i];
  }
  for (int i=0; i<n; i++){
    cin >> arr2[i];
  }
  
  partial_sum(arr1.begin(), arr1.end(), arr1.begin());
  partial_sum(arr2.begin(), arr2.end(), arr2.begin());
  
  int max = -1;
  for (int i=0; i<n; i++){
    if (i == 0){
      int val = arr1[i]+arr2[n-1];
      
      max = val;
    }else{
      int val = arr1[i]+arr2[n-1]-arr2[i-1];
      if (val > max){
        max = val;
      }
    }
  }
  cout << max;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c, d; cin >> a >> b >> c >> d;
    if(a+b == c+d) cout << "Balanced" << endl;
    else if(a+b > c+d) cout << "Left" << endl;
    else cout << "Right" << endl;
}

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

inline int get() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

const int N = 4e5 + 5;
int n;
bool val[N];
struct Edge {
	int v, nxt;
} edge[N];
int head[N], tot = 1;
int dis[N], f[N], sze[N];

inline void addedge(int u, int v) {
	edge[++tot].v = v, edge[tot].nxt = head[u], head[u] = tot;
}

inline void insedge(int u, int v) { addedge(u, v), addedge(v, u); }

inline void init() {
	memset(dis, 0, sizeof(dis));
	memset(f, 0, sizeof(f));
}

inline void dfs(int u, int fa) {
	int mx = 0; sze[u] = val[u];
	for(register int i = head[u]; i; i = edge[i].nxt) {
		int v = edge[i].v;
		if(v == fa) continue;
		dfs(v, u);
		sze[u] += sze[v], dis[v] += sze[v], dis[u] += dis[v];
		if(dis[v] > dis[mx]) mx = v;
	}
	if(!mx) { f[u] = 0; return; }
	if(dis[mx] * 2 < dis[u]) f[u] = dis[u] / 2;
	else f[u] = dis[u] - dis[mx] + min(f[mx], dis[mx] * 2 - dis[u]);
}

int main() {
	n = get();
	int ans = 0x3f3f3f3f;
	for(register int i = 1; i <= n; i++) scanf("%1d", &val[i]);
	for(register int i = 1; i < n; i++) insedge(get(), get());
	for(register int rt = 1; rt <= n; rt++) {
		init();
		dfs(rt, 0);
		if(dis[rt] % 2) continue;
		if(f[rt] * 2 >= dis[rt]) ans = min(ans, dis[rt] / 2);
	}
	printf("%d", ans == 0x3f3f3f3f? -1 : ans);
	return 0;
}


Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLong()) {
            long x = sc.nextLong();
            long fiveAndSix = (x / 11) * 2;
            long rem = x % 11;
            if ( rem > 0 && rem <= 6 ) {
                fiveAndSix++;
            } else if ( rem != 0 ) {
                fiveAndSix += 2;
            }

            System.out.println(fiveAndSix);
        }
    }
}


Measured memory_bytes: 21844
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

N,K=get_i
h=array(N)
N.times do|i|
    h[i]=gets.to_i
end
h.sort!{|x,y| y<=>x}
ans=Float::INFINITY
(N-K+1).times do|i|
    ans=(h[i]-h[i+K-1]).abs if ans>(h[i]-h[i+K-1]).abs
end
puts ans

Measured memory_bytes: 3576
#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, K= getIntList()
#print(N)
za = getIntList()
za += [0 for i in range(200)]
ddd = int(1e10)
dp = [ddd for i in range(N+ 200) ]
dp[0] = 0
for i in range(N-1):
    nd = dp[i]
    for g in range(i+1, i+K+1):
        dp[g] = min(dp[g],  nd + abs( za[i] - za[g]) )
print(dp[N-1])






Measured memory_bytes: 56544
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long ll;

const ll N = 1e7 + 10;

ll n;
ll res = 0;
ll f[N];


ll solve(ll x) {
	ll ret = 1;
	ll i = 2, cnt = 1;
	while (i <= sqrt(x)) {
		while (x % i == 0) cnt++, x /= i;
		ret = ret * cnt;
		cnt = 1, i++;
	}

	if (x != 1) {
		ret = ret * 2;
	}

	return ret;
}

int main() {
	cin >> n;
	/*
	for (ll i = 1; i <= n; i++) {
		res += solve(i) * i;
	}

	cout << res << endl;
	*/

	for (ll i = 1; i <= n; i++)
		for (ll j = 1; j * i <= n; j++)
			f[i * j]++;
	ll res = 0;
	for (ll i = 1; i <= n; i++) {
		res = res + i * f[i];
		//cout << f[i] << " ";
	}
	//cout << endl;
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 81800
s = input()

lgh = len(s)
s = int(s,2)

result = [0,0]

counter = 0

for i in range(lgh):
    result[0] = result[0] + (((s>>i)&1) ^ counter)
    counter = 1 - counter
    result[1] = result[1] + (((s>>i)&1) ^ counter)

print(min(result))


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

int main() {
  int N;
  cin >> N;
  if (N % 10 == 3) {
    cout << "bon" << endl;
  } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    int b = 0,c = 0;
    int acn = 0,zloc = -1;
    for(int i = 0; i < a.size(); i++){
        if(acn == 0 && a[i] == 'A'){
        b = i;
        acn++;
        }
        if(a[i] == 'Z' && zloc < i){
            zloc = i;
            c = i;
        }
    }
    cout << c - b + 1<< endl;
}

Measured memory_bytes: 640
line = input().split(" ")
a = int(line[0])
b = int(line[1])

# a + (n - 1) * (a - 1) >= b
# n * (a - 1) + 1 >= b
# n >= (b - 1)/(a - 1)

n = (b - 1)/(a - 1)

if n == int(n):
  print(int(n))
elif n >= int(n):
  print(int(n) + 1)


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

int main() {
	int n,t;
	cin >> n >> t;
	int cc = 1001;
	for(int i = 0;i < n;i++)
	{
		int c,tm;
		cin >> c >> tm;
		if(t >= tm)
		{
			cc = min(c,cc);
		}
	}
	if(cc > 1000)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << cc << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()

const int mod = 1000000007;
const int N = 1e5 + 1;
vector<int> g[N];
int vis[N];

/*
Idea--



*/

void dfs(int node)
{
    vis[node] = 1;
    for (int c : g[node])
    {
        if (!vis[c])
            dfs(c);
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        // int a[n];
        for (int i = 0; i < m; ++i)
        {
            int u, v;
            cin >> u >> v;
            g[u].push_back(v);
            g[v].push_back(u);
        }
        for (int i = 1; i <= n; ++i)
            vis[i] = 0;
        int ct = 0;
        for (int i = 1; i <= n; ++i)
        {
            if (!vis[i])
            {
                dfs(i);
                ct++;
            }
        }
        cout << ct - 1 << "\n";
    }
}

Measured memory_bytes: 11084
D = int(input())
Cs = list(map(int, input().split()))
Sss = []
for _ in range(D):
    Ss = list(map(int, input().split()))
    Sss.append(Ss)

Ts = []
for _ in range(D):
    Ts.append(int(input()))

lasts = [0] * 26
score = 0
for i, t in enumerate(Ts):
    d = i + 1
    t -= 1
    score += Sss[i][t]
    lasts[t] = d
    for j in range(26):
        score -= (d - lasts[j]) * Cs[j]
    print(score)


Measured memory_bytes: 9256
N=int(input())
ok=True
W2=input()
lis=[W2]
for i in range(N-1):
    W=W2
    W2=input()
    if W2 in lis:
        ok=False
        break
    lis.append(W2)
    if(W2[0]!=W[len(W)-1]):
        ok=False
        break
if(ok):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    long long a[8]={0,1,2,4,8,16,32,64};
    long long n;
    cin>>n;
    for(int i=7;i;i--){
        if(a[i]<=n){
            cout<<a[i]<<endl;
            return 0;
        }
    }
    return 0;
}

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


#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

int qt[20];

int main()
{
  ll n;
  cin >> n;
  if(n & 1)
  {
    cout << "0\n";
    return 0;
  }
  n = (n + 1) / 2;
  ll count = 0;
  for(ll i = 5, j = 0; j <= 26 ; i *= 5, j++)
  {
    count += n / i; 
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
 
using namespace std;
 
int main(void) {
    string s;
    unsigned int k;
    cin >> s;
    cin >> k;
    vector<string> ss;
    for(int i = 0;i < s.length();i++) {
        ss.push_back(s.substr(i,s.length() - i));
    }
    sort(ss.begin(), ss.end());
    
    set<string> sss;
    while(sss.size() < k) {
        string t = *ss.begin();
        for(int i = 1;i <= t.length() && sss.size() < k;i++) {
            if(sss.find(t.substr(0,i)) == sss.end())
                sss.insert(t.substr(0,i));
        }
        ss.erase(ss.begin());
    }
    auto x = sss.begin();
    for(int i = 1;i < k;i++)
        x++;
    cout << *x << endl;
    return 0;
}

Measured memory_bytes: 16128
#include<stdio.h>

int main()
{
  int h,w,k;
  int i,j;
  int c,d;
  int ans=0;
  int b;
  char s[6][6];
  scanf("%d%d%d",&h,&w,&k);
  for(i=0;i<h;i++){
    scanf("%s",s[i]);
  }
  for(c=0;c<(1<<h);++c){
    for(d=0;d<(1<<w);++d){
      b=0;
      for(i=0;i<h;i++){
        for(j=0;j<w;j++){
          if( !(c&(1<<i)) && !(d&(1<<j)) && s[i][j]=='#'){
            b++;
          }
        }
      }
      if(b==k) ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


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

double res(int n)
{
  int ans = 1;
  rep(i, n) ans *= (n - i);
  return ans;
}

int main()
{
  int n;
  cin >> n;
  vector<P> v(n);
  long double sum = 0;
  rep(i, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  do{
    rep(i, n - 1) {
      sum += sqrt(pow((v[i].first - v[i + 1].first), 2) + (pow((v[i].second - v[i + 1].second), 2)));
    }
  }while(next_permutation(v.begin(), v.end()));
  
  cout << setprecision(20) << sum / res(n) << endl;
     
  
  return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

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

    int delta = 1 << 30;
    for (int i = 0; i <= n - k; i++){
        if (data.at(i + k - 1) - data.at(i) < delta){
            delta = data.at(i + k - 1) - data.at(i);
        }
    }

    cout << delta << endl;
}

Measured memory_bytes: 640
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    S = sys.stdin.readline().rstrip()
    K = int(sys.stdin.readline())

    cnt = 0
    for s in S:
        if K == 0:
            print(1)
            break
        if s == "1":
            K -= 1
        else:
            print(s)
            break
    else:
        print(1)

Measured memory_bytes: 5200
import java.util.*;

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

        int max = Math.max(Math.max(A, B), C);
        int ans = 0;

        if (max == A) {
            ans = (int)Math.pow(2, K) * A + B + C;
        } else if(max == B) {
            ans = (int)Math.pow(2, K) * B + A + C;
        } else {
            ans = (int)Math.pow(2, K) * C + A + B;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23380
import heapq
 
N,M,S,T = map(int, raw_input().split())
S,T = S-1,T-1
src = [tuple(map(int, raw_input().split())) for i in range(M)]
 
es = [[] for i in range(N)]
for u,v,a,b in src:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))
 
INF = float('inf')
cy = [INF] * N
cy[S] = 0
hq = [(0,S)]
heapq.heapify(hq)
while hq:
    cost,v = heapq.heappop(hq)
    for to,a,b in es[v]:
        if cost + a >= cy[to]: continue
        cy[to] = cost + a
        heapq.heappush(hq, (cy[to],to))
 
cs = [INF] * N
cs[T] = 0
hq = [(0,T)]
heapq.heapify(hq)
while hq:
    cost,v = heapq.heappop(hq)
    for to,a,b in es[v]:
        if cost + b >= cs[to]: continue
        cs[to] = cost + b
        heapq.heappush(hq, (cs[to],to))
 
ans = [INF]
for i in reversed(range(N)):
    tmp = cs[i] + cy[i]
    ans.append(min(ans[-1],tmp))
 
for a in reversed(ans[1:]):
    print 10**15 - a

Measured memory_bytes: 102428
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

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

int main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    sort(t.begin(), t.end());
    ll cur = 0;
    ll ans = 0;
    while(cur<n){
        int nex = cur;
        while( nex < n && nex - cur < c && t[nex] - t[cur] <= k ) nex++;
        ans++;
        cur=nex;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=1;
    int mini=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]<mini){
        mini=a[i];
        c++; 
        }
    }
    cout<<c;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4424
from collections import Counter

N = int(input())
count = 0
ans = 0
s = [""] * N
for i in range(N):
    tmp = sorted(input())
    s[i] = "".join(tmp)
s.sort()
for i in range(N - 1):
    if s[i] == s[i + 1]:
        count += 1
    elif s[i] != s[i + 1] and count > 0:
        ans += count*(count+1)//2
        count = 0
if count > 0:
    ans += count*(count+1)//2
    count = 0
print(ans)

Measured memory_bytes: 10864
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;
bool odd(ll n)
{
    ll cnt=0;
    while(n)
    {
        cnt++;
        n/=10;
    }

    return cnt%2==1;
}

int main()
{
    fast();
    ll n;
    cin>>n;

    ll cnt=0;
    for(ll i=1;i<=n;i++)
    {
        if(odd(i))
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int main(void){
	int n,maxi,mini;
	int cnt=0;
	int cnt2=0;
	int max=0;
	int min=0;
	int a[50]={0};
	int b[50]={0};
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]<0){
			cnt++;
		}
		if(max<a[i]){
			max=a[i];
			maxi=i;
		}
		if(min>a[i]){
			min=a[i];
			mini=i;
		}
	}
	if(cnt==0){
		printf("%d\n",n-1);
		for(int i=1;i<n;i++){
			printf("%d %d\n",i,i+1);
		}
	}else if(cnt==n){
		printf("%d\n",n-1);
		for(int i=n;i>1;i--){
			printf("%d %d\n",i,i-1);
		}
	}else{
		printf("%d\n",n*2-2);
		if(abs(max)>=abs(min)){
			for(int i=1;i<=n;i++){
				if(i!=maxi){
					printf("%d %d\n",maxi,i);
				}
			}
			for(int i=1;i<n;i++){
				printf("%d %d\n",i,i+1);
			}
		}else{
			for(int i=1;i<=n;i++){
				if(i!=mini){
					printf("%d %d\n",mini,i);
				}
			}
			for(int i=n;i>1;i--){
				printf("%d %d\n",i,i-1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e5+5;
priority_queue<ii> q;
int k,d[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>k; 
	memset(d,0x3f3f3f3f,sizeof(d));
	for(int i=1;i<=9;i++)
	{
		q.push(ii(-i,i%k));
		d[i]=i;
	}
	while(!q.empty())
	{
		ii u=q.top();
		q.pop();
		ll val=-u.first,r=u.second;
		if(val>d[r])	continue;
		for(int i=0;i<10;i++)
		{
			int nr=(r*10+i)%k,nv=val+i;
			if(d[nr]>nv)
			{
				d[nr]=nv;
				q.push(ii(-nv,nr));
			}	
		}
	}
	cout<<d[0]<<'\n';
	return 0;
}

Measured memory_bytes: 3188
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}



int a,b,c;



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


    cin >> a >> b >> c;
    cout << max( 1LL*0, c-a+b );




return 0;
}
///....



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

typedef long long ll;

typedef pair<int, int> P;
typedef pair<double, P> DP;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

map<P,double> d;

int N;
int X[110],Y[110];
vector<int> ys;
int V;
double gx[10010],gy[10010];

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    d.clear();
    ys.clear();
    rep(i,N){
      cin>>X[i]>>Y[i];
      ys.push_back(Y[i]);
    }
    sort(all(ys));
    uni(ys);

    gx[0]=X[0],gy[0]=Y[0];
    V=1;
    rep(i,N-1){
      int crtx=X[i],nxtx=X[i+1];
      int crty=Y[i],nxty=Y[i+1];
      if(crty<nxty){
        double r=(double)abs(nxtx-crtx)/(double)abs(nxty-crty);
        rep(j,ys.size()){
          if(crty<ys[j]&&ys[j]<nxty){
            gy[V]=ys[j];
            gx[V]=(double)crtx+r*((double)ys[j]-(double)crty);
            V++;
          }
        }
      }else{
        double r=(double)abs(nxtx-crtx)/(double)abs(nxty-crty);
        for(int j=ys.size()-1;j>=0;j--){
          if(nxty<ys[j]&&ys[j]<crty){
            gy[V]=ys[j];
            gx[V]=nxtx-r*(double)(ys[j]-nxty);
            V++;
          }
        }
      }
      gx[V]=nxtx; gy[V]=nxty;
      V++;
    }

    priority_queue<DP,vector<DP>,greater<DP> > que;
    que.push(DP(0,P(0,V-1)));
    while(que.size()){
      DP s=que.top(); que.pop();
      if(d.find(s.se)!=d.end())continue;
      d[s.se]=s.fi;
      if(s.se.fi==s.se.se){
        printf("%.10f\n", s.fi);
        break;
      }

      repl(d1,-1,2)repl(d2,-1,2){
        int nx1=s.se.fi+d1;
        int nx2=s.se.se+d2;
        if(nx1>=0&&nx1<V&&nx2>=0&&nx2<V&&nx1<=nx2&&abs(gy[nx1]-gy[nx2])<1e-8){
          double dd1=sqrt(pow(abs(gx[nx1]-gx[s.se.fi]),2)+pow(abs(gy[nx1]-gy[s.se.fi]),2));
          double dd2=sqrt(pow(abs(gx[nx2]-gx[s.se.se]),2)+pow(abs(gy[nx2]-gy[s.se.se]),2));
          que.push(DP(s.fi+dd1+dd2,P(nx1,nx2)));
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 5212
#include <stdio.h>
#include <math.h>

long long	calc(long long a, long long b, unsigned long long x)
{
  	long long	c;
  	long long 	d;
  	
  	c = floor(a * x / b);
  	d = a * floor(x / b);
  	return (c - d);
}

int	main(void)
{
  	long long	a;
  	long long 	b;
  	unsigned long long 	n;
  	unsigned long long 	x;
  	long long 	max;
  	long long 	tmp;
  	  
  	scanf("%lld %lld %lld", &a, &b, &n);
  
  	max = -900000000000;
  	if (n < b)
  	{
/*
        for(x=0; x<=n; x++)
        {
          	tmp = calc(a, b, x);
          	if (max < tmp)
              	max = tmp;
        }
*/
        tmp = calc(a, b, n);
        if (max < tmp)
            max = tmp;
    }
    else
    {
        tmp = calc(a, b, b-1);
        if (max < tmp)
            max = tmp;
/*
      	for(x=0; x<b; x++)
        {
          	tmp = calc(a, b, x);
          	if (max < tmp)
              	max = tmp;
        }
*/
/*
      	for(x=b; x<=n; x+=b)
        {
          	tmp = calc(a, b, x);
          	if (max < tmp)
              	max = tmp;
        }
        */
    }
  	printf("%lld", max);
  	return (0);
}

Measured memory_bytes: 1724
import sys
readline = sys.stdin.readline
from collections import Counter

N = int(readline())
S = [readline().rstrip() for i in range(N)]

c = Counter(S)

maxc = max(c.values())

a = []
for k, v in c.items():
    if v == maxc:
        a.append(k)

a.sort()

for s in a:
    print(s)

Measured memory_bytes: 90708
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int H, W;
string A[1010];
int cnt[1010][1010];
vector<vector<int>> black;

void bfs() {
  queue<vector<int>> que;

  for (auto v : black) {
    cnt[v[0]][v[1]] = 0;
    que.push({v[0], v[1]});
  }

  vector<vector<int>> next = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

  while (que.size() > 0) {
    auto v = que.front(); que.pop();

    int y = v[0];
    int x = v[1];

    for (int i = 0; i < 4; ++i) {
      int ny = y+next[i][0];
      int nx = x+next[i][1];

      if (ny < 0 or H <= ny or nx < 0 or W <= nx or cnt[ny][nx] != -1) continue;

      cnt[ny][nx] = cnt[y][x]+1;
      que.push({ny, nx});
    }
  }
}


int main()
{
  cin >> H >> W;
  REP(i, H) cin >> A[i];

  REP(y, H) REP(x, W) cnt[y][x] = -1;

  REP(y, H) REP(x, W) {
    if (A[y][x] != '#') continue;
    black.push_back({y, x});
  }

  bfs();

  int ans = -1;
  REP(y, H) REP(x, W) {
    ans = max(ans, cnt[y][x]);
  };

  cout << ans << endl;
}

Measured memory_bytes: 115364
s = input()
n = len(s)

def self(i,w):
    if(i == n-1):
        return sum(list(map(int, w.split("+"))))
    return self(i+1,w+s[i+1]) + self(i+1,w+"+"+s[i+1])

print(self(0,s[0]))


Measured memory_bytes: 67100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ld long double
#define MOD 1000000007
#define u128 __int128
#define ff first
#define ss second
#define INTMAX 1000000009
#define N 100050

ll bmexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x;
	cin >> n >> x;
	int l[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> l[i];
	}

	int d = 0, ans = 0;
	int i = 0;
	while(d <= x && i < n)
	{
		d = d + l[i++];
		ans++;
	}
	if(d <= x)
		ans++;
	cout << ans << '\n';
	return 0;	
}

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

int main()
{
	int squ[20][20];
	int n, fi, x, y;
	while (cin >> n, n){
		fi = 0;
		for (int i = 0; i < 20; i++){
			for (int j = 0; j < 20; j++){
				squ[i][j] = 0;
			}
		}
		for (int i = 0; i < n * n; i++){
			if (fi == 0) {
				x = (n / 2);
				y = (n / 2) + 1;
				fi = 1;
			}
			else {
				x += 1;
				y += 1;
				if (x == n) x = 0;
				if (y == n) y = 0;
				if(squ[x][y] >= 1){
					x -= 1;   
					y += 1;
					if (x == -1) x = n - 1; 
			   if (y == n) y = 0;
			 }
			}
			squ[x][y] = i + 1;
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				printf("%4d", squ[j][i]);
				// cout << squ[j][i];
				// if (!(j == n - 1)) cout << " ";
			}
			cout << endl;
		}
	}
	return (0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
 */

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int k,s,ans=0;
  cin>>k>>s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(0<=s-i-j&&s-i-j<=k)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,m;cin>>n>>m;
    if(n<=m)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3636
import java.util.*;
 
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
  String s1=sc.nextLine();
  String s2=sc.nextLine();
  int count=0,i;
  for(i=0;i<s1.length();i++){
    if(s1.charAt(i)==s2.charAt(i))
      count++;
}
  System.out.println(count);
}

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void Nikkei2A()
{
	int N;
	cin >> N;
	if (N % 2 == 0)
	{
		cout << N / 2 - 1 << endl;
	}
	else
	{
		cout << N / 2 << endl;
	}
}

int main()
{
	Nikkei2A();
	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 number1 = sc.nextInt();
    int number2 = sc.nextInt();
    double div = (double) (number1 + number2) / 2;
    System.out.println((int) Math.ceil(div));
  }
}

Measured memory_bytes: 21844
n = int(input())
cards = [input().split() for _ in range(n)]

t = 0
h = 0

for card in cards:
    if card[0] > card[1]:
        t += 3
    elif card[0] < card[1]:
        h += 3
    else:
        t += 1
        h += 1
print(t, h)



Measured memory_bytes: 5716
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long LL;

template<typename T>
void print_vec(vector <T>v){
  for(int i=0;i<v.size();i++){
	cout << v[i] << " ";
  }
  cout << endl;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> ship1;
  vector<int> shipN;

  for(int i=0;i<M;i++){
	int a,b;
	cin >> a >> b;
	if(a==1){
	  ship1.push_back(b);
	}else if(b==N){
	  shipN.push_back(a);
	}
  }

  if(ship1.size()==0 || shipN.size()==0){
	cout << "IMPOSSIBLE" << endl;
	return 0;
  }
  sort(ship1.begin(),ship1.end());
  sort(shipN.begin(),shipN.end());

  
  auto itr1=ship1.begin(),itrN=shipN.begin(),itr1_end=ship1.end(),itrN_end=shipN.end();
  
  while((itr1!=itr1_end&&itrN!=itrN_end)){
	if(*itr1==*itrN){
	  cout << "POSSIBLE" << endl;
	  return 0;
	}else if(*itr1<*itrN){
	  itr1++;
	}else{
	  itrN++;
	}
  }
  
  cout << "IMPOSSIBLE" << endl;

  return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
    int H, W;
    int d[51][51];
    cin >> H >> W;
    int kabe = 0;

    char maze[H][W];
    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
            if (maze[i][j] == '#') kabe++;
        }
    }

    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

    queue<P> que;
    rep(i, H) {
        rep(j, W) {
            d[i][j] = INF;
        }
    }
    que.push(P(0, 0));
    d[0][0] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        if (p.first == H - 1 && p.second == W - 1) break;
        rep(i, 4) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    int goal = d[H - 1][W - 1];
    if (goal == INF) {
        cout << -1 << endl;
    }
    else {
        cout << H * W - goal - kabe - 1 << endl;
    }
    return 0;
}

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

long long solve(const string &S) {
  int N = S.size();
  vector<long long> val(2019, 0);
  long long fac = 1;
  long long cur = 0;
  val[cur]++;
  for (int i = 0; i < N; ++i) {
    long long add = S[N - 1 - i] - '0';
    cur = (cur + fac * add) % 2019;
    fac = (fac * 10) % 2019;
    val[cur]++;
  }
  long long res = 0;
  for (int i = 0; i < val.size(); ++i) {
    res += val[i] * (val[i] - 1) / 2;
  }
  return res;
}

int main() {
  string S;
  cin >> S;
  cout << solve(S) << endl;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
//#include<Rollman>
#define Otaku main
#define Elite cin
#define Rollman return 0
#define Happy_birthday_Rollman endl
#define My_Rollman_is cout

using namespace std;

int Otaku(){
  int result[4],result2[2],nearGPA4=0;//(GPA3.98)
  for(int i=0;i<4;i++) Elite>>result[i];
  for(int i=0;i<2;i++) Elite>>result2[i];
  sort(result,result+4);
  sort(result2,result2+2);
  for(int i=3;i>=1;i--) nearGPA4+=result[i];
    nearGPA4+=result2[1];
   
    My_Rollman_is<<nearGPA4;
    cout<<Happy_birthday_Rollman;
       
  Rollman;
}

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

const int MAXN = 1.1e5;
int N;
int par[MAXN];
int getPar(int a) {
	return (par[a] == -1) ? a : (par[a] = getPar(par[a]));
}
bool merge(int a, int b) {
	a = getPar(a), b = getPar(b);
	if (a == b) return false;
	par[b] = a;
	return true;
}
pair<int, int> X[MAXN];
pair<int, int> Y[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	memset(par, -1, sizeof(par));
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i].first >> Y[i].first;
		X[i].second = Y[i].second = i;
	}
	sort(X,X+N);
	sort(Y,Y+N);
	vector<pair<int, pair<int, int>>> edges;
	for (int i = 0; i+1 < N; i++) {
		edges.push_back({X[i+1].first-X[i].first, {X[i].second, X[i+1].second}});
		edges.push_back({Y[i+1].first-Y[i].first, {Y[i].second, Y[i+1].second}});
	}
	sort(edges.begin(), edges.end());
	long long ans = 0;
	for (auto it : edges) {
		if (merge(it.second.first, it.second.second)) {
			ans += it.first;
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a<b)
    {
        for(int i=0; i<b; i++)
            cout << a;
        cout << endl;
    }
    else
    {
        for(int i=0; i<a; i++)
            cout << b;
        cout << endl;
    }
}


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

typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

#define NIL NULL

Node *root;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;


while(x!=NIL){
  y=x;
  if(z->key < x->key){
    x=x->left;
  }else {
    x=x->right;
  }
 }

z->parent=y;
if(y==NIL){
  root=z;
 }else{
  if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }
 }
}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
} 

  int main(){
    int n,i,x;
    char com[20];
    scanf("%d",&n);

    for(i=0;i<n;i++){
      scanf("%s",com);
      if(strcmp(com,"insert")==0){
	scanf("%d",&x);
	insert(x);
      }
      else if(strcmp(com,"print")==0){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    }
    return 0;
  }

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

int calc(int n) {
	int sum = 1150;
	if (10 < n) sum += (n - 10) * 125;
	if (20 < n) sum += (n - 20) * 15;
	if (30 < n) sum += (n - 30) * 20;
	return sum;
}

int main() {
	int data;
	while (1) {
		cin >> data; if (data == -1) break;
		cout << 4280 - calc(data) << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
//
// Created by 佐竹俊哉 on 2019/11/12.
//

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N; cin >> N;
    V<pii> vec;
    string s;
    cin >> s;
    for (char c : s) {
        if (vec.size() == 0 || vec.back().fi != c) {
            vec.eb(c, 1);
        } else {
            vec.back().se++;
        }
    }
    cout << vec.size() << endl;
    return 0;
}

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

#define int long long
#define ld long double

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cerr<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)100000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 998244353



signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int t;
    t = 1;
    while(t--)
    {
        int pre = -1;
        string s;
        cin>>s;
        int cnt=0, ans = 0;
        for (int i=0;i<sz(s);++i)
        {
            if (s[i]==pre)
                cnt++;
            else
            {
                if (pre=='R')
                {
                    ans = max(ans, cnt);
                }
                cnt = 1;
                pre = s[i];
            }
        }
        if (pre=='R')
            ans = max(ans, cnt);
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;
const int MAX = 1e7;
const int MOD = 1e9+7;

int main(int argc, char *args[]) {
	int n, x;
	cin >> n >> x;
	vector<int> L(n);
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}

	int cnt = 1;
	int d = 0;
	for (int i = 0; i < n; i++) {
		d += L[i];
		if (d <= x)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
graph=[[] for i in range(n)]
for i in range(m):
    l,r,d=map(int,input().split())
    graph[r-1].append((l-1,-d))
    graph[l-1].append((r-1,d))
INF=10**9
x_list=[INF]*n
stack=[]
for i in range(n):
    if x_list[i]==INF:
        x_list[i]=0
        stack.append(i)
        while len(stack)>0:
            now=stack.pop()
            for j in graph[now]:
                if x_list[j[0]]==INF:
                    x_list[j[0]]=x_list[now]+j[1]
                    stack.append(j[0])
                else:
                    if x_list[j[0]]==x_list[now]+j[1]:
                        pass
                    else:
                        print('No')
                        sys.exit()
print('Yes')


Measured memory_bytes: 81952
# -*- coding: utf-8 -*-
import sys
import collections
input = sys.stdin.readline
def ii(): return int(input().rstrip())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input().rstrip())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    n = ii()
    g = [[] for i in range(n)]
    for i in range(n - 1):
        a, b = mi()
        g[a - 1].append((b - 1, i))
        g[b - 1].append((a - 1, i))
    color = max([len(g[i]) for i in range(n)])
    print(color)
    q = collections.deque()
    ans = [-1 for i in range(n - 1)]
    idx = 0
    q.append((0, 0))
    while len(q):
        t, idx = q.popleft()
        for e in g[t]:
            if ans[e[1]] != -1:
                continue
            idx += 1
            ans[e[1]] = idx
            q.append((e[0], idx))
    print(*map(lambda x: x % color + 1, ans), sep="\n")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74272
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map(String::toLong)
    println(calcXor(a - 1) xor calcXor(b))
}

fun calcXor(x: Long) = when (x % 4) {
    0L -> x
    1L -> 1
    2L -> x + 1
    else -> 0
}

Measured memory_bytes: 38104
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,k,q;
  cin>>n>>k>>q;
  vi a(n,0);

  rep(i,q){
    int b;
    cin>>b;
    b--;
    a[b]++;
  }

  rep(i,n){
    if(k-(q-a[i])>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}



Measured memory_bytes: 1408
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll k;
	cin >> n >> k;
	vector<ll>d(n + 2);
	vector<ll>dm(n + 2);
	d[1] = 0;
	dm[1] = n;
	ll res = 0;
	for (ll i = 2; i <= n + 1; i++) {
		d[i] = d[i - 1] + i - 1;
		dm[i] = dm[i - 1] + n + 1 -i;
	}
	for (ll i = k; i <= n + 1; i++) {
		res += dm[i] - d[i] + 1;
		res %= ma;
	}
	cout << res << endl;
}

Measured memory_bytes: 6308