akhauriyash/Code-Regression huggingface dataset:
import itertools
H,W = map(int,input().split())
mas = [input() for _ in range(H)]
ans = 0
for i, j in itertools.product(range(H), range(W)):
    if mas[i][j] == '.':
        pass
    else :
        if i == 0 : # top row
            if j == W - 1 : # right edge
                if mas[i][j-1] == '.' and mas[i][j+1] == '.' :
                    print('No')
                    #print(1)
                    ans = 1
                    break
            elif j == 0 : # left edge
                if mas[i+1][j] == '.' and mas[i][j+1] == '.' :
                    print('No')
                    #print(2)
                    ans = 1
                    break
            else :
                if mas[i][j - 1] == '.' and mas[i + 1][j] == '.' and mas[i][j + 1] == '.':
                    print('No')
                    #print(3)
                    ans = 1
                    break
        elif i == H - 1 : # bottom row
            if j == W - 1 : # right edge
                if mas[i-1][j] == '.' and mas[i][j-1] == '.' :
                    print('No')
                    #print(4)
                    ans = 1
                    break
            elif j == 0 : # left edge
                if mas[i-1][j] == '.' and mas[i][j-1] == '.' :
                    print('No')
                    #print(6)
                    ans = 1
                    break
            else :
                if mas[i-1][j] == '.' and mas[i][j + 1] == '.' and mas[i][j - 1] == '.':
                    print('No')
                    #print(5)
                    ans = 1
                    break
        else : # middle row
            if j == W - 1 : # right edge
                if mas[i-1][j] == '.' and mas[i][j-1] == '.' and mas[i+1][j] == '.' :
                    print('No')
                    #print(7)
                    ans = 1
                    break
            elif j == 0 : # left edge
                if mas[i+1][j] == '.' and mas[i][j-1] == '.' and mas[i][j+1] == '.' :
                    print('No')
                    #print(8)
                    ans = 1
                    break
            else :
                if mas[i-1][j] == '.' and mas[i + 1][j] == '.' and mas[i][j - 1] == '.' and mas[i][j + 1] == '.':
                    print('No')
                    #print(9)
                    ans = 1
                    break
if ans == 0 :
    print('Yes')

Measured memory_bytes: 3192
from collections import*;M=lambda:map(int,input().split());n,k,l=M();d=[-1]*n;t=[-1]*n;r=range
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):
  if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x)
for i in r(k+l):a,b=M();u(d if i<k else t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in r(n)];c=Counter(p);print(*[c[p[i]]for i in r(n)])

Measured memory_bytes: 44400
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    int k, ans = -1;
    cin >> k;
    int m = 0;
    rep(i, 0, 10000000){
        m = (m*10 + 7)%k;
        if(m == 0){
            ans = i+1; break;
        }
    }
    cout << ans << endl;
}
signed main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3636
num_list = [int(i) for i in input().split()]
product_list = [int(i) for i in input().split()]

lim_score = sum(product_list) * (1/(4*num_list[1]))

ok_list = [i for i in product_list if i >= lim_score]

if len(ok_list) >= num_list[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */
int main() {
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes" << '\n';
	else cout << "No" << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

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

  map<ll, ll> mp;
  for (ll i = 0; i < N; i++)
  {
    ll a;
    cin >> a;
    mp[a]++;
  }

  vector<ll> A;
  for (auto itr = mp.begin(); itr != mp.end(); itr++)
  {
    if (itr->second < 2)
      continue;
    A.push_back(itr->first);
    if (itr->second >= 4)
      A.push_back(itr->first);
  }

  sort(A.begin(), A.end(), greater<ll>());

  ll ans = (A.size() >= 2) ? (A.at(0) * A.at(1)) : (0);
  cout << ans << endl;
}

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000000

using namespace std;
#define prime 1000000007

const ll N = 300005;

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int a, b;

int ce(int a, int b){
	return (a+b-1)/b;
}

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

	if(a < 13){
		if(a < 6) printf("0\n");
		else printf("%d\n", b/2);
	}else{
		printf("%d\n", b);
	}

	return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

main = do
    [n,x] <- map read . words <$> getLine
    xs <- sort . (x:) . VU.toList . VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine :: IO [Int]
    let xs' = map snd $ drop 2 $ scanl' (\(prev, _) x -> (x, abs $ prev - x)) (0, 0) xs :: [Int]
    print $ foldl1' gcd xs'

Measured memory_bytes: 15740
#include <bits/stdc++.h>
#define MAXN 200100
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;


int main (){
    ios_base::sync_with_stdio(false);
    int n, k;

    cin >> n >> k;

    int ini = max(-1000000, k - n + 1);

    for (int i = ini; i <= ini+n+n-2; i++){
        if (i - ini) cout << " ";
        cout << i ;
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
string S;



long long dp[200100][5];

int main() {
  cin >> S;
  
  memset(dp, 0, sizeof(dp));
  
  dp[0][0] = 1;
  for (int i = 0; i < S.size(); ++i) {
	for (int j = 0; j < 5; ++j) {
      
	  if (S[i] != '?') dp[i+1][j] += dp[i][j]%1000000007 ;
      
	  else dp[i+1][j] += dp[i][j] * 3 % 1000000007;
	}
	if (S[i] == 'A' || S[i] == '?') dp[i+1][1] += dp[i][0]%1000000007;
	if (S[i] == 'B' || S[i] == '?') dp[i+1][2] += dp[i][1]%1000000007;
	if (S[i] == 'C' || S[i] == '?') dp[i+1][3] += dp[i][2]%1000000007;  
  }
  
  cout << dp[S.size()][3]%1000000007 << endl;
}


Measured memory_bytes: 8320
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin>>s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') s[i] = '9';
    else if (s[i] == '9') s[i] = '1';
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const int INF = 1e9+7;

struct edge{
	int from;
	int to;
	int cost;
};

int N,M,P;
int v[2555];
bool reachableFrom0[2505],reachableToN[2505],ok[2505];
vector<vector<int>> to(2505),rto(2505);

void dfs(int v){
	if(reachableFrom0[v]==true)return;
	reachableFrom0[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(void){
	cin >> N >> M >> P;
	int S = 0;		//始点
	int G = N-1;	//終点
	ll d[2505];	//始点からそこまで行くのにかかるコスト
	vector<edge> edges;
	fill(d,d+N,INF);
	d[0] = 0;//始点を0にする
	for(int i=0;i<M;i++){
		struct edge add;
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;c -= P;
		to[a].push_back(b);
		rto[b].push_back(a);
		add.from = a;
		add.to = b;
		add.cost = -c;
		edges.push_back(add);
	}
	dfs(0);
	rdfs(N-1);
	for(int i=0;i<N;i++)ok[i] = reachableFrom0[i]*reachableToN[i];
	for(int i=0;i<N;i++){
		for(int j=0;j<(int)edges.size();j++){
			struct edge e = edges[j];
			if(!ok[e.from])continue;
			if(!ok[e.to])continue;
			if(d[e.to]> d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i==N-1){
					cout << -1 << endl;
					return 0;
					break;
				}
			}
		}
	}
	cout << max((ll)0,-d[N-1]) << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
using namespace std;
vector<int> cs(vector<int> &a, int n){
    vector<int> b(n);
    vector<int> c(10001, 0);
    for(int i=0;i<n;++i) c[a[i]]++;
    for(int i=1;i<10001;++i) c[i]=c[i]+c[i-1];
    for(int i=n-1;i>=0;--i){
        b[c[a[i]]-1]=a[i];
        c[a[i]]--;
    }
    return b;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    vector<int> b=cs(a,n);
    for(int i=0;i<n;++i) cout<<(i?" ":"")<<b[i];
    cout<<endl;
}

Measured memory_bytes: 18560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

double v[200020];

int main(){
  rep(i,200020)v[i]=longinf;
  int n;
  cin >> n;
  pair<double,pair<double,double>> p[n];
  double t=0;
  rep(i,n){
    double x;
    cin >> x;
    double s=t;
    double e=t+x;
    t+=x;
    p[i].second.first=s;
    p[i].second.second=e;
  }
  rep(i,n)cin >> p[i].first;
  sort(p,p+n);
  rep(i,n){
    rep(j,2*t+1){
      if(p[i].second.first<=0.5*j && 0.5*j<=p[i].second.second){
        v[j]=min(v[j],p[i].first);
      }
    }
  }
  rep(i,n){
    rep(j,2*t+1){
      v[j]=min(v[j],p[i].first+min(abs(0.5*j-p[i].second.first),abs(0.5*j-p[i].second.second)));
    }
  }
  rep(j,2*t+1)v[j]=min(v[j],-0.5*j+t);
  rep(j,2*t+1)v[j]=min(v[j],0.5*(double)j);
//  rep(i,2*t+1)cout << i << ' ' << v[i] << endl;
  double ans=0.0;
  rep(i,2*t){
    ans+=(v[i]+v[i+1])/2.0;
  }
  cout << setprecision(12) << ans/2.0 << endl;
return 0;}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#define rep(i,n) for(int i=0; i < (n); i++)
int main(){
  char n[1000];
  scanf("%s",n);
  int len=strlen(n)-1;
  if(n[len]=='3'){
    printf("bon");
    return 0;
  }else if(n[len]=='0'){
    printf("pon");
  }else if(n[len]=='6'){
    printf("pon");
  }else if(n[len]=='1'){
    printf("pon");
  }else if(n[len]=='8'){
    printf("pon");
  }else{
    printf("hon");
  }
  return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

void dfs(vector<vector<int>> &G, vector<int> &dist, int v) {
  dist.at(v) = 0;
  queue<int> Q;
  Q.push(v);
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();

    for (int nv : G.at(v)) {
      if (dist.at(nv) == -1) {
        dist.at(nv) = dist.at(v) + 1;
        Q.push(nv);
      }
    }
  }
}

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

  int N, X, Y;
  cin >> N >> X >> Y;
  --X;
  --Y;

  vector<vector<int>> G(N);
  REP(i, N - 1) {
    G.at(i).push_back(i + 1);
    G.at(i + 1).push_back(i);
  }
  G.at(X).push_back(Y);
  G.at(Y).push_back(X);

  vector<int> ans(N, 0);

  REP(i, N) {
    vector<int> dist(N, -1);
    dfs(G, dist, i);
    // cout << "i=" << i << endl;
    // for (int j : dist) {
    //   cout << j << endl;
    // }

    REP(j, N) {
      if (dist.at(j) >= 1)
        ++ans.at(dist.at(j));
    }
  }
  // cout << "done" << endl;

  REPI(i, 1, N) { cout << ans.at(i) / 2 << endl; }

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1004535809;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
int main()
{
	string st;
	cin>>st;
	int t=0;
	for(int i=0;i<st.Sz();i++)
	{
		t+=((st[st.Sz()-i-1]!=st[i])?1:0);
	}
	cout<<t/2;
	return 0;
}

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



int main() {
  
  long long X, K, D;
  scanf("%lld %lld %lld", &X, &K, &D);

  if (X<0){
    X*=-1;
  }

  int direction = X>=0?-1:1;
  long long k_necessary = X/D;
  
  if (k_necessary>K){
    printf("%lld\n", X - K*D);
    return 0;
  }
  
  long long p1 = X - k_necessary*D;  
  long long p2 = p1 - D;
  long long K_left = K-k_necessary-1;

  if (K_left%2==0){
    printf("%lld\n", -p2);
  }else{
    printf("%lld\n", p1);
  }

  return 0;
}




Measured memory_bytes: 3780
#include <iostream>


int main()
{
    std::int64_t x = 0;
    std::cin >> x;
    if (x < 0)
    {
        x = -x;
    }

    std::int64_t k;
    std::cin >> k;

    std::int64_t d;
    std::cin >> d;

    if (x / d > k)
    {   // ループするまで回数&距離が無い
        std::cout << x - d * k;
        return 0;
    }
    
    const auto div = x / d;
    auto lx = x - (d * div);
    const auto left = (k - div) % 2;
    
    for (std::int64_t count = 0; count < left; ++count)
    {
        if (lx > 0)
        {
            lx -= d;
        }
        else
        {
            lx += d;
        }
    }

    std::cout << std::abs(lx);
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    string x,y;
    cin>>x>>y;
    if (x>y)
    {
        cout<<'>'<<endl;
    }else if (x==y)
    {
        cout<<'='<<endl;
    }else
    {
        cout<<'<'<<endl;
    }
    
    
    

    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  int ans = 0;
  
  for(int i=1;i<=n;i+=2){
    int cnt = 0;
    rep(j,i){
      if(i%(j+1)==0){
        cnt++;
      }
    }
    if(cnt==8)
      ans++;
  }
  
  cout << ans ;


}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Numerics.BitOperations;

namespace ABC174
{
    class SolverA
    {
        static void Main()
        {
            SetOut(new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false});
            new SolverA().Solve();
            Out.Flush();
        }

        public void Solve()
        {
            var n = Get.Int();
            WriteLine(n>=30 ? "Yes" : "No");
        }




        static class Get
        {
            public static string Str() => ReadLine().Trim();
            public static int Int() => int.Parse(Str());
            public static long Long() => long.Parse(Str());
            public static double Double() => double.Parse(Str());
            public static string[] Strs() => Str().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            public static int[] Ints() => Strs().Select(int.Parse).ToArray();
            public static long[] Longs() => Strs().Select(long.Parse).ToArray();
            public static double[] Doubles() => Strs().Select(double.Parse).ToArray();
            static bool TypeEq<T,U>() => typeof(T).Equals(typeof(U));
            static T TypeConv<T,U>(U u) => (T)Convert.ChangeType(u, typeof(T));
            static T TypeConv<T>(string s) => TypeEq<T, int>() ?   TypeConv<T, int>(int.Parse(s))
                                        : TypeEq<T, long>() ?       TypeConv<T, long>(long.Parse(s))
                                        : TypeEq<T, double>() ?     TypeConv<T, double>(long.Parse(s))
                                        : TypeConv<T, string>(s);
            public static (T,U) Tuple<T,U>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); return(t,u);}
            public static (T,U,V) Tuple<T,U,V>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); V v = TypeConv<V>(strs[2]); return(t,u,v);}
        }
    }

    
}


Measured memory_bytes: 27524
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>

typedef long double ld;
typedef long long ll;


using namespace std;

#define MAXN (1 << 20)

int n;
ld a[MAXN];
ll b[MAXN];

int main() {

	cin >> n;
	ld rd = 1;
	ll rl = 1;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		a[i] = b[i];
		rd *= b[i];
		rl *= b[i];
	}
	
	if (rd > 1e18) {
		cout << "-1";
	} else {
		cout << rl;
	}

	return 0;
}


Measured memory_bytes: 5876
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		@SuppressWarnings("unused")
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		int[] a = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
		}

		int c1 = 0;
		int c2 = 0;
		for (int e : a) {
			if (e < x) {
				c1++;
			} else {
				c2++;
			}
		}

		pr.println(Math.min(c1, c2));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

class lazy_segtree {
    private:
        int size;
        vector<long long> node,lazy;
    public:
        lazy_segtree(int n_) {
            size=1;
            while (size<n_) size*=2;
            node.resize(2*size, 0);
            lazy.resize(2*size, 0);
        }

        void setlazy(int k,long long v,int l, int r) {
            lazy[k] += v;
            node[k] += v*(r-l);
        }

        void push(int k,int l,int r) {
            if (lazy[k] == 0) return ;
            setlazy(k*2+1,lazy[k],l,(r+l)/2);
            setlazy(k*2+2,lazy[k],(r+l)/2,r);
            lazy[k] = 0;
        }

   void merge(int k){
            node[k]=node[k*2+1]+node[k*2+2];
        }

        void range_add(int queryL,int queryR,int val,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return ;
            if (queryL<=nodeL && nodeR<=queryR) {
                setlazy(k,val,nodeL,nodeR);
                return ;
            }
            else {
                push(k,nodeL,nodeR);
                int nodeM=(nodeL+nodeR)/2;
                range_add(queryL,queryR,val,k*2+1,nodeL,nodeM);
                range_add(queryL,queryR,val,k*2+2,nodeM,nodeR);
                merge(k);
                return ;
            }
        }

        long long get_sum(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return 0;
            if (queryL<=nodeL && nodeR<=queryR) return node[k];
            else {
                push(k,nodeL,nodeR);
                int nodeM=(nodeL+nodeR)/2;
                long long vl=get_sum(queryL,queryR,k*2+1,nodeL,nodeM);
                long long vr=get_sum(queryL,queryR,k*2+2,nodeM,nodeR);
                return vl+vr;
            }
        }
};

int n,q;

int main(){
    cin >> n >> q;
    lazy_segtree ls(n);
    for (int i=0; i<q; i++) {
        int que,s,t,x,idx;
        cin >> que;
        if (que==0) {
            cin >> s >> t >> x;
            ls.range_add(s-1,t,x);
        }
        else {
            cin >> s >> t ;
            cout << ls.get_sum(s-1,t) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7076
/* include */
#include <bits/stdc++.h>
#include <boost/algorithm/string/trim.hpp>
#include <boost/range/algorithm.hpp>

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x)  \
    boost::sort(x); \
    (x).erase(unique(all(x)), (x).end())
#define mp make_pair

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(all(v));
    if (v[n / 2] != v[(n / 2) - 1])
    {
        cout << abs(v[(n / 2) - 1] - v[n / 2]) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

int main(void){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
    
    return 0;
}

Measured memory_bytes: 3636
n = STDIN.gets.to_i
list = STDIN.gets.split.map(&:to_i)
puts list.join(" ")
(1...n).each do |i|
  v = list[i]
  j = i - 1
  while j >= 0 && list[j] > v
    list[j+1] = list[j]
    j -= 1
    list[j+1] = v
  end
  puts list.join(" ")
end



Measured memory_bytes: 6892
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void){
	char text[1024];
	int i,n;
	fgets(text,1024,stdin);
	n=strlen(text);
	for(i=0;i<n-5;i++){
		if(text[i]=='a' && text[i+1]=='p' && text[i+2]=='p' && text[i+3]=='l' && text[i+4]=='e'){
			text[i]='p';text[i+1]='e';text[i+2]='a';text[i+3]='c';text[i+4]='h';
		}
		else if(text[i]=='p' && text[i+1]=='e' && text[i+2]=='a' && text[i+3]=='c' && text[i+4]=='h'){
			text[i]='a';text[i+1]='p';text[i+2]='p';text[i+3]='l';text[i+4]='e';
		}
	}
	printf("%s",text);
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No");
}


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

int main() {
    int N, R;
    while (cin >> N >> R, N || R) {
        vector<int> v(N);
        for (int i = 0; i < N; i++) {
            v[i] = i+1;
        }

        while (R--) {
            int p, c;
            cin >> p >> c;
            auto w = v;
            for (int i = 0; i < p-1; i++) {
                w[N - p - c + i + 1] = v[N - p + i + 1];
            }

            for (int i = 0; i < c; i++) {
                w[N - c + i] = v[N - p - c + i + 1];
            }

            v = w;
        }

        cout << v[N-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 3032
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] temp = sc.nextLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int x = Integer.parseInt(temp[1]);

		String[] tmp = sc.nextLine().split(" ");

		int ans = 0;
		int count = 1;
		for(int i = 0; i < tmp.length; i++) {

			ans += Integer.parseInt(tmp[i]);

			if(ans > x) {

				break;

			}

			count++;

		}

		System.out.println(count);


	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

std::vector<int> ans;
std::vector<int> prime;

void calc( int n, int i ) {
	for ( int j = i; j < prime.size(); j++ ) {
		int m = prime[j];

		if ( !(n % m) ) {
			ans.push_back(m);
			calc(n/m, j);
		}
	}
}

int main()
{
	prime.push_back(6);
	for ( int i = 7; i <= 300000; i+=7 ) {
		for ( int j = -1; j < 2; j+=2 ) {
			int m = i + j;
			int k;
			int sq = sqrt(m);
			for ( k = 0; k < prime.size(); ++k ) {
				if (sq < prime[k]) { prime.push_back(m); break; }
				if (!(m % prime[k])) break;
			}
		}
	}
	while(true){
		int n;

		std::cin >> n;
		if ( n == 1 ) break;

		ans.clear();

		calc(n, 0);

		std::sort(ans.begin(), ans.end());
		ans.erase(std::unique(ans.begin(), ans.end()), ans.end());

		std::cout << n << ": ";
		for ( int i = 0; i < ans.size(); ++i ) {
			std::cout << ans[i] << ((i == ans.size()-1) ? "" : " ");
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include<set>  
#include<map> 
#include<stack>
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<climits>  
#include<cstring>  
#include<iostream>  
#include<algorithm>  
using namespace std;
#define eps 1
#define MAXN 100
#define INF 0x3f3f3f3f  
int read(){  
    int f=1,x=0;  
    char c=getchar();  
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}  
    while('0'<=c&&c<='9') x=x*10+c-'0',c=getchar();  
    return f*x;  
}
map<string,int>Map;
string s[MAXN+5],t[MAXN+5];
int main()  
{
	int n,m,earn=0;
	n=read();
	for(int i=1;i<=n;i++)
		cin>>s[i],Map[s[i]]=1;
	m=read();
	for(int i=1;i<=m;i++)
		cin>>t[i];
	for(map<string,int>::iterator i=Map.begin();i!=Map.end();i++)  
	{
		int tmp=0;
		for(int j=1;j<=n;j++)
			if(i->first==s[j])tmp++;
		for(int j=1;j<=m;j++)
			if(i->first==t[j])tmp--;	
		earn=max(earn,tmp);
	}
	printf("%d\n",earn);
    return 0;  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
    string s; cin >> s;
    int y=atoi(s.substr(0, 4).c_str());
    int m=atoi(s.substr(5, 2).c_str());
    if(y>=2019 && m>=5){
        cout << "TBD\n";
    } else{
        cout << "Heisei\n";
    }
    return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i,N) cin >> v[i];
    sort(ALL(v));
    reverse(ALL(v));

    --N;
    --N;
    ll ans = v[0];
    bool used = false;
    int i = 1;
    while(N > 0) {
        ans += v[i];
        if(!used) used = true;
        else {
            used = false;
            i++;
        }
        --N;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4060
#include <stdio.h>
#include <utility>
using namespace std;

const int MAX = 3000;

int main(){
  int x[MAX],y[MAX];
  int work1,work2;
  int length = 0;

  for(int i=0;i<MAX;i++){
    scanf("%d",&work1);
    scanf("%d",&work2);
    if( work1 == 0 && work2 == 0 ){
      break;
    } else {
      x[i] = work1;
      y[i] = work2;
      length++;
    }
  }

  for(int i=0;i<length;i++){
    if(x[i] > y[i]) swap(x[i],y[i]);
    printf("%d %d\n",x[i],y[i]);
  }
}


Measured memory_bytes: 2608
#include <stdio.h>
#define N 45
int a[N];
 
int f(int n){
  int i;

  for(i=0;i<=n;i++){
    if(i<2){
      a[i]=1;
    }
    else a[i]=a[i-1]+a[i-2];
  } 
  return a[n];
}
main(void){
  int i,n,x;

  scanf("%d",&n);
  x=f(n);
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define fi first
#define se second 
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c >= 22 ? "bust" : "win") << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

bool dp[1000100];
int main(){
  int x;
  cin >> x;
  dp[0] = true; 
  rep(i,x+1){
    rep(j,6){
      if (i-100-j >= 0 && dp[i-100-j]) dp[i] = true;
    }
  }
  if (dp[x]) cout << 1 << endl;
  else cout << 0 << endl;

  

}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<int> A(N); rep(i, N) cin >>A[i];
  sort(allR(A));
  vector<int> check(1000001, 0);
  for (int i=0; i<N; i++){
    int a = A[i];
    if (check[a] > 0){
      check[a]++; continue;
    }
    int tmp = a;
    while (tmp <= 1000000){
      check[tmp]++;
      tmp += a;
    }
  }
  int res = 0;
  rep(i, N){
    if (check[A[i]] == 1) res++;
  }
  cout <<res <<endl;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string board[1010];

int main(void){
	int n;
	while(cin >> n){
		if(n==0)
			break;
		rep(i,n) cin >> board[i];

		rep(i,n){
			int m=board[i].size();
			int j;
			for(j=m-1;j>=0;--j)
				if(board[i][j]=='.')
					break;
			if(j!=-1)
				board[i][j]='+';
		}
		rep(i,n)rep(j,board[i].size()){
			if(board[i][j]=='+'){
				int ni=i+1;
				bool ok=false;
				while(ni<n&&j<board[ni].size()){
					if(board[ni][j]=='+'){
						ok=true;
						break;
					}
					if(board[ni][j]!='.')
						break;

					ni++;
				}
				if(ok)
					for(int k=i+1;k<ni;++k)
						board[k][j]='|';
			}
		}
		rep(i,n)rep(j,board[i].size()){
			if(board[i][j]=='.')
				board[i][j]=' ';
		}
		rep(i,n) cout << board[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1988
#include <cstdio>

using namespace std;

#define INF 1000000000000000000LL

int N;
bool exceed;
long long ans = 1;

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        long long A; scanf("%lld", &A);
        if (A == 0) {
            printf("0\n");
            return 0;
        }
        if (ans > INF / A) {
            exceed = true;
        }
        ans *= A;
    }
    if (!exceed) printf("%lld\n", ans);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  string s;
  cin>>s;
  if(s=="abc" || s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba")
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

#define LL long long int
#define mp make_pair
#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef vector <LL> vll;
typedef pair<LL, LL> iPair;
const int MOD = 1e9+7;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);

    LL t = 1;
    LL i,j;
    // cin>>t;
    
    while(t--)
    {
        int n, k;
        cin >> n >> k;

        vi arr(n);
        vi dp(n);
        FOR(i, n) cin >> arr[i];
        dp[0] = 0;
        for(int i = 1; i < n; ++i)
        {
            int m = INT_MAX;
            for(int j = i - 1; j >= (i - k) && j >= 0; j--)
            {
                m = min(m, dp[j] + abs(arr[i] - arr[j]));
            }
            dp[i] = m;
        }
        cout<<dp[n-1];
    }

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>

int main()
{
	double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%f\n", sqrt((x1 - x2)*(x1-x2)+ (y1 - y2)*(y1-y2)));
	return 0;
}

Measured memory_bytes: 2652
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
print(max_wa)


Measured memory_bytes: 23588
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var k = next();
  var x = 10, ans = xArray(-1,x+1);
  ans[x] = 1;
  for(var i = 1; i < k; i++){
    if((ans[x-1] < 0 || ans[x-1] >= ans[x]) && ans[x] !== 9){
      ans[x]++;
      continue;
    }
    for(var j = x; --j;){
      if((ans[j-1] < 0 || ans[j-1] >= ans[j]) && ans[j] !== 9)break;
    }
    if(ans[j] === -1)ans[j] = 0;
    ans[j++]++;
    for(; j <= x; j++){
      if(ans[j-1])ans[j] = ans[j-1] - 1;
      else ans[j] = 0;
    }
  }
  for(var i = 0; i < x; i++)if(ans[i] === -1)ans[i] = 0;
  return +ans.join("");
}

Measured memory_bytes: 21064
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int h,w;
    cin >> h >> w;
    char a[102][102];

    for(int i = 1; i <= h; ++i) for(int j = 1; j <= w; ++j) cin >> a[i][j];

    for(int i = 0; i <= h+1; ++i){
        for(int j = 0; j <= w+1; ++j){
            if(i == 0 || i == h+1 || j == 0 || j == w+1)
                cout << "#";
            else
                cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

/*
long long hspow(long long x, long long n){
    if(n == 0) return 1;
    if(n % 2 == 0) return hspow(x * x, n / 2);
    else return x * hspow(x, n - 1);
}
*/
/*
ll hspow(ll a, ll n){
    ll x = 1;
    while(n > 0){
        if(n & 1){
            x = x * a;
        }
        a = a * a;
        n >>=1;
    }
    return x;
}
*/
ll func(ll H){
    if(H == 1) return 1;
    else return 2 * func(H/2) + 1;
}

void solve(long long H){
    cout << func(H) << endl;
    return;
}

int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 3700
while 1:
    n,x = map(int,input().split())
    if n+x==0:break
    cnt = 0
    for a in range(1,n+1):
        for b in range(a+1,n+1):
            c = x-a-b
            if c>b and c<=n:
                cnt+=1
    print(cnt)


Measured memory_bytes: 5592
#define _GLIBCXX_DEBUG
#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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[100010];

int main(){
  int n; cin >> n;
  rep(i,n+1) dp[i]=inf;
  dp[0]=0;
  rep(i,n){
    int a=6;
    while(i+a<=n){
      chmin(dp[i+a],dp[i]+1);
      a*=6;
    }
    int b=9;
    while(i+b<=n){
      chmin(dp[i+b],dp[i]+1);
      b*=9;
    }
    chmin(dp[i+1],dp[i]+1);
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 640
def main():
    n = int(input())
    a = list(map(int, input().split()))

    su = [0 for _ in range(n + 1)]    
    for l in range(n):
        su[l + 1] = su[l] + a[l]

    INF = 1e18
    dp = [[-INF for _ in range(n + 1)] for _ in range(n + 1)]

    for l in range(n + 1):
        dp[l][l] = 0
    for length in range(1, n + 1):
        l = 0
        while l + length <= n:
            r = l + length
            dp[l][r] = max(a[l] + (su[r] - su[l + 1]) - dp[l + 1][r], 
                            a[r - 1] + (su[r - 1] - su[l]) - dp[l][r - 1])
            l += 1
    print(dp[0][n] - (su[n] - dp[0][n]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 399488
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	int q;
	cin>>s>>q;
	
	deque<char> dq;
	REP(i,s.size()) dq.push_back(s[i]);
	bool jud=true;
	REP(i,q){
		int t;
		cin>>t;
		if(t==1){
			jud^=1;
		}else{
			int f;
			char c;
			cin>>f>>c;
			if(f==1 xor jud) dq.push_back(c);
			else dq.push_front(c);
		}
	}
	
	if(jud){
		REP(i,dq.size()) cout<<dq[i];
	}else{
		for(int i=dq.size()-1;i>=0;--i) cout<<dq[i];
	}
	cout<<endl;
}

Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int ans[200005];
ll a[200005];
vector<vector<int> > edge(200005);
vector<int> arr(200005, inf);

void solve(int u, int v) {
  int change = lower_bound(arr.begin(), arr.end(), a[u]) - arr.begin();
  int bef = arr[change];
  arr[change] = a[u];
  ans[u] = lower_bound(arr.begin(), arr.end(), inf) - arr.begin();
  for(int i=0;i<edge[u].size();++i) {
    if(edge[u][i]==v) continue;
    solve(edge[u][i], u);
  }
  arr[change] = bef;
  return;
}

int main() {
  int N;
  cin>>N;
  for(int i=0;i<N;++i) cin>>a[i];
  int u, v;
  for(int i=0;i<N-1;++i) {
    cin>>u>>v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  solve(0, -1);
  for(int i=0;i<N;++i) {
    cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 31668
#include<bits/stdc++.h>
using namespace std;
  int n,m,sum,a[105],b[105],c[105];
int main() {
  cin>>n;
  
  for (int i=1;i<=n;++i) cin>>a[i],sum+=a[i];
  cin>>m;
  for (int i=1;i<=m;++i) {
    cin>>b[i]>>c[i];
    cout<<sum-a[b[i]]+c[i]<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=998244353;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int nmax=300005;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
// modintを使うときはllをmintに
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,k;cin >> n >> a >> b >> k;
    ll ans=0;
    COMinit();
    for(ll i=0;i<=n&&i*a<=k;i++){
        if((k-i*a)%b==0){
            (ans+=com(n,i)*com(n,(k-i*a)/b)%mod)%=mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
#include<stdio.h>

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

    int i,h;
    int ans=0;
    for ( i = 0; i < N; i++){
        scanf("%d", &h);
        if (h>=K){
            ans++;
        }   
    }
    
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.numeric;
import std.math;
import std.algorithm;
import std.string;
import std.container;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}

void main() {
    int p, q; scanf("%d %d\n", &p, &q);
    q /= gcd(p, q);
    int ans = 1;
    for (int n = 2; n * n <= q; n++) {
        if (q % n == 0) {
            while (q % n == 0) q /= n;
            ans *= n;
        }
    }
    ans *= q;
    writeln(ans);
}

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	long long ans1=0,ans2=0;
	ans1=a*(n-1)+b;
	ans2=a+b*(n-1);
	printf("%lld\n",max(ans2-ans1+1,1ll*0));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAXn 100000
#define MAXq 50000

int main(){
  int sn, tqn, Snum[MAXn], Tq[MAXq], i, left, right, mid, key, cnt=0;
  
  scanf("%d", &sn);
  for(i=0;i<sn;i++){
    scanf("%d", &Snum[i]);
  }
  scanf("%d", &tqn);
  for(i=0;i<tqn;i++){
    scanf("%d", &Tq[i]);
  }

  for(i=0;i<tqn;i++){
    key = Tq[i];
    left = 0;
    right = sn;
    while(left < right){
      mid = (left+right)/2;
      if(Snum[mid] == key){
        cnt++;
        break;
      }
      else if(key < Snum[mid]){
        right = mid;
      }
      else{
        left = mid+1;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c=(x-a) %b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140