akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

int n;

int main () {
    scanf("%d", &n);
    printf("%d\n", n/3);
    return 0;
}

Measured memory_bytes: 768
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,l;
  cin >> n >> l;

  int sum = 0;
  REP(i,n) sum += i+l;

  //debug(sum);

  int ans = INF, mn = INF;

  REP(i,n){
    if(mn > abs(i+l)){
      ans = sum - (i+l);
      mn = abs(i+l);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/* ABC136-B.c
   Takatan */

#include<stdio.h>
#include<math.h>
int main(void){
    int number, count, i, j;
    count = 0;
    i = 10;
    j = 1;

    scanf( "%d" , &number);

    while(number>=i){
        if(j%2==1){ /* i/10からi-1までの整数の桁数が奇数のとき */
            count += i * 9 / 10; /* 加算 */
        }
        i = i * 10;
        j++;
    }
    if(j%2==1){ /* i/10からnumまでの整数の桁数が奇数のとき */
        count = count + number - i / 10 + 1; /* 加算 */
    }

    printf( "%d\n" , count); /* 出力 */
    return 0;
}

Measured memory_bytes: 128
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from sys import exit

import sys
sys.setrecursionlimit(1000000000)
mod = 998244353

#############
# Main Code #
#############

N, X, M = getNM()
# 一つしかないなら二度と出ない
lista = [[-1, -1] for i in range(M)]

n = X
for i in range(2 * M + 1):
    if lista[n][0] == -1:
        lista[n][0] = i
    elif lista[n][1] == -1:
        lista[n][1] = i
    n *= n
    n %= M

cnt = 0
for i in range(M):
    s, e = lista[i]
    # ループする
    if s >= 0 and e >= 0:
        cnt += i * (((N - 1) - s) // (e - s) + 1)
    # 1回きり
    elif s >= 0:
        cnt += i
print(cnt)

Measured memory_bytes: 82452
from collections import Counter
import itertools
n = int(input())
march = Counter()
is_march = ['M', 'A', 'R', 'C', 'H']
for i in range(n):
    head = input()[0]
    if head in is_march:
        march[head] += 1
ans = 0
for c in itertools.combinations(march.keys(), 3):
    t = 1
    for x in c:
        t *= march[x]
    ans += t
print(int(ans))


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int unit = y + z;
		int ans = (x - z)/unit;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22356
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL L;
int Q;
LL X[100011];

const int LOG = 18;
int nxt[LOG][100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", X+i);

    scanf("%lld%d", &L, &Q);
    for (int i=0, j=0; i<N; i++) {
	while (j+1 < N && X[j+1]-X[i] <= L) j++;
	nxt[0][i] = j;
    }

    REP (t, LOG-1) REP (i, N) nxt[t+1][i] = nxt[t][nxt[t][i]];

    REP ($, Q) {
	int a, b;
	scanf("%d%d", &a, &b);
	a--; b--;
	if (a > b) swap(a, b);

	int ans = 0;
	for (int t=LOG; t--;) {
	    if (nxt[t][a] < b) {
		ans += 1<<t;
		a = nxt[t][a];
	    }
	}

	if (a != b) {
	    ans++;
	}
	printf("%d\n", ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 8576
strings = str(input())
string_list = list(strings)
string_set = set(string_list)

import string

alpha = list(string.ascii_lowercase)
alpha_set = set(alpha)

ans = (alpha_set - string_set)
ans = list(ans)
ans.sort()

if len(ans) > 0:
    print(ans[0])
else:
    print("None")

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

int main() {
  int n,q;
  cin >>n>>q;
  vector<int> a(n-1),b(n-1);
  vector<int>t[n],c(n);

  rep(i,n-1) {
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
    t[b.at(i)].push_back(a.at(i));
    t[a.at(i)].push_back(b.at(i));
  }
  vector<int>p(q),x(q);
  rep(i,q){
    cin>>p.at(i)>>x.at(i);
    p.at(i)--;
    c[p.at(i)]+=x.at(i);
  }
  vector<int>ans(n);
  queue<int>que;
  que.push(0);
  ans.at(0)=c.at(0);
  vector<bool>v(n,false);
  v.at(0)=true;
  while(!que.empty()){
    int p=que.front();que.pop();
    rep(j,t[p].size()){
      if(!v.at(t[p].at(j))){
        que.push(t[p].at(j));
        ans.at(t[p].at(j))=ans.at(p)+c.at(t[p].at(j));
        v.at(t[p].at(j))=true;
      }
    }
  }
  
  rep(i,n){
    printf("%d%c",ans[i],' ');
  }
}



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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  int count = 0;
  
  for(int i = 0; i < n; i++){
    if(a.at(i) < 0){
      count++;
      a.at(i) = - a.at(i);
    }
  }
  
  sort(a.begin(), a.end());
  long long ans = 0;
  
  if(count % 2 == 0){
    for(int i = 0; i < n; i++){
      ans += a.at(i);
    }
    cout << ans << endl;
  }
  else{
    a.at(0) = -a.at(0);
    for(int i = 0; i < n; i++){
      ans += a.at(i);
    }
    cout << ans << endl;
  }
}

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

int main(void){
  int a, b;

  cin >> a >> b;

  if(a == b) cout << "Draw" << endl;
  else if(a == 1 || b == 1)
    cout << ((a<b)?"Alice":"Bob") << endl;
  else 
    cout << ((a>b)?"Alice":"Bob") << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
cnt = [0]*3

for i in range(N):
    if(P[i] >= B+1):
        cnt[2] += 1
    elif(P[i] <= A):
        cnt[0] += 1
    else:
        cnt[1] += 1
print(min(cnt))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define nFOR(i,a,b) for(int i=a; i>=b; --i)

#define ll long long
#define pb(x) push_back(x)
#define pii pair <int, int>


const int MAX=2e+5;

using namespace std;

int Fi(int n, int &lastn){
    lastn = n % 10;
    while(n>=10){
        n /= 10;
    }
    return n;
}

main(){
	int n;
	cin>>n;
	ll a[10][10]={0};
	FOR(i,1, n){
		int first, last;
		first=Fi(i, last);
		a[first][last]++;
	}
	ll ans=0;
	FOR(i,1,9){
		FOR(j,1,9) ans+=a[i][j]*a[j][i];
	}
	cout<<ans;
}


Measured memory_bytes: 256
int main() {
	int i, count = 0, max = 0;
	char s[10+1];
	scanf("%s", &s);

	for (i = 0; i < sizeof(s); i++) {
		if (s[i] == 'A')
			count++;
		else if (s[i] == 'C')
			count++;
		else if (s[i] == 'G')
			count++;
		else if (s[i] == 'T')
			count++;
		else {
			if (max < count)
				max = count;
			count = 0;
		}
	}

	printf("%d", max);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(a != c) {
			System.out.println("1");
		}else {
			System.out.println("0");
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(v, n) { rep(_, n) cout << v[_].F << " " << v[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, a) (int)(lower_bound(all(v), a) - v.begin())
#define UB(v, a) (int)(upper_bound(all(v), a) - v.begin())

vector<pair<char, int> > runlength(string str) {
    vector<pair<char, int> > ret;
    int cnt = 1;
    int n = SZ(str);
    rep3(i, 1, n) {
        if (str[i] == str[i - 1]) {
            cnt++;
        } else {
            ret.eb(make_pair(str[i - 1], cnt));
            cnt = 1;
        }
    }
    ret.eb(make_pair(str[n - 1], cnt));
    return ret;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin >> str;
    auto v = runlength(str);
    // outp(v, SZ(v));
    
    int n = SZ(str);
    ll table[n];
    fill_n(table, n, 0);
    if (v[0].F == 'L') table[0] = v[0].S;
    
    ll acc[n];
    acc[0] = v[0].S;
    rep3(i, 1, SZ(v)) acc[i] = acc[i - 1] + v[i].S;
    // outa(acc, SZ(v));
    
    rep3(i, (v[0].F == 'L' ? 1 : 0), (v[SZ(v) - 1].F == 'R' ? SZ(v) - 1 : SZ(v))) {
        if (v[i].F == 'R') {
            ll num = acc[i] - (i == 0 ? 0 : acc[i - 1]);
            table[acc[i] - 1] = num - num / 2;
            table[acc[i]] = num / 2; // L
        } else {
            ll num = acc[i] - acc[i - 1];
            table[acc[i - 1]] += num - num / 2; // L
            table[acc[i - 1] - 1] += num / 2;
        }
        // outa(table, n);
    }
    
    if (v[SZ(v) - 1].F == 'R') table[n - 1] = acc[n - 1] - acc[n - 2];
    
    outa(table, n);
}




Measured memory_bytes: 3140
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N  = scan.nextInt();
        List<Pair>[] list = new List[N];
        for (int i = 0; i < N; i++) {
            int A = scan.nextInt();
            list[i] = new ArrayList<Pair>();
            for (int j = 0; j < A; j++) {
                int x = scan.nextInt()-1;
                int y = scan.nextInt();
                Pair p = new Pair(x, y);
                list[i].add(p);
            }
        }
        int max = pow(N);
        int answer = 0;
        for (int pattern = 0; pattern < max; pattern++) {
            int current = 1;
            boolean[] judge = new boolean[N];
            Arrays.fill(judge, false);
            int count = 0;
            for (int i = 0; i < N; i++) {
                if (0 < (pattern & current)) {
                    judge[i] = true;
                    count += 1;
                }
                current *= 2;
            }
            boolean contradiction = false;
            for (int j = 0; j < N; j++) {
                List<Pair> pair = list[j];
                for (Pair p : pair) {
                    // 正直者
                    if (judge[j]) {
                        if (judge[p.x] && (p.y == 1)) {
                            continue;
                        }
                        if ((!judge[p.x]) && (p.y == 0)) {
                            continue;
                        }
                        contradiction = true;
                        break;
                    }
                }
                if (contradiction) {
                    break;
                }
            }
            if (!contradiction) {
                answer = Math.max(answer, count);
            }
        }
        System.out.println(answer);
    }
    private int pow(int N) {
        int i = 0;
        int pow = 1;
        while (i < N) {
            pow *= 2;
            i += 1;
        }
        return pow;
    }
    class Pair {
        int x;
        int y;
        Pair (int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 28836
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}
int main(){
  int64_t h,w,k;
  cin >> h >> w >> k;
  vector<vector<int64_t>> s(h,vector<int64_t>(w));
  rep(i,h){
    rep(j,w){
      char c;
      cin >> c;
      s[i][j] = (c - '0');
      //cout << s[i][j];    
    }
    //cout << endl;
  }
  int64_t minchoco = 10000000000000;
  setfspattern(2,h-1);
  rep(fs,fspcnt){
    int64_t hbunkatu = 0;
    rep(i,h-1){
      if(fspattern[fs][i] == 1){
        hbunkatu++;
      }
    }
    int64_t wbunkatu = 0;
    vector<int64_t> chococnt(hbunkatu+1);
    int64_t pos = 0;
    int64_t mxc = 0;
    rep(j,w){
      vector<int64_t> tame(hbunkatu+1);
      pos = 0;
      mxc = 0;
      rep(i,h-1){
        //cout << s[i][j] << "###" << endl;
        tame[pos] += s[i][j];
        mxc = max(mxc,tame[pos]+chococnt[pos]);
        //cout << tame[pos]+chococnt[pos] << "L" << endl;
        if(fspattern[fs][i] == 1){
          pos++;
        }
      }
      tame[pos] += s[h-1][j];
      mxc = max(mxc,tame[pos]+chococnt[pos]);
      /*rep(i,hbunkatu+1){
        cout << chococnt[i] << " ";
      }
      cout << endl;*/
      if(mxc > k){
        rep(i,hbunkatu+1){
          chococnt[i] = tame[i];
        }
        wbunkatu++;
        mxc = 0;
      }else{
        rep(i,hbunkatu+1){
          chococnt[i] += tame[i];
        }
      }
      //cout << hbunkatu << endl;
      /*rep(i,hbunkatu+1){
        cout << chococnt[i] << " ";
      }
      cout << endl;*/
    }
    bool ok = true;
    rep(i,hbunkatu+1){
      if(chococnt[i] > k){
        ok = false;
      }
    }
    //cout << hbunkatu+wbunkatu << endl;
    if(ok) minchoco = min(minchoco,hbunkatu+wbunkatu);
    //cout << "////////////////" << endl;
  }
  cout << minchoco << endl;
}


Measured memory_bytes: 384
while 1:
 n=int(input())
 if n==0:break;
 a=[]
 for _ in[0]*n:
  b=list(map(int,input().split()))
  b+=[sum(b)]
  a+=[b]
  for s in b:print("%5d"%s,end='')
  print()
 for c in zip(*a):print("%5d"%sum(c),end='')
 print()


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int H, W;
string board[51];

int dist[51][51];

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

int main() {
    cin >> H >> W;
    rep(i, H) cin >> board[i];

    queue<P> que;
    que.push(make_pair(0, 0));
    fill(dist[0], dist[51], 1e8);
    dist[0][0] = 0;
    while (que.size()) {
        P p = que.front(); que.pop();
        if (p == make_pair(H-1, W-1)) {
            break;
        }
        rep(i, 4) {
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if (ny < 0 or ny >= H or nx < 0 or nx >= W or board[ny][nx] == '#' or dist[ny][nx] != 1e8) continue;
            dist[ny][nx] = dist[p.first][p.second] + 1;
            que.push(make_pair(ny, nx));
        }
    }

    int tmp = dist[H-1][W-1];
    if (tmp == 1e8) {
        cout << -1 << endl;
        return 0;
    }
    int sum = -1;
    rep(y, H) rep(x, W) {
        if (board[y][x] == '.') sum++;
    }
    cout << sum - tmp << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
 
fn main() {
    
    let n = read::<usize>();
    let a : Vec<f64>= (0..n).map(|_| { read::<f64>() }).collect();
    
    let mut sum = 0.;
    for i in 0..n {
        sum += 1. / a[i];
    }
    
    println!("{}", 1. / sum);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	inl(n);
	inl(k);
	ll a[10000010];
	FOR(i,0,n){in(a[i]);}
	sort(a,a+n);
	ll l = -INF;
	ll r = INF;
	while(r-l>1){
		ll mid = (l+r)>>1;
		ll tmp = 0;
		FOR(i,0,n){
			if(a[i]>=0){
				if(a[i]*a[0]>mid)continue;
				ll l1 = i;
				ll r1 = n;
				while(r1 - l1 >1){
					ll mid1 = (r1+l1)>>1;
					if(a[i]*a[mid1]>mid)r1 = mid1;
					else l1 = mid1;
				}
				tmp += l1 - i;
			}
			if(a[i]<0){
				if(a[i]*a[n-1]>mid)continue;
				ll l1 = i;
				ll r1 = n;
				while(r1 - l1 >1){
					ll mid1 = (r1+l1)>>1;
					if(a[i]*a[mid1]>mid)l1 = mid1;
					else r1 = mid1;
				}
				tmp += n-r1;
			}
		}
		if(tmp>=k) r = mid;
		else l = mid;
	}
	out(r);
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll h, w; cin >> h >> w;
  V<string> a(h);
  REP(i, h) cin >> a.at(i);
  vvll dp(h, vll(w, 0)); dp.at(0).at(0) = 1;
  REP(i, h) {
    REP(j, w) {
      if (a.at(i).at(j) == '#') continue;
      if (i == 0 && j == 0) continue;
      else if (i == 0) dp.at(i).at(j) += dp.at(i).at(j-1);
      else if (j == 0) dp.at(i).at(j) += dp.at(i-1).at(j);
      else dp.at(i).at(j) = (dp.at(i-1).at(j) + dp.at(i).at(j-1)) % MOD;
    }
  }
  cout << dp.at(h-1).at(w-1) << endl;
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = ((result%MOD) * (x%MOD))%MOD;
    result %= MOD;
    x=((x%MOD)*(x%MOD))%MOD;
    x %= MOD;
    n >>= 1;
  }
  return result;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}
vector<ll>ar(410) , pref(410);
vector<vector<ll>>dp(410,vector<ll>(410,-1));
ll sum(ll a , ll b){
    if(a==0)return pref[b];
    return pref[b] - pref[a-1];
}
ll solve(ll i , ll j){
  if(i>=j)return 0;
  if(dp[i][j]!=-1)return dp[i][j];
  dp[i][j] = INF;
  for(ll k=i ; k<j ; k++){
    dp[i][j] = min(dp[i][j] , solve(i,k) + solve(k+1,j) + sum(i,k) + sum(k+1,j));
  }
  return dp[i][j];
}
int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  
  ll n;
  cin >> n;
  ar = vector<ll>(n);
  for(auto &x:ar)cin >> x;
  dp = vector<vector<ll>>(n+1 , vector<ll>(n+1,-1));
  pref[0] = ar[0];
  for(ll i=1 ; i<n ; i++)pref[i] = ar[i] + pref[i-1];
    cout << solve(0,n-1);
}

Measured memory_bytes: 2944
/*
 * N M
 * a1
 * ...
 * an
*/

#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <cmath>
#include <cassert>

using namespace std;

int main() {
  long long N, M, mod;
  mod = 1000000000 + 7;
  cin >> N >> M;


  set<long long> s;

  for (int i = 0; i < M; i++) {
    long long a;
    cin >> a;
    s.insert(a);
  }

  vector<long long> counts(N + 1);

  counts[0] = 1;

  for (int i = 1; i < N + 1; i++) {
    if (s.count(i) == 1) {
      counts[i] = 0;
    }
    else if (i == 1) {
      // 0段からは1通り
      counts[i] = counts[i - 1];
    }
    else {
      counts[i] = (counts[i - 1] + counts[i - 2]) % mod;
    }

    // printf("%d, %d\n", i, counts[i]);
  }

  cout << counts[N] << endl;
}



Measured memory_bytes: 5760
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i]>x:
        ans+=a[i]-x
        a[i]=x
for i in range(n-1):
    b=a[i]+a[i+1]
    if b>x:
        ans+=b-x
        a[i+1]-=b-x
print(ans)

Measured memory_bytes: 14060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String strN = sc.next();
        
        String ans = "";
        for(int i = 0; i < strN.length(); i++){
            if( strN.charAt(i) == '1' ){
                ans += "9";
            } else if( strN.charAt(i) == '9' ){
                ans += "1";
            } else {
                ans += strN.charAt(i);
            }       
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 23252
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
int n,m,st[5010],num[5010],b[210][5010],l[210][5010],r[210][5010];
int ans=0,a[5010],pre[5010],sq[5010][5010];
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1,x;i<n;i++){
		scanf("%lld",&x);
		pre[i+1]=pre[i]+x;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%lld",&b[j][i]);
	for(int i=1;i<=m;i++){
		int L=0,R=0;
		for(int j=1;j<=n;j++){
			while(L&&b[i][j]>st[L])L--;
			l[i][j]=L?num[L]+1:1;
			st[++L]=b[i][j];
			num[L]=j;
		}
		for(int j=n;j;j--){
			while(R&&b[i][j]>st[R])R--;
			r[i][j]=R?num[R]-1:n;
			st[++R]=b[i][j];
			num[R]=j;
		}
		for(int j=1;j<=n;j++){
			sq[l[i][j]][j]+=b[i][j];
			sq[l[i][j]][r[i][j]+1]-=b[i][j];
			sq[j+1][j]-=b[i][j];
			sq[j+1][r[i][j]+1]+=b[i][j];
		}		
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			sq[i][j]+=sq[i][j-1];
		for(int j=1;j<=n;j++)
			sq[i][j]+=sq[i-1][j];
		for(int j=i;j<=n;j++)
			ans=max(ans,sq[i][j]-pre[j]+pre[i]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 222488
N, M = [int(n) for n in input().split()]
check = [0] * N
for m in range(M):
  a, b = [int(n) - 1 for n in input().split()]
  if a == 0:
    check[b] += 1
  if b == N-1:
    check[a] += 1
flag = False
for n in range(N):
  if check[n] == 2:
    flag = True

if flag == True:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 4596
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n = input()
    ans = 0
    for i in range(len(n)):
        ans += int(n[i])

    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")


main()


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

using ll = long long;

int const M = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int k;
    cin >> n >> k;
    vector<int> a(n), temp(n);
    int f[2001]{};
    ll r = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        f[a[i]]++;
        for (int j = 0; j < i; j++) {
            if (a[i] < a[j]) {
                r += k;
            }
        }
    }
    int c = n * (n - 1) / 2;
    for (int i = 1; i <= 2000; i++) {
        c -= f[i] * (f[i] - 1) / 2;
    }
    cout << (r + (ll)k * (k - 1) / 2 % M * c) % M << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve();
int main(){
    int t = 1;
    while(t --) solve();
    return 0;
}

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

const int maxn = 1e6 + 6;
const int mod = 1e9 + 7;

int a[maxn], b[maxn];
void solve(){
    multiset<int>s;
    int n, k, q, res = 2e9,Q, X, Y;
    cin >> n >> k >> q;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b+n);
    for(int i = 0; i < n; i ++){
        if(i && b[i] == b[i-1]) continue;
        s.clear();
        int l = i, r = n-1, m;
        while(l <= r){
            m = (l + r) / 2;
            s.clear();
            X = 2e9;
            Y = 0;
            Q = q;
            for(int j = 0; j < n && Q; j ++){
                if(a[j] < b[i]){
                    s.clear();
                }else{
                    s.insert(a[j]);
                    while(!s.empty() && *s.begin() <= b[m] && s.size() >= k){
                        X = min(X, *s.begin());
                        Y = max(Y, *s.begin());
                        Q --;
                        s.erase(s.begin());
                    }
                }
            }
            if(Q == 0){
                res = min(res, Y - X);
                r = m - 1;
            }else
            l = m + 1;
        }
    }
    cout << res << endl;
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int h,w,k;
  ll res = INF;
  cin >> h >> w >> k;
  vector<string> v(h);
  REP(i,h)cin >> v[i];
  for(int bit = 0;bit < (1 << (h-1));bit++){
    vector<vector<int>> nu(h);
    nu[0].push_back(0);
    int dd = 0;
    for(int i = 0;i < h-1;i++){
      if(bit >> i & 1)nu[dd+1].push_back(i+1),dd++;
      else nu[dd].push_back(i+1);
    }
    ll sum = __builtin_popcount(bit);
    int many = sum + 1;
    vector<int> white(many,0);
    vector<int> pre(many,0);
    for(int i = 0;i < w;i++){
      bool flag = true;
      for(int j = 0;j < many;j++){
        int whi = 0;
        for(int ss = nu[j][0];ss - nu[j][0]< (int)nu[j].size();ss++){
          if(v[ss][i]-'0')whi++;
        }
        if(white[j]+whi > k && whi <= k){
          flag = false;
          pre[j] = white[j];
          white[j] += whi;
        }else if(whi > k){
          flag = false;
          sum = INF;
        }else{
          pre[j] = white[j];
          white[j] += whi;
        }
        if(j == many-1){
          if(!flag){
            sum++;
            for(int  gg = 0;gg < many;gg++)white[gg] -= pre[gg];
          }
        }
      }
    }
    res = min(res,sum);


  }
  cout << res << endl;

  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int num[3];
	int i,f,m;
	
	scanf("%d %d %d",&num[0],&num[1],&num[2]);
	
	for(i=0;i<3;i++){
		for(f=i+1;f<3;f++){
			if(num[i]<num[f]){
				m=num[i];
				num[i]=num[f];
				num[f]=m;
			}
		}
	}
	
	m=(num[0]*10)+num[1]+num[2];
	
	printf("%d",m);
	
	return 0;
}

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

int main()
{
    long long a[10];

    for(int i=0; i<10; i++)     scanf("%lld", &a[i]);

    sort(a, a+10);

    printf("%lld\n%lld\n%lld\n", a[9],a[8], a[7]);

    return 0;
}

Measured memory_bytes: 3220
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

######
# URL: https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
######

def main():
    N = i_inpl()
    base_S = input()
    ans = set()
    for i in range(1000):
        S = copy.deepcopy(base_S)
        find_num = str(i).zfill(3)
        k = S.find(find_num[0])
        if k == -1:
            continue

        S = S[k+1:]
        k = S.find(find_num[1])
        if k == -1:
            continue

        S = S[k+1:]
        k = S.find(find_num[2])
        if k == -1:
            continue

        ans.add(find_num)
    print(len(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 39920
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 1;

    for(ll i = 0;i < N;i++){
        cin >> A.at(i);
    }

    sort(A.begin(),A.end());

    for(ll i = 0;i < N;i++){
        if(A.at(i) == 0){
            cout << 0 << endl;
            break;
        }else if(JUUHATI / ans < A.at(i)){
            cout << -1 << endl;
            break;
        }else if(i == N -1){
            if(JUUHATI / ans < A.at(i))
                cout << -1 << endl;
            else
            {
                ans *= A.at(i);
                cout << ans << endl;
            }    
        }else{
            ans *= A.at(i);
        }
    }
    
}

Measured memory_bytes: 4056
n,k=map(int, input().split())
r,s,p=map(int, input().split())
t=list(input())

for num,i in enumerate(t):
    if num<k:
        continue  
    if i==t[num-k]:
        t[num]=0

rl=[]
sl=[]
pl=[]
count=0
for num,i in enumerate(t):
    if i=="r":
        count+=p
        #rl.append(num)
    elif i=="s":
        count+=r
        #sl.append(num)
    elif i=="p":
        count+=s
        #pl.append(num)

print(count)

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

int main() {
	ll H;
	cin >> H;

	ll p = 0;
	for(ll i=0;pow(2,i)<=H;i++){
		p = pow(2,i+1);
	}
    cout << p - 1 << endl;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> ans(10001);
	for(int x = 1; x <= 100; x++){
		for(int y = 1; y <= 100; y++){
			for(int z = 1; z <= 100; z++){
				int tmp = x * x + y * y + z * z + x * y + y * z + x * z;
				if(tmp <= 10000) ans[tmp]++;
			}
		}
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  long a = 2, b = 1;
  long l = 1;
  for (int i = 0;i < n - 1;i++){
    l += a;
    a = b;
    b = l;
  }
  cout << l << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int r = 0;
		for (int i =0;i<m;i++) r += sc.nextInt();
		if (n >= r)
		System.out.println(n - r);
		else System.out.println(-1);
	}
}


Measured memory_bytes: 46384
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

red = p[:X]
green = q[:Y]

red_no_eat = 0
green_no_eat = 0
for no in r:
    red_worst = red[-red_no_eat - 1] if red_no_eat < X else 10 ** 10
    green_worst = green[-green_no_eat - 1] if green_no_eat < Y else 10 ** 10
    if no > red_worst or no > green_worst:
        if red_worst < green_worst:
            red_no_eat += 1
        else:
            green_no_eat += 1
print(sum(p[:X-red_no_eat]) + sum(q[:Y-green_no_eat]) + sum(r[:red_no_eat+green_no_eat]))


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

int main(){
  int n, x;

  while(1){
  	cin >> n >> x;
  	int c = 0;
  	if ( n == 0 && x == 0 ) break;
  	
  	for (int i = 1; i <= n; i++ ){
  	  for ( int j = i + 1; j <= n; j++ ){
  	  	for ( int k = j + 1; k <= n; k++ ){
  	  	  if ( i + j + k == x ) c++;
  	  	}
  	  }
  	}
  	cout << c << endl;
  }
  
  return 0;
}


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

int main(void){
 
 int A,B;
 cin >> A >> B;
 
 if(A*B*1 % 2 == 1 || (A*B*2)&2 == 1 || (A*B*3)%2 == 1){
     cout << "Yes" <<endl;
 }
 else{
     cout << "No" <<endl;
 }
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b, a%b);
}
int main()
{
	int a, b, c;
  cin>>a>>b>>c;
  cout<<min(b/a, c)<<endl;
  
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN

/*
連結成分をつなげていく。
*/

struct UnionFind{
	int n;
	vector<int> r,p;
	UnionFind(){}
	UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
	int find(int x){
		return (x==p[x]?x:p[x]=find(p[x]));
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y) return;
		if(r[x]<r[y]) swap(x,y);
		r[x]+=r[y];
		p[y]=x;
	}
	int size(int x){
		return r[x]=r[find(x)];
	}
};

ll ans[100010]={},tmp;
ll n,m,a[100010],b[100010];

int main(void){
	cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i];
	}
	//
	UnionFind f(n);
	tmp=n*(n-1)/2;
	//
	irep(i,m){
		ans[i]=tmp;
		if(!f.same(a[i]-1,b[i]-1)){
			ll p=f.size(a[i]-1),q=f.size(b[i]-1);
			// cout<<i<<": "<<p<<","<<q<<endl;
			tmp = tmp + p*(p-1)/2 + q*(q-1)/2 - (p+q)*(p+q-1)/2;
			f.unite(a[i]-1, b[i]-1);
		}
	}
	rep(i,m)cout<<ans[i]<<endl;
	return 0;
}

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

const int Maxn = 100005;
int n, cnt, root, fa[Maxn], siz[Maxn], pos[Maxn], head[Maxn];
long long d[Maxn], dis[Maxn];
map <long long, int> Ma;
struct edg
{
	int nxt, to;
}edge[Maxn];
void add(int x, int y)
{
	edge[++cnt] = (edg){head[x], y};
	head[x] = cnt;
}
void dfs1(int u)
{
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		dfs1(to), dis[u] += dis[to] + siz[to];
	}
}
void dfs2(int u)
{
	for (int i = head[u]; i; i = edge[i].nxt)
	{
		int to = edge[i].to;
		dis[to] = dis[u] + n - 2 * siz[to];
		dfs2(to);
	}
}
int main()
{
	scanf("%d", &n);
	root = 1;
	for (int i = 1; i <= n; i++)
		scanf("%lld", &d[i]), pos[i] = i, Ma[d[i]] = i, siz[i] = 1;
	sort(pos + 1, pos + 1 + n, [](int x, int y){return d[x] < d[y];});
	for (int i = n; i >= 1; i--)
	{
		Ma[d[pos[i]]] = 0;
		fa[pos[i]] = Ma[d[pos[i]] - n + 2 * siz[pos[i]]];
		siz[fa[pos[i]]] += siz[pos[i]];
	}
	for (int i = 1; i <= n; i++)
	{
		if (!fa[i] && i != pos[1])
		{
			puts("-1");
			return 0;
		}
		add(fa[i], i);
	}
	dfs1(pos[1]);
	for (int i = 2; i <= n; i++)
		dis[pos[i]] = 0;
	dfs2(pos[1]);
	for (int i = 1; i <= n; i++)
		if (d[i] != dis[i])
		{
			puts("-1");
			return 0;
		}
	for (int i = 2; i <= n; i++)
		printf("%d %d\n", fa[pos[i]], pos[i]);
	return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n ;
	vector<ll> a(n);
	rep(i,n) cin >> a[i]; 

	ll data[100];
	rep(i,100) data[i] = 0;
	
	ll sum = 0 ;
	for(ll i = 0 ; i < n ; i++){
		if(i!=0){
			ll next = a[i];
			ll size = i;
			ll two = 1 ;
			for(ll bit = 0 ; bit < 61 ; bit++){

				if(next &(1ll <<bit)){
					sum += two*(size-data[bit]);
				}
				else{
					sum += two*data[bit];
				}
				sum %= mod;
				two*=2;
				two%=mod;
			}
		}
		ll now = a[i];
		for(ll bit = 0 ; bit < 61; bit++){
			if(now & (1ll <<bit)){
				data[bit]++;
			}
		}
	}
	cout << sum << endl;

}



Measured memory_bytes: 2560
import heapq
N, M = map(int, input().split())
reward = [[] for _ in range(M)]
for i in range(N):
  A, B = map(int, input().split())
  if A <= M:
    reward[A - 1].append(B)
q = []
ans = 0
for day in range(M):
  for r in reward[day]:
    heapq.heappush(q, -r)
  if len(q) > 0:
    ans += -heapq.heappop(q)
print(ans)

Measured memory_bytes: 18504
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,h[110];
int main(){
	read(n);
	int mx=0;
	for(int i=1;i<=n;i++){
		int x;read(x);
		if(x>=n){puts("Impossible");return 0;}
		h[x]++;
		mx=max(mx,x);
	}
	int flag=1;
	if(~mx&1) flag&=h[mx+1>>1]==1;
	else flag&=h[mx+1>>1]==2;
	for(int i=mx;i>mx+1>>1;i--) flag&=h[i]>1;
	for(int i=1;i<mx+1>>1;i++) flag&=!h[i];
	if(flag) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      if(n/100==7||(n%100)/10==7||n%10==7){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
	}
}

Measured memory_bytes: 35532
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
cost = []
for i in range(10):
    cost.append([int(x) for x in stdin.readline().rstrip().split()])

A = []
for i in range(H):
    A.append([int(x) for x in stdin.readline().rstrip().split()])

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j])

ans = 0
for a in A:
    for aa in a:
        if aa == -1:
           continue
        ans += cost[aa][1]
print(ans)

Measured memory_bytes: 3316
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n, m;

    cin >> n >> m;


    vector<pair<long long , long long>>v;
    for (int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());
    long long ans = 0;
    int i = 0;
    while (m > 0) {
        if (m > v[i].second) {
            ans += v[i].first * v[i].second;
            m -= v[i].second;
        }
        else {
            ans += v[i].first * m;
            m = 0;

        }
        i++;
    }

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



Measured memory_bytes: 5332
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100009
#define mod 10000007
using namespace std;
ll dp[109][mx];

int main(){//read(x);
//fast;
ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;
cin>>n>>k;
ll w[n],p[n];
for(i=0;i<n;i++)cin>>w[i]>>p[i];
dp[n][0]=0;
for(i=1;i<=k;i++)dp[n][i]=inf*-1;
for(i=n-1;i>=0;i--){
    for(j=0;j<=k;j++){
        dp[i][j]=max(dp[i+1][j],(j-w[i]>=0)?p[i]+dp[i+1][j-w[i]]:-inf);
    }
}
l=0;
    for(j=0;j<=k;j++)l=max(l,dp[0][j]);
    cout<<l<<endl;
}





















Measured memory_bytes: 82508
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n - 1, 0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9 + 7;
#define ll long long
signed main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int now = 0;
  int nex = 1;
  int ca = 1000;
  int cr = 0;
  bool f = false;
  a.push_back(-9999);
  a.push_back(-9999);
  while (now <= n)
  {
    if (f && a[now] > a[nex])
    {
      f = false;
      ca += cr * a[now];
    }
    else if (!f && a[now] < a[nex])
    {
      f = true;
      cr = ca / a[now];
      ca -= cr * a[now];
    }
    now++;
    nex++;
  }
  cout << ca << endl;

  return 0;
}


Measured memory_bytes: 3640
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
A.append(X)
A.sort()
m = A.index(X)
n = len(A) - 1 - A.index(X)
if n == 0:
  print(0)
elif m < n:
  print(m)
elif m >= n:
  print(n)

Measured memory_bytes: 3060