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

using namespace std;

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

  int n;
  cin >> n;
  vector<bool> dp(n + 1);
  dp[0] = true;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (dp[x - 1]) {
      dp[x] = true;
    }
  }
  for (int i = n; i; --i) {
    if (dp[i]) {
      cout << n - i;
      return 0;
    }
  }
  cout << -1;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
abc = [list(map(int,input().split())) for i in range(n)]

dp = [[0] * 3 for i in range(n + 1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k])
print(max(dp[-1]))

Measured memory_bytes: 79448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, long long S){
  vector<ll> ans(N);
  if(S<1000000000){
    REP(N){
      if(i<K)
        ans[i]=S;
      else 
        ans[i]=1000000000;
    }
  }else{
    REP(N){
      if(i<K)
        ans[i]=S;
      else 
        ans[i]=1;
    }
  }
  REP(N){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=2e5+5;
const ll mod=1e9+7;
vector<int> ve[w];
int vis[w];
int ans[w];
void dfs(int x,int z)
{
    vis[x]=z;
    for(int i=0;i<ve[x].size();i++)
    {
        int y=ve[x][i];
        if(vis[y])  continue;
        dfs(y,3-z);
    }
}
int main()
{
    int i,j;
    int n;
    cin>>n;
    for(i=1;i<n;i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        ve[x].push_back(y);
        ve[y].push_back(x);
    }
    dfs(1,1);
    int aa=0,bb=0;
    for(i=1;i<=n;i++)
        if(vis[i]==1)
            aa++;
        else
            bb++;
    if(aa<=n/3||bb<=n/3)
    {
        int u=1,v=1;
        for(i=1;i<=n;i++)
        {
            if((vis[i]==1&&aa<=n/3)||(vis[i]==2&&bb<=n/3))
                ans[i]=v*3,v++;
            else
            {
                if(u>n)
                    ans[i]=v*3,v++;
                else
                {
                    ans[i]=u,u++;
                    if(u%3==0)
                        u++;
                }
            }
        }
    }
    else
    {
        int u=1,v=2,z=3;
        for(i=1;i<=n;i++)
        {
            if(vis[i]==1)
            {
                if(u<=n)
                    ans[i]=u,u+=3;
                else
                    ans[i]=z,z+=3;
            }
            else
            {
                if(v<=n)
                    ans[i]=v,v+=3;
                else
                    ans[i]=z,z+=3;
            }
        }
    }
    for(i=1;i<=n;i++)
        printf("%d ",ans[i]);
    return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  if (n - sum >= 0)
  	cout << n - sum << endl;
  else
    cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 7220
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s,c;
int main(){
	cin>>s>>c;
	if(s==c)puts("H");
	else puts("D");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
    while(true){
        int w, h;
        std::cin >> h >> w;
        if(!w && !h) break;
        for(int i=0; i<h; i++) {
            for(int i=0; i<w; i++) std::cout << '#';
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3100
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
int a[N] , n;
ll sum[N];

int main(){
    scanf("%d",&n);
    rep(i,1,n+1) scanf("%d",a + i) , sum[i] = sum[i-1] + a[i];
    ll ans = 1ll<<60;
    rep(i,1,n) ans = min(ans , abs(sum[i] - (sum[n] - sum[i])));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; 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 INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll s = (n / (a + b));
    cout << s*a + min(n - s*(a+b), a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, D, X, A[110], ans=0;

  cin >> N >> D >> X;
  for(int i = 0; i < N; i++) cin >> A[i];

  for(int i = 0; i < N; i++){
    int day = 1;
    while(day <= D){
      ans++;
      day += A[i];
    }
  }
  ans += X;

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct edge{__int128 from, to, cost;};

int main(void) {
	while(true) {
		string s;
		getline(cin, s);
		if(s.size() == 1 && s[0] == '.')break;
		bool d = true;
		stack<ll> r;
		stack<ll> b;
		REP(i, s.size()) {
			if(s[i] == '(') r.push(b.size());
			if(s[i] == ')') {
				if(r.size() == 0) {
					d = false;
					break;
				}
				ll hoge = r.top();
				r.pop();
				if(hoge != b.size()) {
					d = false;
					break;
				}
			}
			if(s[i] == '[') b.push(r.size());
			if(s[i] == ']') {
				if(b.size() == 0) {
					d = false;
					break;
				}
				ll hoge = b.top();
				b.pop();
				if(hoge != r.size()) {
					d = false;
					break;
				}
			}
		}
		if(d && b.size() == 0 && r.size() == 0) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

const int N = 2e5+5;

int up[N];

int Find(int x) {
	if (up[x] < 0) {
		return x;
	}
	int root = Find(up[x]);
	up[x] = root;
	return root;
}

void Union(int x, int y) {
	if (x == y) {
		return;
	}
	if (up[x] < up[y]) {
		up[x] += up[y];
		up[y] = x;
	}
	else {
		up[y] += up[x];
		up[x] = y;
	}
}

int n, k, l;
int ro[N], ra[N];
map< pair<int, int>, int > cnt;
int x, y;

signed main() {
	scanf("%d%d%d", &n, &k, &l);
	memset(up, -1, sizeof(up));
	for (int i = 1; i <= k; i++) {
		scanf("%d%d", &x, &y);
		Union(Find(x), Find(y));
	}
	for (int i = 1; i <= n; i++) {
		ro[i] = Find(i);
	}
	memset(up, -1, sizeof(up));
	for (int i = 1; i <= l; i++) {
		scanf("%d%d", &x, &y);
		Union(Find(x), Find(y));
	}
	for (int i = 1; i <= n; i++) {
		cnt[{ro[i], Find(i)}]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << cnt[{ro[i], Find(i)}] << ' ';
	}
}

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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def pop_count(i):
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    i = (i + (i >> 4)) & 0x0f0f0f0f
    i = i + (i >> 8)
    i = i + (i >> 16)
    return i & 0x3f

N = INT()
cards = [[]] * 2
cards[0] = LIST()
cards[1] = LIST()

# dp[S][i] := 既に使用したカードの集合がSで、最後に使った(現在の右端の)カードがiの時の最小合計転倒数
dp = list2d(1<<N, N, INF)
for i in range(N):
    # 一番左は何が来ても転倒数0
    dp[1<<i][i] = 0
for S in range(1, 1<<N):
    popcnt = pop_count(S)
    # 各位置より元indexが右側にある出現済要素の個数(転倒数)を前計算しておく
    acc = [0] * N
    for i in range(N):
        if S & 1<<i:
            acc[i] = 1
    # 後ろから累積和
    acc = list(accumulate(acc[::-1]))[::-1]
    for i in range(N):
        if dp[S][i] == INF or not S & 1<<i:
            continue
        # 遷移元の右端カードの表裏を確定
        cur = cards[(i&1)^(1-(popcnt&1))][i]
        for j in range(N):
            if S & 1<<j:
                continue
            # 遷移先の右端カードの表裏を確定
            nxt = cards[(j&1)^(popcnt&1)][j]
            # 昇順が崩れないなら遷移させてOK
            if cur <= nxt:
                # 転倒数を追加して遷移
                dp[S|1<<j][j] = min(dp[S|1<<j][j], dp[S][i] + acc[j])
ans = INF
for i in range(N):
    ans = min(ans, dp[(1<<N)-1][i])
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 104368
#pragma GCC optimize(2)

#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstring>

#include <set>
#include <queue>
#include <complex>
#include <algorithm>

int read(void){
	int res = 0, sign = 1;
	char ch = std::getchar();
	while(!std::isdigit(ch)){
		if(ch == '-')
			sign = -1;
		ch = std::getchar();
	}
	while(std::isdigit(ch))
		res = res * 10 + ch - 48, ch = std::getchar();
	return sign * res;
}

template<class Tp>
	void write(const Tp &x){
		if(x > 9)
			write(x / 10);
		std::putchar(x % 10 + 48);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

const int MAXN = 89;

int n, a[MAXN];
int pos[MAXN], cnt;
ll money = 1000;

int main(){
	n = read();
	for(int i = 1; i <= n; ++i)
		a[i] = read();
	for(int i = 1, j = 1; i <= n; i = j + 1){
		j = i;
		while(a[j + 1] >= a[j])
			++j;
		money = money % a[i] + money / (ll)a[i] * (ll)a[j];
	}
	write(money);
	return 0;
}

Measured memory_bytes: 1532
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a,b,c=map(int,input().split())
print(int(a*b/2))

Measured memory_bytes: 2940
import java.util.*;
import java.util.stream.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		if (x > y) {
			int t = x;
			x = y;
			y = t;
			t = a;
			a = b;
			b = t;
		}
		if (a + b <= 2*c) {
			out.println((a*x + b*y));
		} else {
			int ans1 = x*(2*c) + (y-x)*b;
			int ans2 = y*(2*c);
			out.println(Math.min(ans1, ans2));
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 21844
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n =sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
        if((a+b)%2==0){
            System.out.println((a+b)/2-a);
        } else {
            System.out.println(Math.min(a-1,n-b)+(b-a-1)/2+1);
        }
    }
}


Measured memory_bytes: 23636
import java.util.*;
import java.io.*;
public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String input = sc.next();
        if(input.contains("RRR")) pw.println(3);
        else if(input.contains("RR")) pw.println(2);
        else if(input.contains("R")) pw.println(1);
        else pw.println(0);
        pw.close();
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException
        {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if(x.charAt(0) == '-')
            {
                neg = true;
                start++;
            }
            for(int i = start; i < x.length(); i++)
                if(x.charAt(i) == '.')
                {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                }
                else
                {
                    sb.append(x.charAt(i));
                    if(dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg?-1:1);
        }

        public boolean ready() throws IOException {return br.ready();}


    }
}


Measured memory_bytes: 25432
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
int solveMeFirst(int a, int b) {
 // Hint: Type return a+b; below:
  
}
 
int main() {
  string t;
  cin>>t;
  int count = 0;
  for(int i = 0; i < t.length()/2; i += 1) {
      if(t.at(i) != t.at(t.length()-1-i)) count += 1;
  }
  cout<<count;
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    string s = "AGCT";

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (s.find(S[i]) != string::npos) {
            int end = i;
            while (end + 1 < N && s.find(S[end + 1]) != string::npos) {
                end++;
            }
            ans = max(ans, end - i + 1);
            i = end;
        }
    }
    cout << ans << endl;
}


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

int main(){
    std::string S, T;
    std::cin >> S;
    if(S.size()<1 || S.size()>100){
        std::cout << "error";
        return 1;
    }
    for(int i=0; i<S.size(); i++){
        if((S[i]>='a' && S[i]<='z') || (S[i]>='A' && S[i]<='Z')){
        }
        else{
            std::cout << "error";
            return 1;
        }
    }
    std::cin >> T;
    if(T.size()<1 || T.size()>100){
        std::cout << "error";
        return 1;
    }
    for(int i=0; i<T.size(); i++){
        if((T[i]>='a' && T[i]<='z') || (T[i]>='A' && T[i]<='Z')){
        }
        else{
            std::cout << "error";
            return 1;
        }
    }

    std::string U = T+S;
    std::cout << U;

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long int;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))


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; }


int main(){
	int n,m,d,now;
	int x[1000];
	while(1){
		cin>>n>>m;
		if(!(n||m))break;
		now=0;
		REP(i,n){
			cin>>x[i];
		}
		bool end=false;
		REP(i,m){
			cin>>d;
			now+=d;
			if(end){
				continue;
			}
			if(now>=n-1){
				cout<<i+1<<"\n";
				end=true;
				continue;
			}
			now+=x[now];
			if(now>=n-1){
				cout<<i+1<<"\n";
				end=true;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 10000000000
#define MAX 500008

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  vector<vector<ll>> rc(R,vector<ll>(C,0));
  for(int i=0;i<K;i++){
    int r,c;
    ll v;
    cin>>r>>c>>v;
    r--;
    c--;
    rc[r][c]=v;
  }

  vector<vector<vector<ll>>> sum(R+1,vector<vector<ll>>(C+1,vector<ll>(4,0)));
  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      for(int k=0;k<4;k++){
        sum[i+1][j+1][0]=max<ll>(sum[i+1][j+1][0],sum[i][j+1][k]);
        sum[i+1][j+1][1]=max<ll>(sum[i+1][j+1][1],sum[i][j+1][k]+rc[i][j]);
      }
    }
    for(int j=0;j<C;j++){
      sum[i+1][j+1][0]=max<ll>(sum[i+1][j+1][0],sum[i+1][j][0]);
      for(int k=0;k<3;k++){
        sum[i+1][j+1][k+1]=max<ll>(sum[i+1][j+1][k+1],sum[i+1][j][k+1]);
        sum[i+1][j+1][k+1]=max<ll>(sum[i+1][j+1][k+1],sum[i+1][j][k]+rc[i][j]);
      }
    }
  }

  ll ans=0;
  for(int k=0;k<4;k++){
    ans=max<ll>(ans,sum[R][C][k]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 706504
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll 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(ret);
  return (ret);
}

signed main() {
  init();
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;

  vll A(X);
  rep(i, X) cin >> A[i];
  vll B(Y);
  rep(i, Y) cin >> B[i];
  vll C(Z);
  rep(i, Z) cin >> C[i];

  // solver 1
  vll t;
  rep(i, X) {
    rep(j, Y) {
      t.pb(A[i] + B[j]);
    }
  }
  sort(ALL(t), greater<ll>());

  vll ans;
  rep(i, min((ll)t.size(), K)) {
    rep(j, Z) {
      ans.pb(t[i] + C[j]);
    }
  }
  sort(ALL(ans), greater<ll>());

  rep(i, K) {
    COUT(ans[i]);
  }

  // solver 2
  // sort(ALL(A), greater<ll>());
  // sort(ALL(B), greater<ll>());
  // sort(ALL(C), greater<ll>());
  // vll ans;
  // rep(i, X) {
  //   rep(j, Y) {
  //     rep(k, Z) {
  //       if ((i + 1) * (j + 1) * (k + 1) <= K)
  //         ans.pb({A[i] + B[j] + C[k]});
  //       else
  //         break;
  //     }
  //   }
  // }
  // sort(ALL(ans), greater<ll>());
  // rep(i, K) {
  //   COUT(ans[i]);
  // }

  return 0;
}

Measured memory_bytes: 44092
import sys
input = sys.stdin.readline
enum = enumerate

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	N = int(input())
	vA = linput()
	#vA.sort()
	#vA.reverse()
	
	if N==1:
		print(1)
		return
		
	vC =[a-pp for a,pp in zip(vA[1:],vA)]
		
	res = 0
	pp = 0
	cnt = 0
	for c in vC:
		if c==0: continue
		if pp==0:
			pp = 1 if c>0 else -1
			cnt = 1
			res += 1
			continue
		if c>0 and pp<0:
			cnt = 1
			pp = 0
			continue
		if c<0 and pp>0:
			cnt = 1
			pp = 0
			continue
		cnt += 1
	
	if pp==0:
		res += 1
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 91588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    int month = stoi(S.substr(5, 2));
    if(month <= 4) {
        cout << "Heisei" << endl;
    }
    else {
        cout << "TBD" << endl;
    }
    return 0;
}


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

int main() {
	int a,b;cin>>a>>b;
	if(a<b){
		puts("a < b");
	}
	else if(a>b){
		puts("a > b");
	}
	else puts("a == b");
}

Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

set<int> s;
int N;

int main() {
  cin >> N;
  rep(i, N) {
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  ll a,b,x; cin >> a >> b >> x;
  ll num = b/x;
  ll num1 = 0;
  if(a>=1)num1 = (a-1)/x;
  else num1 = -1;
  out(num-num1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int ans;
int l[520];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)scanf("%d",&l[i]);
	sort(l+1,l+2*n+1);
	for(int i=2;i<=2*n;i+=2)
	 	ans+=l[i-1];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

inline vector<int> digits(unsigned long long n) { // {{{
    vector<int> ret;
    do { ret.push_back(n % 10); n /= 10; } while(n > 0);
    reverse(ret.begin(), ret.end());
    return ret;
} // }}}

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

    int N, M;
    read(N, M);
    vector<int> s(N);
    vector<int> c(N);

    rep(i, M) {
        read(s[i], c[i]);
        --s[i];
    }

    i64 p = 1;
    rep(i, N) p *= 10;
    trace(p);

    rep(i, p) {
        auto d = digits(i);
        if (d.size() != N) continue;
        bool ok = true;
        rep(k, M) {
            ok &= d[s[k]] == c[k];
        }
        if (ok) {
            print(i);
            return 0;
        }
    }

    print(-1);

    return 0;
}


Measured memory_bytes: 256
#include<set>  
#include<map>  
#include<stack>  
#include<cstdio>  
#include<queue>  
#include<cmath>  
#include<vector>  
#include<cstring> 
#include<iostream> 
#include<climits>  
#include<algorithm> 
using namespace std;
#define INF 0x3f3f3f3f
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
#define MAXN 100
char a[4][MAXN+5];
int main(){
	scanf("%s",a[0]);
	scanf("%s",a[1]);
	scanf("%s",a[2]);
	int la[5];
	la[0]=strlen(a[0]),la[1]=strlen(a[1]),la[2]=strlen(a[2]);
	int ta[5]={0},t=0,f=0;
	while(ta[0]<=la[0]&&ta[1]<=la[1]&&ta[2]<=la[2]){
		if(ta[t]==la[t]){f=t;break;}
		t=a[t][ta[t]++]-'a';
	}
	if(f==0) printf("A\n");
	else if(f==1) printf("B\n");
	else printf("C\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        S=S.replaceAll("eraser","-");
        S=S.replaceAll("erase","-");
        S=S.replaceAll("dreamer","-");
        S=S.replaceAll("dream","-");
        S=S.replaceAll("-","");
        if(S.length()==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 28568
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

template<typename Ty>
inline Ty gcd(Ty a, Ty b)
{
	Ty r;
	if (a < b) swap(a, b);
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		ll N;

		cin >> N;
		if (cin.fail()) break;
		vector<PT> V(N);
		for (int i = 0; i < N; i++) {
			cin >> V[i].x >> V[i].y;
		}
		sort(V.begin(), V.end(), [](PT& a, PT b) {
			if (a.y < b.y) return true;
			if (a.y == b.y && a.x < b.x) return true;
			return false;
		});

		bool success = true;
		ll now = 0;
		for (int i = 0; i < N; i++) {
			now += V[i].x;
			if (now > V[i].y) success = false;
		}
		cout << (success ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long 
using namespace std;
typedef pair<int,int> ii;

int fact[1000005];
int mod = 1000000007;
long long qexp(long long b, long long p){
    long long res = 1;
    while(p){
        if(p&1) res = (res * b) % mod;
        b = (b * b) % mod;
        p >>= 1;
    }
    return res;
}
int inv(long long b){ return qexp(b, mod-2); }

signed main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	
	int T = (c - a)*60 + (d-b);
	
	cout << max(0LL, T-e);
	
}


Measured memory_bytes: 3652
# 蟻本1-6-1例題相当
# 今回も、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# 最後に、x,yの取りうる範囲を考慮する

k, s = map(int,input().split())
xmin = (s - 2 * k) if (s - 2 * k) > 0 else 0
xmax = k if k < s else s
count = 0
for x in range(xmin, xmax+1):
  ymin = (s - k - x) if (s - k - x) > 0 else 0
  ymax = k if k < s - x else s - x
  for y in range(ymin, ymax+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)

Measured memory_bytes: 3064
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Dictionary<long, long> a = new Dictionary<long, long>();
			for (int i = 0; i < n; i++) {
				if (a.ContainsKey(vs[i])) {
					a[vs[i]]++;
				} else {
					a.Add(vs[i], 1);
				}
			}

			long ans = 0;
			foreach (var item in a) {
				//System.Diagnostics.Debug.WriteLine($"{item.Key} {item.Value}");
				ans += item.Key * item.Value;
			}

			int q = int.Parse(Console.ReadLine());
			for (int i = 0; i < q; i++) {
				vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
				long b = vs[0];
				long c = vs[1];
				if (a.ContainsKey(b)) {
					ans += (c - b) * a[b];
					if (a.ContainsKey(c)) {
						a[c] += a[b];
					} else {
						a.Add(c, a[b]);
					}
					a.Remove(b);
				}
				Console.WriteLine(ans);
			}

		}
	}
}



Measured memory_bytes: 47668
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    if (n == m) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21972
/**
 *    Author:  "Robin Singh" !!!
 *    BrainyIsTheNewSexy     (CodeForces)
 *    rob_in_1               (Other OJs)
**/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ff first
#define ss second
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr) 
#define nl "\n"
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector < pair<int,int> > vpii;
typedef vector < pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const long double eps = 1e-9;
const long long INF = (1LL<<61);
const int inf = (1<<30);
const int nn = 1e5+5;
//---------------------------------------------*DEBUGGING*--------------------------------------------------------->]
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//----------------------------------------------------------------------------------------------------------------->]
//*****************************************!Template Ends Here!*****************************************************]

int cnt[2][nn];

int main()
{
    
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    IOS;
    int n;
    cin >> n;
    int a[n];
    fr(i, 0, n) {
        cin >> a[i];
        cnt[i%2][a[i]]++;
    }

    int mx1 = 0, mx11 = 0, mx2 = 0, mx22 = 0;
    int n1, n2;

    fr(i, 0, nn){
        if(cnt[0][i] > mx1){
            n1 = i;
            mx11 = mx1;
            mx1 = cnt[0][i];
        }
        else if(cnt[0][i] > mx11){
            mx11 = cnt[0][i];
        }

        if(cnt[1][i] > mx2){
            n2 = i;
            mx22 = mx2;
            mx2 = cnt[1][i];
        }
        else if(cnt[1][i] > mx22){
            mx22 = cnt[1][i];
        }
    }

    if(n1 == n2){
        int mx = max({mx1 + mx22, mx2 + mx11});
        cout << n - mx;
    }
    else cout << n/2-mx1 + n/2-mx2;
    return 0;
}

//->INTUITIONS are not to be ignored. They represent data processed too fast for the conscious mind to comprehend !!


Measured memory_bytes: 1408
#include<stdio.h>

int main(){
	int a,b,c,d;
	scanf("%1d",&a);
	scanf("%1d",&b);
	scanf("%1d",&c);
	scanf("%1d",&d);
	
	if(a+b+c+d==7){
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	}
	else if(a+b+c-d==7){
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	}
	else if(a+b-c+d==7){
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	}
	else if(a+b-c-d==7){
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	}
	
	
		else if(a-b+c+d==7){
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	}
		else if(a-b+c-d==7){
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	}
		else if(a-b-c+d==7){
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	}
		else if(a-b-c-d==7){
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	}
	
	
	
	
}

Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        int S, W;
        intReadLine(out S, out W);
        if(S > W)
        {
            WriteLine("safe");
        }
        else
        {
            WriteLine("unsafe");
        }
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
    
    public static int[] intArrayReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static long[] longArrayReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static List<int> intListReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToList();
    }

    public static List<long> longListReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToList();
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 28184
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

int D[40][40];
int num[3][40];
int cost[3][40][40];

void solve() {
  int N, C;
  cin >> N >> C;

  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= C; j++) {
      cin >> D[i][j];
    }
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      int c;
      cin >> c;
      num[(i + j) % 3][c]++;
    }
  }

  vector<pair<int, int>> v[3];

  for (int i = 0; i < 3; i++) {
    for (int to = 1; to <= C; to++) {
      int cost = 0;
      for (int src = 1; src <= C; src++) {
        if (to == src) {
          continue;
        }
        cost += num[i][src] * D[src][to];
      }
      v[i].emplace_back(cost, to);
    }
    sort(v[i].begin(), v[i].end());
  }

  int ans = INF;
  for (auto &a : v[0]) {
    for (auto &b : v[1]) {
      for (auto &c : v[2]) {
        if (a.second == b.second || b.second == c.second ||
            c.second == a.second) {
          continue;
        }
        ans = min(ans, a.first + b.first + c.first);
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    priority_queue<int> pq;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        pq.push(a);
    }

    while(--m >= 0){
        int a = pq.top();
        pq.pop();
        a /= 2;
        pq.push(a);
    }

    long long ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(void)
{
    int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
    d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

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

using namespace std;

long long int calc(string ex){
	long long int str,cnt,ans=0,now=0,addn=1,addd=1,n=ex.length(),i;
	bool sus=false,minus=false;
	char pm='+',md='*';
	for(i=0; i<n; i++){
		if(sus){
			if(ex[i]=='('){
				cnt++;
			}else if(ex[i]==')'){
				cnt--;
				if(cnt == 0){
					now = calc(ex.substr(str,i-str));
					sus = false;
				}
			}
		}else{
			switch(ex[i]){
				case '(':
					str = i+1;
					cnt = 1;
					sus = true;
					break;
				case '-':
					if(i==0 || ex[i-1]== '+' || ex[i-1]== '-' || ex[i-1]== '*' || ex[i-1]== '/'){
						minus = true;
						break;
					}
				case '+':
					if(minus){
						now *= -1;
						minus = false;
					}
					if(md == '*'){
						addn *= now;
					}else{
						addd *= now;
					}
					if(pm == '+'){
						ans += addn/addd;
					}else{
						ans -= addn/addd;
					}
					pm = ex[i];
					md = '*';
					now = 0;
					addn = 1;
					addd = 1;
					break;
				case '*':
				case '/':
					if(minus){
						now *= -1;
						minus = false;
					}
					if(md == '*'){
						addn *= now;
					}else{
						addd *= now;
					}
					md = ex[i];
					now = 0;
					break;
				case '0':
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
					now *= 10;
					now += ex[i]-'0';
					break;
				default:
					break;
			}
		}
	}
	if(minus){
		now *= -1;
		minus = false;
	}
	if(md == '*'){
		addn *= now;
	}else{
		addd *= now;
	}
	if(pm == '+'){
		ans += addn/addd;
	}else{
		ans -= addn/addd;
	}
	return ans;
}

int main(void){
	int n,i;
	long long int ans;
	string str;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> str;
		ans = calc(str);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

const int MOD = 1000000007;

struct Edge {
    int to;
    int weight;

    Edge(int t, int w) : to(t), weight(w) {}
};

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

    int left = 0;
    int right = 0;
    string ans = S;
    int x = 101;
    for (char c : S) {
        x = min(x, left - right);
        if (c == '(') left++;
        else right++;
    }
    int d_s = left - right;
    x = min(x, d_s);
    int cnt = d_s - x;
    cerr << d_s << endl;
    cerr << cnt << endl;
    while (x) {
        ans = '(' + ans;
        ++x;
    }
    while (cnt) {
        ans += ')';
        cnt--;
    }
    cout << ans  << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n, k;
    vector<int> vec;

    cin >> n >> k;

    for(int i = 0; i < n; ++i)
    {
        vec.emplace_back();
        cin >> vec.back();
    }

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

    int ans = 0;

    for (int i = 0; i < k; ++i)
    {
        ans += vec[i];
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B = inputMap()
    
    tmp = A+B
    
    if tmp < 10:
        print(tmp)
    else:
        print("error")
    
        
if __name__ == "__main__":
	main()


Measured memory_bytes: 39280