akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<ll> a,b,ans;
// 素集合データ構造
struct UnionFind
{
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<int> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1)
    {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        rep(i, n) par[i] = i;
    }

    // データxが属する木の根を得る
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y)
    {
        // データの根ノードを得る
        x = find(x);
        y = find(y);

        // 既に同じ木に属しているならマージしない
        if (x == y)
            return;

        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y])
            swap(x, y);

        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x)
    {
        return sizes[find(x)];
    }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for (int i = 0; i < m; i++)
    {
        ll temp,temp1;
        cin >> temp>>temp1;
        temp--;
        temp1--;
        a.push_back(temp);
        b.push_back(temp1);
    }
    reverse(ALL(a));
    reverse(ALL(b));
    UnionFind uf(n);
    ll now=n*(n-1)/2;
    for(int i=0;i<m;i++){
        ans.push_back(max(now,ll(0)));
        ll temp=uf.size(a[i]);
        ll temp1=uf.size(b[i]);
        if(uf.find(a[i])!=uf.find(b[i]))
        now-=temp*temp1;
        uf.unite(a[i],b[i]);
    }
    reverse(ALL(ans));
    for(int i=0;i<m;i++)
    cout << ans[i] << "\n";
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define INF 1e9

int N;
int X[maxn],Y[maxn];
char U[maxn];

map <int,vi> yxLm,yxLp,yxRm,yxRp;
vi XposD[maxn],XposU[maxn],YposR[maxn],YposL[maxn];

int main(){
	fast;
	
	cin>>N;
	
	FOR(i,1,N){
		cin>>X[i]>>Y[i]>>U[i];
		if (U[i] == 'D') XposD[X[i]].pb(Y[i]); 
		if (U[i] == 'U') XposU[X[i]].pb(Y[i]);
		if (U[i] == 'R') YposR[Y[i]].pb(X[i]);
		if (U[i] == 'L') YposL[Y[i]].pb(X[i]);
		
		if (U[i] == 'R'){
			yxRm[Y[i] - X[i]].pb(Y[i]);
			yxRp[Y[i] + X[i]].pb(Y[i]);
		}else if (U[i] == 'L'){
			yxLm[Y[i] - X[i]].pb(Y[i]);
			yxLp[Y[i] + X[i]].pb(Y[i]);
		}
	}
	
	FOR(i,0,maxn-1){sort(all(XposD[i])); sort(all(XposU[i])); sort(all(YposL[i])); sort(all(YposR[i]));}
	
	aFOR(i,yxLm) sort(all(yxLm[i.f]));
	aFOR(i,yxRp) sort(all(yxRp[i.f]));
	aFOR(i,yxRm) sort(all(yxRm[i.f]));
	aFOR(i,yxLp) sort(all(yxLp[i.f]));
	
	ll ans = INF;
	
	FOR(i,1,N){ //opp dir
		if (U[i] == 'U'){
			auto it = upper_bound(all(XposD[X[i]]), Y[i]);
			if (it != XposD[X[i]].end()) ans = min(ans, (*it - Y[i]) * 5);
		}else if (U[i] == 'D'){
			auto it = lower_bound(all(XposU[X[i]]), Y[i]);
			if (it != XposU[X[i]].begin()) it--;
			else continue;
			
			if (it != XposU[X[i]].end()) ans = min(ans, (Y[i] - *it) * 5);
		}else if (U[i] == 'R'){
			auto it = upper_bound(all(YposL[Y[i]]), X[i]); 
			if (it != YposL[Y[i]].end()) ans = min(ans, (*it - X[i]) * 5);
		}else{
			auto it = lower_bound(all(YposR[Y[i]]), X[i]);
			if (it != YposR[Y[i]].begin()) it--;
			else continue;
			
			if (it != YposR[Y[i]].end()) ans = min(ans, (X[i] - *it) * 5);
		}
	}
	FOR(i,1,N){ //perp dir
		if (U[i] == 'U'){
			auto it = upper_bound(all(yxLm[Y[i] - X[i]]), Y[i]);
			if (it != yxLm[Y[i] - X[i]].end()) ans = min(ans, (*it - Y[i]) * 10);
			
			auto it2 = upper_bound(all(yxRp[Y[i] + X[i]]), Y[i]);
			if (it2 != yxRp[Y[i] + X[i]].end()) ans = min(ans, (*it2 - Y[i]) * 10);
			
		}else if (U[i] == 'D'){
			auto it = lower_bound(all(yxRm[Y[i] - X[i]]), Y[i]);
			if (it != yxRm[Y[i] - X[i]].begin()){
				it--;
			
				if (it != yxRm[Y[i] - X[i]].end()) ans = min(ans, (Y[i] - *it) * 10);
			}
			
			auto it2 = lower_bound(all(yxLp[Y[i] + X[i]]), Y[i]);
			if (it2 != yxLp[Y[i] + X[i]].begin()) it2--;
			else continue;
			
			if (it2 != yxLp[Y[i] + X[i]].end()) ans = min(ans, (Y[i] - *it2) * 10);
		}
	}
	if (ans == INF) cout<<"SAFE";
	else cout<<ans;
		
	
}


Measured memory_bytes: 68392
num_datasets = int(input())

for i in range(num_datasets):
    n = input().strip()
    m = input().strip()
    first_num_str = ""
    second_num_str = ""
    if len(n) > len(m):
        first_num_str = n
        second_num_str = m
    else:
        first_num_str = m
        second_num_str = n
    total = ""
    carry = 0
    first_int = 0
    second_int = 0
    first_last_index = len(first_num_str)-1
    second_last_index = len(second_num_str)-1
    for i in range(len(first_num_str)):
        first_int = int(first_num_str[first_last_index-i])
        if i < len(second_num_str):
            second_int = int(second_num_str[second_last_index-i])
        else:
            second_int = 0
        added = (first_int + second_int + carry) % 10
        carry = (first_int + second_int + carry) // 10
        total = str(added) + total
    if carry > 0:
        total = str(carry) + total
    if len(total) > 80:
        print("overflow")
    else:
        print(total)


Measured memory_bytes: 5596
// Author : heyuhhh
// Created Time : 2020/09/19 20:22:35
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    string s;
    cin >> s;
    int n = s.length();
    if (s[n - 1] == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3668
# D - I hate Factorization

x = int(input())

# a ** 5 - b ** 5 == x となる組 (a,b) を1つ答える.
# 1 <= x <= 10 ** 9
# a >= 0と仮定してもよい. b < aと仮定してよい. bが減ると左辺は増加.

a = 0
while a ** 5 - (a-1) ** 5 <= x:
    b = a - 1
    while a ** 5 - b ** 5 < x:
        b -= 1
    if a ** 5 - b ** 5 == x:
        print(a, b)
        exit()
    a += 1


Measured memory_bytes: 9164
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		String result = "No";
		if(a%2 == 1 && b%2 == 1) result = "Yes";
        
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <complex>


using namespace std;

int main(){
    long long int K,N,amari,sa= 0;
    cin >> N >> K ;
    amari = N%K;
    sa = amari - K;
    if (sa < 0 ) sa = -1*sa;
    if(sa < amari){
        cout << sa << endl;
    }else{
       cout << amari << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//Comparing Strings
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main ()
{
    int a,b;
    cin >> a >> b;
    string s,t;
    s = t = "";
    for (int i = 0; i < a; i++) {
        s += to_string(b);
    }
    for (int i = 0; i < b; i++) {
        t += to_string(a);
    }
    if (s < t) {
        cout << s << endl;
    }
    else {
        cout << t << endl;
    }
    return 0;
}

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

constexpr int M = 10007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    string t = "JOI";
    vector<vector<int>> dp(n + 1, vector<int>(1 << 3));
    dp[0][1] = 1;
    for(int i = 0; i < n; ++i) {
        int lead = t.find(s[i]);
        for(int pre = 0; pre < (1 << 3); ++pre) {
            for(int nxt = 0; nxt < (1 << 3); ++nxt) {
                if(pre & nxt && (nxt & (1 << lead))) {
                    (dp[i + 1][nxt] += dp[i][pre]) %= M;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < (1 << 3); ++i) {
        (ans += dp[n][i]) %= M;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

// 最大公約数
ll GreatestCommonDivisor(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

// 最小公倍数
ll LeastCommonMultiple(ll a, ll b) {
	ll gcd = GreatestCommonDivisor(a, b);

	ll tmp = a / gcd;
	return tmp * b;
}

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

	// long long?
	int N;
	cin >> N;

	ll ans = 1;
	rep(i, N) {
		ll tmp;
		cin >> tmp;
		ans = LeastCommonMultiple(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int K;
    cin >> K;
    if (K % 2 == 0 || K % 5 == 0)
    {
        cout << -1 << endl;
        return 0;
    }
    int count = 1;
    long long seven = 7;
    while (1)
    {
        seven = seven % K;
        if (seven == 0)
        {
            cout << count << endl;
            return 0;
        }
        seven = seven * 10 + 7;
        count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3492
#include <iostream>
#include <climits>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


struct UnionFind { //UnionFind
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



signed main() {
    ll n, m;
    cin >> n >> m;
    vll p(n);
    
    ll r = 0;
    
    rep(i, n) {
        cin >> p[i];
    }

    UnionFind tree(n);

    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }

    
    rep(i, n) {
        if (tree.same(i, p[i]-1)) {
            r++;
        }
    }
    mes(r);
    
    
}

Measured memory_bytes: 4584
from itertools import product

INF = 10**18

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(N)]

# i番目までのケーキの内、j個食べた時のpointの最大値
# (ただしpointの計算時には、8通りのmaskを乗算する)

def mul_mask(l, mask):
    return [a*b for a, b in zip(l, mask)]

dp_std = [[-INF for _ in range(M+1)] for _ in range(N+1)]
for i in range(N+1):
    dp_std[i][0] = 0

max_p = -INF
masks = product([-1, 1], repeat=3)
for mask in masks:
    dp = dp_std[:]
    for i in range(1, N+1):
        score = sum(mul_mask(XYZ[i-1], mask))
        for j in range(1, M+1):
            # print(i, j, XYZ[i-1], mask)
            dp[i][j] = max(
                dp[i-1][j],
                dp[i-1][j-1] + score
            )
            # for dp_i in dp:
            #     print(dp_i)
    p = dp[N][M]
    max_p = max(max_p, p)
    # print(p)

print(max_p)

Measured memory_bytes: 54492
#include<iostream>
#include<vector>
#include<cmath>
typedef long long ll;
using namespace std;


vector<ll> y;

int isqrt(ll x) {
	int i;
	for (i = 1; x > 0; i++) {
		x -= i * 2 + 1;
	}
	return i - 1;
}


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

void yaku(ll x) {
    int sq = isqrt(x);
    for (int i = 1; i <= sq; ++i) {
        if (x % i == 0) {
            y.push_back(i);
            if ((ll)i * i != x) y.push_back(x / i);
        }
    }
}

int isPrime(ll x){
    if (x == 1) return 1;
    if (x == 2) return 1;
    int sq = isqrt(x);

    for (int i = 2; i <= sq; ++i) {
        if (x % i == 0) return 0;
    }

    return 1;
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    yaku(g);

    ll ans = 0;

    for (ll val: y){
        if (isPrime(val)) ans++;
    }

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

Measured memory_bytes: 384
class Node:
    def __init__(self):
        self.id = -1
        self.parent = None
        self.childs = [None, None]
        self.sibling = -1
        self.depth = -1
        self.height = -1

    def parentId(self):
        return -1 if self.parent == None else self.parent.id

    def type(self):
        if self.parent == None:
            return "root"
        elif self.childs[0] != None or self.childs[1] != None:
            return "internal node"
        return "leaf"

    def degree(self):
        r = 0
        for c in self.childs:
            r += 1 if c != None else 0
        return r


def setDepthAndHeight(node, d):
    h = 0
    node.depth = d
    for i in range(2):
        if node.childs[i] != None:
            h = max(h, setDepthAndHeight(node.childs[i], d+1)+1)
    node.height = h
    return h


n = int(input())
nodes = [Node() for _ in range(n)]

for i in range(n):
    id, l, r = map(int, input().split())
    p = nodes[id]
    p.id = id
    if l >= 0:
        nodes[l].parent = p
        nodes[l].sibling = r
        p.childs[0] = nodes[l]
    if r >= 0:
        nodes[r].parent = p
        nodes[r].sibling = l
        p.childs[1] = nodes[r]

root = None
for node in nodes:
    if node.type() == "root":
        root = node
        break

setDepthAndHeight(root, 0)

for node in nodes:
    s = f"node {node.id}: "
    s += f"parent = {node.parentId()}, "
    s += f"sibling = {node.sibling}, "
    s += f"degree = {node.degree()}, "
    s += f"depth = {node.depth}, "
    s += f"height = {node.height}, "
    s += f"{node.type()}"
    print(s)



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

using namespace std;

#define PII pair<int, int>

const int N = 1e5 + 5;

int n, a[N];
PII tree[4 * N];
map<PII, int> vis;

PII merge(PII x, PII y) {
  if (x.first == -1) return y;
  if (y.first == -1) return x;
  return x.first > y.first ? x : y;
}

void build(int p, int b, int e) {
  if (b == e) {
    tree[p].first = a[b];
    tree[p].second = b;
    return;
  }
  int m = b + e >> 1;
  build(p * 2, b, m);
  build(p * 2 + 1, m + 1, e);
  tree[p] = merge(tree[p * 2], tree[p * 2 + 1]);
}

PII query(int p, int b, int e, int l, int r) {
  if (b > r || e < l) return {-1, -1};
  if (b >= l && e <= r) return tree[p];
  int m = b + e >> 1;
  return merge(query(p * 2, b, m, l, r), query(p * 2 + 1, m + 1, e, l, r));
}

multiset<PII> FOK, SOK;

long long run(int l, int r) {
  if (l >= r || vis[{l, r}]) return 0;
  PII yo = query(1, 1, n, l, r);
  PII mg = merge(query(1, 1, n, l, yo.second - 1), query(1, 1, n, yo.second + 1, r));
  int L = min(yo.second, mg.second);
  int R = max(yo.second, mg.second);
  int peche = L - l + 1;
  int shamne = r - R + 1;
  /*for (int i = l; i <= L; i++) {
    for (int j = R; j <= r; j++) {
      FOK.insert({i, j});
      if (i == 4 && j == 5) {
        cout << i << " " << j << endl;
      }
    }
  }*/
  vis[{l, r}] = 1;
  long long ans = (long long)mg.first * (long long)peche * (long long)shamne;
  //cout << ans << " " << l << " " << L << " " << R << " " << r << endl;
  return ans + run(l, R - 1) + run(L + 1, r);
}

long long brute() {
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    int fs = a[i], sn = -1;
    for (int j = i + 1; j <= n; j++) {
      if (sn == -1) {
        sn = a[j];
        int tmp = max(fs, sn);
        sn = min(fs, sn);
        fs = tmp;
      } else if (fs < a[j]) {
        sn = fs;
        fs = a[j];
      } else if (sn < a[j]) {
        sn = a[j];
      }
      SOK.insert({i, j});
      //cout << i << " " << j << " " << sn << endl;
      sum += sn;
    }
  }
  return sum;
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n);
  cout << run(1, n) << '\n';
  /*cout << "BRUTE: " << brute() << '\n';
  for (auto i : FOK) {
    cout << i.first << " " << i.second << endl;
  }
  cout << FOK.size() << " " << SOK.size() << endl; */
  return 0;
}


Measured memory_bytes: 24064
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define lld long long double
#define pb push_back



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

    int n;
    cin>>n;
    unsigned long long prod=1;
    vector<unsigned long long>arr(n);
    for(int i=0 ; i<n ; i++)
    {
        cin>> arr[i];
    }
    sort(arr.begin(),arr.end());
    if(arr[0]==0){cout<<0;return 0;}
    for(long long i=0 ; i<n ; i++)
    {
        if(arr[i]>1000000000000000000/prod){cout << -1;return 0;}
        prod=prod*arr[i];
    }
    //if(prod<0) {cout <<-1;return 0;}
    cout << prod;

}





Measured memory_bytes: 3988
/*input
4 5
1 2 2
1 3 2
2 3 1
2 4 2
3 4 1
*/
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pti;

const int N = 1505, inf = 1e9;
vector<pti> child[N];
vector<int> Adj[N];
int d[N], mark[N], n, r;

int main(){
	scanf("%d%d", &n, &r);
	for(int i = 1; i <= r; ++i) {
		int u, v, w; scanf("%d%d%d", &u, &v, &w);
		child[u].push_back(make_pair(v, w));
		child[v].push_back(make_pair(u, w));
	}

	int maxdist = - inf;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) d[j] = inf;

		priority_queue<pti, vector<pti>, greater<pti> > q;
		d[i] = 0;
		q.push(make_pair(0, i));

		while(!q.empty()) {
			pti u = q.top(); q.pop();
			if(u.first != d[u.second]) continue;
			for(auto v : child[u.second])
				if(d[v.first] > u.first + v.second) {
					d[v.first] = u.first + v.second;
					q.push(make_pair(d[v.first], v.first));
				}
		}
		for(int j = 1; j <= n; ++j) maxdist = max(maxdist, d[j]);
	}

	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) d[j] = inf, Adj[i].clear();

		priority_queue<pti, vector<pti>, greater<pti> > q;
		queue<int> qu;
		d[i] = 0;
		q.push(make_pair(0, i));

		while(!q.empty()) {
			pti u = q.top(); q.pop();
			if(u.first != d[u.second]) continue;
			if(u.first == maxdist) qu.push(u.second);

			for(auto v : child[u.second])
				if(d[v.first] > u.first + v.second) {
					d[v.first] = u.first + v.second;
					Adj[v.first].clear(), Adj[v.first].push_back(u.second);
					q.push(make_pair(d[v.first], v.first));
				}
				else if(d[v.first] == u.first + v.second) 
					Adj[v.first].push_back(u.second);
		}

		while(qu.size()) {
			int u = qu.front(); qu.pop(); mark[u] = 1;
			for(int v : Adj[u])	mark[v] = 1, qu.push(v);
		}
	}

	vector<int> res;
	for(int i = 1; i <= n; ++i)
		if(mark[i] == 0) res.push_back(i);

	printf("%d\n", (int)res.size());
	for(int v : res) printf("%d\n", v);
}


Measured memory_bytes: 3540
N, D = map(int, input().split())
zahyo = [0]*N
for i in range(N):
  zahyo[i] = list(map(int, input().split()))
count = 0
for i in range(N):
  for j in range(i+1, N):
    V = 0
    for k in range(D):
      V += (zahyo[i][k]-zahyo[j][k])**2
    if (float(V**0.5)).is_integer():
      count += 1
print(count)


Measured memory_bytes: 38640
n = int(input())
h = list(map(int,input().split()))
p = 0
while h.count(0) != n:
    x = 0
    for i in range(n):
        if h[i] == 0:
            if x != i:
                for j in range(x,i):
                    h[j] -= 1
                p += 1
                x = i + 1
            else:
                x += 1     
    if h[-1] != 0:
        for i in range(x,n):
            h[i] -= 1
        p += 1
print(p)

Measured memory_bytes: 9208
def solve(n):
    for i in range(n+2):
        if (i+1)*i//2 > n:
            return i-1

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])


    return arr



N = int(input())
li = factorization(N)
ans = 0
for [a,b] in li:
    ans += solve(b)
    
if ans == 0:
    if N != 1:
        ans += 1
print(ans)

Measured memory_bytes: 63328
# なんだか釈然としていないが解説の通りに
from collections import deque
import sys

def MI(): return map(int, sys.stdin.readline().split())

class water:
    def __init__(self, t, v):
        self.v = v
        self.tv = v * t

    def __le__(self, other):
        return self.v * other.tv - self.tv * other.v >= 0

    def __isub__(self, other):
        t = self.tv / self.v
        self.v -= other
        self.tv = t * self.v
        return self

    def __iadd__(self, other):
        self.v+=other.v
        self.tv+=other.tv
        return self

def main():
    n, l = MI()
    dam = deque()
    t, v = MI()
    print(t)
    dam.append(water(t, v))
    # stvはtvの合計（vがlのときのvt）
    stv = t * v
    for _ in range(n-1):
        t, v = MI()
        # 朝に水をもらう
        dam.appendleft(water(t, v))
        over = v
        stv += t * v
        # 増えた分の水を古い方から捨てる
        # ベクトルごと削除できるもの
        while dam[-1].v <= over:
            w = dam.pop()
            over -= w.v
            stv -= w.tv
        # 最後のはみ出しているベクトルは縮める
        stv -= dam[-1].tv  # 一度合計から取り出して
        dam[-1] -= over  # 縮めて
        stv += dam[-1].tv  # 元に戻す
        # その日の水温を出力
        print(stv / l)
        # グラフの左側が凹んでいたらベクトルを合成して凸に直す
        while len(dam)>1 and dam[0] <= dam[1]:
            w = dam.popleft()
            dam[0] += w

main()


Measured memory_bytes: 131416
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    ll res = 0;
    REP(i, N - 1) {
        if (A[i + 1] < A[i]) {
            res += A[i] - A[i + 1];
            A[i + 1] = A[i];
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	
	const float t1 = 0.08;
	const float t2 = 0.1;

	int ans = -1;
	for (int i = 0; i < 1100; i++) {
		int a = i * t1;
		if (a == A) {
			for (int j = i; j < 1100; j++) {
				a = j * t1;
				int b = j * t2;
				if (a != A) break;
				if (a == A && b == B) {
					ans = j;
					break;
				}
			}
		}

		if (ans != -1) break;
	}

	cout << ans << endl;

	return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll x; cin >> x;
  ll k; cin >> k;
  ll d; cin >> d;
  x = abs(x);

  ll a = x/d;
  if (a >= k) {
    cout << x-k*d << endl;
    return 0;
  }
  k -= a;
  if (k%2 == 1) a++;
  x -= a*d;
  cout << abs(x) << endl;

  return 0;
}


Measured memory_bytes: 3636
//Aizu - 0033 : Ball

#include<stdio.h>
int ball[15];
int main()
{
	int n,i,l,r,flag;
	scanf("%d",&n);
	while(n--)
	{
		l=0;
		r=0;
		flag=0;
		for(i=1;i<=10;i++)
		{
			scanf("%d",&ball[i]);
		}
		for(i=1;i<=10;i++)
		{
			if(ball[i]>l)
			{
				l=ball[i];		
				continue;
			}
			else if(ball[i]>r)
			{
				r=ball[i];
				continue;
			}
			else		//else if(ball[i]<l&&ball[i]<r)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			printf("YES\n");
		}
		else			//else if(flag==1)
		{
			printf("NO\n");
		}
	}
	return 0;
} 

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(){

	string str;
	cin>>str;
	int num=0;
	cin>>num;
	set<string> s;
	int size = str.size();

	for(int i=0;i<size;i++){
		for(int j=1;j<=5;j++){
			s.insert(str.substr(i,j));
		}
	}

	int cnt=0;
	for(auto itr = s.begin();itr != s.end();++itr){
		cnt++;
		if(cnt==num){
			cout<<*itr<<endl;
		}
		if(cnt>=10)break;
	}

	return 0;

}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,a[10000000],sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(i+1==a[a[i]-1]) sum++;
  }
  cout<<sum/2<<"\n";
}

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

int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<s.size()-1;i+=2){
		//cout<<s.substr(0,(i+1)/2)<<" "<<s.substr((i+1)/2,i-i/2)<<endl;
		if(s.substr(0,(i+1)/2)==s.substr((i+1)/2,i-i/2)){
			ans=max(ans,i+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<vector<int> > a(61, vector<int>(2));
    rep(i, n) {
        ll b;
        cin >> b;
        rep(j, 61) {
            ++a[j][b % 2];
            b /= 2;
        }
    }
    
    ll ans = 0;
    rep(i, 61) {
        (ans += (1LL << i) % mod * a[i][0] % mod * a[i][1] % mod) %= mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		sc.close();
		double right = 2 * Math.PI;
		double left = 0.0;
		for(int i = 1;i <= 100000;i++) {
			double mid = (right + left) / 2.0;
			if(function(a,b,mid) < x) {
				right = mid;
			}else {
				left = mid;
			}
		}
		System.out.println(right / Math.PI * 180);
	}

	private static double function(double a, double b, double theta) {
		if(theta > Math.PI/2.0 - 0.0000000001) {
			return 0.0;
		}
		double res = 0.0;
		if(a * Math.tan(theta) <= b) {
			BigDecimal tan = new BigDecimal(a*a*b - (a*a*a*Math.tan(theta)/2.0));
			res = tan.doubleValue();
		}else {
			BigDecimal tan = new BigDecimal(b * b / Math.tan(theta) * a / 2.0);
			res = tan.doubleValue();
		}
		return res;
	}
}

Measured memory_bytes: 94996
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < K;i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        int min = 0;
        for(int i = 0;i < N;i++){
            min += list.get(i);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 38896
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 998244353

int N;
string S;
map<int, ll> divi;
ll two_pow[1<<20];

bool odd(int i) {
  return i % 2;
}

bool greaterEqual(const string &S, const int &key) {
  for(int i = 0;i < N;i++) {
    int val1 = (S[i] == '1');
    int val2 = (S[i % key] == '1');
    if(odd(i/key)) val2 = !val2;

    if(val2 > val1) return false;
    if(val1 > val2) return true;
  }
  return true;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> N >> S;

  for(int i = 1;i*i <= N;i++) {
    if(i*i == N) {
      if(odd(i)) divi[i] = 0;
      continue;
    }

    if((N % i) == 0) {
      if(odd(i)) divi[N/i] = 0;
      if(odd(N/i)) divi[i] = 0;
    }
  }

  two_pow[0] = 1;
  for(int i = 1;i <= N;i++) two_pow[i] = (two_pow[i-1]*2) % mod;

  ll ans = 0;
  for(auto it = divi.begin();it != divi.end();it++) {
    int key = it->first;
    if(greaterEqual(S, key)) divi[key]++;
    // debug(divi[key]);
    for(int j = 0;j < key;j++) {
      if(S[key-1-j] == '1') divi[key] = (divi[key] + two_pow[j]) % mod;
    }

    for(auto sit = divi.begin();sit != it;sit++) {
      int key_p = sit->first;
      if(key % key_p == 0) {
        divi[key] = (divi[key] - divi[key_p] + mod) % mod;
      }
    }

    ll tans = (2*key*divi[key])%mod;
    ans = (ans+tans)%mod;

    // debug(key);
    // debug(divi[key]);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int n,d,x,a,s,j,cnt=0;;
	cin>>n>>d>>x;
	
	for(int i=0;i<n;i++){
		cin>>a;
		j=0;
		s=0;
		while(1){
			if(s>d) {
				break;
				cnt-=1;
			}
			s=1+j*a;
			cnt++;
			j++;
		}
	}
	cout<<cnt+x-n<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int, int> > vp;
	int n = N;
	if (N % 2 == 0)n++;
	for (int i = 1; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (i + j != n) {
				vp.emplace_back(i, j);
			}
		}
	}
	cout << vp.size() << endl;
	for (int i = 0; i < vp.size(); i++) {
		cout << vp[i].first << " " << vp[i].second << endl;
	}
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAXN 100005

int N;
int v[MAXN];
int c1[MAXN];
int c2[MAXN];
int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &v[i]);

	for (int i = 0; i < N; i += 2) c1[v[i]]++;
	for (int i = 1; i < N; i += 2) c2[v[i]]++;

	int x1 = 0, x2 = 0, y1 = 0, y2 = 0;
	for (int i = 0; i < MAXN; i++)
	{
		if (c1[x1] < c1[i]) x1 = i;
		if (c2[y1] < c2[i]) y1 = i;
	}
	for (int i = 0; i < MAXN; i++)
	{
		if (x1 != i && c1[x2] < c1[i]) x2 = i;
		if (y1 != i && c2[y2] < c2[i]) y2 = i;
	}

	if (x1 != y1) printf("%d", N - c1[x1] - c2[y1]);
	else
	{
		if (c1[x1] + c2[y2] < c1[x2] + c2[y1])
			printf("%d", N - c1[x2] - c2[y1]);
		else
			printf("%d", N - c1[x1] - c2[y2]);
	}

	return 0;
}

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

#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())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll n;
    
    cin >> n;
  	
    ll mx = 0;
  	for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            mx = i;
        }
    }
    cout << (mx-1)+((n/mx)-1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int i,j,data[10],num;
	for(i = 0;i <= 9;i++){
		scanf("%d",&num);
		data[i] = num;
	}
	for(i = 0;i <= 9;i++){
		for(j = i;j <= 9;j++){
			if(data[i] < data[j]){
				num = data[i];
				data[i] = data[j];
				data[j] = num;
			}
		}
	}
	for(i = 0;i <= 2;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+6;
int a[maxn];
int main()
{
	int n,k,q,x;
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%d",&x);
		a[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(q-a[i]<k)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
#define int long long
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}


signed main(){
unordered_map<int,int> m;
for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
        for(int k=1;k<=100;k++){
            int ans=i*i+j*j+k*k+i*j+i*k+j*k;
            m[ans]++;

        }
    }
}
int n;
cin>>n;
FOR1(i,1,n+1){
out(m[i]);}
}


Measured memory_bytes: 4996
#include <stdio.h>

int main()
{
    int k,a,b;
    int temp;
    
    scanf("%d %d %d",&k,&a,&b);
    
    if(a%k==0){
        printf("OK");
    }else{
        temp = a-a%k+k;
        if(temp<=b) printf("OK");
        else printf("NG");
    }

    return 0;
}


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

using ll = long long;

string N;
int K;

vector<vector<ll>> dp0(101 + 1, vector<ll>(3 + 1, 0));

vector<vector<ll>> dp1(101 + 1, vector<ll>(3 + 1, 0));

void solve(){
    int L = N.size();
    for(int i = 0; i < L; ++i){
        dp1[i][0] = 1;
    }
    dp1[L][0] = 0;
    for(int i = 1; i <= L; ++i){
        for(int j = 0; j <= K; ++j){
            ll a = (ll)(N[i - 1] - '0');

            ll _dp0 = dp0[i - 1][j];
            if(j > 0) _dp0 += 9 * dp0[i - 1][j - 1];
            if(a > 1 && j > 0) _dp0 += (a - 1) * dp1[i - 1][j - 1];
            if(a > 0) _dp0 += dp1[i - 1][j];

            ll _dp1 = 0;
            if(a == 0) _dp1 += dp1[i - 1][j];
            else if(j > 0) _dp1 += dp1[i - 1][j - 1];

            dp0[i][j] = _dp0;
            dp1[i][j] = _dp1;
        }
    }
    cout << dp0[L][K] + dp1[L][K];
}

int main(){
    cin >> N >> K;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			int[] p = new int[n];
			
			for(int i = 0 ; i < n ; i++ ) {
				p[i] = sc.nextInt();
			}
			
			int count = 0;
			for(int i = 0 ; i < n ; i++ ) {
				if ( (i+1) == p[i] ) {
					//OK
				}
				else {
					count++;
				}
			}
			
			if ( count < 3 ) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
			
		}
	}
}

Measured memory_bytes: 21716
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
num = 0
dif = 10000000

for n in range(N):
  C = T-H[n]*0.006
  if dif > abs(A-C):
    dif = abs(A-C)
    num = n+1
    
print(num)

Measured memory_bytes: 9204
#include <stdio.h>
int main(void){
	int n, key;
	scanf("%d",&n);
	key = n / 100;
	key = key*100 + key*10 + key;
	if(key >= n){
		printf("%d\n",key);
	}else{
		printf("%d\n",key+111);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>

#define fin cin

using namespace std;

int n = 0, m = 0;
vector<int> h;
vector<int> w;

template<typename Vec>
void push_sum(Vec &v, int size)
{
    for(unsigned i = 0; i < size; i++){
        int num = v[i];

        unsigned sub = i + 1;
        while(sub < size)
        {
            num += v[sub];
            v.push_back(num);
            sub++;
        }
    }
}

int main()
{
//    ifstream fin("in.txt");

    while(fin >> n >> m, n | m)
    {

        h.clear();
        w.clear();

        h.shrink_to_fit();
        w.shrink_to_fit();

        

        int tmp = 0;
        for(int i = 0; i < n; i++)
        {
            fin >> tmp;
            h.push_back(tmp);
        }
        for(int i = 0; i < m; i++)
        {
            fin >> tmp;
            w.push_back(tmp);
        }

        push_sum(h, n);
        push_sum(w, m);


        int ans = 0;
        short h_val[1000 * 1500 + 1] = {};
        short w_val[1000 * 1500 + 1] = {};

        //sort(h.begin(), h.end());
        //sort(w.begin(), w.end());

        for(unsigned i = 0; i < h.size(); i++)
        {
            h_val[(h[i])]++;
        }
        for(unsigned i = 0; i < w.size(); i++)
        {
            w_val[(w[i])]++;
        }
        for(int i = 0; i < 1000 * 1500 + 1; i++)
        {
            ans += (h_val[i] * w_val[i]);
        }
        

        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 25564
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(void){
	char s[100100],c;
	int n,g=0,p=0,ans=0,i;
	cin >> s;
	n = strlen(s);
	for(i=0; i<n; i++){
		c = s[i];
		if(c=='g'){
			if(g>p){
				p++;
				ans++;
			}else{
				g++;
			}
		}else if(c=='p'){
			if(g>p){
				p++;
			}else{
				g++;
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N / 1000 == N % 1000 / 100 && N % 1000 / 100 == N % 100 / 10) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 / 100 == N % 100 / 10 && N % 100 / 10 == N % 10) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  // ここにプログラムを追記
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    s += '#';

    int N = s.size();
    int ans = 0, cons = 0;
    for(int i=0; i<N; i++) {
        string pat = "ATGC";
        if(pat.find(s[i]) != string::npos) {
            cons++;
        }
        else {
            ans = max(ans, cons);
            cons = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n, m;
    std::cin >> n >> m;

    std::multimap<long, long> stores;
    for(int i = 0; i < n; ++i){
        long a, b;
        std::cin >> a >> b;
        stores.insert(std::make_pair(a, b));
    }

    std::multimap<long, long>::iterator itr = stores.begin();
    long sum = 0, amount = 0;
    while(sum < m){
        while(sum < m && 0 < itr->second){
            ++sum;
            amount += itr->first;
            --(itr->second);
        }
        ++itr;
    }

    std::cout << amount << std::endl;

    return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n) for(int i=a;i<n;i++)
#define REP(i, n) F(i, 0, n)
#define REP1(i, n) for(int i=1;i<=n;i++)
#define REV(i, n) for(int i=n;i>=0;i--)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef long long ll;

const ll MAX = 1e6 + 5;

int n,q,x;
map<int,int> a;
ll k,score[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>k>>q;
	ll t = k-q;
	REP1(i, n){
		score[i] = t;
	}
	REP1(i, q){
		cin>>x;
		a[x]++;
	}
	REP1(i, n){
		score[i] += a[i];
		if(score[i] <= 0)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 6144