akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!

N = int(input())
stair = list(range(1, N+1))
A = list(map(int, input().split()))

list = [[stair[i], A[i]] for i in range(N)]

list2 = sorted(list, key=lambda x : x[1])
list3 = [x for x,y in list2]

for i in list3 : 
    print(i)

Measured memory_bytes: 24128
// ABC177D Friends改改

#include<stdio.h>
int par[200001];//親
int siz[200001];//サイズ

void ini(int n){ //初期化
  for(int i=0;i<=n;i++){
    par[i] = i;
    siz[i] = 1;
  }
}

int root(int x){
    int count=0,s[200001];
    if(par[x] == x){
        for(int i=0;i<count;i++){
            par[s[i]] = x;
        }
        return x;
    }
    else{
        s[count] = par[x];
        count++;
        return par[x] = root(par[x]);
    }
}

void uni(int x, int y){ 
    x = root(x);
    y = root(y);
    if(x != y){
        if(siz[x] >= siz[y]){
            par[y] = x;
            siz[x] += siz[y];
        }
        else if(siz[x] < siz[y]){
            par[x] = y;
            siz[y] += siz[x];
        }
    }
}

int size(int x){ //サイズを返す
  return siz[root(x)];
}

int max(int x, int y){
  if(x>=y) return x;
  else return y;
}

int main(void){
  int n,m,a,b,ma=0;
  scanf("%d %d",&n,&m);
  ini(n);
  for(int i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    uni(a,b);
  }
  for(int i=1;i<=n;i++){
    ma = max(ma,size(i));
  }
  printf("%d",ma);
  return 0;
}

Measured memory_bytes: 3260
#2005_c
"""
n = int(input())
k = list("mcxi")
for i in range(n):
    d = {"m":0,"c":0,"x":0,"i":0}
    a,b  = input().split()
    a = list(a)
    b = list(b)
    a.insert(0,1)
    b.insert(0,1)
    for j in range(1,len(a)):
        if a[j] in k:
            if a[j-1] in k:
                d[a[j]] += 1
            else:
                d[a[j]] += int(a[j-1])
    for j in range(1,len(b))[::-1]:
        if b[j] in k:
            if b[j-1] in k:
                d[b[j]] += 1
            else:
                d[b[j]] += int(b[j-1])
            if d[b[j]] >= 10:
                l = b[j]
                while d[l] >= 10:
                    d[l] -= 10
                    l = k[k.index(l)-1]
                    d[l] += 1
    for j in k:
        if d[j]:
            if d[j] == 1:
                print(j,end = "")
            else:
                print(str(d[j])+j,end = "")
    print()
"""
#2017_c
while 1:
    h, w = map(int, input().split())
    if h == w == 0:
        break
    s = [list(map(int, input().split())) for i in range(h)]

    ans = 0
    for u in range(h):
        for d in range(u+2,h):
            for l in range(w):
                for r in range(l+2,w):
                    m = float("inf")
                    for i in range(u,d+1):
                        m = min(m,s[i][l],s[i][r])
                    for i in range(l,r+1):
                        m = min(m,s[u][i],s[d][i])
                    f = 1
                    su = 0
                    for i in range(u+1,d):
                        for j in range(l+1,r):
                            su += (m-s[i][j])
                            if s[i][j] >= m:
                                f = 0
                                break
                        if not f:
                            break
                    if f:
                        ans = max(ans,su)
    print(ans)



Measured memory_bytes: 5640
using System;
 
class P
{
  static void Main()
  {
    for(;;) {
      var s = Console.ReadLine().Split(' ');
      if(s[1] == "?") break;
      var a = int.Parse(s[0]);
      var b = int.Parse(s[2]);
      var r = 0;
      switch (s[1]) {
        case "+": r = a + b; break;
        case "-": r = a - b; break;
        case "*": r = a * b; break;
        case "/": r = a / b; break;
      }
      Console.WriteLine(r);
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string w[114];
	cin>>n;
	REP(i, n){
		cin>>w[i];
	}
	REP(i, n-1){
		if(w[i][w[i].size()-1]!=w[i+1][0]){
			cout<<"No"<<'\n';
			return 0;
		}
	}
	REP(i, n){
		REP(j, n){
			if(i!=j && w[i]==w[j]){
				cout<<"No"<<'\n';
				return 0;
			}
		}
	}
	cout<<"Yes"<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  vector<int>A(n);
  vector<int>ans(n);
  for(int i=0;i<n;i++) cin >> A[i];
  ans =  A;
  sort(All(A),greater<int>());
  int first = A[0];
  int second = A[1];
  for(int i=0;i<n;i++){
    if(ans[i]==first) cout<< second <<endl;
    else cout<< first <<endl;
  }

}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int answer;
    if (n % 2 == 1)
    {
        answer = n / 2 + 1;
    }else {
        answer = n / 2;
    }
    cout << answer << endl;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    vector<ll> B(N);
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll death = 0;

    for (int i = N - 1; i >= 0; i--) {
        for (int k = 1; k >=0; k--) {
            if (A[i + k] >= B[i]) {
                death += B[i];
                A[i + k] -= B[i];
                B[i] = 0;
            }
            else if (A[i + k] < B[i]) {
                death += A[i + k];
                B[i] -= A[i + k];
                A[i + k] = 0;
            }
        }
    }

    cout << death << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize(2)

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
using namespace std;
string buf;
bool istrue[100005];
bool issame[100005];
int n;

bool search(){
	for(int i=2;i<n;i++){
		if(istrue[i-1]){
			if(issame[i-1]){
				istrue[i]=istrue[i-2];
			} else {
				istrue[i]=(!istrue[i-2]);
			}
		} else {
			if(issame[i-1]){
				istrue[i]=(!istrue[i-2]);
			} else {
				istrue[i]=istrue[i-2];
			}
		}
	}
	bool ok;
	if(istrue[0]){
		if(issame[0]){
			ok=(istrue[1]==istrue[n-1]);
		} else {
			ok=(istrue[1]!=istrue[n-1]);
		}
	} else {
		if(issame[0]){
			ok=(istrue[1]!=istrue[n-1]);
		} else {
			ok=(istrue[1]==istrue[n-1]);
		}
	}
	if(istrue[n-1]){
		if(issame[n-1]){
			ok&=(istrue[n-2]==istrue[0]);
		} else {
			ok&=(istrue[n-2]!=istrue[0]);
		}
	} else {
		if(issame[n-1]){
			ok&=(istrue[n-2]!=istrue[0]);
		} else {
			ok&=(istrue[n-2]==istrue[0]);
		}
	}
	return ok;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	cin>>buf;
	rep(i,n){
		issame[i]=(buf[i]=='o');
	}
	rep(i,2){
		rep(j,2){
			istrue[0]=i;
			istrue[1]=j;
			if(search()){
				rep(i,n){
					cout<<(istrue[i]?'S':'W');
				}
				return 0;
			}
		}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 720
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans += gcd([i,j,k])

print(ans)

Measured memory_bytes: 75116
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1003;
ll i,j,n,m;
char a[N][N];
ll dp[N][N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n) rep(j,0,m) cin>>a[i][j];
    rep(i,0,n){
        if(a[i][0] == '#')
            break;
        dp[i][0] = 1;
    }
    rep(i,0,m){
        if(a[0][i] == '#')
            break;
        dp[0][i] = 1;
    }
    rep(i,1,n) rep(j,1,m){
        if(a[i][j] == '#')
            continue;
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
    }
    cout<<dp[n - 1][m - 1];
    return 0;
}

Measured memory_bytes: 9088
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a,b;
    cin >> a >>b;
    
    if(a>8 or b>8)
    {
        cout << ":(";
    }
    else
    {
        cout << "Yay!";
    }
}


Measured memory_bytes: 3000
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int T = cin.nextInt();
        long sum = 0;
        int last = 0;
        for (int i = 0; i < N; i++)
        {
            int t = cin.nextInt();
            sum -= Math.Max(0, last - t);
            sum += T;
            last = t + T;
        }
        Console.WriteLine(sum);
    }

    int[] uni;
    void init(int N)
    {
        uni = new int[N];
        for (int i = 0; i < N; i++)
        {
            uni[i] = -1;
        }
    }

    int root(int a)
    {
        if (uni[a] < 0) return a;
        else return uni[a] = root(uni[a]);
    }

    bool connect(int a, int b)
    {
        a = root(a);
        b = root(b);
        if (a == b) return false;
        if (uni[a] > uni[b]) swap(ref a, ref b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }  


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 28256
import math

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

MOD = int(1e9) + 7

s = pow(2, n, MOD)-1

def cbn(n, a, MOD):
    x = 1
    for i in range(a):
        x = (x * (n-i)) % MOD

    y = math.factorial(a) % MOD
    return x * pow(y, MOD-2, MOD) %MOD

s = (s- cbn(n, a, MOD)) %MOD
s = (s- cbn(n, b, MOD)) %MOD


print(s)

Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A = 0;
  string x;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x == "Y") {
      A++;
    }
  }
  if (A == 0) {
    cout << "Three";
  }
  else {
    cout << "Four";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,M;
map<string,int> mp;
bool e[200][200],ee[200][200];
int t[200];
void dfs(int x,int c){
	t[x]=c;
	rep(i,N){
		if(e[x][i]&&t[i]==0) dfs(i,-c);
		else if(e[x][i]) assert(t[i]==-t[x]);
	}
	rep(i,N){
		if(e[i][x]&&t[i]==0) dfs(i,-c);
		else if(e[i][x]) assert(t[i]==-t[x]);
	}
}
int main(){
	while(true){
		cin>>M;
		if(M==0) break;
		mp.clear();
		rep(i,200) rep(j,200) e[i][j]=0,ee[i][j]=(i==j);
		rep(i,200) t[i]=0;
		int J=0;
		rep(i,M){
			string st;
			cin>>st;
			int j=0;
			while(st[j]!='-') j++;
			string xx=st.substr(0,j),yy=st.substr(j+1);
			if(!mp.count(xx)) mp[xx]=J++;
			if(!mp.count(yy)) mp[yy]=J++;
			int x=mp[xx],y=mp[yy];
			e[x][y]=1;
		}
		N=mp.size();
		cout<<N<<endl;
		int I=1;
		rep(i,N) if(t[i]==0) dfs(i,I++);
		rep(i,N) rep(j,N){
			bool a=0,b=1;
			rep(k,N){
				if((e[i][k]||e[k][i])&&(e[j][k]||e[k][j])) a=1;
				if((e[i][k]&&e[k][j])||(e[j][k]&&e[k][i])) b=0;
			}
			if(a&&b) ee[i][j]=1;
		}
		rep(i,N) rep(j,N) e[i][j]|=ee[i][j];
		rep(i,N) rep(j,N) rep(k,N) if(e[j][i]&&e[i][k]) e[j][k]=1;
		int Q;
		cin>>Q;
		rep(tt,Q){
			string st;
			cin>>st;
			int j=0;
			while(st[j]!='-') j++;
			string xx=st.substr(0,j),yy=st.substr(j+1);
			if(!mp.count(xx)||!mp.count(yy)){
				puts("NO");
				continue;
			}
			int x=mp[xx],y=mp[yy];
			if(t[x]==-t[y]&&e[x][y]) puts("YES");
			else puts("NO");
		}
	}
}

Measured memory_bytes: 3216
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            String t = in.next();
            out.println(t.startsWith(s) ? "Yes" : "No");
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 33964
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int m,f,r;
	while(scanf("%d%d%d",&m,&f,&r)){
		if(m==-1&&f==-1&&r==-1) break;
		if(m+f>=80) printf("A\n");
		else if(m+f>=65&&m!=-1&&f!=-1) printf("B\n");
		else if(m+f>=50&&m!=-1&&f!=-1) printf("C\n");
		else if(m+f>=30&&m!=-1&&f!=-1){
			if(r>=50) printf("C\n");
			else printf("D\n");
		}
		else{
			printf("F\n");
		}
	}
	return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

struct UnionFind {
  vector<int> par;
  vector<int> sz;
  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      sz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sz[find(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(101010);
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    if (!uf.same(x, y)) {
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i == uf.find(i)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	if(n / 100 == n % 10) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

bool comp(P& x, P& y){
    int h1 = x.first;
    int w1 = x.second;
    int h2 = y.first;
    int w2 = y.second;

    int d1 = h1 * h1 + w1 * w1;
    int d2 = h2 * h2 + w2 * w2;

    if(d1 != d2){
        return d1 < d2;
    }
    return h1 < h2;
}

signed main(){
    vector<P> a;
    for(int i = 1; i < 150; i++){
        for(int j = i + 1; j < 150; j++){
            a.emplace_back(i, j);
        }
    }

    sort(a.begin(), a.end(), comp);

    while(true){
        int h, w;
        cin >> h >> w;

        if(h == 0 && w == 0){
            break;
        }

        rep(i, (int)a.size()){
            int hh = a[i].first;
            int ww = a[i].second;
            if(h == hh && w == ww){
                cout << a[i+1].first << " " << a[i+1].second << endl;
                break;
            }
        }
    }

    return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  
  int p[N];
  
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  
  sort(p, p+N);
  
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
N=int(input())
S={}
c={}
for i in range(N):
    s=''.join(sorted(input()))  
    if s in S:
        c[s]+=1
        if c[s]>=2:
            S[s]=S[s]+c[s]
        else:
            S[s]+=1

    else:
        S[s]=0
        c[s]=0
print(sum(S.values()))

Measured memory_bytes: 24172
#include<stdio.h>

int main(void){
    int n,m,x,y;
    int i;
    int x1,y1;
    int xmax = -100, ymin = 100;
    scanf("%d %d %d %d",&n,&m,&x,&y);
    for(i=0;i<n;i++){
        scanf("%d",&x1);
        if(x1>=xmax){
            xmax = x1;    // xiの最大値
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&y1);
        if(y1<ymin){
            ymin = y1;    //yiの最小値
        }
    }
    if(xmax<=x){
        if(x<ymin){
            printf("No War");
        }else{
            printf("War");
        }
    }
    if(xmax>x){
        if(xmax<ymin && xmax<y){
            printf("No War");
        }else{
            printf("War");
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            long tmp = sc.nextLong();
            if(tmp % 2 == 0) {
                a.add(tmp);
            }
        }
        int ans = 0;
        if(a.size() == 0) {
            System.out.println(ans);
            return;
        }
        for (int i = 0; i < a.size(); i++) {
            while(a.get(i) % 2 == 0) {
                a.set(i, a.get(i) / 2);
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;


ll solve(ll h)
{
    if(h == 1) return 1;
    ll res = solve(h/2);
    res*=2;
    return res + 1;
}

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

    ll h;
    cin >> h;
    cout << solve(h);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll big = 1e9;

int was[N];  
int main() 
{
    data();      
    int n;
    cin >> n;
    int a[n + 1];
    int gcd = 0;
    for (int i = 1; i <= n; i++)
    {
    	cin >> a[i];
    	was[a[i]]++;
    	gcd = __gcd(a[i], gcd);
    }
    int ok = 0;
    for (int i = 2; i <= 1e6; i++)
    {
    	if (was[i] >= 2)
    	{
    		ok = 1;
    	}
    	int kol = 0;
    	for (int j = i + i; j <= 1e6; j += i)
    	{
    		if (was[j])
    		{
    			kol++;
    		}
       	}
    	if (kol + was[i] >= 2)
    	{
    		ok = 1;
    	//	cout << i << '\n';
    	}
    }
    //cout << ok << '\n';
    if (ok == 0)
    {
    	cout << "pairwise coprime ";
    }
    else if (gcd == 1)
    {
    	cout << "setwise coprime ";
    }
    else if (ok == 1 && gcd > 1)
    {
    	cout << "not coprime";
    }
}
//a[3] * (a[1] + a[2]

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

using namespace std;
const int N = 2e5+10;
typedef long long ll;

int a[N];
ll sum[N];
int cmp(int a,int b)
{
    return a > b;
}
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        if(i != 0)sum[i] = sum[i - 1] + a[i];
        else sum[i] = a[i];
    }
    double d = 0;

    for(int i = k ;i <= n;i++)
    {
        double t = sum[i] - sum[i - k];
        d = max((t + k) / 2,d);
    }

    printf("%.9lf",d);

    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    ll x, y;
    cin >> x >> y;

    if (y > x) {
        cout << 0 << endl;
    } else {
        cout << x-y << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// ここからトピック9

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner.Split(bufio.ScanWords)
	query := strings.ToLower(nextString())
	count := 0
	for{
		str := nextString()
		if str == "END_OF_TEXT"{
			break
		}

		if strings.ToLower(str) == query{
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1084
import numpy as np
N,D=map(int, input().split())
X=np.zeros((D,N))
count=0;
for i in range(N):
    X[:,i]=np.array(input().split(),dtype=float)
for i in range(N-1):
    for k in range(i+1,N):
        dist=np.linalg.norm(X[:,i]-X[:,k])
        dist=dist.astype('float')
        if dist.is_integer():
            count=count+1
print(count)


Measured memory_bytes: 12508
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n;
  int num[20];
  cin>>n;
  int cnt=0,ans=1;
  for(int i=0;i<n;i++){
    cin>>num[i];
    ans*=3;
    if(num[i]%2==0)
      cnt++;
  }
  int min=1;
  for(int j=0;j<cnt;j++){
    min*=2;
  }
  cout<<ans-min<<endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll l,r; cin >> l >> r;
    if((r-l)>=2018) cout << 0 << endl;
    else{
        ll ans = 2019;
        for(ll i = l; i < r; ++i){
            for(ll j = i+1; j <= r; ++j){
                ans = min(ans, (i%2019)*(j%2019)%2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char tx[5][5];
    for(int i=0; i<2; i++)
    {
        for(int j=0; j<3; j++)
        {
            scanf(" %c",&tx[i][j]);
        }
    }
    if((tx[0][0]==tx[1][2])&&(tx[0][1]==tx[1][1])&&(tx[0][2]==tx[1][0]))
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
void func(int N,int next,string s) {
  if(N == 0) {
    cout << s << endl;
    return;
  }
  int i;
  for(i=0;i<=next;i++)func(N-1,max(next,i+1),s+(char)('a'+i));
}
int main() {
  int N;
  cin >> N;
  func(N,0,"");
}

Measured memory_bytes: 1536
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-01 15:31:45
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

class Combination {
 public:
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 2000 + 5;

  Combination() { build(); }

  std::array<int64, n_> fact_;
  std::array<int64, n_> inv_;
  std::array<int64, n_> finv_;

  // return nCk
  int64 get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return fact_[n] * (finv_[k] * finv_[n - k] % mod_) % mod_;
  }

 private:
  void build() noexcept {
    fact_[0] = 1;
    fact_[1] = 1;
    finv_[0] = 1;
    finv_[1] = 1;
    inv_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      fact_[i] = fact_[i - 1] * i % mod_;
      inv_[i] = mod_ - inv_[mod_ % i] * (mod_ / i) % mod_;
      finv_[i] = finv_[i - 1] * inv_[i] % mod_;
    }
  }
};

Combination kyomu;

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

  int n, k; cin >> n >> k;
  if (n > k) {
    cout << 0 << endl;
  } else {
    cout << kyomu.get(k, n) << endl;
  }

  return 0;
}


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

int main(){
    int n, a, b;

    cin >> n >> a;

    b = n / 500;
    n = n - 500*b;
    if(a>=n){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    ll n = S.size();
    ll ans = n*(n-1)/2;
    map<int, ll> mp;
    REP(i, n){
        mp[S[i]-'a']++;
    }
    for(auto&& m : mp){
        ans -= m.se*(m.se-1)/2;
    }
    pr(ans+1);
}

Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var values = input[0].split(' ');
    var n = parseInt(values[0], 10);
    var m = parseInt(values[1], 10);

    var ans = (1900 * m + 100 * (n - m)) * Math.pow(2, m);
    console.log(ans);

    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

void solve(){
    int N; cin >> N;
    vector<int> A(N);
    vector<int> alt(N);
    for(int i = 0; i < N ; ++i){
        cin >> A[i];
        alt[i] = A[i];
    }

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int it = lower_bound(alt.begin(), alt.end(), A[i]) - alt.begin();
        if (abs(it - i) % 2 == 1) ans++;
    }

    cout << ans/2 << '\n';
}



int main() {
    #ifdef MYLOCAL
    const int CASES = 2;
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 1024
import numpy as np
import math
import collections
import bisect
import itertools
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    counter = Counter(A)
    sumA = sum(A)
    # print(counter)
    for i in range(Q):
        b, c = map(int, input().split())
        if b in counter:
            if c in counter:
                counter[c] = counter[c] + counter[b]
            else:
                counter[c] = counter[b]
            sumA += (c - b) * (counter[b])
            del counter[b]
        print(sumA)


if __name__ == "__main__":
    main()


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

int main()
{
  long X;
  cin >> X;
  long h500, h5;
  h500 = X / 500;
  h500 *= 1000;
  X %= 500;
  h5 = X / 5;
  h5 *= 5;
  cout << h500 + h5 << endl;
}


Measured memory_bytes: 768
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
my $f = 0;
for my $i (1..length($n)-1) {
  $f = 1 if substr($n, $i, 1) < 9;
}
my $ans = 9 * (length($n) - 1);
$ans += (substr($n, 0, 1) - $f);
say $ans;

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

using namespace std;
int main()
{
    long long n, x, res = 0;
    vector<long long> burgerBuns(51);
    vector<long long> burgerPatty(51);

    cin >> n >> x;

    burgerBuns[0] = 1;
    burgerPatty[0] = 1;

    for (long long i = 1; i <= 50; ++i)
    {
        burgerBuns[i] = burgerBuns[i - 1] * 2 + 3;
        burgerPatty[i] = burgerPatty[i - 1] * 2 + 1;
    }

    while (n > 0 && x > 0)
    {
        x--;
        n--;
        if (x >= burgerBuns[n])
        {
            x -= burgerBuns[n];
            res += burgerPatty[n];
            if (x == 0)
            {
                break;
            }
            x--;
            res++;
            if (x >= burgerBuns[n])
            {
                res += burgerPatty[n];
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

int main() {
  int D;
  cin >> D;
  if (D == 25)
    cout << "Christmas" << endl;
  else if (D == 24)
    cout << "Christmas Eve" << endl;
  else if (D == 23)
    cout << "Christmas Eve Eve" << endl;
  else
    cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000


int main(){
    int k,x;
    cin>>k>>x;
    
    int tmp = 500*k;
    
    tmp >= x ? (cout << "Yes" << endl) : (cout << "No" << endl);
    

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a,b);
}

//degree → radian
ll chg_DegRad(ll deg) {
	return deg * PI / 180.0;
}

//radian → degree
int chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

ll a, b;



int main() {
	
	cin >> a >> b;
	cout << lcm(a, b) << endl;
	return 0;
}





Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
			String[] ary=br.readLine().split(" ");
			int H=Integer.parseInt(ary[0]);
	        int W=Integer.parseInt(ary[1]);
			if(H==0&&W==0) break;
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					if(i%2==0){
						if(j%2==0){
							sb.append('#');
						}else{
							sb.append('.');
						}
					}else{
						if(j%2==0){
							sb.append('.');
						}else{
							sb.append('#');
						}
					}
				}
				sb.append('\n');
			}
			sb.append('\n');
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 25100
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
int dp[100000][3]={};
ll dp2[300000][60]={};
int main() {
	int k,x;
	cin>>k>>x;
	if(500*k>=x){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  VI a(3 * n);
  rep(i, 3 * n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll ans = 0;
  rep(i, 2 * n) {
    if(i % 2 == 1)
      ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n, k;
	cin >> n >> k;
	vi l(n);
	rep(i, n)cin >> l[i];
	sort(all(l));

	int ans = 0;
	reprrev(i, l.size() - k, l.size()) {
		ans += l[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int x, t;
    cin >> x >> t;
    cout << max(0, x - t) ;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
typedef pair <pi,ll> pii;
typedef vector <pii> vpii;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int L;
vpii edges;

int msb;

int main(){
	fast;
	
	cin>>L;
	
	DEC(i,20,0){
		if (L & (1<<i)){
			msb = i;
			break;
		}
	}
	
	int N = msb + 1;
	
	FOR(i,1,N-1){
		edges.pb(pii(pi(i,i+1),0));
		edges.pb(pii(pi(i,i+1),(1 << (i-1))));
	}
	
	L -= (1<<msb);
	
	int mx = (1<<msb);
	FOR(i,0,20){
		if (L & (1<<i)){
			edges.pb(pii(pi(i+1,N),mx));
			mx += (1<<i);
		}
	}
	
	cout<<N<<' '<<edges.size()<<'\n';
	
	aFOR(i,edges){
		cout<<i.f.f<<' '<<i.f.s<<' '<<i.s<<'\n';
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
int a, b, c;
const int maxa = 1e5 + 1;
int n[maxa], x, y;
int main()
{
    cin >> a >> b >> c;
    for (int i = 0; i < a; i++)
        cin >> n[i];
    sort (n , n + a);
    for (int i = 0; i < a - 1; i++){
        if (i + 1 - x + 1 > b){
            y++;
            x = i + 1;
        }
        else if(n[i + 1] > n[x] + c){
        	y++;
            x = i + 1;
		}
    }
    y += 1;
    cout << y << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
using namespace std;
using llong = long long;

llong n, k;
llong x[3005];
llong y[3005];
unordered_map<double, llong> mp;
llong ans = 0;

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

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	for (int i = 0; i < n; i++) {
		mp.clear();
		for (int j = 0; j < n; j++) {
			if (i == j) continue;

			double idx = atan2(y[j] - y[i], x[j] - x[i]);
			mp[idx]++;

			if (mp[idx] >= k - 1) ans = 1;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3536