akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A){
  multiset<ll,greater<ll>> x;
  REP(N){
    auto tmp=x.upper_bound(A[i]);
    if(tmp==x.end()){
      x.insert(A[i]);
    }else{
      x.erase(tmp);
      x.insert(A[i]);
    }
  }
  cout<<x.size()<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

unsigned long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0, startp = 0, endp = 0, checker = 0;
std::vector<unsigned long long int> vec{}, vecsec{};
int iremono[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char cutcount[201];
int kakunou2[50][50] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{

	cin >> a;
	rep(i, a) {
		cin >> x;
		vec.push_back(x);
	}
	std::sort(vec.begin(), vec.end());
	z = 1;
	vec.push_back(13298321);
		for (int i = 1; i <= a; i ++) {
			if (vec[i] == vec[i - 1]) {
				z++;
				
			}
			else {
				rep(j, z/2) {
					vecsec.push_back(vec[i - 1]);
				}
				z = 1;
			}
			
		}

		if (vecsec.size() >= 2) {
			cout << vecsec[vecsec.size() - 1] * vecsec[vecsec.size() - 2];
		}
		else {
			cout << 0 << endl;
		}
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    sort(all(v));

    double ans = v[0];
    for(size_t i = 1; i < n; i++) {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int k = nextInt(), x = nextInt();
        System.out.println((500*k) >= x ? "Yes" : "No");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 23124
import os
import sys
from io import BytesIO, IOBase
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------------------

from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

# ------------------------------
# f = open('../input.txt')
# sys.stdin = f

def main():
    n = N()
    res = ""
    while n>0:
        n-=1
        res+=chr(ord('a')+n%26)
        n//=26
    print(res[::-1])


if __name__ == "__main__":
    main()



Measured memory_bytes: 66084
function Main(input){
	input = input.split("\n")[1].split(" ").map(a=>~~a);
  return Math.max(...input)-Math.min(...input);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
4
1 4 6 3
`);

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

//xÆ1ÌÂª¯¶ÅÉå«¢ðÔ·
inline int lex_next(int x) {
  int t = (x|(x-1)) + 1;
  return t | ((((t & -t) / (x & -x)) >> 1) - 1);
}

int main() {
    int v,e,k,l;
    while(cin>>v>>e, v|e) {
        vector<vector<int> > g(v, vector<int>(v,0));
        for(int i=0; i<e; ++i) {
            cin>>k>>l;
            g[k][l] = g[l][k] = 1;
        }

        bool cc[v];
        int ccc = 0;
        for(int num = 1; num <= v; ++num) {
            for(int set = (1<<num)-1; set < (1<<v); set = lex_next(set)) {
                memset(cc, false, sizeof(cc));
                ccc = 0;
                for(int i=0; i<v; ++i) {
                    if((set>>i) & 1) {
                        if(!cc[i]) {
                            ccc++;
                            cc[i] = true;
                        }
                        for(int j=0; j<v; ++j) if(g[i][j] && !cc[j]) {
                                ccc++;
                                cc[j] = true;
                            }
                    }
                }
                if(ccc == v) {
                    cout<<num<<endl;
                    goto NEXT;
                }
            }
        }
    NEXT:;
    }
}

Measured memory_bytes: 908
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int aa,bb,m,amin=mod,bmin=mod;
    cin>>aa>>bb>>m;
    vi a(aa);
    vi b(bb);
    FOR(i,0,aa){
        cin>>a[i];
        amin=min(amin,a[i]);
    }
    FOR(i,0,bb){
        cin>>b[i];
        bmin=min(bmin,b[i]);
    }
    int ans=amin+bmin;
    FOR(i,0,m){
        int x,y,c;
        cin>>x>>y>>c;
        int t=a[x-1]+b[y-1]-c;
        ans=min(ans,t);
    }
    cout<<ans<<endl;

}


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

N,L=map(int, input().split())

ans = 0
for i in range(N):
    ans = ans + L + i

if L > 0:
    ans = ans - L
if (L + N - 1) < 0:
    ans = ans - (L + N - 1)

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q=0;
    for(int i=1;i<n;i++){
        int ans=0;
        for(char c='a';c<='z';c++){
            bool a=false,b=false;
            for(int j=0;j<i;j++){
                if(s[j]==c)
                a=true;
            }
            for(int j=i;j<n;j++){
                if(s[j]==c)
                b=true;
            }
            if(a&&b)
            //cout<<a<<b<<endl;
            ans++;
        }
        q=max(ans,q);
        //cout<<q<<endl;
    }
    cout<<q<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
	int num;
	cin>>num;
	long long int x,y;
	cin>>x>>y;
	for(int i=1;i<num;i++){
		long long int a,b;
		cin>>a>>b;
		for(long long int j=max(x/a,y/b);;j++){
			if(a*j>=x&&b*j>=y){
				a*=j;
				b*=j;
				break;
			}
		}
		x=a;
		y=b;
	}
	cout<<x+y<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        String S = in.s();
        int r = 0;
        int g = 0;
        int b = 0;
        for (int i = 0; i < N; i++) {
            int c = S.charAt(i);
            if (c == 'R') {
                r++;
            } else if (c == 'G') {
                g++;
            } else {
                b++;
            }        
        }
        long ans = (long)r * g * b; 
        
        int iMax = (N - 1) / 2;
        for (int i = 1; i <= iMax; i++) {
            int jMax = N - 1 - 2 * i;
            for (int j = 0; j <= jMax; j++) {
                char c1 = S.charAt(j);
                char c2 = S.charAt(j + i);
                char c3 = S.charAt(j + i + i);
                if (c1 != c2 && c2 != c3 && c3 != c1) {
                    ans--;
                }
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 25976
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n,k;
    cin>>n>>k;
    vi a(n);
    int pos=-1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1) pos=i;
    }
    int ans=0x3f3f3f3f;
    for(int r=pos;r<n;r++)
    {
        int l=max(0,r-k+1);
        if(l>pos) break;
        ans=min(ans,1+(l+k-2)/(k-1)+(n-1-r+k-2)/(k-1));
    }
    print(ans);
}

Measured memory_bytes: 640
n = int(input())
s = input()
s = s + s[0]

inv = { "S": "W", "W": "S" }

for zero, one in [["S", "S"], ["S", "W"], ["W", "S"], ["W", "W"]]:
    animals = [zero, one]
    for i in range(2, n + 2):
        if animals[i - 1] == "S":
            if s[i - 1] == "o":
                animals.append(animals[i - 2])
            else:
                animals.append(inv[animals[i - 2]])
        else:
            if s[i - 1] == "o":
                animals.append(inv[animals[i - 2]])
            else:
                animals.append(animals[i - 2])
    if animals[0] == animals[n] and animals[1] == animals[n + 1]:
        print("".join(animals[0:n]))
        exit(0)

print(-1)


Measured memory_bytes: 4860
N = int(input())
X = [[None for i in range(3)] for j in range(N)]
for i in range(N):
    X[i][0] = i+1
    a = input().split()
    X[i][1] = a[0]
    X[i][2] = int(a[1])
X.sort(key=lambda x: (x[1], -x[2]))
for i in range(N):
    print(X[i][0])

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll MOD = 1e9+7;

ll N, K;
vll fact;
vll invfact;
vll inv;

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

ll inverse(ll n) {
    return binpow(n, MOD-2);
}

ll choose(ll n, ll k) {
    return fact[n] * invfact[k] % MOD * invfact[n-k] % MOD;
}

int main() {
	cin >> N >> K;
	fact.resize(N+1);
	invfact.resize(N+1);
	inv.resize(N+1);
	
    fact[0] = 1;
    FOR(i, 1, N+1) fact[i] = fact[i-1] * i % MOD;

    inv[1] = 1;
    FOR(i, 2, N+1) inv[i] = (MOD - (MOD/i) * inv[MOD%i] % MOD) % MOD;

    invfact[0] = 1;
    FOR(i, 1, N+1) invfact[i] = invfact[i-1] * inv[i] % MOD;

	ll ans = 0;
	for (int i = 0; i <= min(K, N - 1); ++i) {
		ans += choose(N, i) * choose(N - 1, N - i - 1) % MOD;
		ans %= MOD;
	}
	print(ans);
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  bool isOk = true;
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    if(A.at(i) % 2 == 0) {
      if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
        isOk = false;
      }
    }
  }
  if(isOk)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n,l;
    cin>>n>>l;
    ll apples[n];
    ll sum=0;
    ll near=100000;
    for(int i=0;i<n;++i){
        apples[i]=l+(i+1)-1;
        sum+=apples[i];
        near=min(near,abs(apples[i]));
    }

    if(sum<0){
        cout<<sum+near<<endl;
    }else{
        cout<<sum-near<<endl;
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
   int n,k,s;cin >>n>>k>>s;
   int now;
   if(s==1||s==2){
       now=3;
   }
   else {
       now=s-1;
   }
   vector<int>ans(n,now);
    for (int i = 0; i < k; ++i) {
        ans[i]=s;
    }
    for (int i = 0; i < n; ++i) {
        cout <<ans[i]<<" ";
    }
    cout <<endl;
}


Measured memory_bytes: 3772
N = int(input())
E = sorted([list(map(int, input().split())) + [i] for i in range(N-1)], key = lambda x:x[1])
E.sort()
ans = [0 for _ in range(N-1)]
flg = [0 for _ in range(N+1)]

t = 0
cnt = 0
ans_a = 0
for i in range(N-1):
	a,b,ind = E[i]
	if t != a:
		cnt = 1
		t = a
	if flg[a] == cnt:
		cnt += 1
	ans[ind] = cnt
	flg[b] = cnt
	ans_a = max(ans_a, cnt)
	cnt += 1



print(ans_a)
for a in ans:
	print(a)

Measured memory_bytes: 76248
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin>>n;
    vector<int>l(n);
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l.begin(),l.end());

    int cnt=0;
  for(int i=0;i<n-2;++i){
    int k=i+2;
    for(int j=i+1;j<n;++j){
        while(k<n&&l[i]+l[j]>l[k])++k;
        if(k>j)cnt+=k-j-1;
    }
  }
cout<<cnt;

    return 0;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100007];
int main()
{
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	/*for(i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;*/
	int s=1,ans=0;
	for(i=2;i<=n;i++)
		{	
			if(a[i]!=a[i-1])
			{
				
				if(s>a[i-1])
					ans+=s-a[i-1];
				if(s<a[i-1])
					ans+=s;
				s=1;
				//cout<<a[i]<<" "<<ans<<endl;
			}
			else 
				s++;
			//cout<<s<<" ";
		}
	if(s>a[n])
		ans+=s-a[n];
	if(s<a[n])
		ans+=s;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, a, N);
  print(*max_element(all(a)) - *min_element(all(a)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll cnt = 0;
    vector<ll> vc(n+1);
    vc[0] = 0;
    for (ll i = 1; i <= n; i++)
    {
        vc[i] = vc[i - 1] + i;
    }

    for (ll i = k-1; i <= n; i++)
    {
        ll k = n-i-1;
        if(k==-1) {
            k = 0;
        }
        ll max = vc[vc.size()-1]-vc[k];
        ll min = vc[i];
        cnt += (max - min + 1)%MOD;
        cnt %=MOD;
    }
    cout << cnt << endl;
}

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

using namespace std;

using ll=long long ;

const ll MOD = 1000000007;

void add(ll& r, const ll& x){
    (r += x) %= MOD;
}

int minpop(ll l, ll r){
    if (l == 0) return 0;
    l--;
    ll res = 0;
    for (int j = 60; j >= 0; j--) {
        ll k = 1ll << j;
        if ((l&k) ^ (r&k)) {
            res |= k; break;
        } else {
            res |= (l&k);
        }
    }
    return __builtin_popcountll(res);
}

void solve() {
    int n; ll K;
    cin >> n >> K;
    vector<ll> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    n = a.size();

    map<vector<ll>, vector<pair<ll,int>>> mp;
    for (int j = 0; j <= 60; j++) {
        vector<ll> c(n);
        ll k = 1ll << j;
        for (int i = 0; i < n; i++) {
            c[i] = a[i] & (k-1);
        }
        sort(c.begin(), c.end());
        c.erase(unique(c.begin(), c.end()), c.end());
        ll l = 0;
        for (ll r: c) {
            int mi = minpop(l, r);
            if (mi + j > K || r > a[0]) continue;
            vector<ll> b(n);
            for (int i = 0; i < n; i++) {
                b[i] = (a[i]-r) >> j;
            }
            vector<ll> pat;
            for (int i = 1; i < n; i++) {
                pat.emplace_back(b[i]-b[i-1]);
            }
            ll L = max(0ll, b[0] - (K-mi-j)), R = b[0];
            mp[pat].emplace_back(L, 0);
            mp[pat].emplace_back(R+1, 1);
            l = r+1;
        }
    }

    ll res = 0;
    for (auto& kv: mp) {
        auto& v = kv.second;
        if (v.empty()) continue;
        sort(v.begin(), v.end());
        ll l = v[0].first;
        int stk = 0;
        for (auto& p: v) {
            if (p.second) stk--;
            else {
                stk++;
                if (stk == 1) {
                    l = p.first;
                }
            }
            if (stk == 0) {
                add(res, p.first-l);
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 16512
dice = input().rstrip().split(' ')
indication = str(input())
indic = list(indication)
length = len(indic)
for i in range(length):
  newdice = [0] * 6
  if str(indic[i]) == "N":
    newdice[0] = dice[1]
    newdice[1] = dice[5]
    newdice[2] = dice[2]
    newdice[3] = dice[3]
    newdice[4] = dice[0]
    newdice[5] = dice[4]
    dice = newdice
  elif str(indic[i]) == "S":
    newdice[0] = dice[4]
    newdice[1] = dice[0]
    newdice[2] = dice[2]
    newdice[3] = dice[3]
    newdice[4] = dice[5]
    newdice[5] = dice[1]
    dice = newdice
  elif str(indic[i]) == "E":
    newdice[0] = dice[3]
    newdice[1] = dice[1]
    newdice[2] = dice[0]
    newdice[3] = dice[5]
    newdice[4] = dice[4]
    newdice[5] = dice[2]
    dice = newdice
  elif str(indic[i]) == "W":
    newdice[0] = dice[2]
    newdice[1] = dice[1]
    newdice[2] = dice[5]
    newdice[3] = dice[0]
    newdice[4] = dice[4]
    newdice[5] = dice[3]
    dice = newdice

print(int(dice[0]))


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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int div1(ll x){
  return x%1000000007;
}

ll broken(int x){
    if (x==-1) return 0;
    return x;
}

main(){
    int n=in(),m=in(),st[n+1];
    queue<int> a;
    for (int i=0;i<n+1;i++) st[i]=0;
    for (int i=0;i<m;i++) st[in()]=-1;
    st[0]=1;
    if (st[1]==0) st[1]=1;
    for (int i=2;i<n+1;i++){
        if (st[i]==-1) continue;
        st[i]=div1(broken(st[i-2])+broken(st[i-1]));
    }
    cout << st[n]<< endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

class SWAG(object):
    def __init__(self,dot):
        self.__front=[]; self.__back=[]; self.__dot=dot

    def __bool__(self):
        return bool(self.__front or self.__back)

    def __len__(self):
        return len(self.__front)+len(self.__back)

    def append(self,x):
        back=self.__back
        if(not back): back.append((x,x))
        else: back.append((x,self.__dot(back[-1][1],x)))

    def popleft(self):
        assert(self)
        front=self.__front; back=self.__back
        if(not front):
            front.append((back[-1][0],back[-1][0]))
            back.pop()
            while(back):
                front.append((back[-1][0],self.__dot(back[-1][0],front[-1][1])))
                back.pop()
        return front.pop()[0]

    def sum(self):
        assert(self)
        front=self.__front; back=self.__back
        if(not front): return back[-1][1]
        elif(not back): return front[-1][1]
        else: return self.__dot(front[-1][1],back[-1][1])

def resolve():
    # input
    n,m=map(int,input().split())
    S=list(map(int,input()))

    # dp
    swag=SWAG(min)
    dp=[None]*(n+1)
    dp[n]=0
    for i in range(n-1,-1,-1):
        swag.append(dp[i+1])
        dp[i]=swag.sum()+1 if(S[i]==0) else INF
        if(len(swag)==m): swag.popleft()

    # output
    if(dp[0]==INF):
        print("-1")
        return
    ans=[]
    now=next=0
    while(now<n):
        next+=1
        if(dp[now]>dp[next]):
            ans.append(next-now)
            now=next
    print(*ans)
resolve()

Measured memory_bytes: 74972
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

struct edge {
    int v;
    int w;
    int id;
    edge() {}
    edge(int v, int w, int id) : v(v), w(w), id(id) {};
};

vector<ll> dijkstra(int n, vector<vector<edge> >& G, int s) {
    vector<ll> d(n, 1ll<<55); d[s] = 0;
    priority_queue<pair<ll, int> > que;
    que.push(make_pair(0ll, s));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int u = p.second;
        ll dist = -p.first;
        if (dist > d[u]) continue;
        for (edge e : G[u]) {
            if (d[e.v] > d[u]+e.w) {
                d[e.v] = d[u] + e.w;
                que.push(make_pair(-d[e.v], e.v));
            }
        }
    }
    return d;
}

const int MAXM = 1111;
int A[MAXM], B[MAXM], C[MAXM];

bool used[MAXM];

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		--A[i]; --B[i];
		G[A[i]].emplace_back(B[i], C[i], i);
		G[B[i]].emplace_back(A[i], C[i], i);
	}
	for (int i = 0; i < N; i++) {
		auto d = dijkstra(N, G, i);
		for (int j = 0; j < M; j++) {
			if (d[A[j]] + C[j] == d[B[j]] || d[B[j]] + C[j] == d[A[j]]) used[j] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		ans += !used[i];
	}
	cout << ans << endl;
	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int a[MAXN], b[MAXN], c[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &a[i]);
	}
	REP(i, 0, n) {
		scanf("%d", &b[i]);
	}
	REP(i, 0, n) {
		scanf("%d", &c[i]);
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	ll ans = 0ll;
	for(int i = 0, j = 0, k = 0; j < n; j++) {
		for(; i < n && a[i] < b[j]; i++);
		for(; k < n && c[k] <= b[j]; k++);
		ans += (ll)i * (ll)(n - k);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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


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

    string s;

    cin >> s;

    int rain = 0;

    for(int i=0; i<3; i++)
    {
        if(s[i] == 'R')
        {
            rain++;
        }
    }

    if(rain == 3)
    {
        cout << 3;
    }

    else if(rain == 1)
    {
        cout << 1;
    }

    else if(rain == 2)
    {
        if(s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R')
        {
            cout << 2;
        }

        else
        {
            cout << 1;
        }
    }

    else if(rain == 0)
    {
        cout << 0;
    }
}









Measured memory_bytes: 3536
using System;
using System.Collections.Generic;

enum occupant
{
build, floor, room, number
}

class Program
 {


     
     static void Main(string[] args)
     {
         String nyuryoku;
         string[] data = new string[3];
         string[] data1;
         int mid,final,makeup,result;
         var student = new List<string>();

         while (true)
         {
             nyuryoku = Console.ReadLine();
             data = nyuryoku.Split(' ');
             mid = int.Parse(data[0]);
             final = int.Parse(data[1]);
             makeup = int.Parse(data[2]);
             if (mid == -1 & final == -1 & makeup == -1)
                 break;
             result = mid + final;
             if (mid < 0 | final < 0)
                 student.Add("F");
             else if (result >= 80)
                 student.Add("A");
             else if (result >= 65)
                 student.Add("B");
             else if (result >= 50)
                 student.Add("C");
             else if (result >= 30)
             {
                 if (makeup >= 50)
                     student.Add("C");
                 else
                     student.Add("D");
             }
             else
                 student.Add("F");
         }
         for (int i = 0; i < student.Count; i++)
             Console.WriteLine(student[i]);






      }
 }



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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n;
        cin >> n;
        string s, t;
        cin >> s >> t;
        int i = 0;
        while (i < 2 * s.length())
        {
            if (i & 1)
                cout << t[i / 2];
            else
                cout << s[i / 2];
            ++i;
        }
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3652
s = input()
ans = []
for i in range(len(s)):
    if s[i] == '0':
        ans.append('0')
    if s[i] == '1':
        ans.append('1')
    if s[i] == 'B':
        if len(ans) != 0:
            ans.pop(-1)
print(''.join(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
constexpr int IINF = numeric_limits<int>::max();
constexpr long LINF = numeric_limits<long>::max();
constexpr int MOD = (int) 1e9 + 7;
// constexpr int MOD = 998244353;

int main(){
    long x;
    cin >> x;
    long y = 100.0;
    long year = 0;
    while (true) {
        if (y >= x) {
            cout << year << "\n";
            return 0;
        }
        y = (double)y * 1.01;
        year++;
    }
}

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

typedef long long ll;
const ll INF=1e18;

int main(){
    ll a,b,q; cin >> a >> b >> q;
    vector<ll> s(a+2);
    vector<ll> t(b+2);
    s[0]=-1*INF;t[0]=-1*INF;
    s[a+1]=INF;t[b+1]=INF;
    for(int i=1;i<=a;i++) cin >> s[i];
    for(int i=1;i<=b;i++) cin >> t[i];
    while(q--){
        ll x; cin >> x;
        int iter1=lower_bound(s.begin(),s.end(),x)-s.begin();
        int iter2=lower_bound(t.begin(),t.end(),x)-t.begin();

        ll s1,s2,t1,t2;
        s1=s[iter1-1]; s2=s[iter1];
        t1=t[iter2-1]; t2=t[iter2];

        //cout << s1 << " " << s2 << " " << t1 << " " << t2 << endl;
        
        ll ans=INF;
        if(s1>t1){
            ans=min(ans,x-t1);
        }else{
            ans=min(ans,x-s1);
        }

        if(s2>t2){
            ans=min(ans,s2-x);
        }else{
            ans=min(ans,t2-x);
        }

        ans=min(x-s1+t2-s1,ans);
        ans=min(t2-x+t2-s1,ans);
        ans=min(s2-x+s2-t1,ans);
        ans=min(x-t1+s2-t1,ans);

        cout << ans << endl;

    }
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

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

Measured memory_bytes: 256
# E - Roadwork
from bisect import bisect_left
from operator import itemgetter


def main():
    N, Q, *STXD = map(int, open(0).read().split())
    STX, D = sorted(zip(*[iter(STXD[: 3 * N])] * 3), key=itemgetter(2)), STXD[3 * N :]
    ans = [-1] * Q
    road = [-1] * Q  # (road[i] = x) := if -1: open / else: closed until x
    for s, t, x in STX:
        l, r = bisect_left(D, s - x), bisect_left(D, t - x)
        while l < r:
            if road[l] == -1:
                ans[l] = x
                road[l] = r
                l += 1
            else:
                l = road[l]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 166876
def resolve():
    '''
    code here
    '''
    x, y = [int(item) for item in input().split()]
    res = 0

    if x < 0 and abs(y) - abs(x) >= 0:
        res += 1
    elif x > 0 and abs(y) - abs(x) <= 0:
        res += 1

    res += abs(abs(x) - abs(y))


    if y > 0 and abs(y) - abs(x) < 0:
        res += 1
    elif y < 0 and abs(y) - abs(x) > 0:
        res += 1

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if((i%3==0 || i%5==0) || (i%3==0 && i%5==0)){
            continue;
        } else
            sum+=i;

    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3632
a, b = map(int, input().split())

if int(a / 0.08 * 0.1) == b:
    print(round(a / 0.08 + 0.0001))
elif int(b / 0.1 * 0.08) == a:
    print(round(b / 0.1 + 0.0001))
else:
    print(-1)


Measured memory_bytes: 9092
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<set>
using namespace std;
using ll = long long;



int main(void){
	string a, b;
	cin >> a >> b;
	int c = stoi(a + b);
	int d = sqrt(c);
	
	if ((d*d) == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  ll result = 0;
  rep1(i, n){
    result += (n-1)/i;
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 3624
# edpc a

import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7

# ここから書き始める
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    cost_from_2 = dp[i - 2] + abs(h[i] - h[i - 2])
    cost_from_1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp[i] = min(cost_from_1, cost_from_2)
# print(dp)
print(dp[n - 1])


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

int main(){
  double ans;
  cin >> ans;
  cout << setprecision(10) << ans*6.283185307179586232 << endl;
}




Measured memory_bytes: 3736
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int count_two(LL v) {
  int count = 0;
  while (v % 2 == 0) {
    v /= 2;
    ++count;
  }
  return count;
}

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

LL lcm(LL a, LL b) {
  if ((a == 0) || (b == 0)) return 0;
  return ((a / gcd(a, b)) * b);
}

int main() {
  LL N, M; std::cin >> N >> M;
  std::vector<LL> a(N);
  for (int i = 0; i < N; ++i) std::cin >> a[i];

  int count1 = count_two(a[0]);
  for (int i = 1; i < N; ++i) {
    int count2 = count_two(a[i]);
    if (count1 != count2) {
      std::cout << 0 << std::endl;
      return 0;
    }
  }

  LL v = a[0]/2;
  for (int i = 1; i < N; ++i) {
    v = lcm(v, a[i]/2);
    if (v == 0) {
      std::cout << 0 << std::endl;
      return 0;
    }
  }

  std::cout << ((M/v) + 1LL)/2LL << std::endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
pair<int, int> imap[201];
vector<pair<int, int> >nmap;
int n, m;

bool comp(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

bool find(const int &nx, const int &ny) {
    int idx = upper_bound(nmap.begin(), nmap.end(), make_pair(nx, ny)) - nmap.begin()-1;
    return (nmap[idx].first == nx && nmap[idx].second == ny);
}

void solve() {
    int diffx, diffy, nx, ny, sx, sy;
    bool flag;
    diffx = imap[0].first - imap[1].first, diffy = imap[0].second - imap[1].second;
    int left = 0;
    //restore every differences between points
    pair<int, int> diffs[m];
    for (int i = 1; i < m-1; i++) {
        diffs[i] = {imap[i].first-imap[i+1].first, imap[i].second-imap[i+1].second};
    }
    for(; ;) {
        for (int i = left; i < n-1; i++) {
            nx = nmap[i].first-diffx, ny = nmap[i].second-diffy;
            if (find(nx, ny)) { left=i+1, sx = nx, sy = ny; break; }
        }
        flag = true;
        for (int i = 1; i < m-1; i++) {
            nx = sx-diffs[i].first, ny = sy-diffs[i].second;
            if (!find(nx, ny)) {
                flag = false;
                break;
            }
            sx = nx, sy = ny;
        }
        if (flag) { printf("%d %d\n", sx-imap[m-1].first, sy-imap[m-1].second); break; }
    }

}


int main() {
    int x, y;
    for (; ;) {
        scanf("%d", &m);
        if (m == 0) break;
        for (int i = 0; i < m; i++) {
            scanf("%d %d", &x, &y);
            imap[i] = {x, y};
        }
        sort(imap, imap+m, comp);
        scanf("%d", &n);
        nmap.reserve(n);
        for (int i = 0; i < n; i++) {
            scanf("%d %d", &x, &y);
            nmap.push_back({x, y});
        }
        sort(nmap.begin(), nmap.end(), comp);
        solve();
        nmap.clear();
    }
    return 0;
}



Measured memory_bytes: 2692
#include <cstdio>
#include <algorithm>

using namespace std;

#define chmin(a,b) a=min(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)

const int inf = 1e9;

int d[10][10];
bool found[10];
int N;

void wf()
{
	rep(k, 10) rep(i, 10) rep(j, 10) {
		chmin(d[i][j], d[i][k] + d[j][k]);
	}
}

int main()
{
	while (scanf("%d", &N), N) {
		fill_n(found, 10, false);
		fill(d[0], d[10], inf);
		rep(i, 10) d[i][i] = 0;

		rep(i, N) {
			int a, b, c; scanf("%d %d %d", &a, &b, &c);
			d[a][b] = d[b][a] = c;
			found[a] = found[b] = true;
		}

		wf();

		int mi = inf, a;

		rep(i, 10) if (found[i]) {
			int sum = 0;
			rep(j, 10) if (found[j]) {
				sum += d[i][j];
			}
			if (mi > sum) {
				mi = sum;
				a = i;
			}
		}

		printf("%d %d\n", a, mi);
	}
}

Measured memory_bytes: 1028
#include <stdio.h>

int main(void){
    int N;
    int counter = 0;
    scanf("%d", &N);
    int d[N];
    for (int i = 0; i < N; i++){
        scanf("%d", &d[i]);
    }
    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){
            counter += d[i] * d[j];
        }
    }
    printf("%d\n", counter);

    return 0;
}

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

ll flag(ll a){
  if(a>0)return 1;
  else return 0;
}

ll lcm(ll a, ll b){
  ll x,r,tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

int main(){
  ll A,B,C,D;
  cin >>A>>B>>C>>D;
  ll num_a = B/C-(A/C+flag(A%C))+1;
  ll num_b = B/D-(A/D+flag(A%D))+1;
  ll CD = lcm(C,D);
  ll num_ab = B/(CD)-(A/(CD)+flag(A%(CD)))+1;

  ll ans = B-A+1-(num_a+num_b-num_ab);
  //cout << num_a << num_b << num_ab << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){

  //入力
  int N, T, A;
  cin >> N >> T >> A;
  
  int H[N];
  float a[N];
  float min = 1000000000;
  for(int i = 0; i < N; i++){
    cin >> H[i];
    float sa = A - (T - H[i] * 0.006);
    //差がマイナスだったらマイナスをかける
    if(sa < 0){
      sa = -sa;
    }
    a[i] = sa;
    if(a[i] < min){
      min = a[i];
    }
  }
  
  int ans;
  for(ans = 0; ans < N; ans++){
    if(min == a[ans]){
      break;
    }
  }
  
  cout << ans + 1 << endl;

  return 0;
}


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

long long n,k;

int main()
{
	scanf("%lld%lld",&n,&k);
	
	if(n<k) {
		if (n<=k/2) printf("%lld\n",n);
		else printf("%lld",-(n-k));
	}else
	{
		if (n%k==0) printf("0\n");
		else if (n%k<=k/2) printf("%d",n%k);
		else printf("%lld\n",n-(n/k+1)*k<0? -(n-(n/k+1)*k):n-(n/k+1)*k);
	}
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(problem091a(a, b, c))
}

fun problem091a(a: Int, b: Int, c: Int): String {
    return if (a + b >= c) "Yes" else "No"
}

Measured memory_bytes: 31136
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int a, b;

	cin >> a >> b;
	int t;
	cin >> t;

	int ans = b * (int)((t + 0.5) / a);

	cout << ans << endl;
}

Measured memory_bytes: 256
def solve(next_idx, exp):
  if next_idx >= len(S):
    total = eval("".join(exp))
    return exp if total == 7 else ""

  return max(solve(next_idx+1, exp+"+"+S[next_idx]), solve(next_idx+1, exp+"-"+S[next_idx]))

S = input()
print(solve(1, S[0]) + "=7")


Measured memory_bytes: 3060