akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX_N = 100100;
vector<int> dp;
vector<bool> seen;

int longest (const vector<vector<int>> &G, int v) {
    if (seen[v]) return dp[v];
    seen[v] = true;
    if (G[v].size() == 0) return dp[v] = 0;
    int res = 0;
    for (auto u : G[v]) {
        chmax(res, longest(G, u));
    }
    return dp[v] = res + 1;
}

int main() {
    int N, M;
    cin >> N >> M;
    dp.assign(MAX_N, 0);
    seen.assign(MAX_N, false);
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].emplace_back(b);
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        chmax(ans, longest(G, i));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
# -*- coding: utf-8 -*-

def abc158c(a, b):
    min_b = b * 10
    for cand in range(min_b, min_b+10):
        if int(cand * 0.08) == a:
            return cand
    
    return -1

###
# main
if(__name__ == '__main__'):
    # input
    a, b = map(int, input().split(" "))
    
    accomplishment = abc158c(a, b)
    
    # output
    print(accomplishment)
# else:
    # do nothing


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  REP(i,n) cin >> h[i];
  --h[0];
  for(int i = 1; i < n; ++i){
    // if(h[i] > h[i-1] + 1){
    //   cout << "No" << endl;
    //   return 0;
    // }

    if(h[i] > h[i-1]){
      --h[i];
    }
    else if(h[i] == h[i-1]){

    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    
    rep(i, N) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    
    sort(A.begin(), A.end());
    int b = A[N / 2];
    ll ans = 0;
    
    rep(i, N) {
        ans += abs(A[i] - b);
    }
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int a,b,c,d,e,f;
	int g,j,i,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	g=b/d;
	i=c/e;
	j=b%d;
	y=c%e;
	if(j>0)
	{
		g=g+1;
	}
	if(y>0)
	{
		i=i+1;
	}
	if(i>g)
	{
		x=a-i;
		printf("%d\n",x);
	}
	if(g>i)
	{
		x=a-g;
		printf("%d\n",x);
	}
	if(g==i)
	{
		x=a-i;
		printf("%d\n",x);
	}
	
	return 0;
}


Measured memory_bytes: 2140
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();
        for (int i=1; i<=100; i++) {
            if ((A * i) % B == C) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc093/tasks/abc093_b

int main() {
    int A, B, K; cin >> A >> B >> K;
    set<int> ans;

    for (int i = A; i < A+K; i++) {
        if (i > B) continue;
        ans.insert(i);
    }
    for (int i = B; i > B-K; i--) {
        if (i < A) continue;
        ans.insert(i);
    }
    for (int t : ans) {
        cout << t << "\n";
    }

    return 0;
}


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

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

    int g1, g2;

    g1 = X / 500;
    X = X % 500;
    g2 = X / 5;

    cout << g1 * 1000 + g2 * 5 << endl;
}

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

int main(){
    int n;
    cin >> n;
    int i=1,ans;
    while(i*i<=n){
        ans=i*i;
        i++;
    }
    cout << ans << endl;
}



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

int main() {
	int n, k;
	char s[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> k;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[k-1]) s[i] = '*';
	}
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+10;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	ll x; cin >> x;
	vector<ll> v;
	for(ll i = 0; i <= 200; i++){
		v.PB(i*i*i*i*i);
	}

	FOR(i, v.size()){
		FOR(j, v.size()){
			if(v[i] + v[j] == x){
				cout << i << ' ' << -j << '\n';
				return 0; 
			}else if(v[i] - v[j] == x){
				cout << i << ' ' << j << '\n';
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b+c||b==a+c||c==a+b)
	{ 
	printf("Yes");
	} 
	else 
	{
	printf("No");
	} 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>    //super header :標準ライブラリ,STLを全てインクルード
using namespace std;

#define CIN2(a,b) long long a,b;cin >> a >> b; 
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    //string s;cin >> s;
    int a,b,c;scanf("%d/%d/%d",&a,&b,&c);
    if(a>2019){
        cout << "TBD\n";
    }else if(a<2019){
        cout << "Heisei\n";
    }else if(b>4){
        cout << "TBD\n";
    }else{
        cout << "Heisei\n";
    } 
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j;
    long long a[10];
    unsigned long long n,temp;
    for(i=0;i<10;i++){
        scanf("%lld",&a[i]);
    }
    for(i=0;i<10;i++){
        for(j=0;j<10-i-1;j++){
            if(a[j]<a[j+1]){
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }

        }
    }

    for(i=0;i<3;i++){
        printf("%lld\n",a[i]);
    }

     return 0;

}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int n,m,i,j,x,y;
    cin>>n;
    int arr[n+1];
    map<int,int> mp,mpp;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]+i]++;
        mpp[i-arr[i]]++;
    }
    int ans=0;
    for(auto it:mp)
    {
        ans+=(it.second*mpp[it.first]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 39488
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdlib>
using namespace std;


int main(){
    long long int h,w;
    long long int ans =0;
    cin >> h >> w;
    if(w % 2 == 0){
        ans = w/2*h;
    }
    else
    {
        if(h % 2 == 0){
            ans = (w/2+1)*h/2+(w/2)*h/2;
        }else if(h % 2 == 1){
            ans = (w/2+1)*(h/2+1)+(w/2)*(h/2);
        }
    }
    if(w == 1 || h == 1){
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
N = int(input())
ans = 0
for i in range(1, 10):
  for x in itertools.product("753", repeat=i):
    s= ''.join(x)
    if int(s) > N: continue
    if '3' not in s: continue
    if '5' not in s: continue
    if '7' not in s: continue
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<queue>
#include<algorithm>

using namespace std;

int used[1050][1050];
int dis[1050][1050];

int H, W;
string A[1050];

int main(void) {
	cin >> H >> W;

	for (int i = 1; i <= H; i++) {
		cin >> A[i];
		A[i] = "$" + A[i] + "$";
	}
	for (int i = 0; i <= W + 1; i++) {
		A[0] += "$";
		A[H + 1] += "$";
	}

	queue<pair<int, int> > Q;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			dis[i][j] = 3333;
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (A[i][j] == '#') { Q.push(make_pair(i, j)); used[i][j] = 1; dis[i][j] = 0; }
		}
	}

	while (Q.size() > 0) {
		pair<int, int> P = Q.front();
		Q.pop();

		int I = P.first;
		int J = P.second;

		if ((A[I + 1][J] == '.') && (used[I + 1][J] == 0)) { dis[I + 1][J] = dis[I][J] + 1; used[I + 1][J] = 1; Q.push(make_pair(I + 1, J)); }
		if ((A[I -1][J] == '.') && (used[I -1][J] == 0)) { dis[I - 1][J] = dis[I][J] + 1; used[I -1][J] = 1; Q.push(make_pair(I - 1, J)); }
		if ((A[I][J+1] == '.') && (used[I][J+1] == 0)) { dis[I][J+1] = dis[I][J] + 1; used[I][J+1] = 1; Q.push(make_pair(I, J+1)); }
		if ((A[I][J - 1] == '.') && (used[I][J - 1] == 0)) { dis[I][J - 1] = dis[I][J] + 1; used[I][J - 1] = 1; Q.push(make_pair(I, J - 1)); }

	}

	int ans = 0;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			ans = max(ans, dis[i][j]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 18832
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int a,b;
  a=(s[0]-'0')*10+(s[1]-'0');
  b=(s[2]-'0')*10+(s[3]-'0');
  
  int y[2],m[2];
  y[0]=0;y[1]=0;m[0]=0,m[1]=0;
  if(a>=0) y[0]=1;
  if(b>=0) y[1]=1;
  if(a>=1 &&  a<=12) m[0]=1;
  if(b>=1 &&  b<=12) m[1]=1;
  if(y[0]==1 && m[0]==1 && y[1]==1 && m[1]==1){ cout<<"AMBIGUOUS";return 0;}
  if((y[0]==0 && y[1]==0) || (m[1]==0 && m[0]==0)) {cout<<"NA";return 0;}
  if(y[0]==1 && m[1]==1) {cout<<"YYMM";return 0;}
  if(y[1]==1 && m[0]==1) {cout<<"MMYY";return 0;}
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b) gcd(b, a);
	long long  r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
inline long long mod(long long a, long long m) {
	return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {
	if (b == 0) { p = 1; q = 0; return a; }
	long long d = extGcd(b, a%b, q, p);
	q -= a / b * p;
	return d;
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
//amari,mod,amari,mod
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
	long long p, q;
	long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
	if ((b2 - b1) % d != 0) return make_pair(0, -1);
	long long m = m1 * (m2 / d); // lcm of (m1, m2)
	long long tmp = (b2 - b1) / d * p % (m2 / d);
	long long r = mod(b1 + m1 * tmp, m);
	return make_pair(r, m);
}
typedef pair<int, int>p;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int dp[402][402][2];
	int n, ma, mb;
	cin >> n >> ma >> mb;
	for (int i = 0; i < 402; i++) {
		for (int j = 0; j < 402; j++) {
			dp[i][j][0] = dp[i][j][1] = INT_MAX/2;
		}
	}
	dp[0][0][0] = 0;
	int a, b, c;
	for (int z = 1; z <= n; z++) {
		cin >> a >> b >> c;
		for (int i = 0; i < 402; i++) {
			for (int j = 0; j < 402; j++) {
				if (i - a >= 0 && j - b >= 0) {
					dp[i][j][1] = min(dp[i][j][1], dp[i - a][j - b][0] + c);
				}
				dp[i][j][1] = min(dp[i][j][1], dp[i][j][0]);
			}
		}
		for (int i = 0; i < 402; i++) {
			for (int j = 0; j < 402; j++) {
				dp[i][j][0] = dp[i][j][1];
			}
		}
	}
	int x = ma, y = mb;
	int ans = INT_MAX/2;
	while (x <= 400 && y <= 400) {
		ans = min(ans, dp[x][y][0]);
		x += ma;
		y += mb;
	}
	if (ans == INT_MAX / 2)cout << -1;
	else cout << ans;
}


Measured memory_bytes: 1536
test = int(input())

ac = 0
wa = 0
tle = 0
re = 0


for i in range(test):
    n = input()

    if n == "AC":
        ac += 1

    if n == "WA":
        wa += 1

    if n == "TLE":
        tle += 1

    if n == "RE":
        re += 1




print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")


Measured memory_bytes: 9192
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

LL a[100001][3], dp[100001][3];

PLL notof(LL j){
    if(j == 0){
        return MP((LL)1, (LL)2);
    }
    if(j == 1){
        return MP((LL)0, (LL)2);
    }
    if(j == 2){
        return MP((LL)1, (LL)0);
    }
}

int main()
{
    fast();

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    LL t,n,i,j,k,x,y,c;
    cin >> n;
    REP(i, n){
        REP(j, 3){
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    REP(i, n){
        if(i == 0)continue;
        REP(j, 3){
            PLL ind = notof(j);
            dp[i][j] = a[i][j] + max(dp[i - 1][ind.ff], dp[i - 1][ind.ss]);
        }
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a, b, t;

int main(){
	cin >> a >> b >> t;
	cout << b*(t/a) << endl;
	return 0;
}

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

struct UnionFind{
  vector<int> par;
  UnionFind(int N) : par(N){
    r(i,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main() {
  int n,m,sum=0;
  cin >> n >> m;
  vector<int> v(n);
  r(i,n)cin >> v[i];
  
  UnionFind tree(n);
  r(i,m){
    int x,y;
    cin >> x >> y;
    tree.unite(x-1,y-1);
  }
  r(i,n){
    if(tree.same(i,v[i]-1))sum++;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1024
const main = input =>{
    const IN = input.split("\n");
    const N = parseInt(IN[0].split(" ")[0]);
    const K = parseInt(IN[0].split(" ")[1]);
    const list = IN[1].split(" ")
    count = 0;

    for(var i=0; i<N; i++){
        if(list[i] >= K){
            count ++;
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for(long long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    long long N;
    cin >> N;
    vector<long long> div = divisor(N);

    long long res = 0;
    for(long long q : div) {
        if(q < (N / q - 1)) res += N / q - 1;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll H, W;
    cin >> H >> W;
    write(H == 1 || W == 1 ? 1 : (H * W + 1) / 2);
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -optc-O2 #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Applicative
import Control.Monad

hasNext :: (Int, Int, Int) -> Bool
hasNext (a, b, c) = even a && even b && even c

getNext :: (Int, Int, Int) -> (Int, Int, Int)
getNext (a, b, c) = (a', b', c')
    where ! a' = (b + c) `div` 2
          ! b' = (a + c) `div` 2
          ! c' = (a + b) `div` 2

states :: (Int, Int, Int) -> [(Int, Int, Int)]
states a | hasNext a = a : states (getNext a)
         | otherwise = [a]

getLength :: (Eq a) => [a] -> Int
getLength [] = 0
getLength [_] = 1
getLength xs = go (0, xs) (2, drop 2 xs)
    where go (tl, t) (hl, h) = case h of
                                 []  -> hl
                                 [_] -> hl + 1
                                 _   -> if head t == head h
                                        then (-1)
                                        else go (tl + 1, tail t) (hl + 2, drop 2 h)

main :: IO ()
main = do
  [a, b, c] <- map read . words <$> getLine
  let length = getLength $ states (a, b, c)
  if length < 0
  then print length
  else print (length - 1)


Measured memory_bytes: 508
program ccc
implicit none

integer :: n, i, j, st, en, res
integer,allocatable,dimension(:) :: h

read*, n
allocate(h(0:n+1))
read*, h(1:n)

h(0)=0
h(n+1)=0
st=0
en=0
res=0

do while(sum(h)/=0)

do i=0,n
if(h(i)==0.and.h(i+1)/=0) then
st=i+1
exit
end if
end do
do i=0,n
if(h(i)/=0.and.h(i+1)==0) then
en=i
exit
end if
end do

do i=st,en
h(i)=h(i)-1
end do

res=res+1

end do

write(*,'(i0)') res

end program

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

vector<unsigned long long> next_p_mod(unsigned N, long long mod) { //next_permutation
  vector<unsigned long long> Next_p(N);
  unsigned long long Next_p_buff = 1;
  for (int i = 0; i < N; i++)
  {
    Next_p_buff *= (i + 1) % mod;
    Next_p.at(i) = Next_p_buff % mod;
  }
  return Next_p;
}
unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod) {
   unsigned long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v,unsigned long long mod) {
  //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
    }
  }
}
// a^{-1} mod を計算する
unsigned long long modinv(unsigned long long a, unsigned long long mod) {
    return modpow(a, mod - 2, mod);
}


// modinv
/*void modinv(unsigned long long N, unsigned long long mod,unsigned long long *inv) {
 // unsigned long long inv[N] ;
  for (unsigned long long i = 1; i < N; i++) {
    inv[i] = (i == 1) ? 1 : (mod - (mod / i) * inv[mod % i] % mod);
    assert(inv[i] * i % mod == 1);
  }
  //return 0;
}*/

int main() {
  int N,D;
  ll chk=0;
  long chk2=0;
  double chk3=0;
  unsigned long long mod = 1000000000 + 7;
  cin >> N >> D;
  long C=0;
    vector< vector<int> > v (N, vector<int>(D) );
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
    cin>>v[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=0;k<D;k++){
        chk+=pow(v[i][k]-v[j][k],2.0);
      }
      //cout<<chk<<" : ";
      chk2=sqrt(chk);
      chk3=sqrt(chk*1.0);
      //cout<<chk<<endl;
      if(chk2==chk3){
        C++;
      }
      chk=0;
    }
  }
        cout<<C<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll A[MAX_N];
    ll answer;
    vector<ll> edge;

    cin >> N;
    rep(i, N) cin >> A[i];
    map<ll,ll> cnt;
    rep(i, N) cnt[A[i]] = 0;
    rep(i, N) cnt[A[i]] ++;
    for(auto& kv: cnt){
        if (kv.second >= 4) rep(i,2) edge.push_back(kv.first);
        else if (kv.second >= 2) edge.push_back(kv.first);
    }
    sort(rall(edge));

    if (edge.size() > 1){
        cout << edge[0] * edge[1] << endl;
    }else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,i;
	scanf("%d %d %d",&a,&b,&c);
	if(c*2>=b-a+1)
	{
		for(i=a;i<=b;i++)
			printf("%d\n",i);	
	}
	else
	{
		for(i=a;i<a+c;i++)
			printf("%d\n",i);
		for(i=b-c+1;i<=b;i++)
			printf("%d\n",i);	
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  string s; cin >> s;
  int ans = 0;

  rep(i, si(s)-1) {
    if (s[i] != s[i+1]) ++ans;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3728
#include <stdio.h>
#include <string.h>

int main(void){
    int K, i;
    char S[200005];
    scanf("%s", S);
    K=strlen(S);
    for (i=0; i<=strlen(S)-2; i++) {
        if (S[i]==S[i+1]) {
            K--;
            i+=2;
            // printf("%d\n", i);
        }
    }
    printf("%d", K);
    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 9;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    char c;
    cin>>c;
    if(c>='A'&&c<='Z') {
        cout<<'A';
    }
    else {
        cout<<'a';
    }
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3616
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47568
#include <bits/stdc++.h>
#define PI acos(-1)
#define falcon ios_base::sync_with_stdio(false) ; cin.tie(NULL) ;
typedef long long ll ;
using namespace std ;

int main()
{
    falcon ;

    vector <int> heights , dp ;

    int n , k ;
    cin >> n >> k ;
    for(int i = 0 ; i < n ; i++)
    {
        int height ;
        cin >> height ;
        heights.push_back(height) ;
    }
    dp.push_back(0) ;
    for(int i = 1 ; i < n ; i++)
    {
        dp.push_back(dp[i - 1] + abs(heights[i] - heights[i - 1])) ;
        for(int j = 2 ; j <= k ; j++)
        {
            if(i - j < 0) break ;
            dp[i] = min(dp[i] , dp[i - j] + abs(heights[i] - heights[i - j])) ;
        }
    }
    cout << dp[n - 1] << "\n" ;
}

Measured memory_bytes: 4280
import sys

n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
n_bin = len(bin(max(a_ls))) - 2
a_ls = [bin(a)[2:].zfill(n_bin) for a in a_ls]
cnt = {i : 0 for i in range(n_bin)}
for a in a_ls:
    for i, _a in enumerate(a):
        cnt[i] += _a == "1"
flg = True
if sum(cnt.values()) == 0:
    print("Yes")
elif n % 3 != 0:
    print("No")
else:
    for i in range(n_bin):
        flg &= (cnt[i] == 0 or cnt[i] == n // 3 * 2)
        if not flg:
            break
    if flg:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15840
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    ll a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    qsort(a,n,sizeof(ll),compare);
    for(i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
typedef pair<int,int> P;
string alph="abcdefghijklmnopqrstuvwxyz";

signed main(){
    int  a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double maxi=-1;
    int x=0,y=0;;
    for(int i=0;i<=f/a*100;i++){
        for(int j=0;100*a*i+100*b*j<=f;j++){
            double w=(a*i+b*j)*100;
            double s=w/100*e;
            for(int k=0;k*c<=s;k++){
                for(int g=0;c*k+g*d<=s;g++){
                    double rs=c*k+g*d;
                    double key=rs/(rs+w)*100;
                    if(rs+w<=f&&key>maxi){
                        maxi=key;
                        x=w;y=rs;
                    }
                }
            }
        }
    }
    cout<<x+y<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = {0,0,0};
		boolean b = true;
		for(int i = 0; i < n; i++){
			int[] nextArray = new int[3];
			for(int j = 0; j < 3; j++){
				nextArray[j] = sc.nextInt();
			}
			int t = nextArray[0] - array[0];
			int length = Math.abs(nextArray[1] - array[1]) + Math.abs(nextArray[2] - array[2]);
			if(!(b = t >= length && (t - length) % 2 == 0)) break;
		}
		System.out.println(b ? "Yes" : "No");
	}
}


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

using namespace std;

typedef long long  ll;

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

    string s;
    cin >> s;
    const int n = s.size() + 1;
    vector<int> h(n);
    h[0] = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == '\\')
            h[i] = 1;
        else if (s[i - 1] == '/')
            h[i] = -1;
        else if (s[i - 1] == '_')
            h[i] = 0;
    }
    for (int i = 1; i < n; ++i)
        h[i] += h[i - 1];

    double area = 0.0;
    vector<double> L;
    int left = 0, right = 0;

    while (left < n) {

        right = left + 1;
        if (n <= right)
            break;
        if (h[left] == h[right] || h[left] > h[right]) {
            ++left;
            continue;
        }

        while (right < n && h[left] != h[right])
            ++right;
        if (right == n) {
            ++left;
            continue;
        }

        double tmp = 0.0;
        int p = 0;
        for (int i = left; i < right; ++i) {
            if (s[i] == '\\') {
                tmp += p + 0.5;
                ++p;
            }
            else if (s[i] == '/') {
                tmp += (p - 1) + 0.5;
                --p;
            }
            else
                tmp += p;
        }

        L.emplace_back(tmp);
        area += tmp;
        left = right;
    }

    cout << (int)area << endl;
    cout << L.size();
    for (int i = 0, size = L.size(); i < size; ++i)
        cout << " " << (int)L[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 1364
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <numeric>
#define PI 3.141592653589793238462643383279
#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;
#define debret(x) debug(x) ; return 0;

using namespace std;

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

    char a[N];
    
    REP(i,N) {
        cin >> a[i];
    }

    int cnt = 1;

    char base = a[0];
    FOR(i,1,N) {
        if (base != a[i]) {
            cnt++;
            base = a[i];
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

a, b = input().split()

tmp = 0
res = 0

a = int(a)
b = int(b.replace(".", ""))
res = a * b // 100

print(res)


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int X, Y, A, B, C;
        cin >> X >> Y >> A >> B >> C;
        vector<Int> P(A), Q(B), R(C);
        for (int i = 0; i < A; ++i) cin >> P[i];
        for (int i = 0; i < B; ++i) cin >> Q[i];
        for (int i = 0; i < C; ++i) cin >> R[i];
        sort(P.rbegin(), P.rend());
        sort(Q.rbegin(), Q.rend());
        sort(R.rbegin(), R.rend());

        priority_queue<pair<Int, Int>> pq;
        Int sum = 0;
        vector<Int> cnt(3);
        auto add = [&](Int val, Int col) {
            sum += val;
            pq.push(make_pair(-val, col));
            cnt[col]++;
        };
        auto del = [&]() {
            auto top = pq.top();
            top.first *= -1;

            pq.pop();
            sum -= top.first;
            cnt[top.second]--;
            return top;
        };

        for (int i = 0; i < X; ++i) {
            add(P[i], 0);
        }
        for (int i = 0; i < Y; ++i) {
            add(Q[i], 1);
        }

        Int ans = sum;
        for (int i = 0; i < C; ++i) {
            del();
            add(R[i], 2);
            chmax(ans, sum);
        }
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 8816
#include <stdio.h>

int
main(void)
{
	int w, h, x, y, r;

	scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
	printf("%s\n", ((x - r) < 0 ||
			(y - r) < 0 ||
			(x + r) > w ||
			(y + r) > h) ? "No" : "Yes");

	return 0;
}


Measured memory_bytes: 2100
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map (read :: String -> Int) . words <$> getLine
  print $ solve as

solve :: [Int] -> Int
solve as = go as' (if length as' /= 1
                   then (head y <= head (head ys))
                   else True)
  where
    as'@(y:ys) = group as
    go :: [[Int]] -> Bool -> Int
    go [] _ = 0
    go [x] _ = 1
    go (x:xs@(z:zs)) b
      | head x <= head z , b = go xs b 
      | head x >= head z , not b = go xs b
      | otherwise = if (not.null) zs
                    then 1 + go zs (head z <= head (head zs))
                    else 1 + go xs b


Measured memory_bytes: 52604
package main
 
import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)
 
func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    var queue [][]int
    line, _, _ := reader.ReadLine()
    arr := strings.Split(string(line), " ")
    H, _ := strconv.Atoi(arr[0])
    W, _ := strconv.Atoi(arr[1])
    visited := make([][]int, H)
 
    for i := 0; i < H; i++ {
        line, _, _ = reader.ReadLine()
 
        for j, v := range line {
            visited[i] = append(visited[i], -1)
 
            if string(v) == "#" {
                var val []int
                val = append(val, j)
                val = append(val, i)
                queue = append(queue, val)
                visited[i][j] = 0
            }
        }
    }
 
    // BFS
    var dx [4]int
    var dy [4]int
    dx[0] = 0
    dx[1] = 0
    dx[2] = 1
    dx[3] = -1
    dy[0] = 1
    dy[1] = -1
    dy[2] = 0
    dy[3] = 0
    var now_x, now_y, next_x, next_y int
    var cnt int = 0
 
    for len(queue) > 0 {
        now_x = queue[0][0]
        now_y = queue[0][1]
 
        for i := 0; i < 4; i++ {
            next_x = queue[0][0] + dx[i]
            next_y = queue[0][1] + dy[i]
 
            if next_x >= 0 && next_x < W &&
               next_y >= 0 && next_y < H &&
               visited[next_y][next_x] == -1 {
               var val []int
               val = append(val, next_x)
               val = append(val, next_y)
               queue = append(queue, val)
               visited[next_y][next_x] = visited[now_y][now_x] + 1
               cnt = visited[next_y][next_x]
            }
        }
 
        queue = queue[1:]
    }
 
    fmt.Println(cnt)
}

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

using namespace std;

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

    int n , k , q;
    cin >> n >> k >> q;

    vector<int> s(n + 1 , 0);
    for (int i = 0 ;i < q ;i++) {
        int x;
        cin >> x;
        s[x]++;
    }

    for (int i = 1 ;i <= n ;i++) {
        if (k - q + s[i] > 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}


Measured memory_bytes: 3708
#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
using namespace std;

int main(){
	int n,x,a;
	while(1){
		cin>> n>> x;
		if(n==0 && x==0)break;
		a=0;
		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){
						a++;
					}
				}
			}
		}
		cout<< a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;

int main(){
	int n;

	cin >> n;

	vector<ll> a(n + 1, 0);
	vector<ll> b(n, 0);

	for (size_t i = 0; i < n + 1; ++i) {
		ll tmp;
		cin >> tmp;
		a[i] = tmp;
	}
	for (size_t i = 0; i < n; ++i) {
		ll tmp;
		cin >> tmp;
		b[i] = tmp;
	}

	vector<ll> c(n+1, 0);

	for (size_t i = 0; i < n; ++i) {
		ll rem = b[i];
		if (a[i] <= b[i]) {
			c[i] += a[i];
			rem -= a[i];
			a[i] = 0;
		} else {
			c[i] += b[i];
			rem = 0;
			a[i] -= b[i];
		}

		if (a[i+1] <= rem) {
			c[i+1] += a[i+1];
			rem -= a[i+1];
			a[i+1] = 0;
		} else {
			c[i+1] += rem;
			a[i+1] -= rem;
			rem = 0;
		}
	}

	ll ret = accumulate(begin(c), end(c), 0LL);

	cout << ret << endl;
	
	return 0;
}

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

int main(void){
  char b; cin>>b;
  if(b=='A') cout<<'T'<<endl;
  if(b=='T') cout<<'A'<<endl;
  if(b=='C') cout<<'G'<<endl;
  if(b=='G') cout<<'C'<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
N = len(S)
count = 0
R_1 = [-1 for i in range(26)]
R_2 = [-1 for i in range(26)]

answer = "Yes"
for i in range(N):
    r1 = ord(S[i]) - 97
    r2 = ord(T[i]) - 97
    if R_1[r1] >= 0:
        if r2 != R_1[r1]:
            answer = "No"
            break
    if R_2[r2] >= 0:
        if r1 != R_2[r2]:
            answer = "No"
            break
    if R_1[r1] < 0:
        R_1[r1] = r2
    if R_2[r2] < 0:
        R_2[r2] = r1
print(answer)

Measured memory_bytes: 9340
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(reader.readLine().replace(" ", ""));
        System.out.print(num % 4 == 0 ? "YES" : "NO");        
    }
}


Measured memory_bytes: 32708
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		int h1 = reader.ni();
		int m1 = reader.ni();
		int h2 = reader.ni();
		int m2 = reader.ni();
		int k = reader.ni();

		int a = h1 * 60 + m1;
		int b = h2 * 60 + m2;

		int p = b - a;
		p -= k;

		p = Math.max(0, p);

		out.println(p);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32868
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

i64 Xor(i64 x){
  if(x&1) return !((x>>1)&1);
  else if(x==0) return 0;
  else return x ^ Xor(x-1);
}

void Main()
{
  i64 A, B;
  cin >> A >> B;

  if(A==0){
    cout << Xor(B) << "\n";
  } 
  else{
    cout << (Xor(A-1) ^ Xor(B)) << "\n";
  }
  return;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H == 0 && W == 0)break;
		for(int a = 0;a < H;a++){
			for(int b = 0;b < W;b++){
				if(a == 0 || a == H - 1 || b == 0 || b == W - 1){
					cout<<"#";
				}else{
					cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
N, x = map(int, input().split())
A = list(map(int, input().split()))

# if len(A) % 2 == 0:
#     A = A + [0]
# print('A', A)

ans = 0
for i in range(1, N):
    total = A[i - 1] + A[i]
    diff = total - x
    if diff <= 0:
        continue
    v1 = min(A[i], diff)
    v2 = diff - v1
    A[i] -= v1
    A[i - 1] -= v2
    ans += v1 + v2
    # print('A', A)
print(ans)


Measured memory_bytes: 14052
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int n = sc.nextInt();
	    int v[] = new int[n];
	    int c[] = new int[n];
	    
	    int sum = 0;
	    
	    for(int i = 0; i < n; i++) {
	    	v[i] = sc.nextInt();
	    }
	    
	    for(int i = 0; i < n; i++) {
	    	c[i] = sc.nextInt();
	    }
	    
	    for(int i = 0; i < n; i++) {
	    	if((v[i] - c[i] > 0)) {
	    		sum += (v[i]-c[i]);
	    	}
	    }
	    
	    System.out.println(sum);
	}
}

Measured memory_bytes: 22736
import java.util.Scanner;
import java.util.ArrayList;
class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
 
int N = scan.nextInt();
int K = scan.nextInt();
int TT[] = new int[N];
int i, j, e, d;
int count = 0;
  for (i = 0; i < K; i++){
    d = scan.nextInt();
      for(j = 0; j < d; j++){
        e = scan.nextInt();
        TT[e-1] = 1;
        }
   }

  for (i = 0; i < N; i++){
    if (TT[i] == 0){
    count += 1;
    }
    else{
    }
  }
  System.out.println(count);
 }
}

Measured memory_bytes: 46200
def main():
    N = int(input())
    H = list(map(int, input().split()))
    
    num_lower = [0]*(N)

    step = 0
    h_right = H[-1]
    for i in range(N-2, -1, -1):
        h = H[i]
        if h >= h_right:
            step += 1
        else:
            step = 0
        num_lower[i] = step
        h_right = h

    print(max(num_lower))
    
main()

Measured memory_bytes: 20336
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm> 
#include <cmath>
#include <cstdlib>
using namespace std;
#define ll long long 
#define gc getchar_unlocked
const ll int INF = 1e18;
const int MOD = 1000000007;
const int MAXW = 1e5+10;

ll knapsack[MAXW];
int N,W;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	
  	cin>>N>>W;
	for(int item = 1;item<=N;item++)
    {
		int w,v;
		cin >> w >> v;
		for(int i = W;i>=w;i--) knapsack[i] = max(knapsack[i-w] + v,knapsack[i]);
	}
	ll best = 0;
	for(int i = 0;i<=W;i++)
      best = max(best,knapsack[i]);
	cout<<best<<"\n";
}

Measured memory_bytes: 4348