akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#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;
typedef long long ll;

int main()
{
    // Input
    int a;
    cin >> a;

    cout << a + pow(a, 2) + pow(a, 3);

    return 0;
}


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


int N;
vector<int> P;


void input() {
    cin >> N;
    P = vector<int>(N);
    rep(i, N) cin >> P[i];
}


int main() {
    input();
    sort(P.begin(), P.end());
    int ans = 0;
    rep(i, N-1) ans += P[i];
    ans += P.back() / 2;
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        t--;
        a[i] = t;
    }

    vector<bool> c(N, false);
    int next = 0, cnt = 0;
    while(!c[next]){
        c[next] = true;
        cnt++;
        next = a[next];

        if(next==1){
            cout << cnt << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

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

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

    int i;
    int cnt = 0;
    for(i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (hypot(x, y) <= d) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main() {
  string s;
  cin >> s;
  string ans;
  for (char c : s) {
    if (c == 'B') {
      if (!ans.empty()) ans.erase(ans.end() - 1);
    } else {
      ans += c;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N, M;
string S;

vector<int> l_zero, r_zero; // i からみて 1 がないすぐ左／右の場所(自分が 0 なら自分)

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

    cin >> N >> M >> S;

    // -1 チェック
    int cnt = 0;
    REP(i, N + 1) {
        if(S[i] == '1') {
            cnt++;
            if(cnt >= M) {
                printf("-1\n");
                return 0;
            }
        }
        else {
            cnt = 0;
        }
    }

    // l_zero, r_zero の作成
    l_zero.assign(N + 1, -1);
    r_zero.assign(N + 1, -1);
    int cur = 0;
    REP(i, N + 1) {
        if(S[i] == '0') { cur = i; }
        l_zero[i] = cur;
    }
    cur = N;
    for(int i = N; i >= 0; --i) {
        if(S[i] == '0') { cur = i; }
        r_zero[i] = cur;
    }

    // まず最短距離を出す
    int ans_dist = 0;
    vector<int> ans_pos;
    cur = 0;
    ans_pos.push_back(0);
    while(cur < N) {
        // 行けそうなら行く
        if(cur + M >= N) {
            cur = N;
            ans_dist++;
            break;
        }

        int next_cur = cur + M;
        if(S[next_cur] == '1') {
            next_cur = l_zero[next_cur];
        }
        cur = next_cur;
        ans_pos.push_back(cur);
        ans_dist++;
    }
    ans_pos.push_back(N);

    // ans_pos を左に寄せられないか調整
    reverse(ans_pos.begin(), ans_pos.end());
    vector<int> ans_r;
    REP(i, ans_pos.size() - 1) {
        // 現在の移動距離
        int cur_dist = ans_pos[i] - ans_pos[i + 1];
        // まだいける移動距離
        int sub_dist = M - cur_dist;

        int new_pos = ans_pos[i+1] - sub_dist;
        if(new_pos < 0) { new_pos = 0; }
        new_pos = r_zero[new_pos];
        int new_dist = ans_pos[i] - new_pos;
        ans_r.push_back(new_dist);

        ans_pos[i + 1] = new_pos;
    }

    reverse(ans_r.begin(), ans_r.end());
    REP(i, ans_r.size()) {
        printf("%lld%c", ans_r[i], (i == ans_r.size() - 1) ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 4292
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
  int n;
  cin>>n;
  
  int cnt[4]={0};
  for(int i=0;i<n;i++){
  	string t;
    cin>>t;
    
    if(t=="AC"){
    	cnt[0]++;
    }else if(t=="WA"){
    	cnt[1]++;
    }else if(t=="TLE"){
    	cnt[2]++;
    }else if(t=="RE"){
    	cnt[3]++;
    }
  }
  
  cout<<"AC x "<<cnt[0]<<endl;
  cout<<"WA x "<<cnt[1]<<endl;
  cout<<"TLE x "<<cnt[2]<<endl;
  cout<<"RE x "<<cnt[3]<<endl;
  
  	
}

Measured memory_bytes: 3628
from collections import deque

n = int(input())

ab = [list(map(int,input().split())) for i in range(n-1)]

ver = [[] for i in range(n)]

for i in range(n-1):
    a,b = ab[i][0],ab[i][1]
    ver[a-1].append(b-1)
    ver[b-1].append(a-1)

#print(ver)

color = [dict() for i in range(n)]
q = deque()
i = 1
for v in ver[0]:
    color[0][v] = i
    color[v][0] = i
    q.append((0,v))
    i += 1

#print(q)

while q:
    f,t = q.popleft()
    i = 1
    for v in ver[t]:
        if v == f:
            continue
        if i == color[f][t]:
            i += 1
        color[t][v] = i
        color[v][t] = i
        q.append((t,v))
        i += 1

#print(color)
k = 0
for i in range(n):
    k = max(k,len(ver[i]))
print(k)
for i in range(n-1):
    a,b = ab[i][0],ab[i][1]
    print(color[a-1][b-1])


Measured memory_bytes: 115928
import java.util.*;
 
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        if (a.charAt(a.length() - 1) == b.charAt(0) &&
                b.charAt(b.length() - 1) == c.charAt(0))
        {
            System.out.println("YES");
        }
        else
        {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll suma = accumulate(all(a), 0LL);
    ll td = 0, cd = 0;
    rep(i, n - 1) {
        cd = a[i] * 2 - cd;
        td += cd;
    }
    vector<ll> ans(n);
    ans[0] = suma - td;
    rep(i, n - 1) {
        ans[i + 1] = a[i] * 2 - ans[i];
    }
    rep(i, n) printf("%lld%s", ans[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
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;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  vector<ll>b(n);
  rep(i,0,n)b[a[i]-1]++;
  vector<ll>c;
  rep(i,0,n)if(b[i]>0)c.PB(b[i]);
  sort(ALL(c));
  ll idx=0,sumbuf=0;
  vector<ll>ret(n+1);
  rep(i,1,n+1){
    while(idx<c.size()&&c[idx]<=i){
      sumbuf+=c[idx];
      idx++;
    }
    //cout<<i spa sumbuf<<endl;
    ret[i]=sumbuf+((ll)c.size()-idx)*i;
  }
  vector<ll>s(n);
  idx=1;
  //debug(c,c.size());
  //debug(ret,n+1);
  rrep(i,0,n){
    while(idx<=n&&ret[idx]/(idx)>=i+1)idx++;
    s[i]=idx-1;
  }
  rep(i,0,n)cout<<s[i]<<endl;
  return 0;
}

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

vector<pair<ll,ll> > to[100010];

int main(){
    ll n;cin>>n;
    rep(i,0,n-1){
        ll u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        to[u].push_back(make_pair(v,w));
        to[v].push_back(make_pair(u,w));
    }
    
    vector<int> dist(n, -1); 
    queue<int> que;
    ll clr[100010];
    rep(i,0,100010)clr[i]=-1;
    clr[0]=0;

    dist[0] = 0;
    que.push(0); 

    while (!que.empty()) {
        int v = que.front(); 
        que.pop();

        for (auto nv : to[v]) {
            if (clr[nv.first] != -1) continue; 

            if(nv.second%2==1)clr[nv.first] = 1-clr[v];
            else clr[nv.first] = clr[v];
            que.push(nv.first);
        }
    }
    rep(i,0,n)cout<<clr[i]<<endl;

}







Measured memory_bytes: 9088
import sys

n,m=map(int,next(sys.stdin).split())
adj=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,next(sys.stdin).split())
    a,b=a-1,b-1
    adj[a].append(b)
    adj[b].append(a)

ans=0
vis=[0]*n
for i in range(n):
    if vis[i]:
        continue
    vis[i]=1
    k=0
    stk=[i]
    while stk:
        u=stk.pop()
        k+=1
        for v in adj[u]:
            if vis[v]:
                continue
            vis[v]=1
            stk.append(v)
    ans=max(ans,k)

print(ans)


Measured memory_bytes: 107416
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e16;
const int MOD = 1e9 + 7;


int N;


int main(void) {
	cin >> N;
	if (N == 25)ct("Christmas");
	else if (N == 24)ct("Christmas Eve");
	else if (N == 23)ct("Christmas Eve Eve");
	else if (N == 22)ct("Christmas Eve Eve Eve");
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+solls[j]
    if (s%2 == 0)and(A[i] == 1):
        solls[i] = 1
    if (s%2 == 1)and(A[i] == 0):
        solls[i] = 1

s = 0
ls = []
for i in range(N+1):
    if solls[i] == 1:
        ls.append(i)
        s = s+1

print(s)
print(*ls)    

Measured memory_bytes: 22844
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
	// write your code here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw =new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int K = Integer.parseInt(st.nextToken());
        int X = Integer.parseInt(st.nextToken());
        pw.println((X/500.0)<=K?"Yes":"No");
        pw.flush();
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%2d %2d",&a,&b);
    if(a<=12 && a>0)
    {
        if(b<=12 && b>0)
        cout<<"AMBIGUOUS"<<endl;
        else
            cout<<"MMYY"<<endl;

    }
    else if(b<=12 && b>0)
    {
        cout<<"YYMM"<<endl;
    }
    else
        cout<<"NA"<<endl;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"strconv"
	"strings"
	"os"
)

const MAX_LENGTH int = 2*10e6
const MAX_VALUE int = 10e4

func countingSort(A []int, N int) []int {
	C := make([]int, MAX_VALUE+1)
	B := make([]int, N)

	for i:=0; i<N; i++ {
		C[A[i]] += 1
	}
	for i:=1; i<=MAX_VALUE; i++{
		C[i] += C[i-1]
	}
	for j:=N-1; j>=0; j-- {
		B[C[A[j]] -1] = A[j]
		C[A[j]] -= 1
	}
	return B
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N := nextInt(scanner)
	A := make([]int, N)
	for i:=0; i<N; i++{
		A[i] = nextInt(scanner)
	}
	arr := countingSort(A, N)
	arrStr := make([]string, N)
	for i:=0; i<N; i++ {
		arrStr[i] = strconv.Itoa(arr[i])
	}
	fmt.Println(strings.Join(arrStr, " "))
}


Measured memory_bytes: 80884
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
 
int main(){
  int n,k;
  while(cin >> n >> k, n){
    vector<string> a(n);
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    sort(a.begin(), a.end());
 
    set<string> ans;
    for(int bit=1;bit<(1<<n);bit++){
      if(__builtin_popcount(bit) == k){
        vector<string> use;
        for(int i=0;i<n;i++){
          if( (bit>>i)&1 ) use.push_back(a[i]);
        }
        do{
          string con;
          for(int i=0;i<k;i++) con += use[i];
          ans.insert(con);
        }while( next_permutation(use.begin(), use.end()) );
      }
    }
    cout << ans.size() << endl;
  }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    int n;
    cin>>n;
    n%=10;
    if (n==2||n==4||n==5||n==7||n==9) out("hon");
    if (n==0||n==1||n==6||n==8) out("pon");
    out("bon");

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    set<int>s;
    cin>>n;
    int x;
    while(n--){
        cin>>x;
        if(s.find(x)==s.end())s.insert(x);
        else{
            s.erase(x);
        }
    }
    cout<<s.size();
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < n; i++)
#define inf 1000000000
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int a;
    cin >> a;

    if(a%1000==0){
        cout << 0 << endl;
      return 0;
    }
    cout << 1000-a%1000 << endl;

    return 0;
}

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

using namespace std;

#define ll long long

ll cost[100010], h[100010];

main()
{
    ll n, i, j, c, c2, k;

    cin>>n>>k;

    for(i=0; i<n; i++) scanf("%lld", &h[i]);
    c=h[1]-h[0];
    if(c<0) c=-c;
    cost[1]=c;
    for(i=2; i<n; i++)
    {
    cost[i]=1000000000000000000;
    for(j=1; j<=k && i-j>=0; j++)
    {
       c2=h[i]-h[i-j];
       if(c2<0) c2=-c2;
       c2+=cost[i-j];
       if(cost[i]>c2) cost[i]=c2;
    }
    }

    cout<<cost[n-1]<<endl;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;


int main()
{


 ll X,Y,x,y;
 cin>>X>>Y>>x>>y;
 /*float area1=(x*Y)/1.0;
 float area2=((X-x)*Y)/1.0;
 float area3=(y*X)/1.0;
 float area4=((Y-y)*Y)/1.0;
 float minn1=min(area1,area2);
 float minn2=min(area3,area4);
 float maxx=max(minn1,minn2);*/
 double area=(X*Y)/2.0;
  cout<<fixed<<setprecision(9)<<area<<" ";
 if(x+x==X && y+y==Y)
   cout<<"1";
 else
   cout<<"0";

 return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  const N=input[0]-0;
  const height=input[1].split(' ').map(e=>{
    return e-0;
  });
  var max=0;
  var ret=0;
  height.forEach(e=>{
    if(max<e){
      max=e;
    }else{
      ret+=max-e;
    }
  });
  console.log(ret);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 49888
'use strict'

function Main(input) {
    const AB = input.trim().split(" ");
    const A = AB[0]
    const B = AB[1]

    let m, n;
    if (A > B) {
        m = A
        n = B
    } else {
        m = B
        n = A
    }

    while (n != 0) {
        let tmp = n
        n = m % n
        m = tmp
    }

    console.log(A * B / m)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef pair<long, long> pl; // price, num

int main(void){
	long N, M;
	long sum = 0;
	cin >> N >> M;
    priority_queue< pl, vector<pl>, greater<pl> > q;
	for(int i = 0; i < N; i++){
		long price, num;
		cin >> price >> num;
		q.push(make_pair(price, num));
	}
	while(M > 0){
		pl top;
		long price, num;
		top = q.top();
		if(M - top.second >= 0){
			M -= top.second;
			sum += top.first * top.second;
			q.pop();
		}
		else{
			sum += top.first * M;
			M = 0;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
 
using namespace std;
 
int main()
{
int h=0, m=0, s=0;
 
cin >>h >>m >>s;

if(h < m && m < s)
{
cout <<"Yes"<<endl;
}
else
{
cout <<"No"<<endl;
}
 
return 0;
}

Measured memory_bytes: 3112
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int k = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			SortedSet<long> set = new SortedSet<long>();
			int digits = 0;
			while (set.Count < k) {
				for (int j = 1; j <= 9; j++) {
					for (int i = 0; i < Math.Pow(3, digits); i++) {
						long num = MakeNumber(j, digits, i);
						//System.Diagnostics.Debug.WriteLine($"{j} {digits} {i} {num}");
						if (num > 0) {
							set.Add(num);
						}
					}
				}
				digits++;
			}
			Console.WriteLine(set.Skip(k - 1).First());


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}

		static long MakeNumber(int top, int digits, int pattern)
		{
			long result = top;
			int tmp = (int)Math.Pow(3, digits - 1);
			for (int i = 0; i < digits; i++) {
				long x = 0;
				switch (pattern / tmp % 3) {
					case 0:
						x = result % 10 - 1;
						break;
					case 1:
						x = result % 10;
						break;
					case 2:
						x = result % 10 + 1;
						break;
				}
				if (x < 0 || 9 < x) {
					return 0;
				}
				result = result * 10 + x;
				tmp /= 3;
			}
			return result;
		}
	}
}


Measured memory_bytes: 25804
import fractions

a,b,c,d = map(int,input().split())
cd =  int(c*d/fractions.gcd(c, d))

ac1,ac2 = a//c,a%c
ad1,ad2 = a//d,a%d
bc1,bc2 = b//c,b%c
bd1,bd2 = b//d,b%d
acd1,acd2 = a//cd,a%cd
bcd1,bcd2 = b//cd,b%cd

if ac2 == 0:
    a_ = bc1-ac1+1
else:
    a_ = bc1-ac1

if ad2 == 0:
    b_ = bd1-ad1+1
else:
    b_ = bd1-ad1

if acd2 == 0:
    c_ = bcd1-acd1+1
else:
    c_ = bcd1-acd1

print(b-a+1-(a_+b_-c_))





Measured memory_bytes: 5076
x,k,d = map(int,input().split())

if abs(x)//d <= k and k>1000 :
  z = k - (abs(x)//d)
  x = abs(x)%d
  if z % 2 == 0:
    print(x)
    exit()
  else:
    if abs(x) + d <= abs(abs(x) - d):
      print(abs(x)+d)
      exit()
    else:
      print(abs(abs(x)-d))
      exit()
elif abs(x)//d > k and k>1000 :
  x = abs(x) - k*d
  print(abs(x))
  exit()
else:
  for i in range(1,k+1):
    if abs(x) >= abs(abs(x) - d):
      x = abs(x) - d
    else:
      if (k-i-1)%2 == 0:
        print(abs(x))
        exit()
      else:
        if abs(x) + d <= abs(abs(x) - d):
          print(abs(x)+d)
          exit()
        else:
          print(abs(abs(x)-d))
          exit()
print(abs(x))

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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl;
#define pqueue priority_queue
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'


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

    ll a, b, k;cin>>a>>b>>k;
    ll x = min(a, k);
    a -= x;
    k -= x;
    if (k > 0) b -= min(b, k);

    cout << a << " " << b << endl;

    return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	LL n, c, k;
	cin >> n >> c >> k;
	vl t(n);

	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	SORT(t);

	int ans = 0;
	vi b(n);

	bool noI = false;
	int cnt = 0;
	for (int i = 0; i < n;) {
		cnt = 0;
		for (int j = i; j < n; j++) {
			if (b[j]) {
				break;
			}

			if (cnt >= c) {
				ans++;
				i = j;
				noI = true;

				break;
			}

			if (t[j] <= t[i] + k) {
				b[j] = true;
				cnt++;
			} else {
				ans++;
				i = j;
				noI = true;

				break;
			}
		}

		if (noI) {
			noI = false;
		} else {
			if (cnt > 0) {
				ans++;
			}
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
// ------------------------------------
// Date:2018/ 4/29
// Problem:/ / / d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

ll N, K;

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

  cin >> N >> K;

  if (K == 0) {
    cout << N * N << endl;
    return 0;
  }
  
  ll ans = 0ll;
  FOR(bi, K, N + 1) {

    ll tmp = (N + 1) / bi;
    // debug(tmp);
    ans += tmp * max(bi - K, 0ll);
    ans += max((N + 1) % bi - K, 0ll);
    // debug(ans);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    bool existC = false;
    if (s[0] != 'A' || s[1] < 'a') {
        cout << "WA" << endl;
    } else {
        for (int i=2; i<s.size(); i++) {
            if (s[i] == 'C') {
                if (existC || i==s.size()-1) {
                    cout << "WA" << endl;
                    return 0;
                } else {
                    existC = true;
                }
            } else if (s[i] < 'a') {
                cout << "WA" << endl;
                return 0;
            }
        }
        if (existC) {
            cout << "AC" << endl;
        } else {
            cout << "WA" << endl;
        }
    }
}

Measured memory_bytes: 3564
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b,c,d,e,f,A,B,C,D,E,F;
a=1;
b=5;
c=10;
d=50;
e=100;
f=500;
cin>>A>>B>>C>>D>>E>>F;
if((a*A)+(b*B)+(c*C)+(d*D)+(e*E)+(f*F)<1000){
cout<<0<<endl;
}else {
cout<<1<<endl;
}
         return 0;
      }

Measured memory_bytes: 1164
# 2019/09/20

from collections import deque

s=input()
n=len(s)
def chk(s):
    s=''.join(s).replace('x','')
    if s!=s[::-1]:
        print(-1)
        exit()
chk(s)

s=deque(s)

res=[]
cnt=0
while len(s)>1:
    if s[0]==s[-1]:
        s.pop()
        res.append(s.popleft())
    else:
        if s[0]=='x':
            s.append('x')
        else:
            s.appendleft('x')
        cnt+=1
print(cnt)

Measured memory_bytes: 4964
import numpy as np
import collections

N, M = map(int, raw_input().split())
X = map(int, raw_input().split())

dupM = np.zeros(M, dtype='int')
modM = np.zeros(M, dtype='int')

# count dup
X_count = collections.Counter(X)
for x in X_count.keys():
    dupM[x % M] += int(X_count[x] / 2)
# count mod
for x in X:
    modM[x % M] += 1

res = 0
for m in range(M):
    if m == 0:
        res += int(modM[m] / 2)
    elif 2*m < M:
        res += min(modM[m], modM[M-m])
        if modM[M-m] < modM[m]:
            res += min(int((modM[m] - modM[M-m]) / 2), dupM[m])
        else:
            res += min(int((modM[M-m] - modM[m]) / 2), dupM[M-m])
    elif 2*m == M:
        res += int(modM[m] / 2)
    else:
        pass
print res

Measured memory_bytes: 24464
#include <bits/stdc++.h>
using namespace std;
#define LL long long
char s[15];
int pos[15];
LL num(int l,int r)
{
    LL ans=0;
    //cout<<l<<" "<<r<<endl;
    for(int i=l; i<=r; i++)
    {
        ans=ans*10+(s[i]-'0');
    }
    return ans;
}
LL solve(int n)
{
    int l=-1;
    LL ans=0;
    pos[n]=1;
    for(int i=0; i<=n; i++)
    {
        if(pos[i]!=0)
        {
            ans+=num(l+1,i);
            l=i;
        }
    }
    return ans;
}
int main()
{
    while(cin>>s)
    {
        int n=strlen(s);
        long long ans=0;
        int R= (1<<(n-1));
        //cout<<R<<endl;
        for(int i=0; i<R; i++)
        {
            memset(pos,0,sizeof(pos));
            int tot=0;
            int temp=i;
            while(temp)
            {
                pos[tot++]=temp%2;
                temp=temp/2;
            }
            //cout<<solve(n-1)<<endl;
            ans+=solve(n-1);
            //cout<<ans<<endl;
        }
        printf("%lld\n",ans);
    }
    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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b>>c;
  cout <<max(c-a+b,0);
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,t,k=0,a,b,ans=0;
	cin>>n;
	t=n;
	while(t){
	    k+=t%10;
	    t/=10;
	}
	if(n%k)cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define f first
#define INF (lint )(1e9)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s second
#define endl '\n'
#define pii pair<int,int >
using namespace std;


int main()
{__
     

     string a,b;

     cin>>a>>b;

     a+=a;

std::size_t found = a.find(b);
     if (found!=std::string::npos)
     	cout<<"Yes"<<endl;
     else
     	cout<<"No"<<endl;
      return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Slist();
            Ai.Insert(0, 0);
            Ai.Add(0);
            var Nd = N + 2;
            var dsts = new long[Nd - 1];
            for (var i = 0; i < Nd - 1; ++i)
                dsts[i] = Abs(Ai[i + 1] - Ai[i]);
            var ruid = new long[Nd];
            for (var i = 1; i < Nd; ++i)
                ruid[i] = ruid[i - 1] + dsts[i - 1];
            for (var i = 1; i <= N; ++i)
            {
                var dst = ruid[i - 1] + ruid[Nd - 1] - ruid[i + 1];
                dst += Abs(Ai[i + 1] - Ai[i - 1]);
                WriteLine(dst);
            }
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 38624
#include <stdio.h>

int main (void)
{
int a,b,d=0,r=0;
double f=0;

scanf("%d %d",&a,&b);

d=a/b;
r=a%b;
f=(double)a/b;

printf("%d %d %lf\n",d,r,f);

return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  int k;cin>>k;
  int h[n+10];rep(i,0,n)cin>>h[i];

  int ans=0;
  rep(i,0,n){
    if(h[i]>=k)ans++;
  }

  out(ans);


  return 0;
}


Measured memory_bytes: 640
class UnionFind:
    def __init__(self, n):
        self.r = [-1 for i in range(n)]
    
    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] < self.r[y]:
            temp = x
            x = y
            y = temp
        self.r[x] += self.r[y]
        self.r[y] = x
        return True
    
    def size(self, x):
        return -self.r[self.root(x)]

n, m = map(int, input().split())
UF = UnionFind(n)
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    UF.unite(a, b)

ans = 0
for i in UF.r:
    if i < 0:
        ans += 1

print(ans-1)

Measured memory_bytes: 11156
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=300001;

int main(){
  int A,B,C;
  cin >> A >> B >> C ;
  if(C>=A && C<=B) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define N 305
#define M 8000005
 
#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)
 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
 
#define Mo 1000000007
#define g 3
using namespace std;
int f[N*2][N][N],cnt,i,j,m,n,p,k,a[N*2],vis[N*2];

void jia(int &x,int y){
	x+=y; if (x>=Mo) x-=Mo;
}
int main(){
	cin >> n;
	for (i=1;i<=2*n;++i){
		cin >> a[i];
		if (a[i]!=-1) a[i]=2*n-a[i]+1;
	}
	for (i=1;i<=2*n;i+=2)
		if (a[i]!=-1&&a[i+1]!=-1) vis[a[i]]=vis[a[i+1]]=1;
		else if (a[i]!=-1) vis[a[i]]=2;
			 else if (a[i+1]!=-1) vis[a[i+1]]=2;
				  else cnt++;
		f[0][0][0]=1;
		int P=0,L=0;
		for (i=1;i<=2*n;++i){
			for (j=0;j<=cnt;++j)
				for (k=0;k<=n;++k)
					if (f[i-1][j][k]){
						if (vis[i]==1) f[i][j][k]=f[i-1][j][k];
						else if (vis[i]==2){
								int rest=P-(2*j+L-k);
								if (rest>0) jia(f[i][j][k],f[i-1][j][k]);
								jia(f[i][j][k+1],f[i-1][j][k]);
							}else{
								jia(f[i][j][k],f[i-1][j][k]);
								if (k>0) jia(f[i][j][k-1],1ll*k*f[i-1][j][k]%Mo);
								int rest=P-(2*j+L-k);
								if (rest>0&&cnt>j) jia(f[i][j+1][k],1ll*f[i-1][j][k]*(cnt-j)%Mo);
							}
					}
			if (vis[i]==0) P++;
			if (vis[i]==2) L++;
		}
	cout << f[2*n][cnt][0] << endl;
}


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

const int mod = 1000000007;
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int x,y;
    cin >> x >> y;
    if((x+y)%3){
        cout << 0 << endl;
        return 0;
    }
    int n = (x+y)/3;
    x -= n; y-=n;

    if(x < 0|| y < 0){
        cout << 0 << endl;
        return 0;
    }
    combination c(x+y);
    mint ans = c(x+y,x);
    cout << ans.x << endl;
    
    return 0;
}  

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

int main(){
    ll n;
    cin >> n;
    vector<ll> fl(100010, 0);
    rep(i, 0, n){
        ll a;
        cin >> a;
        fl[a]++;
        if(a > 0) fl[a-1]++;
        fl[a+1]++;
    }
    auto ans = *max_element(fl.begin(), fl.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4032
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int x = vs[0];
			int y = vs[1];

			if ((x + y) % 3 != 0) {
				Console.WriteLine(0);
				return;
			}
			// n + 2m = x
			// 2n + m = y
			// m = y-2n
			// n + 2(y-2n) = x
			// n + 2y - 4n = x
			// 2y - 3n = x
			// 2y - x = 3n
			// m = y - 2n
			int n = (2 * y - x) / 3;
			int m = y - 2 * n;
			System.Diagnostics.Debug.WriteLine($"{n} {m}");
			if (n < 0 || m < 0) {
				Console.WriteLine(0);
				return;
			}
			long ans = Combination(n + m, n, mod);
			Console.WriteLine(ans);
		}

		#region 場合の数 O(r) long Combination(long n, long r, long mod)
		static long Combination(int n, int r, long mod)
		{
			if (n < r) { return 0; }
			if (n == r) { return 1; }
			// nCr = (n * (n-1) * ... * (n-(r-1))) / (r * r-1 * ... * 2 * 1)
			long a = 1;
			long b = 1;
			for (int i = 0; i < r; i++) {
				a = Mod(a * (n - i), mod);
				b = Mod(b * (i + 1), mod);
			}
			return Mod(a * ModInv(b, mod), mod);
		}
		#endregion

		#region 逆元(拡張Euclidの互除法) long ModInv(long a, long mod)
		static long ModInv(long a, long m)
		{
			long b = m, x = 1, y = 0;
			while (b > 0) {
				long t = a / b;
				a = Mod(a, b);
				x = x - t * y;
				(a, b, x, y) = (b, a, y, x);
			}
			x = Mod(x, m);
			return x;
		}
		#endregion

	}
}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x=min(b,d)-max(a,c);
  if (x>0){
    cout << x << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2002,mod=1e9+7;
int n,k,c[N][N];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<=n+1;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for(int i=1;i<=k;i++)
	{
		int ans=1ll*c[k-1][i-1]*c[n-k+1][i]%mod;
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<vector<char>> S(N);
    string s;
    vector<char> s0(10);
    FOR(i,0,N){
        cin>>s;
        FOR(i,0,10){
            s0[i]=s[i];
        }
        VSORT(s0);
        //for(auto e:s0)cout<<e<<' '<<i<<endl;
        S[i]=s0;
    }
    
    VSORT(S);
    
    ll a=1;
    vector<ll> ans={};
    
    FOR(i,0,N-1){
        if(S[i]==S[i+1]) a++;
        else {
            ans.pb(a);
            a=1;
        }
    }
    ans.pb(a);
    
    ll A=0;
    
    FOR(i,0,ans.size()){
        //cout<<ans[i]<<endl;
        if(ans[i]>=2) A+=ans[i]*(ans[i]-1)/2;
    }
    
    /*FOR(i,0,N){
        FOR(j,0,10)cout<<S[i][j]<<endl;
        cout<<endl;
    }*/
    
    cout<<A<<endl;
}

Measured memory_bytes: 6904
class Dice
  def initialize num_dict
    @num=num_dict

    @top=1
    @bottom=6
    @right=3
    @left=4
    @forward=5
    @backward=2

  end
  
  def getTop
    @num[@top]
  end

  def moveE
    temp=@top
    @top=@left
    @left=@bottom
    @bottom=@right
    @right=temp
  end

  def moveW
    temp=@top
    @top=@right
    @right=@bottom
    @bottom=@left
    @left=temp
  end

  def moveN
    temp=@top
    @top=@backward
    @backward=@bottom
    @bottom=@forward
    @forward=temp
  end
  
  def moveS
    temp=@top
    @top=@forward
    @forward=@bottom
    @bottom=@backward
    @backward=temp
  end

  def rotate(char)
    case char
      when "E"
        moveE
      when "W"
        moveW
      when "N"
        moveN
      when "S"
        moveS
    end
  end
end

a,b,c,d,e,f=STDIN.gets.split(" ")
dice=Dice.new({1 => a.to_i , 2 => b.to_i , 3 => c.to_i , 4 => d.to_i , 5 => e.to_i , 6 => f.to_i})

order=STDIN.gets

order.chars do |char|
  dice.rotate(char)
end
puts dice.getTop 

Measured memory_bytes: 8644
/**
 * author:    Ziel
 * created:   11.04.2020 15:18:06
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
inline void cmin(T &a, T b) { a = min(a, b); }
template <class T>
inline void cmax(T &a, T b) { a = max(a, b); }

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int k;
	cin >> k;
	
	vector<ll> v;
	queue<ll> q;
	for (int i = 1; i <= 9; i++) q.push(i);
	
	while (true) {
		ll x = q.front();
		q.pop();

		if (x) v.pb(x);
		if (sz(v) >= k) break;
		if (x % 10 > 0) q.push(x * 10 + (x % 10) - 1);
		q.push(x * 10 + (x % 10));
		if (x % 10 < 9) q.push(x * 10 + (x % 10) + 1);
	}
	
	sort(all(v));
	cout << v[--k];
	
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 2676