akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

#define yes puts("Yes")
#define no puts("No")

void solve(string s){

    while(s.size()>3){
        bool f = false;
        for(int i=0;i<s.size();i++){
            if(s.substr(i,3)=="ABC"){
                f=true;
                break;
            }
        }
        if(!f) break;
        string tmp="";
        string c;
        if(s.substr(0,3)=="ABC"){
            c = "A";
        }else if(s.substr(s.size()-3,3)=="ABC"){
            c = "C";
        }else{
            f = true;
            for(int i=1;i<s.size()-1;i++){
                if(s[i]=='B'){
                    if(!(s[i-1]=='A' and s[i+1]=='C')){
                        no;
                        return;
                    }
                }
            }
            c = "B";
        }

        for(int i=0;i<s.size();i++) if(s.substr(i,3)=="ABC"){
            s.replace(i,3,c);
        }
    }

    if(s=="ABC") yes;
    else no;
}

int main(){
    while(1){
        string s;
        cin>>s;
        if(s=="0") break;
        //cout << s << " -> ";
        solve(s);

        break;
    }
}

Measured memory_bytes: 3252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int data[10];

int main() {
	int n;
	n=in();
	while(n--){
		double shin;
		cin>>shin;
		if(shin<165)data[1]++;
		else if(shin<170)data[2]++;
		else if(shin<175)data[3]++;
		else if(shin<180)data[4]++;
		else if(shin<185)data[5]++;
		else data[6]++;
	}
	int i;
	for(i=1;i<=6;i++){
		cout<<i<<":";
		for(;data[i]--;)cout<<"*";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_W				100										// 幅
#define D_H				21										// 高さ
#define D_CHAR_W		'.'										// 文字 - 白
#define D_CHAR_B		'#'										// 文字 - 黒

// 内部変数
static char sc2Mass[D_H * 2][D_W + 5];							// マス

// 内部変数 - テスト用
#ifdef D_TEST
	static FILE *szpFpT;
#endif

// マスセット
int
fSetMass(
	int piRow					// <I> 開始行 0～
	, char pcIni				// <I> 初期文字
	, char pcSet				// <I> セット文字
	, int piCnt					// <I> セット数
)
{
	int i;

	// 初期化
	for (i = 0; i < D_H; i++) {
		memset(sc2Mass[piRow + i], pcIni, sizeof(sc2Mass[piRow + i]));
		sc2Mass[piRow + i][D_W] = '\0';
	}

	// 文字セット
	piRow++;
	while (piCnt > 0) {

		// １行セット
		for (i = 0; i < D_W; i += 2) {

			// １文字セット
			sc2Mass[piRow][i] = pcSet;

			// 終了チェック
			piCnt--;
			if (piCnt < 1) {
				break;
			}
		}

		// 次の次の行へ
		piRow += 2;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
#endif

	// 白数・黒数取得
	int liWCnt, liBCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d", &liWCnt, &liBCnt);

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
#endif

	// マスセット
	fSetMass(0, D_CHAR_B, D_CHAR_W, liWCnt - 1);
	fSetMass(D_H, D_CHAR_W, D_CHAR_B, liBCnt - 1);

	// 表示
	printf("%d %d\n", D_H * 2, D_W);
	for (i = 0; i < D_H * 2; i++) {
		printf("%s\n", sc2Mass[i]);
	}

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, x = MAP()
if 2*x <= a*a*b:
	print(degrees((atan((a*b*b)/(2*x)))))
else:
	print(degrees((atan((2*a*a*b-2*x)/(a*a*a)))))

Measured memory_bytes: 64620
using System;
namespace AtCoderer
{
    public class App
    {
      	const int mod = 1000000007;
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var dp = new long[256, n+1];
            dp[255, 0] = 1;
            long sum = 0;
            for (int i = 1;i<=n;i++)
            {
                sum = 0;
                for (int c = 0; c < 256; c++)
                {
                    if ((c & 63) == 9)
                        continue;
                    if ((c & 207) == 9)
                        continue;
                    if ((c & 243) == 33)
                        continue;
                    if ((c & 63) == 33)
                        continue;
                    if ((c & 63) == 6)
                        continue;
                    for (int b = 0; b < 256; b += 64)
                    {
                        dp[c, i] += dp[(c >> 2) + b, i - 1];
                    }
                    sum += dp[c, i];
                    sum %= mod;
                    dp[c, i] %= mod;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.indexOf("a") >= 0 && S.indexOf("b") >= 0 && S.indexOf("c") >= 0) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


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

int main(void){
    int n;
    cin >> n;
    vector<int>a;
    vector<int>b;
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(x);
        x =x-(i+1);
        b.push_back(x);
    }
    ll ans = 0;
    sort(b.begin(),b.end());
  	
    int bb=0;
    if(n%2==1){
        bb = b[n/2];
    }
    else{
        bb=(b[n/2]+b[n/2-1])/2;
    }
  
    rep(i,n){
        ans +=abs(a[i]-(bb+i+1));
    }
    
    cout << ans <<endl;
    
    
    return 0;
}





















































Measured memory_bytes: 2036
n = gets.to_i
a = gets.split.map(&:to_i)
b = Array.new(n + 1) { 0 }

a.reverse_each.with_index do |e, idx|
  b[n - idx] = 1 if e != Array.new(n / (n - idx) - 1) { |i| b[(n - idx) * (i + 2)] }.sum % 2
end

ret = b.filter_map.with_index { |e, idx| idx if e == 1 }

if ret.size != 0
  puts ret.size
  puts ret.join(' ')
else
  puts 0
end

Measured memory_bytes: 51988
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
const long N = 100100;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
void solve(){
    long n;
    cin >> n;
    vector <long> v(n);
    for(auto &i: v) cin >> i;
    long mn = v[0], cnt = 0;
    for (int i = 0; i < n; ++i){
        if( v[i] <= mn ) cnt ++;
        mn = min(mn, v[i]);
    }
    cout << cnt;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 4788
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll x, h = 0;
  cin >> x;
  ll tmp = x;
  string ans = "No";
  while (tmp > 0) {
    h += tmp % 10;
    tmp /= 10;
  }
  if (x % h == 0) ans = "Yes";
  cout << ans << endl;
}

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

int main(void){
    int n;
    cin >> n;
    int aa = 6, count = 0;
    int check[14];
    int answer[100001];
    for(int i = 1; i < 8; i++){
        check[count] = aa;
        aa *= 6;
        count++;
    }
    aa = 9;
    for(int i = 1; i < 8; i++){
        check[count] = aa;
        aa *= 9;
        count++;
    }
    sort(check, check+count);
    answer[0] = 0;
    for(int i = 1; i < 100001; i++){
        if(i < 6)
            answer[i] = i;
        else 
            answer[i] = 100000;
    }
    for(int i = 0; i <= 14; i++){ 
        for(int j = 1; j < 100000; j++){
            if(check[i]*j > 100000)
                break;
            answer[check[i]*j] = min(answer[check[i]*(j-1)] + 1, answer[check[i]*j]);
        }
    }
    for(int i = 0; i < 100001; i++){
        for(int j = 0; j <= 14; j++){
            if(i - check[j] >= 0)
                answer[i] = min(min(answer[i-check[j]]+1, answer[i-1]+1), answer[i]);
        }
    }
    cout << answer[n] << endl;
    return 0;
}

Measured memory_bytes: 640
X = int(input())

n = 2 * X
is_prime = [False] * 2 + [True] * (n - 1)

for i in range(2, int(n ** 0.5) + 1): # 素数候補
    if not is_prime[i]: continue
    for j in range(2 * i, n + 1, i):
        is_prime[j] = False

for i in range(X, n):
    if is_prime[i]:
        print(i)
        break

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
    s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  auto graph = ReadUndirectedGraph(n, n - 1, true);
  vector<int> ds(n, -1);  // Depth
  function<void(int, int, int)> dfs_fn = [&](int v, int p, int d) {
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      dfs_fn(e.to, v, d + 1);
    }
    ds[v] = d;
  };
  dfs_fn(0, -1, 0);

  vector<int> counts(2);
  for (int i = 0; i < n; i++) {
    counts[ds[i] % 2]++;
  }
  if (DEBUG) cout << "counts: " << counts << endl;
  int c_max = max(counts[0], counts[1]);
  int t = n / 3 * 2;
  if (n % 3 != 0) t++;
  if (DEBUG) cout << "t: " << t << endl;

  deque<int> q0, q1;
  if (c_max > t) {
    // s0 > s1
    auto make_queues_fn = [](int n, int s0, int s1) -> tuple<deque<int>, deque<int>> {
      deque<int> q0, q1;
      vector<int> used(n + 1);
      for (int k = 0; k < s1; k++) {
        q1.push_back(3 * (k + 1));
        used[3 * (k + 1)] = true;
      }
      for (int i = 1; i <= n; i++) {
        if (!used[i]) {
          q0.push_back(i);
          used[i] = true;
        }
      }
      return make_tuple(q0, q1);
    };
    tie(q0, q1) = make_queues_fn(n, max(counts[0], counts[1]), min(counts[0], counts[1]));
    if (counts[0] < counts[1]) {
      swap(q0, q1);
    }
  } else {
    // s0 > s1
    auto make_queues_fn = [](int n, int s0, int s1) -> tuple<deque<int>, deque<int>> {
      deque<int> q0, q1;
      vector<int> used(n + 1);
      for (int k = 1; k <= n; k += 3) {
        if (q0.size() == s0) break;
        q0.push_back(k);
        used[k] = true;             
      }
      for (int k = 3; k <= n; k += 3) {
        if (q0.size() == s0) break;
        q0.push_back(k);
        used[k] = true;             
      }
      for (int k = 1; k <= n; k++) {
        if (!used[k]) {
          q1.push_back(k);
          used[k] = true;
        }
      }
      return make_tuple(q0, q1);
    };
    tie(q0, q1) = make_queues_fn(n, max(counts[0], counts[1]), min(counts[0], counts[1]));
    if (counts[0] < counts[1]) {
      swap(q0, q1);
    }
  }
  vector<int> rs(n);
  for (int i = 0; i < n; i++) {
    if (ds[i] % 2 == 0) {
      rs[i] = q0.front();
      q0.pop_front();
    } else {
      rs[i] = q1.front();
      q1.pop_front();
    }
  }

  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << rs[i];
  }
  cout << endl;
}

Measured memory_bytes: 25768
input()
get_data = input().split(' ')  # String
default = 1
dup_list = list()
for v in get_data:
  if int(v) == default:
    dup_list.append(int(v))
  default += 1
 
del_count = 0
next_skip = False
for v in dup_list:
  if next_skip:
    next_skip = False
    continue
  if v+1 in dup_list:
    next_skip = True
  del_count += 1
  
print(del_count)

Measured memory_bytes: 51436
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

const int N = 100005;
ll dp[N][4];

int main() {
    int n,m,q;cin>>n>>m>>q;
    
    vector<vector<int>> cnt(n);
    rep(i,n){
        cnt[i].resize(n);
    }
    
    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;
        cnt[a][b]++;
    }
    
    rep(i,n){
        repsg(j,1,n){
            cnt[i][j]+=cnt[i][j-1];
        }
    }
    rep(j,n){
        for(auto i = n-2;i>=0;i--){
            cnt[i][j]+=cnt[i+1][j];
        }
    }
    
    rep(i,q){
        int l,r;cin>>l>>r;
        cout<<cnt[l-1][r-1]<<endl;
    }
        
    
    return 0;
}









Measured memory_bytes: 1920
#include<stdio.h>
int main(){
  int ans1,ans2,ans3,a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  ans1=a-c;
  ans2=a-b;
  ans3=b-c;
  if(ans1<0){
    ans1*=-1;
  }
  if(ans2<0){
    ans2*=-1;
  }
  if(ans3<0){
    ans3*=-1;
  }
  if(ans1<=d || ans2<=d && ans3<=d){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
   int n ; 
   scanf("%d",&n);
   int i , j ;
   int count = 0 , count2 =0 ;
   for(i = 1 ; i <= n ; i=i+2){
       for(j = 1 ; j<= i ; j++)
       {
           if(i%j==0){
               count++ ;
           }
       }
       if(count==8){
           count2++ ;
       }
       //printf("%d",count);
       count=0 ;
       
   }
    printf("%d",count2) ;
   
   

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int C=0;
  cin>>A;
  B=A;
  C+=A%10;
  while(A>=10){
    A/=10;
    C+=A%10;
  }
  if(C==1&&B>1){
    cout<<10;
  }
  else{
    cout<<C;
  }
  return 0;
}

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

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x.at(i);
    if(n < m) {
        sort(x.begin(), x.end());
        vector<int> diff(m - 1);
        rep(i, m - 1) diff.at(i) = x.at(i + 1) - x.at(i);
        sort(diff.begin(), diff.end());
        rep(i, m - n) ans += diff.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int N;
  cin >> N;

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

  vector<int>color(9,0);

  for(int i=0;i<N;i++){
    if(rate[i] < 400)
      color[0]++;
    else if(rate[i] < 800)
      color[1]++;
    else if(rate[i] < 1200)
      color[2]++;
    else if(rate[i] < 1600)
      color[3]++;
    else if(rate[i] < 2000)
      color[4]++;
    else if(rate[i] < 2400)
      color[5]++;
    else if(rate[i] < 2800)
      color[6]++;
    else if(rate[i] < 3200)
      color[7]++;
    else
      color[8]++;
  }

  int ans = 0;
  for(int i=0;i<8;i++){
    if(color[i] != 0)
      ans++;
  }

  if(ans != 0)
  cout << ans << " " << ans + color[8] << endl;
  else
  cout << 1 << " " << ans + color[8] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);
 
mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}

int main(){
    int x,y;
    cin >> x >> y;
    if((x+y)%3!=0){
        puts("0");
        return 0;
    }
    int n = (x+y)/3;
    x -= n;
    y -= n;
    if(x<0 || y<0){
        puts("0");
        return 0;
    }
    mint ans = comb(x+y,x);
    cout << ans.x << endl;
    return 0;
}



Measured memory_bytes: 31488
#include<stdio.h>

int main(){
    int n, q;
    long int sum=0, count[1000000]={0}, p;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%ld", &p);
        count[p]++;
        sum = sum + p;
    }
    scanf("%d", &q);
    int b[100000], c[1000000];
    for(int i=0; i<q; i++){
        scanf("%d%d", &b[i], &c[i]);
        sum = sum + (c[i]-b[i])*count[b[i]];
        printf("%ld\n", sum);
        count[c[i]] = count[c[i]] + count[b[i]];
        count[b[i]] = 0;
    }
}





Measured memory_bytes: 10296
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long int lint;
typedef unsigned long long int ulint;
 
lint t,dizi[120],cev[120];
bool visit[120]={0};
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lint n,m,i,j,k,a;
   cin>>n;
   for(i=1;i<=n;i++) cin>>dizi[i];
   for(j=n;j>0;j--){
       lint sira=1,soni=-1;
       for(i=1;i<=n;i++){
           if(visit[i]==false){
               if(sira==dizi[i]){
                   soni=i;
                   
               }
               sira++;
           }
       }
       if(soni==-1) {cout<<-1; return 0;}
       else{
           cev[j]=dizi[soni];
           visit[soni]=true;
           
       }
   }
   for(i=1;i<=n;i++) cout<<cev[i]<<endl;
    
}

Measured memory_bytes: 256
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, W = rli()
	items = []
	maxval = 0
	for _ in range(n):
		w, v = rli()
		maxval += v
		items.append((w, v))

	dp = [INF for _ in range(maxval + 1)]
	dp[0] = 0
	for w, v in items:
		for i in range(maxval, -1, -1):
			if i - v >= 0:
				dp[i] = min(dp[i], dp[i-v] + w)
	ans = NINF
	for val, minweight in enumerate(dp):
		if minweight <= W:
			ans = val
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 71584
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, m; cin>>n>>m;
    vector<int> a(n);
    vector<int> head(n), tail(n);
    ll ans=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        ans+=abs(a[i]-i);
        head[i]=(min(i, a[i]));
        tail[i]=(max(i, a[i]));
    }

    sort(head.begin(), head.end(), greater<int>());
    sort(tail.begin(), tail.end());

    int cnt=0;
    for(int i=0; i<m; i++){
        if(head[cnt]-tail[cnt]>0){
            ans+=(head[cnt]-tail[cnt])*2;
            cnt++;
        }
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

#include <iostream>
#include <vector>

int A[MAX_N];
int P[MAX_N];
int L[MAX_N], R[MAX_N];

int main() {

	int N;
    cin >> N;
	rep(i, N){cin >> A[i];}
	rep(i, N){P[A[i]]=i;}

	{
		set<int> st;
		for(int x = 1; x<=N; x++){
			set<int>::iterator a = st.lower_bound(P[x]);
			if(a == st.begin()){
			  L[x] = -1;
			}
			else{
              a--;
			  L[x] = *a;
			}
			st.insert(P[x]);
		}
	}

	{
		set<int> st;
		for(int x = 1; x<=N; x++){
			auto a = st.upper_bound(P[x]);
			if(a == st.end()){
				R[x] = N;
			}
			else{
				R[x] = *a;
			}
			st.insert(P[x]);
		}
	}

    ll ret = 0;
	for(int x = 1; x<=N; x++) {
		// printf("x:%d pos:%d left:%d right:%d v:%d\n", x, P[x], L[x], R[x], x * (P[x]-L[x]) * (R[x]-P[x]));
        ll n = ll(P[x]-L[x]) * ll(R[x]-P[x]);
	    ret +=  x * n;
    }
    cout << ret << endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  
  for (int i = 0; i < n; i++) {
  	cin >> s.at(i);
  }
  
  bool ans = true;
  int maximum = 1;
  
  for (int i = 0; i < n; i++) {
  	if (maximum - s.at(i) > 1) {
    	ans = false;
    }
  
  maximum = max(maximum, s.at(i));
  }
  
  if (ans) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 768
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int K = scanner.nextInt();
    if (possible(N, M, K)) System.out.println("Yes");
    else System.out.println("No");
  }

  private static boolean possible(int N, int M, int K) {
    for (int x = 0; x <= N; x++) {
      for (int y = 0; y <= M; y++) {
        if (x * M + y * N - 2 * x * y == K) return true;
      }
    }
    return false;
  }
}


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

int main()
{
 int a,b;
 cin >> a >> b;
 if(a >= 13){
   cout << b << endl;
 }else if(a>=6 && a <= 12){
   cout << b/2 << endl;
 }else{
   cout << 0 << endl;
 }
}



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

int main()
{
    int N;
    string S;

    cin >> N;
    cin >> S;

    char prev = '\0';
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] != prev) {
            ans++;
            prev = S[i];
        }
    }

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


Measured memory_bytes: 512
def main():
    (k, x) = map(int, input().split())

    min_n = max(-1000000, x - k + 1)
    max_n = min(1000000, x + k - 1)

    print(' '.join(map(str, range(min_n, max_n + 1))))


if __name__ == "__main__":
    main()


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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool complete(int satisfied[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		if (satisfied[i] != 1)
			return false;
	}
	return true;
}
void swap(int *x, int *y)
{
	int t = *x;
	*x = *y;
	*y = t;
}

bool f(int x, int y)
{
	return x > y;
}
int Lucky(int n)
{
	int c = 0;
	while (n != 0)
	{
		int r = n % 10;
		if (r == 4 || r == 7)
			c++;
		n /= 10;
	}
	return c;
}
bool isPrime(int x)
{
	int i;
	for (i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}
int32_t main()
{
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int a, b, k;
	cin >> a >> b >> k;
	if (k <= a)
		cout << a - k << " " << b;
	else if (k <= a + b)
		cout << "0" << " " << b - (k - a);

	else
		cout << "0" << " " << "0";


}



Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import numpy as np

N, M, X = map(int, input().split())
A = np.zeros((N, M), dtype=np.int32)
C = np.zeros(N, dtype=np.int32)

for i in range(N):
  H = list(map(int, input().split()))
  C[i] = H[0]
  A[i,:] = H[1:M+1]

Sum = A.sum(axis=0)
price = []
if(min(Sum) < X):
  print('-1')
else:
  for i in range(2**N):
    bb = bin(i)
    B = [0]*N
    B += [int(bb[k]) for k in range(2, len(bb))]
    B = np.array([B[-N:]]).T

    pro = A*B
    s = pro.sum(axis=0)
    if(min(s) >= X):
      price.append(np.dot(C,B)[0])

  print(min(price))


Measured memory_bytes: 27180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  ll n, x;
  cin >> n >> x;
  ll a[n];
  REP(i, n) cin >> a[i];
  SORT(a, n);
  ll s[n + 1];
  s[0] = 0;
  REP(i, n) s[i + 1] = s[i] + a[i];
  int ans = 0;
  if(s[n] == x) cout << n << endl;
  else{
    while(s[ans + 1] <= x){
      ans++;
      if(ans == n){
        cout << n - 1 << endl;
        return 0;
      }
    }
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{ int x1,x2,x3,x4,x5;
 int i;
 scanf("%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5);
 if(x1==0)printf("1");
 if(x2==0) printf("2");
 if(x3==0)printf("3");
 if(x4==0)printf("4");
 if(x5==0)printf("5");
 return 0;
}
 

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

int main() {
	int k, ne, no;
	cin >> k;
	if (k% 2 == 0) {
		ne = k/2;
		no= k/2;
	} else {
		ne = (k - 1)/2;
		no= (k + 1)/2;
	}
	cout << ne * no << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
	int N, M; cin >> N >> M;
	vector<string> a(N), b(M);
	for (int i = 0; i < N; ++i) cin >> a[i];
	for (int i = 0; i < M; ++i) cin >> b[i];

	string ans = "No";
	for (int i = 0; i + (M - 1) < N; ++i) {
		for (int j = 0; j + (M - 1) < N; ++j) {
			bool f = true;
			for (int k = 0; k < M; ++k) {
				for (int l = 0; l < M; ++l) {
					if (a[i + k][j + l] != b[k][l]) f = false;
				}
			}
			if (f) {
				ans = "Yes";
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	string t; cin>>t;
	rep(i,0,t.size()){
		if(t[i]=='?'){
			t[i]='D';
		}
	}
	cout<<t<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
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 int MAX = 2e6 + 2;

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  vector<ll> f(MAX, 1), rf(MAX / 2 + 1, 1);
  ll now = 1;
  FOR(i, 1, MAX) {
    now = (now * i) % mod;
    f[i] = now;
    if (i < MAX / 2 + 1) rf[i] = modpow(now, mod - 2);
  }

  ll ans = 0;
  FOR(i, r1, r2 + 1) {
    ll res = (rf[i + 1] * rf[c2]) % mod;
    res = (res * f[i + 1 + c2]) % mod;
    ans = (ans + res) % mod;
  }
  FOR(i, r1, r2 + 1) {
    ll res = (rf[i + 1] * rf[c1 - 1]) % mod;
    res = (res * f[i + c1]) % mod;
    res = (mod - res) % mod;
    ans = (ans + res) % mod;
  }
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 23680
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	h := nextInt()
	n := nextInt()
	a := nextInts(n)
	for i := 0; i < n; i++ {
		h = h - a[i]
		if h <= 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// Segment Tree {{{
template <typename T>
class SegTree {
 private:
    int _n;
    T _init_val;
    std::vector<T> _data;
    std::function<T(T, T)> _f;

    T _query(int a, int b, int k, int l, int r) {
        // [a b)と[l r]が交差しない
        if (r <= a || b <= l) return _init_val;

        // [a b)が[l r]を含む
        if (a <= l && r <= b) return _data[k];

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

        return _f(vl, vr);
    }

 public:
    SegTree(int n, T init_val, std::function<T(T, T)> f) {
        _init_val = init_val;
        _n = 1;
        _f = f;

        while (_n < n)
            _n *= 2;
        _data.resize(2 * _n, init_val);
    }

    T get(int k) {
        return _data[k + _n - 1];
    }

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

    // [a b)の範囲でfを適用
    T query(int a, int b) {
        return _query(a, b, 0, 0, _n);
    }

    // 先頭からチェックし，はじめてxを満たしたインデックス
    int lower_bound(T x) {
        return _lower_bound(x, 0);
    }

    int _lower_bound(T x, int k) {
        if (k >= _n-1) {
            return k - (_n - 1);  // 葉
        } else if (_data[k] < x) {
            return _n;  // 該当なし
        } else if (x <= _data[k * 2 + 1]) {
            return _lower_bound(x, k * 2 + 1);
        } else {
            return _lower_bound(x - _data[k * 2 + 1] , k * 2 + 2);
        }
    }
};
// }}}

signed main() {
  ll N;
  cin >> N;
  vector<ll> l(N);
  SegTree<ll> st(300000,(ll)0,[](const ll &x, const ll &y) {return x+y;});
  rep(i,N) {
    cin>>l[i];
    st.update(l[i], st.get(l[i])+1);
  }
  ll ans = 0;
  rep(i,N) for(ll j=i+1; j<N; j++) {
    // remove l[i], l[j] from st
    st.update(l[i], st.get(l[i])-1);
    st.update(l[j], st.get(l[j])-1);

    // calc
    // max(l[i]-l[j], l[j]-l[i]) < x < l[i]+l[j]
    ll t = st.query(max(l[i]-l[j], l[j]-l[i]) + 1, l[i]+l[j]);
    ans += t;
    // printf("l[%d]=%d l[%d]=%d t=%d\n", i, l[i], j, l[j], t);

    // add l[i], l[j] to st
    st.update(l[i], st.get(l[i])+1);
    st.update(l[j], st.get(l[j])+1);
  }
  if (ans!=0)
    ans /= 3;
  cout << ans << endl;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>

using namespace std;

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

  while(n){
    string s;
    int hit=0,out=0,point=0;
    while(1){
      cin >> s;
      if(s == "HIT"){
        hit++;
        if(hit > 3) point++,hit=3;
      }
      if(s == "HOMERUN"){
        point += hit+1;hit=0;
      }
      if(s == "OUT"){
        out++;
        if(out == 3) break;
      }
    }
    cout << point << endl;
    n--;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;
 
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
 
int n;
ll a[100000],b[100000],c[100000],cnt[100000];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	REP(i,n) cin>>c[i];
	sort(a,a+n),sort(b,b+n),sort(c,c+n);
 
	int i=0;
	REP(j,n) {
		while (a[i]<b[j]&&i<n) i++;
		cnt[j]=i;
	}
	i=0;
	ll ans=0,sum=0;
	REP(j,n) {
		while (b[i]<c[j]&&i<n) {
			sum+=cnt[i];
			i++;
		}
		ans+=sum;
	}
	cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {
  int a, b, w, t;
  scanf("%d%d%d", &w, &a, &b);
  if(a > b) t = a, a = b, b = t;
  printf("%d", a + w < b ? b - a - w : 0);
  return 0;
}

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

int main() {
    int n, a, b;

    scanf("%d", &n);

    if (n == 1) {
        printf("Hello World\n");
    } else if (n == 2) {
        cin >> a >> b;
        printf("%d", a + b);
    }

    return 0;
}

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

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#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(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll T=0ll, A=0ll;
    rep(i,n){
        ll ti, ai;
        cin >> ti >> ai;
        if(i==0){
            T = ti;
            A = ai;
            dd(T, A)
            continue;
        }
        dd(ti, ai)
        ll p = 1;
        p = max((T+ti-1)/ti, (A+ai-1)/ai);
        d(p)
        ti*=p;
        ai*=p;
        T = ti;
        A = ai;

            dd(T, A)
    }

    cout << 0ll + T + A << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int index = -1;

    List<int[]> protList = new ArrayList<int[]>();
    for (int i = 0; i < n; i++) {
      int[] prot = new int[3];
      prot[0] = sc.nextInt();
      prot[1] = sc.nextInt();
      prot[2] = sc.nextInt();
      if (prot[2] > 0) {
        index = i;
      }
      protList.add(prot);
    }

    for (int x = 0; x <= 100; x++) {
      for (int y = 0; y <= 100; y++) {

        int aa = Math.abs(protList.get(index)[0] - x);
        int bb = Math.abs(protList.get(index)[1] - y);
        int hh = aa + bb + protList.get(index)[2];
        int tmpH = hh;

        boolean isCollect = true;

        for (int[] p : protList) {
          int a = Math.abs(p[0] - x);
          int b = Math.abs(p[1] - y);
          int h = a + b + p[2];
          if (p[2] != 0 && tmpH != h) {
            isCollect = false;
            break;
          }
          if (p[2] == 0 && tmpH > h) {
            isCollect = false;
            break;
          }
        }
        if (isCollect) {
          System.out.println(x + " " + y + " " + tmpH);
          return;
        }
      }
    }
  }
}


Measured memory_bytes: 23764
N_M = list(map(int, input().split()))
items = list(map(int, input().split()))
total = sum(items)
match_items = []
for item in items:
    if item >= (total/4 / N_M[1]):
        match_items.append(item)
print('Yes') if N_M[1] <= len(match_items) else print('No')

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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     
const LL MOD = LL(1e9) + 7;



int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    

    int N;
    cin >> N;
    vector<int> ts(N);
    vector<int> aa(N);
    ii (N)
        cin >> ts[i];
    ii (N)
        cin >> aa[i];

    vector<int> fixed(N, 0);
    fixed[0] = 1;
    fixed[N-1] = 1;
    int rightmax = 0;
    if (ts[N-1] != aa[0]) {
                cout << 0 << '\n';
                return 0;
    }
    iii (1, N) {
        if (ts[i] != ts[i-1]) {
            fixed[i] = 1;
            if (ts[i] > aa[i]) {
                cout << 0 << '\n';
                return 0;
            }
        }
        int ci = N-1-i;
        if (aa[ci] != aa[ci+1]) {
            fixed[ci] = 1;
            if (aa[ci] > ts[ci]) {
                cout << 0 << '\n';
                return 0;
            }
        }
    }
    ii (N) {
        if (ts[i] == aa[i]) {
            rightmax = i;
        }
    }

    LL rr = 1LL;
    int prev = 0;
    ii (rightmax) {
        if (fixed[i]) {
            prev = ts[i];
            continue;
        }
        rr = (rr * LL(prev)) % MOD;
    }

    iii (rightmax, N) {
        int ci = N-1-i + rightmax;
        if (fixed[ci]) {
            prev = aa[ci];
            continue;
        }
        rr = (rr * LL(prev)) % MOD;
    }

    cout << rr << '\n';
    

    return 0;
}



Measured memory_bytes: 1408
n,*s=map(int,open(0).read().split());s,t,f,g=[s[i*n:i*n+n]for i in range(4)];r=range(n);a=[n*[0]for _ in r];e=enumerate
for b in range(64):
 y=1<<b;u=[k&y for k in f];v=[k&y for k in g];l=[0]*n;m=l[:]
 for i,k in e(u):
  for j,h in e(v):
   if(k&h)|((s[i]^1)*k)|((t[j]^1)*h):a[i][j]|=y;l[i]+=1;m[j]+=1
 for i in r:
  if(l[i]==0)*s[i]*u[i]:
   for j in r:
    if(t[j]^1)*(n-m[j]>1):a[i][j]|=y;m[j]+=1;break
  if(m[i]==0)*t[i]*v[i]:
   for j in r:
    if(s[j]^1)*(n-l[j]>1):a[j][i]|=y;l[j]+=1;break
h=a[0][:];w=[i[0]for i in a]
for i,k in e(a):
 for j,l in e(k):w[i]=(l|w[i]if s[i]else w[i]&l);h[j]=(l|h[j]if t[j]else h[j]&l)
if(g!=h)|(f!=w):print(-1);exit() 
for i in a:print(*i)

Measured memory_bytes: 99488