akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

vvl m(105, vl(105,INF));
ll n;

ll prim(){
    ll u, minv=INF;
    vl visit(105,0);
    vl d(105,INF);
    vl p(105,-1);

    d[0] = 0;
    while(1){
        minv = INF;
        rep(i,n){
            if(d[i] < minv && visit[i] == 0){
                minv = d[i];
                u = i;
            }
        }
        if(minv == INF) break;
        visit[u] = 1;
        rep(i,n){
            if(visit[i] == 0 && m[u][i] != INF){
                if(d[i] > m[u][i]){
                    d[i] = m[u][i];
                    p[i] = u;
                }
            }
        }
    }
    ll sum=0;
    rep(i,n){
        if(p[i] != -1) sum += d[i];
    }
    return sum;
}

int main(){
    ll t;
    cin >> n;
    rep(i,n){
        rep(j,n){
            cin >> t;
            m[i][j] = (t==-1) ? INF : t;
        }
    }

    cout << prim() << "\n";

    return 0;
}



Measured memory_bytes: 3236
#include<iostream>
using namespace std;
int main() {
	int home[4][3][10] = { {{}} };
	int n,b,f,r,v,i,j,k;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		home[b - 1][f - 1][r - 1] += v;
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				cout << " " << home[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) {
			cout << "####################" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

    // bool operator==(const mint a) { return x == a.x; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll n;

int main() {
    cin >> n;
    vector<ll> tvec(n, 0);
    vector<ll> avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> tvec[i];
    for(int i = 0; i < n; ++i) cin >> avec[i];

    vector<ll> hvec(n, 0);
    vector<ll> tcvec(n, 0);
    vector<ll> acvec(n, 0);
    tcvec[0] = tvec[0];
    acvec[n-1] = avec[n-1];
    for(int i = 1; i < n; ++i) {
        if(tvec[i-1] < tvec[i]) tcvec[i] = tvec[i];
    }
    for(int i = n-2; i >= 0; --i) {
        if(avec[i] > avec[i+1]) acvec[i] = avec[i];
    }

    for(int i = 0; i < n; ++i) {
        if(tcvec[i] != 0) {
            if(acvec[i] != 0) {
                if(tcvec[i] == acvec[i]) hvec[i] = 1;
                else hvec[i] = 0;
            }else {
                if(tcvec[i] <= avec[i]) hvec[i] = 1;
                else hvec[i] = 0;
            }
        }else {
            if(acvec[i] != 0) {
                if(acvec[i] <= tvec[i]) hvec[i] = 1;
                else hvec[i] = 0;
            }else {
                hvec[i] = min(tvec[i], avec[i]);
            }
        }
    }

    mint ans = (mint)1;
    for(int i = 0; i < n; ++i) ans *= (mint)hvec[i];

    cout << ans << endl;
}

Measured memory_bytes: 7188
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned int *A_array, *B_array;

  int C_array[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A_array = malloc(sizeof(int)*n+1);
  B_array = malloc(sizeof(int)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C_array[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%d", &A_array[i + 1]);
    C_array[ A_array[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C_array[i] = C_array[i] + C_array[i - 1];

  for ( j = 1; j <= n; j++ ){
    B_array[ C_array[ A_array[j]]] = A_array[j];
    C_array[ A_array[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B_array[i]);
  }
  printf("\n");

  return 0;
}

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

int main(){
  int n;
  
  vector<int> a(3);
  cin >> n >> a[0] >> a[1] >> a[2];
  
  vector<int> l(n);
  for(int i=0; i<n; i++)
    cin >> l[i];
  
  ll ans = 1000000000;
  
  for(ll i=0; i<(1<<(2*n)); i++){
    int j = i;
    vector<int> v(3,0), hon(3,0);
    
    int counter = 0;

    while(j > 0){
      if(j % 4 == 1){
        v[0] += l[counter];
        hon[0]++;
      }
      else if(j % 4 == 2)
      {
        v[1] += l[counter];
        hon[1]++;
      }
      else if(j % 4 == 3)
      {
        v[2] += l[counter];
        hon[2]++;
      }
      
      counter++;
      j /= 4;
    }
    
//    cout << "i = " << i << endl;
    ll ans_local = 0;
    for(int k=0; k<3; k++){
      if(hon[k] == 0) ans_local = 100000000;
      ans_local += abs((v[k]-a[k])) + 10 * max(0, (hon[k] - 1));
//      cout << abs((v[k]-a[k])) + 20 * max(0, (hon[k] - 1)) << endl;
    }
    
    if(ans > ans_local){
      ans = ans_local;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a == 1){ return a; } else{ return a * fact(a - 1); } }

int main(){
    ll N;
    vector<ll> x,y;
    cin >> N;
    rep(i, 0, N){
        ll temp, temp1;
        cin >> temp >> temp1;
        x.push_back(temp);
        y.push_back(temp1);
    }

    ll pattern = fact(N);
    vector<double> div;
    rep(i, 0, N){
        rep(ii, i + 1, N){
            double temp = pow(pow(x[i] - x[ii], 2) + pow(y[i] - y[ii], 2), 0.5);
            div.push_back(temp);
        }
    }
    ll cnt = pattern * 2 / N;
    double ans = accumulate(begin(div), end(div), 0.0) * cnt / pattern;
    cout << fix(10) << ans << endl;
    return 0;
}


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

int main()
{
    int N, ans = 0;
    cin >> N;

    int d[N];

    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }

    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}

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

int n, a[16][16];
int64_t score[1 << 16];
int64_t go(int mask) {
    if (score[mask] != -1)
        return score[mask];
    // all as one group
    score[mask] = 0;
    int64_t all_score = 0;
    for (int i = 0; i < n; i++) {
        if (mask & (1 << i)) {
            for (int j = i + 1; j < n; j++) {
                if (mask & (1 << j))
                    all_score += a[i][j];
            }
        }
    }
    score[mask] = max(score[mask], all_score);
    // split into some groups
    for (int submask = mask; (submask = (submask - 1) & mask) > 0;) {
        score[mask] = max(score[mask], go(submask) + go(mask ^ submask));
    }
    return score[mask];
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n;
    memset(score, -1, 1 << 19);
    score[0] = 0;
    for (int i = 0; i < n; i++)
        score[1 << i] = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    cout << go((1 << n) - 1) << '\n';
    return 0;
}

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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    int n;
    int64_t c;
    cin >> n >> c;

    vector<int64_t> x(n), v(n);

    int64_t sumV = 0;
    repeat (i, n) {
        cin >> x[i] >> v[i];
        sumV += v[i];
    }

    int64_t ans = max({(int64_t)0, sumV - (c - x[0]), sumV - x[n - 1]});

    {
        // 最初に右に移動すると考える。
        priority_queue<int64_t> pque;
        int64_t curSumV = sumV;

        // 右端をiに固定する。
        // 左端の範囲を伸ばす。
        for (int i = n - 2; i >= 0; i--) {
            curSumV -= v[i + 1];
            pque.push(sumV - curSumV - (c - x[i + 1]));

            ans = max(ans, curSumV - x[i]);
            ans = max(ans, curSumV - 2 * x[i] + pque.top());
        }
    }

    {
        // 最初に左に移動すると考える。
        priority_queue<int64_t> pque;
        int64_t curSumV = sumV;

        // 左端をiに固定する。
        // 右端の範囲を伸ばす。
        for (int i = 1; i < n; i++) {
            curSumV -= v[i - 1];
            pque.push(sumV - curSumV - x[i - 1]);

            ans = max(ans, curSumV - (c - x[i]));
            ans = max(ans, curSumV - 2 * (c - x[i]) + pque.top());
        }
    }

    cout << ans << endl;

    return 0;
}


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

string divide[4] = {"dream", "erase", "eraser", "dreamer"};
string S;

bool DFS(int n) { // n文字目以降の文字がうまく切れるかを計算します
    if (n == S.size()) return true; // 最後まできたら成功
    for (string i : divide) {
        if (n + i.size() <= S.size() && S.substr(n, i.size()) == i) {
            if (DFS(n + i.size())) return true; // とりあえず切ってみて成功だったらうれしい
        }
    }
    return false; // どうやっても切れなかったら失敗
}

int main() {
    cin >> S;

    cout << (DFS(0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 2368
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

set<char> in[26];
set<char> out[26];

int main(void) {
    string S, T;
    cin >> S >> T;
    int len = (int) S.size();

    for (int i = 0; i < len; i++) {
        int cs = S[i] - 'a';
        int ct = T[i] - 'a';
        out[cs].insert((char) ct);
        in[ct].insert((char) cs);
    }

    bool ok = true;
    for (int i = 0; i < 26; i++) {
        // printf("in['%c']: %d\n", (char) ('a' + i), (int) in[i].size());
        if ((int) in[i].size() > 1) {
            ok = false;
        }
    }
    for (int i = 0; i < 26; i++) {
        // printf("out['%c']: %d\n", (char) ('a' + i), (int) out[i].size());
        if ((int) out[i].size() > 1) {
            ok = false;
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 776
package main

import (
	"bufio"
	"fmt"
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var s string
	var n, k int
	fmt.Scan(&n, &s, &k)
	k--
	for i := 0; i < n; i++ {
		if s[i] != s[k] {
			fmt.Print("*")
		} else {
			fmt.Printf("%c", s[i])
		}
	}
	fmt.Print("\n")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, M;
  cin>>N>>M;
  vector<Int>D(N);
  cin>>D;

  vector<vector<P> > G(N);

  for(Int i=0;i<M;i++){
    Int a, b;
    cin>>a>>b; a--, b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }


  vector<vector<Int> > G2(N);
  vector<Int> ans(M, 1e9);
  for(Int i=0;i<N;i++){
    Int idx = 0;
    for(Int j=0;j<(Int)G[i].size();j++)
      if(D[ G[i][idx].first ] > D[ G[i][j].first] ) idx = j;
    Int to = G[i][idx].first;
    Int eidx = G[i][idx].second;
    Int d = D[to];
    if(d > D[i]){cout<<-1<<endl;exit(0);}
    ans[eidx] = D[i];
    G2[i].emplace_back(to);
    G2[to].emplace_back(i);
  }
  string S(N, '#');
  function<void(Int, char)> dfs=[&](Int pos, char ch){
    if(S[pos] != '#') return;
    S[pos] = ch;
    ch = ch == 'W'? 'B':'W';
    for(Int to:G2[pos]) dfs(to, ch);
  };

  for(Int i=0;i<N;i++) if(S[i] == '#') dfs(i, 'W');
  cout<<S<<endl;
  for(Int i=0;i<M;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 22784
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a // g * b


def main():
    N = int(input())
    t_list = list(sorted([int(input()) for _ in range(N)]))
    ans = 1
    for t in t_list:
        ans = lcm(ans, t)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
X, x = map(int,input().split())
a = list(map(int,input().split()))

ate_n = 0

for i in range(X-1):
    if a[i] + a[i+1] > x:
        if a[i] >= x:
            ate_n += a[i+1]
            a[i+1] = 0
        
        else:
            ate_n += (a[i]+a[i+1]) - x 
            a[i+1] -= (a[i]+a[i+1]) - x 
            
        if a[i] > x:
            ate_n += (a[i] - x)
            a[i] -= (a[i] - x)
            
print(ate_n)

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

long long int MOD=1000000007;

long long int gamma[100001];

long long int inv(long long int t){//逆元
	long long int t2[36];
	t2[0]=1;t2[1]=t;
	for(int i=2;i<36;i++){
		t2[i]=(t2[i-1]*t2[i-1])%MOD;
	}
	long long int ans=1;
	long long int s=MOD-2;
	int i=1;
	while(s>0){
		if(s%2==1){ans=(ans*t2[i])%MOD;}
		s=s/2;i++;
	}
  return ans;
}

long long int C(long long int a,long long int b){//combination
  if(a==b or b==0){return 1;}
	long long int ans=gamma[a];
	ans=(ans*inv(gamma[b]))%MOD;
	ans=(ans*inv(gamma[a-b]))%MOD;
	return ans;
}

long long int gcd(long long int a,long long int b){
	while(a!=b){
		if(b>a){swap(a,b);}
		a=a-b;
	}
	return a;
}

int main(){
	long long int a,b;
	cin>>a>>b;
	cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
cand = []
for bit in range(8):
    plus_minus = [1,1,1]
    for  b in range(3):
        if bit & (1 << b):
            plus_minus[b] = -1
    L = sorted(L, key = lambda x:x[0]*plus_minus[0]+x[1]*plus_minus[1]+x[2]*plus_minus[2])
    tmp = 0
    for i in range(M):
        for j in range(3):
            tmp += L[i][j] * plus_minus[j]
    cand.append(tmp)

print(max(abs(min(cand)),max(cand)))




Measured memory_bytes: 3316
import sys

sys.setrecursionlimit(4100000)
n = int(input())
numlist = [3, 5, 7]


ans = 0


def dfs(num, a, b, c):
    global ans
    if num > n:
        return False
    if a == 1 and b == 1 and c == 1:
        if num <= n:
            ans += 1
    for d in numlist:
        na, nb, nc = a, b, c
        if d == 3:
            na = 1
        if d == 5:
            nb = 1
        if d == 7:
            nc = 1
        if num == 0:
            num = d
        else:
            num = num * 10 + d
        dfs(num, na, nb, nc)
        num //= 10


dfs(0, 0, 0, 0)
print(ans)


Measured memory_bytes: 75220
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define abs(a) ((a < 0) ? -(a) : a)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

int main() {
	int a = ri();
	int b = ri();
	
	int c = b-a;
	int right = ((c+1)*c)/2;
	
	int res = right-b;
	
	printf("%d", res);
	
	return 0;
}


Measured memory_bytes: 128
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        s = s.Replace("+x", "+1x");
        s = s.Replace("-x", "-1x");
        var a = getList(s);
        var ans = getAns(a);
        print(ans);
    }
    static void print (List<int> a)
    {
        foreach (var x  in a.OrderByDescending(y =>y))
        {
            var w = (-x).ToString();
            if (x < 0) w = "+" + w;
            Console.Write("(x{0})",w);
        }
        Console.WriteLine();
    }
    static List<int> getAns(List<int> a)
    {
        var ans = new List<int>();
        var ac = a.Count() - 1;
        for (int i = -2000; i <= 2000; i++)
        {
            var p = ac;
            var wa = 0L;
            foreach (var x in a)
            {
                wa += x * (long)Pow(i, p);
                p--;
            }
            if (wa == 0)  ans.Add(i); 
            if (ans.Count() == ac) break;
        }
        return ans;
    }
    static List<int> getList(string s)
    {
        string[] line = s.Split('+', '-');
        var e = new List<int>();
        e.Add(1);
        var pre = int.Parse(line[0][line[0].Length - 1].ToString());
        for (int i = 1; i < line.Length -1; i++)
        {
            var LL = line[i].Length;
            var ip = line[i].Substring(LL - 1);
            int w;
            if (!int.TryParse(ip, out w)) w = 1;
            if (pre - w > 1) for (int j = 0; j < pre - w - 1; j++) e.Add(0);
            var px = line[i].IndexOf('x');
            var ww = line[i].Substring(0, px);
            e.Add(int.Parse(ww));
            pre = w;
        }
        if (s.IndexOf("x+") < 0 && s.IndexOf("x-") < 0) e.Add(0);
        e.Add(int.Parse(line[line.Length - 1].ToString()));
        var p = 1;
        foreach (var x in s)
        {
            if (x == '+' | x == '-')
            {
                while (true)
                    if (e[p] == 0) p++;
                    else break;
                if (x == '-') e[p] = -e[p];
                p++;
            }
        }
        return e;
    }
}



Measured memory_bytes: 21000
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
  int H,W;
  cin >> H >> W;
  if(H%3==0 || W%3==0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = min(H,W);
  vector<ll> M(3);
  for(ll h=1; h<H; h++){
    M[0] = h*(W/2);
    M[1] = (H-h)*W;
    M[2] = h*W-M[0];
    sort(M.begin(),M.end());
    ans = min(ans,M[2]-M[0]);
  }
  for(ll w=1; w<W; w++){
    M[0] = w*(H/2);
    M[1] = (W-w)*H;
    M[2] = w*H-M[0];
    sort(M.begin(),M.end());
    ans = min(ans,M[2]-M[0]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    Yes(n/10==9||n%10==9);
}

Measured memory_bytes: 256
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#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 ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    ll S, C;
    cin >> S >> C;
    if (S > C/2) {
        cout << C / 2 << endl;
    } else {
        cout << S + (C - S * 2) / 4 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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; }
void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


template <class T>
struct CumSum2D {
private:
	const int h, w;
	vector<vector<T>> data;

public:
	CumSum2D(int h, int w) : data(h + 1, vector<T>(w + 1, (T)0)), h{ h + 1 }, w{ w + 1 } {}

	void add(int i, int j, T val) { if ((i + 1) < h && (j + 1) < w) data[i + 1][j + 1] += val; }
	void cumulate() { REP1O(i, h) REP1O(j, w) data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; }
	
	// [s, g) , s : btm-left, g : top-right
	T get(int si, int sj, int gi, int gj) { return data[gi][gj] + data[si][sj] - data[gi][sj] - data[si][gj]; }
};

int n, k;

int main()
{
	cin >> n >> k;
	CumSum2D<int> white(k, k), black(k, k);

	REP(_i, n)
	{
		int x, y; char c;
		cin >> x >> y >> c;

		x %= (2 * k);
		y %= (2 * k);
		int isBlack = c == 'B';

		if (x >= k) { x -= k; isBlack ^= 1; }
		if (y >= k) { y -= k; isBlack ^= 1; }

		if (isBlack)
			black.add(y, x, 1);
		else
			white.add(y, x, 1);
	}

	white.cumulate();
	black.cumulate();

	int ans = 0;

	REP(y, k)
		REP(x, k)
	{
		int tmp = 0;
		tmp += black.get(0, 0, y, x) + black.get(y, x, k, k);
		tmp += white.get(y, 0, k, x) + white.get(0, x, y, k);

		chmax(ans, max(tmp, n - tmp));
	}

	cout << ans << endl;
}


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

int main() {
  
  string s, ans; cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) ans += s.at(i);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
char s[10];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=read(),t0=0,t1=0,t2=0,t3=0;
	for(int i=1;i<=n;i++){
		scanf("%s",s);
		if(s[0]=='A')t0++;
		else if(s[0]=='W')t1++;
		else if(s[0]=='T')t2++;
		else t3++;
	}
	printf("AC x %d\n",t0);
	printf("WA x %d\n",t1);
	printf("TLE x %d\n",t2);
	printf("RE x %d",t3);
	return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m, u, v;
VI mem[100010];

bool chk[100010];
int dst[100010];
void dfs(int a,int depth){
  chk[a]=1;
  dst[a] = depth;
  for (int i = 0; i < mem[a].size(); i++)
  {
    if(!chk[mem[a][i]])
      dfs(mem[a][i],depth+1);
  }
}
void pnt(int a){
  dst[a] = 0;
  for (int i = 0; i < mem[a].size(); i++)
  {
    if (dst[mem[a][i]] == 0)
      continue;
    if(dst[mem[a][i]]>dst[u]/2)
      continue;
    pnt(mem[a][i]);
  }
}
bool chkd[100010];
int srch(int a)
{
  int ret = dst[a];
  chkd[a] = 1;
  for (int i = 0; i < mem[a].size(); i++)
  {
    if(dst[mem[a][i]]!=0&&!chkd[mem[a][i]]){
      ret = max(ret, srch(mem[a][i]));
    }
  }
  return ret;
}

int main()
{
  cin >> n >> u >> v;
  int a, b;
  for (int i = 0; i < n - 1; i++)
  {
    cin >> a >> b;
    mem[a].push_back(b);
    mem[b].push_back(a);
  }
  dst[v] = 0;
  dfs(v,0);
  //vから初めて(dst[u])/2以上の点は削除
  pnt(v);
  cout << max(0,srch(u)-1) << endl;
}


Measured memory_bytes: 10112
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 100000001
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[120][1050];

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    int i;
    int n;
    int a,b,d,c;
    int e,weight;
    ll h,w;
    cin>>str;
            int cnt=0;

    rep(i,str.length()){
        if(str[i]=='A'&&f==0){
            f=1;
            //cnt++;
        }
        if(f==1) cnt++;
        if(str[i]=='Z'&&f==1){
            sum=max(cnt,sum);
        }
        //cout<<str[i];
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
    int N;
    int A[110];
    cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }
    int M = A[0];
    int m = A[0];
    for (int i = 0; i < N; ++i)
    {
        if(A[i] > M){
            M = A[i];
        }
        if(A[i] < m){
            m = A[i];
        }
    }
    cout << M - m << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) <<
#include "atcoder/all"

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)

using namespace std;
using namespace atcoder;


int main(){
    int n, q;
    cin >> n >> q;

    dsu tree(n);
    while(q--){
        int t, u, v;
        cin >>  t >> u >> v;
        if(t){
            if(tree.same(u,v)) cout << 1 << endl;
            else cout << 0 << endl;  
        }else{
            int a = tree.merge(u,v);
        }
    }
}



Measured memory_bytes: 4036
n, k = map(int, input().split())
p = max(0, n//11-1)
q = n-11*p
#print(p, q)
r = 0
for i in range(11):
  for j in range(5):
    s = (7*(i+1)+(j+1)-7)*9+0+1+2+7+8+9+14+15+16
    if s%11 == k:
      r += 1
r = r*p
for i in range(q-2):
  for j in range(5):
    s = (7*(i+1)+(j+1)-7)*9+0+1+2+7+8+9+14+15+16
    if s%11 == k:
      r += 1
print(r)


Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,q;
    string s;
    cin>>n>>s>>q;

    vector<set<int>> pls;
    pls.assign(26,set<int>({INF}));
    rep(i,n) pls[s[i]-'a'].insert(i);

    while(q--){
        int c;
        cin>>c;

        if(c==1){
            int id;
            char c;
            cin>>id>>c;
            id--;
            auto pc=s[id];
            s[id]=c;
            pls[pc-'a'].erase(id);
            pls[c-'a'].insert(id);
        }
        else{
            int l,r;
            cin>>l>>r;
            l--;
            int ans=0;
            rep(i,26){
                if(pls[i].empty()) continue;
                int lid=*pls[i].lower_bound(l);
                int rid=*pls[i].lower_bound(r);
                if(rid>lid) ans++;
            }

            cout<<ans<<endl;
        }
    }
}


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

int  main()
{
	int a , b;
	cin >> a >> b;
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
	return (0);
}


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

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

int main() {
  int n;
  cin >> n;
  vector<int> M;
  int sum = 0;
  for(int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    sum += x;
    M.push_back(x);
  }
  int ans = sum;
  int pre = 0;
  for(auto x : M) {
    pre += x;
    ans = min(ans, abs(pre - (sum - pre)));
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        ma: usize,
        mb: usize,
        abc: [(usize, usize, usize); n],
    }
    let mut ans = std::i64::MAX;

    let mut dp = vec![vec![vec![4_001; 411]; 411]; n + 1];
    dp[0][0][0] = 0;

    for i in 0..abc.len() {
        for a in 0..=400 {
            for b in 0..=400 {
                dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
                dp[i + 1][a + abc[i].0][b + abc[i].1] = min(
                    dp[i][a][b] + abc[i].2,
                    dp[i + 1][a + abc[i].0][b + abc[i].1],
                );
            }
        }
    }

    let mut ans = std::i64::MAX;
    let mut i = 1;
    while 404 > max(ma, mb) * i {
        ans = min(ans, dp[n][i * ma][i * mb] as i64);
        i += 1;
    }
    if ans == 4_001 {
        println!("-1")
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 56608
#include<iostream>
using namespace std;
main(){
char g[]={97,102,107,112,117,122,98,103,108,113,118,46,99,104,109,114,119,63,100,105,110,115,120,33,101,106,111,116,121,32};
string s,a;
while(cin>>s,!cin.eof()){
a="";
for(int i=0;i<s.size();i+=2){
int l=s[i]-'0',r=s[i+1]-'0';
if(s.size()%2||l<1||r<1||l>6||r>5){a="NA";break;}
a+=g[r*6+l-7];
}
cout<<a<<'\n';
}	
}

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

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       "\n"
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();

void vrikodara(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    // #ifndef ONLINE_JUDGE
    //      freopen("input.txt",  "r",  stdin);
    //      freopen("output.txt", "w", stdout);
    // #endif
}

//____________________________________________________________________________________

v2d dp(3005,v1d(3005,-1));

int fun(v1d &v,int n,int i,int j){
    if(dp[i][j] != -1)return dp[i][j];
    if(i == j)return dp[i][j] = v[i];
    dp[i][j] = max(v[i]-fun(v,n,i+1,j), v[j]-fun(v,n,i,j-1));
    return dp[i][j];
}

void solve(){
    int n,k;cin>>n;
    v1d v(n+2);
    for(int i=0;i<n;i++)cin>>v[i+1];
    cout<<fun(v,n,1,n);
}

int32_t main(){
    vrikodara();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    


    return 0;
}


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

signed main ( ) {

    int l, r;
    cin >> l >> r;
    vector<int> v;
    for ( int i = l; i <= min(l+2019*2+1, r); i++ ) {
        v.push_back(i%2019);
    }

    int mn = 10000;
    for ( int i = 0; i < (int)v.size(); i++ ) {
        for ( int j = i+1; j < (int)v.size(); j++ ) {
            mn = min ( mn, (v[i]*v[j]) % 2019 );
        }
    }

    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 256
N, P = map(x -> parse(Int64, x), split(readline(STDIN)))

function primes(n)
    prime_factors = Dict{Int64, Int64}()
    divisor = 2
    
    while divisor ^ 2 <= n
        count = 0
        while n % divisor == 0
            count += 1
            n ÷= divisor
        end
        if count > 0
            prime_factors[divisor] = count
        end
        divisor += 1
    end
    
    if n > 1
        prime_factors[n] = 1
    end
    
    return prime_factors
end

primes_dic = primes(P)

cal_k(pair) = pair.first ^ floor(Int64, pair.second / N)

answer = length(primes_dic) == 0 ? 1 : mapreduce(x-> cal_k(x), *, primes_dic)

println(answer)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

template<typename T>
struct RMQ {
  int n;
  vector<T> dat;

  RMQ(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
  }

  void update(int k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  T query(size_t a, size_t b) {
    return query(a, b, 0, 0, n);
  }

  T query(size_t a, size_t b, size_t k, size_t l, size_t r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat.at(k);

    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

    return max(vl, vr);
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> h(n);
    vector<int> a(n);
    cin >> h >> a;

    const int H = 2 * 1e5 + 5;
    RMQ<lli> rmq(H);
    
    for (int i = 0; i < n; ++i) {
      rmq.update(h[i], a[i] + rmq.query(0, h[i]));
    }
    cout << rmq.query(0, H - 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> task(n, vector<int>(2));
    for (int i = 0; i < n; i++)cin >> task[i][1] >> task[i][0];

    sort(task.begin(), task.end());
    ll sum = 0;
    bool ret = true;
    for (int i = 0; i < n; i++) {
        sum += task[i][1];
        if (sum > task[i][0])ret = false;
    }

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

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

template<class T> void YES(T condition){ if(condition) OUT("YES"); else OUT("NO"); }
template<class T> void Yes(T condition){ if(condition) OUT("Yes"); else OUT("No"); }
template<class T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

typedef long long ll;
typedef pair<ll, ll> P;

const int MOD=1e9+7;

int main() {
  // 方針としては、コストを0にする人数が最大になるように割り振る
  // つまりコストの昇順でそーとして、小さいものから順番に減らしていき
  // 残ったものを食べにくさの降順にぶつける
  //
  // コストの合計-Kをfoodにうまく割り振って、最大を最小にする
  // foodの食べにくさが小さい順に割り振った方がいいので降順ソート
  // そして、最小の食べにくさのところに優先的に降っていって、その合計が次の食べ物x1を超えたらそっちに割り振っていく
  ll N,K;cin>>N>>K;
  vector<ll> AS(N),FS(N);
  REP(i,N) cin>>AS[i];
  REP(i,N) cin>>FS[i];
  sort(ALL(AS),greater<ll>());
  sort(ALL(FS));

  ll total_cost = accumulate(ALL(AS),0LL);

  // もし全員コスト0にできるなら
  if (total_cost<=K) {
    OUT(0);
    return 0;
  }

  ll rest_cost = total_cost-K;

  // 入れた値以下にできるか
  auto checker = [&](ll limit) -> bool {
    ll tmp = 0;
    REP(i,N) tmp += min(AS[i],limit/FS[i]);
    return tmp>=rest_cost;
  };

  ll left=0,right=1e12;
  while (left<right) {
    ll mid = (left+right)/2;
    if (checker(mid)) right = mid;
    else left = mid+1;
  }
  OUT(left);

  return 0;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  if(y%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  if(4*x >= y && 2*x <= y){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll modPow(int a, int n) {
    if (n == 1) return a;
    if (n % 2) return a * modPow(a, n - 1) % MOD;
    ll t = modPow(a, n / 2) % MOD;
    return t * t % MOD;
}

ll modnCr(ll n, ll r) {
    ll X = 1, Y = 1;
    for (ll i = 0; i < r; i++) { 
        X *= (n - i);
        X %= MOD;
        Y *= (r - i);
        Y %= MOD;
    }
    return X * modPow(Y, MOD - 2) % MOD;
}

int main() {
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int ans =  modPow(2, n) - 1;
    ans -= modnCr(n, a);
    ans += MOD;
    ans %= MOD;
    ans -= modnCr(n, b);
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    vector<int> a(n);
    vector<int> b;
    int diff[n];
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    b = a;
    sort(ALL(b));
    for (int i=0; i<n; ++i){
        auto itr = lower_bound(ALL(b), a[i]) - b.begin();
        diff[i] = abs(itr - i);
    }
    for (int i=0; i<n; ++i){
        if(diff[i] % 2 == 1){
            ans++;
        }
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int NMAX=100000;
const int KMAX=200;
int dp[NMAX+1][KMAX+1];

signed main()
{
   int N,K; cin>>N>>K;

   if(K>KMAX){
      cout<<0<<endl;
      return 0;
   }

   for(int i=1;i<=N;i++){
      dp[i][1]=1;
      for(int k=1;k<=KMAX;k++){
         for(int j=i*2;j<=N;j+=i){
            dp[j][k+1]+=dp[i][k];
         }
      }
   }

   int ans=0;
   for(int i=1;i<=N;i++){
      ans+=dp[i][K];
   }
   cout<<ans<<endl;
}




Measured memory_bytes: 159268
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


count1 = count2 = 0
for s in sys.stdin:
  d = map(int,s.split(","))
  if d[2]**2 == d[0]**2 + d[1]**2:
    count1 += 1
  if d[0] == d[1]:
    count2 +=1

print count1
print count2

Measured memory_bytes: 4196
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}



int main() {
    char c; cin>>c;
    c++;
    cout<<c<<endl;
   return 0;
}
/*
7
1 2 3 5 4 6 7
*/


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll r;
    cin >> r;

    MSG(fixed << setprecision(15) << 2*r*3.14159265358979323846)
}


Measured memory_bytes: 3776