akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const int N = 1e3+9, M = 1e5+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
int  h,w;
int memo[N][N];
char grid[N][N];
int solve(int i=0,int j=0)
{  
  if(i==h && j==w) return 1;
  
  int &ret =memo[i][j];
  if(~ret) return ret;
  ret=0;
  if(i+1<=h && grid[i+1][j]!='#') ret += solve(i+1,j)%MOD;
  if(j+1<=w && grid[i][j+1]!='#') ret += solve(i,j+1)%MOD;

  return ret%MOD;
}
int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d%d",&h,&w);
  for(int i=0;i<h;++i) scanf("%s",grid[i]);
  h--,w--;
  printf("%d\n",solve());

  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 5248
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n,k] = nextIntArray()
    let ans = 1000000001
    let h = []
    while(hasNext()){
        h.push(nextInt())
    }
    h.sort((a,b)=>a-b)
    for(let i = k-1;i<h.length;i++){
        ans = Math.min(ans, h[i]-h[i-k+1])
    }
    console.log(ans)
}
Main()



Measured memory_bytes: 43024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;


	bool ok = false;
	if (a < c && c < b) {
		ok = true;
	} else if (b < c && c < a) {
		ok = true;
	}

	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

bool isPrime(long long n);

int main(){
    long long count2=0,N;
    cin >> N;
    vector<long long> a(N);
    for(int i=0;i<N;i++){
        cin >> a.at(i); 
    }

    bool count;
    for(int i=0; i<N; i++){
        count = isPrime(a.at(i));
        if(count){
            count2++;
        }
    }
    cout << count2 << '\n';
    return 0;
}

    bool isPrime(long long n){
        if(n == 2)return true;
        if(n <= 1 || n % 2 == 0)return false;
        for(long long i = 3; i * i <= n; i+=2){
            if(n % i == 0)return false;
        }
        return true;
    }


Measured memory_bytes: 3172
package main

import (
  "fmt"
  "sort"
)

func main() {
  a := make([]int, 3)
  for i := 0; i < 3; i++ {
    fmt.Scan(&a[i])
  }
  sort.Ints(a)
  fmt.Println(a[2] - a[0])
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	int n, k, ans=1;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		ans = min(2 * ans, ans + k);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 13
#define N1 3
#define N2 2
using namespace std;
void Drop(int,int,int);
int data[N][N];
int dy[N1]={-1,0,1};int dx[N1]={-1,0,1};
int dy2[N2]={-1,1};int dx2[N2]={-1,1};
int dy3[N1+1]={-2,0,2,0};int dx3[N1+1]={0,2,0,-2};
int main(){
  int x,y,size,maxv=0,cnt=0;
  while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
    Drop(y+2,x+2,size);
  }
  for(int i=2;i<N-1;i++){
    for(int j=2;j<N-1;j++){
      maxv=max(maxv,data[i][j]);
      if(data[i][j]==0) cnt++;
    }
  }
  cout << cnt << endl << maxv << endl;
  return 0;
}
void Drop(int y,int x,int size){
  for(int i=0;i<N1;i++)
    for(int j=0;j<N1;j++)
      data[y+dy[i]][x+dx[j]]++;
  if(size==1)
    for(int i=0;i<N2;i++)
      for(int j=0;j<N2;j++)
	data[y+dy2[i]][x+dx2[j]]--;
  if(size==3)
    for(int i=0;i<N1+1;i++)
      data[y+dy3[i]][x+dx3[i]]++;
}

Measured memory_bytes: 1208
import java.io.*;
class Main{
  public static void main(String[] args){
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
    
    try{
      
      String str2 = "abc";
      String str3 = "acb";
      String str4 = "bac";
      String str5 = "bca";
      String str6 = "cba";
      String str7 = "cab";
      
    String str1 = br.readLine();
    
      if(str1.equals(str2) || str1.equals(str3) || str1.equals(str4) || 
         str1.equals(str5) || str1.equals(str6) || str1.equals(str7) ){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      
    }catch(Exception e) {
    }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using TP = tuple<int,int,int,int>;

int main()
{
	int N, M, r, q, t, n, m, s, ts, te;
	while (cin >> N >> M, N || M) {
		vector<TP> use;
		cin >> r;
		while (r--) {
			cin >> t >> n >> m >> s;
			if (s) {
				use.push_back(TP(n, m, t, 0));
			}
			else {
				for (size_t j = use.size() - 1; j >= 0; j--) {
					if (get<0>(use[j]) == n && get<1>(use[j]) == m) {
						get<3>(use[j]) = t;
						break;
					}
				}
			}
		}
		cin >> q;
		while (q--) {
			cin >> ts >> te >> m;
			int res = 0;
			for (int k = ts; k < te; k++) {
				for (size_t j = 0; j < use.size(); j++) {
					if (get<1>(use[j]) == m && get<2>(use[j]) <= k && get<3>(use[j]) > k) {
						res++;
						break;
					}
				}
			}
			cout << res << endl;
		}
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int ans=0;
  for (int i=1; i<=n; i++) {
    int cnt=1,tmp=i;
    while(tmp/10) {
      tmp/=10;
      cnt++;
    }
    if (cnt%2) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

#define INF 1e9

// ??????????????????
// s: ????§??????????, adjlist: ??£??\????????? (first: ????????? second: ?????????)
vector<int> dijk(int s, vector<vector<pair<int, int> > > adjlist){
  int v = adjlist.size();
  priority_queue<pair<int, int > > wait;
  vector<int> result(v, 1e9);
  int nowpoint, nowcost;

  // ??????????????°????????????
  result[s] = 0;
  wait.push(make_pair(0, s));

  // ????????????????????¬???
  while (!wait.empty()) {
    // ??????
    nowpoint = wait.top().second;
    nowcost = -wait.top().first;
    wait.pop();
    // ????????????????????¢?´¢??????????????????????????§????????´?????????????£???°???
    if (result[nowpoint] < nowcost) { continue; }
    
    // ?????????????????¨??£??\??????????????????????????????????????????
    for (int i = 0; i < adjlist[nowpoint].size(); i++) {
      int nextpoint = adjlist[nowpoint][i].second;
      int nextcost = nowcost + adjlist[nowpoint][i].first;
      // ??¢?´¢????????????????????°?????§???????????§????????°??????????????´??°??????????????????????????\??????????´?
      if(result[nextpoint] > nextcost){
        result[nextpoint] = nextcost;
        wait.push(make_pair(-nextcost, nextpoint));
      }
    }
  }

  // ?????????: ?????????
  return result;
}


int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }
    
    int a, b, cost, time;
    vector<vector<pair<int, int> > > adjlist_cost(m);
    vector<vector<pair<int, int> > > adjlist_time(m);
    for(int i = 0; i < n; i++){
      cin >> a >> b >> cost >> time;
      --a;
      --b;
      adjlist_cost[a].push_back(make_pair(cost, b));
      adjlist_cost[b].push_back(make_pair(cost, a));
      adjlist_time[a].push_back(make_pair(time, b));
      adjlist_time[b].push_back(make_pair(time, a));
    }

    int k;
    cin >> k;

    int p, q, r;
    vector<int> result;
    for(int i = 0; i < k; i++){
      cin >> p >> q >> r;
      --p;
      --q;
      result = (r == 0) ? dijk(p, adjlist_cost) : dijk(p, adjlist_time);
      cout << result[q] << endl;
    }
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  sort(s.begin(), s.end());
  
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  // ll ans = 0;
  bool ok = (s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]);

  // cout << ans << endl;
  cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3596
N = int(input())
A = list(map(int,input().split()))

dp = [[0]*3100 for _ in range(3100)]
for length in range(1,N+1):
    for i in range(N-length+1):
        j = i + length

        # 先手番
        if (N-length)%2 == 0:
            dp[i][j] = max(dp[i+1][j] + A[i], dp[i][j-1] + A[j-1])

        # 後手番
        else:
            dp[i][j] = min(dp[i+1][j] - A[i], dp[i][j-1] - A[j-1])

print(dp[0][N])

Measured memory_bytes: 117852
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	if N == 1 {
		fmt.Println("YES")
		return
	}

	A := make([]int, 0, N)
	var total int
	for i := 0; i < N; i++ {
		v := nextInt()
		A = append(A, v)
		total += v
	}

	removeNum := N * (N + 1) / 2
	if total%removeNum != 0 {
		fmt.Println("NO")
		return
	}

	total /= removeNum
	for i := 0; i < N; i++ {
		t := A[i] - A[(i+1)%N] + total
		if t < 0 || t%N != 0 {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

// ---------- Util.


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  int r;
  cin>>r;
  cout<<fixed<<setprecision(15)<<3.1415926535*2*r<<endl;

}


Measured memory_bytes: 3756
#include<cstdio>
#include<algorithm>
using namespace std;
int n,t[2],a[5][100010],to[100010];
inline int abs(int x){
    return x>=0?x:-x;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=3;i++)
        for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    for(register int i=1;i<=n;i++){
        to[i]=a[2][i]/3+1;
        if(!((a[1][i]-a[2][i]==-1&&a[2][i]-a[3][i]==-1&&a[1][i]%3==1)||(a[1][i]-a[2][i]==1&&a[2][i]-a[3][i]==1&&!(a[1][i]%3)))||(abs(i-to[i])&1)){
            puts("No");
            return 0;
        }
        t[i&1]^=(a[1][i]>a[2][i]);
    }
    for(register int i=1;i<=n;i++){
        while(to[i]!=i){
            t[i&1^1]^=1;
            swap(to[i],to[to[i]]);
        }
    }
    puts(t[0]||t[1]?"No":"Yes");
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
lamps = [0] * N
next_ = 0
count = 0
buttons = list(map(lambda x: int(x) - 1, (input() for _ in range(N))))
while True:
    count += 1
    lamps[next_] = 1
    next_ = buttons[next_]
    if next_ == 1:
        break
    if lamps[next_]:
        count = -1
        break

print(count)


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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  bool kawaisou = false;
  if (a == b && a != c) kawaisou = true;
  if (b == c && b != a) kawaisou = true;
  if (c == a && c != b) kawaisou = true;
  if (kawaisou) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
	int N, i, ans = 0;
  cin >> N;
  int A[N];
  for(i=0; i<N; i++){
    cin >> A[i];
  }
  
  for(i=0; i<N-2; i++){
    if ((A[i] < A[i+1] && A[i+1] < A[i+2]) || (A[i] > A[i+1] && A[i+1] > A[i+2])){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  int D,X;cin>>D>>X;
  int ans = X;
  REP(i,N) {
    int a;cin>>a;
    int tmp = 0;
    while (a*tmp+1<=D) {
      ans++;
      tmp++;
    }
  }
  OUT(ans);

  return 0;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct UF {
  vector<int> data;
  int group;
  UF(int size) : data(size, -1), group(size) {}
  bool merge(int x, int y){
    x = root(x), y = root(y);
    if (x != y){
      group--;
      if (data[x] > data[y]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return (x != y);
  }
  int root(int x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int count(){
    return group;
  }
};

int main()
{
  int w, h;
  while (h = in(), w = in(), w){
    vector<string> field;
    for (int i = 0; i < h; i++){
      string s;
      cin >> s;
      field.push_back(s);
    }
    UF uf(h * w);
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        for (int d = 0; d < 4; d++){
          static const int dx[] = {0, 0, 1, -1};
          static const int dy[] = {1, -1, 0, 0};
          int nx = j + dx[d];
          int ny = i + dy[d];
          if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
          if (field[i][j] == field[ny][nx]){
            uf.merge(i * w + j, ny * w + nx);
          }
        }
      }
    }
    printf("%d\n", uf.count());
  }

  return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    cin >> Q;
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];
}

void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;
const int maxN = 200 + 5;

int n;
int a[maxN];
int memo[maxN][maxN];
bool calc[maxN][maxN];

int dp(int i, int curH){
    if(i == n){
        return (curH != a[i]);
    }

    if(calc[i][curH]){
        return memo[i][curH];
    }

    int ans = n;
    for(int nxtH = 1; nxtH < maxN; nxtH++){
        if(curH != nxtH){
            ans = min(ans, dp(i + 1, nxtH) + (curH != a[i]));
        }
    }

    calc[i][curH] = true;
    return (memo[i][curH] = ans);
}

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

    cin >> n;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }

    int mn = n;

    for(int curH = 1; curH < maxN; curH++){
        mn = min(mn, dp(1, curH));
    }

    cout << mn << '\n';

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	
	int n;
	
	while(cin >> n && n!=0) {
		
		int *A;
		int sum = 0;
		
		A = new int[n];
		
		for(int i=0;i<n;i++)
			cin >> A[i];
		
		sort(A, A+n);
		
		for(int i=1;i<n-1;i++)
			sum += A[i];
		
		cout << sum / (n - 2) << "\n";
		delete [] A;
		A = NULL;
	}

	return 0;
}



Measured memory_bytes: 3136
#include<stdio.h>

typedef struct card
{
	char a;
	int b;
}card_in;

void BubbleSort(card_in C[],int N)
{
	int i,j;
	card_in temp[N];
	
	for(i=0;i<N;i++)
	{
		for(j=N-1;j>=i+1;j--)
		{
			if(C[j].b<C[j-1].b)
			{
				temp[j]=C[j];
				C[j]=C[j-1];
				C[j-1]=temp[j];
			}
		}
	}
}

void SelectionSort(card_in C[],int N)
{
	int i,minj,j;
	card_in temp[N];
	
	for(i=0;i<N;i++)
	{
		minj=i;
		for(j=i;j<N;j++)
		{
			if(C[j].b<C[minj].b)
			{
				minj=j;
			}
		}
		temp[i]=C[i];
		C[i]=C[minj];
		C[minj]=temp[i];
	}
}

void isStable(card_in in[],card_in out[],int N)
{
	int i,j,a,b;
	int c=0;
	
	for(i=0;i<N;i++)
	{
		for(j=i+1;j<N;j++)
		{
			for(a=0;a<N;a++)
			{
				for(b=a+1;b<N;b++)
				{
					if((in[i].b==in[j].b)&&(in[i].a==out[b].a)&&(in[i].b==out[b].b)&&(in[j].a==out[a].a)&&(in[j].b==out[a].b))
					{
					    if(c>=1)
						{
							break;
						}
						 printf("Not stable\n");
						c++;
						break;
					}
				}
			}
		}
	}
	if(c==0) printf("Stable\n");
}

int main(void)
{
	int n;
	int i;
	
	scanf("%d",&n);
	
	card_in C1[n];
	card_in C2[n];
	card_in C3[n];
	
	for(i=0;i<n;i++)
	{
		scanf(" %c%d",&C1[i].a,&C1[i].b);
	}
	for(i=0;i<n;i++)
	{
		C2[i]=C1[i];
		C3[i]=C1[i];
	}
	
	BubbleSort(C1,n);
	for(i=0;i<n;i++)
	{
		if(i!=0)
		{
			printf(" ");
		}
		printf("%c%d",C1[i].a,C1[i].b);
	}printf("\n");
	
	isStable(C1,C3,n);
	
	SelectionSort(C2,n);
	for(i=0;i<n;i++)
	{
		if(i!=0)
		{
			printf(" ");
		}
		printf("%c%d",C2[i].a,C2[i].b);
	}printf("\n");
		
	isStable(C2,C3,n);
	
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  rep(i,n) {
    if(a[i]%2==0) {
      if(a[i]%3&&a[i]%5) {
        pr("DENIED");
        return;
      }
    }
  }
  pr("APPROVED");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
using namespace std;
 
signed main(){
    int N;cin>>N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long ans=LLONG_MAX;
    int sig[2]={1,-1};
    REP(j,2){ 
        long long sum=0;
        long long count=0;
        REP(i,N){
            sum+=A[i];
            if(sig[(i^j)&1]*sum>=0){
                count+=llabs(sum)+1;
                sum=-sig[(i^j)&1];
            }
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc160/tasks/abc160_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> va(A), vb(B), vc(C);
    for (auto &x : va)
        cin >> x;
    for (auto &x : vb)
        cin >> x;
    for (auto &x : vc)
        cin >> x;

    // 降順ソート
    sort(ALLR(va));
    sort(ALLR(vb));
    sort(ALLR(vc));

    priority_queue<int, vector<int>, greater<int>> qa, qb;
    REP(i, X) { qa.push(va[i]); }
    REP(i, Y) { qb.push(vb[i]); }

    for (auto &x : vc) {
        int t1 = qa.top();
        int t2 = qb.top();
        if (t1 < t2) {
            if (t1 < x) {
                qa.pop();
                qa.push(x);
            } else {
                break;
            }
        } else {
            if (t2 < x) {
                qb.pop();
                qb.push(x);
            } else {
                break;
            }
        }
    }
    int sum = 0;
    while (!qa.empty()) {
        sum += qa.top();
        qa.pop();
    }
    while (!qb.empty()) {
        sum += qb.top();
        qb.pop();
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vll = vector<ll>;
using vvll = vector<vll>;

int main()
{
  vvi c(3, vi(3));
  rep(i,3)
  {
    rep(j,3)
    {
      cin >> c[i][j];
    }
  }

  int d1 = c[0][1] - c[0][0], d2 = c[0][1] - c[0][2];

  bool check = true;
  for (int i = 1; i < 3; i++)
  {
    if(c[i][1]-c[i][0]!=d1||c[i][1]-c[i][2]!=d2)
      check = false;
  }

  if(check)
    cout << "Yes" << endl;
    else
      cout << "No" << endl;

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int 
    int main()
    {
        int n;
        string s;
        cin>>n>>s;
        if(n<3200)
        cout<<"red"<<endl;
        else
        {
            cout<<s<<endl;
        }
        
    } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int ans=1e9;
signed main(){
	ios_base::sync_with_stdio(0);
	string s,t;
	cin>>s>>t;
	for(int i=0;i+sz(t)<=sz(s);i++){
		string u=s.substr(i,sz(t));
		int cur=0;
		for(int i=0;i<sz(t);i++) if(u[i]!=t[i]) cur++;
		ans=min(ans,cur);
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    
    int n = input.nextInt();
    Map<Integer, Integer> map = new HashMap<>();
    int[] a = new int[n];
    
    for (int i = 0; i < n; i++) {
      a[i] = input.nextInt();
      map.merge(a[i], 1, Integer::sum);
    }
    
    long total = 0;
    
    for (int val : map.values()) {
      total += (long)(val) * (val - 1) / 2;
    }
    
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < n; i++) {
      int size = map.get(a[i]);
      long tmp = total - (long)(size) * (size - 1) / 2;
      tmp += (long)(size - 1) * (size - 2) / 2;
      ans.append(tmp).append("\n");
    }
    
    System.out.print(ans);
  }
}

Measured memory_bytes: 102068
a=int(input())+1
b=int(input())+1
c=int(input())+1
x=int(input())/10
s=0
for i in range(a):
    for j in range(b):
        for k in range(c):
            if 50*i+10*j+5*k==x:
                s+=1
print(s)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n,x,t; cin >> n >> x >> t;
    
    if((n%x)==0){
        cout << n/x*t << ln;
    }else{
        cout << (n/x+1)*t << ln;
    }
    
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, l; cin >> n >> l;
    int sum = 0;
    rep(i,n){
        sum += l + i;
    } 
    if(l+n-1<0) cout << sum - (l+n-1) << endl;
    else if(l > 0) cout << sum - l << endl;
    else cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n, m, A[100][100], b[100], c[100]={};
 
  cin >> n >> m;
 
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>A[i][j];
    }
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      c[i] += A[i][j]*b[j];
    }
  }
  for(int i=0;i<n;i++){
    cout<<c[i]<<endl;
  }
}

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

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	ll n,k,q;cin>>n>>k>>q;
	vi v(n+1,k);
	map<int,int> mapp;
	rep(i,0,q){
		int a;cin>>a;mapp[a]++;
	}
	rep(i,1,n+1){
		if(v[i]+mapp[i]-q<=0)cout<<"No\n";
		else cout<<"Yes\n";
	}
	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N;
    cin >> N;
    vec A(N);
    map<ll, ll> cnt;
    Rep (i, N) {
        cin >> A[i];
        A[i] -= i;
        cnt[A[i]]++;
    }

    ll ans = 0;
    Rep (i, N) {
        ans += cnt[-A[i]-i-i];
        cnt[A[i]]--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 27488
from collections import Counter
N = int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


T = []
for n in range(1, N + 1):
    T.extend(prime_factorization(n))

C = Counter(T)


def num(x):
    ret = sum([cnt >= x - 1 for cnt in C.values()])
    return ret


ans = num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) // 2 * (num(3) - 2) + num(75)
print(ans)


Measured memory_bytes: 3444
s=input()

t=s.replace("x","")

v=len(t)
if len(t)%2==1:
    if t[v//2+1:]!=t[:v//2][::-1]:
        print(-1)
        exit()
else:
    if t[v//2:]!=t[:v//2][::-1]:
        print(-1)
        exit()
v=len(s)-1
w=0
news=0
while v-w>0:
    #print(news)
    #print(s[w],s[v])
    if s[w]!=s[v]:
        if s[w]=="x":
            news+=1
            w+=1
        else:
            news+=1
            v-=1
    else:
        w+=1
        v-=1
print(news)
    

Measured memory_bytes: 3316
n=int(input())
a=list(map(int,input().split()))
s=1
a.sort()
for i in range(n):
  s=s*a[i]
  if s==0:
    break
  if s>10**18:
    break
if s>10**18:
  print(-1)
else:
  print(s)

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

int main()
{	
	int n,k;
	cin>>n>>k;
	
	vector<int>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		}
	
	vector<bool>dp(k+1);
	
	for(int s=0;s<=k;s++){
		for(int j=0;j<n;j++){
			if(s>=v[j] && (!dp[s-v[j]])){
				dp[s]=true;
				
				}	
			}
		}
		if(dp[k]){cout<<"First"<<endl;}
		else{cout<<"Second";}
	
	return 0;
	}


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

int main() {
   int age,a,b;
   cin >> age;
   if(age == 1){
      cout << "Hello World";
      return 0;
   }
   cin >> a >> b;
   cout << a+b << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  ll a,sum=0;
  cin >> a ;
  sum+=1000*(a/500);
  //cout << sum <<endl;
  a-=500*(a/500);
  //cout << a <<endl; 
  sum+=5*(a/5);
  //cout << 5*(a/5) <<endl;
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n)cin >> A[i];
  set<int> s;
  rep(i,n) s.insert(A[i]);
  
  if(s.size() ==n) cout << "YES" <<  endl;
  else cout << "NO" << endl;
}


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

int main() {
  int N;
  vector<float> x(N);
  vector<string> u(N);
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> x.at(i) >> u.at(i);
  }
  float tot=0;
  for (int i=0; i<N; i++) {
    if (u.at(i)=="JPY") {
      tot+=x.at(i);
    }
    else {
      tot+=x.at(i)*380000;
    }
  }
  cout << tot << endl;
  }


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    ll prev=-1;
    vector<ll> v2;
    for(ll i=0;i<n;i++)
    {
        if(v[i]!=prev)
        {
            v2.push_back(v[i]);
            prev=v[i];
        }
    }
    n = v2.size();
    for(ll i=1;i<n;i++)
    {
        if(v2[i]<v2[i-1])
        {
            v2[i-1]--;
        }
    }
    for(ll i=1;i<n;i++)
    {
        if(v2[i]<v2[i-1])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<vector>
using namespace std;
int main(){
 int n;
 cin>>n;
 vector<int> a(n);
 for(int i=0;i<n;i++){
  cin>>a[i];
 }

 int ans=0;
 int p=1;
 while(p!=2){
  p=a[p-1];
  ans++;
  if(ans==n+1){
   ans=-1;
   break;
  }
 }
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int p = scan.nextInt();
        int q = scan.nextInt();
        int r = scan.nextInt();
        System.out.println(p + q + r - Math.max(p, Math.max(q, r)));
    }
}

Measured memory_bytes: 23124
n, m = gets.chomp.split.map(&:to_i)
graph = Hash.new{ |h,k| h[k] = {} }

m.times do |i|
  x, y, z = gets.chomp.split.map(&:to_i)
  graph[x][y] = z & 1
  graph[y][x] = z & 1
end

count = 0
check = []
(1..n).each do |i|
  next if check[i] != nil
  count += 1
  check[i] = 0
  queue = graph[i].to_a
  while q = queue.shift
    y, z = q
    next if check[y] != nil
    check[y] = z
    graph[y].each do |ny, nz|
      queue << [ny, z ^ nz]
    end
  end
end

puts(count)

Measured memory_bytes: 51068
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

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

	int x, y, z, K;
	long long int t;
	vector <long long int> a, b, c;
	priority_queue <long long int, vector <long long int>, greater<long long int>> pque;

	cin >> x >> y >> z >> K;

	for (int i = 0; i < x; i++)
	{
		cin >> t;
		a.push_back(t);
	}

	for (int i = 0; i < y; i++)
	{
		cin >> t;
		b.push_back(t);
	}

	for (int i = 0; i < z; i++)
	{
		cin >> t;
		c.push_back(t);
	}

	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());

	vector <long long int> res;

	for (int i = 0; i < x; i++)
	{
		for (int j = 0; j < y; j++)
		{
			for (int k = 0; k < z; k++)
			{
				if ((i + 1)*(j + 1)*(k + 1) <= K)
				{
					res.push_back(a[i] + b[j] + c[k]);
				}
			}
		}
	}

	sort(res.rbegin(), res.rend());

	for (int i = 0; i < K; i++)
	{
		cout << res[i] << '\n';
	}

	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  ll sum = 0;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
    sum = sum ^ a[i];
  }

  rep(i, n){
    cout << (sum ^ a[i]) << " ";
  }
  cout << endl;

  return 0;
}


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

const ll mod = 1e9 + 7;

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

ll comb(ll a, ll b) {
  ll ans = 1;
  for (ll i = 0; i < b; i++) {
    ans *= ((a - i) * powmod(i + 1, mod - 2)) % mod;
    ans %= mod;
  }
  return ans;
}

int main() {  
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = powmod(2, n);

  ans -= comb(n, a);
  ans %= mod;
  if (ans < 0) ans += mod;

  ans -= comb(n, b);
  ans %= mod;
  if (ans < 0) ans += mod;

  ans -= 1;
  ans %= mod;
  if (ans < 0) ans += mod;

  cout << ans << endl;
}


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


bool solve(long long A, long long B){
    if (A <= 8 && B <= 8) return true;
    return false;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    cout << (solve(A, B) ? "Yay!" : ":(") << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int a[105],n,i,ma,mi;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
        mi=ma=a[0];
    for(i=0;i<n;i++)
    {
        if(a[i]>ma) ma=a[i];
        if(a[i]<mi) mi=a[i];
    }
    printf("%d\n",ma-mi);
    return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int a, b;

int mx(int n) {
    if(n == 2) {
        return 29;
    }
    if(n == 4 || n == 6 || n == 9 || n == 11) {
        return 30;
    }
    return 31;
}

int main() {
    std::cin >> a >> b;
    int cnt = 0;
    int r = (a <= b ? a : a-1);
    for(int i=1; i<=r; ++i) {
        if(i == std::min(mx(i), i)) {
            ++cnt;
        }
    }
    std::cout << cnt << std::endl;
}

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
long long h,n,m=0;
cin >> h>> n;
long long a[n],b[n];
rep(i,n){cin >> a[i]>>b[i];
    m = max(m,a[i]);
    }

const long long INF = 1LL << 60;

long long dp[44000];

rep(i,44000)dp[i] = INF;

dp[20000] = 0;

rep(i,h+m){
    rep(j,n){
        chmin(dp[20000+i],dp[20000+i-a[j]]+b[j]);
    }
}
m = 100000000;
for(int i = 20000+h;i<44000;++i){
if(dp[i]<m)m=dp[i];
}


cout << m << endl;



return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        string s; cin >> s;
        int i,j, ans; i = j = ans = 0;
        for (; j < n; j++) {
            if (s[j] == '0') {
                while (j+1 < n && s[j+1] == '0')
                    j++;
                k--;            /* use 1 of k */
            }
            while (j+1 < n && s[j+1] == '1')
                j++;
            if (k < 0) {        /* bring i up */
                while (i < j && s[i] == '1')
                    i++;
                while (i < j && s[i] == '0')
                    i++;
            }
            ans = max(ans, j-i+1);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 512
from fractions import gcd

a, b, c, d = map(int, input().split())

lcm = (c*d) // gcd(c, d)

all_count = b - a + 1
c_count = b // c - (a-1) // c
d_count = b // d - (a-1) // d
cd_count = b // lcm - (a-1) // lcm

print(all_count - c_count - d_count + cd_count)

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

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll one = 0;
  for (ll i = 0; i < k; i++) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  int dp[100005];
  int h[100005];
  int small;
  cin >> n >> k;
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for(int i=2; i<n; i++){
    small = 1;
    dp[i] = abs(h[i] - h[i-small]) + dp[i-small];
    for(int j=2; j<=k; j++){
      if(i - j < 0) break;
      if(abs(h[i] - h[i-j]) + dp[i-j] < abs(h[i] - h[i-small]) + dp[i-small]){
	dp[i] = abs(h[i] - h[i-j]) + dp[i-j];
	small = j;
      }
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024