akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, s, w);
	OUT(s <= w ? "unsafe" : "safe");
}


Measured memory_bytes: 3648
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

analyze :: Int -> Int -> VU.Vector Int -> [Int] -> Int
analyze x n ys []     = x + (vectorToTen $ VU.drop n ys)
analyze x n ys (z:zs) = analyze (x+(vectorToTen $ VU.slice n (z-n) ys)) z ys zs

main :: IO ()
main = do
    s <- getLine
    let ys = VU.fromList $ map digitToInt s 
    print $ if length s == 1 then digitToInt $ head s else sum $ map (analyze 0 0 ys) (powerSet [1..length s -1])


vectorToTen :: VU.Vector Int -> Int
vectorToTen xs = if VU.null xs then 0 else 10*(vectorToTen $ VU.init xs) + VU.last xs

powerSet :: [a] -> [[a]]
powerSet = filterM (\x -> [True,False])

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


main()
{
   int n,l,ans = 0 ,res = 1e9,fin = 0;
   cin>>n>>l;

   for(int i = 1; i<=n; i++){
        ans+=l+i-1;
   }
   for(int i =1; i<=n; i++){
    int cur = ans - (l+i-1);
    if(res > abs(cur-ans)){
        fin = cur;
        res = abs(cur-ans);
    }
   }
   cout<<fin<<endl;




    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define INF 10000000000000001
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long> 
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 100005
#define sz(x) (ll)x.size()
#define ins insert
#define mp make_pair
//typedef  long long int in;
typedef long long ll;
typedef long double ld;
using namespace std;

inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}


signed  main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3648
import heapq
n, m = map(int, input().split())

graph = [set() for _ in range(n)]
side = dict()
ans = [0 for _ in range(m + 1)]
for i in range(m):
    a, b, c = map(int, input().split())
    t = (a - 1, b - 1, c)
    side[i] = t
    graph[a-1].add(i)
    graph[b-1].add(i)

for j in range(n):
    D = [(0, 0, j, m), ]
    heapq.heapify(D)
    done = [True for _ in range(n)]

    while D:
        d = heapq.heappop(D)
        if done[d[2]]:
            done[d[2]] = False
            ans[d[3]] = 1

            for i in graph[d[2]]:
                a, b, c = side[i]
                if b == d[2]:
                    a, b = b, a
                if done[b]:
                    heapq.heappush(D, (d[0] + c, ans[i], b, i))

print(m - (sum(ans) - 1))


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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;
bool visited[MAXN];
vector<int> grf[MAXN];

int edis(string s,string t){
	n=s.length(); m=t.length();
	int dp[n+1][m+1];
	memset(dp,0,sizeof dp);
	for(int i=1; i<=n; i++)
		dp[i][0]=i;
	for(int i=1; i<=m; i++)
		dp[0][i]=i;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(s[i-1]==t[j-1]){
				dp[i][j] = dp[i-1][j-1];
			}
			else{
				dp[i][j] = 1+min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]});
			}
		}
	}
	return dp[n][m];
}

signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s,t; cin>>s>>t;
	cout<< edis(s,t); br;

}


Measured memory_bytes: 13412
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
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 { 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; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    a.erase(unique(a.begin(), a.end()), a.end());

    ull ans = 1000;
    int min = a[0];
    int min_then = 0;
    int max = 0;
    int max_then = 0;
    int dir = 0;
    ull num = 0;
    for (int i = 1; i < a.size(); i++) {
        if (a[i] > a[i - 1]) {
            if (dir == 0) {
                num = ans / a[i - 1];
                ans -= a[i - 1] * num;
            }
            dir = 1;
        }
        else {
            if (dir == 1) {
                ans += num * a[i - 1];
                num = 0;
            }
            dir = 0;
        }
    }

    ans += num * a[a.size() - 1];

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int A,B,C;
    cin >> A >> B >> C;
    cout << ((1 * (A + B) >= C) ? "Yes" : "No") << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n, d;
    cin>>n>>d;
    d=d*d;
    ll ans=0;
    rep(i,0,n) {
        ll x, y;
        cin>>x>>y;
        if (x*x+y*y<=d) {
            ans++;
        }
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int N,X,T,a;
    scanf("%d%d%d",&N,&X,&T);
    if(N % X == 0){
        a = N / X;
    }else{
        a = N / X + 1;
    }
    
    printf("%d",a * T);
}


Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a >= 13) {
            System.out.println(b);
        } else if (a >= 6 && a <= 12) {
            System.out.println(b / 2);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 23764
def II(): return int(input())
N=II()
d=2
ans=0
while d*d<=N:
  if N%d!=0:
    d+=1
    continue
  z=d
  while N%z==0:
    ans+=1
    N//=z
    z*=d
  while N%d==0:
    N//=d
if N!=1:
  ans+=1
print(ans)

Measured memory_bytes: 9080
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


div = make_divisors(N)
total = 0

for num in div:
    if num == 1:
        continue

    if N // (num - 1) == N % (num - 1):
        total += (num - 1)

print(total)


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
const int MX=3e5+2;
int N, M, k;
int arr[MX];
int main()
{
    int curt=0, curx=0, cury=0, ok=1;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        int t, x, y;
        cin>>t>>x>>y;
        int tt=abs(curt-t);
        int d=abs(curx-x)+abs(cury-y);
        if(abs(d-tt)&1 || d > tt) ok=0;
        curx=x;
        cury=y;
        curt=t;
    }
    if(ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

int main(){
	int x; read(x);
	printf("%d\n", 1-x);
	return 0;
}

Measured memory_bytes: 3720
n=int(input())
c=[0]*4
for i in range(n):
    s=input()
    if s=='AC':
        c[0]+=1
    elif s=='WA':
        c[1]+=1
    elif s=='TLE':
        c[2]+=1
    else:
        c[3]+=1
print('AC x '+str(c[0]))
print('WA x '+str(c[1]))
print('TLE x '+str(c[2]))
print('RE x '+str(c[3]))

Measured memory_bytes: 9220
using System;class P{static void Main(string[] args){bool a=false;int b,c,d,e;int[] f,g=new int[4],h=new int[4],i=new int[]{10,50,100,500};while(true){b=int.Parse(Console.ReadLine());if(b==0){break;}if(!a){a=!a;}else{Console.WriteLine();}c=0;f=Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);for(e=3;e>=0;e--){c+=f[e]*i[e];}d=c-b;for(e=3;e>=0;e--){g[e]=d/i[e];d-=g[e]*i[e];h[e]=f[e]-g[e];}for(e=0;e<4;e++){if(h[e]>0){Console.WriteLine("{0} {1}",i[e],h[e]);}}}}}


Measured memory_bytes: 9308
using System;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var num = ToInt32(input[0]);
        var colorFig = ToInt32(input[1]);
        WriteLine(colorFig * Math.Pow(colorFig - 1, num - 1));

    }
}



Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int len = s.size();
    for(int i=0;i < len;++i){
        int x = s[i] - 'A';
        x = (x+n)%26; 
        
        cout << (char)('A'+x)  << (i == len-1 ? "\n" : "");
    }

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long max = 0;
        long res = 0;
        for (int i = 0; i < a.Length; i++)
        {
            max = Max(a[i], max);
            res += max - a[i];
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 47952
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W;
    cin>>H;
    cin>>x;
    cin>>y;
    cin>>r;
if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
    cout<<"Yes";
}
else {
    cout<<"No";
}
cout<<endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<ll,P> State;

const ll INF = 1001001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Edge{
    int to, cost;
};

ll dl[200][200], ds[200][200], dp[1000][200];
int N, M, R;
int Z[1000];

int main(){
    while(std::cin >> N >> M, N){
        
        REP(i, 200){
            REP(j, 200){
                if(i == j){
                    dl[i][j] = 0;
                    ds[i][j] = 0;
                }else{
                    dl[i][j] = INF;
                    ds[i][j] = INF;
                }
            }
        }

        REP(i, M){
            int from, to, cost;
            char c;
            std::cin >> from >> to >> cost >> c;
            from--; to--;

            if(c == 'L'){
                dl[from][to] = std::min(dl[from][to], static_cast<ll>(cost));
                dl[to][from] = std::min(dl[to][from], static_cast<ll>(cost));
            }else if(c == 'S'){
                ds[from][to] = std::min(ds[from][to], static_cast<ll>(cost));
                ds[to][from] = std::min(ds[to][from], static_cast<ll>(cost));
            }
        }

        REP(k, N){
            REP(i, N){
                REP(j, N){
                    dl[i][j] = std::min(dl[i][j], dl[i][k] + dl[k][j]);
                    ds[i][j] = std::min(ds[i][j], ds[i][k] + ds[k][j]);
                }
            }
        }

        std::cin >> R;
        REP(i, R){
            std::cin >> Z[i];
            Z[i]--;
        }

        REP(i, 1000){
            REP(j, 200){
                dp[i][j] = INF;
            }
        }
        dp[0][Z[0]] = 0;
        
        REP(i, R-1){
            REP(j, N){
                // A->陸->C->海->D->陸->B
                REP(k, N){
                    dp[i+1][j] = std::min(dp[i+1][j], dp[i][k] + dl[Z[i]][k] + ds[k][j] + dl[j][Z[i+1]]);
                }
                // A->陸->B
                dp[i+1][j] = std::min(dp[i+1][j], dp[i][j] + dl[Z[i]][Z[i+1]]);
            }
        }

        ll res = INF;
        REP(i, N){
            res = std::min(res, dp[R-1][i]);
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 3348
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	vi a(3);
	rep(i, 3) cin >> a[i];
	sort(rall(a));
	int ans = 0;
	ans += abs(a[0] - a[1]);
	ans += abs(a[1] - a[2]);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int num;

	cin >> num;
	int i = num;
	int sum = 0;
	while (i > 0) {
		sum += i % 10;
		i /= 10;
	}

	if (num % sum == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;

#define PAD(n, div) (n+div-1)/div

unsigned long long cnt_div(unsigned long long from, unsigned long long to, unsigned long long div)
{
  unsigned long long ans = to/div - PAD(from, div) + 1;
  return ans;
}

int main(int argc, char* argv[])
{
    unsigned long long A, B, C, D;
    cin >> A >> B >> C >> D;

    unsigned long long div_c = cnt_div(A, B, C);
    unsigned long long div_d = cnt_div(A, B, D);
    unsigned long long div_both = cnt_div(A, B, C*D/__gcd(C,D));

    cout << B-A+1-(div_c+div_d-div_both) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)
	//i=m -> n(降順)

int main(){
  LL a,b,n,ans;
  cin >> a >> b >> n;
  
  if(b > n){
    ans = ((a*n)/b) - a*(n/b);
  }
  else if(b == 1){
    ans = 0;
  }
  else{
    ans = a-1-(a/b);
  }
  
  cout << ans << endl;
  
  return 0;
}


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

int main(){
	map<char,string> t;
	map<string,char> t_;
	t['A'] = "00000";
	t['B'] = "00001";
	t['C'] = "00010";
	t['D'] = "00011";
	t['E'] = "00100";
	t['F'] = "00101";
	t['G'] = "00110";
	t['H'] = "00111";
	t['I'] = "01000";
	t['J'] = "01001";
	t['K'] = "01010";
	t['L'] = "01011";
	t['M'] = "01100";
	t['N'] = "01101";
	t['O'] = "01110";
	t['P'] = "01111";
	t['Q'] = "10000";
	t['R'] = "10001";
	t['S'] = "10010";
	t['T'] = "10011";
	t['U'] = "10100";
	t['V'] = "10101";
	t['W'] = "10110";
	t['X'] = "10111";
	t['Y'] = "11000";
	t['Z'] = "11001";
	t[' '] = "11010";
	t['.'] = "11011";
	t[','] = "11100";
	t['-'] = "11101";
	t['\''] = "11110";
	t['?'] = "11111";
	t_["101"] = ' ';
	t_["000000"] = '\'';
	t_["000011"] = ',';
	t_["10010001"] = '-';
	t_["010001"] = '.';
	t_["000001"] = '?';
	t_["100101"] = 'A';
	t_["10011010"] = 'B';
	t_["0101"] = 'C';
	t_["0001"] = 'D';
	t_["110"] = 'E';
	t_["01001"] = 'F';
	t_["10011011"] = 'G';
	t_["010000"] = 'H';
	t_["0111"] = 'I';
	t_["10011000"] = 'J';
	t_["0110"] = 'K';
	t_["00100"] = 'L';
	t_["10011001"] = 'M';
	t_["10011110"] = 'N';
	t_["00101"] = 'O';
	t_["111"] = 'P';
	t_["10011111"] = 'Q';
	t_["1000"] = 'R';
	t_["00110"] = 'S';
	t_["00111"] = 'T';
	t_["10011100"] = 'U';
	t_["10011101"] = 'V';
	t_["000010"] = 'W';
	t_["10010010"] = 'X';
	t_["10010011"] = 'Y';
	t_["10010000"] = 'Z';

	string s;
	while( getline(cin,s) ){
		string s_;
		for(int i=0 ; i < s.size() ; i++ ){
			s_ += t[ s[i] ];
		}
		string ans,tmp;
		for(int i=0 ; i < s_.size() ; i++ ){
			tmp.push_back( s_[i] );
			if( t_.count(tmp) ){
				ans.push_back( t_[tmp] );
				tmp = "";
			}
		}
		cout << ans << endl;
	}
}

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

int saigo(int n) {
  return n%10;
}

int saisyo(int n) {
  int a;
  while(n != 0) {
    a = n%10;
    n = n/10;
    
  }
  return a;
}
    
 
  

  
 

int main() {
  int N;
  cin >> N;
  map<pair<int,int>,int> mp;   //((saisyo、saigo),何個あるか)
  
  for (int i = 1;i <= N; i++) {
    pair<int,int> p;
    p = make_pair(saisyo(i),saigo(i));
    //cout << saisyo(i) << saigo(i) << endl;
    mp[p]++;
  }   
  
  int ans = 0;
  
  for (int i = 1; i <=9;i++) {    //最初の文字(左)　最後の文字（右）
    for (int j = 1;j <= 9; j++) { //最後の文字（左）最後の文字（右）
      pair<int,int> a,b;
      a = make_pair(i,j);
      b = make_pair(j,i);
      ans += mp[a] * mp[b];
    }
  }
  cout << ans << endl;
}
   
      
  
  
  


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int a,b,c,d,p,x,y;
    cin >> a >> b >> c >> d >> p;
    x=p*a;
    if(p<=c){
        y=b;
        if(x<y) cout << x << endl;
        else    cout << y << endl;
    }           
    else{
        y=b+(p-c)*d;
        if(x<y) cout << x << endl;
        else    cout << y << endl;
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(26);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a, int day) {
  int sum = 0;
  vi last(26, 0);
  for (int i = 0; i <= day; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i + 1;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j] + 1);
    }
  }
  return sum;
  // return max((int)1e6 + sum, 0);
}

int simulate(vi a) { return simulate(a, D - 1); }

void solve() {
  int best = simulate(ans);

  //
  {
    vi a = ans;
    for (int i = 0; i < D; i++) {
      int bst = -INF, idx = 0;
      for (int j = 0; j < 26; j++) {
        a[i] = j;
        int x = simulate(a, i);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }
    if (best < simulate(a)) ans = a, best = simulate(ans);
  }

  //
  srand((unsigned)time(NULL));
  int loop = 0;  // 20;
  bool lastIsNew = true;
  while (loop--) {
    vi a = ans;
    if (!lastIsNew) {
      int change = D / 2;
      while (change--) {
        a[rand() % D] = rand() % 26;
      }
    }

    for (int i = 0; i < D; i++) {
      vi b = a;
      int idx = 0, bst = simulate(b);
      for (int j = 0; j < 26; j++) {
        b[i] = j;
        int x = simulate(b);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }

    lastIsNew = false;
    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
      lastIsNew = true;
    }
  }
}

int main() {
  input();
  ans = vi(D, 0);
  solve();
  output();
}


Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int n, m;
	cin >> n >> m;
	pll p[N];
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	priority_queue<ll> que;
	int i = 0;
	ll ans = 0;
	for(int remain = 1; remain <= m; remain++) {
		while(i < n && p[i].first <= remain) {
			que.push(p[i].second);
			i++;
		}
		if(que.empty()) continue;
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;	
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

ll sum(ll n, ll b){
	ll ans = 0;
	if(b <= 1)return -1;
	while(n > 0){
		ans += n % b;
		n /= b;
	}
	return ans;
}

int main(){
	IOS;
	ll n, s;
	cin >> n >> s;
	if(n == s){
		dump(n + 1);
		return 0;
	}
	if(n < s){
		dump(-1);
		return 0;
	}
	for(ll i = 2;(i * i)<= n;i++){
		if(sum(n,i) == s){
			dump(i);
			return 0;
		}
	}
	ll ans = INF;
	for(ll p = 1;p * p < n;p++){
		ll b = (n - s) / p + 1;
		if(sum(n, b) == s)ans = min(ans, b);
	}
	if(ans == INF)dump(-1);
	else dump(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    rep(i, N + 1) { cin >> A[i]; }

    rep(i, N) { cin >> B[i]; }

    ll ans = 0;
    rep(i, N) {
        if (A[i] > B[i])
            A[i] -= B[i], ans += B[i], B[i] = 0;
        else {
            B[i] -= A[i], ans += A[i], A[i] = 0;
            if (A[i + 1] > B[i])
                ans += B[i], A[i + 1] -= B[i], B[i] = 0;
            else
                B[i] -= A[i + 1], ans += A[i + 1], A[i + 1] = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a[3][3];
    for(long long i=0;i<3;i++){
        for(long long j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    long long n;
    cin>>n;
    long long b[3][3]={0};
    for(long long i=0;i<n;i++){
        long long c;
        cin>>c;
        for(long long j=0;j<3;j++){
            for(long long k=0;k<3;k++){
                if(a[j][k]==c){
                    b[j][k]=1;
                }
            }
        }
    }
    long long ans=0;
    if(b[0][0]==1&&b[0][1]==1&&b[0][2]==1){
        ans=1;
    }
    if(b[1][0]==1&&b[1][1]==1&&b[1][2]==1){
        ans=1;
    }
    if(b[2][0]==1&&b[2][1]==1&&b[2][2]==1){
        ans=1;
    }
    if(b[0][0]==1&&b[1][0]==1&&b[2][0]==1){
        ans=1;
    }
    if(b[0][1]==1&&b[1][1]==1&&b[2][1]==1){
        ans=1;
    }
    if(b[0][2]==1&&b[1][2]==1&&b[2][2]==1){
        ans=1;
    }
    if(b[0][0]==1&&b[1][1]==1&&b[2][2]==1){
        ans=1;
    }
    if(b[0][2]==1&&b[1][1]==1&&b[2][0]==1){
        ans=1;
    }
    if(ans==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P.append([int(i) for i in input().split()])
P.append(P[0])
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7716
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	if (N<4){
		cout<<"No"<<endl;
		return 0;
	}
	if (N%4==0 || N%7==0){
		cout<<"Yes"<<endl;
		return 0;
	}
	for (int i=0;i<=N;i++){
		for (int j=0;j<=N;j++){
			if (i*4+j*7==N){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0 ; i<(n) ;i++)
bool go(int a,int b,int k){
	int n = 0;
	while(k>0){
		n += k%10;
		k /=10;
	}

	return (k>=a && k<=b);
}

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

	for(int i=0 ; i<=n ;i++){
		for(int j=0 ; j<=n ;j++){
			int k = n-i-j;
			if(k>=0){
			   if((i*10000 + j*5000 + (k)*1000) == x && n==(i+j+k)){
					cout << i << " " << j << " " << k << endl;
					return 0;
			} 
			}
				
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int a;
int b;
int c;
int N;
int i;

int main(void){
	N = 0;
	scanf("%d %d %d",&a,&b,&c);
	if(a > b){
		printf("error\n");
	}
	for(i=a;i<=b;i++){
		if(c % i == 0){
			N++;
		}
	}
	printf("%d\n",N);
	return 0;
}

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

int main(){
    int N,K,total=0;
    cin >> N >> K;
    int nakama[N];
    rep(i,N) cin >> nakama[i];
    rep(i,N){
        if(nakama[i]>=K) total++;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cstdlib>
#include <typeinfo>
#include <list>
#include <stdio.h>
#include <math.h>

using namespace std;

int MAX_R = 10;
int MAX_C = 10000;

int main() {
  int gril[MAX_R][MAX_C];
  int r, c;

  while(1){
    scanf("%d %d", &r, &c);
    if(r == 0 && c == 0) return 0;
    for (int i = 0; i < r; i++)
      for (int j = 0; j < c; j++)
        scanf("%d", &gril[i][j]);

    int ans = 0;
    for (int mask = 0; mask < (1 << r); mask++) {
      vector<int> sum_of_0(c, 0);

      for (int r_pos = 0; r_pos < r; r_pos++) {
        if (mask & (1 << r_pos)){
          for (int i = 0; i < c; i++) if(gril[r_pos][i] == 1) sum_of_0[i]++;
        }else{
          for (int i = 0; i < c; i++) if(gril[r_pos][i] == 0) sum_of_0[i]++;
        }
      }

      int tmp = 0;
      for (int i = 0; i < c; i++) tmp += max(sum_of_0[i], r - sum_of_0[i]);
      ans = max(ans, tmp);
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>

int calcMaxSum(int amount_set);

int main()
{
    while (true) {
        int amount_set;
        std::cin >> amount_set;
        if(amount_set == 0) {
            break;
        }
        std::cout << calcMaxSum(amount_set) << std::endl;
    }

    return 0;
}

int calcMaxSum(int amount_set)
{
    const int MAXNUMBER = 100000;//??\????????????????????§??????

    int *data;
    data = new int[amount_set + 1];
    int *sum = new int[amount_set + 1];

    sum[0] = 0;//???????????????????????????????????´??????sum[0]??§??????

    std::cin >> data[1];//?????????????????±???
    sum[1] = data[1];//?????????????????????

    for (int number = 2; number <= amount_set; number++) {
        std::cin >> data[number];//????????????????????????
        sum[number] = sum[number - 1] + data[number];// ????????´??°
    }

    int max = -MAXNUMBER;//????????????????????¨??¨-MAXNUMBER???????????????????????§???????????????????????????????°????

    for (int number_big = 1; number_big <= amount_set; number_big++) {
        for (int number_small = 0; number_small < number_big; number_small++) {
            if (sum[number_big] - sum[number_small] > max) {
                max = sum[number_big] - sum[number_small];
            }
        }
    }
    delete [] data;
    delete [] sum;

    return max;

}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long N;
void dfs(long long t, int &ans, int cnt){
    if(t <= N && cnt == 7) ans++;
    else if(t > N) return;
    t *= 10;
    dfs(t + 3, ans, cnt | (1 << 0));
    dfs(t + 5, ans, cnt | (1 << 1));
    dfs(t + 7, ans, cnt | (1 << 2));
}
int main(){
    cin >> N;
    int ans = 0;
    dfs(3, ans, (1 << 0));
    dfs(5, ans, (1 << 1));
    dfs(7, ans, (1 << 2));
    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long count = 0;
        int base = 0;
        int now = sc.nextInt();
        for (int i = 0; i < N-1; i++) {
            int Ai = sc.nextInt();
            base = Ai;
            if (Ai < now) {
                base = now;
                count += (now-Ai);
            }
            now = base;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 58532
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#include <unordered_map>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define all(s) s.begin(), s.end()
#define fo(i, start, finish) for(int i = start; i <= finish; i ++)
#define y1 kdfjsalsdkf

const long long MXN = 1e5 + 10;
const long long MNN = 5e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, k, cnt[MNN][MNN], ans = OO, u[MNN], v[MNN];
vector<int> g[MNN];

void dfs(int x, int p, int batya, int lvl){
    for(int i : g[x]){
        if (i == p) continue;
        dfs(i, x, batya, lvl + 1);
    }
    if(lvl > k / 2){
        cnt[batya][0]++;
    }
}

int main(){
    ios;
    cin >> n >> k;
    for(int i = 1; i < n; i++){
        cin >> u[i] >> v[i];
        g[u[i]].pb(v[i]);
        g[v[i]].pb(u[i]);
    }
    if(k % 2 == 0){
        for(int i = 1; i <= n; i++){
            dfs(i, 0, i, 0);
            ans = min(ans, cnt[i][0]);
        }
    } else {
        for(int i = 1; i < n; i++){
            cnt[u[i]][0] = 0;
            cnt[v[i]][0] = 0;
            dfs(u[i], v[i], u[i], 0);
            dfs(v[i], u[i], v[i], 0);
            ans = min(ans, cnt[u[i]][0] + cnt[v[i]][0]);
        }
    }
    cout << ans;
    return 0;
}


//
//
//


Measured memory_bytes: 39936
#include <cstdio>

typedef long long i64;

const int N = 2000 + 10, M = 200000 + 10, MOD = 1000000007;

int f[2 * N][2 * N], g[2 * N][2 * N];

int n, a[M], b[M];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= n; ++i) ++f[N - a[i]][N - b[i]];
  for (int i = 1; i < 2 * N; ++i)
    for (int j = 1; j < 2 * N; ++j)
      f[i][j] = ((i64)f[i - 1][j] + f[i][j - 1] + f[i][j]) % MOD;
  g[0][0] = 1;
  for (int i = 0; i < 2 * N; ++i)
    for (int j = !i; j < 2 * N; ++j)
      g[i][j] = ((i ? g[i - 1][j] : 0) + (j ? g[i][j - 1] : 0)) % MOD;
  int ans = 0;
  for (int i = 1; i <= n; ++i) (ans += f[N + a[i]][N + b[i]]) %= MOD;
  for (int i = 1; i <= n; ++i) (ans -= g[2 * a[i]][2 * b[i]]) %= MOD;
  ans = (MOD + 1LL) / 2 * ans % MOD;
  printf("%d\n", (ans + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 128128
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""

n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
    s, t = list(map(int, input().split()))
    adj[s].append(t)
    adj[t].append(s)
#print(*adj, sep='\n')
def dfs(u, color):
    if v[u] > 0:
        return 0
    stack.append(u)
    while stack:
        current = stack[-1]
        v[current] = color
        #print(u, current, stack)
        flag = 0
        for k in adj[current]:
            if v[k] > 0:
                continue
            stack.append(k)
            flag = 1
        if flag == 0:
            stack.pop()
    return 1

color = 1
for start in range(n):
    if dfs(start, color) == 1:
        color += 1
#for i in range(n):        
#    print('color:{} for node:{}'.format(i, v[i]))

q = int(input())
for i in range(q):
    s, t = list(map(int, input().split()))
    if v[s] == v[t]:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 23732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
void solve(){
    int n,ans=0,c1=0,c2=0;
    cin>>n;
    vector<int>k(n),l(n),r(n);
    vector<int>v1[n+2],v2[n+2];
    rep(i,n){
        cin>>k[i]>>l[i]>>r[i];
        if(l[i]>r[i])c1++;
        if(l[i]<r[i])c2++;
    }
    rep(i,n){
        if(l[i]>r[i]){
            v1[min(k[i],c1)].pb(l[i]-r[i]);
            ans+=l[i];
        }
        if(l[i]<r[i]){
            v2[max(n-c2+1,k[i]+1)].pb(r[i]-l[i]);
            ans+=r[i];
        }
        if(l[i]==r[i])ans+=l[i];
    }
    priority_queue<int,vector<int>,greater<int>>q;
    for(int i=1;i<=c1;i++){
        for(int j:v1[i])q.push(j);
        while(q.size()>i){
            ans-=q.top();
            q.pop();
        }
    }
    while(!q.empty())q.pop();
    for(int i=n+1;i>=n-c2+1;i--){
        for(int j:v2[i])q.push(j);
        while(q.size()>n-i+1){
            ans-=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int t;cin>>t;while(t--)solve();
    return 0;
}


Measured memory_bytes: 22016
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<cctype>

using namespace std;

int main(){
  string s;
  cin>>s;
  bool frag=true;
  int n=s.size();
  int ccount=0;
  int cp;
  for (int i=2;i<=n-2;i++){
    if (s[i]=='C') {
      ccount++;
      cp=i;
    }
  }
  if (ccount!=1) frag=false;
  for (int i=0;i<n && frag;i++){
    if (i==0) {
      if (s[i]!='A') frag=false;
    }
    else if (i!=cp){
      if (isupper(s[i])) frag=false;
    }
  }
  if (frag) cout<<"AC";
  else cout<<"WA";
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

        // 空白で分割してaとbを定義

        int a = scanner.nextInt();

        int b = scanner.nextInt();

      System.out.println(a * b + " " + 2 * (a + b));
 }
}


Measured memory_bytes: 26100
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n ;
	cin >> n ;
	int arr[n] ;
	for(int i = 0 ; i < n ; i++) cin >> arr[i] ;
	multiset < int > m ;
	m.insert(arr[0]) ;
	// cout << *m.begin() ;
	for(int i = 1 ; i < n ; i++){
		if(arr[i] > *m.begin()){
			auto it = m.lower_bound(arr[i]) ;
			it-- ;
			m.erase(it) ;
			m.insert(arr[i]) ;
		}
		else m.insert(arr[i]) ;
	}
	cout << m.size() ;
}

Measured memory_bytes: 5376
s = input()
mp_ok = int(s[0:2]) <= 12 and int(s[0:2]) > 0
mn_ok = int(s[2:]) <= 12 and int(s[2:]) > 0

if mp_ok and mn_ok:
    print("AMBIGUOUS")
elif mp_ok:
    print("MMYY")
elif mn_ok:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
// ------------------------------------
// Date:2018/ 3/24
// Problem:Digits in Multiplication c.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__)

static const int INF = 1e9 + 1;
static const int MAX_N = 1;

int check(ll a)
{
  string tmp = to_string(a);
  return tmp.size();
}

int main()
{
  LCIN(N);
  // 高々√N
  int ans = INF;
  FOR(i, 1, sqrt(N) + 1) {
    if (N % i == 0) {
      ans = min(ans, max(check(N / i), check(i)));
      // debug(N);
      // debug(N / i);
      // debug(ans);
    }
  }

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



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B){
    if(A < 6) cout << 0 << endl;
    else if(A < 13) cout << B/2 << endl;
    else cout << B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256