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








int main(){

  long long n,m;
  cin>>n>>m;
  

  vector<vector<long long>> data(n,vector<long long>(2));
  
  for (long long i=0;i<n;i++){
    long long a,b;
    cin>>a>>b;
    data.at(i).at(0)=a;
    data.at(i).at(1)=b;
  }
  
  sort(data.begin(),data.end());
  
  long long count=m;
  
  long long answer=0;
  
  for (long long i=0;i<n;i++){
    long long tmp;
    tmp=min(count,data.at(i).at(1));
    count-=tmp;
    answer+=data.at(i).at(0)*tmp;
    if (count==0){
      break;
    }
  }
  
  cout<<answer<<endl;
  
      
    
  
  

  
  

  

        
}

Measured memory_bytes: 5760
from collections import deque
from collections import defaultdict
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
  if x[i]-1 < i or x[i]-1 > n*n-n+i:
    print("No")
    exit()
    
ans = [-1]*n*n
for i in range(n):
  ans[x[i]-1] = i+1
x2 = []
for i in range(n):
  x2.append((x[i],i+1))
x2.sort()
yusen = deque([])
ato = deque([])
for i in range(n):
  yusen.extend([x2[i][1]]*(x2[i][1]-1))
  ato.extend([x2[i][1]]*(n-x2[i][1]))
for i in range(n*n):
  if ans[i] == -1:
    if yusen:
      ko = yusen.popleft()
      ans[i] = ko
    else:
      ko = ato.popleft()
      ans[i] = ko
d = defaultdict(int)
for i in range(n*n):
  d[ans[i]] += 1
  if d[ans[i]] == ans[i]:
    if i+1 != x[ans[i]-1]:
      print("No")
      exit()
print("Yes")
print(*ans)


Measured memory_bytes: 60964
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for _ in range(m)]

ans=min(al)+min(bl)
for i in range(m):
    tmp=0
    tmp=al[xyc[i][0]-1]+bl[xyc[i][1]-1]-xyc[i][2]
    ans=min(ans,tmp)
print(ans)

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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> p(n); rep(i, 0, n) { cin >> p[i]; }
		vector<int> j(n - 1); rep(i, 0, n - 1) { cin >> j[i]; }
		int sum = accumulate(all(p), 0);
		int cnt = n;
		sort(all(j), greater<int>());
		int ma = sum*n;
		rep(i, 0, n - 1) {
			sum += j[i];
			cnt--;
			chmax(ma, sum*cnt);
		}
		cout << ma << endl;
	}
	return 0;
}

Measured memory_bytes: 3872
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
arr = L()
answer = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if arr[i] == arr[j]:
            continue
        for k in range(j+1, n):
            if arr[i] == arr[k] or arr[j] == arr[k]:
                continue
            if (arr[i] + arr[j] > arr[k]) and (arr[i] + arr[k] > arr[j]) and (arr[j] + arr[k] > arr[i]):
                answer += 1
out(answer)


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

const int mod = 1e9 + 7;
int main() {
    long  long N, K;
    cin >> N >> K;
    long long res = 0;
    for (long long k = K; k <= N + 1; ++k) {
        long long first = k * (k - 1) / 2;
        long long final = (N * 2 - k + 1) * k / 2;
        long long add = final - first + 1;
        res = (res + add) % mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3600
(defun solve (r d x c)
  (if (= c 0)
      nil
      (let ((x1 (- (* r x) d)))
        (format t "~A~%" x1)
        (solve r d x1 (- c 1)))))

(let ((r (read))
      (diff (read))
      (x (read)))
  (solve r diff x 10))

Measured memory_bytes: 12008
N = int(input())  # 数値入力
c = list(map(int, input().split()))  # 複数数値入力(リスト格納)
ans = float("inf")  # 無限

for i in range(1, N):
    a = sum(c[0:i])
    b = sum(c[i:N])

    if ans > abs(a - b):
        ans = abs(a-b)

print(ans)


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
import sys
import collections

def main():
	S = input()
	S = list(S)
	
	ans = 0
	for i, vol in enumerate(S):
		tmp = 0
		if vol == "A" or vol == "C" or vol == "G" or vol == "T":
			tmp += 1
			for j in range(i+1, len(S)):
				if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
					tmp += 1
				else:
					break
			if ans < tmp:
				ans = tmp
			
		
	
	print(ans)
			
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3572
#include<cstdio>
main(){for(char t[11];scanf("%s",t)!=EOF;){int i,s,p[10]={1,9,6,4,6,6,4,6,9,1};for(i=s=0;i<10;)s+=(t[i]-48)*p[i++];printf("%d\n",s%10);}}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    ll n, k;
    ll ans = 0;
    cin >> n >> k;
    for (ll i = k; i <= n + 1; ++i) {
        ll a = (i - 1) * i / 2;
        ll b = i * (2 * (n - i + 1) + i - 1) / 2;
        ans += max(0LL, b - a + 1);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

// dp[S][v] := 頂点0から出発して、集合Sに含まれる頂点をすべて訪れるpath
// のうち、頂点vが最後になるようなpathの総数
ll dp[2000][20];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = 1;
        g[b][a] = 1;
    }

    dp[1][0] = 1;

    for (int S = 1; S < (1 << n); S++)
    {
        for (int v = 0; v < n; v++)
        {
            if ((S & (1 << v)) == 0)
            {
                continue;
            }
            int sub = (S ^ (1 << v));
            for (int u = 0; u < n; u++)
            {
                if ((sub & (1 << u)) && g[v][u] == 1)
                {
                    dp[S][v] += dp[sub][u];
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        ans += dp[(1 << n) - 1][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  vi x(n);
  rep(i, n) cin >> x[i];
  int c = 0;
  loop(i, 1, n) c += min((x[i] - x[i - 1]) * a, b);
  cout << c << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char s[20];
    scanf("%s",s);
    int l=strlen(s);
    int i;
    for(i=0; i<l ; i++)
    {
        if(s[i]==',') s[i]=' ';
    }
    printf("%s\n",s);

}


Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int a[505][505];
int main() {
    int n;
    cin >> n;
    if(n == 1) {
        cout << "Yes" << endl << "1" << endl;
        return 0;
    }
    if(n % 2 == 1)
        cout << "No" << endl;
    else if(n % 2 == 0) {
        cout << "Yes" << endl;
        for(int i = 1; i <= n; i++)
            a[i][i] = n;
        for(int i = 1; i <= n / 2; i++)
            a[i][n - i + 1] = 2 * n - 1;
        for(int i = n / 2 + 1; i <= n; i++)
            a[i][n - i + 1] = 1;
        for(int j = 1; j <= n / 2 - 1; j++)
            for(int i = j + 1; i <= n - j; i++)
                a[i][j] = i + j - 1;
        for(int j = 1; j <= n / 2 - 1; j++)
            for(int i = j + 1; i <= n - j; i++)
                a[j][i] = 2 * n - i - (j - 1);
        for(int i = 2; i <= n / 2; i++)
            a[i][n] = 2 * n + 1 - 2 * i;
        for(int i = n - 1; i >= n / 2 + 1; i--)
            a[i][n] = n + 2 * (n - i);
        for(int i = n / 2 + 1; i <= n - 1; i++)
            a[n][i] = i * 2 - n;
        for(int i = 2; i <= n / 2; i++)
            a[n][i] = 2 * i - 1;
        for(int i = n - 1; i >= n / 2 + 2; i--)
            for(int j = (n - i) + 2; j <= i - 1; j++)
                a[i][j] = a[i][j - 1] + 1;
        for(int i = n - 1; i >= n / 2 + 2; i--)
            for(int j = (n - i) + 2; j <= i - 1; j++)
                a[j][i] = a[j - 1][i] - 1;
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j < n; j++)
                cout << a[i][j] << " ";
            cout << a[i][n] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4080
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
char sign[2]={'+','-'};
char b[5];
int sum,flag=0;
int a[5];
void dfs(int num){
    if((num==3&&sum==7)||flag==1) {
        flag=1;
        return ;
    }
    else if(num==3) return ;
    for(int i=0;i<2;i++){
        if(i==0) sum+=a[num+1];
        else sum-=a[num+1];
        b[num]=sign[i];
        dfs(num+1);
        if(flag==1) return ;
        if(i==0) sum-=a[num+1];
        else sum+=a[num+1];
    }

}
int main(){
    int n;

    scanf("%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3]);

    sum=a[0];
    dfs(0);
    for(int i=0;i<4;i++){
        printf("%d",a[i]);
        if(i!=3) printf("%c",b[i]);
    }
    printf("=7");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = INF<int>;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(), v.end());
    for (int i = 0; i < n-k+1; ++i) {
        ans = min(ans, v[i+k-1]-v[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n;cin >> n;
    vector<int>d(n);
    rep(i,n)cin >> d[i];
    int sum = 0;

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            sum += d[i]*d[j];
        }
    }
    cout << sum << endl;
    return 0;
}


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

int n;
void solve(){
    cin >> n;
    int ans = 0;
    for(int i=1;i<=n;++i) {
        for(int j=1;j<=n&&i*j<=n;++j) {
            if(n-i*j > 0)
                ans ++;
        }
    }
    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3652
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <math.h>
int main(void){
	int a,b,s[1001],i,j,k,n;
	double x,y,m;
	while(1){
		scanf("%d%*c",&n );
		if(n==0)break;
		for(i=0,a=0;i<n;i++){
			scanf("%d",&s[i] );
			a+=s[i];
		}
		m=(double)a/n;
		for(i=0,x=0;i<n;i++){
			x+=pow(s[i]-m,2)/n;
		}
		printf("%f\n",sqrt(x));
	}


	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<int> A(N),B(N),need1(160000),need2(160000),side(N),s(N),cnt(N);
        for(int i=0;i<N;i++){
            cin>>A[i]>>B[i];
            chmax(need1[1],A[i]);
        }
        
        int t=0;
        while(1){
            bool ok=false;
            for(int i=0;i<N;i++){
                if(cnt[i]==B[i]) continue;
                ok=true;
                
                if(side[i]==0){
                    if(t>=max(s[i]+A[i],need1[s[i]])){
                        side[i]=1;
                        s[i]=t;
                        chmax(need2[t+1],t+A[i]);
                    }
                }else{
                    if(t>=max(s[i]+A[i],need2[s[i]])){
                        side[i]=0;
                        cnt[i]++;
                        s[i]=t;
                        if(cnt[i]!=B[i]) chmax(need1[t+1],t+A[i]);
                    }
                }
            }
            for(int i=t+2;i<=t+300;i++){
                chmax(need1[i],need1[i-1]);
                chmax(need2[i],need2[i-1]);
            }
            if(!ok) break;
            t++;
        }
        cout<<t-1<<endl;
    }
}



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

using namespace std;

int main() {
    int n;
    long l;
    cin >> n >> l;
    long a, prev=-10000000000;
    int i = 0;
    for ( ; i<n; i++) {
        cin >> a;
        if (a + prev >= l) 
            break;
        prev = a;
    }
    if (i == n) {
        cout << "Impossible" << '\n';
        return 0;
    }
    cout << "Possible" << '\n';
    for (int j=1; j<i; j++) 
        cout << j << '\n';
    for (int j=n-1; j>i; j--) 
        cout << j << '\n';
    cout << i << '\n';
    return 0;
}

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


int partition(int A[], int p, int r) {
  int x = A[r];
  int i = p-1;
  for (int j = p; j < r; ++j) {
    if (A[j] <= x) {
      swap(A[++i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i+1;
}

int main() {
  int n;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  int q = partition(A, 0, n-1);
  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    if (i == q) cout << "[";
    cout << A[i];
    if (i == q) cout << "]";
  }
  cout << endl;
}



Measured memory_bytes: 3364
#include<iostream>
using namespace std;
#define N 1000000
int main(){
	bool prime[N+1] = {0};
	prime[1] = 1;
	for(int i = 2; i * i <= N; i++){
		if(prime[i] == 0){
			for(int j = i; j <= N; j+=i){
				prime[j] = 1;
			}
			prime[i] = 0;
		}
	}
	int n;
	while(cin >> n){
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			if(!prime[i])cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

int main() {
    int a;
    int b;
    cin >> a >> b;
    if (a < b){
      cout <<"a < b" << endl;
    } else if (a == b) {
      cout << "a == b" << endl;
    } else {
      cout <<"a > b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	string s; cin >> s;
	cout << s.length() - (find(s.begin(), s.end(), 'A') - s.begin()) - (find(s.rbegin(), s.rend(), 'Z') - s.rbegin()) << endl;
	return 0;
}

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

int n, k, t, X[100000 + 100], A[100000 + 100],m,result;

int main(){
	cin >> t;
	for (int i = 0; i < t; i++){
		cin >> n >> k;
		for (int j = 0; j < n; j++)
			cin >> X[j];
		for (int j = 0; j < n - 1; j++)
			A[j] = X[j + 1] - X[j];
		sort(A, A + n - 1);
		m = max(0, n - 1 - (k - 1));
		result = 0;
		for (int j = 0; j < m; j++){
			result += A[j];
		}
		cout << result << endl;
	}

}

Measured memory_bytes: 1956
sss = str(input())
ss_list = []

for i in range(len(sss)):
    for j in range(i,len(sss)+1):
        ss_list.append(sss[i:j])
ss_list = list(set(ss_list))


#文字列を渡して、AGTCから構成されていればその長さを返す
def bh(ss):
    flag = 0
    for s in ss:
        if s not in ["A","G","T","C"]:
            flag = 1
    if flag == 0:
        return len(ss)
    else:
        return 0

max_len = 0
for ss in ss_list:
    l = bh(ss)
    if l>max_len:
        max_len = l

print(max_len)

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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
string S;
int W[300010], E[300010];

int main() {
    cin >> N >> S;
    S = " " + S;
    W[0] = 0;
    E[N+1] = 0;
    for (int i = 1; i <= N; ++i) {
        W[i] = W[i-1] + (S[i] == 'W');
    }
    for (int i = N; i >= 0; --i) {
        E[i] = E[i+1] + (S[i] == 'E');
    }

    int ans = N;
    for (int i = 1; i <= N; ++i) {
        ans = min(ans, W[i-1] + E[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define N 51
#define INF 1e9
using namespace std;
typedef long long ll;
int n,num[3];
ll rG[N];

ll mem[N][110],used[N][110];
ll dfs(int pos,int dep){
  if(dep==0) return (1LL<<pos);
  if(used[pos][dep]++) return mem[pos][dep];

  ll res=0;
  for(int i=0;i<n;i++)
    if((rG[pos]>>i)&1)res|=dfs(i,dep-1);
  return mem[pos][dep]=res;
}

  
int bfs(){
  vector<int> D(N,INF);
  int cnt[3][N]={};
  queue<int> Q;
  Q.push(n-1);
  D[n-1] = 0;
  
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    int cost = D[pos];
    if(pos==0) return cost;
    
    for(int k=0;k<3;k++)
      for(int i=0;i<n;i++)cnt[k][i]|=(dfs(pos,num[k])>>i)&1;

    for(int i=0;i<n;i++){
      if(!cnt[0][i]||!cnt[1][i]||!cnt[2][i]||D[i]<=cost+1)continue;
      Q.push(i);
      D[i] = cost+1;
    }
  }
  return 0;  
}

int main(){
  int m;
  cin>>n>>m;
  for(int i=0;i<3;i++)cin>>num[i];
  for(int i=0,a,b;i<m;i++)cin>>a>>b,rG[b-1]|=1LL<<(a-1);

  int ans = bfs();
  if(ans)cout<<ans<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;

const int INF = 1001001001;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  for(int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  for(int i = 0; i < n; i++) {
    ok[i] = reachableFrom1[i]&reachableToN[i];
  }
  { // bellman-ford
    vector<int> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      for(int i = 0; i < m; i++) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        int newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("-1");
        return 0;
      }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
  }
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll k, x;
  cin >> k >> x;
  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, m, p = map(int, input().split())
abc = []
for _ in range(m):
    a, b, c = map(int, input().split())
    abc.append([a-1, b-1, p-c])

d = [float('inf')] * n
d[0] = 0

for i in range(n):
    for a, b, c in abc:
        d[b] = min(d[b], d[a] + c)

for a, b, c in abc:
    if d[b] > d[a] + c:
        d[b] = - float('inf')

for i in range(n):
    for a, b, c in abc:
        d[b] = min(d[b], d[a] + c)

if d[n-1] == - float('inf'):
    print(-1)
else:
    print(max(0, - d[n-1]))


Measured memory_bytes: 57816
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int INF=1e9;
ll a[maxn],b[maxn],k,n;
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
ll ans=0;
void dfs(ll bit,ll now,bool check){
	if(check && bit>=0){
		if(k & (1<<bit)){
			dfs(bit-1,now,1);
			dfs(bit-1,now^(1<<bit),0);
		}
		else dfs(bit-1,now^(1<<bit),1);
	}
	else{
		if(now==-1)return;
		ll res=0;
		ll i;
		for(i=1;i<=n;i++)
			if((a[i] & now) == a[i])res+=b[i];
		ans=max(ans,res);
	}
}
int main(){
	ll i,j,m;
	n=read();k=read();
	for(i=1;i<=n;i++){
		ll x=read(),y=read();
		a[i]=x;b[i]=y;
	}
	dfs(30,-1,1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

static const int MAX = 100;
static const long long INFTY = 1LL << 32;

int n;
long long d[MAX][MAX];

void floyd()
{
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (d[i][k] == INFTY) continue;
			for (int j = 0; j < n; j++) {
				if (d[k][j] == INFTY) continue;
				if (d[i][j] > d[i][k] + d[k][j])
					d[i][j] = d[i][k] + d[k][j];
			}
		}
	}
}

int main()
{
	int e, u, v, c;
	cin >> n >> e;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = ((i == j) ? 0 : INFTY);
		}
	}

	for (int i = 0; i < e; i++) {
		cin >> u >> v >> c;
		d[u][v] = c;
	}

	floyd();

	bool negative = false;
	for (int i = 0; i < n; i++) if (d[i][i] < 0) negative = true;

	if (negative) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j) cout << " ";
				if (d[i][j] == INFTY) cout << "INF";
				else cout << d[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
ll ans = -1;
  int n; cin>>n;
  for (int i=0; i<n; i++) {
    ll x; cin>>x;
    if (i==0) {
      ans = x; continue;
    }
    ans = ans / __gcd(ans, x) * x;
  }
  cout<<ans<<endl;
  

  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
 
int R,C,N;
ll x,y;

PP G[100005]; 

ll c[100005],r[100005],A[100005],X[100005],Y[100005];

vector<P> ex[100005],ey[100005]; bool xx[100005],z;

const ll INF=100000000005;

void dfs(int a,bool b){

	if(!b){
		while(ex[a].size()){
			if(c[ex[a][0].first]!=INF){
				if(c[ex[a][0].first]!=ex[a][0].second-r[a]){
					z=1;
 				}
			}
			else{
				c[ex[a][0].first]=ex[a][0].second-r[a];
				if(c[ex[a][0].first]<y) y=c[ex[a][0].first];
				dfs(ex[a][0].first,1);
			}
				ex[a].erase(ex[a].begin());
	    }
	}else{
		while(ey[a].size()){
			if(r[ey[a][0].first]!=INF){
				if(r[ey[a][0].first]!=ey[a][0].second-c[a]){
					z=1;
				}
			}
			else{
				r[ey[a][0].first]=ey[a][0].second-c[a];
				if(r[ey[a][0].first]<x) x=r[ey[a][0].first];
				dfs(ey[a][0].first,0);
			}
				ey[a].erase(ey[a].begin());
		}
	}

	return;
}
 
int main(){             
  
  cin>>R>>C>>N; 
  
  for(int i=0; i<N; i++) scanf("%ld %ld %ld", &G[i].first.first, &G[i].first.second, &G[i].second);

  sort(G,G+N);

  for(int i=0; i<N; i++){
  	X[i]=G[i].first.first; xx[X[i]]=1;
  	Y[i]=G[i].first.second;
  	A[i]=G[i].second;
  }

  for(int i=0; i<100005; i++){
  	c[i]=INF; r[i]=INF;
  }

  for(int i=0; i<N; i++){
  	ex[X[i]].push_back(P(Y[i],A[i]));
  	ey[Y[i]].push_back(P(X[i],A[i]));
  }

  for(int i=1; i<=R; i++){
  	if(xx[i]&&r[i]==INF){
  		r[i]=0; 
  		x=0; y=INF;
		dfs(i,0); 
		if(x+y<0){
			cout<<"No"<<endl; return 0;
		}	
  	}
  }

  if(z){
  	cout<<"No"<<endl; return 0;
  }

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

Measured memory_bytes: 20992
#include<stdio.h>
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if(x==2||y==2)
		printf("No\n");
	else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))
		printf("Yes\n");
	else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
		printf("Yes\n");
	else
		printf("No\n");
    return 0;
}

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


#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define ll long long
#define all(v) v.begin(), v.end()

#define si set<int>
#define sl set<long long>

#define pair(x,y) pair<x, y>

#define frt(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rew(i,a,b) for(int i=a;i>=b;i--)

#define mod %
#define pow ^

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test if(TEST == 1)

#define left (2*idx)+1
#define right (2*idx)+2

#define INF 1000000000000000000
#define MOD (ll)(1e9 + 7)
#define N 7001

ll powerf(ll a, ll b, ll c)
{
    ll ans = 1;
    
    while(b>0)
    {
        if(b & 1)
        {
            ans = (ans * a) % c;
        }
        b = b >> 1;
        a = (a * a) % c;
    }
    
    return ans;}

int main()
{

    FIO
    int TEST = 0;
    int t = 1;

    while(t--)
    {
        int n;
        cin >> n;
        if(n == 1)
        {
            cout << 1 << "\n";
            return 0;
        }
        vector<pair(int, int)> v;
        fre(i, 1, n)
        {
            int x, y;
            cin >> x >> y;
            v.pb({x, y});
        }

        set<pair<int, pair<int,int>>> s;
        map<pair<int, int>, int> m;

        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(j == i)
                    continue;

                int d_x = v[i].first - v[j].first;
                int d_y = v[i].second - v[j].second;

                pair<int, int> d = {d_x, d_y};

                if(m[d] == 0)
                {
                    m[d] = 1;
                    s.insert({m[d], d});
                }
                else
                {
                    s.erase({m[d], d});
                    m[d]+=1;
                    s.insert({m[d], d});
                }
            }
        }
        pair<int, pair<int, int>> d = *s.rbegin();
        // cout << d.first << " : " << d.second.first << " " << d.second.second << "\n";
        cout << n - (*s.rbegin()).first << "\n";

    }  
}




Measured memory_bytes: 512
import Data.List

f xs = case length xs of
         n | h == n -> 0
           | h < n  -> n - h
           | h > n  -> n
  where
    h = head xs

main :: IO ()
main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    print . sum . map f . group  . sort $ a

Measured memory_bytes: 39548
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    cout << (n+k-3)/(k-1) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int all,a,b,c,d;
	cin>>all;
	a=all/1000;
	b=(all-a*1000)/100;
	c=(all-a*1000-b*100)/10;
	d=(all-a*1000-b*100-c*10);
	//cout<<a<<b<<c<<d<<endl;
	if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
	else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
	else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
	else if(a-b-c-d==7)cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
	else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
	else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
	else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
    else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n,k=map(int,input().split())
a=list(map(int,input().split()))

order = []
now = 1
count = 0
d = defaultdict(int)


for i in range(n):
    if d[now]!=0:
        s=d[now]-1
        g=i
        break
    order.append(now)
    d[now] = i+1
    now = a[now-1]


if k<=s:
    print(order[k])
else:
    k-=s
    loop = order[s:g]
    print(loop[k%len(loop)])

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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a, b, c, d;
    for (int i = 0; i < Q; i++) {
        int ai, bi, ci, di;
        cin >> ai >> bi >> ci >> di;
        a.push_back(ai);
        b.push_back(bi);
        c.push_back(ci);
        d.push_back(di);
    }
    vector<int> perm(N+M-1, 1);
    for (int i = 0; i < N; i++) perm[i] = 0;
    long long ans = 0;
    do {
        vector<int> A(N+1, 0);
        int v = 1, cnt = 1;
        for (int j = 0; j < N + M -1; j++) {
            if (perm[j] == 1) {
                v++;
                continue;
            }
            A[cnt] = v;
            cnt++;
        }
        long long ans_temp = 0;
        bool ok = true;
        for (int i = 1; i <= N; i++) if (A[i-1] > A[i]) {
            ok = false;
            break;
        }
        if (ok) for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) ans_temp += d[i];
        }
        if (ok) ans = max(ans, ans_temp);
        // for (auto i: perm) {
        //     cout << i;
        // }
        // cout << endl;
    } while(next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s;
	cin >> s;
	if (c < b) {
		/*bool flag = true;
		FOR(i, a, c) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		FOR(i, b, d) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		if (flag) {
			put("Yes");
		}
		else {
			put("No");
		}*/
	}
	else if (c < d) {
		bool flag = true;
		FOR(i, a, d) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		if (flag) {
			put("Yes");
		}
		else {
			put("No");
		}
	}
	else {
		bool flag = true;
		FOR(i, a, c) {
			if (s[i] == '#' && s[i + 1] == '#') {
				flag = false;
			}
		}
		if (!flag) {
			put("No");
			return 0;
		}
		bool flag2 = false;
		FOR(i, b-1, d) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				flag2 = true;
				break;
			}
		}
		if (flag2) {
			put("Yes");
		}
		else {
			put("No");
		}
	}
	return 0;
}


Measured memory_bytes: 640
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]


T = sorted(T)

num  = 0  
bus = 0
flag = 0

if C != 1:
  
  for n in range(N):
    if flag == 0:
      person_limit = C-1
      time_limit = T[n] + K
      flag = 1
    else:
      if T[n] <= time_limit:
        person_limit -= 1
        if person_limit == 0:
          bus += 1
          flag = 0
      else:
        bus += 1
        person_limit = C-1
        time_limit = T[n] + K
        flag = 1

    if n == N-1 and flag == 1:
      bus += 1

else:
  bus = len(T)

print(bus)

Measured memory_bytes: 13964
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	int N;
	long long K, ans = 0;
	scanf("%d %lld", &N, &K);
	long long A[N + 1];
	A[0] = 0;
	for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
	map<long long, long long> hi;
	int lower = 0;
	for (int i = 1; i <= N; ++i) A[i] += A[i - 1] - 1;
	for (int i = 1; i <= N; ++i) A[i] %= K;
	hi[A[0]] = 1;
	for (int i = 1; i <= N; ++i) {
		if (i - lower >= K) --hi[A[lower++]];
		ans += hi[A[i]];
		++hi[A[i]];
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 14336
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]


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


ans = 0
for h in range(H):
    for w in range(W):
        if A[h][w] == -1:
            continue
        ans += C[A[h][w]][1]

print(ans)


Measured memory_bytes: 73988
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#define EPS (1e-7)
using namespace std;






int main() {


	string S;
	long long K;
	long long current = 0, prec = 0;
	int ans;
	cin >> S >> K;
	vector<pair<long long,long long>> L(S.size());

	for (auto i = 0; i < S.size(); i++)
	{
		L[i] = make_pair(S[i]-48, 1);
	}
	if (K == 1) {
		cout << L[0].first << endl;
		return 0;
	};

	for (auto j = 0; j < S.size(); j++)
	{

		if (L[j].first == 1) {
			if (current >= K-1) {
				cout << L[j].first << endl;
				return 0;
			}
			current += 1;
		}
		else {
			for (auto i = 0; i < 5000000000000000; i++)
			{
				L[j].second = L[j].first*L[j].second;
				if (prec + L[j].second >= K-1) {
					cout << L[j].first << endl;
					return 0;
				}
 			}
			current += L[j].second;
		}
		prec = current;
	}

	

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int n, x, ans;
  while(1){
    cin >> n >> x;
    ans = 0;
    if(n==0 && x==0) break;
    for(int i = 1; i < n; i++){
      for(int j = i+1; j < n; j++){
        int k = x-i-j;
        
        if(k <= n && k > 0 && k > j) {
          ans++;
        }
      }
    }
    print(ans);
  }

}



Measured memory_bytes: 3100
N=int(input())
a=list(map(int,input().split()))
b=[]
if N%2==0:
  for i in range(int(N/2)):
    b+=[a[N-1-2*i]]
  for i in range(int(N/2)):
    b+=[a[2*i]]
else:
  for i in range(int((N+1)/2)):
    b+=[a[N-1-2*i]]
  for i in range(int((N-1)/2)):
    b+=[a[2*i+1]]
print(' '.join(map(str, b)))

Measured memory_bytes: 29768
N,M = map(int,input().split())
ab = []
for i in range(M):
    ab+= list(map(int,input().split()))

counters = {}

for i in range(1,N+1):
    counters[i] = 0

for i in ab:
    if i in counters:
        counters[i] += 1
    else:
        continue

for num in counters.values():
    print(num)


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

#define MAX_N 100
#define MAX_V 100000
#define INF 1<<30
typedef long long int ll;

ll dp[MAX_N + 1][MAX_V + 1];

int main() {
  int n, v[MAX_N + 1];
  ll W, w[MAX_N + 1];

  std::cin >> n >> W;
  for(int i = 0; i < n; ++i) {
    std::cin >> w[i] >> v[i];
  }

  for(int j = 1; j <= MAX_V; ++j) {
    dp[0][j] = (v[0] >= j) ? w[0] : INF;
  }

  for(int i = 1; i < n; ++i) {
    for(int j = 1; j <= MAX_V; ++j) {
      dp[i][j] = dp[i - 1][j];
      if(j - v[i] >= 0) {
        dp[i][j] = std::min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
      }
    }
  }

  int ans = 0;
  for(int j = 1; j <= MAX_V; ++j) {
    if(dp[n - 1][j] <= W) {
      ans = j;
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000

int main(){
	
	int N;
	cin>>N;
	priority_queue<pair<int,int>> L;
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> R;
	vector<pair<long long,long long>> P(N);
	for(int i=0;i<N;i++){
		cin>>P[i].first>>P[i].second;
		L.emplace(P[i].first,i);
		R.emplace(P[i].second,i);
	}
	
	set<int> used;
	long long ans = 0LL;
	long long now = 0LL;
	
	for(int i=0;true;i++){
		if(L.size()==0&&R.size()==0)break;
		while(L.size()!=0&&used.count(L.top().second))L.pop();
		long long l = Inf;
		if(L.size()!=0){
			l = L.top().first;
			used.insert(L.top().second);
			L.pop();
		}
		while(R.size()!=0&&used.count(R.top().second))R.pop();
		long long r = Inf;
		if(R.size()!=0){
			r = R.top().first;
			used.insert(R.top().second);
			R.pop();
		}
		//cout<<l<<','<<r<<endl;
		if(l!=Inf)ans = max(ans,now+2*l);
		if(r!=Inf)ans = max(ans,now-2*r);
		if(l==Inf||r==Inf)break;
		now += 2*l;
		now -= 2*r;
		ans = max(ans,now);
	}
	
	cout<<ans<<endl;
	

	return 0;
}

Measured memory_bytes: 11148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, k;
    cin >> n >> k;
    set<int> st;
    rep(i, n) st.insert(i+1);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int x;
            cin >> x;st.erase(x);
        }
    }
    cout << st.size() << '\n';
    return 0;
}

Measured memory_bytes: 3636
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;

   cin>>s1;
   if(s1[3]==s1[2]&&s1[4]==s1[5])
   {
       cout<<"Yes"<<endl;
   }
   else{cout<<"No"<<endl;}
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,M,C;
    cin >>N>>M>>C;
   vector<int> B(M);
   for(int i =0;i < M;i++) cin >> B[i];
   int ans = 0;
   for(int i = 0;i < N;i++){
       vector<int> A(M);
       int sum = 0;
       for(int j = 0;j < M;j++){
           cin >> A[j];
           sum += A[j] * B[j];
       }
       if(sum + C > 0) ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::*;
use std::cmp::max;
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut score = 0;
    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 40;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0, 5);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        score += max_score;
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
    l: usize,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let l = max(1, l - 1);
    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    let w = if l > 1 { 2 } else { 1 };
    for &(_, j) in cands.iter().take(w) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score, l);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


Measured memory_bytes: 2372
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0 for i in range(n)]

for i in range(n):
	a[i] = (p[i]*(p[i]+1)//2)/p[i]
s = sum(a[:k])
mx = s
for j in range(k,n):
	s += a[j]
	s -= a[j-k]
	mx = max(mx,s)
	#print (mx)
print (mx)

Measured memory_bytes: 25060
import javax.swing.*;
import javax.swing.plaf.synth.SynthSpinnerUI;
import java.util.Scanner;
import java.util.function.DoubleToIntFunction;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int x,tmp = 1;
        while((x = scan.nextInt()) != 0){
            System.out.println("Case " + tmp + ": " + x);
            tmp++;
        }




    }

}


Measured memory_bytes: 41740
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string n;
    cin >> n;
    for (int i = 0; i < n.size(); ++i) {
        if (n[i] == '9') {
            n[i] = '1';
        } else if (n[i] == '1') {
            n[i] = '9';
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256