akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define INFTY (2e+9)

using namespace std;

struct Card{
	char mark;
	int num;
};

int partition(Card A[], int p, int r){
	int x = A[r].num, i = p - 1;
	Card tmp;
	FOR(j, p, r){
		if (A[j].num <= x){
			i++;
			tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;
	return i + 1;
}

/*
1 quicksort(A, p, r)
2   if p < r
3     q = partition(A, p, r)
4     quickSort(A, p, q-1)
5     quickSort(A, q+1, r)
*/

void quicksort(Card A[], int p, int r){
	if (p < r){
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

int merge(Card A[], int left, int mid, int right){
	int c = 0, n1, n2;
	n1 = mid - left;
	n2 = right - mid;
	Card *L, *R;
	L = new Card[n1 + 1];
	R = new Card[n2 + 1];
	REP(i, n1){
		L[i] = A[left + i];
	}
	REP(i, n2){
		R[i] = A[mid + i];
	}
	L[n1].num = INFTY;
	R[n2].num = INFTY;
	int i = 0, j = 0;
	FOR(k, left, right){
		if (L[i].num <= R[j].num){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
		c++;
	}
	delete[] L;
	delete[] R;
	return c;
}

int mergeSort(Card A[], int left, int right){
	int c = 0, mid;
	if (left + 1 < right){
		mid = (left + right) / 2;
		c += mergeSort(A, left, mid);
		c += mergeSort(A, mid, right);
		c += merge(A, left, mid, right);
	}
	return c;
}

int main(){
	int n;
	Card A[100000], B[100000];

	scanf("%d", &n);
	
	REP(i, n){
		getchar();
		scanf("%c %d", &A[i].mark, &A[i].num);
		B[i] = A[i];
	}

	quicksort(A, 0, n - 1);
	mergeSort(B, 0, n);

	bool f = true;
	REP(i, n){
		if (B[i].mark != A[i].mark){
			f = false;
		}
	}
	if (f){
		printf("Stable\n");
	}
	else{
		printf("Not stable\n");
	}
	REP(i, n){
		printf("%c %d\n", A[i].mark, A[i].num);
	}

	return 0;
}


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


using namespace std;
double pi=3.14159265358979323846264338;
long long sum;
long long ma;
long long n,k,st;
long long pr(long long a, long long b){
	long long k=1;
	if(b==0)return 1;
	
	for(int i=0;i<b;i++)k=k*10;
	return k;
}
long long arr[200001];
bool che(long long a){
	long long cur=0;
	for(int i=0;i<n;i++){
		cur+=(arr[i]+a-1)/(a)-1;
	}
	if(cur<=k)return true;
	return false;
}
int main(){
	sum=0;
	ma=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		long long cur;
		cin>>cur;
		arr[i]=cur;
		ma=max(ma,cur);
		sum+=cur;
	}
	st=(sum+n+k-1)/(n+k);
	//cout<<st<<endl;
	long long ls=st;
	long long to=ma;
	long long mid;
	while(ls<=to){
		mid=(ls+to)/2;
		if(!che(mid))ls=mid+1;
		else to=mid-1;
	}
	//cout<<ls<<" "<<to<<endl;
	for(int i=max(1LL,ls-4);i<=to+4;i++){
		if(che(i)){cout<<i<<endl;return 0;}
	}
			
	return 0;
}

Measured memory_bytes: 5124
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int com(int s) {
  int count = 0;
  while(s > 0) {
    if(s % 10 == 2) count++;
    s /= 10;
  }
  return count;
}
int main() {
  int t;
  cin >> t;
  cout << com(t) << endl;
  return 0;
}

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

int main() {
    long long L[90];
    L[0] = 2LL;
    L[1] = 1LL;
    int N;
    cin >> N;
    for(int i = 2; i <= N; i++) {
        L[i] = L[i - 2] + L[i - 1];
    }
    cout << L[N] << endl;
    return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int x, t; cin >> x >> t;
    cout << max(0, x-t) << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	ll x; cin >> x;
	ll a = x / (6 + 5);
	ll b = x % (6 + 5);
	if (b == 0)cout << a*2 << endl;
	else if (b <= 6)cout << a*2 + 1 << endl;
	else cout << a*2 + 2 << endl;
}

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


int main() {
 vector <char>P(3);
 vector <char>R(3);
 int count=0;
 for(int i=0;i<3;i++){
	 cin>>P.at(i);
 }
 for(int i=0;i<3;i++){
 	 cin>>R.at(i);
  }
 for(int i=0;i<3;i++){
  	if(P.at(i)==R.at(i)){
  		count++;
  	}
   }
 cout<<count<<endl;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
  val a = (1..5).map { readLine()!!.toInt() }.toTypedArray()
  val k = readLine()!!.toInt()
  println(if (solve(a, k)) "Yay!" else ":(")
}

fun solve(a:Array<Int>, k:Int) : Boolean {
  for ((index, value) in a.withIndex()) {
    for (i in index..a.size - 1) {
      if (a[index] - a[i] > k || a[i] - a[index] > k) {
        return false
      }
    }
  }
  return true
}


Measured memory_bytes: 35796
def is_prime(x):
    if x == 2:
        return(True)
    
    if x < 2 or (x % 2) == 0:
        return(False)
    
    for i in range(3, int(x**(1/2))+1):
        if x % i == 0:
            return(False)
    
    return(True)

N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if is_prime(a):
        count += 1

print(count)


Measured memory_bytes: 5656
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#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 <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endN "\n"

bool solve(){
  string s;cin>>s;
  ll k;cin>>k;
  rep(i,s.size()){
    if(s[i]=='a')continue;
    if(('z'+1-s[i])<=k){
      k-=('z'+1)-s[i];
      s[i]='a';
    }
  }
  //最後
  s.back()=((s.back()-'a')+k)%26+'a';
  cout<<s<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    ll N, K;        //ll
    cin >> N >> K;
    ll n = 0;
    ll sum_min = 0, sum_max = 0;

    for(ll i = K; i <= N + 1; i++) {
        sum_min = (0 + i - 1) * i / 2;
        sum_max = (N + N - i + 1) * i / 2;
        ll a = sum_max - sum_min + 1;
        n += a;
    }
    int ans = 0;
    ans = n % ll(1e9 + 7);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>

using namespace std;

struct Node {
    int a, b;

    bool operator < (const Node& x) const {
        return a < x.a || (a == x.a && b < x.b);
    }
};

int n, ma, mb, a, b, c, ans;
int dp[403][403];

int main() {
    while(3 == scanf("%d%d%d", &n, &ma, &mb)) {
        memset(dp, 0x3f, sizeof(dp));
        dp[0][0] = 0;
        while(n-- > 0) {
            scanf("%d%d%d", &a, &b, &c);
            for(int i = 400 - a; i >= 0; --i) {
                for(int j = 400 - b; j >= 0; --j) {
                    dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c);
                }
            }
        }
        ans = 0x3f3f3f3f;
        a = ma;
        b = mb;
        while(a <= 400 && b <= 400) {
            if(a * mb == b * ma) {
                ans = min(ans, dp[a][b]);
            }
            a += ma;
            b += mb;
        }
        printf("%d\n", ans == 0x3f3f3f3f ? -1 : ans);
    }
    return 0;
}


Measured memory_bytes: 768
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func abs(x int) int {
	if x < 0 {
		return -1 * x
	} else {
		return x
	}
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

type History struct {
	Cs  int
	Ps  int
	Sum int
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()

	ps := make([]int, n+1)
	cs := make([]int, n+1)
	for i := 1; i <= n; i++ {
		ps[i] = nextInt()
	}
	for i := 1; i <= n; i++ {
		cs[i] = nextInt()
	}

	ans := -10000000000
	for i := 1; i <= n; i++ {
		x := i
		scores := []int{}
		total := 0
		for {
			x = ps[x]
			scores = append(scores, cs[x])
			total += cs[x]
			if x == i {
				break
			}
		}
		now := 0
		t := 0
		//fmt.Println("(i, scores, total)", i, scores, total)
		for j := 0; j < len(scores); j++ {
			t += scores[j]

			if j+1 > k {
				//fmt.Println("break")
				break
			}
			//fmt.Println("t", t)
			now = t
			if total > 0 {
				e := (k - (j + 1)) / len(scores)
				//fmt.Println("j", j, e)
				now += total * e
			}
			//fmt.Println("now", now)
			ans = max(ans, now)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6568
s = input()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  print("Yes")
elif s[0]==s[2] and s[2]!=s[1] and s[1]==s[3]:
  print("Yes")
elif s[0]==s[3] and s[3]!=s[1] and s[1]==s[2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
a, b, c=map(int, input().split())

if a==7:
  if b==5:
    if c==5:
      res='YES'
    else:
      res='NO'
      
  else:
    res='NO'
    
elif a==5:
  if b==5:
    if c==7:
      res='YES'
    else:
      res='NO'
      
  elif b==7:
    if c==5:
      res='YES'
    else:
      res='NO'
      
else:
  res='NO'
  
print(res)
  
        

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, A, B;
  cin>>N>>A>>B;
  if((B-A)%2!=0) cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;
}



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

using namespace std;

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

    int ans = numeric_limits<int>::max();
    for(int j=-100; j<=100; j++) {
        int tmp = 0;
        for(int i=0; i<N; i++) {
            tmp += (a[i]-j)*(a[i]-j);
        }
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
set<ll> st;
/*==================================================*/
/*function*/

/*==================================================*/

int main(){
    cin>>N;

    if(N <= 5){
        switch (N) {
            case 3:
                cout<<2<<" "<<5<<" "<<63<<endl;
                break;
            case 4:
                cout<<2<<" "<<5<<" "<<63<<" "<<20<<endl;
                break;
            case 5:
                cout<<2<<" "<<5<<" "<<63<<" "<<20<<" "<<30<<endl;
                break;
            default:
                cout<<"EORROR!"<<endl;
                break;
        }
        return 0;
    }

    ll num = 0;
    ll sum = 0;
    int cnt = 0;
    while(cnt < N){
        num++;
        if(num % 2 == 0 || num % 3 == 0){
            st.insert(num);
            sum += num;
            cnt++;
        }
    }

    ll nextn = num;
    while(true){
        nextn++;
        if(nextn % 6 == 0){
            break;
        }
    }
    ll nextf = num;
    while(true){
        nextf++;
        if(nextf % 6 == 4){
            break;
        }
    }

    switch (sum % 6){
        case 0:
            break;
//        case 1:
//            st.erase(14);
//            st.insert(nextn - 7);
//            break;
        case 2:
            st.erase(8);
            st.insert(nextn);
            break;
        case 3:
            st.erase(9);
            st.insert(nextn);
            break;
//        case 4:
//            st.erase(9);
//            st.insert(nextf + 1);
//            break;
        case 5:
            st.erase(9);
            st.insert(nextf);
            break;
        default:
            cout<<"ERROR!"<<endl;
            break;
    }

    auto it = st.begin();
    while(it != st.end()){
        cout<<(*it);
        if(it != st.end()) cout<<" ";
        it++;
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1280
A = [-1]*101
d = []
for i in range(3):
    a,b,c = map(int,input().split())
    d.append(a)
    d.append(b)
    d.append(c)
    A[a] = 0
    A[b] = 0
    A[c] = 0
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

for i in range(N):
    A[b[i]] += 1

if (A[d[0]]==1 and A[d[1]]==1 and A[d[2]]==1) or (A[d[3]]==1 and A[d[4]]==1 and A[d[5]]==1) or (A[d[6]]==1 and A[d[7]]==1 and A[d[8]]==1) or (A[d[0]]==1 and A[d[3]]==1 and A[d[6]]==1) or (A[d[1]]==1 and A[d[4]]==1 and A[d[7]]==1) or (A[d[2]]==1 and A[d[5]]==1 and A[d[8]]==1) or (A[d[0]]==1 and A[d[4]]==1 and A[d[8]]==1) or (A[d[2]]==1 and A[d[4]]==1 and A[d[6]]==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define fr first
#define sc second
#define INF 100
typedef pair<int,int>Pt;
int main(){
  int n;
  double H,M,hh,mm,mini;
  scanf("%d",&n);
  while(n--){
    scanf("%lf:%lf",&hh,&mm);
    H = hh * 30.0 + mm * 0.5;
    M = mm * 6.0;
    mini = fabs(H - M);
    if(H<M) H += 360.0;
    else M += 360.0;
    mini = min(mini,fabs(H-M));

    if(mini<30) cout << "alert" << endl;
    else if(mini>=90) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
}

Measured memory_bytes: 1228
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

//----------------------------------------


int main(void)
{
	int n;
	int now = -1;
	cin >> n;

	vector<int> h(n);

	rep(i, n) cin >> h[i];

	bool f = true;

	h[0]--;
	for (int i = 0; i < n - 1; i++)
	{
		if (h[i] < h[i + 1]) h[i+1]--;
		
	}

	rep(i, n - 1)
	{
		if (h[i] > h[i + 1]) f = false;
	}

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
int q[2001000],a[500010],p[500010];
inline void add(int l,int r,int o,int x,int y) {
	if(l==r){q[o]=y;return;}
	int mid=(l+r)/2;
	if(x<=mid)add(l,mid,2*o,x,y);
	else add(mid+1,r,2*o+1,x,y);
	q[o]=min(q[2*o],q[2*o+1]);
}
inline int query(int l,int r,int o,int x,int y){
	if(x<=l&&r<=y)return q[o];
	int mid=(l+r)/2,ret=1e9;
	if(x<=mid)ret=min(ret,query(l,mid,2*o,x,y));
	if(y>mid)ret=min(ret,query(mid+1,r,2*o+1,x,y));
	return ret;
}
struct Edge{
	int v,Next;
} G[1000010];
int head[500010],d[500010],tot;
inline void add(int u,int v){
	//cerr<<u<<" "<<v<<endl;
	G[++tot]=(Edge){v,head[u]};
	head[u]=tot;d[v]++;
}
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,1,n)scanf("%d",&a[i]);
	rep(i,1,n)p[a[i]]=i;
	memset(head,-1,sizeof(head));
	rep(i,1,4*n)q[i]=1e9;
	for(int i=n;i>=1;--i){
		//cerr<<i<<endl;
		int wt=query(1,n,1,p[i],min(n,p[i]+k-1));
		if(wt!=1e9)add(p[i],p[wt]);
		wt=query(1,n,1,max(1,p[i]-k+1),p[i]);
		//if(wt!=1e9)cerr<<"pp "<<p[wt]<<endl;
		if(wt!=1e9)add(p[i],p[wt]);
		//cerr<<p[i]<<" " <<i<<endl;
		add(1,n,1,p[i],i);
		//cerr<<p[i]<<" " <<i<<endl;
	}//cerr<<233<<endl;
	priority_queue<int> Q;
	rep(i,1,n)if(!d[i]){
		Q.push(-i);
	}
	int tt=0;
	while(!Q.empty()){
		int x=-Q.top();Q.pop();
		p[++tt]=x;
		for(int i=head[x];i!=-1;i=G[i].Next){
			d[G[i].v]--;
			if(d[G[i].v]==0){
				Q.push(-G[i].v);
			}
		}
	}
	rep(i,1,n)a[p[i]]=i;
	rep(i,1,n)printf("%d\n",a[i]);
}

Measured memory_bytes: 27512
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int main()
{
    ull N, A, B, comb, temp;
    cin >> N >> A >> B;
    comb = N / (A+B);
    if (N - comb* (A+B) > A) temp = A;
    else temp = N - comb * (A+B); 
    cout << comb * A + temp << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main() {
  int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, k, v;
  for(i = 2; i <= MAX_V; i++) {
      prime[i] = 1;
    }
      for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
          for(k = 2 * i; k <= MAX_V; k += i) {
            prime[k] = 0;
          }
        }
      }
  while(scanf("%d", &v) != EOF) {
    if(v != 0){
      int s = 0;
      for(int i = 0;i <= v;i++){
        int isprime = prime[i];
        if(isprime){
          s++;
        }
      }
      int side[s],d = 0;
      for(int i = 0;i <= v;i++){
        int isprime = prime[i];
        if(isprime) {
          side[d] = i;
          d++;
        }
      }
      int m = d-1;
      int dai = 0,syo = 0;
      for(int n = m;n >= 0;n--){
        if(side[n] - side[n-1] == 2){
          if(syo < side[n-1]){
            syo = side[n-1];
            dai = side[n];
          }
        }
      }
      printf("%d %d\n",syo,dai);
    }else break;
  }
  return 0;
  }

Measured memory_bytes: 5696
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7
INF = float('inf')

def main():
    N = int(readline())
    T, A = map(int, readline().split())
    H = list(map(int, readline().split()))
    small = INF
    for i in range(N):
        t = T - H[i]*0.006
        if abs(A-t)<small:
            ans = i + 1
            small = abs(A-t)
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
main(n,f,x){unsigned int u;for(scanf("%d",&n);n--;){
	scanf("%x",&u);
	f=(u&0x7f)*78125;
	for(x=7;x>1&&!(f%10);f/=10)x--;
	printf("%s%d.%0*d\n",u&(1<<31)?"-":"",u<<1>>8,x,f);
}exit(0);}

Measured memory_bytes: 616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String contains7 = "No";
        for (int i = 0; i < word.length(); i++) if (word.charAt(i) == '7') contains7 = "Yes";
        System.out.println(contains7);
    }
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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...));
}

int main() {
    set<int> st{1, 2, 3};

    int a, b; cin >> a >> b;

    st.erase(a);
    st.erase(b);

    cout << *st.begin() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  int x[100];
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }

  int y[100];
  for (int i = 0; i < n; i++) {
    scanf("%d", &y[i]);
  }

  double D[4] = {};
  for (int i = 0; i < n; i++) {
    D[0] += abs(x[i] - y[i]);
  }

  for (int i = 0; i < n; i++) {
    int xy = abs(x[i] - y[i]);
    D[1] += xy * xy;
  }
  D[1] = sqrt(D[1]);

  for (int i = 0; i < n; i++) {
    int xy = abs(x[i] - y[i]);
    D[2] += xy * xy * xy;
  }
  D[2] = cbrt(D[2]);

  for (int i = 0; i < n; i++) {
    if (abs(x[i] - y[i]) > D[3]) {
      D[3] = abs(x[i] - y[i]);
    }
  }

  printf("%f\n%f\n%f\n%f\n", D[0], D[1], D[2], D[3]);

  return 0;
}


Measured memory_bytes: 2912
#define _USE_MATH_DEFINES
//#include <windows.h>
#include <algorithm>
#include <cstdio>
#include <list>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1000000007
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef priority_queue<P, vector<P>, greater<P> > minPQ;
struct edge {int to,cost;};
//const int SIZE = 1<<18;

int main() {
	int N;
	string S;
	cin >> N >> S;
	int x = 0;
	int MAX = 0;
	REP(i,N) {
		if(S[i]=='I') x++;
		else if(S[i]=='D') x--;
		MAX = max(MAX,x);
	}
	cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 256
use integer;
$n=<>;
$ans=1;
$limit=10**18;
@a=glob<>;
if(grep{$_==0}@a){
	print 0;
	exit
}
map{
	if($ans>$limit/$_){
		print -1;
		exit
	}
	$ans*=$_;
}@a;
print $ans;

Measured memory_bytes: 82884
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, x; 
  cin >> A >> B >> x;

  if(A != 0) cout << B/x-(A-1)/x << "\n";
  else cout << B/x+1 << "\n";

  return 0;
}

Measured memory_bytes: 256
from functools import lru_cache

k = 0

def format_input(filename = None):
	global k
	if filename == None:
		k = int(input())

	elif filename == '__random__':
		from random import randint as rng
		k = rng(1, 2 * 10**2)
		print(k)

@lru_cache(maxsize=None)
def gcd(a, b):
	i, j = a, b
	while j > 0:
		i %= j
		i, j = j, i
	return i

def get_answer():
	answer = 0
	for a in range(1, k+1):
		for b in range(1, k+1):
			for c in range(1, k+1):
				answer += gcd(a, gcd(b, c))
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


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

long long kt=10000000000000;

struct longnum {
	 long long n[3];
	 double d;
 }; 

longnum add(longnum a,longnum b) {
	int i;
	longnum c;
	c.d=0;
	for (i=0;i<3;i++) {
		c.n[i]=a.n[i]+b.n[i];
		if (c.n[i]>=kt) { c.n[i]-=kt; b.n[i+1]++;}
	}
	return c;
}

longnum mul(longnum a,int b) {
	int i;
	long long h=0,d; 
	longnum c;
	c.d=0;
	for (i=0;i<3;i++) {	 d=a.n[i]*b+h; c.n[i]=d % kt; h=d/kt; }
	return c;
}	 

longnum div(longnum a,int b) {
	int i,k;
    for (i=2;i>=0;i--) {
		k= a.n[i] % b; a.n[i]/=b;
		if (i>0) a.n[i-1]+=k*kt; else a.d+=k;
	}
	a.d/=b;
	return a;
}

void set(longnum &a,int b) {
	a.n[2]=a.n[1]=0;
	a.n[0]=b; a.d=0;
 } 

struct masu {
	int in,ia;
	longnum g[2][5101];
    };
    
masu m[51];    

int main() {
	int c,x,y,z,n,e,a,i,j,k,d,g,v[4],s[2][51],sn[2],f,f2,f3,cl[51],mx;
	longnum h,t;
	double ans;
	while(cin >> x >> y >> z && x!=0) {
		ans=0; mx=0; f3=0;
		for (i=0;i<=y;i++) for (j=0;j<=5000;j++) {set(m[i].g[0][j],0); set(m[i].g[1][j],0); m[i].in=0;}
		for (i=0;i<x;i++) cin >> v[i];
		for (i=0;i<z;i++) { cin >> n >> e >> a; m[n].in=e; m[n].ia=a;}
		sn[0]=1; sn[1]=0; s[0][0]=0; f=0; c=0; 
		set(m[0].g[f][0],1);
	while (true) {
		for (i=0;i<=y;i++) cl[i]=0; 
		for (i=0;i<sn[f];i++) for (j=0;j<x;j++) {
			k=s[f][i]+v[j]; if (k>y) k=y; 
			if (m[k].in==1) k+=m[k].ia; if (k>y) k=y;
			cl[k]=1;
		}
		for (i=1;i<=y;i++) if (cl[i]==1) for (j=0;j<=c*100+100;j++) set(m[i].g[1-f][j],0);
		for (i=0;i<sn[f];i++) {
			if (s[f][i]==y) continue;
			for (j=0;j<x;j++) {
			k=s[f][i]+v[j]; f2=0; 
			if (k>y) k=y;
			if (m[k].in==1) { k+=m[k].ia; f2=1;}
			if (k>y) k=y;
			if (k>f3) f3=k;
			d=0;
			for (g=0;g<sn[1-f];g++) if (s[1-f][g]==k) d=1;
			if (d==0) {s[1-f][sn[1-f]]=k; sn[1-f]++;}
			for (e=0;e<=mx;e++) {
			 d=0;	
			 if (m[k].in==2 && f2==0) { d=1; m[k].g[1-f][e+m[k].ia]=add(m[k].g[1-f][e+m[k].ia],m[s[f][i]].g[f][e]);}
             if (m[k].in==3 && f2==0) { d=1; if (e-m[k].ia<0) m[k].g[1-f][0]=add(m[k].g[1-f][0],m[s[f][i]].g[f][e]);
				                        else m[k].g[1-f][e-m[k].ia]=add(m[k].g[1-f][e-m[k].ia],m[s[f][i]].g[f][e]);}
			 if (d==0)  m[k].g[1-f][e]=add(m[k].g[1-f][e],m[s[f][i]].g[f][e]);  		
			   }
			  }
			  }
			sn[f]=0;
			f=1-f;
			c++;
			mx=0; for (i=0;i<=f3;i++) if (m[i].in==2) mx+=m[i].ia; 
			set(t,0); 
			for (i=1;i<=c*100;i++) { h=mul(m[y].g[f][i],i); t=add(t,h);}
			for (i=0;i<c;i++) t=div(t,x);
			ans=ans+t.n[0]+t.d;
			if (sn[f]==1 && s[f][0]==y) break;
			}
		cout << (int)ans << endl;
		}
	return 0;
}

Measured memory_bytes: 17424
n, a, b, c, d = map(int, input().split())
s = list(input())

ans = "Yes"
if any(map(lambda i: s[i] == s[i + 1] == '#', range(a - 1, c - 1))):
    ans = "No"
if any(map(lambda i: s[i] == s[i + 1] == '#', range(b - 1, d - 1))):
    ans = "No"
if d < c and not any(map(lambda i: b <= i + 1 <= d, list(filter(lambda i: s[i - 1] == s[i] == s[i + 1] == '.', range(1, n - 1))))):
    ans = "No"

print(ans)

Measured memory_bytes: 61936
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    string S;
    cin >> S;

    ll invalidLeft = 0;
    ll invalidRight = 0;
    rep(i, n) {
        if (S[i] == '(') {
            invalidLeft++;
        }
        if (S[i] == ')') {
            if (invalidLeft > 0) {
                invalidLeft--;
            }
            else {
                invalidRight++;
            }
        }
    }

    string res = string(invalidRight, '(') + S + string(invalidLeft, ')');
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3608
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        k: usize,
    }

    let ans = (1..std::cmp::max(a, b) + 1)
        .rev()
        .filter(|i| a % i == 0 && b % i == 0)
        .nth(k - 1)
        .unwrap();

    println!("{}", ans);
}


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

#define ll long long
#define vec vector<ll>
#define rev(a); reverse(a.begin(), a.end());
#define sorta(a); sort(a.begin(), a.end());
#define sortd(a); sort(a.begin(), a.end(), greater<int>());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)
#define printarray(a) FOR(Q,0,(int)(a).size()) cout<<(a)[Q]<<" "; cout<<'\n';
#define pb push_back
#define mp make_pair

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/


int gcd(int a, int b) {
	if (a<b) {
		a^=b;
		b^=a;
		a^=b;
	}
	if (a==b) return a;
	if (b==0) return a;
	return gcd(b,a%b);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;cin>>n;
	n++;
	ll out=0;

	FOR(i,1,n) {
		FOR(j,1,n) {
			FOR(k,1,n) {
				out+=gcd(i,gcd(j,k));
				out%=MOD;
			}
		}
	}
	cout<<out;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <utility>
#include <vector>

#define MAX_H (1000)
#define MAX_W (1000)
#define SIZE_BUF (30)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int H, W;
  char ass[MAX_H][MAX_W + 1], buf[SIZE_BUF];
  scanf("%d %d", &H, &W);
  fgets(buf, SIZE_BUF, stdin);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ass[i][j] = fgetc(stdin);
    }
    fgets(buf, SIZE_BUF, stdin);
  }
  // for (int i = 0; i < H; i++) {
  //   for (int j = 0; j < W; j++) {
  //     printf("%c", ass[i][j]);
  //   }
  //   printf("\n");
  // }

  // put in queue
  int ans = 0;
  queue<pair<pair<int, int>, int>> que;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ass[i][j] == '#') {
        que.push(make_pair(make_pair(i, j), 0));
      }
    }
  }
  // simulate
  const int dis[] = {1, 0, -1, 0}, djs[] = {0, 1, 0, -1};
  while (!que.empty()) {
    const int i = que.front().first.first, j = que.front().first.second,
              n = que.front().second;
    que.pop();
    // printf("i = %d, j = %d, n = %d\n", i, j, n);
    for (int k = 0; k < 4; k++) {
      const int id = i + dis[k], jd = j + djs[k], nd = n + 1;
      if (id >= 0 && id < H && jd >= 0 && jd < W && ass[id][jd] == '.') {
        ass[id][jd] = '#';
        que.push(make_pair(make_pair(id, jd), nd));
        ans = max(ans, nd);
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 13328
from itertools import combinations_with_replacement


def euclidean(num_list: list):
    a, b = sorted(num_list)
    while b % a != 0:
        redi = b % a
        b = a
        a = redi
    return a


K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    gcd = euclidean(comb[0:2])
    gcd = euclidean([gcd, comb[2]])
    if comb[0]==comb[1] and comb[1]==comb[2]:
        coef = 1
    elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
        coef = 6
    else:
        coef = 3
    result += gcd * coef
print(result)

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

int main(){
    int n;
    cin>>n;
    bool b=0;
    while(n>0)
    {
        if(n%10 == 7 )
        {
            b=1;
            break;
        }
        n/=10;
    }
    if(b) cout<<"Yes";
    else cout<<"No";

}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    vector<int> h(n);

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

    for (int i = n - 2; i >= 0; i--)
    {
        if (h[i] > h[i + 1])
        {
            h[i]--;
        }

        if (h[i] > h[i + 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 640
def comb_mod(n,r,m):
    ans = 1
    for i in range(1,r+1):
        ans *= (n-i+1) % m
        ans *= pow(i,m-2,m) % m
        ans = ans % m
    return ans
x,y = map(int,input().split())
m = 10**9+7
n = (x+y)//3
c = 0
if x*0.5 <= y <= 2*x and (x+y)%3 == 0:
    r = x - n
    c = comb_mod(n,r,m)
else:
    ans = 0
print(c)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double r;
    cin>>r;
    double s=(double)r*2*3.141592653589;
    double d=(double)r*r*3.141592653589;
    printf("%.6lf %.6f",d,s);
    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
const int MN=4000+5;
const int P=1000000007;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,m,N;
ll fac[MN*2],inv[MN*2];
ll f[MN][MN],ans;
int a[200010],b[200010];
ll qp(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%P)if(b&1)c=c*a%P;return c;}
ll C(int n,int m){return fac[n]*inv[m]%P*inv[n-m]%P;}
void input(){
	IN(n);fac[0]=1;N=8000;
	for(int i=1;i<=N;++i)fac[i]=fac[i-1]*i%P;
	inv[N]=qp(fac[N],P-2);
	for(int i=N;i>=1;--i)inv[i-1]=inv[i]*i%P;
	for(int i=1;i<=n;++i)IN(a[i]),IN(b[i]),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4001;++i)for(int j=1;j<=4001;++j)f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%P;
	for(int i=1;i<=n;++i)ans=(ans+f[2001+a[i]][2001+b[i]]-C(a[i]*2+b[i]*2,b[i]+b[i])+P)%P;
	printf("%lld\n",ans*qp(2,P-2)%P);
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 127232
#include <stdio.h>

int main()
{
        int n, n1, n2, n3, n4;

        scanf("%d", &n);
        int b[n][10], f[n][10], r[n][10], v[n][10];

        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 10; j++) {
                        b[i][j] = 0;
                        f[i][j] = 0;
                        r[i][j] = 0;
                        v[i][j] = 0;
                }
        }

        for (int i = 0; i < n; i++) {
                scanf("%d %d %d %d", &n1, &n2, &n3, &n4);
                if (n1 == 1) {
                        b[n2-1][n3-1] += n4;
                } else if (n1 == 2) {
                        f[n2-1][n3-1] += n4;
                } else if (n1 == 3) {
                        r[n2-1][n3-1] += n4;
                } else {
                        v[n2-1][n3-1] += n4;
                }
        }

        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 10; j++) {
                                printf(" %d", b[i][j]);
                }
                printf("\n");
        }
        printf("####################\n");

        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 10; j++) {
                                printf(" %d", f[i][j]);
                }
                printf("\n");
        }
        printf("####################\n");


        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 10; j++) {
                                printf(" %d", r[i][j]);
                }
                printf("\n");
        }
        printf("####################\n");


        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 10; j++) {
                                printf(" %d", v[i][j]);
                }
                printf("\n");
        }
}



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

int main() {
    while (true) {
        int z;
        cin >> z;
        if (!z) return 0;
        int res = 0;
        for (int i = 1; i * i * i <= z * z * z; i++) {
            for (int j = 1; j * j * j <= z * z * z; j++) {
                int calc = i * i * i + j * j * j;
                if (calc <= z * z * z) res = max(res, calc);
            }
        }
        cout << z * z * z - res << endl;
    }
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<< endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, Q);
  VAR(string, S);
  vector<pii> p(Q);
  each(x, p) in(x.first, x.second);
  vi a(N);
  rep(i, 1, N) {
    a[i] = a[i - 1];
    if (S[i - 1] == 'A' && S[i] == 'C') a[i]++;
  }
  rep(i, 0, Q) {
    print(a[p[i].second - 1] - a[p[i].first - 1]);
  }
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int MOD=1e9+7;

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

  string s;cin>>s;
  int res=0,pre=0;
  for(int i=0;i<(int)s.length();i++){
      if(s[i]=='S') pre++;
      else{
          if(pre){
              res++;
              pre--;
          }
      }
  }
  cout<<s.length()-2*res<<endl;
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <utility>

int main(){
  int x, y;
  for(int i = 0; ; i++){
       std::cin >> x >> y;
       if( x == 0 && y == 0) break;
       if(x >= y){
         std::cout << y << " " <<  x << std::endl;
       }
       else if(x < y){
         std::cout << x << " " <<  y << std::endl;
       }
    }
return 0;
}



Measured memory_bytes: 3068
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

int main(){
    int A, B, C;
    
    cin >> A >> B >> C;
    
    if (A+B+1>=C) {
        cout << B + C << endl;
    }
    
    else {
        cout << B + A + B + 1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 768
program probb
	implicit none
    integer :: a, i
    logical :: check
    read(*,*) a
    check = .false.
    do i = 1, 9
    	if(mod(a,i) == 0 .and. a/i <= 9) then
        	check = .true.
        end if
   	end do
    if(check) then
    	write(*,*) "Yes"
    else
    	write(*,*) "No"
    end if
    
    
    stop
end program probb


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */
int n;
vi a;
vi b;
vec<pi> diff;
void in(){
    cin >> n;
    rep(i,0,n){
        int ai, bi; cin >> ai >> bi;
        a.push_back(ai);
        b.push_back(bi);
        diff.push_back(pi(ai + bi, i));
    }
    sort(all(diff)); reverse(all(diff));
}



void solve(){

    int ta = 0, ao = 0;

    rep(i,0,n){
        if(i % 2 == 0){
            ta += a[diff[i].second];
        }else{
            ao += b[diff[i].second];
        }
    }

    print(ta - ao);
    

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if(s == t)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

	int w, h, x, y, r;
	bool check() {
		return x >= r && y >= r && x <= w - r && y <= h - r;
	}

	int main() {
		cin >> w >> h >> x >> y >> r;
		cout << (check() ? "Yes" : "No") << endl;
	}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

vector<ll> ans;
vector<vector<int>> graph;
vector<ll> sum;
void dfs(int v, int p, ll s){
	ans[v] = s + sum[v];
	for(int u: graph[v]){
		if(u==p) continue;
		dfs(u, v, ans[v]);
	}
}

int main(){
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N), B(N);
	for(int i=0; i<N-1; i++) cin >> A[i] >> B[i];
	vector<int> P(Q), X(Q);
	for(int i=0; i<Q; i++) cin >> P[i] >> X[i];

	graph.assign(N, {});
	for(int i=0; i<N-1; i++){
		A[i]--; B[i]--;
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}
	sum.assign(N, 0);
	for(int i=0; i<Q; i++){
		P[i]--;
		sum[P[i]] += X[i];
	}

	ans.assign(N, 0);
	dfs(0, -1, 0);
	pr(ans);
	return 0;
}


Measured memory_bytes: 28928