akhauriyash/Code-Regression huggingface dataset:
let f()=List.map int_of_string(Str.split(Str.regexp_string" ")(read_line()))open Array;;match f()with|n::m::_->let a,b=make(n*m)0,make m 0in for i=0to n-1do List.iteri(fun j e->a.(m*i+j)<-e)(f())done;for i=0to m-1do b.(i)<-read_int()done;for i=0to n-1do let c=ref 0in for j=0to m-1do c:=!c+a.(m*i+j)*b.(j)done;Printf.printf"%d
"!c done|_->()

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e9

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    string alp = "abcdefghijklmnopqrstuvwxyz";
    int n;
    map<char, int> mp;

    REP(i, 26)
    mp[alp[i]] = INF;

    cin >> n;
    REP(i, n)
    {
        string s;
        cin >> s;

        map<char, int> mp_;
        REP(j, s.size())
        mp_[s[j]]++;

        REP(j, 26)
        mp[alp[j]] = min(mp[alp[j]], mp_[alp[j]]);
    }

    REP(i, 26)
    if (mp[alp[i]] != INF)
    {
        REP(j, mp[alp[i]])
        cout << alp[i];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<62)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define T ((ll)(2e12))

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int h,w,d,i,j,a,n,q,l,r;
	P pos[99999];
	ll dist[99999];
	fill(dist,dist+99999,0ll);
	cin >> h >> w >> d;
	for(i=1; i<=h; ++i){
		for(j=1; j<=w; ++j){
			cin >> a;
			pos[a] = P(i,j);
		}
	}
	n = h*w;
	for(i=(d+1); i<=n; ++i){
		dist[i] = dist[i-d];
		dist[i] += abs(pos[i].first - pos[i-d].first);
		dist[i] += abs(pos[i].second - pos[i-d].second);

	}
	cin >> q;
	for(i=0; i<q; ++i){
		cin >> l >> r;
		cout << (dist[r] - dist[l]) << endl;
	}
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    map<string, int> M;
    int N;
    cin >> N;
    
    rep(i,N) {
        string s;
        cin >> s;
        if(M[s] >0)M[s]++;
        else M[s] = 1;
    }
    cout << "AC" << " x " << M["AC"] << endl;
    cout << "WA" << " x " << M["WA"] << endl;
    cout << "TLE" << " x " << M["TLE"] << endl;
    cout << "RE" << " x " << M["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    var K = nl()
    val A = na(N, -1)
    var cur = 0
    val path = mutableListOf<Int>()
    path += cur
    val visited = BooleanArray(N)
    visited[cur] = true
    cur = A[cur]
    while(!visited[cur]) {
      path += cur
      visited[cur] = true
      cur = A[cur]
    }
    debug{visited.joinToString(" ")}
    debug{path.joinToString(" ")}
    debug{"cur:$cur"}

    val beforeLen = path.indexOf(cur)
    val cycleLen = path.size - beforeLen
    debug{"before:$beforeLen cycle:$cycleLen"}

    val x = min(K, beforeLen.toLong()).toInt()
    K -= x
    if (K == 0L) {
      out.println(path[x] + 1)
    } else {
      val j = K % cycleLen
      out.println(path[beforeLen + j.toInt()] + 1)
    }
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


Measured memory_bytes: 57484
red = []
blue = []
ans = 0
n = int(input())
for _ in range(n):
    red.append(input())
m = int(input())
for _ in range(m):
    blue.append(input())
for word in set(red):
    if word in blue:
        tmp = red.count(word) - blue.count(word)
    else:
        tmp = red.count(word)
    if tmp > ans:
        ans = tmp
print(ans)

Measured memory_bytes: 3064
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
    int a,n,m;cin >> a >> n >> m;
    int ans = 0;
    int i = 1;
    while(1){
        int u = a + i;
        ll w = pow(u, n);
        if(w > m){
            break;
        }
        string p = to_string(w);
        int s = 0;
        for(auto b : p)s += b - '0';
        if(s == i)ans++;
        i++;
    }
    cout<<ans<<endl;
}



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

int h,w;

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

void solve()
{
	vector<string> V;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		V.push_back(s);
	}

	vector<vector<int> > Dp(h,vector<int>(w,10000000));

	Dp[0][0]=0;

	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			for(int r=0;r<2;r++){
				int nx=x+dx[r],ny=y+dy[r];
				if(nx<0 || ny<0 ||nx>=w || ny>=h) continue;
				Dp[y][x]=min(Dp[ny][nx]+V[y][x]-'0',Dp[y][x]);
			}
		}
	}
	cout<<Dp[h-1][w-1]<<endl;
}

int main()
{
	while(cin>>h>>w){
		if(h==0) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <cctype>

using namespace std;

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

	if (isupper(c)) {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}

	return 0;
}


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int n,flag=0,t;
	scanf("%d",&n);
	while(n){
		t=n%10;
		if(t==7)flag=1;
		n/=10;
	}
	if(flag)printf("Yes");
	else printf("No");
	return 0;
} 

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n) {
        if(s[i] == 'o') {
            ans++;
        }
    }
    ans = ans+15-n;
    if(ans>=8){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define p pair<int,int>
int N, K;
vector<p> n;

int main(){
    cin >> N >> K;
    for(int i = 2; i <= N; i++){
        for(int j = i + 1; j <= N; j++){
            n.push_back({i, j});
        }
    }
    int mx = (N - 1) * (N - 2) / 2;
    if(K > mx){
        cout << -1 << endl;
        return 0;
    }
    cout << N - 1 + mx - K << endl;
    for(int i = 2; i <= N; i++){
        cout << 1 << " " << i << endl;
    }
    for(int i = 0; i < mx - K; i++){
        cout << n[i].first << " " << n[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

	int max_dist=0;
	for (int i=0; i<n; i++) 
		max_dist = max(abs(a[i+1]-a[i]), max_dist);
	int ans = k - max_dist;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  k <- (read::String -> Int) <$> getLine
  arr <- map (read::String -> Int) . words <$> getLine
  print $ foldl (\acc x -> acc + min (2 * x) (2 * (k - x))) 0 arr


Measured memory_bytes: 892
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll a, b, k;
	re(a,b,k);
	if(k<=a)
	{
		cout<<a-k <<" "<< b << "\n";
	}
	else
	{
		cout<<0 <<" "<<max(0ll,(b-(k-a)));
	}
	 
}


Measured memory_bytes: 256
H, W = map(int, input().split())

result = []
result.append(['0'] * (W))

for h in range(H):
    result.append(['0'] * W)
    s = input()

    for w in range(W):
        if s[w] == '#':

            result[h][w] = '#'

            if 0 < h and 0 < w:
                if result[h-1][w-1] != '#':
                    result[h-1][w-1] = str(int(result[h-1][w-1]) + 1)
            
            if 0 < h and w < W-1:
                if result[h-1][w+1] != '#':
                    result[h-1][w+1] = str(int(result[h-1][w+1]) + 1)

            if h < H-1 and w < W-1:
                if result[h+1][w+1] != '#':
                    result[h+1][w+1] = str(int(result[h+1][w+1]) + 1)
            
            if h < H-1 and 0 < w:
                if result[h+1][w-1] != '#':
                    result[h+1][w-1] = str(int(result[h+1][w-1]) + 1)

            if 0 < h:
                if result[h-1][w] != '#':
                    result[h-1][w] = str(int(result[h-1][w]) + 1)
            
            if h < H-1:
                if result[h+1][w] != '#':
                    result[h+1][w] = str(int(result[h+1][w]) + 1)
            
            if 0 < w:
                if result[h][w-1] != '#':
                    result[h][w-1] = str(int(result[h][w-1]) + 1)

            if w < W-1:
                if result[h][w+1] != '#':
                    result[h][w+1] = str(int(result[h][w+1]) + 1)

    if h > 0:
        print(''.join(result[h-1]))

print(''.join(result[-2]))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, k;
    cin >> n >> k;
    int ans = k;    
    rep(i, 0, n - 1){
        ans *= k - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
using System;

class Program {
    static void Main(string[] args) {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int p = int.Parse(input[1]);
        p += a * 3;
        int num = (p / 2); 
        Console.WriteLine(num);
    }
}


Measured memory_bytes: 13140
//Created by Young Charlie
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int(a.size())

int main(){
	int ans = 1003, T, n; cin>>n>>T;
	while(n--){
		int c, t; cin>>c>>t;
		if(t <= T){
			ans = min(ans, c);
		}
	}		
	cout<<(ans == 1003 ? "TLE\n": to_string(ans));
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};


int main() {
	int A, B;
	cin >> A >> B;
	if (A < B * 2) {

		cout << 0;
	}
	else {
		cout << A - B * 2;

	}
}

//int m[500][26] = {};
//void func(string& s, int N, int i, vector<string>a, int J) {
//	int j;
//		for (j = 0; j < J; j++) {
//			if (m[J - 1 - i][(int)a[i][j] - 97] == 1) {
//		s += a[i][j];
//				break;
//			}
//			if (j == J - 1) {
//				s = "-1";
//				i = N - 1;
//				break;
//			}
//		}
//		i++;
//	if (i == N) {
//		
//	}
//	else {
//		func(s, N, i, a, J);
//	}
//}
//
//int main() {
//	ll N;
//	cin >> N;
//	vector<string>a(N);
//	
//	rep(i, N) {
//		cin >> a[i];
//	}
//	if (N == 1) {
//		cout << a[0];
//		return 0;
//	}
//	rep(i, N) {
//		rep(j, N) {
//			m[i][(int)a[i][j] - 97]=1;
//		}
//	}
//	string ans;
//
//	func(ans, N/2,0,a,N);
//
//	if (ans == "-1") {
//		cout <<ans;
//		return 0;
//	}
//		cout << ans;
//		
//		if (N % 2 == 1) {
//			cout << a[N / 2 + 1][0];
//		}
//	rep(i, N / 2) {
//
//	cout << ans[N/2-i-1];
//	
//	}
//}
//
//
//


Measured memory_bytes: 3208
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;
typedef long long ll ;
# define rep (i , n ) for ( int i =0; i < n ; i++)
# define _sort(arg) sort(begin(arg), end(arg))

int compare(string &s1, string &s2)
{
	if (s1.size() != s2.size()) return s1.size() < s2.size();

	int i = 0;
	while(s1[i] == s2[i])
	{
		i++;
		if (i >= s1.size())
		{
			break;
		}
	}
	if (i == s1.size())
	{
		return 0;
	}
	else
	{
		return s1[i] < s2[i];
	}
}

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

	int N, L;
	cin >> N >> L;

	string s[N];

	//rep(i,N)
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
	}

	sort(s, s+N, compare);
		
	//cout << "S;" << endl;
	for (int i = 0; i < N; i++)
	{
		cout << s[i];
	}

	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,c,d,e,x;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  x=(c*60+d)-(a*60+b)-e;
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

void solve() {
    int n; cin >> n;
    ll p = 1;
    
    ll a[n];
    bool mark = false;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (!a[i]) {
            mark = true;
        }
    }

    if (mark) {
        cout << 0 << endl;
    } else {
        for (int i = 0; i < n; ++i) {
            if (a[i] <= 1000000000000000000 / p) {
                p *= a[i];
            } else {
                cout << -1 << endl;
                return;
            }
        }
        cout << p << endl;
    }

}

int main(void) {
    int t; t = 1;
    while (t--) solve();
    return 0;
}

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

using namespace std;

const int N = 100005;

char s[N];

int main() {
    scanf("%s", s);
    int i;
    for (i = 0; s[i]; i++)
    if (s[i] == 'C') break;
    if (s[i] == 'C') {
        for (; s[i]; i++)
            if (s[i] == 'F') break;
        if (s[i] == 'F') {
            printf("Yes"); return 0;
        }
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n;
int A[21];

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  
  res = solve(i+1,m)||solve(i+1,m-A[i]);
  
  return res;
}


int main(){
  int q;
  int m[201];
  int i;
  //bool existM[201];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    if(solve(0,m[i]))
      printf("yes\n");
    else
      printf("no\n");
  }
  
  
  return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main() {
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] is total cost that we did activity i on last considered day
    int i, j, k;
    while (scanf("%d %d %d", &i, &j, &k) == 3) {
        int a = i + max(dp[1], dp[2]);
        int b = j + max(dp[0], dp[2]);
        int c = k + max(dp[0], dp[1]);
        dp[0] = a; dp[1] = b; dp[2] = c;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));

    return 0;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginner contest 055 B - Training Camp
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/03/11
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdint>
#include <iostream>
#include <algorithm>
using namespace std;

uint32_t n;

void solve() {
    uint64_t product = 1;
    for (uint32_t i=1;i<=n;i++) {
        product = product * i;
        product = product % 1000000007;
    }
    cout << product << endl;
}

int main() {

    cin >> n;
    solve();

}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        string s; cin>>s;
        bool f=false;
        if(s=="hi")f=true;
        if(s=="hihi")f=true;
        if(s=="hihihi")f=true;
        if(s=="hihihihi")f=true;
        if(s=="hihihihihi")f=true;

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

}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if ((A <= C and C <= B) or (B <= C and C <= A)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define loop(i,b,a) for(int i = b ; i < a; i ++)
#define rep(i,a) for(int i = 0 ; i < a; i ++)
int main(void){
  string str;
  getline(cin,str);
  string word[] = {"apple","peach"};
  rep(i,str.size()){
    rep(k,2)
    if(str[i  ] == word[k][0] &&
       str[i+1] == word[k][1] &&
       str[i+2] == word[k][2] &&
       str[i+3] == word[k][3] &&
       str[i+4] == word[k][4] ){
	rep(j,word[0].size())str[i+j] = word[(k?0:1)][j];
	break;
    }    
    cout<<str[i];
  }
  cout<<endl;
}

Measured memory_bytes: 1180
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_TakahashikunTheStrider solver = new A_TakahashikunTheStrider();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_TakahashikunTheStrider {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            double alpha = in.nextInt() * Math.PI / 180.0;
            double c = Math.cos(alpha);
            double s = Math.sin(alpha);
            double x = 0;
            double y = 0;
            double vx = 0;
            double vy = 1;
            int ans = 0;
            final double eps = 1e-10;
            do {
                x += vx;
                y += vy;
                double nvx = vx * c - vy * s;
                double nvy = vx * s + vy * c;
                vx = nvx;
                vy = nvy;
                ++ans;
            } while (Math.abs(x) > eps || Math.abs(y) > eps);
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

#define loop(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> P;
vector<P> p;

bool ex(int x,int y){
  return binary_search(p.begin(),p.end(),P(x,y));
}

int main(){
  int n,x,y;
  while(cin>>n,n){
    p.clear();
    loop(_,n){
      cin>>x>>y;
      p.push_back(P(x,y));
    }
    sort(p.begin(),p.end());
    int m=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        int px=p[i].first;
        int py=p[i].second;
        int qx=p[j].first;
        int qy=p[j].second;
        int dx=qx-px;
        int dy=qy-py;
        if((ex(px-dy,py+dx)&&ex(qx-dy,qy+dx))||(ex(px+dy,py-dx)&&ex(qx+dy,qy-dx))){
          m=max(m,dx*dx+dy*dy);
        }
      }
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll n,ww; cin>>n>>ww;
  
  vector<ll> v(n+1),w(n+1);
  rep(i,n) cin>>w[i+1]>>v[i+1];
  ll vsum=accumulate(v.begin(),v.end(),(ll)0);
  vector<vector<ll>> dp(n+1,vector<ll>(vsum+1));
  
  REP(i,1,n+1){
    REP(j,0,vsum+1-v[i]){
      if(j==0 || dp[i-1][j]>0){
        if(dp[i][j] == 0){
          dp[i][j] = dp[i-1][j];
        }
        if(dp[i-1][j+v[i]] > 0){
          dp[i][j+v[i]] = min(dp[i-1][j+v[i]], dp[i-1][j] + w[i]);
        }else{
          dp[i][j+v[i]] = dp[i-1][j] + w[i];
        }
      }
    }
  }
  ll idx=0;
  REP(i,1,vsum+1){
    if(dp[n][i] == 0) continue;
    if(dp[n][i] > ww) continue;
    idx = i;
  }
  cout<<idx<<endl;
}

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

int main() {
  int N,Y;
  cin >> N >> Y;
  int x=-1,y=-1,z=-1;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(Y==10000*i+5000*j+1000*(N-i-j)){
        x=i,y=j,z=N-i-j;
      }
    }
  }
  
  cout << x <<" " << y << " " <<z;
  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(read())

def test(x):
    return x * (x + 1) // 2 >= X

left = 0 # 足りない
right = X + 10
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = right
print(answer)

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;

void solve() {
	int n, m;
	cin >> n >> m;
	if (m >= n) cout << "unsafe\n";
	else cout << "safe\n";
}

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

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main() 
{
	int x,y;
	cin>>x;
	if(360%x==0)
	{
		cout<<360/x;
	}
	else
	{
		int i;
		for(i=1;(i*x)%360!=0;i++);
		cout<<i;
	}
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

ll gcd(ll x, ll y) {
	if (x > y) swap(x, y);
	if (y % x == 0) return x;
	else return gcd(y % x, x);
}

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 1;
	rep(i, n) {
		ans = (ans / gcd(ans, a[i])) * a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,h,m;
    cin>>n;
    h=n/3600;
    n=n%3600;
    m=n/60;
    n=n%60;
    printf("%d:%d:%d\n",h,m,n);
    return 0;
}



Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt(), b = sc.nextInt();
		
		System.out.println((a * b % 2 == 0) ? "Even" : "Odd");
		
	}

}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
const int ms = 1e6+9, inf = 0x3f3f3f3f;
int d,g,a,b;
typedef pair<int,int> ii;
vector<ii> vet;
int dp[101][ms];

int solve(int id, int atual){
	if(atual <=0)
		return 0;
	if(id == d)
		return inf;
	int &ans = dp[id][atual];
	if(~ans)
		return ans;
	ans = inf;
	
	for(int i = 0;i<=vet[id].first;i++){
		ans = min(ans, i+ solve(id+1, atual - (id+1)*i - (i == vet[id].first)*vet[id].second));
	
	}
	return ans;
}


int main(){
	cin >> d >> g;
	g/=100;
	for(int i= 0 ;i<d;i++){
		cin >> a >> b;
		b/=100;
		vet.push_back({a,b});
	}
	
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,g);


}

Measured memory_bytes: 394752
#include "iostream"
#include "string"
#include "stdio.h"
#include "ctype.h"
#include "algorithm"
#include "stack"
#include "cmath"
#include "cstring"
#include "iomanip"
using namespace std;
int main()
{
    int N,M,A[10010],sum=0;
    scanf("%d%d",&N,&M);
    for(int i=0;i<M;i++)
    {
        scanf("%d",&A[i]);
        sum+=A[i];
    }
    if(sum>N)
        printf("-1\n");
    else
        printf("%d\n",N-sum);
    return 0;
}


Measured memory_bytes: 3856
n=int(input())
a=[]
for i in range(2):
    a.append(list(map(int,input().split())))
ans=0
for i in range(n):
    b=0
    for j in range(n):
        if i>j:
            b+=a[0][j]
        elif i==j:
            b+=a[0][j]+a[1][j]
        else:
            b+=a[1][j]
    ans=max(ans,b)
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;

int main(){
	int n;
	int a[100];
	int count=0;
	
	scanf(" %d", &n);
	for(int i=0; i<n; ++i) scanf(" %d", &a[i]);
	
	//selection sort	
	for(int i=0; i<n; ++i){
		int minj=i;
		for(int j=i; j<n; ++j){
			if(a[j]<a[minj]) minj=j;		
		}	
		
		if(i!=minj){
			swap(a[i], a[minj]);
			count++;
		}
	}
	
	for(int i=0; i<n; ++i){
		if(i>0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n%d\n", count);
	
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int maxn=1e5+5;
const ll inf=1e18;
int N,M;
int fa[maxn];
int find(int x){
    if(fa[x]!=x)fa[x]=find(fa[x]);
    return fa[x];
}
int main(){
    cin>>N>>M;
    for(int i=1;i<=N;i++)fa[i]=i;

    for(int i=1;i<=M;i++){
        int a,b;
        cin>>a>>b;
        int faa=find(a);
        int fab=find(b);
        if(faa!=fab)
        fa[faa]=fab;
    }
    int cnt=-1;

    for(int i=1;i<=N;i++){
        find(i);
        if(fa[i]==i)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

class UnionFind{
  public:
    //親の番号を格納．親の場合は-(その集合のサイズ)
    vector<int> Parent;
    //作るときはParentの値をすべて-1にする
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //親を求める
    int find(int x){
      if(Parent[x] < 0) return x;
      //親の紐づけを変更
      return Parent[x] = find(Parent[x]);
    }

    //xの属する集合のサイズを取ってくる
    int size(int x){
      return -Parent[find(x)];
    }

    //xとyの属する集合を併合
    //併合できたらtrue，すでに併合していたらfalse 
    bool unite(int x, int y){
      //xとyを直接つけない，親同士をつける
      x = find(x);
      y = find(y);
      if(x==y) return false;

      //大きいほうに小さいほうをくっつける
      if(size(x) < size(y)) swap(x,y);

      //xのサイズを更新
      Parent[x] += Parent[y];
      Parent[y] = x;
      return true;
    }

    //xとyが同じ集合に属するか
    bool same(int x, int y){
      return find(x) == find(y);
    }
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<PII> v(M);
  rep(i,M){
    cin >> v[i].first >> v[i].second;
    --v[i].first;
    --v[i].second;
  }
  int count = 0;
  rep(i,M){
    UnionFind uni =  UnionFind(N);
    rep(j,M){
      if(i==j)continue;
      uni.unite(v[j].first, v[j].second);
    }
    if(uni.size(0) != N) ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    times = [int(x) for x in sys.stdin.readline().split()]
    times.sort()
    ans = sum(times[:2])
    print(ans)




if __name__ == "__main__":
    main()


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

namespace Computation
{
    class Min__Max_and_Sum
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split(' ').Take(n).Select(s =>long.Parse(s)).ToArray();

            Console.WriteLine(array.Min() + " " + array.Max() + " " + array.Sum());
        }
    }
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int a, b;
  cin >> a >> b;
  
  for (int c = 1; c <= 3; ++c) {
    if (a * b * c % 2 == 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	const ll p = 998244353;

	ll n, s;
	cin >> n >> s;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	vector<vector<ll>> dp(n, vector<ll>(s + 1, 0));
	dp[0][0] = 2;
	if (a[0] <= s) dp[0][a[0]] = 1;
	for (ll i = 1; i < n; i++) {
		for (ll j = 0; j <= s; j++) {
			dp[i][j] += dp[i - 1][j] * 2 % p;
			dp[i][j] %= p;
			if (j + a[i] <= s) {
				dp[i][j + a[i]] += dp[i - 1][j];
				dp[i][j + a[i]] %= p;
			}
		}
	}
	cout << dp[n - 1][s] << endl;
}


Measured memory_bytes: 73692
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef tuple<int, int, int> T;

const lint MOD = (lint)1e9 + 7;
lint N, X, dp[205][100005], S[205];
vector<lint> fact, fact_inv, inv;

lint mod_pow(lint n, lint x){
    lint res = 1;
    while(x){
        if(x&1) res = res * n % MOD;
        x >>= 1; n = n * n % MOD;
    }
    return res;
}

void createFactInvMod(int n){
    fact.resize((unsigned int)n+1); fact_inv.resize((unsigned int)n+1);
    fact[0] = 1;
    for(int i=1;i<=n;i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[n] = mod_pow(fact[n], MOD-2);
    for(int i=n-1;0<=i;i--) fact_inv[i] = fact_inv[i+1] * (i+1) % MOD;
}

void createInvMod(int n){
    inv.resize((unsigned int)n+1);
    createFactInvMod(n);
    inv[0] = 0;
    for(int i=1;i<=n;i++) inv[i] = fact[i-1] * fact_inv[i] % MOD;
}

lint rec(int i, lint x){
    if(i==N-1) return x % S[N-1];
    if(dp[i][x]>-1) return dp[i][x];
    return dp[i][x] = (rec(i+1, x%S[i])+(N-i-1)*rec(i+1, x)) % MOD * inv[N-i] % MOD;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> X;
    for(int i=0;i<N;i++) cin >> S[i];

    createInvMod(N);
    sort(S, S+N); reverse(S, S+N);
    for(int i=0;i<=N;i++) for(int j=0;j<=X;j++) dp[i][j] = -1;

    cout << fact[N] * rec(0, X) % MOD << endl;
    return 0;
}

Measured memory_bytes: 157952
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    while(getline(cin,s))
	{
        for(int i=0;i<26;++i)
		{
            for(int j=0;j<s.size();++j) 
				if('a'<=s[j]&&s[j]<='z')
					{
						s[j]=((s[j]-'a'+1)%26+'a');
				}
            if(s.find("the")!=-1||s.find("this")!=-1||s.find("that")!=-1)break;
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#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 < min(1000, x); i++)
	{
		for (int j = 0; j < min(1000, y); j++)
		{
			for (int k = 0; k < min(1000, z); k++)
			{
				if (pque.size() < K)
				{
					pque.push(a[i] + b[j] + c[k]);
				}
				else
				{
					long long int t = a[i] + b[j] + c[k];
					if (pque.top() < t)
					{
						pque.pop();
						pque.push(t);
					}
				}
			}
		}
	}

	while (!pque.empty())
	{
		res.push_back(pque.top());
		pque.pop();
	}

	for (int i = res.size() - 1; i >= 0; i--)
	{
		cout << res[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {

    int a, b, x;
    cin >> a >> b >> x;

    cout << ((a <= x && x - a <= b)? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int main()
{
        int N = ri();
        vector<int> A(N, 0);

        for (int i = 0; i < (N - 1); i++)
                A[ri() - 1]++;

        wvi(A);

	return 0;
}


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

typedef struct _data
{
	int val;
	struct _data *prev;
	struct _data *next;
} data;


data *head, *tail;

void insert(int x)
{
	data *p = (data*)malloc(sizeof(data));
	p->val = x;
	p->prev = NULL;
	p->next = head;
	if (head == NULL) tail = p;
	else head->prev = p;
	head = p;
}

void deleteFirst()
{
	data *p;

	if (head == NULL) return;
	p = head;
	head = head->next;
	free(p);
	if (head == NULL) tail = NULL;
	else head->prev = NULL;
	return;
}

void deleteLast()
{
	data *p;
	if (tail == NULL) return;
	p = tail;
	tail = tail->prev;
	free(p);
	if (tail == NULL) head = NULL;
	else tail->next = NULL;
	return;
}

void delete(int x)
{
	data *p;
	p = head;
	while (p != NULL && p->val != x) p = p->next;

	if (p == NULL) return;
	if (p == head) deleteFirst();
	else if (p == tail) deleteLast();
	else
	{
		p->prev->next = p->next;
		p->next->prev = p->prev;
		free(p);
	}
	return;
}

void terminate()
{
	data *p;
	while ((p = head) != NULL)
	{
		head = head->next;
		free(p);
	}
	tail = NULL;
}

void dump()
{
	data *p = head;
	while (p != NULL)
	{
		printf("%d", p->val);
		if (p->next != NULL) printf(" ");
		p = p->next;
	}
	printf("\n");
}

int main()
{
	int i, n, x;
	char cmd[12];

	head = tail = NULL;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%11s", cmd);
		if (!strcmp(cmd, "insert"))
		{
			scanf("%d", &x);
			insert(x);
		}
		else if (!strcmp(cmd, "delete"))
		{
			scanf("%d", &x);
			delete(x);
		}
		else if (!strcmp(cmd, "deleteFirst")) deleteFirst();
		else if (!strcmp(cmd, "deleteLast"))  deleteLast();
	}

	dump();
	terminate();

	return 0;
}

Measured memory_bytes: 32928
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define endl "\n"
#define PI 3.14159265
const int mod=1e9+7;
//const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
const int N = (int)2e5 + 10;
int tree[4 * N];
int dp[N];
int h[N], val[N];
int n;
void build(int node,int start,int end,int tree[],int a[])
{
    if(start==end)
     { tree[node]=a[start]; return;}
    int mid=(start+end)/2;
    build(2*node,start,mid,tree,a);
    build(2*node+1,mid+1,end,tree,a);
    tree[node]=min(tree[2*node],tree[2*node+1]);
}

void update(int node,int start,int end,int idx,int val)
{
    if(start==end)
   {
       //a[idx]=val;
       tree[node]=val;
    }
   else
 {
    int mid=(start+end)/2;
   if(idx>=start&&idx<=mid)
     update(2*node+1,start,mid,idx,val);
   else
      update(2*node+2,mid+1,end,idx,val);
    tree[node]=max(tree[2*node+1],tree[2*node+2]);
   /*if(tree[2*node]<tree[2*node+1])
      tree[node]=tree[2*node];
   else
     tree[node]=tree[2*node+1];*/
   }
}

int query(int node,int start,int end,int l,int r)
{
    if(l>end||start>r)
      return -1;
   if(l<=start&&r>=end)
      return tree[node];
   int p1,p2;
    int mid=(start+end)/2;

   p1=query(2*node+1,start,mid,l,r);
   p2=query(2*node+2,mid+1,end,l,r);
    return max(p1,p2);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //int n;
    cin>>n;
    //int h[n+1],val[n+1];
    //int tree[4*n+1];
    for(int i=0;i<=4*n;i++)tree[i]=0;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=n;i++)
        {cin>>val[i];}

    //int dp[n+1];
    for(int i=1;i<=n;i++)dp[h[i]]=val[i];
    dp[0]=0;

    for(int i=1;i<=n;i++)
    {
        int d=query(0,1,n,1,h[i]-1);
        //cout<<d<<endl;
        dp[h[i]]=max(dp[h[i]],d+val[i]);
        update(0,1,n,h[i],dp[h[i]]);
      /*  for(int j=0;j<i;j++)
        {
            if(h[j]<h[i])
                dp[i]=max(dp[i],dp[j]+val[i]);
        }*/
    }
    int max1=-1;
    for(int i=1;i<=n;i++)
        max1=max(max1,dp[i]);
    cout<<max1<<endl;

    return 0;
}


Measured memory_bytes: 11264
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;



void solve()
{
	ll k,n;cin>>k>>n;
	if(k*500>=n)
		cout<<"Yes";
	else cout<<"No";
}

int main()
{
	//fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi a(N);
    rep(i,N) {
        cin>>a.at(i);
    }
    sort(all(a));
    reverse(all(a));
    int Alice=0;
    int Bob=0;
    rep(i,N) {
        if(i==0||i%2==0) Alice+=a.at(i);
        else Bob+=a.at(i);
    }
    cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 636