akhauriyash/Code-Regression huggingface dataset:
#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;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    h = min(h, 2 * q);
    s = min(s, 2 * h);
    d = min(d, 2 * s);
    cout << (n / 2) * d + (n % 2) * s << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
#define MAXN 100001
int N, M;
vector<pair<int, int>> graph[MAXN];

void dfs(int cur, int id, vector<int> &flg)
{
    flg[cur] = id;
    REP(i, (int)graph[cur].size())
    {
        int point = graph[cur][i].first;
        //  int weight = graph[cur][i].second;
        if (flg[point] == 0)
        {
            dfs(point, id, flg);
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;

    REPS(i, M)
    {
        int x, y, z;
        cin >> x >> y >> z;
        graph[x].emplace_back(y, z);
        graph[y].emplace_back(x, z);
    }

    vector<int> connectComponent(N + 1, 0);
    int count = 0;
    /* connectComponent[1] = 1;
    dfs(1, 1, connectComponent);
    REPS(i, N)
    {
        cout << connectComponent[i] << "\n";
    }
    */
    REPS(i, N)
    {
        if (connectComponent[i] == 0)
        {
            dfs(i, 1, connectComponent);
            count++;
        }
    }
    cout << count << "\n";
    /*  REPS(i, N)
    {
        cout << ((connectComponent[i] > 0) ? 1 : 0) << "\n";
    }*/
}

Measured memory_bytes: 10752
def solve():
    from sys import stdin
    f_i = stdin
    N = int(f_i.readline())
    
    from itertools import combinations
    ans = []
    for m in (map(int, f_i.readline().split()) for i in range(N)):
        for a, b, c in combinations(m, 3):
            if a > b > c:
                ans.append('NO')
                break
        else:
            ans.append('YES')
    print('\n'.join(ans))

solve()


Measured memory_bytes: 5644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <memory.h>
#include <cmath>
#include <queue>


using namespace std;

typedef long long ll;

const int N = 2010;

struct point{
	double x , y;

	bool operator==(const point &rhs)const{
		return fabs(rhs.x - x) < 1e-9 && fabs(rhs.y - y) < 1e-9;
	}
};
int n;

point s , t , cir[N];

double r[N];

double dist(point s , point t){
	return sqrt((s.x - t.x) * (s.x - t.x) + (s.y - t.y) * (s.y - t.y));
}

vector< pair<int,double> > g[N];

double cost[N];

bool vis[N];

struct state{
	int u;
	double cost;

	state(int _u,double _cost){
		u = _u;
		cost = _cost;
	}
	bool operator<(const state &rhs) const{
		return cost > rhs.cost;
	}
};
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%lf%lf%lf%lf",&s.x,&s.y,&t.x,&t.y);
	scanf("%d",&n);
	for(int i = 0 ; i < N ; i++)
		cost[i] = 1e12;

	for (int i = 1; i <= n; ++i){
		scanf("%lf%lf",&cir[i].x,&cir[i].y);
		scanf("%lf",&r[i]);
	}
	for (int i = 1; i <= n; ++i){
		double take = dist(s,cir[i]);
		take -= r[i];
		take = max(0.000000,take);
		g[0].push_back(make_pair(i,take));
		g[i].push_back(make_pair(0,take));
	}
	g[0].push_back(make_pair(n+1,dist(s,t)));
	g[n+1].push_back(make_pair(0,dist(s,t)));
	for (int i = 1; i <= n; ++i){
		double take = dist(t,cir[i]);
		take -= r[i];
		take = max(0.000000,take);
		g[n + 1].push_back(make_pair(i,take));
		g[i].push_back(make_pair(n + 1,take));
	}
	for (int i = 1; i <= n; ++i){
		for (int j = i + 1; j <= n; ++j){
			double take = dist(cir[i],cir[j]);
			take -= r[i] + r[j];
			take = max(0.000000,take);
			g[i].push_back(make_pair(j,take));
			g[j].push_back(make_pair(i,take));
		}
	}
	priority_queue< state > q;
	q.push(state(0,0));
	cost[0] = 0;
	while(!q.empty()){
		state src = q.top();
		q.pop();
		if(vis[src.u])
			continue;
		vis[src.u] = 1;

		cost[src.u] =  src.cost;
		for (int i = 0; i < g[src.u].size(); ++i){
			int v = g[src.u][i].first;

			double newCost = src.cost + g[src.u][i].second;
			if(newCost < cost[v]){
				cost[v] = newCost;
				q.push(state(v,newCost));
			} 
		}
	}
	printf("%.9lf\n",cost[n + 1] );
	return 0;
}

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

namespace ABC129_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var W = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 10000000;
            for (int i = 0; i < N; i++)
            {
                var d1 = W.Take(i).Sum();
                var d2 = W.Skip(i).Take(N-i).Sum();
                ans = Math.Min(ans, Math.Abs(d1 - d2));
            }

            Console.WriteLine(ans);
        }
    }
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  //ikiranai
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,k,ans;
  cin >> n >> k;
  vector<ll> d(k);
  map<ll,ll> mp;
  rep(i,k){
    cin >> d[i];
    mp[d[i]]++;
  }
  for(ll i=n;;i++){
    bool ok1,ok2;
    ok1 = ok2 = false;
    ll j = i;
    while(j>0){
      for(ll m=0;m<=9;m++){
        if(mp[m]>=1 && j%10==m){
          ok1 = true;
          break;
        }
      }
      if(ok1) break;
      else if(j<10){
        ok2 = true;
        break;
      }
      j /= 10;
    }
    if(ok2){
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define	fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(n,arr)  for(int i=0;i<n;i++)cin>>arr[i]; // 0 => n
#define	pi 3.14159265358979323846
#define	endl "\n"
#define f first
#define s second

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5+5 , oo=0x3f3f3f3f , mod=1e9+7;

int main(){
	string a="Sunny";
	string b="Cloudy";
	string c="Rainy";
	string s;cin>>s;
	if(s==a)
		cout<<b;
	else if(s==b)
		cout<<c;
	else if(s==c)
		cout<<a;
	
	return 0;
}

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

using namespace std;

int main()
{
    int n,k,total=0;
    cin>>n>>k;
    int p[n];
    for(int i=0; i<n ; i++)
        cin >> p[i];
    sort(p,p+n);
    for(int i=0 ; i<k ; i++)
        total+=p[i];
    cout<<total;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,a=0,b,c;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    FOR(j,1,N-1){
    if(v[j+1]<v[j]&&v[j]<=v[j-1]||v[j-1]<v[j]&&v[j]<=v[j+1]){
      a++;
    }
    }
    cout << a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef string::const_iterator State;
typedef pair<int, int> Pii;
  
#define fr first
#define sc second
  
bool is_over = false;
  
struct Parser {
  Pii expression(State &idx) {
    Pii ret = term(idx);
    //if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '+' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr + tmp.fr;
	ret.sc = ret.sc + tmp.sc;
      } else if ( *idx == '-' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr - tmp.fr;
	ret.sc = ret.sc - tmp.sc;
      } else {
	break;
      }
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    return ret;
  }
    
  Pii term(State &idx) {
    Pii ret = factor(idx);
    while ( 1 ) {
      if ( *idx == '*' ) {
	idx++;
	Pii tmp = factor(idx), tmp2 = ret;
	ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc;
	ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr;
      } else {
	break;
      }
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    return ret;
  }
  
  Pii factor(State &idx) {
    Pii ret;
    if ( *idx == '(' ) {
      idx++;
      ret = expression(idx);
      idx++;
    } else {
      ret = number(idx);
    }
    return ret;
  }
  
  Pii number(State &idx) {
    int tmp = 0;
    while ( '0' <= *idx && *idx <= '9' ) {
      tmp *= 10;
      tmp += *idx - '0';
      if ( abs(tmp) > 10000 ) is_over = true;
      idx++;
    }
    if ( *idx == 'i' ) {
      idx++;
      return Pii(0, 1);
    }
   
    else return Pii(tmp, 0);
  }
};
  
int main()
{
  string s;
  while ( cin >> s ) {
    is_over = false;
    Parser ps;
    string tmp = s.substr(0, s.size() - 1);
    State idx = s.begin();
  
    Pii ret = ps.expression(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    if ( is_over ) cout << "overflow" << endl;
    else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl;
    else if ( ret.fr == 0 ) printf("%di\n", ret.sc);
    else if ( ret.sc == 0 ) printf("%d\n", ret.fr);
    else printf("%d%+di\n", ret.fr, ret.sc);
  }
  
  return 0;
}

Measured memory_bytes: 3276
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int x, cnt; double sum[10000];
int main() {
	while (true) {
		cin >> x; if (x == -1) { break; }
		sum[0] = x / 2.0; cnt = 0;
		while (abs(x - sum[cnt] * sum[cnt] * sum[cnt]) > 0.00001*x) {
			cnt++;
			sum[cnt] = sum[cnt - 1] - ((sum[cnt - 1] * sum[cnt - 1] * sum[cnt - 1] - x) / (3 * sum[cnt - 1] * sum[cnt - 1]));
		}
		cout << fixed << setprecision(20) << sum[cnt] << endl;
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
int pre[maxn],suf[maxn],a[maxn][3];
int n;
int main(){
	cin>>n;
	for (int j=1;j<=2;j++){
		for (int i=1;i<=n;i++){
			scanf("%d",&a[i][j]);
		}
	}
	for (int i=1;i<=n;i++){
		pre[i]=pre[i-1]+a[i][1];
	}
	for (int i=n;i>=1;i--){
		suf[i]=suf[i+1]+a[i][2];
	}
	int res=0;
	for (int i=1;i<=n;i++){
		res=max(res,pre[i]+suf[i]);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3768
#include<stdio.h>
#define MAX 1000010

int isPrime(int n){
  int i;
  if(n<2)return 0;
  if(n==2)return 1;
  if(n%2==0)return 0;
  for(i=3;i<=n/i;i+=2)
    if(n%i==0)
      return 0;
  return 1;
}

int main(){
  int a,i;
  int prime[MAX];
  for(i=0;i<=MAX;i++)
    prime[i]=isPrime(i);
  for(i=1;i<MAX;i++)
    prime[i]+=prime[i-1];
  while(scanf("%d",&a)!=EOF){
    printf("%d\n",prime[a]);
  }
  return 0;
}

Measured memory_bytes: 4500
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 一括読み
#N, K, *A = map(int, open(0).read().split())


# 整数の入力
n = int(input())

# スペース区切りの入力
#n, x = input().split()

# スペース区切りの整数の入力
#n, m = map(int, input().split())
#n, x = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#a = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#print("a", a, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#b = []
#for x in range(m):
#  b.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def ton(n, k, x):
  s = ""
  while n > 0:
    s = str(n%k) + s
    n //= k
  return s


#print("a", a, file=sys.stderr)
#print("b", b, file=sys.stderr)

def getEnergy():
  for y in b:
    yield y

def doit():
  total = b[0] + b[n-2]
  prev = None
  for x in b:
    if not prev == None:
      total += min(prev, x)
    prev = x
  return total

def yn():
  if doit():
    return "Yes"
  else:
    return "No"

#print(doit([0] * 4))
#doit(a)
#print(doit())
try:
  #doit()
  print(doit())
  #print(yn())
except Exception as e:
  print("e", e, file=sys.stderr)


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

int main(){
    int x, a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }
    else{
        cout << 10 <<endl;
    }
    return 0;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 5222;

struct Man {
    int h, p;
};
int n;
Man a[N];

int main() {
    ios::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i].h >> a[i].p;
    sort(a, a + n, [](Man const& x, Man const& y) {
        return x.h + x.p < y.h + y.p;
    });

    ll d[2][N];
    memset(d, 0x3f, sizeof(d));
    d[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
        int i1 = i & 1;
        d[i1][0] = 0;
        for (int cnt = 1; cnt <= i; ++cnt) {
            d[i1][cnt] = d[i1^1][cnt];
            if (a[i-1].h >= d[i1^1][cnt-1])
                d[i1][cnt] = min(d[i1][cnt], d[i1^1][cnt-1] + a[i-1].p);
        }
    }
    
    int ans = 0;
    for (int i = 0; i <= n; ++i)
        if (d[n&1][i] < LINF)
            ans = i;
    cout << ans << "\n";

    return 0;
}


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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      return 0;
    } else {
      string row(W, '#');
      for (int i = 0; i < H; i++) {
        cout << row << endl;
      }
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3140
use rand::{Rng, SeedableRng};
use rand::rngs::SmallRng;
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        d: i32,
        c: [i32; 26],
        s: [[i32; 26]; d],
    }
    let mut greedy_result = greedy(d, &c, &s);
    local_search(d, &c, &s, &mut greedy_result.contests);
    let s: String = greedy_result.contests.iter()
                    .map(|x| (x+1).to_string())
                    .collect::<Vec<String>>()
                    .join("\n");
    println!("{}", s);
}

struct BestResult {
    satification: i32,
    contests: Vec<usize>
}

fn greedy(d: i32, c: &Vec<i32>, s: &Vec<Vec<i32>>) -> BestResult {
    let mut satification = 0;
    let mut last: Vec<i32> = vec![0; 26];
    let mut contests: Vec<usize> = vec![0; d as usize];
    for i in 1..d+1 {
        let mut best_contest: usize = 1;
        let mut best_satification = -1_000_000_000;
        for t in 0..26 {
            let pre_last = last[t];
            last[t] = i;
            last[t as usize] = i as i32;
            let tmp_satification = {
                satification
                + s[(i-1) as usize][t as usize]
                - last.iter().zip(c).map(|(l, c)| c*(i as i32 - l)).sum::<i32>()
            };
            last[t] = pre_last;
            if best_satification < tmp_satification {
                best_contest = t;
                best_satification = tmp_satification;
            }
        }
        satification = best_satification;
        last[best_contest] = i;
        contests[(i-1) as usize] = best_contest;
        // println!("{}", best_contest+1);
    }
    BestResult{
        satification,
        contests
    }
}

fn local_search(d: i32, c: &Vec<i32>, s: &Vec<Vec<i32>>, contests: &mut Vec<usize>) {
    let mut rng = SmallRng::from_entropy();
    let day = rng.gen_range(0, d) as usize;
    let changed_contest = rng.gen_range(0, 26);
    let mut change = s[day][contests[day]];
    // 変更する操作を無かったことにするための差分
    change += match contests[day..d as usize]
                    .iter()
                    .position(|x| *x == contests[day]) {
        Some(x) => - c[contests[day-1]]*(x - day) as i32,
        None => match contests[..day-1 as usize]
                      .iter().rev()
                      .position(|x| *x == contests[day-1]) {
            Some(x) => c[contests[day-1]]*(day - x) as i32,
            None => c[changed_contest] * day as i32
            }
    };
    // 変更後の差分
    change+= s[day-1][changed_contest];
    change -= match contests[day..d as usize]
                    .iter()
                    .position(|x| *x == changed_contest) {
        Some(x) => c[changed_contest]*(x - day) as i32,
        None => 0
    };
    change -= match contests[..day-1 as usize]
                    .iter().rev()
                    .position(|x| *x == contests[day-1]) {
        Some(x) => c[changed_contest]*(day - x) as i32,
        None => c[changed_contest] * day as i32
    };

    if change > 0 {
        contests[day-1] = changed_contest;
    }

}

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

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

  string result = "consonant";
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    result = "vowel";
  }

  cout << result << endl;
}


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

p = 0
Z = []

for a in A :
    d = a - p
    Z.append(d)
    p = a

B = K - A[N-1]
Z[0] = B + A[0]
print( K - max(Z) )


Measured memory_bytes: 26420
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;



int main() {
	double X, Y;
	cin >> X >> Y;
	double a = (Y - 2 * X) / 2;
	double b = (4 * X - Y) / 2;
	double A = a - floor(a);
	double B = b - floor(b);
	if (A != 0) {
			cout << "No" << endl;
			return 0;
	}
	if (B != 0) {
			cout << "No" << endl;
			return 0;
	}
	if (a < 0) {
		cout << "No" << endl;
		return 0;
	}
	if (b < 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	string s; std::cin >> s;
	ll k; std::cin >> k;
	int len = (int)s.size();
	if (s == string(len, s[0])) {
		std::cout << len * k / 2 << "\n";
		return 0;
	}
	ll eqCnt1 = 0;
	rep(i, len - 1) {
		if (len && s[i] == s[i+1])
			eqCnt1++, i++;
	}
	ll eqCnt2 = 0;
	rep(i, len * 2 - 1) {
		if (s[i % len] == s[(i+1) % len])
			eqCnt2++, i++;
	}
	ll ans = eqCnt1 + (eqCnt2 - eqCnt1) * (k - 1);
	std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <limits>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  vector<int> v(S.size()+1, 0), w(T.size()+1, 0);
  REP(i, S.size()) {
    v[i+1] = v[i] + (S[i] == 'A' ? 1 : -1);
  }
  REP(i, T.size()) {
    w[i+1] = w[i] + (T[i] == 'A' ? 1 : -1);
  }
  int Q;
  cin >> Q;
  REP(_, Q) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int cS = v[B] - v[A-1], cT = w[D] - w[C-1];
    cout << ((cS - cT) % 3 == 0 ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2000+5,base=2001*3;
int f[N*3][N*6],mod;
void add(int &x,int y){
	x=(x+y)%mod;
}
signed main(){
	int n;
	cin>>n>>mod;
	n*=3;
	f[0][base]=1;
	for(int i=0;i<n;++i)
		for(int j=-i;j<=i;++j)
			if(f[i][j+base]){
				add(f[i+1][j+1+base],f[i][j+base]);
				add(f[i+2][j-1+base],1ll*f[i][j+base]*(i+1)%mod);
				add(f[i+3][j+base],1ll*f[i][j+base]*(i+1)%mod*(i+2)%mod);
			}
	int ans=0;
	for(int j=0;j<=n;++j)
		add(ans,f[n][j+base]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 238632
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LFR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')
fact = [i for i in range(2 * 10 ** 6 + 1)]
fact[0] = 1
for i in range(2 * 10 ** 6):
    fact[i + 1] *= fact[i]
    fact[i + 1] %= mod
invfact = fact[:]
invfact[-1] = pow(invfact[-1], mod - 2, mod)
for i in range(2 * 10 ** 6, 0, -1):
    invfact[i - 1] = i * invfact[i]
    invfact[i - 1] %= mod

def combination_mod(n, k, mod):
    """ power_funcを用いて(nCk) mod p を求める """ 
    """ nCk = n!/((n-k)!k!)を使用 """
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = fact[n]
    b = invfact[k]
    c = invfact[n - k]
    return (a * b * c) % mod

#solve
def solve():
    k = II()
    s = S()
    ans = pow(26, len(s) + k, mod)
    sk = len(s) + k
    for i in range(len(s)):
        ans -= combination_mod(sk, i, mod) * pow(25, sk - i, mod)
        ans %= mod
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 163128
import java.util.Scanner;
public class Main {
	public static void main (String[]args) {
		Scanner teclado = new Scanner (System.in);
		int a;
		int b;
		a=teclado.nextInt();
		b=teclado.nextInt();
		
		if(a >=0 && a <=100 && b%2==0 && b >=2 && b <=1000) {
			if(a >= 13 ) {
				System.out.println(b);
			}else if(a >=6 && a <= 12) {
				System.out.println(b/2);
			}else {
				System.out.println(0);
			}
		}
		
		
	}
}




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

using namespace std;

int ap[999];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

    int i, j;
    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j <= m; j ++)
        {
            char c;
            do
            {
                scanf("%c", &c);
            }
            while(!(c >= 'a' && c <= 'z'));

            ap[c - 'a' + 1] ++;
        }
    }

    int imp = 0, cas2 = 0;
    for(i = 1; i <= 26; i ++)
    {
        imp += (ap[i] % 2);

        if(ap[i] % 4 != 0)
        {
            if(ap[i] % 4 >= 2)
                cas2 ++;
        }
    }

    if(imp > 1)
    {
        printf("No\n");

        return 0;
    }

    if(imp == 1)
    {
        if(!(n % 2 == 1 && m % 2 == 1))
        {
            printf("No\n");

            return 0;
        }
    }

    if(cas2 > 0)
    {
        int pos = 0;

        if(n % 2)
            pos += m / 2;

        if(m % 2)
            pos += n / 2;

//        printf("AVEM %d %d\n", pos, cas2);

        if(cas2 > pos)
        {
            printf("No\n");

            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int[][] f;
	static int[][] step;
	static int w,h,xs,ys,xg,yg;
	static Ice[] ice;
	static int iceCount;
	static int[] v1={1,0,-1,0};
	static int[] v2={0,-1,0,1};
	static int a;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			w=cin.nextInt();
			h=cin.nextInt();
			if(w+h==0){
				break;
			}
			a=0;
			f=new int[h][w];
			step=new int[h][w];
			ice=new Ice[h*w/2];
			for(int i = 0;i<h;i++){
				for(int j = 0;j<w;j++){
					step[i][j]=h*w*2;
				}
			}
			for(int i = 0;i<h;i++){
				String s = cin.next();
				for(int j = 0;j<s.length();j++){
					if(s.charAt(j)=='.'){
						f[i][j]=-1;
					}
					else if(s.charAt(j)=='#'){
						f[i][j]=-2;
					}
					else if(s.charAt(j)=='X'){
						f[i][j]=-3;
					}
					else if(s.charAt(j)=='S'){
						xs=i;
						ys=j;
						f[i][j]=-1;
						step[i][j]=0;
					}
					else{
						xg=i;
						yg=j;
						f[i][j]=-1;
					}
					
				}
			}
			iceCount=0;
			for(int i = 0;i<h;i++){
				for(int j = 0;j<w;j++){
					if(f[i][j]==-3){
						a=0;
						bfsIce(i,j);
						ice[iceCount++]=new Ice(a);
					}
				}
			}
			bfs(xs,ys);
			System.out.println(step[xg][yg]);
		}
	}
	static void bfs(int x,int y){
		//System.out.println(x+" " +y + " " + step[x][y]);
		for(int i =0;i<4;i++){
			
			int xx=x+v1[i];
			int yy=y+v2[i];
			if(xx<0||xx>=h||yy<0||yy>=w){
				continue;
			}
			if(f[xx][yy]!=-2){
				if(f[xx][yy]>=0){
					ice[f[xx][yy]].step++;
					if(ice[f[xx][yy]].isBroken()){
						//System.out.println("break "+f[xx][yy]+" " + xx+" " + yy);
						ice[f[xx][yy]].step--;
						continue;
					}
				}
				if(step[x][y]+1 <= step[xx][yy]){
					step[xx][yy]=step[x][y]+1;
					bfs(xx,yy);
				}
				if(f[xx][yy]>=0){
					ice[f[xx][yy]].step--;
				}
			}
		}
	}
	static void bfsIce(int x,int y){
		f[x][y]=iceCount;
		a++;
		for(int i = 0;i<4;i++){
			int xx=x+v1[i];
			int yy=y+v2[i];
			if(xx<0||xx>=h||yy<0||yy>=w){
				continue;
			}
			if(f[xx][yy]==-3){
				bfsIce(xx,yy);
			}
		}
	}
}
class Ice{
	int size;
	int step;
	boolean isBroken(){
		return size/2+1 <= step;
	}
	Ice(int a){
		size=a;
		step=0;
	}
}
class Field{
	int type;
	int size;
	int step;
	Field(int a){
		size=a;
		step=0;
	}
	
}

Measured memory_bytes: 12000
/***
 ** " Your limitation it's only your imagination. "
 ** 	-- Pablo Picasso
***/

/**
  *  Author: dhruv_gheewala
  *  Date:   28.03.2020
  *  Time:   18:05:09
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif


typedef unsigned int ui;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(),s.end()
#define test int __T__=1;if(testcases)cin>>__T__;while(__T__--)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

ll seed;auto random_address=[]{char *p=new char;delete p;return (uint64_t)p;};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()*(random_address()|1));
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a)
{in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a)
{for(auto &x : a)in>>x;return in;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}

int main()
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    int k,n;
    test{

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

    for(int i = 0; i < n; i++)
    	a[i]%=k;


    ll ans;
    vi diff(n);
    ans = diff[0] = (a[0] - a[n-1] + k)%k;
    for(int i = 1; i < n; i++)
    {
    	diff[i] = a[i] - a[i-1];
    	ans += diff[i];
    }


    d(diff);
    ans -= *max_element(all(diff));
    cout<<ans<<endl;

    fundri;
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n======\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

Measured memory_bytes: 1792
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = IS()
    x = int(n)
    fx = sum(int(ni) for ni in n)
    if x%fx==0: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)998244353;
const ll N = 1e5+5, inf = 1e17;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  int a; cin >> a;
  cout << a + a*a + a*a*a << endl;
}

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

int main()
{
	int counter=0;
	string s;
	cin >> s;
	char arr0[1000010];
	char arr1[1000010];
	for(int i=0;i<1000010;i++)
	{
		if(i%2==0)
		{
			arr0[i]='0';
		}
		else
		{
			arr0[i]='1';
		}
	}
	
	for(int i=1;i<1000010;i++)
	{
		if(i%2==0)
		{
			arr1[i-1]='0';
		}
		else
		{
			arr1[i-1]='1';
		}
	}
	bool nol=false;
	if(s[0]=='0')
	{
		nol = true;
	}
	else
	{
		nol=false;
	}
	if(nol==true)
	{
		for(int i=0;i<s.length();i++)
		{
			if(s[i]!=arr0[i])
			{
				counter++;
			}
		}
	}
	else
	{
		for(int i=0;i<s.length();i++)
		{
			if(s[i]!=arr1[i])
			{
				counter++;
			}
		}
	}
	cout << counter << endl;
	
	
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

main()
{
	IO;
	int n;
	cin>>n;
	
	vector<int> v(n),ans(n,0);
	
	for(int i=0;i<n;i++)
	cin>>v[i];
	
	ans[1]=abs(v[1]-v[0]);
	
	for(int i=2;i<n;i++)
	{
		ans[i]=min(ans[i-1]+abs(v[i]-v[i-1]),ans[i-2]+abs(v[i]-v[i-2]));
	}
	
	cout<<ans[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    double m=0,y=380000;
    cin>>n;
    for(int i=0;i<n;i++){
        string u;
        double x;
        cin>>x>>u;
        if(u=="JPY"){
            m+=x;
        }else{
            m+=x*y;
        }
    }
    cout<<setprecision(20)<<m<<endl;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1 && b==2){
    cout << 3 << endl;
  }
  if(a==1 && b==3){
    cout << 2 << endl;
  }
  if(a==2 && b==1){
    cout << 3 << endl;
  }
  if(a==2 && b==3){
    cout << 1 << endl;
  }
  if(a==3 && b==2){
    cout << 1 << endl;
  }
  if(a==3 && b==1){
    cout << 2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a;
  cin >> a;
  char B=a-32;
  char C=a+32;
  if(97 <= a && a <= 123){
  cout << "a" << endl;
  }
  else{
    cout<< "A" << endl;
  }
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
const int mod = 1e9+7;
using namespace std;
int main()
{
    long long s,c;
    cin >> s >> c;
    if(s * 2 > c)cout << c/2<<endl;
    else cout << s+ (c-2*s)/4 <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    std::string s;
    cin >> s;
    const int n = s.size()+1;

    int l[n];
    int cnt = 0;
    for(int i=0; i<n-1; i++){
        l[i] = cnt;
        if(s[i]=='<'){
            cnt++;
        }else{
            cnt = 0;
        }
    }
    l[n-1] = cnt;

    int r[n];
    cnt = 0;
    for(int i=n-1; i>0; i--){
        r[i] = cnt;
        if(s[i-1]=='>'){
            cnt++;
        }else{
            cnt = 0;
        }
    }
    r[0] = cnt;

#if 0
    for(int i=0; i<n-1; i++){
        printf(" %c ", s[i]);
    }
    printf("\n");
    for(int i=0; i<n-1; i++){
        printf("%2d ", l[i]);
    }
    printf("%2d\n", l[n-1]);
    for(int i=0; i<n-1; i++){
        printf("%2d ", r[i]);
    }
    printf("%2d\n", r[n-1]);
#endif
    long long int sum = 0;
    for(int i=0; i<n; i++){
        sum += std::max(l[i], r[i]);
    }
    cout << sum << endl; 
    return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M;
	cin >> N >> M;
	int H[N], A[M], B[M];
	for(int i=0;i<N;i++){
		cin >> H[i];
	}
	int R[N], G[N];
	for(int i=0;i<N;i++){
		R[i] = 0;
		G[i] = 0;
	}
	for(int j=0;j<M;j++){
		cin >> A[j] >> B[j];
		R[A[j] - 1]++;
		R[B[j] - 1]++;
		if (H[A[j] - 1] > H[B[j] - 1]) G[A[j] - 1]++;
		if (H[B[j] - 1] > H[A[j] - 1]) G[B[j] - 1]++;
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		if(R[i] == G[i])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5560
import itertools
L,R=map(int,input().split())

A=[]
D=[]

if R-L+1<2019:
    for i in range(R-L+1):
        A.append((i+L)%2019)

    if A.count(1)>=2:
        B=set(A)
        B.add(1)
    else:
        B=set(A)

    C=list(itertools.combinations(B,2))
    for j in range(len(C)):
        D.append(C[j][0]*C[j][1]%2019)
    E=sorted(D)
    print(E[0])
else:
    print(0)


Measured memory_bytes: 243384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <string.h>
#include <math.h>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef long double ld;
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define pb push_back
#define _1 first
#define _2 second

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1000000007;
const int alphabet = 26;
const int MAXINT = 2e5+1;

int n;
string s, t;

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

    bool ans = true;
    if( s.size()+1 != t.size()  ) ans = false;
    else FOR(i,0,s.size()) ans = ans && (s[i]==t[i]);
    printf("%s\n", (ans?"Yes":"No"));
}

/*

*/  

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

int main()
{
	int X, Y, Z;
	int K;
	cin >> X >> Y >> Z >> K;

	vector<long long> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];

	vector<long long> AB(X * Y);
	for (int i = 0; i < X; i++)
	{
		for (int j = 0; j < Y; j++)
		{
			AB[i * Y + j] = A[i] + B[j];
		}
	}

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

	int W = min(X * Y, K);

	vector<long long> ABC(W * Z);
	for (int i = 0; i < W; i++)
	{
		for (int j = 0; j < Z; j++)
		{
			ABC[i * Z + j] = AB[i] + C[j];
		}
	}

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

	for (int i = 0; i < K; i++)
	{
		cout << ABC[i] << endl;
	}
}

Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int N;
long double v[51];

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v,v+N);
    long double sum = 0;
    long long div = 2;
    for(int i=N-1;i>0;i--){
        sum += v[i]/div;
        div*=2;
    }
    sum += v[0]/(div/2);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys 
# sys.stdin = open('input.txt', 'r')  
# sys.stdout = open('output.txt', 'w') 
n, d = map(int, input().split())
d = d * d
ans = 0
for _ in range(n):
	x, y = map(int, input().split())
	if d >= (x * x) + (y * y):
		ans += 1

print(ans)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int x, a, b;

int main() {
	cin >> x >> a >> b;
	
	cout << (abs(a - x) < abs(b - x) ? "A" : "B") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const int mod = 1e9 + 7;

int main (){
    int n, minimo = 1000, maximo = -1001, ans = mod;
    cin >> n;

    vector<int> v(n);

    for (int i=0; i<n; i++){
        cin >> v[i];
        minimo = min(minimo, v[i]);
        maximo = max(maximo, v[i]);
    }

    for (int i=minimo; i<= maximo; i++){
        int sum = 0;

        for (int j=0; j<n; j++){
            sum += abs(v[j] - i)*abs(v[j] - i);
        }
        ans = min(ans, sum);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, X;
    cin >> N >> X;
    vector<int>Ms(N);
    for (int i=0; i<N; i++){
        cin >> Ms[i];
        X -= Ms[i];
    }
    sort(all(Ms));
    cout << X / Ms[0] + N << endl;
}

Measured memory_bytes: 256
#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 <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

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


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	int n;
	string s;
	cin >> n >> s;
	vi a(n+1);
	vi b(n+1);
	int scnt = 0;
	int pcnt = 0;
	repr(i, 1, n+1) {
		if (s[i-1] == '#') {
			a[i] = a[i - 1] + 1;
			b[i] = b[i - 1];
			scnt++;
		}
		else {
			a[i] = a[i - 1];
			b[i] = b[i - 1] + 1;
			pcnt++;
		}
	}
	int ans = INFL;
	rep(i, n+1) {
		//cout << a[i] << ' ' << b[i] << endl;

		ans = min(ans, (b[n] - b[i] + a[i]));
		//cout << ans << ' ' << (b[n] - b[i] + a[i]) << endl;
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
// #define rep(i,n) for(int i=0;i<n;++i)
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ALL(x) (x).begin(),(x).end()
#define pb(x)  push_back(x);
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int N, L;
    cin >> N >> L;
    int total = 0;
    int eat = 1000;
    rep(i,0,N) {
        int taste = L+i;
        total += taste;
        if(abs(taste) < abs(eat)) eat = taste;
    }
    cout << (total-eat) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAXN = 200000;
int arr[MAXN];

int main() {
	int N, T;
	cin >> N >> T;
	
	for (int i = 0; i < N; ++i) {
		cin >> arr[i];
	}
	
	if (N == 1) {
		cout << T;
		return 0;
	}
	
	long long int result = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (arr[i+1] - arr[i] < T) {
			result += (arr[i+1] - arr[i]);
		} else {
			result += T;
		}
	}
	result += T;
	
	cout << result;
	
	return 0;
}

Measured memory_bytes: 1024