akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int x; cin >> x;
    cout << 1-x << endl;
}

Measured memory_bytes: 3652
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();

        if (!a.Any(o => o == 1))
        {
            Console.WriteLine(-1);
            return;
        }

        int O = 1;
        for (int i = 0; i < a.Count(); i++)
        {
            if (a[i] == O)
                O++;
        }

        O = N - O + 1;
        Console.WriteLine(O);
    }
}


Measured memory_bytes: 34268
n,m = map(int,input().split())
broken = [True] * (n+1)
for _ in range(m):
    broken[int(input())] = False

mod = 10 ** 9 + 7

dp = [0] * (n+1)
dp[-1] = 1
if broken[n-1]:
    dp[n-1] = 1

for i in reversed(range(n-1)):
    if broken[i]:
        dp[i] = (dp[i+1] + dp[i+2]) % mod
        
print(dp[0])

Measured memory_bytes: 7668
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char s[200005];
int n,cnt[26];
ll ans=0;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)cnt[s[i]-'a']++;
	ans=1;
	for(int i=0;i<26;i++)for(int j=i+1;j<26;j++)ans+=1ll*cnt[i]*cnt[j];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1896
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll N,M;
    cin >> N >> M;
    if ( (N==1 || N==2) && (M==1 || M==2)) {
        cout << (N*M)%2 << endl;
        return 0;
    }
    if (N==2 || M==2) {
        cout << 0 << endl;
        return 0;
    }
    if (N==1) {
        cout << (M-2) << endl;
        return 0;
    }
    if (M==1) {
        cout << (N-2) << endl;
        return 0;
    }
    cout << (N-2)*(M-2) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [0] * n
u = [0] * n

ans = 0
for i in range(n):
    x[i], u[i] = input().split()
    x[i] = float(x[i])

for i in range(n):
    if u[i] == "JPY":
        ans += x[i]
    else:
        ans += x[i]*380000

print(ans)


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    int ct[26]={};
    rep(i,s.size()) ct[s[i]-'a']++;

    int odd=0,even=0;
    rep(i,26)
    {
        if(ct[i]>0)
        {
            if(ct[i]%2==0) ++even;
            else ++odd;
        }
    }

    printf("%d\n",odd/2);
    return 0;
}

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

int main(){

	int S;
	cin >> S;

	int h, m, s;
	h = S / 3600;
	m = (S % 3600) / 60;
	s = S % 60;

	cout << h << ":" << m << ":" << s << endl;

return 0;
}

Measured memory_bytes: 1164
using System;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      string[] input=Console.ReadLine().Split(' ');
    int N=int.Parse(input[0]);
    int R=int.Parse(input[1]);
      if(N>=10){
        Console.WriteLine(R);
      }else{
       int nr=R+1000-100*N;
        Console.WriteLine(nr);
    }
    }
    
  }
 
}

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

int getDays(int y, int m, int d) {
  if (m <= 2) {
    --y;
    m += 12;
  }
  int dy = 365 * (y - 1);
  int c = y / 100;
  int dl = (y >> 2) - c + (c >> 2);
  int dm = (m * 979 - 1033) >> 5;
  return dy + dl + dm + d - 1;

}

int main() {
  int y1, m1, d1, y2, m2, d2;
  string s;
  while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
    if (y1 < 0) break; 
    int t1 = getDays(y1, m1, d1);
    int t2 = getDays(y2, m2, d2);
    cout << t2 - t1 << endl;
  }
  return 0;
}



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

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1){
    for (int u : to[v])
    {
        if (u == p)
        {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}


int main(){

    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    ans.resize(n);
    for (int i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);

    for (int i = 0; i < n; i++)

        cout << ans[i] << " ";

    cout << endl;
    return 0;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using graph = vector<vi>;
const int MAXN = 212345;
graph g;
int h[MAXN];
bool seen[MAXN];

void sol(int u) {
    seen[u] = 1;
    h[u] = 0;
    for (auto v : g[u]) {
        if (!seen[v]) {
            sol(v);
        }
        h[u] = max(h[u], 1+h[v]);
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    g.assign(n+1, vi());
    int u, v;
    while (m--) {
        scanf("%d %d", &u, &v);
        g[u].emplace_back(v);
    }
    int ans = 0;
    for (int i = 1; i<=n; ++i) {
        if (!seen[i]) {
            sol(i);
            ans = max(ans, h[i]);
        }
    }
    printf("%d\n", ans);

}


Measured memory_bytes: 8192
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a >= 13)
  {
    cout << b;
  }
  else if(a >= 6)
  {
    cout << b / 2;
  }
  else
  {
    cout << 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	char name[ 21 ];
	int score;
} Rec;

Rec record[ 10 ];

void insertionSort( Rec *, int );
void print( int );

int main( void ) {
	int n;

	scanf( "%d", &n );
	print( n );

	for ( ; scanf( "%d", &n ), n; print( n ) )
		putchar( '\n' );

	return 0;
}

void insertionSort( Rec *data, int n ) {
	int i, j;
	Rec tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ].score > tmp.score; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

void print( int n ) {
	int i, win, draw;

	for ( i = n; i--;  ) {
		scanf( "%s %d %*d %d", record[ i ].name, &win, &draw );

		record[ i ].score = win * 3 + draw;
	}

	insertionSort( record, n );

	while ( n-- )
		printf( "%s,%d\n", record[ n ].name, record[ n ].score );
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = (n / x) * t;
    if (n % x != 0) ans += t;
    cout << ans << "\n";
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


struct P
{
    int num;
    int id;    
};
vector<vector<P>> G;
vector<int> ans;

void dfs(int cur, int color, int from){
    //cout << "cur: " << cur << endl;
    int n_color = 1;
    rep(i,G[cur].size()){
        int nx = G[cur][i].num;
        int id = G[cur][i].id;
        if(nx==from) continue; //防止回去
        if(n_color==color) n_color++; //颜色不能重复
        ans[id] = n_color; n_color++;
        dfs(nx, ans[id], cur);
    }
}

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

    int N;
    cin >> N;
    G.resize(N);
    rep(i,N-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(P{b,i});
        G[b].pb(P{a,i});
    }

    ans.resize(N-1,-1);
    dfs(0,-1,-1);

    //rep(i,ans.size()) cout << ans[i] << " ";
    //cout << endl;

    int maxn = 0;
    rep(i,ans.size()) maxn = max(maxn,ans[i]);
    cout << maxn << endl;
    rep(i,ans.size()) cout << ans[i] << endl;

}

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

int main(){
    string s;
    cin >> s;
    vector<string> d = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for(int i = 0; i < 7; ++i){
        if(s == d[i]){
            cout << 7-i << endl;
        }
    }
}


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

int main()
{
    int r, g, b;
    
    cin >> r >> g >> b;
    
    if((100*r+10*g+b) % 4 == 0) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 int A[200001];
 long long int L[200001];  //first smallest index in left;
 long long int R[200001]; //first smallest index in right; 
 int stack[200001];
 long long int C[200001];
 int sp=0;

 void push(int x) {
 	stack[sp] = x;
 	sp ++;
 }

 void pop() {
 	sp--;
 }
 int empty(){
    if(sp==0)
    	return 1;
    	return 0;
 }
 int top(){
 	return stack[sp-1];
 }


int main() {
     int n,i;
     long long int ans=0;
     scanf("%d",&n);

     for(i=0;i<n;i++)
     	scanf("%d",&A[i]);
     
     for(i=0;i<n;i++) {
     	while(sp>0 && A[top()] > A[i]) {
     		pop();
     	}
     	if(empty())
     		L[i] = -1;
     	else
     		L[i] = top();
     	push(i);
     	
     }
     sp = 0;
     for(i=n-1 ;i>=0; i--){
     	while(sp>0 && A[top()] > A[i]) {
     		pop();
     	}
     	if(!empty())
     		R[i] = top();

     	else
     		R[i] = n;
     	push(i);
     }
     for(i=0;i<n;i++) {
     	C[i] = (i-L[i])*(R[i]-i);
     	ans = ans+C[i]*A[i];
     }
     printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 6400
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
    // String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu);


     String nyu2=sc.nextLine();
int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);


//if(nyu.equals(line_r_2) && nyu2.equals(line_r_1)){
//double res=Math.ceil((AB)/2);

System.out.println(E+(E-D));
//}else if((int)c[0]>(int)c[2]){
//System.out.println(">");

//}else{
//System.out.println("NO");

//}




	}
}

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    string s;
    cin >> s;
    char tmp;
    int ans = 1;
    bool is_double = false;
    bool double_fin = false;
    for(int i = 0; i < s.length()-1; i++){
        if(double_fin == true){
            ans++;
            double_fin = false;
            is_double = false;
        }else if(s[i] == s[i+1]){
            if(is_double == false){
                is_double = true;
            }else{
                ans++;
                is_double = false;
                double_fin = true;
            }
        }else{
            if(is_double == true){
                ans++;
                is_double = false;
                double_fin = true;
            }else{
                ans++;
            }
        }
    }
    out(ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
  int x = 0, max = 0, n, i;
  char a;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> a;
    if(a == 'I'){
      x++;
    }else if(a == 'D'){
      x--;
    }
    if(max < x){
      max = x;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector<long double> p(n + 1, 0.0);
	for(int i = 1; i <= n; i++) {
		cin >> p[i];
	}

	vector<vector<long double>> dp(n + 1, vector<long double>(n + 1, 0.0));
	dp[0][0] = 1.0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= i; j++) {
			if(j == 0) {
				dp[i][j] = (dp[i - 1][j] * (1.0 - p[i]));
			}
			else {
				dp[i][j] = ((dp[i - 1][j] * (1.0 - p[i])) + (dp[i - 1][j - 1] * (p[i])));
			}
		}
	}

	long double res = 0.0;
	for(int i = 0; i <= n; i++) {
		if(i > n - i) {
			res += dp[n][i];
		}
	}

	cout << fixed << setprecision(10) << res << '\n';
}

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

int main()
{
  string s;
  cin >> s;
  string ans = "Yes";
  if (s == "AAA" || s == "BBB")
    ans = "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int A, B, C,D;
	cin >> A >> B >> C >> D;
	int flag = -1;
	while (A > 0 && B > 0)
	{
		C -= B;
		if (C <= 0)
		{
			flag = 1; 
			break;
		}
		A -= D;
		if (A <= 0)
		{
			flag = 0;
			break;
		}

	}
	if (flag == 1)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;
const double PI=3.14159265358979323846;

int main() {
  double r;
  cin >> r;
  cout << 2*r*PI << endl;
  return 0;
}


Measured memory_bytes: 3780
{-# LANGUAGE TypeApplications #-}

import           Control.Monad
import           Control.Applicative
import           Data.List
import           Data.Char
import           Control.Arrow

main = do
  n <- readLn @Int
  putStrLn $ solve n []
 where
  solve 0 str = str
  solve n str =
    let a = chr $ ord 'a' + ((n - 1) `mod` 26)
        m = (n - 1) `div` 26
    in  solve m (a : str)



Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
vector<int>e[N];
int f[N],n,i,x,y;
void dfs(int x,int fa){
	for(int i=0;i<e[x].size();++i)
		if(e[x][i]!=fa)dfs(e[x][i],x),f[x]^=f[e[x][i]]+1;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(i=1;i<n;++i)cin>>x>>y,e[x].push_back(y),e[y].push_back(x);
	dfs(1,0);
	cout<<(f[1]?"Alice\n":"Bob\n");
	return 0;
}

Measured memory_bytes: 12416
#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
ll doe,n,ans;
void dfs(ll x,ll y)
{
	if (x%y==0)
	{
		ans+=(x*2-y);
		return;
	}
	ans+=(x/y)*y*2;
	dfs(y,x%y);

}
int main()
{
	scanf("%lld%lld",&n,&doe);
	if (doe*2==n)
	{
		printf("%lld\n",doe*3);
		return 0;
	}
	ans+=n;
	ll x=doe;
	ll y=n-doe;
	if (y>x) swap(x,y);
	dfs(x,y);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
nums = gets.chomp.split("").map(&:to_i)
(3 ** 2).times do |i|
  op1 = i[0] == 1 ? "+" : "-"
  op2 = i[1] == 1 ? "+" : "-"
  op3 = i[2] == 1 ? "+" : "-"
  ops = [op1, op2, op3]
  sum = nums.first
  nums[1..-1].each_with_index do |num, index|
    sum += ops[index] == "+" ? num : -num
  end
  if sum == 7
    puts "#{nums[0]}#{op1}#{nums[1]}#{op2}#{nums[2]}#{op3}#{nums[3]}=7"
    exit
  end
end


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N, M, Q;
int a[50], b[50], c[50], d[50];

int calc(vector<int> v){
    int ans = 0;
    for(int i = 0; i < Q; i++){
        if(v[b[i]]-v[a[i]] == c[i]) ans += d[i];
    }
    return ans;
}

int ans;

void dfs(vector<int> v){
    if(v.size() == N){
        ans = max(ans, calc(v));
    }else{
        if(v.size() == 0){
            for(int i = 1; i <= M; i++){
                vector<int> u;
                for(int j : v) u.push_back(j);
                u.push_back(i);
                dfs(u);
            }
        }else{
            int s = v.size();
            for(int i = v[s-1]; i <= M; i++){
                vector<int> u;
                for(int j : v) u.push_back(j);
                u.push_back(i);
                dfs(u);
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M >> Q;
    for(int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> v;
    dfs(v);
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MX 100001
#define FF freopen("input.in","r",stdin); freopen("output.txt","w",stdout);
int n;
pair<int ,pair<int ,int > > a[MX];
ll dp[MX][4];
ll f(int i,int last)
{
    if(i==n)return 0;
    if(dp[i][last]!=-1)return dp[i][last];
    if(last==1)
    {
        return dp[i][last]=max(f(i+1,2)+a[i].second.first,f(i+1,3)+a[i].second.second);
    }
    else if(last==2)
    {
        return dp[i][last]=max(f(i+1,1)+a[i].first,f(i+1,3)+a[i].second.second);
    }
    else if(last==3)
    {
        return dp[i][last]=max(f(i+1,2)+a[i].second.first,f(i+1,1)+a[i].first);
    }
    else
        return dp[i][last]=max(f(i+1,2)+a[i].second.first,max(f(i+1,1)+a[i].first,f(i+1,3)+a[i].second.second));
}
int main()
{
    //FF;
    IOS;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        a[i]=make_pair(x,make_pair(y,z));
    }
    memset(dp,-1,sizeof dp);
    cout<<f(0,0);
}



Measured memory_bytes: 10752
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  int h[100005], dp[100005];
  int tmp;
  cin >> N >> K;
  rep(i, N){
    cin >> h[i+1];
  }

  REP(i, 1, N+1){
    if (i == 1){
      dp[1] = 0;
    } else if (i <= K){
      tmp = INT_MAX;
      REP(j, 1, i){
        tmp = min(dp[i-j]+abs(h[i]-h[i-j]), tmp);
      }
      dp[i] = tmp;
    } else {
      tmp = INT_MAX;
      REP(j, 1, K+1){
        tmp = min(dp[i-j]+abs(h[i]-h[i-j]), tmp);
      }
      dp[i] = tmp;
    }
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		String op = scan.next();
		int b = scan.nextInt();
		if(op.equals("+")) {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
		scan.close();
	}

}


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

int main(){
    long n, i, a, min = 1000001, max = -1000001, sum = 0;
    cin >> n;
    i = 1;
    while (i <= n){
        cin  >> a;
        if (a < min) min = a;
        if (a > max) max = a;
        sum = sum + a;
        i++;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


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

int main() {

    int N, M;
    cin >> N >> M;

    int l, r;
    int left = -1;
    int right = 10000000;
    for (int i = 0; i < M; i++) {
        cin >> l >> r;
        if (l > left) {
            left = l;
        }
        if (r < right) {
            right = r;
        }
    }

    if (left <= right) {
        cout << right - left + 1 << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}


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

int main()
{
    long long int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
     cin>>v[i];
    for(int i=0;i<n-k;i++)
    {
        if(v[i+k]>v[i])
         cout<<"Yes";
        else
         cout<<"No";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3920
N=int(input())
S=input()
cnt_W=0
cnt_E=0
arr_W=[]
arr_E=[]
for s in S:
    if s=='W':
        cnt_W+=1
    arr_W.append(cnt_W)

for s in S[::-1]:
    if s=='E':
        cnt_E+=1
    arr_E.append(cnt_E)

import numpy as np

print((np.array(arr_W)+np.array(arr_E[::-1])).min()-1)

Measured memory_bytes: 34060
#include <iostream>
#include<string>

using namespace std;
int main()
{
	string date;
	cin >> date;

	int year = stoi(date.substr(0, 4));
	int month = stoi(date.substr(5, 2));
	int day = stoi(date.substr(8, 2));

	string wkstr = date.substr(0, 4) + date.substr(5, 2) + date.substr(8, 2);
	int wkint = stoi(wkstr);
	
	if (wkint <= 20190430) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
package main

import (
    "fmt"
)

func min(a, b int) int{
    if a < b {
        return a
    } else {
        return b
    }
}

func abs(a, b int) int{
    if a < b {
        return b-a;
    } else {
        return a-b;
    }
}

func main(){
    var x, y int
    fmt.Scanln(&x, &y)
    for{
        if x == y {
            break
        }
        z := abs(x, y)
        x = min(x, y)
        y = z

    }
    fmt.Println(x)
}


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

int main(){
  int D, G;
  cin >> D >> G;

  vector<vector<int>> vec(D, vector<int>(2));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 2; j++) {
        cin >> vec.at(i).at(j);
    }
  }

  int res=1000;
  for (int bit = 0; bit < (1<<D) ; bit++) {
       bool ans = false;
       int sum=0;
       int count=0;
       vector<int> S;
       for (int i = 0; i < D; i++) {
           if (bit & (1<<i)) {
               sum+=vec.at(i).at(0)*(i+1)*100+vec.at(i).at(1);
               count+=vec.at(i).at(0);
               S.push_back(i);
           }
       } 
       if(sum>=G){
         ans=true;
       }
       else{
         int x;
         if (bit==0) {
            x=D-1; 
         }
         else{
            sort(S.begin(), S.end());
            reverse(S.begin(), S.end()); 
            x=D-1;
            int i=0;
            while (i<(int)S.size() && S.at(i)==x) {
               i++;
               x-=1;
           }
         }

         for (int i = 1; i < vec.at(x).at(0); i++) {
             count+=1;
             sum+=(x+1)*100;
             if(sum>=G){
               ans=true;
               break;
             }          
         }
      }
      if (ans) res=min(res,count);
  }
  cout << res << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i = 0; i < n; i++)
    {
        cin >> l[i];
    }

    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for(int i = 0; i < k; i++)
    {
        ans+= l[i];
    }
    
    cout << ans << endl;
    
    return 0;
}

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

for i in range(n):
    otosidama_list.append(list(input().split()))

goukei = 0

for i in range(len(otosidama_list)):
    if otosidama_list[i][1] == "BTC":
        goukei += float(otosidama_list[i][0]) * 380000
    else:
        goukei += int(otosidama_list[i][0])
print(goukei)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<set>
using namespace std;
int a_b[3000+100];
int c_d[3000+100];
int main()
{
	set<int >Sab;
	set<int>Scd;
	int a,b,c,d,e,f;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	a_b[0]=1;
	c_d[0]=1;
	Sab.insert(0);
	Scd.insert(0);
	for(int i=a*100;i<=f;i+=100)
	{
		if(a_b[i-a*100]==1)
		{
			Sab.insert(i);
			a_b[i]=1;
		}
	}
	for(int i=b*100;i<=f;i+=100)
	{
		if(a_b[i-b*100]==1)
		{
			Sab.insert(i);
			a_b[i]=1;
		}
	}
	for(int i=c;i<=f;i++)
	{
		if(c_d[i-c]==1)
		{
			Scd.insert(i);
			c_d[i]=1;
		}
	}
	for(int i=d;i<=f;i++)
	{
		if(c_d[i-d]==1)
		{
			Scd.insert(i);
			c_d[i]=1;
		}
	}
	double max=-1;
	int maxts=0;
	int maxt=0;
	set<int> ::iterator  itab=Sab.begin();
	for(;itab!=Sab.end();itab++)
	{
	//	printf("%d\n",*itab);
		set<int> ::iterator itcd=Scd.begin();
		int xl=0;
		while(*itcd+*itab<=f && *itcd<=*itab/100*e)
		{
			itcd++;
			xl++;
		}
		itcd--;
		xl--;
		int ts=*itab+*itcd;
		int t=*itcd;
		double lv=t*1.0/ts;
		if(lv>=max)
		{
			max=lv;
			maxts=ts;
			maxt=t;
		}
	}
	printf("%d %d\n",maxts,maxt);
	return 0;
}

Measured memory_bytes: 384
my $n = <>; chomp($n);
my $s = <>; chomp($s);

#
my$b = ord('A');
foreach my$c (split '', $s) {
    my$ofs = (ord($c) - $b + $n) % 26;
    #printf("[DBG] $c $ofs\n");
    print chr($b + $ofs);
}


Measured memory_bytes: 1408
v = [ 10000, 5000, 1000, 500 ]

ans _ [] = 0
ans i (v:vs) =
  let d = i `div` v
      r = i `mod` v
  in
    (d * v) + (ans r vs)

main = do
  l <- getLine
  let i = read l :: Int
      o = ans i v
  print o



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n),c(m),d(m);
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i]>>b[i];
    }
    
    for(int i = 0; i < m; i++)
    {
        cin>>c[i]>>d[i];
    }
    
    
    for(int i = 0; i < n; i++)
    {
        int ans = 100;
        int dist = 1e9;

        for(int j = 0; j < m; j++)
        {
            int tmp = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(dist>tmp)
            {
                dist=tmp;
                ans=j;
            }
        }
        cout<<ans+1<<endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
#define INF (1<<29)
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;

  int ans = (n-1)*(m-1);
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3192
N,M=map(int, input().split())
a=set([int(input()) for i in range(M)])
dp=[0]*(N+1)
dp[0]=1
for i in range(1, N+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
        dp[i]=0
print(dp[N])

Measured memory_bytes: 13216
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n,k;    cin >> n >> k;
    vector<int>h(n);
    rep(i, n)   cin >> h[i];
    sort(h.begin(), h.end());
    int ans = 1000000000+5;
    rep(i, n-k+1){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

ll mypow(ll x, ll y){
  ll ans = 1;
  rep(i, 0, y) ans = ans * x;
  return ans;
}

int main(){
  ll k;
  cin >> k;
  
  queue<ll> luna;
  rep(i, 1, 10) luna.push(i);
  ll ans;
  while(k > 0){
    ans = luna.front();
    luna.pop();
    if(!(ans % 10 == 0)) luna.push(ans * 10 + ans % 10 - 1);
    luna.push(ans * 10 + ans % 10);
    if(!(ans % 10 == 9)) luna.push(ans * 10 + ans % 10 + 1);
    k--;
  }
  cout << ans << endl;
}

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

ll n,m,k;
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
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;
}

int main(){
    cin >> n >> m >> k;
    COMinit();
    ll res=0;
    for(ll i=0;i<=k;i++){
        res+=(((m*COM(n-1,i))%MOD)*modpow(m-1,n-1-i,MOD))%MOD;
        res%=MOD;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 15588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

struct UnionFind {
	vector<int> par;
	int n, cnt;
	UnionFind(const int& x = 0) { init(x); }
	void init(const int& x) { par.assign(cnt = n = x, -1); }
	inline int find(const int& x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	inline bool same(const int& x, const int& y) { return find(x) == find(y); }
	inline bool unite(int x, int y) {
		if ((x = find(x)) == (y = find(y))) return false;
		--cnt;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	inline int count() const { return cnt; }
	inline int count(int x) { return -par[find(x)]; }
};

/* example : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n, q; cin >> n >> q;
	UnionFind uf(n);
	for (int i = 0; i < q;i++) {
		ll com, x, y; cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else if (com == 1) {
			if (uf.same(x, y)) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main{

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int num = Integer.parseInt(line.substring(0, line.indexOf(" ")));
        int q = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
        Deque<Process> deque = new ArrayDeque<Process>();

        for(int i = 0; i < num; i++){
        	line = br.readLine();
        	String name = line.substring(0, line.indexOf(" "));
        	int time = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
        	deque.addLast(new Process(name, time));
        }

        int maxTime = 0;
        Deque<Process> resultDeque = new ArrayDeque<Process>();
        while(!deque.isEmpty()){
        	Process p = deque.pollFirst();
        	if(p.time > q){
        		p.time -= q;
        		maxTime += q;
        		deque.addLast(p);
        	}else{
        		maxTime += p.time;
        		p.time = maxTime;
        		resultDeque.addLast(p);
        	}
        }

        for(Process result: resultDeque){
        	System.out.println(result.name + " " + result.time);
        }


    }
}

class Process{
	String name;
	int time;

	Process(String name, int time){
		this.name = name;
		this.time = time;
	}

}


Measured memory_bytes: 52168
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem2583 : JAG-cannel **/
int main()
{
	int N;
	while (cin>>N, N) {
		vector<string> s(N);
		rep(i, N) cin>>s[i];
		REP(i, 1, N) {
			int j=0;
			for(; j<s[i].size(); j++) {
				if (s[i][j+1] != '.') {
					s[i][j] = '+';
					break;
				}
			}
			for (int k=i-1; k>0; k--) {
				if (s[k][j] == '.') {
					s[k][j] = '|';
				} else {
					break;
				}
			}
		}
		
		rep(i, N) {
			rep(j, s[i].size()) {
				if (s[i][j] == '.')
					s[i][j] = ' ';
			}
		}
		
		rep(i, N) {
			cout << s[i] << endl;
		}
	}
}

Measured memory_bytes: 1856
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){

  int s,i,m,f[1000000],j;
  scanf("%d",&s);
  f[0]=s;
  m=0;
  for(i=1;i<1000000;i++){
    if(f[i-1]%2==0)
      f[i]=f[i-1]/2;
    else f[i]=3*f[i-1]+1;
    
    for(j=0;j<i;j++){
      if(f[i]==f[j]){
        m=i+1;
        break;
      }
    }
    if(m!=0)
      break;
  }
  
  printf("%d",m);
  
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  string res;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') cnt++;
    else if (cnt == 0) res = '(' + res;
    else cnt--;
    res += s[i];
  }
  for (int i = 0; i < cnt; i++) res += ')';
  cout << res << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int arr[100005];

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

    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    int idx = n / 2;
    int x = arr[idx];

    int y = arr[idx-1];
    cout << x - y << "\n";

    return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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 int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n;
	cin >> n;
	Vi A(2 * n + 2, 0);

	for (int i = 1; i <= 200; i++) {
		for (int j = 1; j <= 200; j++) {
			for (int k = 1; k <= 200; k++) {
				ll s = (ll)i * i + (ll)j * j + (ll)k * k + i * j + j * k + k * i;
				//if (s == 1) cout << i << j << k << endl;
				if (s >= 1 && s <= n) A[s]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << A[i] << endl;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<pair<ll, int>> apple;
    rep0(i, a){
        ll n;
        cin >> n;
        apple.push_back(make_pair(n, 1));
    }
    rep0(i, b){
        ll n;
        cin >> n;
        apple.push_back(make_pair(n, 2));
    }
    rep0(i, c){
        ll n;
        cin >> n;
        apple.push_back(make_pair(n, 0));
    }
    sort(all(apple),greater<>());
    ll ans = 0,red = 0,blue = 0,less = 0;
    rep0(i, apple.size()){
        if(red + blue + less == x + y)break;
        if(apple[i].second == 1){
            if(red < x){
                ++red;
                ans += apple[i].first;
            }
        }else if(apple[i].second == 2){
            if(blue < y){
                ++blue;
                ans += apple[i].first;
            }
        }else{
            ans += apple[i].first;
            ++less;
        }
    }
    pf(ans);
    return 0;
}



Measured memory_bytes: 10348
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>

int main()
{
    string s;
    cin >> s;
    
    if(s.length() == 2)
    {
        if(s[0] == s[1])
        {
            cout << "1 2" << endl;
            return 0;
        }
        cout << "-1 -1" << endl;
        return 0;
    }
    
    for(int i = 1;i < s.length() - 1;i++)
    {
        map<char, int> m;
        for(int d = -1;d <=1;d++)
        {
            m[s[i + d]]++;
        }
        for(auto& r:m)
        {
            if(r.second >=2)
            {
                cout << i << " " << i + 2 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

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


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n, 0);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());

    ll res = 0;
    for(int i = 0; i < n; i++){
        if(k > 0){
            k--;
        }
        else{
            res += h[i];
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }






int n, k, m, r;
int res[21000];

vint inv(int n, int r) {
    vint res(r*2+1, 0);
    if (n == 1) { res[0] = 1; return res; }
    
    int q = 1;
    for (int i = 1; i <= r*2; ++i) {
        q *= 10;
        res[i] = q/n;
        q = q%n;
    }
    return res;
}

vint add(vint a, vint b) {
    for (int i = a.size()-1; i > 0; --i) {
        a[i] += b[i];
        a[i-1] += a[i]/10;
        a[i] %= 10;
    }
    return a;
}

int main() {
    while (cin >> n >> k >> m >> r) {
        if (n == 0) break;

        if (m == 0) {
            vint res = inv(n, r);
            cout << res[0] << ".";
            for (int i = 1; i <= r; ++i) cout << res[i];
            cout << endl;
        }
        else {
            vint res = inv(n, r);
            for (int i = 1; i <= n-1; ++i) {
                res = add(res, inv(i*n, r));
            }
            cout << res[0] << ".";
            for (int i = 1; i <= r; ++i) cout << res[i];
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), ans = 0;
	hrp(i, 1, n) hrp(j, 1, n) hrp(k, 1, n) ans += __gcd(__gcd(i, j), k);
	cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int temp;
	double a=0,t=1;
	for(int i=0;i<n;i++)
	{
			cin>>temp;
			a+=t/temp;
	}
	double b=1/a;
	printf("%.8lf",b);

		
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int T[2005]={0};
int main(){
  ll n,k;cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>T[i];
  }
  ll a=0,b=0,ans = 0;
  for(int i=1;i<=n-1;i++){
    for(int j=i+1;j<=n;j++){
      if(T[i]>T[j])a++;
      else if(T[i]<T[j])b++;
    }
  }
  ans+=a*((((k+1)*k)/2)%MOD)%MOD;
  ans+=b*((((k-1)*k)/2)%MOD)%MOD;
  cout<<ans%MOD<<endl;
}

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

int main() {
  int d,n;cin>>d>>n;
  int ans=1;
  rep(i,d)ans*=100;
  if(n==100)n++;
  cout<<ans*n<<endl;
}

Measured memory_bytes: 3588