akhauriyash/Code-Regression huggingface dataset:
/* # */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
typedef unsigned int			uint;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
int n;
vi a, dp, ans;
vvi e;

void dfs(int now, int pre){
	int pos = lower_bound(dp.begin(), dp.begin()+n, a[now]) - dp.begin();
	int dp_hist = dp[pos];
	dp[pos] = a[now];
	ans[now] = lower_bound(dp.begin(), dp.begin()+n, inf) - dp.begin();
	
	for(uint i=0; i < e[now].size(); i++){
		int v = e[now][i];
		if(pre == v) continue;
		dfs(v, now);
	}
	
	dp[pos] = dp_hist;
}

void sol() {
	cin >> n;
	a.resize(n + 1);
	dp.assign(n , inf);
	ans.resize(n +1);
	e.assign(n + 1, vi());
	
	for(int i=1; i <= n;i++) 
		cin >> a[i];
		
	for(int i=1; i<n;i++){
		int u, v; 
		cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
		
	dfs(1, -1);
	for(int i=1; i<= n;i++)
		cout << ans[i] << '\n';
	
}         

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
	sol();
    return 0;
}


Measured memory_bytes: 30856
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {   
        String out;
        Scanner sc = new Scanner(System.in); 
        String nyu = sc.next();
        switch(nyu){
            case "A":
                out = "T";
                break;
            case "T":
                out = "A";
                break;
            case "C":
                out = "G";
                break;
            case "G":
                out = "C";
                break;
            default :
                out = "";
                break;
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 1e5 + 7;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];
int ps[N];

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
	ps[0] = 0;
	for (int i = 1; i < N; i++) {
		ps[i] = ps[i - 1] + divv(1, i);
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	init();

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int ans = 0; 
	for (int i = 0; i < n; i++) {
		int c = 0;
		c = ps[i + 1];
		c = add(c, ps[n - i]);
		c = sub(c, 1);
		c = mul(c, f[n]);
		ans = add(ans, mul(a[i], c));
	}
	cout << ans << endl;
}	


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(5000)

input = sys.stdin.readline
sea_map = []
chk_map = []
h = 0
w = 0
def chk_island(i,j):
    chk_map[i][j] = False
    if sea_map[i][j] == 0:
        return 0
    for d in ((-1,0), (-1,1), (0,1), (1,1), (1,0), (1,-1), (0,-1), (-1,-1)):
        if 0 <= i + d[0] < h and 0 <= j + d[1] < w:
            if chk_map[i+d[0]][j+d[1]]:
                chk_island(i+d[0],j+d[1])
    return 1

while True:
    count = 0
    w, h = map(int,input().split())
    if w == 0 and h == 0:
        break
    sea_map = [list(map(int,input().split())) for _ in range(h)]
    chk_map = [[True for _ in range(w)] for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if chk_map[i][j]:
                count += chk_island(i,j)
    print (count)



Measured memory_bytes: 7968
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
long long num[90];
int main()
{
	int n;
	num[0]=2;
	num[1]=1;
	for(int i=2;i<=86;i++)
	{
		num[i]=num[i-1]+num[i-2];
	}
	scanf("%d",&n);
	printf("%lld\n",num[n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  set<string> S;
  ll N; cin>>N;
  rep(i,N){
    string s;
    cin>>s;
    S.insert(s);
  }
   cout<<S.size()<<endl; 
}


Measured memory_bytes: 19176
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main(){
   string s;
   cin  >> s;
   string moto="CODEFESTIVAL2016";
   int count=0;
   for (int i = 0; i < moto.length(); i++)
   {
     if(s[i]!=moto[i])count++;
   }
   cout <<count<<endl;
   return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for i in range(H)]
count = 0
l = [''] * H
S_new = S
for j in range(len(S)):
    S_new[j] = '.' + S[j] + '.'
S_new.insert(H, '.'*(W+2))
S_new.insert(0, '.'*(W+2))
# for i in range(len(S_new)):
#     print(S_new[i])
for i in range(1, H+1):
    for j in range(1, W+1):
        if S_new[i][j] == '#':
            l[i-1] += '#'
        else:
            for k in range(-1, 2):
                for s in range(-1, 2):
                    if S_new[i-k][j-s] == '#':
                        count += 1
            l[i-1] += str(count)
            count = 0
for i in range(len(l)):
    print(l[i])

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

using namespace std;

int number(string &s,int cur,int end){
  // cerr << "number: " << s.substr(cur,end-cur+1) << endl;
  int ret = 0;
  for(int i=cur;i<=end;i++){
    ret*=10;
    ret += s[i]-'0';
  }
  return ret;
}

string str(string &s,int cur,int end){
  // cerr << "str: " << s.substr(cur,end-cur+1) << endl;
  string ret = "";
  for(int i=cur;i<=end;i++){
    ret += s[i];
  }
  return ret;
}

// string dfs(s, cur, end)
string parse(string &s,int start,int end){
  // cerr << "parse: " << s.substr(start,end-start+1) << endl;
  string ret = "";
  int num = 1;
  int cur = start;
  while(cur<=end){
    // cerr << cur << endl;
    if(s[cur]=='('){
      int c = 1;
      string str = "";
      for(int i=cur+1;i<=end;i++){
        if(s[i]=='('){
          c++;
        }else if(s[i]==')'){
          c--;
        }
        if(c==0){
          str = parse(s,cur+1,i-1);
          cur = i+1;
          break;
        }
      }
      for(int i=0;i<num;i++){
        if(ret.size()>1000100)break;
        ret+=str;
      }
      num = 1;
    }else if(isupper(s[cur])){
      string tmp = "";
      for(int i=cur;i<=end;i++){
        if(i+1>end||!isupper(s[i+1])){
          tmp = str(s,cur,i);
          cur = i+1;
          break;
        }
      }
      for(int i=0;i<num;i++){
        if(ret.size()>1000100)break;        
        ret+=tmp;
      }
      num = 1;
    }else{
      for(int i=cur;i<=end;i++){
        if(i+1>end||!isdigit(s[i+1])){
          num = number(s,cur,i);
          cur = i+1;
          break;
        }
      }
    }  
  }
  return ret;
}





int main(){
  string S;
  int num;
  while(cin >> S >> num,S!="0"){
    string res = parse(S,0,S.size()-1);
    // cout << res << endl;
    if(num<res.size()){
      cout << res[num] << endl;
    }else{
      cout << 0 << endl;
    }
  }
}




Measured memory_bytes: 7880
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n, k = LI()
print(min(n % k, k - n % k))

Measured memory_bytes: 39664
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const int N = 2003;
int a[N][N];
int pos[N][N];
int n;
queue <int> q;
inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();
	}
	return v * c;
}
int tot;
struct edge{
	int to;
	int nxt;
	int data;	
}e[N * N];
int head[N * N];
int d[N * N];
int f[N * N];
bool b[N][N];
int belong[N * N];
inline void add(int x,int y,int z){
	x = belong[x],y = belong[y];
	e[++tot].data = z;
	e[tot].to = y;
	e[tot].nxt = head[x];
	head[x] = tot;
	d[y]++;
}
int main(){
	int cntt = 0;
	n = read();
	for(int i = 0;i < n;++i) for(int j = 0;j < n - 1;++j) {
		a[i][j] = read() - 1;
		pos[i][a[i][j]] = j;
	}
	for(int i = 0;i < n;++i){
		for(int j = 0;j < n - 1;++j){
			if(!belong[i * (n - 1) + j]) belong[i * (n - 1) + j] = belong[a[i][j] * (n - 1) + pos[a[i][j]][i]] = ++cntt;
		}
	}	
	for(int i = 0;i < n;++i){
		for(int j = 0;j < n - 2;++j) add(i * (n - 1) + j,i * (n - 1) + j + 1,1);	
	}
	int ans = 1,cnt = 0;
	for(int i = 1;i <= cntt;++i) if(!d[i]) q.push(i),f[i] = 1;
	while(!q.empty()){
		int k = q.front();q.pop();
		cnt++;
		for(int i = head[k];i;i = e[i].nxt){
			int y = e[i].to;
			f[y] = max(f[y],f[k] + e[i].data);
			ans = max(f[y],ans);
			d[y]--;
			if(!d[y]) q.push(y);	
		}
	}
	if(cnt == cntt) printf("%d\n",ans);
	else printf("-1\n");
	return 0;
}


Measured memory_bytes: 49408
n=int(input())
t=[int(x) for x in input().split()]
m=int(input())
p=[]
x=[]
for i in range(m):
    p_,x_=map(int,input().split())
    p.append(p_)
    x.append(x_)
for i in range(m):
    tm=sum(t)-t[p[i]-1]+x[i]
    print(tm)

Measured memory_bytes: 3064
import sys

s = input()

if len(s) == 2 and s[0] == s[1]:
    print('1 2')
    sys.exit(0)
else:
    for i in range(0, len(s)-2):
        c1, c2, c3 = s[i], s[i+1], s[i+2]

        if len(set([c1,c2,c3])) <= 2:
                print('%s %s' % (i+1, i+3))
                sys.exit(0)

print('-1 -1')


Measured memory_bytes: 9128
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

int main() {
	ll k; cin >> k;
	ll cnt = 1;
	ll now = 7;
	while (true) {
		if (now%k == 0) {
			cout << cnt << endl;
			return 0;
		}
		now *= 10;
		now += 7;
		cnt++;
		if (now%k == 0) {
			cout << cnt << endl;
			return 0;
		}
		if (now > k)break;
	}
	ll key;
	key = now % k;
	while (true) {
		ll a = key;
		key *= 10;
		key += 7;
		key %= k;
		cnt++;
		if (key == 0)break;
		if (a == key||cnt>=k) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

const int cnMaxArray = 1000033;

long long fnStrToInt(string sKey)
{
  int iElement;
  int iBase = 1;
  int llKey  = 0;
  for (int i = sKey.size() - 1; i >= 0; i--)
  {
    switch (sKey[i])
    {
      case  'A': iElement = 1;
                 break;
      case  'C': iElement = 2;
                 break;
      case  'G': iElement = 3;
                 break;
      case  'T': iElement = 4;
                 break;
      default:   iElement = 0;
    }
    llKey += iBase * iElement;
    iBase *= 5;
  }
  return llKey;
}

int fnHash1(long long a_llKey) { return (a_llKey % cnMaxArray); }
int fnHash2(long long a_llKey) { return (1 + (a_llKey % (cnMaxArray - 1))); }

void fnDictionary(string a_rsDictionary[])
{
  int iCommandCnt;
  cin >> iCommandCnt;

  for (int i = 0; i < iCommandCnt; i++)
  {
    string sCommand;
    string sKey;
    cin >> sCommand >> sKey;

    long long llKey = fnStrToInt(sKey);
    int iCnt = 0;
    for (iCnt = 0; ;iCnt++)
    {
      int ix = (fnHash1(llKey) + iCnt * fnHash2(llKey)) % cnMaxArray;
      if (a_rsDictionary[ix] == sKey)
      {
        if (sCommand[0] == 'f')
        {
          cout << "yes" << endl;
          break;
        }
      }
      else if (a_rsDictionary[ix].size() == 0)
      {
        if (sCommand[0] == 'i')
        {
          a_rsDictionary[ix] = sKey;
          break;
        }
        else if (sCommand[0] == 'f')
        {
          cout << "no" << endl;
          break;
        }
      }
    }
  }
}

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

  static string sDictionary[cnMaxArray];
  fnDictionary(sDictionary);
  
  return 0;
}

Measured memory_bytes: 35780
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	cin >> N;
	cout << (N / 2) - (N % 2 == 0 ? 1 : 0) << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
    int k = ri();
    s64 res = 0;
    FROMTO(b,1,n) {
        if (b<=k) continue;
        int tmp = (n/b)*(b-k);
        if (n%b&&n%b>=k) tmp += k?n%b-k+1:n%b;
        res += tmp;
        // cout << "b : " << b << " add : " << tmp << endl; 
    }
    cout << res << endl;
 return 0;
}


Measured memory_bytes: 256
from operator import itemgetter


def solve(string):
    n, *ab = map(int, open(0).read().split())
    ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    print(solve(""))


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

int main() {
    int N; cin >> N;
    vector<long long> A(N*3);
    for (int i = 0; i < N*3; ++i) cin >> A[i];
    sort(A.begin(), A.end(), greater<long long>());
    long long res = 0;
    for (int i = 1, j = 0; j < N; i += 2, ++j) res += A[i];
    cout << res << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int digitSum(int num) {
  int sum = 0;
  while (num != 0) {
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

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

  int fx = digitSum(n);
  if (n % fx == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())

battle=[]

def mainasu(x):
    return int(x)-1

front=[]

for _ in range(n):
    tmp=list(map(mainasu,input().split()))[::-1]
    front.append(tmp.pop())
    battle.append(tmp)

def pri():
    global front,battle,day,checkday
    print(day,front,battle,checkday)

day=0

checkday=[-1]*n

#pri()
cnt=0
while 1:
    flag=0
    for i in range(n):
        if i<n and front[i]<n and i==front[front[i]] and checkday[i]<day and checkday[front[i]]<day:
            flag=1
            if len(battle[front[i]])>0:
                front[front[i]]=battle[front[i]].pop()
                checkday[front[i]]=day
            else:
                front[front[i]]=n
                cnt+=1
            
            if len(battle[i])>0:
                front[i]=battle[i].pop()
                checkday[i]=day
            else:
                front[i]=n
                cnt+=1
    #pri()
    if flag==0:
        break
    
    day+=1


if cnt==n:
    print(day)
else:
    print(-1)            

    




Measured memory_bytes: 85780
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


#define MAX_N 510000
class SegTree{
public:
    //セグメント木を持つグローバル変数
    int n;
    vector<vector<int>> dat;

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2 * n - 1; i++){
            dat.emplace_back(vector<int>(26, 0));
        }
    }

    // k番目の値(0-indexed)をaに変更
    void update(int k, int x){
        k += n-1;
        for(int i = 0; i < 26; i++){
            dat[k][i] = 0;
        }
        dat[k][x] = 1;

        while(k > 0){
            k = (k-1)/2;
            for(int i = 0; i < 26; i++){
                dat[k][i] = dat[k*2+1][i] + dat[k*2+2][i];
            }
        }
    }

    // [a, b)の最小値を求める。
    // kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
    // query(a, b, 0, 0, n)で外からは呼び出す。
private: vector<int> query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return vector<int>(26, 0);
        }

        if (a <= l && r <= b) {
            return dat[k];
        } else {
            vector<int> vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            vector<int> vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            vector<int> res(26, 0);
            for(int i = 0; i < 26; i++){
                res[i] = vl[i] + vr[i];
            }
            return res;
        }
    }
    // [a, b)の最小値を求める。
public: vector<int> query(int a, int b){
        return query(a, b, 0, 0, this->n);
    }
};


int main(){
    int N;  string s;
    cin >> N;
    cin >> s;

    SegTree st;
    st.init(N);

    int q;  cin >> q;
    for(int i = 0; i < N; i++){
        st.update(i, s[i] - 'a');
    }

    for(int i = 0; i < q; i++){
        int t;
        cin >> t;
        if(t == 1){
            int a; char c;  cin >> a >> c;
            a--;
            st.update(a, c - 'a');
        }
        else{
            int a, b;   cin >> a >> b;
            a--; b--;
            vector<int> res = st.query(a, b+1);
            int kind = 0;
            for(int j = 0; j < 26; j++){
                if(res[j] > 0){
                    kind++;
                }
            }
            cout << kind << endl;
        }
    }



    return 0;
}


Measured memory_bytes: 140140
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll n; cin>>n;
  string s="";
  while(n>0){
    n--;
    s += 'a'+(n%26);
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
    int f[N2];
    int space;
    string path;
    
    bool operator < ( const Puzzle &p ) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {
    -1, 0, 1, 0
};
static const int dy[4] = {
    0, -1, 0, 1
};
static const char dir[4] = {
    'u', 'l', 'd', 'r'
};

bool isTarget(Puzzle p) {
    for (int i = 0; i < N2; i++) {
        if (p.f[i] != (i + 1)) return false;
    }
    return true;
}

string bfs(Puzzle s) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;
    
    while( !Q.empty()) {
        u = Q.front();
        Q.pop();
        if ( isTarget(u)) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for (int r = 0; r < 4; r++) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if ( !V[v]) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    
    return "unsolvable";
}

int main() {
    Puzzle in;
    
    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    
    return 0;
}


Measured memory_bytes: 30640
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

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

const int MAXN = 100005;

vector <int> adj[MAXN];
int n, f[MAXN];

inline void Dfs(int x)
{
	for (auto y : adj[x])
		Dfs(y);
	sort(adj[x].begin(), adj[x].end(), [&](int a, int b) { return f[a] > f[b]; });
	for (int i = 0; i < adj[x].size(); i ++)
		f[x] = max(f[x], f[adj[x][i]] + i + 1);
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 2; i <= n; i ++)
		adj[Read()].pb(i);
	Dfs(1);
	return printf("%d\n", f[1]), 0;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 1e5+10;
template <typename tp> inline void read(tp &x)
{
    x=0;char c=getchar();int f=0;
    for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
    for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
    if(f) x=-x;
}
int n,x[N],zz,mm;
bool cmp(int a,int b){return a>b;}
int main()
{
    read(n);
    for(int i=1;i<=n;i++) read(x[i]);
    sort(x+1,x+n+1,cmp);
    for(int i=0;i<=n;i++) if(x[i+2]<=i+1) {mm=i;break;}
    for(int i=1;i<=n;i++) if(x[i]>mm) zz=i;
    if((x[mm+1]-mm)%2==1&&(zz-mm)%2==1) puts("Second");
    else puts("First");
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



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

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

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

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

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

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


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

  for (i = 0; i < n; i++) {
    scanf("%s", com);
    if (com[0] == 'f') {
      
    } else if (com[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'd') {
      
    }
  }

  return 0;
}



Measured memory_bytes: 25244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')s[i]='9';
        else s[i]='1';
    }
    cout<<s<<endl;
    return 0;
}


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

 
int main() {
  int N;
  int D;
  int count=0;
  cin >>N>>D;
  for(int i=0;i<N;i++){
    long a;
    long b;
    cin >>a>>b;
    long A=abs(a);
    long B=abs(b);
    long long R=A*A+B*B;
    
    if(pow(R,0.5)<=D){
      count++;
    }
  }
  cout <<count;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int n; cin>>n;
int a[n+1];
rep(i,n){
    cin>>a[i+1];
}//ここまで入力
int now=1,count=0;
map<int,bool> m; //ボタンがついたことあるかどうかをみる
while(now != 2){ //今光っているのが2じゃない場合
 count++; //回数1回増やす
 if(m[now]){  //2回目に来てしまっていたらループしちゃうので終了
     cout<<-1<<endl;
     return 0;
 }else
 {
     m[now] = true;//一回来たことを確認
     now = a[now];//今のついてるボタンを更新
 }
 
}
cout<<count<<endl;//出力
    return 0;
}


Measured memory_bytes: 8552
#include <bits/stdc++.h>
#include <iostream>
#include <string>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 a, b, k;
  cin >> k >> a >> b;

  if (((float)a / k) <= (int)(b / k))
    cout << "OK";
  else
    cout << "NG";

  return 0;
}


Measured memory_bytes: 3612
def solve():
  ans = 0
  N = int(input())
  A = list(map(int, input().split()))
  lis = [0]*(10**5+2)
  for i in range(N):
    lis[A[i]-1] += 1
    lis[A[i]] += 1
    lis[A[i]+1] += 1
  ans = max(lis)
  return ans
print(solve())

Measured memory_bytes: 20628
#include <bits/stdc++.h>
using namespace std;
#ifdef _LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define _n "\n"



void Main()
{
	int X,N;
	cin>>X>>N;
	vec(v,N);
	vin(v);
	int ans=-1;
	int l=X, s=X;
	sort(all(v));

	rep(i,N){
		if(l==v[i])l++;
		if(s==v[N-1-i])s--;
	}

	if(abs(s-X) <= abs(X-l))ans = s;
	else ans = l;
	cout<<ans<<_n;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

int main(){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    
    
    if(a< b && b<c){
        string str = "Yes";
        cout << str << endl;
    }

    else{
        string str = "No";
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long X = nextLong();

        long a = 100;
        for(long i=1; ;i++){
            a = (long)(a*1.01);
            if(a >= X){
                println(i);
                return;
            }
        }
        //println((int)Math.ceil(Math.log(X/100.0)/Math.log(1.01)));
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

int M = 998244353;
int powmod(int a, int n) {
    int res = 1;
    for (int i = 0; i < n; ++i) {
        res *= a;
        res %= M;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,k;
    cin >> n>>k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int sum = 0;
    for (int i = 0; i < k; ++i) {
        sum += a[i];
    }
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3656
N,X,Y = map(int, input().split())
answer= [0]*(N-1)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i==j:
            break
        ans=i-j
        if j<=X and i<=Y and i>=X and Y-i+1+X-j<ans:
            ans=Y-i+1+X-j
        if j<=X and i>=Y and i-Y+1+X-j<ans:
            ans=i-Y+1+X-j
        if j>=X and j<=Y and i>=Y and i-Y+1+j-X<ans:
            ans=i-Y+1+j-X
        if j>=X and j<=Y and i>=X and i<=Y and Y-i+1+j-X<ans:
            ans=Y-i+1+j-X
        answer[ans-1]=answer[ans-1]+1
for k in range (1,N):
    print(answer[k-1])


Measured memory_bytes: 3444
import java.util.*;

public class Main {

    static class Pair implements Comparable<Pair>{
        int count=0;
        int val=0;
        Pair(int x , int y){
            this.count = x;
            this.val = y;
        }
        @Override
        public int compareTo(Pair o) {
            return  o.count - this.count;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        TreeMap<String, PriorityQueue<Pair>> tm = new TreeMap<>();
        for (int i = 0; i < N; i++) {
            String c = sc.next();
            Integer p = sc.nextInt();
            if(!tm.containsKey(c)){
                PriorityQueue<Pair> pq = new PriorityQueue<>();
                pq.add(new Pair(p,i));
                tm.put(c,pq);
            }else{
                PriorityQueue<Pair> pq = tm.get(c);
                pq.add(new Pair(p,i));
            }
        }

        for(Map.Entry<String, PriorityQueue<Pair>> e: tm.entrySet()){
            PriorityQueue<Pair> pq = e.getValue();
            while(!pq.isEmpty()){
                Pair pair = pq.poll();
//                System.out.println(e.getKey() +" "+ (pair.count)+" "+  (pair.val+1));
                System.out.println( (pair.val+1));
            }
        }
    }
}


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

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  if(N%2==0){
   for(int i=0;i<N/2;i++){
     if(S.at(i)!=S.at(N/2+i)){
      cout<<"No"<<endl;
      break;
      }
     if(i==N/2-1){
       cout<<"Yes"<<endl;
     }  
   }
  }
  else{
   cout<<"No"<<endl;
  }
}

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

int main() {
  int h,n;
  cin >> h >> n;
  int a;
  rep(i,n) {
    cin >> a;
    h -= a;
    if (h <= 0) break;
  }
  string result = h <= 0 ? "Yes" : "No";
  cout << result;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n, pos[maxn], pre[maxn], cnt[maxn];
int read() {
    int x=0; char ch, c=getchar();
    while(c<'0' || c>'9') ch = c, c=getchar();
    while(c>='0' && c<='9') x=x*10+c-'0', c=getchar();
    if(ch=='-') x=-x;
    return x;
}
inline bool check(int x, int y, int z) { return ((x<y) + (y<z) + (z<x) == 2); }

int main() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i) pos[read()] = i;
    for (int i=n-1; i; --i) {
        if(!cnt[i+1]) {
            if(pos[i+1]>pos[i]) cnt[i] = 0;
            else cnt[i] = 1, pre[i] = i+1;
        } else {
            if(check(pos[pre[i+1]], pos[i], pos[i+1])) cnt[i] = cnt[i+1], pre[i] = pre[i+1];
            else cnt[i] = cnt[i+1]+1, pre[i] = i+1;
        }
    }
    printf("%d\n", cnt[1]);
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
	
	int a;
	int t,n;
	int i;
	
	for(i=0;i<4;i++){
		scanf("%d %d",&t,&n);
		if(t==1)t=6000;
		if(t==2)t=4000;
		if(t==3)t=3000;
		if(t==4)t=2000;
		a=t*n;
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 1032
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"sort"
)
 
func run() {

	var N int;
    N = nextInt();
    d := make([]int,N);
    for i := 0 ; i < int(N) ; i++ {
        d[i] = nextInt();
    }
	solve(N, d);

}

func solve(N int, d []int){
	sort.Sort(sort.IntSlice(d))
	Println(d[N/2] - d[N/2-1])
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,z;
	cin >> s >> z;
	int count=0;
	for (int i = 0; i < s.size(); ++i)
	{
		if(s.at(i)!=z.at(i)){
			count++;
		}
	}
	if(count!=0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
	int n,max=0,h[101]={0};
	while(cin>>n){
		h[n]++;
		if(h[n]>max)max=h[n];
	}
	for(int i=1;i<=100;++i)if(h[i]==max)cout<<i<<"\n";
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, a, b)    for (int i = a; i <= (int) b; ++i)
#define ii              pair <int, int>
using namespace std;
const int N = 1e3 + 3;
int m, n, a[N][N], f[N][N][2], vis[N][N][2];

void init() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);
}

int get(int xo, int yo, int xi, int yi) {
    return a[xi][yi] + a[xo - 1][yo - 1] - a[xi][yo - 1] - a[xo - 1][yi];
}

int dp(int i, int j, int id) {
    int &shc = f[i][j][id], &foo = vis[i][j][id];
    if (foo) return shc;
    if (i == m || j == n) return shc = 0;
    shc = INT_MIN; foo = 1;
    if (id == 0) {
        if (i < m && j < n) {
            shc = max(shc, get(i + 1, j + 1, i + 1, n) - dp(i + 1, j, 1));
            shc = max(shc, - get(i + 1, j + 1, m, j + 1) - dp(i, j + 1, 1));
        }
    }
    else {
        if (i < m && j < n) {
            shc = max(shc, - get(i + 1, j + 1, i + 1, n) - dp(i + 1, j, 0));
            shc = max(shc, get(i + 1, j + 1, m, j + 1) - dp(i, j + 1, 0));
        }
    }
    return shc;
}

void solve() {
    cin >> n >> m;
    FOR(i, 1, m) FOR(j, 1, n) {
        int x; cin >> x;
        a[i][j] = a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1] + x;
    }

    cout << abs(dp(0, 0, 0)) << '\n';
}

main() {
    init(); solve();
}



Measured memory_bytes: 22964
r1,c1,r2,c2=map(int,input().split())
mod=pow(10,9)+7

# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
def cmb(n,r,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
g1=[1,1] # g1[i]=i! % mod　:階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod　:階乗の逆元
inverse=[0,1]
n=max(r1,c1,r2,c2)
for i in range(2,2*10**6+2):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)
ans=0
for k in range(r1,r2+1):
  tmp=cmb(k+1+c2,c2,mod)-cmb(k+1+c1-1,c1-1,mod)
  ans+=tmp
  ans%=mod
print(ans)

Measured memory_bytes: 222744
#include <stdio.h>
#include <string.h>
#define N 36
int isStable(char in[N][2],char out[N][2],int n);
int main(){
  int i,n,j,min;
  char a[N][2],b[N][2],c[N][2],change[3];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
    strncpy(b[i],a[i],2);
    strncpy(c[i],a[i],2);
  }

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(b[j][1] <b[j-1][1]){	
	strncpy(change,b[j],2);
	strncpy(b[j],b[j-1],2);
	strncpy(b[j-1],change,2);
      }
    }
  }
  for(i=0;i<n;i++){
    if(i<n-1) printf("%c%c ",b[i][0],b[i][1]);
    else printf("%c%c\n",b[i][0],b[i][1]);
  }
  if(isStable(&a[0],&b[0],n)==0) printf("Not stable\n");
  else printf("Stable\n");

     for(i=0;i<n;i++){
      min=i; 
      for(j=i;j<n;j++){
	if(c[j][1]<c[min][1])	  min=j;
      }
      if(i==min) continue;
       strncpy(change,c[i],2);
       strncpy(c[i],c[min],2);
       strncpy(c[min],change,2);
      }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%c%c ",c[i][0],c[i][1]);
      else printf("%c%c\n",c[i][0],c[i][1]);
    }
    if(isStable(&a[0],&c[0],n)==0) printf("Not stable\n");
    else printf("Stable\n");
    return 0;
}

int isStable(char in[N][2],char out[N][2],int n){
  
  int i,j,a,b;
  
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if(in[i][1]==in[j][1] && in[i][0]==out[b][0] && in[j][0] == out[a][0] && in[i][1]==out[b][1] && in[j][1] == out[a][1]){
	    return 0;
	  }
	}
      }
    }
  }
  return 1;
}

Measured memory_bytes: 620
import heapq
import math

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

A = list(map(lambda x: -x, map(int, input().split())))
heapq.heapify(A)

for i in range(M):
    tmp = heapq.heappop(A)
    tmp = math.ceil(tmp / 2)
    heapq.heappush(A, tmp)

print(-sum(A))

Measured memory_bytes: 14536
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    list<int> List;
    string S;
    
    for(int i = 0; i < N; i++){
        
        int X;
        cin >> S;
        
        // 入力・指定する数字を消すとき
        if(S.size() <= 6){
            cin >> X;
            
            // 入力するとき
            if(S[0] == 'i'){ List.push_front(X); }
            
            // 指定する数字を消すとき
            else{
                list<int>::iterator kasu_Posi = List.begin();
                while(kasu_Posi != List.end()){
                    if(*kasu_Posi == X){
                        List.erase(kasu_Posi);
                        break;
                    }
                    kasu_Posi++;
                }
            }
        }
        
        // 先頭を消すとき
        else if(S[6] == 'F'){ List.pop_front(); }
        
        // 最後尾を消すとき
        else{ List.pop_back(); }
    }
    
    // 出力する
    int i = 0;
    list<int>::iterator ans;
    for(ans = List.begin(); ans != List.end(); ans++){
        if(i++) cout << " ";
        cout << *ans;
    }
    cout << endl;
    
}



Measured memory_bytes: 34280