akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    ll n; cin >> n;
    map<ll, ll> m;
    ll x = n;
    for (ll i = 2; i * i <= n; i++) {
        if (x % i != 0) continue;
        int cnt=0;
        while(x % i == 0) {
            cnt++;
            x /= i;
        }
        m[i] = cnt;
    }
    if (x != 1) m[x] = 1;

    vector<ll> v(2000, 0);
    v[0] = 1;
    for (int i = 1; i < 2000; i++) {
        v[i] = v[i-1] + i + 1;
    }

    ll ans = 0;
    for (auto kv: m) {
        ll t = kv.second;
        rep(i, 2000-1) {
            if (v[i] <= t && t < v[i+1]) ans += i+1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <string>
#include <queue>
#include <numeric>

int main() {
  int x, y;
  scanf("%d %d", &x, &y);

  --x, --y;
  int third = 1e5;
  int second = 2e5;
  int first = 3e5;
  std::vector<int> a{first, second, third, 0};
  x = std::min(x, 3);
  y = std::min(y, 3);
  int bonus = 4e5;
  if (x == 0 && y == 0) {
    printf("%d\n", 2*first + bonus);
  } else {
    printf("%d\n", a[x]+a[y]);
  }
}


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

bool sqrt_is(double a){
	return (floor(sqrt(a))*floor(sqrt(a)) == a);
}

int main() {
	int a,b;
	cin >> a >> b;
	double N;
	
	if(b <= 9){
		N = 10*a + b;
	}else if(b <= 99){
		N = 100*a + b;
	}else{
		N = 1000*a + b;
	}
	
	if(sqrt_is(N)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o E_Bullet.exe E_Bullet.cpp 
Execute: ./E_Bullet
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
#include <map>
using namespace std;

long long gcd(long long a, long long b) {
  if(b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

long long power_mod(long long x, long long n, long long M) { 
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
} 


pair<long long, long long> make_orthogonal(long long a1, long long b1) {
	long long a, b;
	
	if(b1 < 0) {
		a = -a1;
		b = -b1; 
	} else {
		a = a1; 
		b = b1; 
	}

	if(a > 0)
		return (make_pair(-b, a));
	if(a == 0)
		return (make_pair(1,0));
	if(a < 0) 
		return (make_pair(b, -a));
		
	return (make_pair(0,0));
}


int main() { 	
	int n;
	long long a, b; 
	long long g; 
	long long mod = 1000000007ULL; 
	map<pair<long long, long long>, pair<int,int>> sardine_slopes; 
		// first = number parallel 
		// second = number orthogonal 
		
	sardine_slopes.clear(); 
		
	// Input and process the sardine slopes 
	cin >> n;
	long long num_zero = 0; 
	for(int i = 0; i < n; i++) {
		cin >> a >> b; 
		if(a==0 && b==0) {
			num_zero++; 
		} else {
			g = abs(gcd(a, b)); 
			a /= g; 
			b /= g; 
			if(b < 0) {
				a *= -1; 
				b *= -1; 
			}
			if(sardine_slopes[make_orthogonal(a,b)].first > 0) {
				sardine_slopes[make_orthogonal(a,b)].second++; 
			} else {
				if(b == 0 && a != 0) {
					sardine_slopes[make_pair(1,0)].first++; 
				}
				if(b > 0) {
					sardine_slopes[make_pair(a, b)].first++; 
				}
				if(b < 0) {
					sardine_slopes[make_pair(-a, -b)].first++; 
				}
			}
		}
	}
	
	long long result = 1, x, x1, x2; 
	
	// cout << "Iterate through elements" << endl; 
	for (map<pair<long long, long long>,pair<int, int>>::iterator it=sardine_slopes.begin(); it!=sardine_slopes.end(); it++) {
		if(it->second.first > 0) {
			x1 = power_mod(2, (it->second.first), mod); 
			x2 = power_mod(2, (it->second.second), mod); 
			x = (x1 + x2 - 1); 
			x %= mod; 
			result *= x; 
			result %= mod; 
		}
		/*
		cout << "(" << it->first.first << "," << it->first.second << ") -> " << it->second.first << " " << it->second.second << endl; 
		*/ 
	}
	
	result += mod - 1;
	result %= mod; 
	result += num_zero; 
	result %= mod; 
	
	// cout << "Result = "; 
	cout << result << endl; 

	
	return 0; 
} 


Measured memory_bytes: 28572
import math


def translate(color):
    ret = 0
    cnt = 0
    for c in color:
        if c == "f":
            num = 15
        elif c == "e":
            num = 14
        elif c == "d":
            num = 13
        elif c == "c":
            num = 12
        elif c == "b":
            num = 11
        elif c == "a":
            num = 10
        else:
            num = int(c)

        if cnt == 0:
            ret += num * 16
            cnt += 1
        else:
            ret += num

    return ret


color = ["black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"]
stlength = [[0, 0, 0], [0, 0, 255], [0, 255, 0], [0, 255, 255],
            [255, 0, 0], [255, 0, 255], [255, 255, 0], [255, 255, 255]]

while 1:
    n = input()
    if n == "0":
        break

    red = n[1:3]
    green = n[3:5]
    blue = n[5:7]

    red = translate(red)
    green = translate(green)
    blue = translate(blue)

    ans = 10**9
    for i, stl in enumerate(stlength):
        distance = math.sqrt(
            (stl[0]-red)**2 + (stl[1]-green)**2 + (stl[2]-blue)**2)
        if distance < ans:
            ans = distance
            name = color[i]

    print(name)



Measured memory_bytes: 5684
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) ((a>b)? b:a)
typedef long long ll;
bool judge(string tmp,ll n){
  if(tmp.find("3")!=std::string::npos){
    if(tmp.find("5")!=std::string::npos){
      if(tmp.find("7")!=std::string::npos){
        if(stoi(tmp)<=n){
          return true;
        }
      }
    }
  }
  return false;
}

int main()
{
  vector<string> st={"","3","5","7"};
  int n;
  cin>>n;
  set<string> vec;

  for(int j=0;j<4;j++){
    for(int j1=0;j1<4;j1++){
      for(int j2=0;j2<4;j2++){
        for(int j3=0;j3<4;j3++){
          for(int j4=0;j4<4;j4++){
            for(int j5=0;j5<4;j5++){
              for(int j6=0;j6<4;j6++){
                for(int j7=0;j7<4;j7++){
                  for(int j8=0;j8<4;j8++){
                    string tmp=st[j]+st[j1]+st[j2]+st[j3]+st[j4]+st[j5]+st[j6]+st[j7]+st[j8];
                    if(judge(tmp,n)){
                      vec.insert(tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<vec.size();        
}

    

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

const int N = 500009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

int n, U, V, x, y;
int dixu[N];
int dixv[N];
vector<int> v[N];

void dfs(int x, int p)
{
	for (auto &it : v[x])
	{
		if (it == p)
			continue;
		dixu[it] = dixu[x] + 1;
		dfs(it, x);
	}
}

void dfs1(int x, int p)
{
	for (auto &it : v[x])
	{
		if (it == p)
			continue;
		dixv[it] = dixv[x] + 1;
		dfs1(it, x);
	}
}

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> n >> U >> V;
	for (int i = 0; i < (n - 1); i++)
	{
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}

	dixu[U] = 0;
	dfs(U, -1);
	dixv[V] = 0;
	dfs1(V, -1);

	int ans = -1;

	for (int i = 1; i <= n; i++)
	{
		if (dixu[i] < dixv[i])
		{
			ans = max(ans, dixv[i] - 1);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, ma = 0, mi = 1001;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        ma = max(ma, a[i]);
        mi = min(mi, a[i]);
    }
    cout << ma - mi;
}


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

int main(){
	int a,b,c,d=0;
	cin>>a>>b>>c;
	for(int e=a;e<a*b;e+=a) if(e%b==c) d=1;
	if(d) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

ll num = 0;
ll ans[100051] = {0};

void saiki(string s){
    ll x = stoll(s);
    //cout << x << endl;
    if (x > 3234566667){
        return ;
    }
    ans[num] = x;
    num++;
    if (s.size() < 10)
    {
        if (s[s.size() - 1] != '0')
        {
            //cout << "saiki to " << s + char(s[s.size() - 1] - 1)<<endl;
            saiki(s + char(s[s.size() - 1] - 1));
        }
        saiki(s + char(s[s.size() - 1]));
        if (s[s.size() - 1] != '9')
        {
            saiki(s + char(s[s.size() - 1] +1));
        }
    }
}

int main()
{
    ll k;
    cin >> k;
    for (int i = 1; i < 10;i++){
        saiki(to_string(i));
    }
    sort(ans, ans + num);
    
    cout << ans[k - 1];
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(m)]

ypi=[[y,p,i] for i,(p,y) in enumerate(PY)]			#順番iはp,yより前に来る
ypi.sort()

from collections import defaultdict

d=defaultdict(int)
ans=[0]*m

for y,p,i in ypi:
	d[p]+=1
	ans[i]=str(p).zfill(6)+str(d[p]).zfill(6)
	
print(*ans,sep="\n")

Measured memory_bytes: 54148
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    def main():
        X=int(input())
        for a in range(-200,200):
            for b in range(-200,200):
                if pow(a,5)-pow(b,5)==X:
                    return [a,b]
    print(*main())

resolve()

Measured memory_bytes: 82152
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char a[4],b[4];
    while(cin>>a>>b){
        int flag=1;
        for(int i=0,j=strlen(a)-1;i<strlen(a);i++,j--){
            if(a[i]!=b[j]){
                cout<<"NO"<<endl;
                flag=0;
                break;
            }
        }
        if(flag)cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
cnt1 = 0
cnt2 = 0
for i in range(1,n+1):
    if i%k == 0: cnt1 += 1
    if i%k == k//2: cnt2 += 1
ans = cnt1**3 if k%2 == 1 else cnt1**3+cnt2**3
print(ans)     

Measured memory_bytes: 9196
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [x, y] = input[0].map(Number);

  const groupA = [1, 3, 5, 7, 8, 10, 12];
  const groupB = [4, 6, 9, 11];
  const groupC = [2];

  if (
    (groupA.includes(x) && groupA.includes(y)) ||
    (groupB.includes(x) && groupB.includes(y)) ||
    (groupC.includes(x) && groupC.includes(y))
  ) {
    return "Yes";
  } else {
    return "No";
  }
};

console.log(main(read()));


Measured memory_bytes: 29592
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> X[2];
	X[0].resize(N);
	X[1].resize(N);
	for(int i = 0; i < N; i++) cin >> X[0][i] >> X[1][i];
	for(int i = 1; i < N; i++) if((X[0][i]+X[1][i]-X[0][0]-X[1][0])%2 != 0) {
		cout << "-1\n";
		return 0;
	}
	vector<cat> lengths;
	for(int i = 0; i < 33; i++) lengths.push_back(1LL<<i);
	if((X[0][0]+X[1][0])%2 == 0) lengths.push_back(1);
	int L = lengths.size();
	cout << L << "\n";
	for(int i = 0; i < L; i++) cout << lengths[i] << ((i == L-1) ? "\n" : " ");
	for(int i = 0; i < N; i++) {
		string s;
		for(int j = 0; j < L; j++) s += '?';
		string dir = "UDLR";
		int d[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
		for(int j = L-1; j >= 0; j--) {
			cat maxdist = 0;
			for(int k = 0; k < j; k++) maxdist += lengths[k];
			cat l = lengths[j];
			for(int k = 0; k < 4; k++) {
				if(abs(X[0][i]-d[k][0]*l)+abs(X[1][i]-d[k][1]*l) > maxdist) continue;
				X[0][i] -= d[k][0]*l;
				X[1][i] -= d[k][1]*l;
				s[j] = dir[k];
				break;
			}
		}
		cout << s << "\n";
	}
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    int tmp, ans = 0;
    string s, x, y;

    cin >> n >> s;

    for (int i = 1; i < s.size(); i++) {
        x = s.substr(0, i);
        y = s.substr(i);
        tmp = 0;

        for (char c = 'a'; c <= 'z'; c++) {
            if (x.find(c) != string::npos && y.find(c) != string::npos) {
                tmp++;
            }
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local ior = io.input()
local n, k = ior:read("*n", "*n")
local v = {}
for i = 1, n do v[i] = ior:read("*n") end
local left = {}
local max = 0
for i_a = 0, n do
  local right = {}
  local clim = n - i_a
  for i_c = 0, n - i_a do
    local blim = mmi(i_a, k - i_a - i_c)
    for i_b = 0, blim do
      local dlim = mmi(i_c, k - i_a - i_c - i_b)
      for i_d = 0, dlim do
        local cand = 0
        for i_left = 1, i_a - i_b do
          cand = cand + left[i_left]
        end
        for i_right = 1, i_c - i_d do
          cand = cand + right[i_right]
        end
        max = mma(max, cand)
      end
    end
    if(i_c ~= clim) then
      table.insert(right, v[n - i_c])
      table.sort(right, function(x, y) return x > y end)
    end
  end
  if(i_a ~= n) then
    table.insert(left, v[i_a + 1])
    table.sort(left, function(x, y) return x > y end)
  end
end
print(max)


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vetcor<ll>
#define vii vector<pii>
#define vll vector<pll>
#define IOS ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
	int n;
	cin>>n;
	vi arr;
	vi correct;
	correct.assign(n, 0);
	
	for(int i = 0; i < n - 1; i++){
		int a;
		cin>>a;
		correct[a-1]++;
	}
	for(int i = 0; i < n; i++)
		cout<<correct[i]<<endl;
		
	return 0;
	
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    map<int, ll> freq;
    for(int i = 11; i <= n; i++){
        if(i % 10 == 0) continue;
        string s = to_string(i);
        int x = (s[0] - '0') * 10 + i % 10;
        freq[x]++;
    }
    for(int i = 1; i <= min(n, 9); i++){
        freq[i * 10 + i]++;
    }
    for(int i = 11; i < 100; i++){
        if(i % 10 == 0) continue;
        string s = to_string(i);
        reverse(s.begin(), s.end());
        int x = (s[0] - '0') * 10 + s[1] - '0';
        ans += freq[i] * freq[x];
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3684
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long diff[] = new long[num];
		for(int i = 0; i < num; i ++) {
			diff[i] = sc.nextLong();
		}
		Arrays.sort(diff);
		System.out.println(diff[num / 2] - diff[num / 2 - 1]);
	}
}

Measured memory_bytes: 61076
#include<stdio.h>

int main(void)
{
    int x, y;

    while(1){
scanf("%d %d", &x, &y);
if(x == 0 && y == 0)
break;

if(x < y)
printf("%d %d\n", x, y);
else
printf("%d %d\n", y, x);
}
    return 0;
}


Measured memory_bytes: 1972
import std.stdio;

void main() {
    size_t n, m;
    readf("%d %d\n", &n, &m);
    bool[30] loved, iter;
    loved[] = true;
    foreach (i; 0 .. n) {
        iter[] = false;
        bool first = true;
        size_t k, a;
        readf("%d", &k);
        foreach (j; 0 .. k) {
            readf(j == k - 1 ? " %d\n" : " %d", &a);
            iter[a-1] = true;
        }
        foreach (j; 0 .. m) {
            loved[j] &= iter[j];
        }
    }
    int result = 0;
    foreach (j; 0 .. m) {
        if (loved[j]) ++result;
    }
    writeln(result);
}


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

using namespace std;

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

#define PII pair<int, int>

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

#ifdef DBG
#define _log(item) cout << #item << " = " << item << endl
#define _loga(array, val) cout << #array << "[" << val << "] = " << array[val] << endl
#else
#define _log(item)
#define _loga(array, val)
#endif

inline int gcd(int number1, int number2)
{
    int m = number1;
    int n = number2;
    if (number2 > number1) {
        m = number2;
        n = number1;
    }
    while (m != n) {
        int temp = n;
        n = m - n;
        m = temp;
    }
    return m;
}
inline int lcm(int number1, int number2)
{
    return number1 * number2 / gcd(number1, number2);
}

//--------------------





signed main()
{
    string s;
    cin >> s;

    bool ok = true;

    rep(i, s.size()){
        if(i % 2 == 1){
            if(s[i] == 'R'){
                ok = false;
                break;
            }
        }
        else{
            if(s[i] == 'L'){
                ok = false;
                break;
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int h, w, n, md;
bool g[51][51];

void answer() {
    ll res = 0;
    ll base = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j]) res = (res+base) % md;
            base = 2*base % md;
        }
    }
    cout << "! " << res << endl;
}

int que(int ax, int ay, int bx, int by) {
    bx--; by--;
    cout << "? " << ay << " " << ax << " " << by << " " << bx << endl;
    int p;
    cin >> p;
    return p;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> h >> w >> n >> md;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            g[i][j] = (que(j, i, j+1, i+1) != 0);
        }
    }
    answer();
    return 0;
}



Measured memory_bytes: 724
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static long A, B, C, X, Y;
        

        
        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReaderL();
            A = input[0];
            B = input[1];
            C = input[2];
            X = input[3];
            Y = input[4];
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long ans = SINF;
            for(var i = 0; i <= Max(X, Y); i++)
            {
                long p = 2 * i * C;
                p += A * Max(0, X - i) + B * Max(0, Y - i);
                ans = Min(p, ans);
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

        

        

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }
}

    



Measured memory_bytes: 13268
from bisect import bisect

icase=1
if icase==1:
    n=int(input())
    a=[0]*n
    for i in range(n):
        a[i]=-int(input())
elif icase==2:
    n=5
    a=[-2,-1,-4,-5,-3]
elif icase==3:
    n=4
    a=[0,0,0,0]

def loopa():

    n=len(a)
    dp = [10**10]*(n+1)
    dp[0] = -10**10
    
    for i in range(n):
#        idx = bisect(dp, a[i]-1)
        idx = bisect(dp, a[i])
        dp[idx] = min(a[i], dp[idx])

#        print("i:",i,"a:",a,"dp2:",dp2)            
    return dp

dp=loopa()        

print(bisect(dp, 10**10-1)-1)    



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

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

    int n;
    ll sum;
    n = sum = 0;
    n = s.size() - 1;

    for (int bit = 0; bit < (1 << n); bit++)
    {
        int pos = s.size();
        int num = 0;
        for (int i = 0; i < (int)s.size(); i++)
        {
            pos--;
            num++;

            if (bit & (1 << i))
            {
                sum += stoll(s.substr(pos, num));
                num = 0;
            }
        }
        sum += stoll(s.substr(pos, num));
    }
    cout << sum << endl;

    return 0;
}


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

int main() {
  	long long int a, v, b, w, t;
  	long long int x = 0;
    long long int y = 0;
    int z = 0;
 	cin >> a >> v >> b >> w >> t;
  
    if(a < b)
  {
        x = a + v * t;
		y = b + w * t;
      
      if(x >= y){z = 1;}
    }
  else
  {
        x = a - v * t;
		y = b - w * t;
      
      if(x <= y){z = 1;}
  }
 
  
 
  
  if(z==1)
  {cout << "YES" << endl;}
    else
  {cout << "NO" << endl;}
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    int T1,T2;
    T1 = T2 = 0;
    int j = N - 1;
    int i = 0;
    while(i <= j){
        if(T1 <= T2) {
            T1 += W[i];
            W[i] = 0;
            i++;
        }
        if(T2 <= T1) {
            T2 += W[j];
            W[j] = 0;
            j--;
        }
        //cout << T1 << " " << T2 << endl;
    }
    //cout << T1 << " " << T2 << endl;
    cout << abs(T1-T2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int mon[200005];
int main()
{

	int n, maxv, minv;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> mon[i];
	maxv = mon[1] - mon[0];
	minv = mon[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, mon[i] - minv);
		if (mon[i] < minv)
			minv = mon[i];
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3860
//お勉強中

//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

inline void keisan(int &a, int &b, int c, int d) {
	int k = min(a, c);
	a = max(a, c);
	b = max(b, k);
	b = max(b, d);
}

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


	int N = getint();
	int n = 1 << N;
	int dp1[1 << 18], dp2[1 << 18];
	rep(i, n) {
		dp1[i] = getint();
		dp2[i] = 0;
	}

	rep(j, N) {
		for (int i = n - 1; i >= 0; i--) {
			if (i >> j & 1) keisan(dp1[i], dp2[i], dp1[i & ~(1 << j)], dp2[i & ~(1 << j)]);
		}
	}

	int saidai = 0;
	rep1(i, n - 1) {
		saidai = max(saidai, dp1[i] + dp2[i]);
		printf("%d\n", saidai);
	}

	Would you please return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<ll,ll> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<set<P>> a(n+1,set<P>());
    rep(i,m){
        int p,y;
        cin >> p >> y;
        // --p;
        a[p].insert(make_pair(y,i));
    }
    vector<P> ans(m);
    for(ll oya=1;oya<=n;oya++){
        if(a[oya].empty())continue;
        ll chk = 0;
        for(auto ele :a[oya]){
            P tmp = make_pair(oya,++chk);
            ans[ele.second] = tmp;
        }
    }
    rep(i,m){
        string res = "";
        rep(j,2){
            int keta = 1;
            ll tmp;
            if(j==0)tmp=ans[i].first;
            else tmp = ans[i].second;
            while(tmp/10>0){
                keta++;
                tmp/=10;
            }
            rep(_,6-keta){
                res.push_back('0');
            }
            string exp;
            if(j==0)exp = to_string(ans[i].first);
            else exp = to_string(ans[i].second);
            // if(j==0)res.push_back((char)ans[i].first+1);
            // else res.push_back((char)ans[i].second+1);
            res += exp;
            // cout << exp << endl;
        }
        cout<<res << endl;
    }
    return 0;
}

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

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

    std::vector<vector<int>> a(n, vector<int>(2));

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

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

    for ( int i = 0; i< n; i++ ){
        cout << a[i][1] << endl;
    }

    return 0;
}

Measured memory_bytes: 6272
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data.at(i);
    }
    int ans = X;
    for (int x : data) {
        ans += floor(D / x) + 1;
        if (D % x == 0) {
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))

a_dict = {}
for i in a:
    if a_dict.get(i, False):
        a_dict[i] += 1
    else:
        a_dict[i] = 1

def mC2(m):
    return m * (m - 1) // 2

sum = 0
for v in a_dict.values():
    sum += mC2(v)

for i, k in enumerate(a):
    ans = sum - (a_dict[k] - 1)
    print(ans)

Measured memory_bytes: 105444
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	map<string, int> S;
	int N;
	cin >> N;
	rep(i, N) {
		string Stmp;
		cin >> Stmp;
		S[Stmp]++;
	}
	rep(s, 4) {
		string Stmp;
		switch (s)
		{
		case 0:
			Stmp = "AC";
			break;
		case 1:
			Stmp = "WA";
			break;
		case 2:
			Stmp = "TLE";
			break;
		case 3:
			Stmp = "RE";
			break;
		}
		cout << Stmp << " x " << S[Stmp] << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict

n,m=map(int,input().split())
r=[list(map(int,input().split())) for _ in range(m)]
d=defaultdict(int)
for x in r:
  d[x[0]]+=1
  d[x[1]]+=1

for i in range(1,n+1):
  print(d[i])


Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int INF = (1<<20), nmax = 40, abmax = 10;
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];
int a[nmax], b[nmax], c[nmax];

int main(){
    int N, Ma, Mb; cin >> N >> Ma >> Mb;
    //vector<int> a(N), b(N), c(N);
    for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];

    for(int i=0; i<=N; i++) for(int j=0; j<=nmax*abmax; j++) for(int k=0; k<=nmax*abmax; k++) dp[i][j][k] = INF;
    dp[0][0][0] = 0;

    for(int i=0; i<N; i++){
        for(int ca=0; ca<=nmax*abmax; ca++){
            for(int cb=0; cb<=nmax*abmax; cb++){
                if(dp[i][ca][cb] == INF) continue;

                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i]);
            }
        }
    }

    int ans = INF;
    for(int ca=1; ca<=abmax*nmax; ca++){
        for(int cb=1; cb<=abmax*nmax; cb++){
            if(ca*Mb == cb*Ma) ans = min(ans, dp[N][ca][cb]);
        }
    }

    if(ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc(s);
	string s2="";
	fu(i,0,le(s)/2-1)s2.pb(s[i]);
	string s3=s2;
	reverse(all(s3));
	if(s3!=s2)re prN,0;
	s2="";
	fu(i,le(s)/2-1+2,le(s)-1)s2.pb(s[i]);
	s3=s2;
	reverse(all(s3));
	if(s3!=s2)re prN,0;
	s3=s;
	reverse(all(s3));
	if(s3!=s)re prN,0;
	prY;
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

int main(){
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  if(c[0][0] + c[1][1] + c[2][2] == c[0][0] + c[1][2] + c[2][1] && c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], m;
string s, t;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}


int32_t main(){_

   
   for (int i = 1; i <= 5; ++i)
   {
      int x;
      cin >> x;
      if (x == 0){
         cout<<i;
         exit(0);
      }
   }
   

   return 0;
}

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

int main(){
  deque<long> v;
  long q, a, b, c;
  cin >> q;
    while(q--){
      cin >> a >> b;
      if(a != 0){
        if(a == 2){
          if(b == 0) v.pop_front();
            else v.pop_back();
        }
        else cout << v.at(b) << endl;;
      }
      else{
        cin >> c;
        if(b == 0) v.push_front(c);
        else v.push_back(c);
      }
    }
}


Measured memory_bytes: 6160
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();
		long K = scan.nextLong();

		int[] A = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}

		//WK変数
		int result = 1;

		LinkedHashSet<Integer> set = new LinkedHashSet<>();
		set.add(result);

		//演算
		for (long i = 0L; i < K; i++) {
			result = A[result - 1];
			if (set.contains(result)) {
				break;
			} else {
				set.add(result);
			}
		}

		int first = 0;

		if (set.size() != K + 1) {
			int position = 1;
			for (int ele : set) {
				if (result == ele) {
					first = position;
					break;
				}
				position++;
			}
			int p = 1;
			for (int ele : set) {
				if (p == first + ((K + 1 - first) % (set.size() + 1 - first))) {
					result = ele;
					break;
				}
				p++;
			}
		}

		//結果出力
		System.out.println(result);
	}
}

Measured memory_bytes: 65052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string s;
	string t;
	cin >> s >> t;
	int count = 0;
	rep(i, s.size()) {
		if (s[i] != t[i]) {
			count ++;
		}
	}
	cout << count << endl;
}
	

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
main(){
  int n,c,k;cin >> n >> c >> k;
  vector<int> t(n);for(int i=0;i<n;i++) cin >> t[i];
  sort(t.begin(),t.end());
  int ans=0;
  for(int i=0;i<n;){
    ans++;
    int j=i;
    while(i<n && t[i]-t[j]<=k && i-j<c) i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3740
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    N *= 3;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
    } 
    sort(retu.begin(),retu.end());
    reverse(retu.begin(),retu.end());
    long long ans = 0;
    N /= 3;
    for(int i = 1;i<=N*2;i += 2){
        ans += retu.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<ctype.h>

int main(void)
{
  char name[1000] = {0};
  int i=0;

  gets(name);
  while(name[i] != '\0'){
    name[i] = toupper(name[i]);
    printf("%c",name[i]);
    i++;
  }
  putchar('\n');
  
  return 0;
}

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

using namespace std;


#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define siii(a, b, c) scanf("%d %d %d", &a, &b, &c)

#define sl(a) scanf("%I64d", &a)
#define sll(a, b) scanf("%I64d %I64d", &a, &b)
#define slll(a, b, c) scanf("%I64d %I64d %I64d", &a, &b, &c)

#define outi(a) printf("%d\n", a)
#define outii(a, b) printf("%d %d\n", a, b)
#define outiii(a, b, c) printf("%d %d %d\n", a, b, c)

#define outl(a) printf("%I64d\n", a)
#define outll(a, b) printf("%I64d %I64d\n", a, b)
#define outlll(a, b, c) printf("%I64d %I64d %I64d\n", a, b, c)

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))


#define fr(i, n) for(ll i=0; i<n;i++)
#define fr1(i, n) for(ll i=1; i<=n;i++) 

#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL)

template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

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

vector<pair<int, string> > ps;

string x, ac = "AC";

int got[100005], ind, wa[100005];

int main()
{
	fastio();

	int n, m, cnta = 0, cntw = 0;

	cin>>n>>m;

	fr(i,m){
		cin>>ind>>x;

		ps.push_back({ind, x});
	}
	fr(i, n+1){
		got[i] = 0;
	}
	fr(i,m){
		ind = ps[i].ff;
		x = ps[i].ss;

		if(!got[ind]){
			if(x == ac){
				cnta++;
				got[ind] = 1;
				cntw += wa[ind];
			}
			else
				wa[ind]++;
		}
	}

	cout<<cnta<<" "<<cntw<<"\n";
	

    return 0;
}


Measured memory_bytes: 7280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<int> A(N),B(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];

  rep(i,N){
    A[i]--;B[i]--;
  }

  vector<ll> an(N,0),bn(N,0);
  rep(i,N) an[A[i]]++;
  rep(i,N) bn[B[i]]++;

  rep(i,N){
    if(N-an[i]<bn[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }

  vector<int> ord(N,0);
  rep(i,N) ord[i]=i;
  sort(all(ord),[&](int a,int b){
      if(an[A[a]]==an[A[b]]){
          if(bn[A[a]]==bn[A[b]]) return a<b;
          else bn[A[a]]>bn[A[b]];
      }else an[A[a]]>an[A[b]];
  });

  vector<int> ans(N,-1);
  vector<int> deg(N,0);
  rep(i,N) deg[i]=an[i];

  set<tuple<int,int,int>> se;
  rep(i,N){
    if(bn[i]==0) continue;
    se.insert(mkt(-deg[i],-bn[i],i));
  }

  for(auto i:ord){
    auto itr=se.begin();
    int ft=get<2>(*itr);
    int tval=A[i];
    if(tval==ft){
      ++itr;
      int st=get<2>(*itr);
      ans[i]=st;
      se.erase(itr);
      bn[st]--;
      if(bn[st]>0) se.insert(mkt(-deg[st],-bn[st],st));
      if(bn[tval]){
        se.erase(mkt(-deg[tval],-bn[tval],tval));
        deg[tval]--;
        se.insert(mkt(-deg[tval],-bn[tval],tval));
      }
    }else{
      ans[i]=ft;
      se.erase(itr);
      bn[ft]--;
      if(bn[ft]>0) se.insert(mkt(-deg[ft],-bn[ft],ft));
      if(bn[tval]){
        se.erase(mkt(-deg[tval],-bn[tval],tval));
        deg[tval]--;
        se.insert(mkt(-deg[tval],-bn[tval],tval));
      }
    }
  }
  cout<<"Yes"<<endl;

  rep(i,N) cout<<ans[i]+1<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 22728
function main(input) {
    const args = input.split(' ');

    var A = parseInt(args[0], 10);
    var B = parseInt(args[1], 10);
    var C = parseInt(args[2], 10);

    if( A === B && A === C && B === C) {
        console.log('Yes')
    } else {
        console.log('No')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

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

// chmax, chmin
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;
}


long long infinite(long long A, long long B, long long N) {
    return __gcd<ll>(A, B) == A - B && N - 1 - B > A;
}


ll sum[30][30][100010];


long long simulate(long long A, long long B, vector<ll> &s) {
    if (infinite(A, B, s.size())) return -1e18;

    ll x = A;
    ll sc = s[A];

    int k = (s.size() - 1 - B) / (A - B);
    assert((s.size() - 1 - B) % (A - B) == 0);

    if (A - B < 20) {
        sc += sum[A - B][0][(k - 1) * (A - B)];
        sc += sum[A - B][A % (A-B)][(k - 1) * (A - B) + A] - sum[A - B][A % (A-B)][A];
    } else {
        for (int i = 0; i <= k - 1; i++) {
            sc += s[i * (A - B)];
        }
        for (int i = 1; i <= k - 1; i++) {
            sc += s[i * (A - B) + A];
        }
    }
    return sc;
}

vector<long long> get_divisors(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(n / i);
            if (i != n / i)ret.push_back(i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


void solve(long long N, std::vector<long long> S) {
    //N = 100000;
    //S.resize(N, 1);


    for (int d = 1; d < 20; d++) {
        for (int s = 0; s < 20; s++) {
            for (int i = s; i < N; i += d) {
                sum[d][s][i] += S[i];
            }
            for (int i = 1; i < N; i++) {
                sum[d][s][i] += sum[d][s][i - 1];
            }
        }
    }
    //N = 10000;
    //s.resize(N);
    // odd
    long long ans = 0;
    for (int B = 1; B <= N; B++) {
        if (N - 1 - B < 0) continue;
        auto ds = get_divisors(N - 1 - B);
        for (auto d : ds) {
            auto A = d + B;
            auto r = simulate(A, B, S);
            //assert((r == -44444) == infinite(A, B, N));
            //cout << A << " " << B << " " << r << " " << infinite(A, B, N) << endl;
            ans = max(ans, r);
        }
    }
    cout << ans << endl;
    cerr << "[]" << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> s(N - 1 - 0 + 1);
    for (int i = 0; i < N - 1 - 0 + 1; i++) {
        scanf("%lld", &s[i]);
    }
    solve(N, std::move(s));
    return 0;
}


Measured memory_bytes: 334976