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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << "\n";

    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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(){
    int n,t;
    cin >> n >> t;
    vector<P> N(n);
    P ans;
    ans.first=0;
    ans.second=9999;
    rep(i,n)
        cin >> N[i].second >> N[i].first ;
    sort(N.begin(),N.end());
    rep(i,n){
        if(N[i].first <= t && N[i].second < ans.second){
            ans.first=N[i].first;
            ans.second=N[i].second;
        }
    }
    if(ans.first==0)
        cout << "TLE";
    else
        cout << ans.second << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split(" ")))
A = [[0 for _ in range(m)] for _ in range(n)]
b = [0 for _ in range(m)]

for i in range(n):
    A_line = list(map(int, input().split(" ")))
    for j, a in enumerate(A_line):
        A[i][j] += a
        
for j in range(m):
    b[j] = int(input())
    
for i in range(n):
    ans = 0
    for j in range(m):
        ans += A[i][j] * b[j]
    print (ans)

Measured memory_bytes: 7912
#include <stdio.h>

int main(void){
	int n, i, j, k;
	int game[200][3];
	int score[200]={0};
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		for(j=0; j<3; j++){
			scanf(" %d", &game[i][j]);
		}
	}
	
	for(k=0; k<3; k++){
		for(i=0; i<n; i++){
			int flag=0;
			for(j=0; j<n; j++){
				if(i==j) continue;
			
				if(game[i][k] == game[j][k]) {
					flag=1;
					break;
				}
			}
			
			if(flag==0) score[i]+=game[i][k];
		}
	}
	
	for(i=0; i<n; i++)
		printf("%d\n", score[i]);

	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include <math.h>
int prime(int n)
{
    int i;
    for(i = 2; i <= sqrt(n); i ++)
    {
        if(n%i==0) return 0;
    }
    return 1;
}
int main()
{
    int m;
    scanf("%d",&m);
    while(!prime(m++));
    printf("%d\n", m-1);
}

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

const int MAX_N = 20;

char maze[MAX_N][MAX_N];
int h,w;

int d[MAX_N][MAX_N];

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

int bfs(int sx, int sy){
    int max_v = 0;
    queue<P> que;

    rep(i,h){
        rep(j,w){
            d[i][j] = -1;
        }
    }
    que.push(P(sx,sy));
    d[sx][sy] = 0;

    while(!que.empty()){
        P p = que.front();
        que.pop();

        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(nx >= 0 && nx < h && ny >= 0 && ny < w && maze[nx][ny] != '#' && d[nx][ny] == -1){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            max_v = max(max_v,d[i][j]);
        }
    }
    return max_v;
}

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

    cin >> h >> w;


    rep(i,h){
        rep(j,w) cin >> maze[i][j];
    }

    int res = 0;
    rep(i,h){
        rep(j,w){
            if(maze[i][j] != '#'){
                res = max(res,bfs(i,j));
            }
        }
    }
    cout << res << endl;
}




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

int sq[30][30];
int a,b,n;
int ans=0;

void bfs(int x,int y){
 
  int dx[2]={0,1};
  int dy[2]={1,0};

  for(int i=0;i<2;i++){
    int nx,ny;
    nx=x-dx[i];
    ny=y+dy[i];
    if(nx==0&&ny==a-1){
      ans++;
      return;
    }
    if(0<=nx&&nx<b&&0<=ny&&ny<a&&sq[nx][ny]!=1) bfs(nx,ny);
  }
  return;
}

int main(){
  while(1){
    cin>>a>>b;
    if(a+b==0) break;  

    for(int i=0;i<=25;i++){
      for(int j=0;j<=25;j++) sq[i][j]=0;
    }
    cin>>n;
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      sq[b-y][x-1]=1;
      // cout<<b-y<<" "<<x-1<<endl;
    }
  
    bfs(b-1,0);

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

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;

int n;
int a[N];
int pref[N];

main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    pref[i] = abs(a[i] - a[i - 1]) + pref[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    int add = 0;
    if (i == n) {
      add = abs(a[i - 1]);
      printf("%d\n", pref[n - 1] + abs(a[n - 1]));
      return 0;
    } else {
      add = abs(a[n]);
    }
    printf("%d\n", pref[n] - (pref[i + 1] - pref[i - 1]) + (abs(a[i + 1] - a[i - 1])) + add);
  }
}


Measured memory_bytes: 2048
#=
D:
- Julia version: 
- Author: abap
- Date: 2019-12-29
=#
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N,K = parseMap(split(readline()))
R,S,P = parseMap(split(readline()))
t = readline()
T =[]
for j in t
	push!(T,j)
end
score = 0
for i in 1:N
	if i <= K
		if T[i] == 'r'
			score += P
			#print('p')
		elseif T[i] == 's'
			score += R
			#print('r')
		elseif T[i] == 'p'
			score += S
			#print('s')
		end
	else
		if T[i] == 'r' && T[i-K] != 'r'
			score += P
			#print('p')
		elseif T[i] == 's' && T[i-K] != 's'
			score += R
			#print('r')
		elseif T[i] == 'p' && T[i-K] != 'p'
			score += S
			#print('s')
		else
			T[i] = "*"
		end
	end
end
#println("")
#println("---")
println(score)

Measured memory_bytes: 169176
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>


using namespace std;

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

 #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());
    auto comPair = [](const P &firstElof, const P &secondElof) {
        int m1 = min(firstElof.first, firstElof.second);
        int m2 = min(secondElof.first, secondElof.second);
        return m1 < m2;
    };
    priority_queue<P, vector<P>, decltype(comPair)> que(comPair);

    ll ans = a[0];
    que.emplace(a[0], a[1]);
    que.emplace(a[0], a[1]);
    repeat(i, 2, n) {
        auto p = que.top();
        que.pop();

        ans += min(p.first, p.second);

        que.emplace(p.first, a[i]);
        que.emplace(p.second, a[i]);
    }
    out(ans);
    return 0;
}

Measured memory_bytes: 6076
#include <iostream>

using namespace std;

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i=0;i<ty-sy;i++){
        cout << "U";
    }
    for(int i=0;i<tx-sx;i++){
        cout << "R";
    }
    for(int i=0;i<ty-sy;i++){
        cout << "D";
    }
    for(int i=0;i<tx-sx;i++){
        cout << "L";
    }
    cout << "L";
    for(int i=0;i<ty-sy;i++){
        cout << "U";
    }
    cout << "U";
    for(int i=0;i<tx-sx;i++){
        cout << "R";
    }
    cout << "R";
    cout << "D";
    cout << "R";
    for(int i=0;i<ty-sy;i++){
        cout << "D";
    }
    cout << "D";
    for(int i=0;i<tx-sx;i++){
        cout << "L";
    }
    cout << "L";
    cout << "U";
    cout << "\n";
    return 0;

}

Measured memory_bytes: 256
def isPrime(n):
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1

ans = 0
n = int(input())
for i in range(n):
    x = int(input())
    ans = ans + isPrime(x)

print(ans)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin()
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ve<ll> a(n),b(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)
        cin>>b[i];
    ll p=0,q=0;
    while(p<n)
    {
        if(a[p]==b[p])
        {
            ll co=0;
            while(co<n && (a[q]==a[p] || b[q]==a[p]))
            {
                co++;
                q=(q+1)%n;
            }
            if(co==n)
            {
                cout<<"No";
                return 0;  
            }
            swap(b[p],b[q]);
        }
        p++;
    }
    cout<<"Yes\n";
    for(auto i:b)
        cout<<i<<' ';
    subt;
    return 0;
}

Measured memory_bytes: 6364
#include<bits/stdc++.h>
typedef long long ll;
const int p=1e9+7;
int c[200010],w[200010],n,x,y;
int b[200010],f[200010],a,d;
int anc(int x){return f[x]?f[x]=anc(f[x]):x;}
void merge(int x,int y){if(anc(x)!=anc(y))f[anc(x)]=anc(y);}
int to[200010],nxt[200010],fst[200010],tot;
void add(int u,int v){to[++tot]=v,nxt[tot]=fst[u],fst[u]=tot;}
int inv[200010],r[200010],ans=1;
int main()
{
    scanf("%d%d%d",&n,&x,&y),w[0]=1e9;
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&c[i],&w[i]);
        if(w[b[c[i]]]>w[i])b[c[i]]=i;
        if(w[a]>w[i])a=i;
    }
    for(int i=1;i<=n;++i)
    {
        if(w[i]+w[b[c[i]]]<=x)merge(i,b[c[i]]);
        if(c[i]!=c[a]&&w[i]+w[a]<=y)merge(i,a);
        if(c[i]!=c[a]&&w[d]>w[i])d=i;
    }
    for(int i=1;i<=n;++i)
        if(c[i]==c[a]&&w[i]+w[d]<=y)merge(i,d);
    for(int i=1;i<=n;++i)add(anc(i),c[i]);
    inv[1]=1;
    for(int i=2;i<=n;++i)
        inv[i]=-(ll)p/i*inv[p%i]%p+p;
    for(int i=1;i<=n;++i)
    {
        for(int e=fst[i];e;e=nxt[e])
        {
            ans=(ll)ans*++r[0]%p;
            ans=(ll)ans*inv[++r[to[e]]]%p;
        }
        for(int e=fst[i];e;e=nxt[e])--r[0],--r[to[e]];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>

using namespace std;
int main()
{
    long long n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++)
    {
        cout<<s<<" ";
    }
    for(int i=k;i<n;i++)
    {
        if(s>2)
        cout<<s-1<<" ";
        else cout<<s+1<<" ";
    }
    return 0;
}


Measured memory_bytes: 1280
fun c93(args: Array<String>) {
    val numList = args[0].split(" ").map { it.toInt() }.sorted()

    val ans = when {
        numList.all { it % 2 == 0 } || numList.all { it % 2 == 1 } ->
            (numList[2] - numList[0]) / 2 + (numList[2] - numList[1]) / 2
        numList.filter { it % 2 == 0 }.count() == 1 -> {
            val incrementedNumList = numList.map { if (it % 2 == 0) it else it + 1 }
            1 + (incrementedNumList[2] - incrementedNumList[0]) / 2 + (incrementedNumList[2] - incrementedNumList[1]) / 2
        }
        else -> {
            val incrementedNumList = numList.map { if (it % 2 == 1) it else it + 1 }
            1 + (incrementedNumList[2] - incrementedNumList[0]) / 2 + (incrementedNumList[2] - incrementedNumList[1]) / 2
        }
    }

    println(ans)
}

fun main(args: Array<String>) {
    c93(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 38304
input_num = gets.chomp.split.map(&:to_i)
input_script = gets.chomp.to_s
puts input_script[0 ,input_num[1] - 1] + input_script[input_num[1] - 1].downcase! + input_script[input_num[1] ,input_num[0] - input_num[1] ]


Measured memory_bytes: 1788
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def div4(x): #素因数分解配列 dict格納型
    div=defaultdict(int)
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div[check]+=1
            x/=check
        check+=1
    if x != 1:
      div[x]+=1
    return div

def nCk(n,k):
    res = 1
    a=n-k
    b=k
    for i in range(1,a+b+1):
        res = res*i%mod
    for i in range(1,a+1):
        res = res*mod_inv(i,mod)%mod
    for i in range(1,b+1):                                 
        res = res*mod_inv(i,mod)%mod
    return res

def main():
    x,y,z,K = inpm()
    a = inpl()
    b = inpl()
    c = inpl()
    a.sort(reverse=True)
    b.sort(reverse=True)
    c.sort(reverse=True)
    que = []
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if (i+1)*(j+1)*(k+1)>K:
                    break
                else:
                    que.append(a[i]+b[j]+c[k])
    que.sort(reverse=True)
    for i in range(K):
        print(que[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 49432
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

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

    if(abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rrep(i, n) {
        ans *= i;
        ans %= MOD;
    }
    rrep(i, m) {
        ans *= i;
        ans %= MOD;
    }
    if(n == m) {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int N;
  vector<int> L;

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

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

  int count = 0;

  for (int i = 0; i < L.size(); i++) {
    for (int k = i + 1; k < L.size(); k++) {
      if (L[i] == L[k]) continue;
      for (int n = k + 1; n < L.size(); n++) {
        if (L[k] == L[n]) continue;
        if (L[i] + L[k] > L[n]) {
          count++;
        }
        else {
          break;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	StringBuilder ans=new StringBuilder();
	
	for(int i=0;i!=a.length();i++) {
		if(i%2==0) {
			ans.append(a.charAt(i));
		}
	}
	System.out.println(ans);
	scan.close();
}
}

Measured memory_bytes: 25980
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    cout << A[0] + A[1] << endl;
}


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

void fnInput(int &rnTrkSiz, vector<int> &rvnLod)
{
  int nLodSiz;
  cin >> nLodSiz >> rnTrkSiz;

  rvnLod.resize(nLodSiz);
  for (int i = 0; i < nLodSiz; i++)
    cin >> rvnLod[i];
}

int fnSimuAlloc(const vector<int> &cnrvnLod, int nTrkSiz, int nLimLod)
{
  int nCurLod;
  int nCntTrk = 0;

  for (int i = 0; i < cnrvnLod.size();    )
  {
    if (cnrvnLod[i] > nLimLod)  return 0;

    nCntTrk++;
    nCurLod = 0;
    while (i < cnrvnLod.size())
    {
      nCurLod += cnrvnLod[i];
      if (nCurLod > nLimLod)  break;

      i++;
    }
  }
  return (nCntTrk <= nTrkSiz);
}

void fnAlloc(const vector<int> &cnrvnLod, int nTrkSiz, int &rnMinLod)
{
  const int cnnMinLod = 0;
  const int cnnMaxLod = 1000000000;

  int nLow  = cnnMinLod;
  int nHigh = cnnMaxLod;
  rnMinLod = cnnMaxLod;

  while (nLow < nHigh)
  {
    int nLimLod = (nLow + nHigh) / 2;
    if (fnSimuAlloc(cnrvnLod, nTrkSiz, nLimLod))
    {
      rnMinLod = min(rnMinLod, nLimLod);
      nHigh = nLimLod;
    }
    else
      nLow = nLimLod + 1;
  }
}

void fnReSult(int nMinLod)
{
  cout << nMinLod << endl;
}

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

  int nTrkSiz;
  vector<int> vnLod;
  int nMinLod = 0;

  fnInput(nTrkSiz, vnLod);
  fnAlloc(vnLod, nTrkSiz, nMinLod);
  fnReSult(nMinLod);

  return 0;
}

Measured memory_bytes: 1524
#include <cstdio>

int main() {
	char map[2][3] = {0};

	for (int i = 0; i < 2; i++)
		scanf("%s", map[i]);

	char rmap[2][3] = {0};
	for (int i = 0, k = 1; i < 2; i++, k--)
		for (int j = 0, l = 2; j < 3;j++, l--)
			rmap[i][j] = map[k][l];

	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 3; j++)
			if (map[i][j] != rmap[i][j]) {
				printf("NO\n");
				return 0;
			}

	printf("YES\n");
}


Measured memory_bytes: 128
mod = 10 ** 9 + 7

def mod_combination(n, k, mod = 10 ** 9 + 7):
    def extended_gcd(a, b):
        if b == 0:
            return (a, 1, 0)
        d, x, y = extended_gcd(b, a % b)
        return (d, y, x - (a // b) * y)
    p, q = 1, 1
    for i in range(n - k + 1, n + 1):
        p = (p * i) % mod
    for i in range(2, k + 1):
        q = (q * i) % mod
    return p * (extended_gcd(q, mod)[1] % mod) % mod

n, a, b = map(int, input().split())

ans = pow(2, n, mod) - 1 - mod_combination(n, a) - mod_combination(n, b)

print(ans % mod)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main()
{
	long long int a, b, c, ans;
	cin >> a >> b >> c;
	ans = b / c - a / c;
	if (a%c == 0)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define N 110
int inm(int x,int y)
{
	if(x<y)
		return x;
	return y;
}
int main()
{
	int n,p[N+1],m[N+1][N+1];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i-1],&p[i]);
	for(int i=1;i<=n;i++)
		m[i][i]=0;
	for(int l=2;l<=n;l++)
		for(int i=1;i<=n-l+1;i++)
		{
			int j=i+l-1;
			m[i][j]=(1<<21);
			for(int k=i;k<=j-1;k++)
				m[i][j]=inm(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
		}
	printf("%d\n",m[1][n]);
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(s.find("ABC") == string::npos) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  while (1)
  {
    int start = s.find("ABC");
    int end = s.size();
    if(start == string::npos) break;
    s = s.substr(start+3, end);
    ans++;
  }
  cout << ans << endl;
  
  return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);
    int P, Q, R;
    cin >> P >> Q >> R;
    int min = 1000;
    if (min > P + Q) min = P + Q;
    if (min > P + R) min = P + R;
    if (min > R + Q) min = R + Q;

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long multi_atob(long long a, long long b) {
	long long ans = 1;
	for (long long i = b; i <= a; i++)
	{
		ans *= i;
		ans %= mod;
	}
	return ans;
}
int main() {
	int N,P,one=0,zero=0;
	cin >> N >> P;
	vector<long long> A(N),p(N+1);

	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
		A.at(i) %= 2;
		if (A.at(i))one++;
		else zero++;
	}
	long long ans = (P+1)%2;
	if(one!=0)ans = pow(2, one-1);
	ans *= pow(2, zero);
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll a; string b;
    cin>>a>>b;
    ll b_=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0')*1;
    ll ans=a*b_/100;
    cout<<ans<<'\n';
    return 0;
}


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

int fairfield(int y, int m, int d) {
	if (m < 3) {
		--y;
		m += 12;
	}
	return 365 * y + (y / 4) - (y / 100) + (y / 400) + (306 * (m + 1) / 10) + d - 428;
}

int main () {
	int y1, m1, d1, y2, m2, d2;
	while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 > 0) {
		cout << fairfield(y2, m2, d2) - fairfield(y1, m1, d1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main(){
	int W[10],K[10];
	for(int i=0;i<10;i++){
		std::cin>>W[i];
	}
	for(int i=0;i<10;i++){
		std::cin>>K[i];
	}
	std::sort(W,W+10);
	std::sort(K,K+10);
	std::cout<<W[9]+W[8]+W[7]<<" "<<K[9]+K[8]+K[7]<<std::endl;
}

Measured memory_bytes: 3004
#include <stdio.h>

void func1(int n);

int main(void) {
  int n;
  scanf("%d", &n);
  while(n >= 10) {
    if(n < 100) {
      n %= 10;
    } else if(n < 1000) {
      n %= 100;
    }
  }
  func1(n);
  return 0;
}

void func1(int n) {
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    printf("hon");
  } else if(n == 0 || n == 1 || n == 6 || n == 8) {
    printf("pon");
  } else {
    printf("bon");
  }
}


Measured memory_bytes: 1700
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  unordered_map<int, int> mp;
  int tmp;
  REP(i,a){
    cin >> tmp;
    mp[tmp]++;
  }
  int ans = 0;
  for(auto itr = mp.begin();itr!=mp.end();++itr){
    ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

sl = len(s)
tl = len(t)

if sl < tl:
    print('UNRESTORABLE')
else:
    for i in range(sl-tl+1)[::-1]:
        flag = True
        for j in range(tl):
            if s[i+j] != '?' and s[i+j] != t[j]:
                flag = False
                break
        if flag:
            for j in range(sl):
                if i <= j < i + tl:
                    s[j] = t[j-i]
                    continue
                if s[j] == '?':
                    s[j] = 'a'
                    continue
            print(''.join(s))
            break
    if not flag:print('UNRESTORABLE')


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; i++){
        cin >> d.at(i);
    }
    
    map <int, int> cnt;
    int ans = 0;
    
    for (int x : d){
        if (!cnt.count(x)){
            cnt[x] = 1;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f;
	string s;
	cin>>n;
	cin>>s;
	ll r=0;
	for(i=0;i<n;i++)if(s[i]=='R')r++;
	j=n-1;
	if(r==0||r==n){cout<<0;exit(0);}
	ll cnt=0;
	for(i=0;(i<n)&&(r>0);i++)
	{
	    if(s[i]=='W'){
	        f=1;
	        for(;j>i;j--)
	        {
	            if(s[j]=='R')
	            {
	                swap(s[i],s[j]);
	                cnt++;
	                r--;f=0;
	                break;
	            }
	        }
	    }
	    else r--;
	}
	cout<<cnt;
	return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> db, de;
vector<vector<ll>> G;

void dfsb(ll id, ll now) {
    db[id] = now;
    for(int i=0;i<G[id].size();i++) {
        if(now+1<db[G[id][i]]) {
            dfsb(G[id][i], now+1);
        }
    }
}

void dfse(ll id, ll now) {
    de[id] = now;
    for(int i=0;i<G[id].size();i++) {
        if(now+1<de[G[id][i]]) {
            dfse(G[id][i], now+1);
        }
    }
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    db.resize(N, INF);
    de.resize(N, INF);
    dfsb(0, 0);
    dfse(N-1, 0);
    for(int i=0;i<N;i++) {
        if(db[i]>de[i]) tmp++;
    }
    //cout << N-tmp << " " << tmp << endl;
    if(N-tmp>tmp) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 14760
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

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

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

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

    string s;
    cin >> s;
    int n = (int) s.size();
    vector<int> ans(n, 1);
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] == 'R' && s[i + 1] == 'R') {
            ans[i + 2] += ans[i];
            ans[i] = 0;
        }
    }
    for (int i = n - 1; i - 1 >= 0; --i) {
        if (s[i] == 'L' && s[i - 1] == 'L') {
            ans[i - 2] += ans[i];
            ans[i] = 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 1104
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, j, k, n, a[9], min, max, buf;
	char num[9];

	scanf("%d", &n);

	for(i=0; i<n; i++){

		scanf("%s", num);

		for(j=0; j<8; j++){
			for(k=0; k<10; k++){
				if(num[j] == '0' + k)
					a[j] = k;
			}
		}

		for(j=0; j<8; j++){
			for(k=6; k>=j; k--){
				if(a[k] < a[k+1]){
					buf = a[k];
					a[k] = a[k+1];
					a[k+1] = buf;
				}
			}
		}

		max=0;
		for(j=0; j<8; j++){
			max += a[j] * (int)pow(10, 7-j);
		}

		for(j=0; j<8; j++){
			for(k=6; k>=j; k--){
				if(a[k] > a[k+1]){
					buf = a[k];
					a[k] = a[k+1];
					a[k+1] = buf;
				}
			}
		}

		min=0;
		for(j=0; j<8; j++){
			min += a[j] * (int)pow(10, 7-j);
		}

		printf("%d\n", max - min);

	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll X, Y;
  cin >> X >> Y;
  ll cnt = 1;
  while(1){
    if(X*2<=Y){
      X *= 2;
      cnt++;
    }
    else break;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

const int INF = 1e9;

int n,i,j;
pair <int, int> a[100005];
long long ans[100005];

struct dat{
	int val,cnt,id;
};

vector <dat> b;

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	
	for(i = 0; i < n; i++){
		if(b.empty() || b.back().val != a[i].first)
		b.push_back({a[i].first, 1, a[i].second});
		else{
			b.back().cnt++;
			b.back().id = min(b.back().id, a[i].second);
		}
	}
	
	b.push_back({0, 0, 0});
	
	long long s = 0;
	int cur = INF;
	for(i = 0; i < b.size() - 1; i++){
		s += b[i].cnt;
		cur = min(cur, b[i].id);
		ans[cur] += (long long)(b[i].val - b[i + 1].val) * s;
	}
	
	for(i = 0; i < n; i++)
	printf("%lld\n", ans[i]);
}


Measured memory_bytes: 3956
#include<stdio.h>
#include<string.h>
int main(){
   char x[10];
   char x1[10]={'A','B','C','\0'};
   char x2[10]={'A','R','C','\0'};
   int y1=strlen(x1);
   int y2=strlen(x2);
   int cnt1=0,cnt2=0;
   scanf("%s",x);
   for(int i=0;x[i]!='\0';i++){
      if(x[i]==x1[i]){
         cnt1++;
      }
      if(x[i]==x2[i]){
         cnt2++;
      }
   }
   if(cnt1==y1){
      printf("%s",x2);
   }
   else if(cnt2==y2){
      printf("%s",x1);
   }
   return 0;
}

Measured memory_bytes: 1736
#075_D
n, k = map(int, input().split())
xy = [tuple(map(int, input().split())) for _ in range(n)]
ans = 10 ** 50
xy.sort()
for l in range(0, n):
    for r in range(l+k-1, n):
        y = [xy[i][1] for i in range(l, r+1)]
        y.sort()
        h = 10 ** 50
        for i in range(len(y)-k+1):
            h = min(h, y[i+k-1] - y[i])
        ans = min(ans, h * (xy[r][0] - xy[l][0]))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

bool chmax(ll& a, ll b){if(a < b){a = b; return 1;}return 0;}

ll pr(ll x, ll y){
    cout << x << " " << y << "\n";
    return x-y;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vp a(n);
    rep(i, n){
        ll x;
        cin >> x;
        a[i] = make_pair(x, i+1);
    }
    sort(ALL(a));
    ll ans = -INF;
    ll anstemp = 0;
    rep(i, n){
        anstemp += a[i].first;
    }
    ll maxi = -INF;
    rep(i, n-1){
        anstemp -= a[i].first * 2;
        if(chmax(ans, anstemp)){
            maxi = i;
        }
    }
    cout << ans << "\n";
    if(maxi == n-2){
        ll xp = a[n-1].first;
        for(ll i = n-2; i >= 0; i--){
            xp = pr(xp, a[i].first);
        }
    }else{
        ll xp = pr(a[maxi].first, a[maxi+2].first);
        repr(i, maxi+3, n){
            xp = pr(xp, a[i].first);
        }
        xp = pr(a[maxi+1].first, xp);
        rep(i, maxi){
            xp = pr(xp, a[i].first);
        }
    }
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e6+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;

char s[maxN];
ll h[maxN];
ll power(ll x,ll p)
{
	if(p == 0)
	{
		return 1;
	}
	ll t = power(x,p/2);
	t = t*t%MOD;
	if(p%2 == 1)
	{
		t = t*x%MOD;
	}
	return t;
}
ll C(int n,int m)
{
	ll ans = h[n] * power(h[m],MOD-2) %MOD * power(h[n-m],MOD-2)%MOD;
	return ans;
}
int main()
{

	int k;
	scanf("%d",&k);
	scanf("%s",s+1);
	int n = strlen(s+1);
	int m = n+k;
	h[0] = 1;
	for(int i=1;i<=m;i++)
	{
		h[i] = h[i-1]*i%MOD;
	}
	ll sum = 0;
	for(int i=n;i<=m;i++)
	{
		sum = (sum + C(i-1,n-1) * power(25,i-n)%MOD * power(26,m-i)%MOD)%MOD;
	}
	cout<<sum<<endl;
	return 0;
}

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

#define ll long long
#define pb push_back
#define mod 1000000007

char CH[7][7];
int K;
int ans=0;
int p =0;
void solve(vector <int> R,vector <int> C,int h,int w)
{
    //p++;
    //cout<<p<<" gggg\n";
    char D[7][7];
    int i,j,cnt=0;
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            D[i][j] = CH[i][j];

    for(i=0;i<int(R.size());i++)
    {
        //cout<<R[i]<<" ";
        for(j=1;j<=w;j++)
            D[R[i]][j]='a';
    }
    //cout<<endl;
    for(i=0;i<int(C.size());i++)
    {
        //cout<<C[i]<<" ";
        for(j=1;j<=h;j++)
            D[j][C[i]]='a';
    }
    //cout<<endl;
    
    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(D[i][j]=='#')
                cnt++;
        }
    }

    if(cnt==K)
        ans++;
    //cout<<cnt<<" ff\n";
}
void func(vector <int> R,vector <int> C,int r,int c,int h,int w)
{
    if(r==h+1 && c==w+1)
    {
        solve(R,C,h,w);
        return;
    }

    if(r<=h && c<=w)
    {
        func(R,C,r+1,c+1,h,w);
        R.push_back(r);
        func(R,C,r+1,c+1,h,w);
        C.push_back(c);
        R.pop_back();
        func(R,C,r+1,c+1,h,w);
        R.push_back(r);
        func(R,C,r+1,c+1,h,w);
    }
    else if(r<=h)
    {
        func(R,C,r+1,c,h,w);
        R.push_back(r);
        func(R,C,r+1,c,h,w);
    }
    else if(c<=w)
    {
        func(R,C,r,c+1,h,w);
        C.push_back(c);
        func(R,C,r,c+1,h,w);
    }
    return;
}
int main()
{
    int h,w,i,j;
    vector <int> R,C;
    int r=1,c=1;

    cin>>h>>w>>K;

    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            cin>>CH[i][j];
    
    func(R,C,r,c,h,w);
    cout<<ans<<"\n";
}

Measured memory_bytes: 3572
program candles
  implicit none
  integer :: n, k, x(100000) = 0, i, m = 1e9, p, q
  read(*,*) n, k
  read(*,*) x(1:n)
  do i = 1, n-k+1
    p = abs(x(i))
    q = abs(x(i+k-1))
    if (sign(1,x(i)) == sign(1,x(i+k-1))) then
      m = min(m,max(p,q))
    else
      m = min(m,max(p,q)+2*min(p,q))
    end if
  end do
  write(*,'(i0)') m
end program candles

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Restaurant> list = new ArrayList<>();
        for(int i = 1; i <= n; i++) {
            list.add(new Restaurant(i, sc.next(), sc.nextInt()));
        }
        Collections.sort(list, new RestaurantComparator());
        
        for(Restaurant r : list) {
            System.out.println(r.getIndex());
        }
    }
}

class Restaurant {
    private int index;
    private String name;
    private int score;
    
    public Restaurant(int index, String name, int score) {
        this.index = index;
        this.name = name;
        this.score = score;
    }
    
    public int getIndex() {
        return index;
    }
    
    public String getName() {
        return name;
    }
    
    public int getScore() {
        return score;
    }
}

class RestaurantComparator implements Comparator<Restaurant> {
    public int compare(Restaurant r1, Restaurant r2) {
        if(r1.getName().equals(r2.getName())) {
            return r2.getScore() - r1.getScore();
        } else {
            return r1.getName().compareTo(r2.getName());
        }
    }
} 

Measured memory_bytes: 23764
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[200010],vis(200010,0),dis(200010,inf),fin(200010,0),col(200010,0),par(200010,0),v;
set<int> st[100010];
int myrandom (int i) { return std::rand()%i;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    f(i,n)
    {
        cin>>v[i];
    }
    ll cnt1=0,i=0,cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(v[j]>v[i])
            {
                cnt++;
            }
        }
    }
    sort(all(v),greater<ll>());
    while(i<n)
    {
        ll num=v[i],temp=0;
        while(i<n&&num==v[i])
        {
            i++;
            temp++;
        }
        cnt1=cnt1+temp*(n-i);
    }
    ll num=(k*(k-1))/2;
    num=num%inf;
    num=(num*cnt1)%inf;
    ll ans=(((cnt%inf)*(k%inf))%inf+num)%inf;
    cout<<ans<<endl;
}



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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int sum_r = 0,sum_b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') sum_r++;
        else sum_b++;
    }
    if(sum_r > sum_b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{
    ll n ,ans=1e12+5;
    cin>>n;
    for(ll i=1 ;i<=sqrt(n) ; i++)
    {
        if(n%i==0 && ans>i+(n/i)-2 )
        {
           ans = i+(n/i)-2 ;
        }
    }
    cout<<ans;

go;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

int a[200003];
int b[200003];
signed main() {
    ll n, k;
    cin>>n>>k;
    rep(i, n) {
        cin>>a[i];
        a[i]--;
    }
    ll counter = 1;
    unordered_map<int, ll> ss; // place, count
    ss[0] = 0;
    // b[0]=0;
    int i = a[0];
    b[1] = a[0];
    while(ss.find(i) == ss.end()) {
        // cerr<<(*ss.find(i)).second<<endl;
        ss[i] = counter;
        counter++;
        i = a[i];
        b[counter] = i;
    }
    ll into_loop = ss[i];
    // cerr<<into_loop<<endl;
    // cerr<<counter<<endl;
    ll loop = counter - into_loop;
    // cerr<<loop<<endl;
    // cerr<<counter;
    if(k < into_loop) {
        ll ans = b[k];
        cout<<(ans+1);
        return 0;
    }
    k -= into_loop;
    k %= loop;
    ll ans = b[into_loop + k];
    cout<<(ans+1);
    return 0;
}

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

int v;
int op(int a, int b) {
    return max(a, b);
}
int e() {
    return (int)(-1e9);
}
bool f(int x) {
    return x<v;
}

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    segtree<int, op, e> seg(a);
    int t, x;
    rep(i, q) {
        cin >> t >> x >> v;
        if (t==1) seg.set(x-1, v);
        else if(t==2) cout << seg.prod(x-1, v) << endl;
        else cout << seg.max_right<f>(x-1)+1 << endl;
    }
    return 0;
}

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

int n, m, p, penalty, ans;
string s;

int main() {
  cin >> n >> m;
  int ans;
  vector<bool> solved(n, false);
  vector<int> wa(n, 0);
  rep (i, m) {
    cin >> p >> s;
    p--;
    if (s == "AC") solved[p] = true;
    else if (!solved[p]) wa[p]++;
  }
  ans = 0;
  rep (i, n) {
    if (solved[i]) {
      ans++;
      penalty += wa[i];
    }
  }
  cout << ans << " " << penalty << endl;
  return 0;
}


Measured memory_bytes: 3696
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve()
{
int n;
cin>>n;
cout<<n+(n*n)+(n*n*n)<<endl;

}
int main()
{
 
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


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

#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 1e6 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// 68
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<ll>adj[e];
ll gt[e], igt[e], a[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n % mod;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t%mod*t%mod)%mod;
    else return ((t%mod * t%mod)%mod * n %mod)%mod;
}

ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}
*/
int n, m;
ll k;

int main()
{
   cin >> k;
   cout << 50 <<"\n";
   for(int i=0; i<50; i++)
   {
       cout << 49 - i + (k + 49 - i)/50 << " ";
   }

}
/*
10 1
306<<>4>04
1 10

3 1 1 2 3 1 1 0 0 0
*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int t[5];
	int i, ave;

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

	ave = ave / 5;

	printf("%d\n", ave);

	return (0);
}

Measured memory_bytes: 600