akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int MOD = 1e9 + 7;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, m;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];
	ll one = 0, two = 0, cnt = 0, prev = 0;
	repn(i, 1, n){
		cnt++;
		ll cur = ((1LL * cnt * (((ll)(x[i] - x[i - 1]) + MOD)) % MOD) + MOD) % MOD;
		one = (one + prev + MOD) % MOD;
		one = (one + cur + MOD) % MOD;
		prev = cur + prev;		
	}
	cnt = 0, prev = 0;
	repn(i, 1, m){
		cnt++;
		ll cur = ((1LL * cnt * (((ll)(y[i] - y[i - 1]) + MOD)) % MOD) + MOD) % MOD;
		two = (two + prev + MOD) % MOD;
		two = (two + cur + MOD) % MOD;
		prev = cur + prev;		
	}
	ll ans = ((one * two) + MOD) % MOD;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1792
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    while b:
        a, b = b, a % b
    return a


x = int(input())
ans = gcd(x, 360)
print(360 // ans)

Measured memory_bytes: 61588
fun main(args: Array<String>) {
    val K = readLine()!!.toInt()


    val lunlunMap: MutableMap<Long, List<Int>> = mutableMapOf()
    repeat(10) { key ->
        val list = mutableListOf<Int>()
        repeat(10) { value ->
            if (Math.abs(key - value) <= 1) {
                list.add(value)
            }
        }
        lunlunMap += key.toLong() to list

    }
    val lunluns = mutableListOf<Long>()
    fun lunlun(n: Long, depth: Long, list: MutableList<Long>) {
        if (depth == 1L) {
            list.add(n)
            return
        }

        val n10 = n * 10L

        val tlun = lunlunMap[n % 10]!!.map { n10 + it }
        tlun.forEach {
            lunlun(it, depth - 1, list)
        }

    }

    var digit = 1L
    while (true) {
        repeat(9) {
            lunlun(it + 1L, digit, lunluns)
            if (lunluns.size >= K) {
                println(lunluns[K - 1])
                return
            }
        }
        digit++
    }
}





Measured memory_bytes: 43416
price = []
while 1:
    a = []
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    sum = -1
    for i in range(len(a)-1):
        for j in range(i+1,len(a)):
            if a[i] + a[j] <= m and sum <= a[i] + a[j]:
                sum = a[i] + a[j]
    if sum < 0:
        price.append(-1)
    else:
        price.append(sum)

for i in range(len(price)):
    if price[i] >= 0:
        print(price[i])
    else:
        print('NONE')



Measured memory_bytes: 5712
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b

n=int(input())
a=list(map(int,input().split()))
s=Csum(a)
su=sum(a)
b=1
c=0
for i in range(n+1):
    c+=b
    b-=a[i]
    if b<=0:
        if i==n and b==0:
            break
        print(-1)
        exit()
    b=min(b*2,su-s[i+1])
print(c)

Measured memory_bytes: 20004
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	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;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	vint ans;
	while (1) {
		string s;
		cin >> s;
		if (s[0] == '0')break;
		int x = 0;
		rep(i, s.size()) {
			x += s[i] - '0';
		}
		ans.push_back(x);
	}
	coutans;
	return 0;
}


Measured memory_bytes: 3124
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	long h, w;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto ar = readln().strip().split().map!(to!long).array();
		h = ar[0];
		w = ar[1];
	}
}

auto main2(Input* input)
{
	with (input)
	{
        if (h == 1 || w == 1)
            return 1;
        long temp = (h / 2) * w;
        if (h % 2 == 1)
            temp += (w + 1) / 2;
        return temp;
	}
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`4 5`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 10);
	}

	unittest // example2
	{
		string example =
`7 3`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 11);
	}

	unittest // example3
	{
		string example =
            `1000000000 1000000000`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 500000000000000000);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		struct Adapter
		{
			string[] _lines;
			this(string input) { _lines = input.splitLines(); }
			string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
		}
		parseInput(input, Adapter(example));
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


Measured memory_bytes: 256
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll a,b;
    cin>>a>>b;

    ll total = (a*(a-1))/2 + (b*(b-1))/2;
        
    cout<<total;    












    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


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

const int MAX_N = (int)1e5 + 5;
const int MAX_M = (int)1e5 + 5;

int n, m;
int p[MAX_N];
// int x[MAX_N], y[MAX_M];

map<int, set<int>> cand_ind_mp;
map<int, set<int>> cand_ele_mp;

int ans = 0;

/////////////////////////////////////////////////////////
int uf_par[MAX_N];
int uf_rank[MAX_N];

void uf_init(int n) {
  for (int i = 0; i < n; ++i) {
    uf_par[i] = i;
    uf_rank[i] = 0;
  }
}

int uf_find (int x) {
  if (uf_par[x] == x) {return x;}
  else {
    return uf_par[x] = uf_find(uf_par[x]);
  }
}

void uf_unite(int x, int y) {
  x = uf_find(x);
  y = uf_find(y);

  if (x == y) {return;}
  if (uf_rank[x] < uf_rank[y]) {uf_par[x] = y;}
  else {
    uf_par[y] = x;
    if (uf_rank[x] == uf_rank[y]) uf_rank[x] += 1;
  }
}

bool uf_same(int x, int y) {
  return uf_find(x) == uf_find(y);
}
/////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);
  uf_init(n + 5);
  for (int i = 1; i <= n; ++i) {scanf("%d", &(p[i]));}
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    uf_unite(x, y);
  }

  for (int i = 1; i <= n; ++i) {
    int cur_par = uf_find(i);
    cand_ind_mp[cur_par].insert(i);
  }

  for (auto itr = cand_ind_mp.begin(); itr != cand_ind_mp.end(); ++itr) {
    for (auto ind: itr->second) {
      cand_ele_mp[itr->first].insert(p[ind]);
    }
  }

  for (auto itr = cand_ind_mp.begin(); itr != cand_ind_mp.end(); ++itr) {
    set<int> cand_ind = cand_ind_mp[itr->first];
    set<int> cand_ele = cand_ele_mp[itr->first];
    for (auto ind: cand_ind) {
      auto itr = cand_ele.find(ind);
      if (itr != cand_ele.end()) {
        ans += 1;
      }
    }
  }

  printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 29568
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        StringBuilder sb = new StringBuilder();
        do {
            sb.setLength(0);
            int[] point = new int[m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    point[j] += in.nextInt();
                }
            }
            for (int i = 0; i < n; i++) {
                int cp = n - i;
                for (int j = 0; j < m; j++) {
                    if (point[j] == cp) {
                        sb.append(' ');
                        sb.append(j + 1);
                    }
                }
            }
            System.out.println(sb.substring(1));
            n = in.nextInt();
            m = in.nextInt();
        } while (n != 0 || m != 0);
        in.close();
    }
}

Measured memory_bytes: 80428
class Combination:

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
c = Combination(3000)

def H(n, r, mod=10**9+7):
    return c(n+r-1, r)


mod = 10**9+7
N, K = map(int, input().split())
B = K
R = N-K
for i in range(1, K+1):
    bn = i
    br = B-i
    rn = i+1
    rr = R-i+1
    if rr<0 or br<0:
        print(0)
    else:
        #print(i, bn, br, rn, rr)
        ans = H(bn, br) * H(rn, rr) % mod
        print(ans)


Measured memory_bytes: 3700
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
    // 整数の入力
    int a, b, c, d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    
    // 出力
    cout << min(a, b)+min(c, d)<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  ll n;
  vector<int> v;
  cin >> n;
  if(n==0) {
    std::cout << 0 << std::endl;
    return 0;
  }
  while (n != 0) {
    ll sum = 0;
    ll p = 0;
    int x;
    if (n > 0) {
      x = 0;
      while (sum < n) {
        p = pow(-2, x);
        sum += p;
        x += 2;
      }
      n -= p;
      v.push_back(x - 2);
    } else {
      x = 1;
      while (sum > n) {
        p = pow(-2, x);
        sum += p;
        x += 2;
      }
      n -= p;
      v.push_back(x - 2);
    }
  }
  vector<int> vv(v[0]+1);
  for(int i=0; i<v[0]+1; i++) {
    auto res = find(v.begin(), v.end(), i);
    if(res==v.end()) {
      vv[i]=0;
    } else {
      vv[i]=1;
    }
  }
  for(int i=v[0]; i>=0; i--) {
    std::cout << vv[i] ;
  }
  cout<<endl;
  return 0;
}


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

bool check(vector<string> S, int A, int B, int N){
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      int nx = (i+A) % N;
      int ny = (j+B) % N;

      int mx = (j+A) % N;
      int my = (i+B) % N;

      if(S[nx][ny] != S[mx][my]){
	return false;
      }
    }
  }
  return true;
}

int main() {
  int N;
  scanf("%d", &N);
  vector<string> S(N);
  for(int i=0; i<N; i++){
    cin >> S.at(i);
  }

  int ans = 0;
  int i=0;
  for(int j=0;j<N;j++){
    if(check(S, i, j, N)){
      ans++;
      //      cout << i << ',' << j << endl;
    }
  }
  printf("%d\n", ans * N);
}


Measured memory_bytes: 512
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int res = 0;
            String prev = "";
            for (int i = 0; i < s.length(); ) {
                int len = 1;
                if (s.substring(i, i + len).equals(prev)) ++len;
                if (i + len > s.length()) break;
                prev = s.substring(i, i + len);
                i += len;
                ++res;
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 39636
#include<bits/stdc++.h>
using namespace std;
set<string> s;
int main()
{
    string c;
	s.insert("a");s.insert("e");s.insert("i");s.insert("o");s.insert("u");
	cin>>c;
	if(s.find(c)!=s.end()) cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x;
	scanf("%d",&x);
	if(x>=0&&x<1200){
		printf("ABC\n");
	}
	else if(x>=1200&&x<2800){
		printf("ARC\n");
	}
	else if(x>=2800&&x<=4208){
		printf("AGC\n");
	}
	return 0;
}

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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;


int main() {
	int A, B;
	char S[11];
	int flag = 1;
	scanf("%d %d", &A, &B);
	scanf("%s", S);
	REP(i, A + B + 1) {
		if (i==A){
			if (S[A] != '-') {
				flag = 0;
				break;
			}
		}else if (S[i]<'0' || S[i]>'9') {
			flag = 0;
			break;
		}
	}
	if (flag) {
		PRINTS("Yes");
	}
	else {
		PRINTS("No");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  
  lint D; cin >> D;
  vi c(26); // contest 0-25
  for(lint i=0; i<26; i++) cin >> c[i];
  vvi s(D+1, vi(26)); // day 0-D
  for(lint d=1; d<=D; d++){
    for(lint j=0; j<26; j++){
      cin >> s[d][j];
    }
  }
  /*
  vi t(D+1); // day 0-D
  
  for(lint d=1; d<=D; d++){
    cin >> t[d];
    t[d]--;
  }
  */
  
  vi last(26,0);
  
  // lint ans = 0;
  vi ans(D+1);
  
  for(lint d=1; d<=D; d++){
    vi diff(26);
    
    for(lint i=0; i<26; i++){ // if contest i (0-25)
      // ans += s[d][t[d]];
      lint plus = s[d][i];
    
      // last[t[d]] = d;
      lint oldlast = last[i];
      last[i] = d;
    
      lint minus = 0;
    
      for(lint j=0; j<26; j++){
        // ans -= c[j] * (d - last[j]);
        minus += c[j] * (d - last[j]);
      }
      
      last[i] = oldlast;
      diff[i] = plus - minus;
    }
    
    vi oldiff = diff;
    sort(ALL(diff));
    lint t = -1;
    for(lint j=0; j<26; j++){
      if(oldiff[j] == diff[25]) t = j;
    }
    // cout << t+1 << endl;
    ans[d] = t+1;
    last[t] = d;
    
  }
  /*
  sort(ALL(c));
  lint tmp = 18; // delete suru kosuu
  for(lint j=0; j<tmp; j++) c.pop_back();
          
  for(lint d=1; d<=D; d++){
    cout << c[d%(26-tmp)] << endl;
  }
  */
  
  for(lint i=0; i<26; i++) last[i] = 0;
  
  lint score = 0;
  
  for(lint d=1; d<=D; d++){
    score += s[d][ans[d]];
    last[ans[d]] = d;
    for(lint j=0; j<26; j++){
      score -= c[j] * (d - last[j]);
    }
  }
  
  lint cnt = 0;
  while(cnt<1){
    lint rd = rand()%25;
    swap(ans[rd], ans[rd+1]);
    ////////
    lint score2 = 0;
    for(lint d=1; d<=D; d++){
      score2 += s[d][ans[d]];
      last[ans[d]] = d;
      for(lint j=0; j<26; j++){
        score2 -= c[j] * (d - last[j]);
      }
    }
    ////////
    if(score2 <= score){
      swap(ans[rd], ans[rd+1]);
    }else{
      // cout << score << endl << score2 << endl;
      score = score2;
      cnt++;
      
    }
  }

  
  for(lint d=1; d<=D; d++) cout << ans[d] << endl;
}
      
      
    
  
  
  
  


Measured memory_bytes: 3720
#include<stdio.h>
#include<math.h>

int n,i;
int main()
{
     scanf("%d",&n);
     int res[n],x,m;
     m=n-1; for(i=1;i<=n;i++) res[i]=0;



    while(m--)
    {
        scanf("%d",&x);
        res[x]++;
    }
    for( i=1;i<=n;i++) printf("%d\n",res[i]);

}


Measured memory_bytes: 2476
// Aizu Vol0 0085: Joseph's Potato
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, m;
	int j, k;

	while (1) {
		scanf("%d%d", &n, &m);
		if (n == 0) break;

		k = 1;
		for (j = 2; j <= n; j++) {
			k = (k + m) % j;
			if (k == 0) k = j;
		}
		printf("%d\n", k);
	}
	return 0;
}

Measured memory_bytes: 600
n, x, y = map(int, input().split())
D = [0]*n
for i in range(1, n+1):
    for j in range(i+1, n+1):
        d = min( j-i, abs(x-j)+abs(y-i)+1, abs(y-j)+abs(x-i)+1 )
        D[d] += 1
[print(d) for d in D[1:]]

Measured memory_bytes: 47324
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int A; int V; cin>>A>>V;
  int B; int W; cin>>B>>W;
  int T; cin>>T;
  if(V<=W)
    cout<<"NO"<<endl;
  else{
   int I=V-W;
    int K=0;
    if(abs(A-B)%I==0)
      K=abs(A-B)/I;
    else K=abs(A-B)/I+1;
    if(K<=T)
      cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}
    

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
using mii = map<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
lint A, B, C, D, E, F, G, H, I, J, K, L, M, N;
lint O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans;

lint gcd(lint a, lint b) {
    if (max(a,b) % min(a,b) == 0) {
        return min(a,b);
    } else {
        return gcd(min(a,b), max(a,b) % min(a,b));
    }
}

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

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

    cout << lcm(A, B) << endl;
    return 0;
}

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

namespace BeginnerContest053
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();                                                   

            //Console.WriteLine(int.Parse(input) < 1200 ? "ABC" : "ARC");
                                                               

            //var first  = input.IndexOf("A");
            //var last = input.LastIndexOf("Z");
            //Console.WriteLine(last - first +1);


            var max = long.Parse(input);

            if (max <= 6)
            {
                Console.WriteLine(1);
            }
            else if (max < 11)
            {
                Console.WriteLine(2);
            }
            else
            {            
                var result = max / 11;
                result *= 2;
                if (max%11 != 0)
                {
                    result += 1;
                    var mod =  max % 11 ;
                    if (mod > 6)
                        result += 1;
                }
                    

                Console.WriteLine(result);
            }                            



        }
    }
}


Measured memory_bytes: 2648
N,*ls=$<.read.split.map(&:to_i)

ls = ls.sort + [9999]

ret = 0

0.upto(N-3) do |i|
  j = i+1
  k = j+1
  while k <= N
    if ls[i]+ls[j] <= ls[k]
      ret += k-j-1
      j += 1
    else
      k += 1
    end

    if j == k
      k = j+1
    end
  end
end

p ret


Measured memory_bytes: 1912
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)


int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,m,j,n,x,k,f,g,q,r,w;
    cin>>n;
    x=0;
    if(n%10==7){
        x=1;
    }
    n=n/10;
    if(n%10==7){
        x=1;
    }
    n=n/10;
    if(n%10==7){
        x=1;
    }
    if(x==0){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}

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

class Cube {
public:
	int f[6];
	Cube(){}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};

bool eq(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++)
		if (c1.f[i] != c2.f[i])return false;
	return true;
}

bool equal(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (eq(c1, c2))return true;
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return 0;
}

int main()
{
	Cube c1, c2;

	for (int i = 0; i < 6; i++)cin >> c1.f[i];
	for (int i = 0; i < 6; i++)cin >> c2.f[i];

	if (equal(c1, c2))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;
//ユークリッドの互除法
ll gcd(ll x,ll y){
    if(x>y)swap(x,y);
    if(y%x==0)return x;
    return gcd(x,y%x);
};
int main(){
    int n;
    cin >> n;
    int ans;
    cin >> ans;
    for(int i = 0; i < n-1; i++){
        int tmp;
        cin >> tmp;
        ans = gcd(tmp,ans);
    }   
    cout << ans << endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    int x,y;
    cin >> x >> y;
    x *= 500;

    if(x>=y) puts("Yes");
    else    puts("No");

    return 0;
}

Measured memory_bytes: 3660
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;



//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int n;

int wa(int k){
	int sum = 0;
	while (k!=0)
	{
		sum += k % 10;
		k /= 10;
	}
	return sum;
}




int main() {
	cin >> n;

	if (n%wa(n) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long i64;
const int P=1e6+3;

int inv[2*P];

int pwr(int x,int a){
	int s=1;
	while(a){
		if(a&1)s=(i64)s*x%P;
		x=(i64)x*x%P;
		a>>=1;
	}
	return s;
}

int main()
{
	int T,i,n,d,x,y;
	scanf("%d",&T);
	inv[0]=1;
	for(i=1;i<P;i++)
		inv[i]=(i64)inv[i-1]*i%P;
	while(T--){
		scanf("%d%d%d",&x,&d,&n);
		if(d==0){
			printf("%d\n",pwr(x,n));
			continue;
		}
		y=(i64)x*pwr(d,P-2)%P;
		if(y+n>P){
			printf("0\n");
			continue;
		}
		printf("%d\n",(i64)inv[y+n-1]*pwr(inv[y-1],P-2)%P*pwr(d,n)%P);
	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
using namespace std;
typedef long long ll;

ll a[87];

int main() {
	a[0] = 2;
	a[1] = 1;
	for(int i = 2; i < 87; ++i){
		a[i] = a[i-1] + a[i-2];
	}
	int n; cin >> n;
	cout << a[n] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string N;cin>>N;
    int sum=0;
    REP(i,N.size())sum+=N[i]-'0';
    cout<<(stoi(N)%sum==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        var inp = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int a = inp[0], b = inp[1];

        //--------------------------------solve--------------------------------//

        Console.WriteLine( Math.Max( 2 * Math.Max( a, b ) - 1, a + b ) );
    }




}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const int MAX_N=100,M=5050;
const ll MOD=1e9+7;
int N;
ll K,dp[MAX_N][M+1];
int main(){
	scanf("%d %lld",&N,&K);
	dp[N-1][0]=K;
	if(K==N){
		dp[N-1][1]=1;
	}else{
		dp[N-1][0]++;
	}
	for(int i=N-1;i>0;i--){
		REP(j,M+1){
			REP(k,K+1){
				int j2=j;
				if(k<=i){
					int j0=j;
					if(j0>=i-k){
						j0-=i-k;
						j2++;
						j2+=j0/i;
					}
				}
				dp[i-1][j2]+=dp[i][j];
				dp[i-1][j2]%=MOD;
			}
		}
	}
	ll ans=1;
	REP(i,N-1){
		ans*=K+1;
		ans%=MOD;
	}
	ans*=N;
	ans%=MOD;
	ans*=K*(K+1)/2;
	ans%=MOD;
	REP(i,M+1){
		ans+=MOD-dp[0][i]*i%MOD;
		ans%=MOD;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4096
import collections

def main():
    n,k,q = [int(x) for x in input().split()]
    a = []
    for i in range(q):
        a.append(int(input()))

    c = collections.Counter(a)

    for i in range(n):
        index = int('{}'.format(i+1))
        point = k + c[index] - q
        if point > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back


 int main()
 {
std::ios::sync_with_stdio(false); cin.tie(NULL);
//ll t;
//cin>>t;
//while(t--)
{

ll n,k=0,p=0;
cin>>n;
k=n;
while(k)
{

   if(k%3==0||k%5==0)
     {k--;continue;}
     else
        p=p+k;
        k--;
}
cout<<p;

   cout<<endl;

}
    return 0;
}





Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  int a,b;
  vector<pair<int ,int> > log;
  map<int,int> old;
  while(scanf("%d,%d",&a,&b),a||b) log.push_back(make_pair(-b,a));
  sort(log.begin(), log.end());
  for(int i=0,j=0,k = 1; j<log.size(); j++){
    if(k!=log[j].first){
      k = log[j].first;
      i++;
    }
    old[log[j].second] = i;
  }
  int n;
  while(cin>>n) cout <<old[n]<<endl;
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s,a,b;
   cin>>s;
   int n=s.size();

   for(int i=0;i<(n-1)/2;i++)
   {
       a.push_back(s[i]);
   }

   for(int i=(n+3)/2-1;i<n;i++)
   {
       b.push_back(s[i]);
   }

   if(a==b)
    cout<<"Yes\n";
   else
    cout<<"No\n";

   exit(0);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
vector <string> v;
string s;
vector<int> ans;
int men[51] = {0};
int main(){
  int n = 0;
  string s;

  cin >>s;
  for(int i = 0; i<3;i++){
    if(s[i] == '1'){
      n++;
    }
  }
  cout << n<<endl;


  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 5005;

ll N, K;
ll C[MAXN], P[MAXN], cyc[MAXN], skor[MAXN], len[MAXN], dp[MAXN][MAXN];

ll f(ll now, ll rem) {
    if (rem == 0) return 0;
    ll &ret = dp[now][rem];
    if (ret == -1) {
        ret = 0;
        ret = max(ret, f(now, rem-1));
        ret = max(ret, C[now] + f(P[now], rem-1));
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> N >> K;
    for (int i = 1; i <= N; i++) cin >> P[i];
    for (int i = 1; i <= N; i++) cin >> C[i];
    
    for (int i = 1; i <= N; i++) {
        if (cyc[i]) continue;
        cyc[i] = i;
        len[i] = 1;
        skor[i] = C[i];
        ll now = P[i];
        while (now != i) {
            cyc[now] = i;
            len[i]++;
            skor[i] += C[now];
            now = P[now];
        }
    }
    
    memset(dp, -1, sizeof(dp));
    ll ans = -INF;
    ll rem = K-1;
    for (int i = 1; i <= N; i++) {
        ans = max(ans, C[i] + f(P[i], min(rem, N)));
        //~ cerr << f(i, min(rem, N)) << "\n";
        ll c = cyc[i];
        ans = max(ans, C[i] + (rem/len[c])*skor[c] + f(P[i], rem%len[c]));
    }
    cout << ans << "\n";
    
}


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

using namespace std;

int main(){
  vector<int>a(32);
  a={1, 1, 1, 2, 1, 2, 1, 5, 2,
     2, 1, 5, 1, 2, 1, 14, 1, 5,
     1, 5, 2, 2, 1, 15, 2, 2, 5,
     4, 1, 4, 1, 51};
  int K;
  cin>>K;
  cout<<a[K-1]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int MAX;
		if(A+B > A-B) {
			if(A+B > A*B) {
				MAX= A+B;
			} else {
				MAX = A*B;
			}
		} else {
			if(A-B > A*B) {
				MAX = A-B;
			} else {
				MAX = A*B;
			}
		}
		System.out.println(MAX);
	}
}

Measured memory_bytes: 21844
n, k = map(int, input().split())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

AA = sorted(A, key=lambda x: -abs(x))

nega1 = []
posi1 = []
for a in AA[:k]:
  if a < 0:
    nega1.append(a)
  else:
    posi1.append(a)

nega2 = []
posi2 = []
for a in AA[k:]:
  if a < 0:
    nega2.append(a)
  else:
    posi2.append(a)

if all(a < 0 for a in A) and k % 2 == 1:
  AA = sorted(A, key=lambda x: abs(x))
  nega1 = []
  posi1 = []
  for a in AA[:k]:
    nega1.append(a)

elif n == k:
  pass

elif len(nega1) % 2 != 0:
  if posi1 and nega2 and posi2:
    if abs(nega1[-1] * nega2[0]) < abs(posi1[-1] * posi2[0]):
      del nega1[-1]
      nega1.append(posi2[0])
    else:
      del posi1[-1]
      posi1.append(nega2[0])
  elif not posi1 or not nega2:
    del nega1[-1]
    nega1.append(posi2[0])
  elif not posi2:
    del posi1[-1]
    posi1.append(nega2[0])
  
a = 1
for m in posi1:
  a = (a * m) % MOD
for p in nega1:
  a = (a * p) % MOD
 
print(a)

Measured memory_bytes: 31848
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

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

#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)

struct even{
  ll start;
  int type;
  ll x;

  even(ll _start, int _type, ll _x){
    start = _start;
    type = _type;
    x = _x;
  }
};

int main() {

  ll N, Q;
  cin >> N >> Q;
  ll S, T, X;
  vector<even> SS;
  REP(i, N) {
    cin >> S >> T >> X;
    SS.push_back(even(S - X, 1, X));
    SS.push_back(even(T - X, -1, X));
  }
  vector<ll> D(Q);
  REP(i, Q) cin >> D[i];

  sort(SS.begin(), SS.end(), [](even& even1, even& even2){
    if (even1.start != even2.start) return (even1.start < even2.start);
    else return (even1.type < even2.type);
  });

  ll latest = 0;
  set<ll> stat;
  for (auto iter : D){
    while(latest < SS.size()){
      if (iter >= SS[latest].start){
        if (SS[latest].type == 1) stat.insert(SS[latest].x);
        else stat.erase(SS[latest].x);
        latest++;
      }
      else break;

    }
    if (stat.empty()) cout << -1 << endl;
    else cout << *stat.begin() << endl;
  }

  return 0;
}


Measured memory_bytes: 22120
#include<bits/stdc++.h>
using namespace std;
#define int 			long long int
#define ld 				long double
#define ff 				first
#define ss 				second
#define P 				pair<int,int>
#define pb 				push_back
#define mod             1000000007
#define inf             1e18
#define endl			'\n'
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
const int N = 22;//change it when needed
int visited = (1 << N) - 1;
int a[N][N];
int dp[N][1 << N];
int n;
int F(int i, int X) {
	if (i == n + 1) {
		return X == ((1 << n) - 1) ? 1 : 0;
	}
	int &ans = dp[i][X];
	// ith bit is 0 then women is availabe
	//  ith bit is 1 then women is occupied
	if (ans != -1)return ans;
	ans = 0;

	for (int j = 0; j < n; j++) {
		bool availabe = (X & (1 << j)) ? 0 : 1;
		if (a[i][j + 1] == 1 and availabe) {
			//that is we are able to compat ith men and jth women
			ans = (ans + F(i + 1, X ^ (1 << j))) % mod;
		}
	}
	return ans;
}
void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << F(1, 0) << endl;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 721280
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define MN 201000

struct xxx{
	int a, b, id;
}d[MN];

int fa[MN], f[MN];

bool operator > (xxx x, xxx y) {return 1ll * x.b * y.a > 1ll * y.b * x.a;}

std::priority_queue<xxx, std::vector<xxx>, std::greater<xxx> > pq;

int Find(int x) {return fa[x] == x ? x : fa[x] = Find(fa[x]);}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 2; i <= n; i++) scanf("%d", &f[i]);
	for(int i = 1; i <= n; i++)
	{
		int v; scanf("%d", &v);
		if(v == 0) d[i].a++;
		if(v == 1) d[i].b++;
		d[i].id = i; fa[i] = i;
		if(i != 1) pq.push(d[i]);
	}
	long long ans = 0;
	while(!pq.empty())
	{
		xxx P = pq.top(); pq.pop();
		int p = P.id; 
		if(P.a != d[p].a || P.b != d[p].b) continue;
		int q = Find(f[p]); 
		fa[p] = q;
		ans += 1ll * d[q].b * d[p].a;
		d[q].a += d[p].a;
		d[q].b += d[p].b;
		if(q != 1) pq.push(d[q]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7796
# coding: utf-8


def main():
    X, Y = map(int, input().split())

    for n_turu in range(X+1):
        n_kame = X - n_turu
        if n_turu * 2 + n_kame * 4 == Y:
            return "Yes"

    return "No"


print(main())


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

int main()
{
    string C[2];
    cin >> C[0] >> C[1];
    reverse(C[1].begin(), C[1].end());
    if (C[0] == C[1])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n); REP(i, n) cin >> a[i];
  FOR(i, k, n) cout << (a[i - k] < a[i] ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 3988
#include<iostream>
#include<vector>

using namespace std;

int main(){
    long long d,n;
    cin >> d >> n;
    long long i = 1;
    vector<long long> presentList;
    while(presentList.size() < n){
        long long copy = i;
        int count = 0;
        for(int j = 0; j <= 2; j++){
            if( copy % 100 == 0){
                copy = copy / 100 + 0.5;
                count ++;
            }
        }
        if(count == d){
            presentList.push_back(i);
        }
        i++;
    }
    cout << presentList.at(n-1) << endl;
    return 0;
}


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

int main(){
	string s;
	
	cin >> s;
	
	if(s == "hi" || s == "hihi" || s =="hihihi" || s =="hihihihi" || s =="hihihihihi"){
	cout << "Yes" << endl;
	}else{
	cout << "No" << endl;
	}
	
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, d;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	ll ans = 0;
	ll sum = 0;
	rep(i, 1, n){
		cin >> d;
		sum += d;
		ans -= d*d;
	}
	
	ans += sum*sum;
	ans /= 2;
	print(ans)
	return 0;
}

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

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

	int height;
	priority_queue<int> pq;

	for(int i = 0; i < 10; i++){
		cin >> height;
		pq.push(height);
	}

	for(int i = 0; i < 3; i++){
		cout << pq.top() << "\n";
		pq.pop();
	}
}

Measured memory_bytes: 3208