akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=221,M=20;
short f[N][N][N][M];
int i,j,k,x,y,u,v,n,m,mid,l,r,s[N][N];
char p[N][N];
void init(){
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%s",p[i]+1);
        for(j=1;j<=m;j++)
            s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(p[i][j]=='.');
    }
}
void work(){
    if(s[n][m]==0||s[n][m]==n*m){
        printf("0");
        return;
    }
    for(i=1;i<=n;i++)
        for(l=1;l<=m;l++)
            for(r=l;r<=m;r++){
                f[i][l][r][0]=i-1;
                for(j=i;j<=n;j++)
                    if((s[j][r]-s[i-1][r]-s[j][l-1]+s[i-1][l-1])%((r-l+1)*(j-i+1))==0)
                        f[i][l][r][0]=j;
            }
    for(k=1;k<M;k++){
        for(i=1;i<=n;i++)
            for(l=1;l<=m;l++)
                for(r=l;r<=m;r++){
                    f[i][l][r][k]=max(f[i][l][r][k-1],f[f[i][l][r][k-1]+1][l][r][k-1]);
                    u=l;v=r-1;
                    while(u<v){
                        mid=u+v+1>>1;
                        if(f[i][l][mid][k-1]>=f[i][mid+1][r][k-1])
                            u=mid;
                        else
                            v=mid-1;                    
                    }
                    f[i][l][r][k]=max(f[i][l][r][k],max(min(f[i][l][v][k-1],f[i][v+1][r][k-1]),min(f[i][l][v+1][k-1],f[i][v+2][r][k-1])));
                }
        if(f[1][1][m][k]==n){
            printf("%d",k);
            return;
        }
    }

}
int main(){
    init();
    work();
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string S[105];

bool check(ll n) {
    FOR(i, n, 1) {
        if (S[i][0] != S[i - 1][S[i - 1].size() - 1])
            return false;

        REP(j, i) {
            if (S[i] == S[j])
                return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> S[i];
    }

    if (check(N))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;

const int MAX_N = 100;
const int MAX_MONEY = 500 * MAX_N;
int n;
int p[MAX_N];
pair<char, int> memo[MAX_N][MAX_MONEY];

inline void Change(pair<char, int> &a, pair<char, int> &b) {
    if ((a.first < b.first) || (a.first == b.first && a.second > b.second))
        a = b;
}

pair<char, int> Solve(int idx, int money) {
    if (idx == n)
        return pair<char, int>(0, 0);

    auto &opt = memo[idx][money];
    if (opt.second != -1)
        return opt;

    // idx?????????????????§????????????
    opt = Solve(idx + 1, money);

    // idx?????????????????§??????
    if (0 < (p[idx] % 1000) && (p[idx] % 1000) <= 500) {
        // 1000????????§?????????
        int res = 1000 - (p[idx] % 1000) - 500 + money;
        auto tmp = Solve(idx + 1, res);
        tmp.first += 1;
        tmp.second += p[idx];
        Change(opt, tmp);
    }
    else if (p[idx] % 1000 == 0) {
        if (500 <= money) {
            int res = money - 500;
            auto tmp = Solve(idx + 1, res);
            tmp.first += 1;
            tmp.second += p[idx];
            Change(opt, tmp);
        }
    }
    else if (500 <= money + 1000 - (p[idx] % 1000)) {
        // 1000????????¨?°????money??§?????????
        int res = money + 1000 - (p[idx] % 1000) - 500;
        auto tmp = Solve(idx + 1, res);
        tmp.first += 1;
        tmp.second += p[idx];
        Change(opt, tmp);
    }
    else {
        // 1000??????????????§?????????
        int res = 1000 - (p[idx] % 1000) + money;
        auto tmp = Solve(idx + 1, res);
        tmp.second += p[idx];
        Change(opt, tmp);
    }

    return opt;
}

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

    while (cin >> n, n) {
        for (int i = 0; i < n; ++i)
            cin >> p[i];

        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n * 500; ++j)
                memo[i][j] = pair<char, int>(0, -1);

        auto res = Solve(0, 0);
        cout << (int)res.first << ' ' << res.second << endl;
    }

    return 0;
}

Measured memory_bytes: 42220
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


vector<vector<pii>> r, rr;
VI usd;

void ckdfs(int s, const int p, const vector<vector<pii>>& cr){
	if(usd[s] & p) return;
	usd[s] |= p;
	for(auto z: cr[s]) ckdfs(z.first, p, cr);
}

vector<ll> bellman(int s){
	int n = sz(r);
	const ll inf = 1LL<<60;
	vector<ll> ds(n, inf);
	ds[s] =0;
	for(int i =0, nxt =1; i<n+3 && nxt>0 ; i++){
		nxt = 0;
		rep(j, n) if(usd[j]==3) for(auto z: r[j]) if(usd[z.first]==3){
			if(ds[j] != inf && ds[z.first] > ds[j] + z.second){
				ds[z.first] = ds[j] + z.second;
				nxt = 1;
			}
		}
		if(i>n ) {ds[s]=ds[0]=-1; return ds;}
	}
	return ds;
}



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, p;
	cin >>n >>m >>p;
	
	r.resize(n); rr.resize(n);
	
	rep(i, m){
		int a,b,c;
		cin >>a >>b >>c;
		a--; b--; c -=p;
		r[a].emplace_back(b, -c);
		rr[b].emplace_back(a, -c);
	}
	usd.resize(n);
	ckdfs(0, 1, r);
	ckdfs(n-1, 2, rr);
	
	
	auto rv = bellman(0);
	//for(auto x :rv) printf("%lld, ",x); puts("");
	if(rv[0]==-1) puts("-1");
	else{
		cout << max(0LL, -rv.back()) <<"\n";
		 
	}
	return 0;
}


Measured memory_bytes: 640
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import gcd
def main():
    n, m = map(int, input().split())
    s = tuple(input())
    t = tuple(input())

    if n > m:
        l1 = n
        l2 = m
        s1 = s
        s2 = t
    else:
        l1 = m
        l2 = n
        s1 = t
        s2 = s

    if s[0] != t[0]:
        r = -1
    elif n == m:
        if s == t:
            r = n
        else:
            r = -1
    elif n % m == 0 or m % n == 0:
        ld = l1 // l2
        for i1 in range(1, l2):
            if s2[i1] != s1[i1*ld]:
                r = -1
                break
        else:
            r = l1
    else:
        l = (n * m) // gcd(n, m)
        # x = [0] * l
        ld1 = l // l1
        ld2 = l // l2
        cnt = 1
        r = l
        while cnt < l1:
            cnt2 = cnt * ld1
            if cnt2 % ld2 == 0:
                if s1[cnt] != s2[cnt2 // ld2]:
                    r = -1
                    break
            cnt += 1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 83400
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int n;
int id[200000];
void initialize()
{
    for(int i=0;i<200000 ; i++)
        id[i] = i;
}

int root (int x)
{
    while(id[x] != x)
    {
        id[x] = id[id[x]];
        x = id[x];
    }
    return x;
}

void union1 (int x, int y)
{
    int p = root(x) , q = root(y);
    id[p] = id[q];
}

int main()
{
    initialize();
    vector < pair < int , ii > > v;
    vector < pair < ii , int > > v2 , v3;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v2.push_back(mp(mp(x,y) , i));
        v3.push_back(mp(mp(y,x) , i));
    }
    sort(v2.begin() , v2.end());
    sort(v3.begin() , v3.end());
    for(int i=1;i<n;i++)
    {
        pair < ii , int > X1 = v2[i];
        pair < ii , int > X2 = v2[i-1];
        int cost = abs(X2.fr.fr-X1.fr.fr);
        v.push_back(mp(cost , mp(X1.sc , X2.sc)));

        X1 = v3[i];
        X2 = v3[i-1];
        cost = abs(X2.fr.fr-X1.fr.fr);
        v.push_back(mp(cost , mp(X1.sc , X2.sc)));

    }
    sort(v.begin() , v.end());
    ll ans = 0;
    for(int i=0;i<v.size();i++)
    {
        int cost = v[i].fr;
        ii node = v[i].sc;
        if(root(node.fr)!= root(node.sc))
        {
         union1(node.fr,node.sc);
         ans+=cost;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 7980
n = int(input())
A = sorted([int(input()) for _ in range(n)])

from collections import deque
que = deque(A)

# p1 <= p2 >= p3 <= ...
ans = deque([que.popleft()])
cur = 0
while que:
    if cur % 2 == 0:
        ans.appendleft(que.pop())
        if len(que):
            ans.append(que.pop())
        cur ^= 1
    else:
        ans.appendleft(que.popleft())
        if len(que):
            ans.append(que.popleft())
        cur ^= 1

res1 = 0
for i in range(n - 1):
    res1 += abs(ans[i] - ans[i + 1])

# p1 >= p2 <= p3 >= ...
que = deque(A)
ans = deque([que.pop()])
cur = 1
while que:
    if cur % 2 == 0:
        ans.appendleft(que.pop())
        if len(que):
            ans.append(que.pop())
        cur ^= 1
    else:
        ans.appendleft(que.popleft())
        if len(que):
            ans.append(que.popleft())
        cur ^= 1

res2 = 0
for i in range(n - 1):
    res2 += abs(ans[i] - ans[i + 1])

print(max(res1, res2))

Measured memory_bytes: 87472
# coding: utf-8
N = int(input())
d = {}
for i in range(N):
    a = int(input())
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1
ans = 0
for a in d.items():
    ans += a[1] % 2
print(ans)

Measured memory_bytes: 15072
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 100005



int main(void){
	int n,a;
	cin>>n;
	ll ans=0;
	rep(i,n){
		cin>>a;
		ans += a-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
H, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
 
r = any(all(i < z for i in x) and all(i >= z for i in y) for z in range(X+1, Y+1))
print("No War" if r else "War")

Measured memory_bytes: 3060
import java.io.PrintWriter
import java.lang.StringBuilder

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    var x = readLong()

    val sb = StringBuilder()
    while (x > 26) {
        x -= 1
        val tmp = x % 26
        x /= 26
        sb.append('a' + tmp.toInt())
    }
    x -= 1
    sb.append('a' + x.toInt())
    println(sb.reverse())
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34568
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	solve := func() int {
		if k == 1 {
			return 0
		}

		n = n % k
		if n > k-n {
			n = k - n
		}
		return n
	}()

	fmt.Println(solve)
}


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

bool solve(const vector<int> &a, int x) {
    deque<int> b;
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] >= x) b.push_back(1);
        else b.push_back(0);
    }
    b.push_front(b[0]);
    b.push_back(b.back());
    
    int mid = b.size() / 2;
    int left, right;
    for (int i = mid - 1; i >= 0; --i) {
        if (b[i] == b[i+1]) {
            left = i;
            break;
        }
    }
    for (int i = mid + 1; i  < b.size(); ++i) {
        if (b[i-1] == b[i]) {
            right = i;
            break;
        }
    }
    if (right - mid >= mid - left) return b[left];
    else return b[right];
}

int main() {
    int N, K; cin >> N;
    vector<int> a(N * 2 - 1);
    for (int i = 0; i < N * 2 - 1; ++i) cin >> a[i];

    int low = 0, high = N*2;
    while (high - low > 1) {
        int mid = (high + low) / 2;
        if (solve(a, mid)) low = mid;
        else high = mid;
    }
    cout << low << endl;
}


Measured memory_bytes: 1904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false); 
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>21){
        cout<<"bust";
    }else{
        cout<<"win";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);
	
	LL n = 1000000000000;
	cin >> n;
	LL ans = 0;
	for(int i = 1; i * (LL) i <= n; ++i)
		if (n % i == 0)
		{
			LL m = n / i - 1;
			if (m > i)
				ans += m;
		}
		
	cout << ans << endl;	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


Measured memory_bytes: 256
def main():
    V, E = map(int,raw_input().split())
    adj = [[float('inf')]*V for i in xrange(V)]
    for i in xrange(E):
        s,t,d = map(int,raw_input().split())
        adj[s][t] = d
    for i in xrange(V):
        adj[i][i] = 0

    for k in xrange(V):
        for i in xrange(V):
            for j in xrange(V):
                adj[i][j] = min(adj[i][j],adj[i][k]+adj[k][j])

    diag = [adj[i][i]==abs(adj[i][i]) for i in xrange(V)]
    if False in diag:
        print "NEGATIVE CYCLE"
    else:
        for item in adj:
            for i in xrange(V):
                d = item[i]
                if i!=V-1:
                    if d==float("inf"):
                        print "INF",
                    else:
                        print d,
                else:                    
                    if d==float("inf"):
                        print "INF"
                    else:
                        print d

if __name__ == "__main__":
    main()

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

long long n,a[200005],dp[200005][20],rez;

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

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        for(int j=0;j<20;j++)
            if((1<<j)&a[i])
                dp[i][j]++;
    }
    for(int i=1;i<=n;i++)
        for(int j=0;j<20;j++)
            dp[i][j]+=dp[i-1][j];

    long long l=1,d=1;
    while(d<=n)
    {
        long long ind=0;
        for(int i=0;i<20;i++)
            if(dp[d][i]-dp[l-1][i]>1)
                ind=1;
        if(ind==0)
        {
            if(d==n)
                rez+=(d-l+1)*(d-l)/2+(d-l+1);
            d++;
        }
        else
        {
            rez+=d-l;
            l++;
        }
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 36472
#include <iostream>
using namespace std;
int main(){
    string ans;
    int A,B,C;
    cin >> A >> B >> C;
    if (A==B and B==C and C==A and A>0 and B>0 and C>0){
    ans = "Yes";
    } else {
    ans = "No";
    }
    
    cout << ans <<"\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n,a,b,c,d,sum=0;
  cin>>n>>a>>b;
  c=n/(a+b);
  d=min(n%(a+b),a);
  sum=c*a+d;
  cout<<sum<<endl;
  return 0;
  }



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N) {
    cin >> S[i];
    replace(all(S[i]), '?', '{');
  }
  string T;
  cin >> T;
  S.push_back(T);
  N++;
  sort(all(S));
  int li = lower_bound(all(S), T) - S.begin();
  int ui = upper_bound(all(S), T) - S.begin();
  bool izryt = false;
  reps(i, li, ui) {
    if(izryt) cout << " ";
    cout << i+1;
    izryt = true;
  }
  int rank = ui;
  reps(i, ui, N) {
    int len = min(T.size(), S[i].size());
    rep(j, len) {
      if(S[i][j] == '{') {
	if(izryt) cout << " ";
	cout << ++rank;
	izryt = true;
	break;
      }
      if(S[i][j] > T[j]) break;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 896
<?php

class Queue {
    private $arr = [];
    private $size = 0;
    
    public function push($item) {
        $this->size++;
        array_push($this->arr, $item);
    }
    
    public function pop() {
        $this->size--;
        return array_shift($this->arr);
    }
    
    public function isEmpty() {
        return $this->size === 0;
    }
}
while (true) {
    $s = trim(fgets(STDIN));
    if ($s === "0") {
        break;
    }
    search($s);
}

function search($s) {
    $length = strlen($s);
    $que = new Queue();
    $que->push([0, $s]);
    $dic = [];
    $r = "";
    $g = "";
    $b = "";
    for ($i = 0; $i < $length; $i++) {
        $r .= "r";
        $g .= "g";
        $b .= "b";
    }
    $singles = [$r, $g, $b];
    $ok = false;
    while (!$que->isEmpty()) {
        list($score, $state) = $que->pop();
        if (isSingleColor($state, $singles)) {
            echo $score . "\n";
            $ok = true;
            break;
        }
        for ($i = 0; $i < $length - 1; $i++) {
            $c1 = $state[$i];
            $c2 = $state[$i + 1];
            if ($c1 != $c2) {
                $c3 = other($c1, $c2);
                $newState = substr_replace($state, $c3, $i, 2);
                if (!array_key_exists($newState, $dic)) {
                    $dic[$newState] = $score + 1;
                    $que->push([$score + 1, $newState]);
                }
            }
        }
    }
    if (!$ok) {
        echo "NA\n";
    }
}



function isSingleColor($s, $singles) {
    foreach ($singles as $single) {
        if ($s === $single) {
            return true;
        }
    }
    return false;
}

function other($c1, $c2) {
    if ($c1 === "r") {
        if ($c2 === "g") {
            return "bb";
        } elseif ($c2 === "b") {
            return "gg";
        }
    } elseif ($c1 === "g") {
        if ($c2 === "r") {
            return "bb";
        } elseif ($c2 === "b") {
            return "rr";
        }
    } elseif ($c1 === "b") {
        if ($c2 === "r") {
            return "gg";
        } elseif ($c2 === "g") {
            return "rr";
        }
    }
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int x, y, z;
  size_t k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
 
  vector<ll> ab; 
  rep(i, x) {
    rep(j, y) {
      ab.push_back(a[i] + b[j]);
    }
  }
  sort(ab.begin(), ab.end());
  reverse(ab.begin(), ab.end());

  vector<ll> ans;
  int last = min(ab.size(), k);
  rep(i, last) {
    rep(j, z) {
      ans.push_back(ab[i] + c[j]);
    }
  }
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());

  rep(i, k) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  
  vector<int> vec(3);
  vec.at(0) = N / 100;
  vec.at(1) = (N - (vec.at(0) * 100)) / 10;
  vec.at(2) = N - (vec.at(0) * 100 )- (vec.at(1) * 10);
  
  reverse(vec.begin(), vec.end());
  int rev = (vec.at(0) * 100) + (vec.at(1) * 10) + vec.at(2);
  
  if(N == rev)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#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>;

const int N_MAX = 100;

int T = 1;
int d[N_MAX];
int f[N_MAX];
vector<int> v[N_MAX];

struct node{
    vector<int> near;
    int dis;
    int fin;
    bool found = false;
};

void dfs(int idx){
    d[idx] = T;
    ++T;
    rep(i, (int)v[idx].size()){
        int x = v[idx][i];
        if(d[x] == 0) dfs(x);
    }
    f[idx] = T;
    ++T;
}

int main() {
    int n;
    cin >> n;
    
    rep(i, n){
        int m, l;
        cin >> m >> l;
        --m;
        rep(j, l){
            int x;
            cin >> x;
            --x;
            v[m].push_back(x);
        }
    }
    
    rep(i, n){
        if(d[i] == 0) dfs(i);
    }
    
    rep(i, n){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <stack>
using namespace std;
int main(void){
  string x;
  stack<char> st;
  cin>>x;
  for(int i=0;i<x.size();i++){
    if(!st.empty()&&st.top()=='S'&&x[i]=='T')st.pop();
    else st.push(x[i]);
  }
  cout<<st.size()<<endl;
  return 0;
}

Measured memory_bytes: 644
import sys
from collections import Counter
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    l = list(IL())
    a = Counter(l)
    f = s = 0
    l = list(set(l))
    l.sort(reverse=True)
    for rep in l:
        if 4<=a[rep]:
            f = max(f,rep)
            s = max(s,rep)
            break
        elif 2<=a[rep]:
            if f==0:
                f = rep
            else:
                s = rep
                break
    
    print(f*s)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 120288
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int x;
    cin>>x;
    set<int> st;
    for(int i=1;i<=1000;i++){
        for(int j=2;j<=10;j++){
            int cnt=1;
            rep(k,j) cnt*=i;
            if(cnt>1000) break;
            st.insert(cnt);
        }
    }
    int k=*begin(st);
    st.erase(k);
    while(!st.empty()){
        if(*begin(st)>x) break;
        k=*begin(st);
        st.erase(k);
    }
    cout<<k<<endl;
}

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

int main(){
int a[10001],n,cnt=0;

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

for(int i=0; i<n ;) {
if(a[i]%2==0){
cnt++;
a[i]/=2;
}else i++;
}

cout << cnt;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    int ans=0;
    int si=S.size();
    for(int i=0; i<si; i++){
        if(S[i]!=S[si-i-1]){
            ans++;
        }
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

b = [None for i in range(n)]

j = 0
for i in range(n-1, -1, -2):
    b[j] = a[i]
    j += 1

# if n % 2:
#     start = 0
# else:
#     start = 1

for i in range(n%2, n-1, 2):
    b[j] = a[i]
    j += 1


# print(b)


for i in range(n):
    print(b[i], end =" ")

print()


Measured memory_bytes: 26180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	ll a, b, x;
	cin >> a >> b >> x;
	if (a == 0 || a % x == 0) {
		cout << (b / x) - (a / x) + 1 << endl;
	}
	else {
		cout << (b / x) - (a / x) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        
        StringBuilder ans = new StringBuilder();
        
        for (int i = 0; i<n.length();i++) {
            if (n.charAt(i) == '1')
                ans.append('9');
            else if (n.charAt(i) == '9')
                ans.append('1');
        }
        System.out.println(ans);
    }
}


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

int main(){
    int_fast64_t N;
    scanf("%lld", &N);
    vector<int_fast64_t> D, d(N + 1);
    for(int_fast64_t i = 0; i < N; ++i) {
        scanf("%lld", &d[i]);
    }
    d[N] = 0;
    sort(d.begin(), d.end());
    for(int_fast64_t i = 0; i <= N; ++i){
        if(i & 1){
            D.push_back(d[i]);
        }else{
            D.push_back(-d[i]);
            D.push_back(24 - d[i]);
        }
    }
    sort(D.begin(), D.end());
    int_fast64_t ans(numeric_limits<int_fast64_t>::max());
    for(int_fast64_t i = 1; i < D.size(); ++i){
        ans = min(ans, D[i] - D[i - 1]);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 384
program coloring_colorfully
  implicit none
  character(100000) :: s
  integer :: n, i, o0, o1, e0, e1
  read(*,*) s
  s = trim(adjustl(s))
  n = len_trim(s)
  o0 = 0
  o1 = 0
  e0 = 0
  e1 = 0
  do i = 1, n, 2
    if (s(i:i).eq."0") then
      o0 = o0 + 1
    else
      o1 = o1 + 1
    end if
  end do
  do i = 2, n, 2
    if (s(i:i).eq."0") then
      e0 = e0 + 1
    else
      e1 = e1 + 1
    end if
  end do
  write(*,'(i0)') n - max(o0+e1,o1+e0)
  stop
end program coloring_colorfully

Measured memory_bytes: 2596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC141
    {
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static double ReadDouble()
        {
            return double.Parse(Console.ReadLine());
        }

        static double[] ReadDoubles()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static string[] ReadStringSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        static void A()
        {
            var s = ReadString();
            switch (s)
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
            }
        }

        static void B()
        {

        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void Main(string[] args)
        {
            A();
            //B();
            //C();
            //D();
        }
    }
}


Measured memory_bytes: 25764
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

const int MOD = 1000000007;

int n, k;

signed main()
{
    cin >> n >> k;

    int res = 0;
    FOR(i, k, n+2){//how many choose
        int ma=0, mi=0;
        mi = ((0 + i-1)%MOD) * i / 2;
        ma = (n + n-i+1) * i / 2;
        res = (res + ma - mi + 1) % MOD;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] nums = Console.ReadLine().Split(' ');
    int N1 = int.Parse(nums[0]);
    int N2 = int.Parse(nums[1]);
    int Sum = 0;
    
    if(N1 > N2)
    {
      Sum += N1;
      N1 -= 1;
      if(N1 > N2) Sum += N1;
      else Sum += N2;
    }
    else
    {
      Sum += N2;
      N2 -= 1;
      if(N1 < N2) Sum += N2;
      else Sum += N1;
    }  
    Console.Write(Sum);
  }
}

Measured memory_bytes: 11092
j;M;m;main(N,q){
int c[9]={};
for(scanf("%d",&N);N--;q<8?c[q]=1:M++)scanf("%d",&q),q/=400;
for(;j<8;j++)M+=c[j],m+=c[j];
m?:m++;
printf("%d %d",m,M);
}

Measured memory_bytes: 1656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        int n = sc.nextInt();
        double p[] = new double[n];
        for(int i = 0; i < n; i++)
        {
        	p[i] = sc.nextDouble();
        }
        
        double dp[][] = new double[n+1][n+1];
        dp[0][0] = 1;
        for(int j = 1; j <= n; j++)
        	dp[0][j] = 0;
        
        for(int i = 1; i <= n; i++)
        {
        	for(int j = 0; j <= n; j++)
        	{
        		dp[i][j] = dp[i-1][j]*(1-p[i-1]);
        		if(j > 0) dp[i][j] += dp[i-1][j-1]*p[i-1];
        	}
        }
        
        double ans = 0;
        int heads = 0;
        int tails = 0;
        for(int i = 0; i <= n; i++)
        {
        	heads = i;
        	tails = n-i;
        	if(heads > tails)
        	{
        		ans += dp[n][i];
        	}
        }
        out.println(ans);
        out.close();
	}

}


Measured memory_bytes: 131020
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol mem[3000];
lol dp(int sum){
  if(sum<=2) return sum==0;
  if(mem[sum]!=0) return mem[sum];
  lol ans=0;
  for(int i=3;i<=sum;i++){
    ans+=dp(sum-i);
    ans%=MOD;
  }
  return mem[sum]=ans;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s;
  cin >>s;
  cout <<dp(s)<<'\n';
  return(0);
}

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

int main(){
    char S;
    cin >> S;

    if(S == 'a' || S == 'i' || S == 'u' || S == 'e' || S == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from itertools import accumulate, islice
from bisect import bisect_left

n = int(input())
xs = list(map(int, input().split()))

ys = list(accumulate(xs))
zs, total = ys[:-1], ys[-1]

res = max(xs) - min(xs)
for i, z in islice(enumerate(zs), 1, n-1):
    j = bisect_left(zs, z//2)
    splits = ((zs[j+k], z - zs[j+k]) for k in (-1, 0, 1) if 0 <= j+k <= i)
    a, b = min(splits, key=lambda s: abs(s[0]-s[1]))

    j = bisect_left(zs, (total - z)//2 + z)
    splits = ((zs[j+k] - z, total - zs[j+k])
              for k in (-1, 0, 1) if i <= j+k <= n-2)
    c, d = min(splits, key=lambda s: abs(s[0]-s[1]))

    minn, _, _, maxx = sorted((a, b, c, d))
    if maxx - minn < res:
        res = maxx - minn

print(res)


Measured memory_bytes: 32776
#include<bits/stdc++.h>
using namespace std;
int main()
{
 unsigned long long s,sum = 0,i=0;
 cin>>s;
 while(++i<=s){
      if(!(i%3==0 || i%5==0))sum+=i;
    }
 cout<<sum<<endl;
 return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    ll a,b;cin>>a>>b;
    ll cnt=0;
    ll x;cin>>x;
    rep(i,n-1){
        ll y;cin>>y;
        cnt+=min((y-x)*a,b);
        x=y;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
// Author : ps41

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 1e9 + 7, N = 1e6 + 5;

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll tmp = n / i;
        ans += i * (tmp * (tmp + 1)) / 2;
    }
    cout << ans;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h> 
#define rep(i,a,b) for(int i = a; i <= b; ++i)
using namespace std;
const int MAXN = 5e5 + 10;
string s;
int a[MAXN];
int n;
int ans, x;
int main() {
	cin >> s;
    n = s.length();
    for (int i = 0, j = n - 1; i < n; ++i, --j) {
		a[i] = s[j] - '0';
	}
    for (int i = 0, sx = 0; i < n; ++i) {
        sx += a[i] * 9;
        a[i] = sx % 10;
        sx /= 10;
        if (sx && i == n - 1) n++;
    }
    rep(i, 0, n - 1) x += a[i];
    for (ans = 1; ans <= n * 20; ++ans) {
        a[0] += 9;
        x += 9;
        for (int i = 0, sx = 0; i < n; ++i) {
            sx += a[i];
            x -= a[i];
            a[i] = sx % 10;
            x += a[i];
            sx /= 10;
            if (!sx) break;
            if (i == n - 1) ++n;
        }
        if (x <= 9 * ans) break;
    }
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    string s;
    cin>>s;
    int n = 0;
    for(int i = 0; i < sz(s); i++){
        n=n*10+(s[i]-'0');
        n%=9;
    }   
    if(n%9==0)cout<<"Yes\n";
    else cout<<"No\n";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3740
#include<iostream>
#include<algorithm>
#include<tuple>
#include<vector>

using namespace std;

int main(){

    while(1){
        int h, w;
        cin>> h>> w;
        if(!(h||w)) break;
        vector<tuple<int, int, int>> V;// sum, height, width
        for(int i=1; i<=200; i++){
            for(int j=i+1; j<=200; j++){
                V.push_back(make_tuple(i*i+j*j, i, j));
            }
        }
        sort(V.begin(), V.end());
        for(int i=0; i<V.size(); i++){
            int s, _h, _w;
            tie(s, _h, _w)=V[i];
            if((s==h*h+w*w)&&h==_h&&w==_w){
                tie(s, _h, _w)=V[i+1];
                cout<< _h<< " "<< _w<< endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3380
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        for (int i = 0; i <= Y / 10000; i++) {
            for (int j = 0; j <= Y / 5000; j++) {
                int k = N - i - j;
                if (k >= 0 && Y == i * 10000 + 5000 * j + 1000 * k) {
                    System.out.printf("%d %d %d", i, j, k);
                    return;
                }
            }
        }
        System.out.print("-1 -1 -1");
    }
}

Measured memory_bytes: 21844
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main()
{
int a;
cin>>a;
string op;
cin>>op;
int b;
cin>>b;
if(op=="+") cout<<a+b<<endl;
else cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

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


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1;i<= N;i++){
        int temp = 0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                temp++;
            }
        }
        if(i%2!=0&&temp==8){
            ans++;
        }

    }
    cout << ans << endl;

}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,50000) {
        if (int(i * 1.08) == n) {
            cout << i;
            return 0;
        }
    }
    cout << ":(";
    return 0;
}


Measured memory_bytes: 256
# 解説動画から、子供はRLのようにRとLが変わるところに集まってくる
# 10^100回移動する（偶数回） 
S = input().strip()
N = len(S)
a = [0] * N
 
for i in range(N):
    # RがLに変わる境界に注目 問題文より左から処理する場合一番左はRなのでRLを考えればよい
    if S[i] == 'R' and S[i+1] == 'L':
        x = 0 # 初期化 
        # まずRについて処理。Lに変わったbreak 
        for j in range(i, -1, -1): # このループでRがx個つながっていることがわかる
            if S[j] == 'L' :
                break
            x += 1
        # a[i] はR、a[i+1]はL　Sの左から偶数桁か奇数桁かで
        # RまたはLどちらにあつまる子供かわかるので
        # 偶奇でそれぞれ処理を行う
        a[i] += (x+1) // 2
        a[i+1] += x // 2
        
        x = 0 # 初期化
        # 次にLについて処理。Rに変わったらbreak
        for j in range(i+1, N):
            if S[j] == 'R' :
                break
            x += 1
        a[i] += (x) // 2
        a[i+1] += (x+1) // 2
        
for i in range(N):
    print(a[i], end=' ')

# 実際に手を動かして数えてみること重要。

Measured memory_bytes: 4864
#include<stdio.h>
#define mod 1000000007
int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int i,a[n+1],k;
  for(i=0;i<=n;i++)a[i]=1;
  for(i=0;i<m;i++){
    scanf("%d",&k);
    a[k]=0;
  }
  int s[n+1];
  s[0]=1;s[1]=a[1];
  for(i=2;i<=n;i++){
    s[i]=(s[i-1]+s[i-2])*a[i]%mod;
  }
  printf("%d",s[n]);
}
  	

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll k,n,a[1000005],mn=0;
    cin >> k >> n;
    rep(i,1,n){
        cin >> a[i];
    }
    rep(i,1,n-1) mn=max(mn,a[i+1]-a[i]);
    mn=max(mn,a[1]+k-a[n]);
    cout << k-mn << endl;
    return 0;
}

Measured memory_bytes: 3840