akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int a = 0;//整数変数aを作る
	int b = 0;//整数変数bを作る

	cin >> a >> b;//2つの数字を受け取り、a.bに代入。
	
	cout << a * b<<endl;//a✕bを出力



	return 0;
}

Measured memory_bytes: 3608
while True:
    n,m = map(int,input().split())
    if n == 0:
        exit()
    t = []
    h = []
    num = []
    for i in range(n):
        t.append(int(input()))
    for i in range(m):
        h.append(int(input()))
    for i in range(n):
        for j in range(m):
            if (sum(t) - t[i] + h[j]) == (sum(h) - h[j] + t[i]):
                num.append([t[i] + h[j], t[i], h[j]])
    num = sorted(num)
    if len(num) != 0:
        print(str(num[0][1]) + " " + str(num[0][2]))
    else:
        print(-1)


Measured memory_bytes: 6508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

string divide[4] = { "dream","dreamer","erase","eraser" };

int main() {
	int N;
	int t[110000], x[110000], y[110000];
	cin >> N;
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
	}

	bool can = true;
	for (int i = 0; i < N; i++)
	{
		int dt = t[i + 1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < dist)can = false;
		if (dist % 2 != dt % 2) can = false;
	}

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;

	
}

Measured memory_bytes: 1408
n=int(input())
lista = []
for i in range(n):
    lista.append(int(input()))
#print(lista)
    
b=0
listb=[]
for i in range(n):
    if lista[i]!=0:
        b+=lista[i]
    elif lista[i]==0:
        listb.append(b)
        b=0
listb.append(b)


listb=list(map(lambda x: x//2,listb))
print(sum(listb))


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

int n, k, x, a[10];

bool f(int n) {
	while (n > 0) {
		if (a[n % 10]) return true;
		n /= 10;
	}
	return false;
}

int main() {
	cin >> n >> k;
	while (k--) {
		cin >> x;
		a[x] = true;
	}
	while (f(n)) n++;
	cout << n << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;

static const int MAX = 200000;

int main(void){
  int h,n;
  int r=0;
  cin>>h>>n;
  vector<int> a(n);
  for (int i=0;i < n; i++) {
    cin>>a[i];
    r += a[i];
  }
  string ans;
  if (r < h)
    ans = "No";
  else
    ans = "Yes";
  cout<<ans<<endl;
  
}


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

int H,W,N;

int go(vector<string> v){
	int lp = 1;
	while(lp){
		lp = 0;
		for(int i = H-2 ; i >= 0  ; i--){
			for(int j = 0 ; j < W ; j++){
				if(v[i][j] != '.' && v[i+1][j] == '.'){ lp = true; swap(v[i][j],v[i+1][j]);}
			}
		}
	}
	while(1){
		int del[31][31] = {};
		bool f = true;
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j <= W-N ; j++){
				bool ff = true;
				for(int k = 0 ; k < N ; k++){
					if(v[i][j+k] != v[i][j]){
						ff = false;
						break;
					}
				}
				if(ff){
					for(int k = 0 ; k < N ; k++){
						del[i][j+k] = true;
					}
				}
			}
		}
		for(int i = 0 ; i <= H-N ; i++){
			for(int j = 0 ; j < W ; j++){
				bool ff = true;
				for(int k = 0 ; k < N ; k++){
					if(v[i+k][j] != v[i][j]){
						ff = false;
						break;
					}
				}
				if(ff){
					for(int k = 0 ; k < N ; k++){
						del[i+k][j] = true;
					}
				}
			}
		}
		int lp = 1;
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				if(del[i][j])v[i][j] = '.';
		while(lp){
			lp = 0;
			for(int i = H-2 ; i >= 0  ; i--){
				for(int j = 0 ; j < W ; j++){
					if(v[i][j] != '.' && v[i+1][j] == '.'){ lp = true; f = false; swap(v[i][j],v[i+1][j]);}
				}
			}
		}
		if(!f) continue;
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				if(v[i][j] != '.') return false;
		return true;
	}
}
int main(){
	cin >> H >> W >> N;
	vector<string> v(H,string(W,' '));
	for(int i = 0 ; i < H ; i++)
			cin >> v[i];
	bool ans = 0;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W-1 ; j++){
			//if(v[i][j] == '.' || v[i][j+1] == '.') continue;
			swap(v[i][j],v[i][j+1]);
			ans = ans || go(v); 
			swap(v[i][j],v[i][j+1]);
		}
	}
	cout << (ans?"YES":"NO") << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};

int main(){

  string s;
  int i,j,k,l,n,m,ans=0;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;

  cin >> n;
  int a[n][n-1];
  int shouka[n] = {0},nshouka[n] = {0};
  int nokori=0.5*n*(n-1);
  int aite;
  int flg = 0;
  
  rep(i,0,n-1){
    rep(j,0,n-2)cin >> a[i][j];
  }
  while(nokori){
    rep(i,0,n-1){
      if(shouka[i] == n-1)continue;
      if(nshouka[i] == 1)continue;
      aite = a[i][shouka[i]];
    //  rep(j,0,n-2)cout << shouka[j] << endl;
      --aite;
      if(a[aite][shouka[aite]] == (i+1)){
        --nokori;nshouka[i]=1;nshouka[aite]=1;flg=1;
      }
    }
    if(flg == 0){
      cout << -1 << endl;
      return 0;
    }
  //  rep(i,0,n-1)cout << nshouka[i] <<  " ";
  //  cout << endl;
    rep(i,0,n-1){
      shouka[i]+=nshouka[i];
      nshouka[i] = 0;
    }
   // rep(i,0,n-1)cout << shouka[i] <<  " ";
   // cout << endl;
   // cout << nokori << endl;
    ++ans;flg = 0;
    
  }/*
    rep(i,0,n-1){
    rep(j,0,n-2)cout << a[i][j] << " ";
      cout << endl;
  }*/
  
  cout << ans << endl;

 
  return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n), b(n), c(n-1);
	for (int i=0; i<n; i++)
		cin>>a[i], a[i]--;
	for (int i=0; i<n; i++)
		cin>>b[i];
	for (int i=0; i<n-1; i++)
		cin>>c[i];
	int ret=0;
	for (int i=0; i<n; i++)
		ret+=b[a[i]];
	for (int i=0; i<n-1; i++)
		if(a[i]+1==a[i+1])
			ret+=c[a[i]];
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  int stones[k+1];
  memset(stones,-1,sizeof(stones));
  stones[0]=0;
  for(int i=0;i<n;i++)
  { cin>>a[i];
    stones[a[i]]=1;
  }
  for(int i=1;i<=k;i++)
  { if(stones[i]==-1)
    { stones[i]=0;
     for(int j=0;j<n;j++)
      {
        if(i>=a[j] && stones[i-a[j]]==0)
        { stones[i]=1;
          break;
        }
      }
    }
  }
  if(stones[k]==1)
  cout<<"First";
  else
    cout<<"Second";
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int key[105];
        rep(i,n){
            cin >> key[i];
        }
        string s;
        cin >> s;
        rep(i,s.size()){
            rep(j, key[i % n]){
                if(s[i] == 'a'){
                    s[i] = 'Z';
                }else if(s[i] == 'A'){
                    s[i] = 'z';
                }else{
                    s[i]--;
                }
            }
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1208
from collections import deque

n = int(input())
edge = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append([b-1, i])
    edge[b-1].append([a-1, i])

l = [len(i) for i in edge]
k = max(l)
root = l.index(k)

d = deque()
d.append([root, 0])
res = [0] * (n - 1)
while d:
    node, par_color = d.popleft()
    color = 0
    for e, idx in edge[node]:
        if res[idx] > 0:
            continue

        color += 1
        if color == par_color:
            color += 1
        d.append([e, color])
        res[idx] = color

print(k)
for c in res:
    print(c)

Measured memory_bytes: 87368
#include <cstdio>
#include <algorithm>

int a,b,c,ans;

int main()
{
  scanf("%d%d%d",&a,&b,&c);
  if(a>b)
    {
      std::swap(a,b);
    }
  if(b>c)
    {
      std::swap(b,c);
    }
  if(a>b)
    {
      std::swap(a,b);
    }
  ans+=c-b;
  a+=c-b;
  if((c-a)%2==1)
    {
      ++ans;
      ++c;
    }
  ans+=(c-a)/2;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    int n, m, a, b;
    cin >> n >> m;
    set<int> f, s;
    REP(i, 0, m)
    {
        cin >> a >> b;
        if (a == 1)
            f.insert(b);
        if (b == n)
            s.insert(a);
    }
    REP(i, 1, n + 1)
    {
        if (f.count(i) > 0 && s.count(i) > 0)
        {
            cout << "POSSIBLE" << endl;
            return;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    X, N = Scanner.map_int()
    P = Scanner.map_int()
    if N == 0:
        print(X)
        return
    t = INF
    for i in range(-1, 102):
        if i in P:
            continue
        t = min(t, abs(i - X))
    if X - t in P:
        print(X + t)
    else:
        print(X - t)


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10728
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 
int main(){
    int N; cin >> N;
    vector <int> A(N+1);
    rep(i,N) cin >> A[i];
    vector <bool> c(N,true);
    
    int i=0,cnt=1;
    while(A[i]!=2){
        if(!c[i]){
            cout << -1;
            return 0;
        }
        c[i]=false;
        i=A[i]-1;
        cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 640
import copy
a = [int(input()) for i in range(5)]
b = copy.deepcopy(a)
for i in range(len(a)):
    if str(a[i])[-1] != "0":
        a[i] = (a[i]//10+1)*10
l = [a[i]-b[i] for i in range(len(a))]
print(sum(a)-max(l))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  vector<vector<char>> a(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a.at(i).at(j);
    }
  }
  int count;
  vector<int> dx={1,0,-1,0,1,-1,-1,1},dy={0,1,0,-1,1,1,-1,-1};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)=='#')cout<<"#";
      else{
        count=0;
        for(int k=0;k<8;k++){
          if(i+dy.at(k)<0 or i+dy.at(k)>=H or j+dx.at(k)>=W or j+dx.at(k)<0)continue;
          else if(a.at(i+dy.at(k)).at(j+dx.at(k))=='#')count++;
        }
        cout<<count;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=2005;
int n,x,y,a[N];
int main()
{
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    if(n==1) printf("%d\n",abs(a[1]-y));
    else
        printf("%d\n",max(abs(a[n]-a[n-1]),abs(a[n]-y)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAX_M = 200010;
// code
//#define int long long
ll S, ans = 0  ; 
 
ll cnt(ll x) {
	if(x == 0) return 0;
	return cnt(x / 10) + 1;
}
 
ll pow_mod(ll x, ll y)
{
    if (!y) return 1;
    ll t = pow_mod(x, y / 2);
    if (y % 2) return t * t % mod * x % mod;
    return t * t % mod;
}
 
void Solve(){
    cin >> S;
    ll r = 1, sub = 0 ; 
    for (ll l = 1; l < 1e7; l++)
    {
        while (sub + cnt(r) <= S) sub += cnt(r), r++;
        if (sub == S) ans++;
        sub -= cnt(l);
    }  
    for (ll dig = 8; dig <= S; dig++){
        ll r = S % dig;
        if (r == 0){
            ans = (ans  + pow_mod(10, dig) - pow_mod(10, dig - 1) - S / dig + 1 + mod) % mod;   
            r = dig;
        }
        ll val = r * (dig + 1);
        ll c = 1ll * dig * (dig + 1);
        if (val < S) ans = (ans + (S - val) / c + ((S - val) % c > 0)) % mod;  
    }
    cout << ans % mod;
}
 
signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


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

bool IS_PRIME[100001];
int C_PRIME[100001];
int MAX_N = 100001;

void init_prime() {
  rep(i, MAX_N) {
    IS_PRIME[i] = true;
  }

  for(int i = 2; i <= MAX_N; i++) {
    if(!IS_PRIME[i]) continue;
    for(int j = i * 2; j <= MAX_N; j += i) {
      IS_PRIME[j] = false;
    }
  }

  for(int i = 3; i <= MAX_N; i += 2) {
    if(IS_PRIME[i] && IS_PRIME[(i + 1) / 2]) {
      C_PRIME[i] = 1;
    }
  }

  for(int i = 3; i <= MAX_N; i++) {
    C_PRIME[i] += C_PRIME[i - 1];
  }
}

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

  int Q;
  cin >> Q;
  init_prime();

  rep(i, Q) {
    int l,r; cin >> l >> r;

    cout << C_PRIME[r] - C_PRIME[l - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int max = 0,min = Integer.MAX_VALUE;
		for(int i=0;i<n;i++){
			int a = scanner.nextInt();
			max = Math.max(max, a);
			min = Math.min(min, a);
		}
		System.out.println(max - min);
	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<int> a(3 * N); rep(i, 0, 3 * N)cin >> a[i];
	sort(a.begin(), a.end()); reverse(a.begin(), a.end());
	lli ans = 0;
	rep(i, 0, N)ans += (lli)a[2 * i + 1];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

int main() {
	map<int, long long int> mp;
	long long int N, K, a, b;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		mp[a] += b;
	}
	map<int, long long int>::iterator it;
	for (it = mp.begin(); it != mp.end(); it++) {
		if (it->second >= K) { 
			cout << it->first;
			break;
		}
		else K -= it->second;
	}
}

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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    int ans = 0;
    for (int i = 0; i < 1000; i++)
    {
        string digit1 = to_string(i / 100);
        string digit2 = to_string((i / 10) % 10);
        string digit3 = to_string(i % 10);
        //cout << digit1 << digit2 << digit3 << endl;

        int base_offset = 0;
        int digit1_offset = 0;
        int digit2_offset = 0;
        int digit3_offset = 0;
        digit1_offset = s.find(digit1, base_offset);
        if (digit1_offset == -1)
        {
            continue;
        }
        // cout << "1:" <<digit1_offset << endl;
        digit2_offset = s.find(digit2, digit1_offset+1);
        if (digit2_offset == -1)
        {
            continue;
        }
        //cout << "2:"<< digit2_offset << endl;
        digit3_offset = s.find(digit3, digit2_offset+1);
        if (digit3_offset == -1)
        {
            continue;
        }
        //cout << "3:" << digit3_offset << endl;
        ans++;
        // cout << "ans" << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,K = [int(i) for i in input().split()]
AAA = [int(i) for i in input().split()]

count = [0 for i in range(200010)]
for A in AAA:
    count[A]+=1
ans=0
count=sorted([i for i in count if i!=0])

if len(count)<=K:
    print("0")
    exit()
else:
    print(sum(count[:-K]))

Measured memory_bytes: 25764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,k;
  string s;
  cin >> n >> k >> s;
  vl a(n);
  char c=s[0];
  ll j=0;
  a[0]=1;
  rep(i,n-1){
    if(c==s[i+1]){
      a[j]++;
    }
    else{
      j++;
      a[j]++;
    }
    c=s[i+1];
  }
  ll sum=0;
  ll x;
  rep(i,n){
    if(a[i]==0){
      x=i;
      break;
    }
  }
  rep(i,x){
    sum +=a[i]-1;
  }
  ll ans=min(sum+2*k,n-1);
  cout << ans << endl;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int N;
    int X[200000], Y[200000];

    cin >> N;
    for(int i = 0; i < N; i++) {
        int t;
        cin >> t;
        X[i] = Y[i] = t;
    }

    sort(X, X + N);

    int a = X[N / 2 - 1], b = X[N / 2];

    for(int i = 0; i < N; i++) {
        if(Y[i] <= a) cout << b << endl;
        else cout << a << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n;
    cin >> n;
    cout << ceil(n/2.0) << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
int main() {
	z = 0;
	vector<pair<long long int, long long int>>pairs;
	cin >> a >> b;
	rep(i, a) {
		cin >> x >> y;
		pairs.push_back(std::make_pair(x, y));
	}
	std::sort(pairs.begin(), pairs.end());
	rep(i, a) {
		if (z >= b) {
			break;
		}
		while (pairs[i].second > 0) {
			z++;
			
			counter += pairs[i].first;
			pairs[i].second -= 1;
			if (z>= b) {
				break;
			}
		}
	}
	cout << counter << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    static const double pi = 3.141592653589793;
    cout << fixed << setprecision(15) << sqrt(a * a + b * b - 2 * a * b * cos(abs((c / 12+d/720) - d / 60) * pi*2)) << endl;
}

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

int main(){
  int i,j,cnt=0;
  string s;
  int k;
  cin>>s;
  cin>>k;
  int n=s.size();
  int x[n];
  for(i=0;i<n;i++){
    x[i]=26-(int)(s[i]-'a');
    if(x[i]==26)x[i]=0;
  }
  for(i=0;i<n;i++){
    if(x[i]<=k){
      k-=x[i];
      x[i]=0;
    }
    if(i==n-1 && k!=0){
      x[i]=(x[i]+26-k%26)%26;
    }
  }
  for(i=0;i<n;i++){
    cout<<(char)((26-(int)x[i])%26+'a');
  }
}


Measured memory_bytes: 896
import sys
input=sys.stdin.readline

n,x,m=map(int,input().split())

l=[x]
check=[False]*m
check[x]=True
a=x

while True:
    a=a**2%m
    if check[a]:
        last=a
        break
    l.append(a)
    check[a]=True

for i in range(len(l)):
    if l[i]==last:
        index=i

start=l[0:index]
cycle=l[index:]

if n<len(start):
    ans=sum(start[0:n])
else:
    ans=sum(start)
    cn=(n-len(start))//len(cycle)
    cq=(n-len(start))%len(cycle)
    ans+=sum(cycle)*cn
    ans+=sum(cycle[0:cq])

print(ans)

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll X;
  cin >> X;

  ll ret = 0;
  ret += (X/500)*1000;

  X = X%500;

  ret += (X/5)*5;
  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	long int a, b, tmp;
	scanf("%ld %ld", &a, &b);
	long int x = a * b;

	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}

	long int r = a % b;
	while(r!=0){
	a = b;
	b = r;
	r = a % b;
	}
	
	printf("%ld", x/b);
	
return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int A=n/100,B=n%100;
	bool sw1=0,sw2=0;
	if(A<=12&&A>=1)
		sw1=true;
	if(B<=12&&B>=1)
		sw2=true;

	if(sw1&&sw2)
		cout<<"AMBIGUOUS"<<endl;
	else if(sw1&&!sw2)
		cout<<"MMYY"<<endl;
	else if(!sw1&&sw2)
		cout<<"YYMM"<<endl;
	else
		cout<<"NA"<<endl;
}



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

int main(){
  int n, k, l = 1;
  cin >> n >> k;
  rep(i,n){
    if (l > k)
      l += k;
    else
      l *= 2;
  }
  cout << l << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vector<int64_t> s(n);
    rep(i,n) cin >> s.at(i);
    int64_t sum = 0;
    rep(i,n) sum += s.at(i);
    if(sum%10!=0){
        cout << sum << endl;
    }else{
        sort(s.begin(), s.end());
        rep(i,n){
            if(s.at(i)%10 != 0){
                cout << sum - s.at(i) << endl;
                break;
            }
            if(i==n-1) cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N,M;
	ll P;
	cin >> N >> M >> P;
	Vec<int> A(M), B(M);
	Vec<ll> C(M);
	for(int i=0;i<M;i++){
		cin >> A[i] >> B[i] >> C[i];
		A[i]--; B[i]--;
		C[i]-=P;
	}
	
	
	ll Inf = (ll) 1e18;
	Vec<Vec<ll>> ma(N * 3 + 1);
	for(int i=0;i<N * 3 + 1;i++){
		ma[i].resize(N);
		for(int j=0;j<N;j++){
			ma[i][j] = -Inf;
		}
	}
	
	ma[0][0] = 0;
	for(int i=0;i<3*N;i++){
		for(int j=0;j<M;j++){
			int a = A[j];
			int b = B[j];
			ll c = C[j];
			if(ma[i][a] == -Inf) continue;
			ma[i + 1][b] = max(ma[i + 1][b], ma[i][a] + c);
		}
	}
	
/*	
	for(int i=0;i<=2*N;i++){
		ma[N-1][i] = max((ll) 0, ma[N-1][i] - i * P); 
	}
*/	
	ll ma0 = -Inf;
	for(int i=0;i<=N;i++){
		ma0 = max(ma0, ma[i][N-1]);
	}
	ll ma1 = -Inf;
	for(int i=N+1;i<=2*N;i++){
		ma1 = max(ma1, ma[i][N-1]);
	}
	ll ma2 = -Inf;
	for(int i=2*N+1;i<=3*N;i++){
		ma2 = max(ma2, ma[i][N-1]);
	}
	
	if(ma2 > ma1){
		cout << -1 << endl;
	} else {
		cout << max((ll) 0, max(ma1,ma0)) << endl;
	}
	
/*	
for(int i=0;i<=3*N;i++){
	for(int j=0;j<N;j++) cout << ma[j][i] << " ";
	cout << endl;
}	
*/	
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 147200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    ll n;
    cin >> n;
    vector <ll> a(n);
    rep(i,n) cin >> a[i];

    ll sum = max(a[0], -a[0]);
    rep(i,n-1) sum += max(a[i+1] - a[i], a[i] - a[i+1]);
    sum += max(a[n-1], -a[n-1]);

    vector <ll> ans(n);
    rep(i,n) ans[i];
    rep(i,n) {
        if (i == 0) ans[i] = sum - max(a[0], -a[0]) - max(a[1]-a[0], a[0]-a[1]) + max(a[1], - a[1]);
        else if (i == n - 1) ans[i] = sum - max(a[n-1], -a[n-1]) - max(a[n-1]-a[n-2], a[n-2]-a[n-1]) + max(a[n-2], -a[n-2]);
        else ans[i] = sum - max(a[i]-a[i-1], a[i-1]-a[i]) - max(a[i]-a[i+1], a[i+1]-a[i]) + max(a[i+1]-a[i-1], a[i-1]-a[i+1]);
    }

    rep(i,n) out(ans[i]);

    return 0;
}








Measured memory_bytes: 2816
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, K = map(int, input().split())
X, Y, C = [[0] * N for _ in range(3)]

mem = [[0] * (4 * K + 1) for _ in range(4 * K + 1)]

for i in range(N):
    S = input().split()
    X[i], Y[i], C[i] = int(S[0]), int(S[1]), S[2]
    x, y = X[i] % (2 * K) + 1, (Y[i] + (K if C[i] == "W" else 0)) % (2 * K) + 1
    mem[x][y] += 1
    mem[x + K][y] -= 1
    mem[x][y + K] -= 1
    mem[x + K][y + K] += 1

for h in range(1, 4 * K + 1):
    for w in range(1, 4 * K + 1):
        mem[h][w] += mem[h - 1][w] + mem[h][w - 1] - mem[h - 1][w - 1]

ans = 0
for h in range(K + 1):
    for w in range(K + 1):
        s = mem[h][w] + mem[h + 2 * K][w] + mem[h][w + 2 * K] + mem[h + K][w + K] + mem[h + 2 * K][w + 2 * K]
        ans = max(ans, s)

for h in range(K + 1):
    for w in range(K, 2 * K + 1):
        s = mem[h][w] + mem[h + 2 * K][w] + mem[h + K][w - K] + mem[h + K][w + K]
        ans = max(ans, s)


print(ans)

Measured memory_bytes: 167516
N = int(input())
A = list(map(int, input().split()))

def choose2(n):
    return int(n*(n-1)/2)

for i in range(N):
    A[i] -= 1

cnt = [0] * N
for i in range(N):
    cnt[A[i]] += 1
total = 0
for i in range(N):
    total += choose2(cnt[i])

for i in range(N):
    ans = total
    ans -= choose2(cnt[A[i]])
    ans += choose2(cnt[A[i]]-1)
    print(ans)


Measured memory_bytes: 26268
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
static const int Inf = 1 << 30;
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    vector<set<int>> clist(26, set<int>({Inf}));
    for (int i = 0; i < N; ++i)
    {
        clist[S[i] - 'a'].insert(i); // アルファベットがが何番目に現れるかを記録
    }

    for (int q = 0; q < Q; ++q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int ind;
            char c;
            cin >> ind >> c;
            --ind;
            char temp = S[ind];
            S[ind] = c;
            clist[temp - 'a'].erase(ind);
            clist[c - 'a'].insert(ind);
        }
        else
        {
            int left, right;
            cin >> left >> right;
            --left;
            int num = 0;
            for (int i = 0; i < 26; ++i)
            {
                if (clist.empty()) continue;
                int lid = *clist[i].lower_bound(left);
                //int rid = *clist[i].lower_bound(right);
                if (lid < right) ++num;
            }
            cout << num << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24196
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <string.h>
typedef long long ll;
const int KTINF = 1e9+7;

enum suit_enum { S, H, C, D, };
static const char *suitname = "SHCD";
static int cards[4][14];

int main(int argc, char **argv)
{
	int c, i, j, n, suit, rank;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf(" %c", &c);
		switch (c) {
		case 'S': suit = S; break;
		case 'H': suit = H; break;
		case 'C': suit = C; break;
		case 'D': suit = D; break;
		default:
			printf("foo");
			return 2;
		}
		scanf(" %d", &rank);
		cards[suit][rank] = 1;
	}
	for (i = 0; i < 4; i++) {
		for (j = 1; j < 14; j++) {
			if (!cards[i][j]) printf("%c %d\n", suitname[i], j);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin>>n>>k;
    vector<int> D(n);
    rep(i, n){
        cin>>D[i];
    }
    // 全探索
    int mnk = min(n,k);
    ll ans = 0;
    for(int a=0;a<=mnk;a++){
        for(int b=0;b<=mnk-a; b++){
            priority_queue<int, vector<int>, greater<int>> pq;
            // cerr<<a<<" "<<b<<" ";
            rep(i, a) {
                pq.push(D[i]);
            }
            rep(j, b){
                pq.push(D[n-1-j]);
            }
            rep(i, k-a-b){
                if(!pq.empty() && pq.top()<0){
                    // cerr<< "pop" << pq.top();
                    pq.pop();
                } else {
                    break;
                }
            }
            ll tmp = 0;
            while(!pq.empty()){
                tmp+= pq.top();
                pq.pop();
            }
            ans = max(tmp, ans);
            // cerr<<tmp<<endl;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define fread           freopen("input.txt","r",stdin)
#define fwrite          freopen("output.txt","w",stdout)
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define memo(ara,val)   memset(ara,val,sizeof(ara))
#define II              ( { int a ; read(a) ; a; } )
#define LL              ( { ll a ; read(a) ; a; } )
#define DD              ({double a; scanf("%lf", &a); a;})
#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,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              printf("\n")
#define sc(x)           scanf("%lld",&x)
#define scw(x)          scanf("%I64d",&x)
#define sci(x)          scanf("%d",&x)
#define sc2(x,y)        scanf("%lld %lld",&x,&y)
#define sc3(x,y,z)      scanf("%lld %lld %lld",&x,&y,&z)
#define Found(a, b)     a.find(b) != a.end()
// bool operator< (const node& sx) const { return sx.val < val; }
//set<ll,greater<ll> >st;
//priority_queue<ll , vector<ll> , greater<ll> >
template<class T>inline bool read(T &x){ int c=getchar();int sgn=1;
  while(~c&&c<'0'|c>'9'){if(c=='-')sgn=-1;c=getchar();}
  for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())x=x*10+c-'0';x*=sgn;return ~c;
}
const ll N = 300005;
const ll MOD = 1e9+7;
ll cost[N];
ll dp[N];
int main(){
   //fread;
    ll n = LL, k = LL;
    rep1(i,n) cost[i] = LL;
    rep1(i,n) dp[i] = 1e18;
    dp[1] = 0;
    for(ll i = 1; i<n; ++i){
        for(ll j = i+1, k1 = 1; j<=n && k1<=k; ++j, ++k1){
             dp[j] = min( dp[j] , dp[i] + abs(cost[i]-cost[j]) );
        }
    } pf(dp[n]),ln;
}











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

int main() {
  int a,b;
  cin>>a>>b;
  if((a+b)==15){
    cout<<'+'<<endl;
  }
  else if(a*b==15){
    cout<<'*'<<endl;
  }
  else{
    cout<<'x'<<endl;
  }
}

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

int main(){
  int N,M;
  cin >> N;
  vector<string> s(N);
  for (int i=0;i<N;i++){
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for (int i=0;i<M;i++){
    cin >> t.at(i);
  }
  string tmp_s;
  int score = 0;
  for (int i = 0;i<N;i++){
    int tmp_score = 0;
    if(!(s.at(i)=="")){
      tmp_s = s.at(i);
      for (int j=i;j<N;j++){
        tmp_score += (tmp_s == s.at(j));
        s.at(i) = "";
      }
      for (int j=0;j<M;j++){
        tmp_score -= (tmp_s == t.at(j));
      }
      score = (score>=tmp_score)*score + (score<tmp_score)*tmp_score;
    }else{
      continue;
    }
  }
  cout << score << endl;
  return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair

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

	#ifdef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
	#endif

    int n;
    cin >> n;
    int dp[4],a[4],t[4];
    cin >> dp[1] >> dp[2] >> dp[3];
    for(int i=1;i<n;i++) {
    	cin >> a[1] >> a[2] >> a[3];
    	t[1] = t[2] = t[3] = 0;
    	for(int j=1;j<=3;j++) {
    		for(int k=1;k<=3;k++) {
    			if(j == k) continue;
    			t[j] = max(t[j],dp[k] + a[j]);
    		}
    	}
    	dp[1] = t[1];
    	dp[2] = t[2];
    	dp[3] = t[3];
    	// cout << dp[1] << " " << dp[2] << " " << dp[3] << '\n';
    }
    cout << max(dp[1],max(dp[2],dp[3])) << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string S; cin >> S;
    S[K - 1] += -'A' + 'a';
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n / 100 == 7 || (n % 100) / 10 == 7 || n % 10 == 7) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 35780
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j]){
        ans++;
        break;
      }
    }
  }
  if(ans){
    cout<<"no"<<endl;
  }
  else{
    cout<<"yes"<<endl;
  }
}

Measured memory_bytes: 3600
#include<iostream>
#include<iomanip>
using namespace std;
main()
{

             long long x, n,k=0;
                cin>>n;
               long long MAX=n+1;

                for(int i=0;i<n;i++)
                {
                     cin>> x;
                     if(x<MAX)
                     {
                                     k++;
                                     MAX=x;
                     }
                }
                cout<<k<<endl;

}


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

const int MAX_N = 100000;
const long long INF = (long long) 9e+18;
typedef long long ll;

int main() {
	int N, K, h[MAX_N];

	std::cin >> N >> K;
	for(int i = 0; i < N; ++i) {
		std::cin >> h[i];
	}

	ll dp[MAX_N] = {};
	for(int i = 1; i < N; ++i) {
		dp[i] = INF;
		for(int j = 1; j <= K; ++j) {
			if(i - j < 0) break;
			dp[i] = std::min(dp[i], dp[i - j] + std::abs(h[i - j] - h[i]));
		}
	}

	std::cout << dp[N - 1] << std::endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(){
	int a,b,c,k;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	int max=0;
	if( max < a){
		max = a;
	}
	if(max<b){
		max=b;
	}
	if(max<c){
		max=c;
	}
	//もしもmaxがAならば
	if( max == a){
		for(int i=0;i<k;i++){
			max *= 2;
		}
		printf("%d",max+b+c);
		return 0;
	}
	if( max == b){
		for(int i=0;i<k;i++){
			max *= 2;
		}
		printf("%d",max+a+c);
		return 0;
	}
	if( max == c){
		for(int i=0;i<k;i++){
			max *= 2;
		}
		printf("%d",max+b+a);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128