akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF 80000001000
int main() {
	int N; cin >> N;
	int a[110];
	for (int i = 0; i < N; i++)cin >> a[i];
	long long ans = INF;
	for (int i = -100; i <= 100; i++){
		long long sum = 0;
		for (int j = 0; j < N; j++)
			sum += (a[j] - i)*(a[j] - i);
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define si set<int>
#define sc set<char>

using namespace std;
int main()
{
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
int m,n,map[10][10];
int solve(int X,int Y,int L) {
	bool H=false;
	if(map[X][Y]==1) map[X][Y]=0,H=true;
	int R=0;
	for(int x=X-1;x>=0;x--) {
		if(map[x][Y]==1) {
			R+=solve(x,Y,L-1); break;
		}else if(map[x][Y]==2&&L==0) {
			if(H) map[X][Y]=1;
			return R+1;
		}
	}
	for(int x=X+1;x<m;x++) {
		if(map[x][Y]==1) {
			R+=solve(x,Y,L-1); break;
		}else if(map[x][Y]==2&&L==0) {
			if(H) map[X][Y]=1;
			return R+1;
		}
	}
	for(int y=Y-1;y>=0;y--) {
		if(map[X][y]==1) {
			R+=solve(X,y,L-1); break;
		}else if(map[X][y]==2&&L==0) {
			if(H) map[X][Y]=1;
			return R+1;
		}
	}
	for(int y=Y+1;y<n;y++) {
		if(map[X][y]==1) {
			R+=solve(X,y,L-1); break;
		}else if(map[X][y]==2&&L==0) {
			if(H) map[X][Y]=1;
			return R+1;
		}
	}
	if(H) map[X][Y]=1;
	return R;
}
int main() {
	while(scanf("%d %d",&m,&n),m|n) {
		int X,Y,H=0;
		for(int y=0;y<n;y++) for(int x=0;x<m;x++) {
			scanf("%d",&map[x][y]);
			if(map[x][y]==1) H++; else if(map[x][y]==2) X=x,Y=y;
		}
		printf("%d\n",solve(X,Y,H));
	}
}

Measured memory_bytes: 1028
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;
#define no_way 100000000;


int d[400][400];


int main(int argc, char **argv){
	int n;
	vector<int> v;
	int value;
	int total = 0;

	while (cin >> n && n != 0) {
		total = 0;
		v.clear();
		for (int i = 0; i < n; i++) {
			cin >> value;
			v.push_back(value);
		}
		sort(v.begin(), v.end());

		for (int i = 1; i < n - 1; i++) {
			total += v[i];
		}
		cout << total / (n - 2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#define N 10000
#define Q 500
main(){
  int s,t,c=0,i,j;
  int a[N],b[Q];

  scanf("%d",&s);
  for(i = 0; i < s; i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&t);
  for(i = 0; i < t; i++){
    scanf("%d",&b[i]);
  }

  for(i = 0; i < t; i++){
    for(j = 0; j < s; j++){
      if(b[i] == a[j]){
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);
  return 0;
}

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

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

    map<string, int> dict;
    for (size_t i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (dict.count(s) == 0) dict.insert(make_pair(s, 1));
        else ++dict[s];
    }

    int m = 0;
    for (auto i = dict.begin(); i != dict.end(); i++) m = max(m, i->second);

    for (auto i = dict.begin(); i != dict.end(); i++){
        if (i->second == m) cout << i->first << endl;
    }

    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
// constexpr ll mod = 1e9+7;
constexpr int mod = 2019;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  // cout << "N:" << N << endl;
  vector<int> cnt(2019, 0);
  int sum = 0;
  int beki = 1;
  ll ans = 0;
  REPR(i, N-1){
    sum = sum +(S[i]-'0')*beki;
    sum %= mod;
    beki *=10;
    beki %=mod;
    //ans += cnt[sum];
    cnt[sum]++;

    // cout << S.substr(i, N-i) << " " << sum << endl;
    if(sum == 0){
      ans++;
    }
  }
  REP(i,2019){
    ans += cnt[i]*(cnt[i]-1)/2;
  }
  cout << ans << endl;
  // cout << 18171 % mod << endl;
  // cout << 81712114LL % mod << endl;
  // cout << 1817181712114LL % mod << endl;
  // cout << 1817100000000LL % mod << endl;
  return 0;
}


Measured memory_bytes: 3716
n, m = map(int, input().split())
answer = [-1] * n
out = False
for i in range(m):
    s, c = map(int, input().split())
    if(s == 1 and c == 0 and n > 1):
        out = True
        break
    elif(answer[s-1] != -1 and answer[s-1] != c):
        out = True
        break
    answer[s-1] = c

if out:
    print(-1)
else:
    if(answer[0] == -1):
        if(n == 1):
            answer[0] = 0
        else:
            answer[0] = 1
    for i in range(1, len(answer)):
        if(answer[i] == -1):
            answer[i] = 0
    print("".join(str(e) for e in answer))


Measured memory_bytes: 3064
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */



constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

std::vector<mint> construct_comb(int n) {
	std::vector<mint> c(n+1);
	mint a = 1;
	c[0] = a;
	for(int i=1;i<=n;i++) {
		a = a*mint(n+1-i)/i;
		c[i] = a;
	}
	return c;
}

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	mint sum = 0;
	mint tmp = 0;
	rep(i,n-1) {
		tmp+=mint(1)/mint(i+1);
		sum+=tmp*mint(a[i+1]-a[i]);
	}
	for(int i=1;i<n;i++) sum*=mint(i);
	print(sum);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
int main()
{
    set<char>q;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        q.insert(s[i]);
    }
   // cout<<q.size()<<endl;
    if(q.size()==s.length())
    {
        if(q.size()%2==0)
        {
            cout<<"Second"<<endl;
        }
        else
        {
            cout<<"First"<<endl;
        }
    }
    else
    {
        if(s[0]==s[s.length()-1])
        {
            if(s.size()==3)
            {
                cout<<"Second"<<endl;
            }
            else if(s.size()%2==0)
            {
                cout<<"First"<<endl;
            }
            else
            {
                cout<<"Second"<<endl;
            }
        }
        else
        {
            if(s.size()%2==0)
            {
                cout<<"Second"<<endl;
            }
            else
            {
                 cout<<"First"<<endl;
            }
        }
    }
    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(string, s);

  for (auto& e : s) {
    if (e == '1') e = '9';
    else e = '1';
  }

  OUTL(s);
  return 0;
}


Measured memory_bytes: 256
def f(flg, an):
    accum = 0
    ret = 0
    for i, ai in enumerate(an):
        accum += ai
        if flg:
            flg = False
            if accum <= 0:
                ret += -accum + 1
                accum = 1
        else:
            flg = True
            if 0 <= accum:
                ret += accum + 1
                accum = -1
    return ret


def main():
    an = list(map(int, open(0).read().split()[1:]))
    print(min(f(False, an), f(True, an)))
    return


main()


Measured memory_bytes: 14084
S = input()
N = len(S)
X = [0] * N

flg = False
cntl, cntr = 0,0
idx = 0

def updateS(X,cntl,cntr):
  #print(cntl,cntr,idx)
  if (cntl + cntr) % 2 == 0:
    X[idx-1], X[idx] = (cntl + cntr) // 2 , (cntl + cntr) // 2
  elif cntr % 2 == 1:
    X[idx-1], X[idx] = (cntl + cntr) // 2 + 1, (cntl + cntr) // 2
  else:
    X[idx], X[idx-1] = (cntl + cntr) // 2 + 1, (cntl + cntr) // 2
  
for i in range(N):
  if S[i] == 'R':
    if i>0 and S[i-1] == 'L':
      updateS(X,cntl,cntr)
      cntl, cntr = 0,0
    flg = True
    cntr += 1
  else:
    if flg:
      idx = i
      flg = False
    cntl += 1
    
updateS(X,cntl,cntr)

print(" ".join(map(str,X)))

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

n = 10 ** 9
k = 2 * 10 ** 5
mod = 10**9 + 7

# x ** a をmodで割った余りを、O(log(a))時間で求める。
def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  # 分子
    denomi = 1  # 分母

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod


print(((((power(2, q) - binomial_coefficients(q, a)) % mod) - binomial_coefficients(q, b)) % mod - 1) % mod)



Measured memory_bytes: 3064
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <cmath>
#include <ctime>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <functional>
#include <random>
#include <numeric>
#include <tuple>
#include <bitset>
using namespace std;
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int, int> ii;
template<class T> string toString(T x) { ostringstream ss; ss << x; return ss.str(); }
void solve();
int main() {
#ifdef LOCAL_COMP
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
	solve();
#ifdef LOCAL_COMP
	cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const ll INF = ll(4e18);
const int MAXP = 16;

vector<ll> get(const vector<ll>& a) {
	const int n = sz(a);
	vector<vector<ll>> dp(n, vector<ll>(MAXP, INF));
	for (int p = 0; p < MAXP; p++) {
		dp[n - 1][p] = p * 2;
	}
	for (int i = n - 2; i >= 0; i--) {
		ll cur = a[i];
		for (int p = 0; p < MAXP; p++) {
			ll nxt = a[i + 1];
			for (int np = 0; np < MAXP; np++) {
				if (cur <= nxt) {
					dp[i][p] = min(dp[i][p], dp[i + 1][np] + p * 2);
				}
				nxt *= 4;
			}
			cur *= 4;
		}
		for (int p = 1; p < MAXP; p++) {
			for (int pp = 0; pp < p; pp++) {
				dp[i][p] = min(dp[i][p], dp[i][pp] + 2 * (p - pp) * (n - i));
			}
		}
	}
	vector<ll> ans(n, INF);
	for (int i = 0; i < n; i++) {
		for (int p = 0; p < MAXP; p++) {
			ans[i] = min(ans[i], dp[i][p]);
		}
	}
	return ans;
}

void solve() {
	int n;
	while (cin >> n) {
		vector<ll> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		vector<ll> suff = get(a);

		vector<ll> b(n);
		for (int i = 0; i < n; i++) {
			b[i] = a[n - i - 1] * 2;
		}
		vector<ll> pref = get(b);
		reverse(all(pref));

		ll ans = INF;
		for (int cntNeg = 0; cntNeg <= n; cntNeg++) {
			ll t;
			if (cntNeg == 0) {
				t = suff[0];
			} else if (cntNeg == n) {
				t = n + pref[n - 1];
			} else {
				t = cntNeg + pref[cntNeg - 1] + suff[cntNeg];
			}
			ans = min(ans, t);
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 39380
s = input()

l = len(s)
center = s[l // 2]
cnt = l % 2
for e1, e2 in zip(s[:l//2][::-1], s[l//2+l%2:]):
    if center == e1 == e2:
        cnt += 2
    else:
        break

ans = (l + cnt) // 2
print(ans)


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

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    int prev = getchar();
    int c;
    while ((c = getchar()) != EOF && !isspace(c)) {
        if (c == prev) {
            printf("Bad\n");
            return 0;
        }
        prev = c;
    }
    printf("Good\n");
    return 0;
}


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

public class Main{
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int[] arr = new int[n];
    public static void main(String[] args){
        for (int i=0; i<n; i++){
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);

        long ans = 0;

        for (int i=0; i<n; i++){
            for (int j=i+1; j<n; j++){
                int left = j;
                int right = arr.length;
                while (left<right){
                    int mid = (left+right)/2;
                    if (arr[mid]<arr[i]+arr[j]){
                        left = mid+1;
                    }else {
                        right = mid;
                    }
                }
                ans += (left-j-1);
            }
        }
        System.out.println(ans);
    }
    private static int lowerbound(int[] arr, int v){
        int left = 0;
        int right = arr.length;
        while (left<right){
            int mid = (left+right)/2;
            if (arr[mid]<v){
                left = mid+1;
            }else {
                right = mid;
            }
        }
        return left;
    }
}

Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string mp[h];
  for(int i=0;i<h;++i){
    cin>>mp[i];
  }
  string white;
  for(int i=0;i<mp[0].size();++i) white+='.';
  for(int i=0;i<h;++i){
    if(mp[i]==white){
      for(int j=0;j<mp[i].size();++j) mp[i][j]='@';
    }
  }
  for(int i=0;i<mp[0].size();++i){
    bool flag=true;
    for(int j=0;j<h;++j){
      if(mp[j][i]=='#') flag=false;
    }
    if(flag){
      for(int j=0;j<h;++j) mp[j][i]='@';
    }
  }
  for(int i=0;i<h;++i){
    int cnt=0;
    for(int j=0;j<mp[i].size();++j){
      if(mp[i][j]!='@'){ cout<<mp[i][j]; ++cnt; }
    }
    if(cnt) cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    if B % A == 0:
        print(A + B)
    else:
        print(B - A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10152
/* Don't quit suffer now and live the rest of your live as a champion */
#include <bits/stdc++.h>
#define int long long
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const long long MOD = 1e9 + 7;
signed main(){
    FAST
    int n;
    cin >> n;
    vector<int> sum(100);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 0; j < 100; j++){
            sum[j]+=(a - (j+ 1)) * (a - (j + 1));
        }
    }
    sort(sum.begin() , sum.end());
    cout << sum[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int a[100005];
int n,ans;
map<int,int> mp;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) mp[a[i]]++;
	for (int i=1;i<=n;i++)
		ans+=(mp[a[i]]>=a[i]?mp[a[i]]-a[i]:mp[a[i]]),mp[a[i]]=0;
	printf("%d",ans);
} 

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int k,x; cin >> k >> x;
	vi ans(k*2-1);
	rep(i,k*2-1){
		cout << x-k+1+i << " ";
	}
	cout << endl;
}




Measured memory_bytes: 256
card = []

for _ in range(3):
    card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
    n = int(input())
    if n in card:
        jadge[card.index(n)] = 1

bingo = False
for i in range(3):
    if (jadge[3 * i] + jadge[3 * i+1] + jadge[3 * i+2]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
        bingo = True
        break

if bingo:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main() {
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);

    int ans=0;

    for (int i=0; i<=N; i++) {
        int digit_sum=0;
        int temp_N = i;

        for (int digit=4; digit>=0; digit--) {
            if (temp_N / pow(10, digit) != 0) {
                digit_sum += (temp_N / (int)pow(10, digit));
                temp_N = (temp_N % (int)pow(10, digit)); 
            } 
        }

        if (A<=digit_sum && B>=digit_sum) {
            ans += i;
        }
    }

    printf("%d\n", ans); 
            
}



Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] sum = new long[n+1];
		for(int i = 0; i < n; i++){
		    long a = sc.nextLong();
		    sum[i+1] += sum[i] + a; 
		}
		
		// 計算
		long result = Long.MAX_VALUE;
		for(int i = 1; i < n; i++){
		    result = min(result, abs((sum[n] - sum[i]) - sum[i]));
		}
		
		// 出力
		System.out.println(result);
	}

}




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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		200050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int DP[MAX];
int prime[MAX];
bool is_prime[MAX+1];

int sieve(int n){
	int p=0;
	REP(i,n+1)is_prime[i]=true;
	is_prime[0] = is_prime[1] = false;
	REPS(i,2,n+1){
		if(is_prime[i]){
			prime[p++] = i;
			REPS(j,2*i,n+1)is_prime[j] = false;
		}
	}
}


//
int main(){
	int N;
	cin >> N;
	V a(N);
	REP(i,N)cin>>a[i];

	sieve(N);

	V ans;
	for(int i=N;i>0;--i){
		//cout << i << " " << DP[i] << " ";
		DP[i] = a[i-1]^DP[i];
		//cout << DP[i] << " " << a[i-1] << endl;
		if(DP[i]){
			ans.push_back(i);
			for(int j=1;j*j <= i; ++j)
				if(i % j == 0){
					DP[j] ^= DP[i];
					//printf("[%d : %d]",j,DP[j]);
					if(j!=1 && j!=(i/j)){DP[i/j] ^= DP[i];
					//printf("[%d : %d]",i/j,DP[i/j]);
					}
					//cout << endl;
				}
		}
	}

	cout << ans.size() << endl;
	if(ans.size()==0)return 0;
	REP(i,ans.size())cout << ans[ans.size()-i-1] << " ";
	cout << endl;

	return 0;
}




Measured memory_bytes: 3320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int mod = 1000000000 + 7;
        Scanner std = new Scanner(System.in);
        int h = std.nextInt();
        int w = std.nextInt();
        int[][] dp = new int[h][w];

        int[][] table = new int[h][w];
        for (int i = 0; i < h; i++) {
            String text = std.next();
            for (int j = 0; j < text.length(); j++) {
                int p = (text.charAt(j) == '.') ? 0 : -1;
                table[i][j] = p;
            }
        }

        dp[0][0] = 1;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (j != w - 1) {
                    if (table[i][j + 1] != -1) {
                        dp[i][j + 1] += dp[i][j];
                        dp[i][j + 1] %= mod;
                    }
                }

                if (i != h - 1) {
                    if (table[i + 1][j] != -1) {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }
            }
        }

        System.out.println(dp[h-1][w-1]);
    }
}


Measured memory_bytes: 37168
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s,t ;
	cin >> s >> t ;
	vvll pos(26,vll(0)) ;
	for(int i=0;i<s.size();i++) pos.at(s.at(i)-'a').emplace_back(i) ;
	ll pnt = -1 ;
	ll cnt = 0 ;
	for(int i=0;i<t.size();i++){
		if(pos.at(t.at(i)-'a').size()==0){
			cout << -1 << endl ;
			return 0 ;
		}else{
			auto itr = upper_bound(pos.at(t.at(i)-'a').begin(),pos.at(t.at(i)-'a').end(),pnt) ;
			if(itr==pos.at(t.at(i)-'a').end()){
				pnt = pos.at(t.at(i)-'a').at(0) ;
				cnt++ ;
			}else{
				pnt = *itr ;
			}
		}
	}
	cout << s.size()*cnt+pnt+1 << endl ;
}


Measured memory_bytes: 1724
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);		
		long n=in.nextLong();
		long ans=0;
		for(int i=(int)Math.sqrt(n);i>0;i--)
		{
			if(n%i==0)
			{
				ans=ans+i+n/i-2;
				break;
			}
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 21716
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a + b + c == 17 {
		if a == 5 && b == 5 {
			fmt.Println("YES")
		} else if b == 5 && c == 5 {
			fmt.Println("YES")
		} else if a == 5 && c == 5 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1832
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
int coaster[1005][1005]={0};
int main(){
  int c,n;
  cin>>c>>n;
  int ts=0,ans=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<n;j++) coaster[i][j]=(s[j]=='0'?0:1);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(coaster[i][j]!=coaster[i][(n-1)-j])  ts++;
      if(coaster[i][j]!=coaster[(n-1)-i][j])  ts++;
    }
  }
  ts/=2;
  if(ts==0) ans++;
  for(int q=1;q<c;q++){
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      int x,y;
      cin>>x>>y;
      x--;
      y--;
      coaster[x][y]=(coaster[x][y]+1)%2;
      if(coaster[x][y]==coaster[x][(n-1)-y]) {
        ts--;
      }
      else{
        ts++;
      }
      if(coaster[x][y]==coaster[(n-1)-x][y])  ts--;
      else ts++;
    }
    if(ts==0){
      ans++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 7128
#include <stdio.h>

int main(void)
{
	int N, K,num=1,i;
	scanf("%d %d",&N, &K);
	
	if(N>1){
		for(i=0;i<N-1;i++){
			num *=(K-1);
		}
	}
	printf("%d\n", K*num);

	return(0);
}

Measured memory_bytes: 128
<?php

fscanf(STDIN, "%d", $N);

for($i=1;$i<=$N;$i++){
    $int = $i;

    while($int % 2 === 0){
        if(!isset($ans[2])) {
            $ans[2] = 2;
        }else{
            $ans[2]++;
        }
        $int /= 2;
    }

    for($j=3;$j<=$N;$j+=2){
        if($j > $int){
            break;
        }
        while($int % $j === 0){
            if(!isset($ans[$j])) {
                $ans[$j] = 2;
            }else{
                $ans[$j]++;
            }
            $int /= $j;

        }
    }

}

arsort($ans);
$new_list = [75=>0, 25=>0, 15=>0, 5=>0, 3=>0];
$qans = 0;
foreach($ans as $value){
    if($value >= 75){
        $new_list[75]++;
    }
    if($value >= 25){
        $new_list[25]++;
    }
    if($value >= 15){
        $new_list[15]++;
    }
    if($value >= 5){
        $new_list[5]++;
    }
    if($value >= 3){
        $new_list[3]++;
    }
}

$qans += $new_list[75];
$qans += max(0, $new_list[25] * ($new_list[3] - 1));
$qans += max(0, $new_list[15] * ($new_list[5] - 1));
$qans += max(0, max(0,$new_list[5] * ($new_list[5]-1) / 2)  * max(0,$new_list[3] - 2));
echo $qans;

Measured memory_bytes: 16292
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	string s;
	cin>>n>>s;
	int r=0, w=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R') r++;
		else w++;
	}
	int cnt=0;
	for(int i=0;i<r;i++){
		if(s[i]=='W') cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 3732
#include<stdio.h>
#include<stdlib.h>

#define MAX 500001

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0; 

int main(){
  int n,i;
  int S[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
    }
  }

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[n-1]);
  printf("%d\n",count);

  return 0;
}

void merge(int *A,int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int i,j,k;
  int *L,*R;

  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));

  for(i=0;i<=n1-1;i++){
    L[i]=A[l+i];
  }

  for(j=0;j<=n2-1;j++){
    R[j]=A[m+j];
  }

  L[n1]=1000000000;
  R[n2]=1000000000;

  i=0;
  j=0;

  for(k=l;k<=r-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }else{
      A[k]=R[j];
      j=j+1;
    }

    count++;
  }

  free(L);
  free(R);
}

void mergeSort(int *A,int left,int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4480
//#define _CRT_SECURE_NO_WARNINGS

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

//#define F first
//#define S second

// TIMER
std::clock_t __start;
double __duration;
void start_timer() { __start = std::clock(); }
void print_timer() {
	__duration = (std::clock() - __start) / (double)CLOCKS_PER_SEC;
	std::cout << "Duration (msec): " << __duration * 1000 << '\n';
}
// END TIMER

//PI
# define M_PI		3.14159265358979323846
// fast input
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)

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

double EPS = 1e-16;
bool eq_(const double& lhs, const double &rhs) {
	return (fabs(lhs - rhs) < EPS);
}

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<llll> vllll;
typedef vector<int> vi;
typedef vector<ull> vull;


# define M_PI		3.14159265358979323846
const int INF = int(2e9);
const ll INF_LL = LLONG_MAX;
const ll MOD = 1e9 + 7;

vi apples;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, T;
	cin >> N >> T;
	apples.resize(N);
	int min_seen = INF;
	int num_min_seen = 0;
	int num_high_seen = 0;
	int best_profit = 0;
	int res = 0;
	int curr_res = 0;
	for (int i = 0; i < N; ++i) {
		cin >> apples[i];
		if (apples[i] - min_seen > best_profit) {
			best_profit = max(best_profit, apples[i] - min_seen);
			num_high_seen = 1;
			curr_res = 1;
			res = 0;
		}
		else if (apples[i] - min_seen == best_profit) {
			num_high_seen++;
			curr_res = min(num_min_seen, num_high_seen);
		}

		if (apples[i] < min_seen) {
			res += curr_res;
			curr_res = 0;
			num_high_seen = 0;
			min_seen = apples[i];
			num_min_seen = 1;
		}
		else if (apples[i] == min_seen)
			num_min_seen++;
	}
	cout <<res+curr_res << '\n';
	return 0;
}


Measured memory_bytes: 768
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  if(N < 1200){
    puts("ABC");
  }else if(N < 2800){
    puts("ARC");
  }else{
    puts("AGC");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int nmax = 300005;

int n,m,k,a[nmax],b[nmax],cnt1,cnt2,ans,prod;
vector<pair<int,int>>point;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n >> m >> k;
    for(int i=1;i<=k;i++){
        int x,y;
        cin >> x >> y;
        point.push_back({x,y});
        a[x]++;
        b[y]++;
    }
    int maxi1 = *max_element(a+1,a+n+1);
    int maxi2 = *max_element(b+1,b+m+1);
    for(int i=1;i<=n;i++) if(a[i] == maxi1) cnt1++;
    for(int i=1;i<=m;i++) if(b[i] == maxi2) cnt2++;
    ans = maxi1 + maxi2;
    prod = cnt1 * cnt2;
    for(auto it : point){
        if(a[it.fr] == maxi1 && b[it.sc] == maxi2){
            prod--;
        }
    }
    if(prod == 0){
        cout << ans - 1 << '\n';
    }
    else{
        cout << ans << '\n';
    }
}


Measured memory_bytes: 16332
#include <stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  while(a!=0||b!=0){
    if(a<=b){
      printf("%d %d\n",a,b);
	}
    else{
      printf("%d %d\n",b,a);
    }
  scanf("%d %d",&a,&b);
  }
  return 0;
    }
  

Measured memory_bytes: 1028
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    alice, bob = 0 , 0
    for i in range(n):
        if (i%2==0):
            alice += a[i]
        else:
            bob += a[i]
    print(alice-bob)
main()

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


int main() {
  string n_str ;
  cin >> n_str ;
  if ( n_str[0] == n_str[2] ) puts( "Yes" ) ;
  else                        puts( "No" ) ;

  return 0 ;
}



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

int main()
{
	int n;
	cin >> n;
	long long array[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> array[i];
	}
	if (n==1) cout << array[0];
	else
	{
		long long g = __gcd(array[0],array[1]);
		long long answer = ((array[0])/g)*array[1];
		// cout << g << " " << answer << endl;
		for (int i = 2; i < n; ++i)
		{
			g = __gcd(answer,array[i]);
			answer = ((answer)/g)*array[i];
			// cout << g << " " << answer << endl;
		}
		cout << answer;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
	vector<pair<pair<string,int>,int>> v(n);
	for(int i=0; i<n; ++i){
        cin >> v[i].first.first >> v[i].first.second;
        v[i].first.second *= -1;
        v[i].second=i+1;
    }
	sort(v.begin(),v.end());
    for(auto i : v) cout << i.second << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int N = Integer.parseInt(st.nextToken());
		int M = Integer.parseInt(st.nextToken());
		
		int cnt = 0;
		for(int i=1; i<N; i++) {
			for(int j=i+1; j<=N; j++)
				cnt++;
		}
		
		if(M > 1) {
			for(int i=1; i<M; i++) {
				for(int j=i+1; j<=M; j++)
					cnt++;
			}
		} else {
			cnt += 0;
		}
		
		System.out.println(cnt);
	}

}

Measured memory_bytes: 32720
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
typedef long long ll;

int main()
{	
	ll a,b,x;
	cin>>a>>b>>x;
	ll sa,sb;
	
	sa=(a-1)/x;
	sb=b/x;
	if(sa<0)
		sa=0;
	
	if(a==0)
		sb++;
	
	cout<<sb-sa<<endl;

	return 0;
}





Measured memory_bytes: 384
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef struct _restaurant 
{
  string s;
  int p;
  int index;
} restaurant;

bool comp(const restaurant& r1,const restaurant& r2)
{
  if(r1.s == r2.s)
    return r1.p > r2.p;
  else
  {
    return r1.s.compare(r2.s) < 0;
  }
}


// code
// ------------------------------------------------
int main() {

  int n;
  cin >> n;

  vector<restaurant> r(n);
  rep(i,n)
  {
    cin >> r[i].s >> r[i].p;
    r[i].index = i;
  }

  sort(all(r),comp);

  rep(i,n)
  {
    cout << r[i].index + 1 << endl;
    //cout << r[i].s << " " << r[i].p << endl;
  }

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

const int INF = 1001001001;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];
    vector<int> dp(n, INF);
    dp[0] = 0;
    rep(i, 0, n-1){
        rep(j, 1, k+1){
            if(i+j >= n) continue;
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	
  	if ( a + b > c + d ){
    	cout << "Left" << endl;
         }
  	if ( a + b < c + d){
    	cout << "Right" << endl;
    }
  	if ( a + b == c + d ) {
    	cout << "Balanced" << endl;
    }
}


Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 a, b, c;
    std::cin >> a >> b >> c;
    a = std::__gcd(a, b);
    c = std::__gcd(c, b);
    std::cout << (a<=c ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==f==r==-1:
        break
    elif (m==-1 or f==-1) or ((m+f)<30):
        print("F")
    elif (m+f)>=80:
        print("A")
    elif 65<=(m+f)<80:
        print("B")
    elif (50<=(m+f)<65) or ((30<=(m+f)<50) and r>=50):
        print("C")
    else:
        print("D")


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int r = in.nextInt();
        System.out.println("A" + (r < 1200 ? "B" : (r < 2800 ? "R" : "G")) + "C");
        in.close();
    }
}

Measured memory_bytes: 21716
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
st = [[xl[i][0] + xl[i][1], xl[i][0] - xl[i][1]] for i in range(n)]
st.sort()
ans = 1
t = st[0][0]
for i in range(1, n):
  if st[i][1] >= t:
    ans += 1
    t = st[i][0]
print(ans)

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    ll a;
    long double b;
    cin>>a>>b;
    ll tmp=b*100+0.1;
    ll ans=(a*tmp)/100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    int x;
    cin>>x;
    int t=0, i=1;
    while(1){
      t+=i;
      if(x==t){
        cout<<i<<endl;
        break;
      }
      else if(x<t){
        cout<<i<<endl;
        break;
      }
      i++;
    }
    return 0;
}


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

using namespace std;
/*
float abs(float x) {
    if(x < 0) return -1*x;
    else{return x;}
}*/

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    int H;
    int ind = 0; double min = 10000000;
    for(int i = 0; i < N; ++i) {
        cin >> H;
        double temp = (float(T)-float(H)*0.006);
        if(abs(double(A)-temp) < min) {
            ind = i+1;
            min = abs(double(A)-temp);
            //cout << i << " " << min << endl;
        }
    }
    cout << ind;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 1e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;
const int DIM=51;

void add_mod(ll &x,ll y){
	x+=y;
	if(x>=MOD){
		x-=MOD;
	}
}
void matrix_mult(ll a[DIM][DIM],ll b[DIM][DIM],ll c[DIM][DIM],int n){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll x=0;
			for(int k=0;k<n;k++){
				ll y=b[i][k]*c[k][j];y%=MOD;
				add_mod(x,y);
			}
			a[i][j]=x;
		}
	}
}

void assign(ll a[DIM][DIM],ll b[DIM][DIM],int n){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			a[i][j]=b[i][j];
		}
	}
}

void solve(){
    int n;ll k;
    cin>>n>>k;
    ll a[DIM][DIM]={};
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		cin>>a[i][j];
    	}
    }
    ll dp[n]; //dp[i]=number of ways to get to i.
    for(int i=0;i<n;i++){
    	dp[i]=1;
    }

    ll a_k[DIM][DIM]={};
    for(int i=0;i<n;i++){
    	a_k[i][i]=1;
    }
    ll temp[DIM][DIM];
    while(k>0){
    	if(k%2){
    		matrix_mult(temp,a_k,a,n);
    		assign(a_k,temp,n);
    		k--;
    	}
    	matrix_mult(temp,a,a,n);
    	assign(a,temp,n);
    	k/=2;
    }


    ll ans=0;
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		ans+=a_k[i][j]*dp[j];
    		ans%=MOD;
    	}
    }
    cout<<ans%MOD<<nl;
}

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

Measured memory_bytes: 384