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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

bool pairCompare(const std::pair<string, priority_queue<int, vector<int>, greater<int> > >& firstElem, const std::pair<string, priority_queue<int, vector<int>, greater<int> > >& secondElem) {
  return firstElem.first < secondElem.first;
}


int main(){
	vector<pair<string, priority_queue<int, vector<int>, greater<int> > > > v;
	string s;int n;
	while(cin >> s >> n){
		bool b = false;
		for(int i=0; i < v.size(); i++) if(v[i].first == s){b = true; v[i].second.push(n); break;}
		if(!b){
			priority_queue<int, vector<int>, greater<int> > q;
			q.push(n);
			v.push_back(make_pair(s, q));
		}
	}
	sort(v.begin(), v.end(), pairCompare);
	for(int i=0; i< v.size(); i++){
		cout << v[i].first << endl;
		bool b = false;
		while(!v[i].second.empty()){
			cout << (b ? " " : "") << v[i].second.top(); b = true;
			v[i].second.pop();
		}
		cout << endl;
	}
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N=100000;
int a[N],i,c,j;
string s;
int main()
{
	cin >> s;
	for(i=0;i<3;i++)
	{
		if(s[i]=='1')
		c++;
	}
	cout << c;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define cin(a,n) for(i=0;i<n;i++){cin>>a[i];sum+=a[i];}
#define ll long long int
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rf1(i,a,n) for(int i=a;i>n;i--)
#define cases() int q;cin>>q;while(q--)
#define ld long double
#define cout(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define inf 1e9;
#define mod 1000000007;
using namespace std;
int main(){
 int k;
 string s;
 cin>>k;
 cin>>s;
 int n=s.size();
 if(n>k){
    s=s.substr(0,k)+"...";
 }
 cout<<s<<'\n';
return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <iterator>
#include <set>

using namespace std;

int main() {
  string s;
  int K;
  cin >> s >> K;
  set<string> S;
  for (int i = 0, n = s.size(); i != n; ++i) {
    for (int j = 1; j <= K; ++j) {
      if (i + j > n) break;
      string subs = s.substr(i, j);
      S.insert(subs);
    }
  }

  auto it = S.begin();
  advance(it, K - 1);
  cout << *it << endl;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int nx = 0, ny = 0;
    int t1 = 0,x1 = 0,y1 = 0;
    int t2 = 0,x2 = 0,y2 = 0; 
    for(int i = 0; i < n; i++){
        cin >> t2 >> x2 >> y2;
        int t = (t2 -t1);
        int d = abs(x2-x1) + abs(y2 - y1);

        if(t < d || t%2 != d%2){
            cout << "No" << endl;
            return 0;
        }
        t1 = t2; x1 = x2; y1 = y2;
        
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll dp[100100][26];

int main(void){
	int n,i,j;
	string s,t;
	fill(dp[0],dp[100100],0ll);
	cin >> n;
	cin >> s;
	cin >> t;
	for(i=0; i<n; ++i){
		s[i] -= 'a';
		t[i] -= 'a';
	}
	dp[0][s[0]] = 1ll;
	for(i=1; i<(n-1); ++i){
		for(j=0; j<26; ++j){
			add_mod(dp[i][j],dp[i-1][j]);
			if(j==s[i]){
				add_mod(dp[i][s[i]],dp[i-1][t[i]]);
			}
		}
	}
	cout << dp[n-2][t[n-1]] << endl;
	return 0;
}



Measured memory_bytes: 23628
#include<cstdio>

int main(){
    int a[44],n;
    a[0]=a[1]=1;
    for(int i=2;i<=44;i++) a[i]=a[i-1]+a[i-2];
    scanf("%d",&n);
    printf("%d\n",a[n]);
    return 0;
}

Measured memory_bytes: 1024
// agrawal117
//chahat agarwal
#include<bits/stdc++.h>  
#define mod 1000000007
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    ll arr[n];
    for(int i=0;i<n;i++){ cin>>arr[i];v[i]=arr[i];}
    sort(v.rbegin(),v.rend());
    // for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
    // cout<<endl;
    for(int i=0;i<n;i++){
        if(arr[i]==v[0]) cout<<v[1]<<endl;
        else cout<<v[0]<<endl;
    }
}


Measured memory_bytes: 4736
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b, c;
   string ans = "No";
   cin >> a >> b >> c;
   if ((a == b || b == c || c == a) && (a != b || a != c))
      ans = "Yes";

   cout << ans << endl;
   return 0;
}


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

int main() {
    int64_t n,k;
    cin >> n >> k;
    vector<int64_t> H(n);
    rep(i,n){
        cin >> H.at(i);
    }
    sort(H.begin(),H.end());
    int64_t ans = INF;
    rep(i,n-k+1){
        ans = min(ans,H.at(i+k-1)-H.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll n, k, res[200005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    ll ans = 0;
    erep(i, 1, n) res[i%k]++;
    rep(i, 0, k) {
      ll b = (k - i) % k;
      ll c = (k - i) % k;
      if ((b + c) % k != 0) continue;
      ans += res[i] * res[b] * res[c];
    }
    cout << ans << endl;
    return 0;
}



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

 using namespace std;

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

   int ans = 0;
   for (int i = 0; i <= N - 3; i++) {
     if (S.substr(i, 3) == "ABC") ans++;
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

char c[505][505];
int min_cost[505][505] = {{INF}};
const vector<int> dx = {1,0};
const vector<int> dy = {0,1};
int h,w;
vector<ll> ans;

void dfs(int x,int y,int count){
    if((x<0||x>h-1)||(y<0||y>w-1)) return;
    if (x == h-1 && y == w-1) {
        ans.push_back(count);
        return ;
    }
    if (c[x+1][y] == '.') {
        dfs(x+1,y,count);
    }
    if (c[x][y+1] == '.'){
        dfs(x,y+1,count);
    }
    if (c[x+1][y] == '#' && c[x][y+1] == '#'){
        count++;
        dfs(x+1,y,count);
        dfs(x,y+1,count);
    }
}

int main(void){
    // Your code here!
    int n; cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - n % 1000 << endl;
    }
}


Measured memory_bytes: 3688
# -*- coding: utf-8 -*-

# 青カードのリスト
blue_count = int(input())
blue_list = []
for i in range(blue_count):
	blue_list.append(input())
# 赤カードのリスト
red_count = int(input())
red_list = []
for i in range(red_count):
	red_list.append(input())

# 全単語リスト作成
all_words = []
# 赤青を連結
all_words.extend(blue_list)
all_words.extend(red_list)
# 重複を削除
all_words = list(set(all_words))

# 全単語でdictを作る
word_dict = {}
for word in all_words:
	word_dict[word] = 0
# 青カード分足す
for word in blue_list:
	word_dict[word] += 1
# 赤カード分引く
for word in red_list:
	word_dict[word] -= 1
# 結果値をリストに
result_list = []
for key, value in word_dict.items():
	result_list.append(value)
# 最大値を算出
result = max(result_list)
# 最大値が0以下なら0
if result <= 0:
	ans = 0
else:
	ans = result

print(ans)

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

int main(){ 
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int d=0;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            for(int k=0;k<c+1;k++){
                if(i*500+j*100+k*50==x){
                    d++;
                }
            }
        }
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static Main m;
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		byte[] v = new byte[6];
		boolean c = true;
		for(int i = 0; i < 6; i++) {
			v[i] = Byte.valueOf(in.readLine());
		}
		for(int i = 0; i < 5; i++) {
			for(int j = 0; j < 5; j++) {
				if(i <= j || !c) {
					continue;
				}
				if(Math.abs(v[i] - v[j]) > v[5]) {
					c = false;
					break;
				}
			}
		}
		System.out.println(c?"Yay!":":(");
	}
}


Measured memory_bytes: 21204
#include <stdio.h>
int main(void){
    int m,f,b;
    
    scanf("%d %d %d",&m,&f,&b);
    if(m>=b){
        printf("0\n");
    }
    else if((m+f)>=b){
        printf("%d\n",(b-m));
    }
    else{
        printf("NA\n");
    }
    
    return 0;
}


Measured memory_bytes: 2112
//https://atcoder.jp/contests/abc123/tasks/abc123_a
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    vector<int> v(5);
    for( auto &x : v ){
        cin >> x;
    }
    int N;
    cin >> N;
    sort( ALL(v) );
    cout << ( v[4] - v[0] <= N ? "Yay!" : ":(" ) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
list1 = [a, b, c, d, e]
for i in range(0, 5):
    for j in range(0, 5):
        if abs(list1[i] - list1[j]) > k:
            print("{}".format(":("))
            sys.exit()

print("{}".format("Yay!"))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

			for (int i = 0; i < n; i++) {
				a_n[i] = sc.nextInt();
			}

		int lcm = lcm(a_n[0], a_n[1]);

			for (int i = 2; i < n ; i++) {
				lcm = lcm(lcm, a_n[i]);
			}

			System.out.println(lcm);

		sc.close();

	}

	private static int lcm(int i, int j) {
		int lcm = i * j / gcd(i, j);
		return lcm;
	}

	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;
		}while(y > 0);

		return x;
	}

}


Measured memory_bytes: 26340
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def run():
    N = int(sysread())
    V = []
    x0, y0, h0 = None, None, None
    for _ in range(N):
        x,y,h = mapline()
        if h > 0 and x0 == None:
            x0, y0, h0 = x,y,h
        V.append((x, y, h))

    for x in range(0, 101):
        for y in range(0, 101):
            H = h0 + abs(x0-x) + abs(y0-y)
            done = True
            for xk, yk, hk in V:
                h_ = max(H - abs(xk-x) - abs(yk-y), 0)
                if h_ != hk:
                    done = False
                    break
            if done:
                print(f'{x} {y} {H}')
                return


if __name__ == "__main__":
    run()


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

int main() {
    int a, b;
    cin >> a;
    b = 0;
    int n = a;
    while (n) {
        b = b * 10 + n % 10;
        n /= 10;
    }
    if (a == b) puts("Yes");
    else puts("No");
}

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

int main(){
  long long N,A,B;
  cin >> N >> A >> B;
  long long s,t,u;
  s=N/(A+B);
  t=N%(A+B);
  if(A<=t)u=A;
  else u=t;
  cout << A*s+u << endl;
  
}

Measured memory_bytes: 256
n=int(input())
if n==0:
  print(0)
  exit()
if n>0:
  x=list(map(int,bin(n)[2:]))
  x.reverse()
  y=[0]*(len(x)+3-len(x)%2)
  for i in range(len(x)):
    if i%2==1 and x[i]==1:
      y[i]+=1
      y[i+1]+=1
    elif i%2==0 and x[i]==1:
      y[i]+=1
  for i in range(len(y)):
    if i%2==0 and y[i]==2:
      y[i]=0
      y[i+1]+=1
      y[i+2]+=1
    elif i%2==1 and y[i]==2:
      y[i]=0
      y[i+1]-=1
  y.reverse()
  print(int("".join(map(str,y))))
  exit()
if n<0:
  x=list(map(int,bin(abs(n))[2:]))
  x.reverse()
  y=[0]*(len(x)+3-len(x)%2)
  for i in range(len(x)):
    if i%2==0 and x[i]==1:
      y[i]+=1
      y[i+1]+=1
    elif i%2==1 and x[i]==1:
      y[i]+=1
  for i in range(len(y)):
    if i%2==1 and y[i]==2:
      y[i]=0
      y[i+1]+=1
      y[i+2]+=1
    elif i%2==0 and y[i]==2:
      y[i]=0
      y[i+1]-=1
  y.reverse()
  print(int("".join(map(str,y))))
  exit()

Measured memory_bytes: 3192
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

typedef struct UnionFind{
	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

	UnionFind(int N){/*最初はすべてが根であると初期化*/
		REP(i,0,N){
			par.push_back(i);
			size.push_back(1);
		}
	}

	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(lli x,lli y){/*xとyの併合*/
		lli rx = root(x);
		lli ry = root(y);
		if(rx == ry)return;
		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
		lli resize = size[rx] + size[ry];
		size[rx] = resize;
		size[ry] = resize;
	}

	bool same(lli x,lli y){
		lli rx = root(x);
		lli ry = root(y);
		return rx == ry;
	}

	lli getSize(lli x){
		lli rx = root(x);
		return size[rx];
	}
};

signed main(){

	lli n,m;
	cin>>n>>m;
	vector<lli> p(n);
	map<lli,lli> ind;
	UnionFind uf(n);
	REP(i,0,n){
		cin>>p[i];
		p[i]--;
		ind[p[i]] =i;
	}

	REP(i,0,m){
		lli x,y;
		cin>>x>>y;
		x--,y--;
		uf.unite(x,y);
	}

	lli cnt=0;
	REP(i,0,n){
		lli nowInd = p[i];
		if(uf.same(i,nowInd))cnt++;
	}

	cout<<cnt<<endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int f_x = 0, surplus = N;
  for (int i = 100000000; i > 1; i /= 10) {
    f_x += surplus/i;
    surplus %= i;
  }
  f_x += surplus;
  
  if (N % f_x == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pr1(a) printf("%d\n",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define loop(i,a,b) for(int i=a;i<b;i+=1)
#define ll long long int
#define ld long double
#define lvec vector<long long int> v
#define vec vector<int> v
#define ite1 vector<int>:: iterator it1
#define ite2 vector<int>:: iterator it2
#define ite3 vector<int>:: iterator it3
#define mp make_pair
#define pb push_back
#define pf push_front
#define pff pop_front
#define pbb pop_back
#define ft first
#define sd second

int main()
{
    int t=1;

    //cin>>t;           // comment this line when number of testcases = 1

    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int h[n];
        loop(i,0,n){cin>>h[i];}
        int dp[n];
        loop(i,0,n){dp[i]=1000000000;}

        dp[0]=0;
        loop(i,1,n)
        {
            //dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]) );
            loop(j,i-k,i)
            {
                if(j<0){continue;}
                dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
            }
        }

        cout<<dp[n-1]<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  int k, t;
  cin >> k >> t;
  int ans = 0;
  rep(i, 0, t){
    int a;
    cin >> a;
    int b = a-(k-a+1);
    if(b>0)ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int64_t Comb(int64_t n,int64_t m){
    if(n>m) return n*(n-1)*(n-2)/6;

}

int main(){
    int64_t N; cin>>N;
    string S; cin>>S;

    int64_t ans=0;
    rep(i,0,1000){
        vector<char> C={(char)('0'+(i/100)%10),(char)('0'+(i/10)%10),(char)('0'+i%10)};
        int cIdx=0;
        rep(j,0,S.size()){
            if(cIdx>2) break;
            if(S.at(j)==C.at(cIdx)){
                cIdx++;
            }
        }
        if(cIdx>2) ans++;
    }

    cout<<ans<<endl;
}

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

void Show(int x,int y){
    while(true){
    cin>>x>>y;
    if(x>y){
        int t;
        t=x;
        x=y;
        y=t;
    }
    if(x==0&&y==0){
        break;
    }
    cout<<x<<" "<<y<<endl;
    }
}
int main(){
    int x,y;
    Show(x,y); 
    
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

string S="ATCG";

signed main(){
    char c;cin>>c;
    int k=find(all(S),c)-S.begin();
    cout<<S[k^1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  string S[2];
  cin >> S[0] >> S[1];
  vec< bool > type;
  REP(i, N) {
    if (S[0][i] == S[1][i]) {
      type.pb(true);
    } else {
      type.pb(false);
      i++;
    }
  }
  //  PRINTALL(type);
  int ans = type[0] ? 3 : 6;
  REP(i, (int)type.size() - 1) {
    if (type[i] && type[i + 1]) {
      ans *= 2;
      ans %= MOD;
    } else if (type[i] && !type[i + 1]) {
      ans *= 2;
      ans %= MOD;
    } else if (!type[i] && type[i + 1]) {

    } else {
      ans *= 3;
      ans %= MOD;
    }
  }
  print(ans);
}

Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
T = [int(x) for x in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
data = []
for _ in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
sum_T = sum(T)

for i,j in data:
    print(sum_T - T[i-1] + j)

Measured memory_bytes: 3060
N=int(input())
lv=list(map(int,input().split()))
dev={}
dod={}
#cev=0#devの種類数
#cod=0#dodの種類数
max1_ev=[0,0]#数字,個数
max2_ev=[0,0]
max1_od=[0,0]#数字,個数
max2_od=[0,0]

for i in range(N):
    if i%2==0:#even
        #max1_ev=[0,0]#数字,個数
        #max2_ev=[0,0]
        #毎回初期化していた！！

        if lv[i] in dev:#辞書の更新
            dev[lv[i]]+=1
        else:
            dev[lv[i]]=1
            #maxの更新
            #cev+=1
            #if cev==1:
            #    max1_ev=[i,lv[i]]
            #elif cev==2:
            #    max2_ev=[i,lv[i]]
        ##3種目以降
        #最大個数の更新
        if dev[lv[i]]>max1_ev[1]:
            a=max1_ev
            max1_ev=[lv[i],dev[lv[i]]]
            max2_ev=a
        #elif dev[lv[i]]>max2_ev[1]:
        elif dev[lv[i]]>=max2_ev[1]:
            max2_ev=[lv[i],dev[lv[i]]]
        #print("dev[lv[i]]",dev[lv[i]])
        #print("max1__ev[1]",max1_ev[1])
        #print("max1_ev",max1_ev)
        #print("max2_ev",max2_ev)
        #if i==0:
        #    max1=[0,1]
        #elif i==1:
        #    max2
    else:#odd
        #max1_od=[0,0]
        #max2_od=[0,0]
        if lv[i] in dod:
            dod[lv[i]]+=1
        else:
            dod[lv[i]]=1
        if dod[lv[i]]>max1_od[1]:
            a=max1_od
            max1_od=[lv[i],dod[lv[i]]]
            max2_od=a
        #elif dod[lv[i]]>max2_od[1]:
        elif dod[lv[i]]>=max2_od[1]:
            max2_od=[lv[i],dod[lv[i]]]
#print("dev",dev)#ok
#print("dod",dod)#ok
#print("max1_ev",max1_ev)
#print("max2_ev",max2_ev)
#デバッグ消し忘れ

#if len(dev)==1 and len(dod)==1:
#    print(int(N/2))
#elif len(dev)==1:
    #for i in range(len(dod)):
    #    if i==0:
    #        max1_od=
#    if max1_ev[0]!=max1_od[0]:
#        print(N-max1_ev[1]-max1_od[1])
##        print(max)
if max1_ev[0]!=max1_od[0]:
    print(N-max1_ev[1]-max1_od[1])
elif len(dev)==1 and len(dod)==1:
    print(int(N/2))
elif len(dev)==1:
    print(int(N/2)-max2_od[1])
elif len(dod)==1:
    print(int(N/2)-max2_ev[1])
else:
    #print(max(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))#minをmaxとしていた
    print(min(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))


Measured memory_bytes: 17644
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a)); i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    int ans = (n+1)/2;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int gcd(int a, int b) {
  while (b) if (a %= b) b %= a; else return b;
  return a;
}

int lcm(int a, int b){
  if (a && b) return a / gcd(a, b) * b;
  return 0;
}

int main() {
  int N; cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
K=int(input())
S=list(input())
len_S=len(S)

def invmod(a):
  return pow(a,MOD-2,MOD)
fact_dic={0:1}
fact_inv_dic={0:1}
fact_mod=1
for i in range(1,K+len_S+1):
  fact_mod=(fact_mod*i)%MOD
  fact_dic[i]=fact_mod
  fact_inv_dic[i]=invmod(fact_mod)
def comb_mod_table(n,r):
  if 0<=r<=n:
    return fact_dic[n]*fact_inv_dic[r]*fact_inv_dic[n-r]
  else:
    return 0
  
answer=pow(26,K+len_S,MOD)
pow25=pow(25,K+len_S,MOD)
inv25=invmod(25)
for i in range(len_S):
  answer-=comb_mod_table(K+len_S,i)*pow25
  pow25=pow25*inv25%MOD
  answer%=MOD
  
print(answer)

Measured memory_bytes: 480916
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        if (N == 1) {
            Console.WriteLine (0);
        } else {
            Console.WriteLine (1);
        }

    }

}

//dotnet run --project test

Measured memory_bytes: 27528
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
C.sort()

ans = 0

def bisect(array, threshold, equal=False):
    OK = -1
    NG = N
    while NG - OK > 1:
        mid = (OK + NG) // 2
        if array[mid] < threshold:
            OK = mid
        elif equal == True and array[mid] == threshold:
            OK = mid
        else:
            NG = mid
    return OK + 1

for i in B:
    ans += bisect(A, i) * (N - bisect(C, i, True))

print(ans)

Measured memory_bytes: 104804
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans;
void solve()
{
    cin>>n>>m>>c;
    ll ar[m];
    ll arr[n][m];
    for(ll  i=0;i<m;i++)
        cin>>ar[i];
    for(ll j=0;j<n;j++)
    {
        for(int  i=0;i<m;i++)
            cin>>arr[j][i];
    }
    for(ll i=0;i<n;i++)
    {
        ll temp=c;
        for(ll j=0;j<m;j++)
            temp+=ar[j]*arr[i][j];
        if(temp>0)
            ans++;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src_, int dst_, Weight weight_) :
		src(src_), dst(dst_), weight(weight_) { }
	Edge(int src_, int dst_) :
		src(src_), dst(dst_) {

	}
};
pair<bool, vector<Weight>> spfa(const int v_num, const vector<vector<Edge>>&es, const int start) {
	vector<Weight>diss(v_num, INT_MAX);
	queue<int>que;
	vector<bool>use(v_num);
	vector<int>count(v_num);
	que.emplace(start);
	diss[start] = 0;
	while (!que.empty()) {
		int src(que.front());
		que.pop();
		use[src] = false;
		for (auto e : es[src]) {
			const int d = e.dst;
			if (diss[src] + e.weight < diss[d]) {
				diss[d] = diss[src] + e.weight;
				if (!use[d]) {
					use[d] = true;
					count[d]++;
					if (count[d] >= v_num)return make_pair(false, vector<Weight>());
					que.emplace(d);
				}
			}
		}
	}
	return make_pair(true, diss);
}
struct Compress {
	map<int, int>mp;
	map<int, int>revmp;

	Compress(vector<int>vs) {
		setmp(vs);
	}
	Compress(const set<int>&vs) {
		setmp(vs);
	}
	Compress() :mp(), revmp() {

	}
	void setmp(vector<int>vs) {
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		for (int i = 0; i < static_cast<int>(vs.size()); ++i) {
			mp[vs[i]] = i;
			revmp[i] = vs[i];
		}
	}
	void setmp(const set<int>&vs) {
		int num = 0;
		for (auto v : vs) {
			mp[v] = num;
			revmp[num] = v;
			num++;
		}
	}
};

int main() {
	int N; cin >> N;
	vector<vector<Edge>>es(N);
	map<int, int>mp;
	map<int, int>revmp;
	for (int i = 0; i < N; ++i) {
		int r; cin >> r;
		mp[r] = i;
		revmp[i] = r;
		int k; cin >> k;
		for (int j = 0; j < k; ++j) {
			int t; cin >> t;
			es[i].push_back(Edge(i, t));
		}
	}
	vector<vector<int>>companion(N,vector<int>(N,1e8));
	for (auto& aes : es) {
		for (auto&e : aes) {
			e.dst = mp[e.dst];
			companion[e.src][e.dst] = 1;
		}
	}
	for (int i = 0; i < N; ++i) {
		companion[i][i] = 0;
	}
	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				companion[i][j] = min(companion[i][k] + companion[k][j], companion[i][j]);
			}
		}
	}
	int P; cin >> P;
	while (P--) {
		int s, d, v; cin >> s >> d >> v;
		int ans = companion[mp[s]][mp[d]];
		if (ans >= v)cout << "NA" << endl;
		else {

			cout << ans + 1 << endl;
		}
	}
	

	return 0;
}

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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int i, j, k;
	int a, b, c;
	int s=0, adding;
	
	scanf("%d %d %d", &i, &j, &k);
	a=max(i, max(j, k));
	c=min(i, min(j, k));
	b=i+j+k-a-c;
	if((b&1)^(c&1)){
		c++;
		a++;
		s++;
	}
	adding=a-b;
	s+=adding;
	c+=adding;
	b+=adding;
	s+=(a-c)/2;
	printf("%d", s);
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> divisors = divisor(M);
    int lb = 0, ub = divisors.size();

    while(lb < ub - 1) {
        ll idx = (lb + ub) / 2;
        if(divisors[idx] * N <= M) {
            lb = idx;
        } else {
            ub = idx;
        }
    }

    cout << divisors[lb] << endl;

    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n, w;
int v;
double h[111];

int main()
{
  while(cin >> n >> w, n){
    rep(i, 111) h[i] = 0.0;
    double mx = 0.0;
    rep(i, n){
      cin >> v;
      h[v / w] += 1.0;
      maxup(mx, h[v / w]);
    }
    int ptr;
    rev(i, 111) if(h[i]){
      ptr = i;
      break;
    }

    double res = 0.01;
    rep(i, ptr){
      res += (double)(ptr - i) * h[i] / (ptr * mx) ;
    }

    printf("%.15f\n", res);
  }

  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=200010;

int n,ret,cur=1<<30;
int a[N],f[N];
priority_queue<ii> h;

main(){
    #define task "FREQ"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    n=in;
    forinc(i,1,n) h.push({in,i});
    while(h.size()){
        int now=h.top().fi;
        while(h.size() && h.top().fi==now){
            cur=min(cur,h.top().se);
            h.pop();
            ret++;
        }
        int to=0;
        if(h.size()) to=h.top().fi;
        f[cur]+=ret*(now-to);
    }
    forinc(i,1,n) cout<<f[i]<<"\n";
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, C[500][3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n-1)FOR(j, 0, 3) cin >> C[i][j];
  FOR(i, 0, n){
    int t = 0;
    FOR(j, i, n-1){
      maxs(t, C[j][1]);
      if(t%C[j][2]) t += C[j][2] - t%C[j][2];
      t += C[j][0];
    }
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> P(A), Q(B), R(C);
  for (int i = 0; i < A; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> Q[i];
  }
  for (int i = 0; i < C; i++) {
    cin >> R[i];
  }
  sort(P.rbegin(), P.rend());
  sort(Q.rbegin(), Q.rend());
  sort(R.rbegin(), R.rend());
  vector<int> V;
  for (int i = 0; i < X; i++) {
    V.push_back(P[i]);
  }
  for (int i = 0; i < Y; i++) {
    V.push_back(Q[i]);
  }
  for (int i = 0; i < C; i++) {
    V.push_back(R[i]);
  }
  sort(V.rbegin(), V.rend());
  ll sum = 0;
  for (int i = 0; i < X + Y; i++) {
    sum += V[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;
	while(q--){
		int n,m;
		cin>>n;

		double ans=3.14159*2*n;

		cout<<ans<<endl;
	}
   
}

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

using namespace std;
const int N=3E5+9;
int arr[N];
int pre[N],suff[N];
int main() {

int n;
cin>>n;
for(int i=1;i<=n;i++)cin>>arr[i];
pre[0]=0;
for(int i=1;i<=n;i++)
{
    pre[i]=__gcd(arr[i],pre[i-1]);

}
suff[n+1]=0;
for(int i=n;i>=1;i--)

{
    suff[i]=__gcd(suff[i+1],arr[i]);
}
int maxi=0;
for(int i=1;i<=n;i++)
{
maxi=max(__gcd(pre[i-1],suff[i+1]) , maxi);


}

cout<<maxi;



}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int a[128];
  rep(i, n) {
    cin >> a[i];
  }

  int minv = INF;
  for (int i = -100; i <= 100; ++i) {
    int sumcost = 0;
    for (int j = 0; j < n; ++j) {
      int cost = (a[j] - i) * (a[j] - i);
      sumcost += cost;
    }
    chmin(minv, sumcost);
  }

  cout << minv << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n, m, q;
int a[55], b[55], c[55], d[55];
int ans;

void calc(vector<int> v) {
    int sum = 0;
    rep(i, 0, q) {
        if (v[b[i]] - v[a[i]] == c[i]) sum += d[i];
    }
    ans = max(ans, sum);
}

void dfs(vector<int> v) {
    if ((int)v.size() == n + 1) {
        calc(v);
        return;
    }
    rep(i, v.back(), m + 1) {
        v.push_back(i);
        dfs(v);
        v.pop_back();
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, 0, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> v(1, 1);
    dfs(v);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  string s; 
  cin>>s;
  int N = int(s.size());
  if (int(s.size()) == 26){
    if (s == "zyxwvutsrqponmlkjihgfedcba"){
      cout << -1 << endl;
    }else{
      string t = s;
      next_permutation(s.begin(), s.end());
      for (int i(0);i<26;i++){
        if (s[i] == t[i]){
          cout << s[i];
        }else{
          cout << s[i] << endl;
          return 0;
        }
      }
      cout << s << endl;
    }
  }else{
    int cnt[30] = {0};
    for (int i(0);i<N;i++){
      cnt[s[i]-'a']++;
    }
    for (int i(0);i<26;i++){
      if (cnt[i] == 0){
        cout << s + (char)('a' + i) << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <queue>
using namespace std;
int n;
string s;
int main()
{
    //freopen("test.inp","r", stdin);
    cin >> n >> s;
    if (s.length() <= n)
    {
        cout << s;
        return 0;
    }
    cout << s.substr(0, n) <<"...";
    return 0;
}


Measured memory_bytes: 3604
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int saiki( vector<int> color, vector<int> num, int up, int down, int n ) {
	while(true) {
		if ( color[up] != color[down] || num[up] + num[down] < 4 ) break;
		n -= num[up] + num[down];
		up--;
		down++;
	}
	return n;
}

int main(){
	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		vector<int> color;
		vector<int> num;
		int input;

		color.push_back(-1);
		num.push_back(0);
		for ( int i = 0; i < n; i++ ) {
			cin >> input;
			if ( color[ color.size()-1 ] == input ) {
				num[ num.size()-1 ]++;
			}else {
				color.push_back(input);
				num.push_back(1);
			}
		}
		color.push_back(-1);
		num.push_back(0);

		int m = n;

		for ( int i = 1; i < color.size()-2; i++ ) {
			if ( num[i] == 1 ) {
				if ( color[i-1] == color[i+1] && num[i-1] + num[i+1] >= 3 ) {
					m = min( m,saiki( color, num, i-2, i+2, n - ( num[i-1]+num[i+1]+1 ) ) );
					continue;
				}
			}
			if ( num[i-1] == 3 ) {
				if ( num[i] == 1 ) {
					m = min( m,saiki( color, num, i-2, i+1, n - 4 ) );
				}else {
					num[i]--;
					m = min( m,saiki( color, num, i-2, i, n - 4 ) );
					num[i]++;
				}
			}
			if ( num[i+1] == 3 ) {
				if ( num[i] == 1 ) {
					m = min( m,saiki( color, num, i-1, i+2, n - 4 ) );
				}else {
					num[i]--;
					m = min( m,saiki( color, num, i, i+2, n - 4 ) );
					num[i]++;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1344
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int d,n;
  cin >> d >>n;
  if(n==100) n+=1;
  if(d!=0){
    int a = pow(100,d);
    cout << a*n << "\n";
  }
  else cout << n << "\n";


  return 0;
}


Measured memory_bytes: 256
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 0

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;
typedef struct R {
	int i;
	string s;
	int p;
} R;
vector<R> Rvec;

bool myfunction(R &i, R &j) {
	if (i.s<j.s) {
		DOUT << "i.s="<<i.s<<" < j.s="<<j.s<<endl;
		return true;
	}
	else if (i.s>j.s) {
		DOUT << "i.s="<<i.s<<" > j.s="<<j.s<<endl;
		return false;
	}
	else {
		if (i.p>j.p) {
			return true;
		}
		else if(i.p<j.p) {
			return false;
		}
	}
	return false;
}

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

	cin >> N;
	for(int n=1;n<=N;n++) {
		string s;
		int p;
		cin >> s >> p;
		R r;
		r.i=n; r.s = s; r.p = p;
		DOUT << "["<<n<<"]: s="<<s<<", p="<<p<<endl;
		Rvec.push_back(r);
	}
	sort(Rvec.begin(), Rvec.end(), myfunction);

	for(vector<R>::iterator it = Rvec.begin(); it!=Rvec.end(); it++) {
		cout << (*it).i << endl;
	}

	return 0;
}



Measured memory_bytes: 256