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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int n) {
	int m; cin >> m;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	int res = 0;
	rep(i, n-1) {
		reps(j, i+1, n) {
			if (v[i] + v[j] <= m) chmax(res, v[i] + v[j]);
		}
	}
	return res;
}

signed main() {
	int n;
	while (cin >> n, n) {
		int r = solve(n);
		if (r) cout << r << endl;
		else cout << "NONE" << endl;
	}
}




Measured memory_bytes: 3056
add_flag = False
tiles = input()
if tiles.__len__() % 2 != 0:
    tiles += "0"
    add_flag = True
pair_tiles_list = [tiles[i: i + 2] for i in range(0, len(tiles), 2)]
base_pair = ""
count = 0
if pair_tiles_list.count("01") < pair_tiles_list.count("10"):
    base_pair = "10"
else:
    base_pair = "01"
if add_flag:
    pair_tiles_list[-1] = pair_tiles_list[-1][0]
for pair in pair_tiles_list:
    if pair != base_pair:
        if pair[0] != base_pair[0]:
            count += 1
        if pair.__len__() > 1:
            if pair[1] != base_pair[1]:
                count += 1
print(count)


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n), b(n);
    for (auto&& aa : a) {
        cin >> aa;
    }
    for (auto&& bb : b) {
        cin >> bb;
    }

    int64_t ans = -1;
    for (auto k : irange(0uL, 1uL << n)) {
        bitset<18> bs(k);

        vector<pair<int64_t, int64_t>> e, o;
        for (auto i : irange(0L, n)) {
            if ((i + bs[i]) % 2 > 0) {
                o.emplace_back((bs[i] == 0 ? a[i] : b[i]), i);
            } else {
                e.emplace_back((bs[i] == 0 ? a[i] : b[i]), i);
            }
        }

        if (!(e.size() == o.size() || e.size() == o.size() + 1)) {
            continue;
        }

        sort(e.begin(), e.end());
        sort(o.begin(), o.end());

        int64_t prev = -1;
        bool ok = true;
        for (auto i : irange(0L, n)) {
            int64_t current = (i % 2 == 0 ? e[i / 2] : o[i / 2]).first;
            if (prev > current) {
                ok = false;
                break;
            }
            prev = current;
        }
        if (!ok) {
            continue;
        }

        vector<int64_t> c(n);
        for (auto i : irange(0uL, e.size())) {
            c[e[i].second] = 2 * i;
        }
        for (auto i : irange(0uL, o.size())) {
            c[o[i].second] = 2 * i + 1;
        }

        // bubble sort
        int64_t m = 0;
        for (auto i : irange(0L, n - 1)) {
            for (auto j : irange(1L, n - i)) {
                if (c[j - 1] > c[j]) {
                    swap(c[j - 1], c[j]);
                    ++m;
                }
            }
        }

        if (ans < 0 || ans > m) {
            ans = m;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def kaijou(n):
    x = 1
    for i in range (1,n+1):
        x *= i
    return x

kaijou_ls = [0]*N

for i in range(N):
    kaijou_ls[i] = kaijou(i+1)

#dp
def count_order(A,k):
    if k==1:
        return 1
    else:
        B = A[N-k:]
        b = B[0]
        C = B.copy()
        C.sort()
        order = C.index(b)*kaijou_ls[k-2]

        return order+count_order(A,k-1)

print(abs(count_order(P,N)-count_order(Q,N)))

Measured memory_bytes: 3064
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    d=int(readline())
    c=list(map(int, readline().rstrip().split()))
    s=[0]*d
    for i in range(d):
        s[i]=list(map(int, readline().rstrip().split()))

    for i in range(d):
        maxx=-1
        memo=0
        for j in range(26):
            if s[i][j] > maxx:
                maxx=s[i][j]
                memo=j
        print(memo+1)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,cnt=0;
int a[100010],sum[100010];

signed main(){
    cin>>n;
    rep(i,0,n+1)sum[i]=0;
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    rep(i,0,n){
        sum[i+1]=sum[i]+a[i];
    }
    for(int i=n-2;i>=0;i--){
        if(sum[i+1]*2>=a[i+1])cnt++;
        else break;
    }
    cout<<cnt+1<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

long long int gcd(long long int a, long long int b) {
    if (a < b)swap(a, b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    LL A,B; cin >> A >> B;
    LL g = gcd(A,B);

    auto pfac = prime_factorize(g);
    LL ans = 1;
    for(auto p : pfac){
        ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = [LIST() for _ in range(2)]
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i + 1):
        tmp += a[0][j]
    for j in range(i, n):
        tmp += a[1][j]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 60012
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  if a[i]+a[i+1]>x:
    y=a[i]+a[i+1]
    if a[i+1]>=y-x:
      a[i+1]-=y-x
      ans+=y-x
    else:
      a[i+1]=0
      ans+=y-x
print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    string S;
    cin >> S;
    cout << (S[2] == S[3] and S[4] == S[5] ? "Yes" : "No") << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	cout << (X-A)%B << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>  
#include <cstdio>  
using namespace std;  
  
#define N 100  
  
int n, m;  
char tile[N][N+1];  
int number;  
  
void dfs(int x, int y, char c)  
{  
    tile[x][y] = 'X';  
    int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};  
    for (int i = 0; i < 4; i ++) {  
        int nx = x + d[i][0], ny = y + d[i][1];  
        if (0 <= nx && nx < n && 0 <= ny && ny < m  
                && tile[nx][ny] == c) {  
            dfs(nx, ny, c);  
        }  
    }  
}  
  
void solve() {  
    int res = 0;  
    for (int i=0; i<n; i++) {  
        for (int j=0; j<m; j++) {  
            if (tile[i][j] != 'X') {  
                dfs(i, j, tile[i][j]);  
                res ++;  
            }  
        }  
    }  
    printf("%d\n", res);  
}  
  
int main(void)  
{  
    while (cin >> n >> m) {  
        if (!m && !n)  
            break;  
  
        for (int i=0; i<n; i++) {  
            cin >> tile[i];  
        }  
  
        solve();  
    }  
  
    return 0;  
}  



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

int main(){
  string s;
  cin>>s;
  if (s=="Sunny"){
    cout<<"Cloudy";
  }
  if (s=="Cloudy"){
    cout<<"Rainy";
  }
  if (s=="Rainy"){
    cout<<"Sunny";
  }
}

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

int main()
{
  int N,A,B;
  int C;
  int tmp;
  int ans=0;

  cin >> N >> A >> B;

  for(int i=0;i<=N;i++){
    C=0;
    tmp=i;
    while(true){
    C += tmp%10;
    tmp = tmp/10;
    if(tmp==0){
      break;
    }
  }
  if(A <= C && C <=B){
    ans+=i;
  }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;

 public class Main{
	 public static void main(String args[]) throws IOException{
		 BufferedReader bf = new BufferedReader(
				 new InputStreamReader(System.in));
		 String str;
		 String[] answer = new String[100];
		 int x = 0;
		 while(true){
			 str = bf.readLine();
			 if(str == null) break;
			 String word[] = str.split(" ",-1);
			 answer[x] = getString(word,setNumber(word));
			 x++;
		 }
		 for(int i = 0; i < x; i++){
			 System.out.println(answer[i]);
		 }
	 }
	 
	 public static int setNumber(String[] word){//????????????????????????????????£??????????????????????????°????????????????????????????????????
		 for(int ansNum = 1; ansNum < 27 ; ansNum++){//1??????????????????????????????????????????????????????2????????????????????????
			 for(int i = 0; i < word.length; i++){ //word[i]???c[]?????\??????
				if (word[i].length() == 3 || word[i].length() == 4) {//the this that ???????????§???????????????????£???°???
					char[] c = word[i].toCharArray();
					String[] newWord = new String[word.length]; 
					for (int j = 0; j < c.length; j++) {//ansNum??????????????????word[i]?????????
						if (c[j] + ansNum > 122) {
							c[j] = (char) (c[j] + ansNum - 26);
						} else {
							c[j] = (char) (c[j] + ansNum);
						}
					}
					newWord[i] = String.valueOf(c);
					if(newWord[i].equals("that")|| newWord[i].equals("this")|| newWord[i].equals("the")){
						return ansNum;
					}
				}
			}
		}
		return 1000;
	}
	 
	 public static String getString(String[] word, int ansNum){
		 String answer ;
		 for(int i = 0; i < word.length; i++){ //word[i]???c[]?????\??????
			char[] c = word[i].toCharArray();
			for(int j = 0; j < c.length; j++){//???????????????????????????
				if (c[j] + ansNum > 122) {
					c[j] = (char) (c[j] + ansNum - 26);
				} else if((int)c[j] == 46 || (int)c[j] == 32){
				} else {
					c[j] = (char) (c[j] + ansNum);
				}
			}
			word[i] = String.valueOf(c);//word[i]???????????´???????????????????????£??????????????????
		}
		answer = word[0]+" ";
		for(int i = 1; i < word.length - 1 ;i++){//word[i]???answer???????´?(????????????????????????)
			answer += word[i]+" ";
		}
		answer += word[word.length - 1];
		return answer;
	}
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

void ok() {
    cout << "Possible" << endl;
}

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

    sort(vs.rbegin(), vs.rend());

    int ans = accumulate(vs.begin(), vs.begin() + k, 0);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,a[9],temp;
	for(i=0;i<=9;i++)
		scanf("%d",&a[i]);
	for(j=0;j<=2;j++)
		for(i=j+1;i<=9;i++)
			if(a[j]<a[i])
			{temp=a[i];a[i]=a[j];a[j]=temp;}
			for(i=0;i<=2;i++)
				printf("%d\n",a[i]);
			return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <deque>
using namespace std;

int main(void)
{
	int N,M,k;

	cin >> N;
	cin >> M;

	deque<int> deq;


	for(int i = 1; i <= N*2; i++)
		deq.push_back(i);

	while(M > 0){
		deque<int> next_deq;
		cin >> k;

		if(k == 0){
			
			for(int i = 0; i < N; i++){
				next_deq.push_back(deq[i]);
				next_deq.push_back(deq[N+i]);
			}

		}
		else {
			for(int i = k; i < N*2; i++)
				next_deq.push_back(deq[i]);
			for(int i = 0; i < k; i++)
				next_deq.push_back(deq[i]);
	
		}
				

		swap(deq,next_deq);
		M--;

	}

	for(int i = 0; i < N*2; i++)
		cout << deq[i] << endl;

	

	return 0;
}

Measured memory_bytes: 1200
import java.util.*;
public class Main {
	//1730 start
	int INF = 1 << 24;
	ArrayList<ArrayList<Edge>> G;
	
	class Edge {
		int to, cap, cost;
		int rev;

		public Edge(int to, int cap, int cost, int rev) {
			this.to = to;this.cap = cap;this.cost = cost; this.rev = rev;
		}
	}
	
	class S implements Comparable<S>{
		int start, end, cost;

		public S(int start, int end, int cost) {
			this.start = start;
			this.end = end;
			this.cost = cost;
		}

		@Override
		public int compareTo(S o) {
			if(this.end < o.end) return -1;
			if(this.end > o.end) return 1;
			return 0;
		}
		
	}

	
	private void doit(){
		Scanner sc =new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			S [] data = new S[n];
			for(int i = 0; i < n; i++){
				data[i] = new S(sc.nextInt(), sc.nextInt(), sc.nextInt());
			}
			Arrays.sort(data);
			int [] start = new int[n];
			int [] end = new int[n];
			int [] cost = new int[n];
			HashSet<Integer> set = new HashSet<Integer>();
			set.add(0);
			set.add(366);
			for(int i = 0; i < n; i++){
				start[i] = data[i].start - 1;
				end[i] = data[i].end;
				set.add(start[i]); set.add(end[i]);
				cost[i] = data[i].cost;
			}
			
			//G[][]をつくる
			G = new ArrayList<ArrayList<Edge>>();
			for(int i = 0 ; i <= 366; i++){
				G.add(new ArrayList<Edge>());
			}
			
			//マイナスのコストがある辺を加える
			for(int i = 0 ; i < n; i++){
				addEdge(start[i], end[i], 1, -cost[i]);
			}
			
			for(int i = 0; i < 366; i++){
				addEdge(i, i + 1, 2, 0);
			}
			
			int res = minCostFlow(0,366, 2);
			System.out.println(-res);
		}
	}
	
	//SHAKYO
	private void addEdge(int from, int to, int cap, int cost){
		G.get(from).add(new Edge(to, cap, cost, G.get(to).size()));
		G.get(to).add(new Edge(from, 0, -cost, G.get(from).size() - 1));
	}

	//SHAKYO
	private int minCostFlow(int s, int t, int f) {
		int V = G.size();
		int [] dist = new int[V];
		int [] prevv = new int[V];
		int [] preve = new int[V];
		
		int res = 0;
		while(f > 0){
			//ベルマン
			Arrays.fill(dist, INF);
			dist[s] = 0;
			boolean update = true;
			while(update) {
				update = false;
				for(int v = 0; v < V; v++){
					if(dist[v] == INF) continue;
					for(int i = 0 ; i < G.get(v).size(); i++){
						Edge  e = G.get(v).get(i);
						if(e.cap > 0 && dist[e.to]> dist[v] + e.cost ){
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i; 
							update = true;
						}
					}
				}
			}
			
			if(dist[t] == INF){
				return -1;
			}
			
			int d = f;
			for(int v = t; v != s; v = prevv[v]){
				d = Math.min(d, G.get(prevv[v]).get(preve[v]).cap);
			}
			f -= d;
			res += d * dist[t];
			for(int v = t; v!= s; v = prevv[v]){
				Edge e =G.get(prevv[v]).get(preve[v]);
				e.cap -= d;
				G.get(v).get(e.rev).cap += d;
			}
		}
		
		return res;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
//9x9
#include <iostream>
using namespace std;
int main () {
	int n, m;	cin >> n >> m;
	if ((n >= 1 && n <= 9) && (m >= 1 && m <= 9 )) {
		cout << n * m << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

if s[k-1] == "A":
    print(s[:k-1] + "a" + s[k:])
elif s[k-1] == "B":
        print(s[:k-1] + "b" + s[k:])
elif s[k-1] == "C":
        print(s[:k-1] + "c" + s[k:])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	map<string, int> mapa;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		mapa[s]++;
	}	
	cout << "AC x " << mapa["AC"] << endl;
	cout << "WA x " << mapa["WA"] << endl;
	cout << "TLE x " << mapa["TLE"] << endl;
	cout << "RE x " << mapa["RE"] << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,x;
	int a[102];
	scanf("%d%d",&n,&x);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int y = 0;
	for(int i = 0 ; i < n-1 ; i ++){
		y += a[i];
		if(y >= x){
			if(y == x)cout << i+1 << endl;
			else cout << i << endl;
			return 0;
		}
	}
	if(y+a[n-1] == x)cout << n << endl;
	else cout << n-1 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  values = []
  total = 0
  open_chars = 0
  close_chars = 0

  for _ in range(int(input())):
    s = input().strip()
    open_required = len(s)
    close_required = len(s)
    open_close = 0

    for i, c in enumerate(s):
      if c == '(':
        open_required = min(i, open_required)
        open_close += 1
      else:
        close_required = min(len(s) - i - 1, close_required)
        open_close -= 1

    if open_required == 0 and close_required == 0 and open_close == 0:
      continue
    elif open_close == len(s):
      open_chars += len(s)
      continue
    elif -open_close == len(s):
      close_chars += len(s)
      continue

    total += open_close
    values.append([open_required, close_required, open_close, 0])

  if total + open_chars - close_chars != 0:
    print('No')
    return

  fvals = values.copy()
  bvals = values

  fvals.sort(key=lambda x: (x[0], -x[2]))
  bvals.sort(key=lambda x: (x[1], x[2]))

  findex = 0
  bindex = 0

  while True:
    while findex < len(fvals) and fvals[findex][3] != 0:
      findex += 1

    while bindex < len(bvals) and bvals[bindex][3] != 0:
      bindex += 1

    if findex >= len(fvals) and bindex >= len(bvals):
      break

    fvals[findex][3] = 1
    bvals[bindex][3] = -1

  values = [v for v in fvals if v[3] == 1] + [v for v in bvals if v[3] == -1][::-1]

  open_close_f = 0
  open_close_b = 0

  for (oreq_f, _, ocval_f, _), (_, creq_b, ocval_b, _) in zip(values, values[::-1]):
    if oreq_f > open_close_f + open_chars:
      print('No')
      return

    if creq_b > open_close_b + close_chars:
      print('No')
      return

    open_close_f += ocval_f
    open_close_b -= ocval_b

  print('Yes')


if __name__ == '__main__':
  main()


Measured memory_bytes: 144568
class eight_Q:
    #Free = 'Free', NOT_Free = 'NotFree'
    N = 8

    def __init__(self):
        #self.position = [['Free' for i in range(self.N)] for j in range(self.N)]
        self.row = [-1 for _ in range(self.N)]
        self.col = ['Free' for _ in range(self.N)]
        self.dpos = ['Free' for _ in range(self.N*2 -1)]
        self.dneg = ['Free' for _ in range(self.N*2 -1)]
        self.initial = [-1 for _ in range(self.N)]

    def initQueen(self,i,j):
        self.row[i] = j
        self.initial[i] = j
        self.col[j] = 'NotFree'
        self.dpos[i+j] = 'NotFree'
        self.dneg[i-j+(self.N-1)] = 'NotFree'

    def putQueen(self, i):
        for j in range(self.N):
            #print(j)
            if i == self.N:
                return 'Success'
            if self.initial[i] == j:
                if self.putQueen(i+1) == 'Success':
                    return 'Success'
                else:
                    continue
            if self.col[j] == 'Free' and self.dpos[i+j] == 'Free' and self.dneg[i-j+(self.N-1)] == 'Free':
                #put queen at (i, j)
                self.row[i] = j
                self.col[j] = 'NotFree'
                self.dpos[i+j] = 'NotFree'
                self.dneg[i-j+(self.N-1)] = 'NotFree'
                #try the next row
                if i == self.N-1:
                    return 'Success'
                else:
                    if self.putQueen(i+1) == 'Success':
                        return 'Success'
                    #remove the queen at (i, j) for backtracking
                    else:
                        self.row[i] = -1
                        self.col[j] = 'Free'
                        self.dpos[i+j] = 'Free'
                        self.dneg[i-j+(self.N-1)] = 'Free'

        return 'Fail'

    def printBoard(self):
        #print(self.row)
        for i in range(self.N):
            for j in range(self.N):
                if self.row[i] == j:
                    print("Q",end='')
                elif self.initial[i] == j:
                    print("Q",end='')
                else:
                    print(".",end='')
            print()


if __name__ == "__main__":
    eightQueen = eight_Q()
    k = int(input())

    for i in range(k):
        _i, _j = (int(z) for z in input().split())
        eightQueen.initQueen(_i, _j)
    if eightQueen.putQueen(0) == 'Success':
        eightQueen.printBoard()
        #print(eightQueen.row)
    else:
        print("Fail to put queen")
        #print(eightQueen.row)



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

int main() {
	int n;
	cin>>n;			
	int arr[n+1];
	int result[n+1] = { 0 };
	for(int i = 2; i <= n; i++) {
		cin>>arr[i];
		result[arr[i]]++;
	}
								
	for(int i = 1; i <= n; i++)
		cout<<result[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 5164
N = int(input())
T,A = tuple(map(int,input().split()))
H = list(map(int,input().split()))

ans = 0
for i in range(N):
    if abs(T-0.006*H[i]-A) < abs(T-0.006*H[ans]-A):
        ans = i

print(ans+1)

Measured memory_bytes: 3188
n,m=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
t=[[]for i in range(n)]
ans=0
for i in range(m):
    a,b=[int(x) for x in input().split()]
    t[a-1].append(b-1)
    t[b-1].append(a-1)
for i in range(n):
    if t[i]==[]:
        ans+=1
    else:
        c=[]
        for j in t[i]:
            if h[i]<=h[j]:
                c.append(False)
        if c==[]:
            ans+=1
print(ans)

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;

class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n, d, in1, in2;
		string s;
		cin >> s >> d;
		reverse(s.begin(), s.end());
		ll dp[s.size()+12][d+5][2];
        rep(i, 0, s.size()+1){
				rep(k, 0, d){
                    dp[i][k][0] = dp[i][k][1] = 0;
				}
			}
        rep(i, 1, 10) {
            if(s[0] - '0' >= i)dp[1][i%d][1]++;
            dp[1][i%d][0]++;
        }
        dp[1][0][1]++, dp[1][0][0]++;
		rep(i, 1, s.size()){
			rep(j, 0, 10){
				rep(k, 0, d){
					if(s[i] - '0' > j)dp[i+1][(k+j)%d][1] += dp[i][k][0], dp[i+1][(k+j)%d][1] %= mod;
					if(s[i] - '0' == j)dp[i+1][(k+j)%d][1] += dp[i][k][1], dp[i+1][(k+j)%d][1] %= mod;
					dp[i+1][(k+j)%d][0] += dp[i][k][0], dp[i+1][(k+j)%d][0] %= mod;
				}
			}
		}
        cout << (dp[s.size()][0][1]-1+mod)%mod << endl;
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

Measured memory_bytes: 16768
//https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    //if( N >= 1000 ) return -1;
    int cnt{};
    REP( i, N + 1 ){
        REP( j, N + 1 ){
            if( R * i + G * j > N ) continue;
            int Bk = N - (R * i + G * j);
            int k = Bk/B;
            int sum = R * i + G * j + B * k;
            if( sum == N ){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long n, d;
  long long counter = 0;
  cin >> n >> d;
  long long d2 = d * d;
  for (int i = 0; i < n; i++) {
    long long tmpx, tmpy;
    cin >> tmpx >> tmpy;
    long long tmpd = tmpx * tmpx + tmpy * tmpy;
    if (d2 >= tmpd) {
      // cout << d2 << " " << tmpd << endl;
      counter++;
    }
  }
  cout << counter << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

int GCD(int m, int n);

int main()
{
	int m, n;
	
	while (cin >> m >> n){
		if (m < n)	swap(m, n);
		
		int gcd = GCD(m, n);
		int lcm = n * (m / gcd);
		
		cout << gcd << ' ' << lcm << endl;
	}	
	return (0);
}

int GCD(int m, int n)
{
	int r;
	while (m % n != 0){
		r = n;
		n = m % n;
		m = r;
    }
	return (n); 
}

Measured memory_bytes: 1160
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1 
s = int(input())
ans = 1
used = set()
while True:
    if s in used:
        break
    used.add(s)
    ans += 1
    s = f(s)
print(ans)

Measured memory_bytes: 2940
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c] <- getIntList
  putStrLn $ if (c - (a + b)) < 0 then "No" else if (c - (a + b)) ^ 2 - 4 * a * b > 0 then "Yes" else "No"


Measured memory_bytes: 3776
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
main(){
	int i=0,n,x;
	vector<int>v;
	for(scanf("%d",&n);i<n;i++)scanf("%d",&x),v.push_back(x);
	make_heap(v.begin(),v.end());
	for(i=0;i<n;i++)printf(" %d",v[i]);
	puts("");
}

Measured memory_bytes: 2964
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

int main() {
	string s, t; cin >> s >> t;
	int a[26] = {}, b[26] = {};

	for (int i = 0; i < s.size(); i++) {
		a[s[i] - 'a'] += 1;
		b[t[i] - 'a'] += 1;
	}

	sort(a, a + 26);
	sort(b, b + 26);

	for (int i = 0; i < 26; i++) {
		if (a[i] != b[i]) { cout << "No" << endl; return 0; }
	}

	cout << "Yes" << endl;






}

Measured memory_bytes: 776
import numpy as np
from numba import njit

@njit #処理の並列化
def imos(n,k,a):
    
    l=np.zeros((n+1),dtype=np.int64)
    for i in range(n):
        ai=a[i]
        start=max(0,i-ai) #StartIndex
        end=min(n,i+ai+1) #EndIndex + 1
        l[start]+=1
        l[end]-=1
    return np.cumsum(l)[:n]

if __name__=="__main__":
    n,k=map(int, input().split())
    a=list(map(int, input().split()))
    for _ in range(k):
        a=imos(n,k,a)
        if a.min()==n:
            break   
    
    print(*a)


Measured memory_bytes: 125120
N, M = (int(i) for i in input().split())

A = []
for i in range(0, M):
    l, r = (int(i) for i in input().split())
    A.append((r, l))

A.sort()

ans = 0
last = -1
for i in range(0, M):
    r, l = A[i]
    if last <= l:
        ans = ans + 1
        last = r

print (ans)


Measured memory_bytes: 17016
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, A, B = na()
X = na()
ans = 0
for i in range(N-1):
    ans += min((X[i+1] - X[i]) * A, B)
print(ans)

Measured memory_bytes: 99436
#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 ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int n;cin >> n;
      vector<ll> a(n);rep(i,n)cin >> a[i];
      vector<ll> b(n);rep(i,n)cin >> b[i];
      vector<ll> c(n);rep(i,n)cin >> c[i];
      sort(ALL(a));
      sort(ALL(c));
      ll ans = 0;
      rep(i,n){
            auto aIter = lower_bound(ALL(a),b[i]);
            auto bIter = upper_bound(ALL(c),b[i]);
            ll aSum = aIter - a.begin();
            ll bSum = c.end() - bIter;
            ans += aSum * bSum;
      }
      cout << ans << endl;
      return 0;
}

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

const int MAXN = 300010;
long long a[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a+3);
	cout<<a[0] + a[1]<<endl;
	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
int main()
{
    long long int n,k,i,x,t;
    scanf("%lld%lld",&n,&k);
    long long int a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    t=((n-k)/(k-1))+1;
   if(k+((t-1)*(k-1))<n)t++;
   printf("%lld\n",t);
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(2*m);
  rep(i,2*m) cin >> a[i];
  vector<int> b(n);
  rep(i,2*m){
    ++b[a[i]-1];
  }
  rep(i,n) cout << b[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char s[100005];
    char a[] = "maerd", b[] = "remaerd", c[] = "esare", d[] = "resare";

    scanf("%s", s);

    int size = 0;
    while(s[size] != '\0'){
        size++;
    }
    char s_rev[100005];
    int i = 0;
    for(int j = size - 1; j >= 0; --j){
        s_rev[i] = s[j];
        i++;
    }
    s_rev[i] = '\0';

    int j = 0;
    int flag = 0;
    while(s_rev[j] != '\0'){
        int k = 0;
        flag = 0;
        if(s_rev[j] != '\0' && flag == 0){
            while(a[k] != '\0'){
                if(s_rev[j + k] == a[k]){
                    flag = 1;
                    k++;
                }else{
                    flag = 0;
                    k = 0;
                    break;
                }
            }
            if(flag == 1){
                j += k;
                k = 0;
            }
        }
        if(s_rev[j] != '\0' && flag == 0){
            while(b[k] != '\0'){
                if(s_rev[j + k] == b[k]){
                    flag = 1;
                    k++;
                }else{
                    flag = 0;
                    //printf("%c\n", s_rev[j]);
                    k = 0;
                    break;
                }
            }
            if(flag == 1){
                j += k;
                k = 0;
            }
        }
        if(s_rev[j] != '\0' && flag == 0){
            while(c[k] != '\0'){
                if(s_rev[j + k] == c[k]){
                    flag = 1;
                    k++;
                }else{
                    flag = 0;
                    //printf("%c\n", s_rev[j]);
                    k = 0;
                    break;
                }
            }
            if(flag == 1){
                j += k;
                k = 0;
            }
        }
        if(s_rev[j] != '\0' && flag == 0){
            while(d[k] != '\0'){
                if(s_rev[j + k] == d[k]){
                    flag = 1;
                    k++;
                }else{
                    flag = 0;
                    k = 0;
                    break;
                }
            }
            if(flag == 1){
                j += k;
                k = 0;
            }
        }
        if(flag == 0) break;
    }

    if(flag == 1) puts("YES");
    else puts("NO");

    return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> x(n), y(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
		y[i] = x[i];
	}
	sort(y.begin(), y.end());
	map<int, int> mp;
	for(int i = 0; i < n; i++) {
		mp[y[i]] = i;
	}
	for(int i = 0; i < n; i++) {
		int idx = mp[x[i]];
		if(idx <= n/2 - 1) {
			printf("%d\n", y[n/2]);
		} else {
			printf("%d\n", y[n/2 - 1]);
		}
	}
}


Measured memory_bytes: 12928
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
a, b = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
print("{}".format(max(max(a+b, a-b), a*b)))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
//#include<vector>
using namespace std;
int main(){
  int n,k;
  std::cin>>n>>k;
  //vector<int>b;
  int j;
  int s=0;
  int i,t;
  for(i=0;i<n;i++)
  {
    std::cin>>j;
    //b.push_back(j);
     t=min(j,abs(k-j));
    s+=t;
  }
  s*=2;
  std::cout<<s;
  return 0;
}
  
    


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<tuple<string, ll, ll>>vp;
    REP(i, n) {
        string s; cin >> s;
        ll p = in();
        vp.emplace_back(s, -p, i);
    }
    sort(ALL(vp));
    REPC(v, vp)cout << get<2>(v) + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX_N 200
#define MAX_H 400

double dp[MAX_N][MAX_H];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, h[MAX_N];
	double ans = INF;
	
	cin>>n;
	
	for(int i = 1; i <= n; i++){
		cin>>h[i];
	}
	
	dp[0][1] = 0;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < MAX_H; j++){
			dp[i][j] = INF;
		}
		for(int j = 1; j < MAX_H; j++){
			if(i == 1 && j != 1) continue;
			for(int k = 1; k < MAX_H; k++){
				double S;
				if((h[i]-j)*(h[i]-k) >= 0) S = (fabs(h[i]-k)+fabs(h[i]-j))/2.0;
				else S = (((double)h[i]-j)*(h[i]-j)+(double)(h[i]-k)*(h[i]-k))/(2.0*fabs(j-k));
				dp[i][k] = min(dp[i-1][j]+S,dp[i][k]);
			}
			
		}
	}

	for(int i = 0; i < MAX_H; i++){
		ans = min(dp[n][i],ans);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;

int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	int n, t, sum = 0;
	bool flag = false;
	vector <int> data;

	cin >> n;
	int i;
	for(i = 0; i < n; ++i)
	{
		cin >> t;
		if( t%10)
			flag = true;
		data.pb(t);
		sum += t;
	}

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

	if(!flag){
		cout << "0\n";
		return 0;
	}

	if( sum %10){
		cout << sum << "\n";
		return 0;
	}

	for(i = 0; i < n; ++i){
		if( data[i]%10 )
		{
			cout << sum-data[i] << "\n";
			return 0;
		}
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	int N;
	cin >> N;
	ll a[3 * N];
	rep(i, 0, 3 * N) cin >> a[i];

	priority_queue<ll> q1, q2;
	ll res1[N + 1], res2[N + 1];
	memset(res1, 0, sizeof(res1));
	memset(res2, 0, sizeof(res2));
	ll prev1 = 0, prev2 = 0;
	rep(i, 0, N) {
		q1.push(-a[i]);
		res1[0] += a[i];
		q2.push(a[3 * N - i - 1]);
		res2[0] += a[3 * N - i - 1];
	}


	ll res = 0;
	rep(k, N, 2 * N) {
		q1.push(-a[k]);
		ll tmp1 = q1.top();
		q1.pop();
		res1[k - N + 1] = res1[k - N] + tmp1 + a[k];
		
		q2.push(a[3 * N - k - 1]);
		ll tmp2 = q2.top();
		q2.pop();
		res2[k - N + 1] = res2[k - N] - tmp2 + a[3 * N - k - 1];
	}
	
	res = res1[0] - res2[N];

	rep(i, 1, N + 1) res = max(res, res1[i] - res2[N - i]);
	cout << res << endl;

}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int n,m;
  cin>>n>>m;
  int tmp=n+m;
  if(tmp%2==0){
    cout<<(tmp/2)*(tmp-1)-n*m<<endl;
  }else{
    cout<<(tmp-1)/2*tmp-n*m<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
const int mod = 998244353;
int n, k;
int main() {
	n = read(); k = read();
	vector<ll>dp(n, 0), l(k + 1, 0), r(n + 1, 0), sum(n + 1, 0);
	for_int(i, 1, k) l[i] = read(), r[i] = read();
	dp[0] = 1;
	for_ll(i, 0, n-1) {
		if (i == 0) continue;
		sum[i] = sum[i - 1] + dp[i - 1];
		for_ll(j, 1, k) {
			if (l[j] > i) continue;
			int t = min(r[j], i) + 1;
			dp[i] += sum[i - l[j] + 1] - sum[i - t + 1];
		}
		dp[i] %= mod;
	}
	cout << dp[n-1] << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)


int main(){
  ll n;
  vector<ll> a(5);
  cin >> n;
  rep(i,5){
    cin >> a[i];
  }
  sort(all(a));
  cout << (n+a[0]-1)/a[0]+4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    int h;
    int w;
    cin>>n>>h>>w;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]>=h&&b[i]>=w){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N, K = Integer.parseInt(sc.next())
    val h = new Array[Long](N)
    for (i <- 0 until N) {
      h(i) = Integer.parseInt(sc.next())
    }

    println(solve(N, K, h))
  }

  def solve(N: Int, K: Int, h: Array[Long]): String = {
    val sortedH = h.sorted

    var ans = sortedH(N - 1)
    for (i <- 0 to N - K) {
      ans = Math.min(ans, sortedH(K - 1 + i) - sortedH(i))
    }
    ans.toString
  }
}

Measured memory_bytes: 55180