akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

    ll n;
    cin >> n;
    

    bool b[10000]={};
    for(ll i=0;i<=25;i++){
        for(ll j=0;j<=15;j++)b[4*i+7*j]=1;
    }
    if(b[n])cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3520
# 桁DPの解説
# http://pekempey.hatenablog.com/entry/2015/12/09/000603
# http://torus711.hatenablog.com/entry/20150423/1429794075
# 桁DPの問題まとめ
# http://hamayanhamayan.hatenablog.jp/entry/2017/04/23/212728
# まとめ
# https://qiita.com/259_Momone/items/86e90d17e4efe3b22433
# ちょっと違う解法
# http://beet-aizu.hatenablog.com/entry/2017/01/12/164738

n = gets.to_i
a = n.to_s(2).split("").map(&:to_i) #dpのiにあたる配列
result = 0 #結果
mod = 10**9+7
dp = Array.new(a.size+1, Array.new(3,0))#dpするやつ
dp.unshift([1,0,0])
# p dp, a, a.size
for i in 1..a.size
	if a[i-1] == 0
		dp[i][2] = (3*dp[i-1][2] + dp[i-1][1]) % mod
		dp[i][1] = dp[i-1][1]
		dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod
	else
		dp[i][2] = ( (3*dp[i-1][2]) + (dp[i-1][1]*2) ) % mod
		dp[i][1] = (dp[i-1][1] + dp[i-1][0]) % mod
		dp[i][0] = dp[i-1][0]
	end
end
# p dp
result = dp[-1][0..2].reduce(:+) % mod
puts result


Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
using namespace std;
int main(){
long long n;
cin >>n;
long long t[n],x[n],y[n];
for(long long i=0;i<n;i++){
cin >>t[i]>>x[i]>>y[i];
}
long long countx,county,sum,time,check;
time=t[0];
countx=abs(x[0]-0);
county=abs(y[0]-0);
sum=countx+county;
bool flag=true;
check=time-sum;
if(check<0){
flag=false;
}
else if((check%2)==1){
flag=false;
}
for(long long i=1;i<n;i++){
time=t[i]-t[i-1];
countx=abs(x[i]-x[i-1]);
county=abs(y[i]-y[i-1]);
sum=countx+county;
check=time-sum;
if(check<0){
flag=false;
break;
}
else if((check%2)==1){
flag=false;
break;
}
}
if(flag)
cout <<"Yes";
else
cout<<"No";
return 0;

}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct union_find{
    VI par, sz, data;

    void init(int n){
        sz.assign(n, 1);
        data.assign(n, 1);
        par.resize(n);
        REP(i,n) par[i] = i;
    }

    int find(int x){
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y){
            data[x] = 0;
        }else{
            sz[y] += sz[x];
            par[x] = y;
            data[y] &= data[x];
        }
    }

    bool is_tree(int x){
        return data[find(x)];
    }
};

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    vector<pair<ll, P>> p(n);
    REP(i,n){
        p[i].second.first = in() - 1;
        p[i].second.second = in() - 1;
        p[i].first = in();
    }
    sort(ALL(p));
    reverse(ALL(p));
    union_find uf;
    uf.init(h + w);
    ll ans = 0;
    for (auto tmp : p){
        ll x = tmp.first;
        int r = tmp.second.first;
        int c = tmp.second.second;
        c += h;
        if (uf.is_tree(r) || uf.is_tree(c)){
            ans += x;
            uf.merge(r, c);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
// AtCoder Beginner Contest 126 - Problem E: 1 ou 2 (https://atcoder.jp/contests/abc126/tasks/abc126_e)
#include <bits/stdc++.h>

using namespace std;
using ii = pair<int, int>;

class UFDS
{
private:
    std::vector<int> size, ps;
    int count;

public:
    UFDS(int N) : size(N + 1, 1), ps(N + 1), count(N)
    {
        std::iota(ps.begin(), ps.end(), 0);
    }

    int find_set(int x) 
    {
        return x == ps[x] ? x : (ps[x] = find_set(ps[x]));
    }

    bool same_set(int x, int y)
    {
        return find_set(x) == find_set(y);        
    }

    void union_set(int x, int y)
    {
        if (same_set(x, y))
            return;

        int p = find_set(x);
        int q = find_set(y);

        if (size[p] < size[q])
            std::swap(p, q);

        ps[q] = p;
        size[p] += size[q];
        --count;
    }

    int get_count() const { return count; }
};

int solve(int N, const vector<ii>& es)
{
    UFDS ufds(N);

    for (auto p : es)
    {
        auto x = p.first, y = p.second;

        ufds.union_set(x, y);
    }

    return ufds.get_count();
}

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

    int N, M;
    cin >> N >> M;

    vector<ii> es(M);

    for (int i = 0; i < M; ++i)
    {
        int x, y, z;
        cin >> x >> y >> z;

        es.push_back(ii(x, y));
    }

    cout << solve(N, es) << endl;

    return 0;
}


Measured memory_bytes: 2672
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map(String::toInt).sorted()

    var result = 0

    for (i in 0 until n - 2) {
        for (j in i + 1 until n - 1) {
            val max = l[i] + l[j]

            for (k in j + 1 until n) {
                if (l[k] < max) result ++
                else break
            }
        }
    }

    println(result)
}

Measured memory_bytes: 48424
import itertools
n,m,q = map(int,input().split())
target = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
  count = sum([abcd[3] for abcd in target if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]])
  ans = max(ans,count)
print(ans)

Measured memory_bytes: 9144
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main () {
    int n = 0, d = 0;
    cin >> n >> d;
    vector<vector<int>> in(n, vector<int> (d));
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            cin >> in.at(i).at(j);
        }
    }
    int count = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            int sum = 0;
            for (int k=0; k<d; k++) {
                sum += pow(in.at(i).at(k) - in.at(j).at(k), 2);
            }
            if (sqrt(sum) == (int)sqrt(sum)) count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int x;
  rep(i,5){
    cin>>x;
    if(x==0){
      cout<<i+1<<endl;
    }
  }
  
}
  

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<char> > a(n + 1, vector<char>(m + 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    vector<vll> dp(n + 1, vll(m + 1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) {
                dp[i][j] = 1;
                continue;
            } 
            if (a[i][j] == '#') {
                continue;
            }
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     for (int j = 1; j <= m; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][m];
}

int main() {
    #ifdef DEBUG
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() << " ms.\n";
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define AC 0
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	cout<<((n+x-1)/x*t)<<endl;
	return AC;
}


Measured memory_bytes: 3664
import sys
import math

S = list(str(input()))
T = list(str(input()))

if len(S) == len(T):
    ans = len(T)
    change = 0
    for j in range(len(T)):
        if T[j] != S[j]:
            change += 1
    ans = min(ans, change)
else:
    ans = len(T)
    for i in range(len(S) - len(T)):
        change = 0
        for j in range(len(T)):
            # print(f'i {i}, j {j}')
            if T[j] != S[i + j]:
                change += 1
    
        ans = min(ans, change)

print(ans)




Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,a,b;
  cin>>n>>a>>b;
  ll t=n%(a+b),q=n/(a+b);
  if(a==0)
    cout<<0;
  else
    cout<<a*q+min(t,a);
}

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

#define SIZE 100005
#define PI acosl(-1) //3.14159265358979323846264338327950L 
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?

typedef long long ll; typedef long double ld;
typedef struct node { int data; struct node *next; } Node;

Node *list[SIZE];
int queue[SIZE]; int q_head = 0, q_tail = 0;

void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)
void printl_int(int size); //リンクリストを出力(for debug)
Node* add_node(int i, int data); void free_list(Node* head);
int queue_empty(); int queue_full();
void enqueue(int data); int dequeue();

int main() {
    int i, N;
    scanf("%d", &N);
    ll *A = array(N, ll);
    rep(i, N) {
        scanf("%lld", A + i);
        if (!A[i]) {
            printf("0\n");
            return 0;
        }
    }
    ll ans = 1, temp = 1;
    rep(i, N) {
        ans *= A[i];
        if (ans > 1000000000000000000LL || ans < temp) {
            printf("-1\n");
            return 0;
        }
        temp = ans;
    }
    printf("%lld\n", ans);
    return 0;
}

void print_log() {
    printf("=== print log ===\n");
}
void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}
void printl_int(int size) {
    int i;
    Node *t;
    rep(i, size) {
        printf("[%d] ", i);
        for (t = list[i]; t; t = t->next) printf("%d, ", t->data);
        printf("\n");
    }
}
Node* add_node(int i, int data) {
    if (!list[i]) {
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
    } else {
        Node *t;
        t = list[i];
        list[i] = (Node*)malloc(sizeof(Node*));
        list[i]->data = data;
        list[i]->next = t;
    }
    return list[i];
}
void free_list(Node* head) {
    Node *prev = NULL, *t = head;
    while (t) {
        prev = t;
        t = t->next;
        free(prev);
    }
}
int queue_empty() {
    return q_head == q_tail;
}
int queue_full() {
    return (q_head - 1) % SIZE == q_tail % SIZE;
}
void enqueue(int data) {
    if (queue_full()) {
        printf("full!\n");
        return;
    }
    queue[q_tail++] = data;
    q_tail %= SIZE;
}
int dequeue() {
    if (queue_empty()) {
        printf("empty!\n");
        return -444444;
    }
    int data = queue[q_head++];
    q_head %= SIZE;
    return data;
}

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

typedef long long int ll;
const int N = 1e6+6;

int main()
{
    ll n;cin>>n;
    ll mn = 1e9;
    for(int i=1;i<n;i++)
    {
        ll a = n-i;
        ll b = i;
        ll now = 0;
        while(a)now+=(a%10),a/=10;
        while(b)now+=(b%10),b/=10;
        mn = min(mn,now);
    }
    cout<<mn<< "\n";


    return 0;
}


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

int main(){
  int N,A,B,Max,Min;
  cin >>N>>A>>B;
  
  if (A<=B){
    Max = A;
  }
  else{
    Max= B;
  }
  
  if(A+B>N){
    Min = A + B - N;
  }
  else{
    Min = 0;
  }
  cout <<Max<<" "<<Min;
}
  
  

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    unordered_map<ll, int> m;
    rep(i, N){
        ll d; cin >> d;
        m[d]++;
    }
    int M; cin >> M;
    rep(i, M){
        ll t; cin >> t;
        m[t]--;
    }
    for(auto a: m){
        if(a.second < 0){
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 12616
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(string& s) {
        int n = s.length();
        const long long MOD = 1e9 + 7;

        const int N = 13;
        vector<long long> dp(N, 0);
        vector<long long> ndp(dp);
        dp[0] = 1;

        for (int i = 0; i < n; ++i) {
            fill(ndp.begin(), ndp.end(), 0);
            for (int j = 0; j < N; ++j) {
                int l = 0;
                int r = 9;
                if (s[i] != '?') {
                    l = r = s[i] - '0';
                }

                for (int k = l; k <= r; ++k) {
                    int nj = (j * 10 + k) % N;
                    (ndp[nj] += dp[j]) %= MOD;
                }
            }
            swap(ndp, dp);
        }
        return dp[5];
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        while (d--) {
            int x;
            cin >> x;
            a[x - 1] = 1;
        }
    }

    cout << n -  accumulate(a.begin(), a.end(), 0) << "\n";
}

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

    int t = 1;
//    cin >> t;
    while (t--) {
       one_case();
    }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

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

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

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, k;

    cin >> n >> k;

    ll res = 0;

    for (int i = k + 1; i <= n; i++)
    {
        ll sum = 0;

        ll num = i - k;

        sum += ((n - (i - 1)) / i + 1) * num;

        int ma = (n - (i - 1)) / i;

        /*
        int l = k - 1, r = i;

        while (r - l > 1)
        {
            int mid = (l + r) / 2;

            if (mid + i * (ma + 1) > n)
                r = mid;
            else
                l = mid;
        }

        if (r - l)
            sum += l - k + 1;
            */

        if ((ma + 1) * i + k <= n)
            sum += max(0, (n % i) - k + 1);

        if (k == 0)
            sum--;

        res += sum;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[10],b=0,c;
for(int i=0;i<10;i++){
scanf("%d",&a[i]);
}
for(int i=0;i<3;i++){
for(int j=0;j<10;j++){
if(a[j]>b){
b=a[j];
c=j;
}
}
printf("%d\n",b);
b=0;
a[c]=0;
}
return 0;
}

Measured memory_bytes: 1028
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 210000;

vector<tuple<ll, ll, ll>> vv;

int n;
ll x;

ll sma;

ll get(tuple<ll, ll, ll> a) {
	ll b, l, u;
	tie(b, l, u) = a;
	return b * l + (x - b) * u;
}

ll sm[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		ll b, l, u;
		cin >> b >> l >> u;
		sma += b * l;
		vv.emplace_back(b, l, u);
	}
	sort(ALL(vv), [] (tuple<ll, ll, ll> a, tuple<ll, ll, ll> b) -> bool {
				return get(a) > get(b);
			});
	for (int i = 0; i < n; ++i)
		sm[i + 1] = sm[i] + get(vv[i]);
	ll l = -1;
	ll r = x * n;
	while (r - l > 1) {
		ll m = (l + r) >> 1;
		ll ans = 0;
		int go = min(ll(n) - 1, m / x);
		for (int i = 0; i < n; ++i) {
			ll now = sm[go];
			if (i < go)
				now = sm[go + 1] - get(vv[i]);
			ll lf = m - go * x;
			ll b, l, u;
			tie(b, l, u) = vv[i];
			now += l * min(b, lf);
			if (lf > b)
				now += (lf - b) * u;
			ans = max(ans, now);
		}
		if (ans >= sma)
			r = m;
		else
			l = m;
	}
	cout << r << "\n";
	return 0;
}




Measured memory_bytes: 4956
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <array>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int n,k;
int p[5000], c[5000];

int main() {
	//freopen("test.in","r",stdin);
	cin >> n >> k;
	REP (i,n) {
		scanf("%d",&p[i]); p[i]--;
	}
	REP (i,n) {
		scanf("%d",&c[i]);
	}
	int64 best=c[0];
	REP (i,n) {
		int j=i;
		int64 s=0;
		int m=0;
		//printf("i=%d\n",i);
		while (m<k) {
			m++;
			s+=c[j];
			if (s>best) best=s;
			//printf("%d : %I64d\n",j,s);
			j=p[j];
			if (j==i) {
				int64 r=max(0, (k-m)/m-1);
				m+=r*m;
				s+=r*s;
				if (s>best) best=s;
			}
		}
	}
	cout << best << endl;
	return 0;
}


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

using namespace std;

int main(){
  int A,B,C,D,N,i;
  char S[222222];
  int free[222222] = {0};
  int rock[222222] = {0};
  cin >> N >> A >> B >> C >> D;
  cin >> S;
  A--;
  B--;
  C--;
  D--;

  if(S[0] == '.')
    while(S[free[0]] == '.')
      free[0]++;
  if(S[0] == '#')
    while(S[rock[0]] == '#')
      rock[0]++;
  for(i=1;i<=N-1;i++){
    if(S[i] == '.' && S[i-1] == '#'){
      while(S[i+free[i]] == '.')
        free[i]++;
    };
    if(S[i] == '#' && S[i-1] == '.'){
      while(S[i+rock[i]] == '#')
        rock[i]++;
    };
  }
  for(i=A;i<max(C,D);i++)
    if(rock[i] >= 2){
      cout << "No" << endl;
      goto END;
    }
  if(C<D) {cout << "Yes" <<endl; goto END;};
  if(C>D){
    for(i=B-1;i<=D-1;i++)
      if(free[i] >= 3){
        cout << "Yes" << endl;
        goto END;
        };
    cout << "No" << endl;
  }
  END:;
}

Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
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; }

using namespace std;

int main(void)
{
    lli X; cin >> X;
    lli sum = 100;
    lli ans = 0;

    while (sum < X) {
        ans++;
        sum = sum + sum / 100;;
    }
    cout << ans << endl;


    return 0;
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a, b;
	cin >> a >> b;

	if(a+b >= 10)
		cout << "error" << endl;
	else
		cout << a+b << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;




int main(){
    int N;cin >> N;
    int ans=100;
    for (int i = 0; i < N; i++) {
        int a;cin >> a;
        int t=0;
        while(a%2==0){
            t++;
            a/=2;
        }
        ans=min(ans,t);
    }
    cout << ans << endl;
    return 0;
}



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

int main(){

    int N, M, p[1011];

    while(cin >> N >> M, N){
        vector <int> sum;
        p[0] = 0;
        for(int i = 1; i <= N; i++) cin >> p[i];
    
        for(int i = 0; i <= N; i++){
            for(int j  = 0; j <= N; j++){
                sum.push_back(p[i] + p[j]);
            }
        }
    
        sort(sum.begin(), sum.end());
        int res = 0;
        for(int i = 0; i  < sum.size() && sum[i] <= M; i++){
            vector <int>::iterator it = lower_bound(sum.begin(), sum.end(), M - sum[i]);
            res = max(res, sum[i] + *(it - 1));
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 9188
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;

#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int w, a;
    cin >> w >> a;
    cout << max(0, w - 2*a) << "\n"   ; 
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import  math

def solve(N: int):
    print(math.ceil(N / 2))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << double(w) * double(h) / 2 << " " << ( x + x == w && y + y == h) << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v = {a, b, c};
    sort(v.begin(), v.end());
    cout << (v[1] == c ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    while(cin>>n)
    {
        ll sum=0;
        ll x=n/500;
        ll r=n%500;
        ll y=r/5;
        cout<<x*1000+y*5<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string str;
    int cnt = 0;
    while (cin >> str) {
        for (const char &c : str)
            cnt += c == 'A';
        cout << (cnt != 0 && cnt != str.size() ? "Yes" : "No") << '\n';
    }
}

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

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll MOD = 1e9+7;

int main(){

    int N;
    cin >> N;

    ll Amin,Bmin = 1e9+1 ,A,B;

    rep(i,0,N){
        cin >> A >> B;
        if (Bmin > B){
            Amin = A;
            Bmin = B;
        }
    }

    cout <<( Amin + Bmin )<< endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = str(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    print(n.count(str(1)))


resolve()


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {

	FAST;

	string s;
	cin >> s;
	s[3] = '8';
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  string s;
  cin>>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
  {
    cout<<"Bad"<<endl;
  }
else{
cout<<"Good"<<endl;
}
  
  
  
 return 0; 
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.StringBuffer;
import java.lang.System;
import java.util.Scanner;

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

        while (sc.hasNext()) {
            int goal = sc.nextInt();
            String binary = Integer.toBinaryString(goal);
            String reverse = new StringBuffer(binary).reverse().toString();

            String res = "";
            for (int i = 0; i < reverse.length(); i++) {
                if (reverse.charAt(i) == '1') {
                    res += kai2(i) + " ";
                }
            }
            System.out.println(res.trim());
        }
    }

    // 2の階乗を求める
    public static int kai2(int i) {
        int res = 1;
        for (int j = 0; j < i; j++) {
            res *= 2;
        }
        return res;
    }
}

Measured memory_bytes: 17220
<?php
    $student = array();
    for($i = 0; $i < 28; $i++)  {
        $students[] = trim(fgets(STDIN));
    }
    $all_students = range(1, 30);
    $not_submitter = array_diff($all_students, $students);
    sort($not_submitter);
    echo implode("\n", $not_submitter). PHP_EOL;
    


Measured memory_bytes: 9256
a,b,c,d = [int(i) for i in input()]
if a+b+c+d == 7:
  ans = [str(a),'+',str(b),'+',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()
if a+b+c-d == 7:
  ans = [str(a),'+',str(b),'+',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a+b-c-d == 7:
  ans = [str(a),'+',str(b),'-',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b-c-d == 7:
  ans = [str(a),'-',str(b),'-',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b+c-d == 7:
  ans = [str(a),'-',str(b),'+',str(c),'-',str(d),'=','7']
  print(''.join(ans))
  exit()
if a+b-c+d == 7:
  ans = [str(a),'+',str(b),'-',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b+c+d == 7:
  ans = [str(a),'-',str(b),'+',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()
if a-b-c+d == 7:
  ans = [str(a),'-',str(b),'-',str(c),'+',str(d),'=','7']
  print(''.join(ans))
  exit()

Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//方針
//dfsで
//訪れていたらused=true
//繋がってるところ全部再帰する
//その時のused=falseならok

int N,M;
bool used[64];
bool to[8][8];

int  dfs(int n, int nokori){
    used[n] = true;
    if(nokori==0) return 1;
    int ret = 0;
    FOR(i, 0, N){
        if(!to[n][i]) continue;
        if(to[n][i] && !used[i]){
            ret += dfs(i, nokori-1);
            used[i] = false;
        }
    }
    return ret;
}

int main(){
    FOR(i, 0, 8) FOR(j, 0, 8) to[i][j] = false;
    FOR(i, 0, 64) used[i] = false;
    cin>>N>>M;
    FOR(i, 0, M){
        int a,b;cin>>a>>b;
        a--;b--;
        to[a][b] = to[b][a] = true;
    }
    cout << dfs(0, N-1) << endl;
}

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

int main() {
  string S;
  cin >> S;
  int s=0;
  int sum=S.length();
  for(int i=0;i<S.length();i++){
    if(S[i]=='S')s++;
    else{
      if(s>0){
        s--;
        sum-=2;
      }
    }
    cerr << sum;
  }
  cout << sum;
}

Measured memory_bytes: 640
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) cout << s << endl;
# define printStr(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

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

    max = a+b;
    if(max < a-b) max = a-b;
    if(max < a*b) max = a*b;

    p(max)

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K = inputIL()

sum = 0

for s in range(K,N+2):
  sum = ( sum + ((2*N-s+1)*s-(s-1)*s)//2+1 )%MOD
  
print(sum)

Measured memory_bytes: 72896
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	string S;

	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else if (S == "Rainy") {
		cout << "Sunny" << endl;
	}

	return 0;
}

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

int main(void)
{
    ll N, D;
    cin >> N >> D;
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }
    ll d2 = D* D;
    ll cnt = 0;
    for (int i = 0; i < N; i++)
    {
        ll val = x[i] * x[i] + y[i] * y[i];
        if(val <= d2){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 6372
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

string S;
void input()
{
    cin>>S;
}

void solve()
{
    string ans="Yes";
    if(S=="AAA" || S=="BBB") ans="No";
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);




	int n,m; cin>>n>>m;
	int su = 0;
	for(int i=0;i<m;i++){
		int x; cin>>x;
		su += x;
	}
	if (su<=n) cout<<n-su;
	else cout<<-1;

	return 0;
}

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

int main(){
    int n, m, p = 0;
    map<int, int> q;
    cin >> n >> m;

    ++q[0];
    for(int i=1; i<=n; ++i){
        int w; cin >> w;
        p = (p + w%m)%m;
        ++q[p];
    }

    long long ans=0;
    for(auto itr = q.begin(); itr != q.end(); ++itr){
        ans += (long long)itr->second*(itr->second - 1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int s=0;s<=a;s++)
	{
		for(int v=0;v<=b;v++)
		{
			if(c==s*b+v*a-2*s*v)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
ll bit[4][N];
void add(int id,int idx, ll val){
	if(id%2){
		for(int i=idx;i>=1;i-=(i&-i)){
			bit[id][i]+=val;
		}
	}
	else{
		for(int i=idx;i<N;i+=(i&-i)){
			bit[id][i]+=val;
		}
	}
}
ll get(int id, int idx){
	if(idx==0 and id%2)return 0;
	ll ret = 0;
	if(id%2==0){
		for(int i=idx;i>=1;i-=(i&-i)){
			ret+=bit[id][i];
		}
	}
	else{
		for(int i=idx;i<N;i+=(i&-i)){
			ret+=bit[id][i];
		}
	}
	return ret;
}
int m,n;
int bs(){
	int st = 1;
	int en = N-1;
	while(st<=en){
		int mid = (st+en)/2;
		if(get(0,mid)>=(m+1)/2){
			en = mid-1;
		}
		else{
			st = mid+1;
		}
	}
	return st;/// to check
}
vector<vector<int> > qry;
int cd[N];
ll dc[N];
void solve(){
	int q; 
	cin>>q; 
	vector<pair<int,int> >v; 
	for(int i=1;i<=q;i++){
		int t;
		cin>>t;
		if(t==1){
			int x,y; 
			cin>>x>>y;
			qry.pb({t,x,y});
			v.pb({x,i});
		}
		else{
			assert(t==2);
			qry.pb({2});
			
		}
	}
	sort(v.begin(),v.end());
	int cnt = 1;
	int z = v.size();
	for(int i=0;i<z;i++){
		if(i==0){
			cd[v[i].sc] = cnt;
			dc[cnt] = v[i].fr;
		}
		else{
			if(v[i].fr!=v[i-1].fr){
				cnt++;
			}
			cd[v[i].sc] = cnt;
			dc[cnt] = v[i].fr;
		}
	}
	ll gy = 0;
	for(int i=1;i<=q;i++){
		int t = qry[i-1][0];
		if(t==1){
			int x = qry[i-1][1];
			int y = qry[i-1][2];
			add(0,cd[i],1);
			add(1,cd[i],1);
			add(2,cd[i],x);
			add(3,cd[i],x);
			m++;
			gy+=y;
		}
		else{
			assert(qry[i-1][0]==2);
			int mid = bs();/// I have cnt of the mid 
			ll ans = get(0,mid)*dc[mid]-get(2,mid);
			ans+= get(3,mid)-get(1,mid)*dc[mid];
			cout<<dc[mid]<<" "<<ans+gy<<endl;
		}
	}
	
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}
/// 2:3 /// 2,3
/// 1:1 /// 3,3
/// aa/bb =x/y
/// bb*x/y = aa
/// bb = aa*y/x


Measured memory_bytes: 19780
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int count(int y, int m, int d){
    int res = 0;
    res += d;
    res += (m-1) * 19;
    if(y%3){
        res += m / 2;
    }else{
        res += m - 1;
    }
    --y;
    res += y * 195;
    res += y / 3 * 5;
    return res;
}

int main(){
    int N;
    while(cin>>N&&N){
        int ans = 0;
        int rp = 1;
        int sum = 0;
        REPA(i, N){
            while(rp<=N&&sum<N){
                sum+=rp++;
            }
            if(N==sum)++ans;
            sum -= i;
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(void){
 int A1,A2,A3;
 scanf("%d %d %d",&A1,&A2,&A3);
 if(A1+A2+A3>=22){printf("bust\n");}
 else if(A1+A2+A3<=21){printf("win\n");}
 return 0;
}

Measured memory_bytes: 128
program hrn;
 var
        s:ansistring;
        i,l,s1,s2:longint;
begin
        readln(s);
        l:=length(s);
        s2:=maxlongint;
        for i:=1 to l do
        begin
                if (s[i]='F') then s1:=i;
        end;
        for i:=l downto 1 do
        begin
                if (s[i]='C') then s2:=i;
        end;
        if s2<s1 then
        begin
                writeln('Yes');
        end
        else
        begin
                writeln('No');
        end;
end.


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

using namespace std;

using ll = long long;

ll Solve() {
    ll l;
    cin >> l;

    vector<ll> a(l + 1);
    for (int i = 1; i <= l; ++i) cin >> a[i];

    constexpr int N = 5;
    vector<vector<ll>> dp(l + 1, vector<ll>(N, 1e11));
    dp[0][0] = dp[0][1] = 0;

    for (int i = 1; i <= l; ++i) {
        dp[i][0] = dp[i - 1][0] + a[i];
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1])
            + (a[i] == 0 ? 2 : (a[i] % 2 == 1));
        dp[i][2] = min({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]})
            + (a[i] == 0 ? 1 : (a[i] % 2 == 0));
        dp[i][3] = min({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2], dp[i - 1][3]})
            + (a[i] == 0 ? 2 : (a[i] % 2 == 1));
        dp[i][4] = min({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2],
                    dp[i - 1][3], dp[i - 1][4]}) + a[i];
    }

    return min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]});
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	int n, m;
	char a[50][50], b[50][50];
	bool isInclude;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%s", a[i]);
	}
	for (int i = 0; i < m; i++) {
		scanf("%s", b[i]);
	}
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			isInclude = true;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (a[i + k][j + l] != b[k][l]) {
						isInclude = false;
					}
				}
			}
			if (isInclude) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#####

import numpy as np
from numpy import newaxis, float32, float64, int32, int64, int16, int8, uint8, uint32, complex64, complex128
import itertools

#####

def getIntList(inp):
	return [int(_) for _ in inp]
	

from sys import stdin

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs

def v(on):
	for i in range(3):
		if on[i,:].all():
			return True
	for i in range(3):
		if on[:,i].all():
			return True
	
	if on[0,0] and on[1,1] and on[2,2]: return True
	if on[2,0] and on[1,1] and on[0,2]: return True
	return False

def main(inputs):
	a=np.empty((3,3),int32)
	aIndex={}
	on=np.zeros((3,3),np.bool)
	for i,j in itertools.product(range(3),range(3)):
		a[i,j]=int(inputs[i][j])
		aIndex[a[i,j]]=(i,j)
		
	n=int(inputs[3][0])
	for i in range(n):
		bi=int(inputs[i+4][0])
		if bi in aIndex:
			index=aIndex[bi]
			on[index[0],index[1]]=True
	
	vv=v(on)
	if vv: print("Yes")
	else: print("No")
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
	


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

int main() {
	int n,l;
	string s[10000];
	cin >> n >> l;
	for(int i = 0;i < n;i++) cin >> s[i];
	sort(s,s + n);
	for(int i = 0;i < n;i++) cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	string s, t;
	cin >> s >> t;
	cout << t << s;
	}

	

Measured memory_bytes: 256