akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
//if(s.find(s1) != std::string::npos)
//mp :: cpp_int a=0;


ll _gcd(ll a, ll b)
{
    if(b==0)return a;
    a=a%b;
    return _gcd(b-a,a);
}
long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}

long long getXor(long long a, long long b) {
     return f(b)^f(a-1);
}

int solve( ){


string  s,s1="keyence";
cin>>s;
if(s.size()<7)cout<<"NO";
else
{
    if(s.find(s1) != std::string::npos)cout<<"YES";
    else
    { int j=0,k=0;
        rep(i,0,7)
        {
            if(s[i]!=s1[i]){break;}
            j++;
        }
        int w=6;
        for(int i=s.size()-1;i>=s.size()-7;i--)
        {
            if(s[i]!=s1[w--]){break;}
            k++;
        }
       // cout<<j<<" "<<k<<" ";
        if(j+k>=7)cout<<"YES";
        else cout<<"NO";

    }
}

}

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  /*
    #ifndef ONLINE_JUDGE
    freopen("test.in", "r" , stdin);
    freopen("test.out", "w", stdout);
    #endif
  */
  clock_t time_req;

    // Without using pow function
    time_req = clock();


//cin>>t;
//cin.ignore();
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken in pow function: "
     //  << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

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

Measured memory_bytes: 764
// at_abc148d.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<stdio.h>

using namespace std;
int main()
{
    int temp;
    int n;cin >> n;
    int cur = 1;
    for (int i = 0;i < n;i++) {
        scanf("%d", &temp);
        if (temp == cur) {
            cur++;
        }
    }
    if (cur == 1) {
        cout << "-1\n"; return 0;
    }
    cout << n - cur + 1<<"\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
//1:20
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
vector<int> v[N];
int n;string s;
bool ava[N];
void BFS(){
    int nz[N];
    queue<int> Q;
    lol(i,n){
	ava[i]=1;
	nz[i]=v[i].size();
	if(nz[i]==1&&s[i]=='B')Q.push(i);
    }
    while(!Q.empty()){
	int i=Q.front();Q.pop();
	ava[i]=0;
	for(auto x:v[i]){
	    nz[x]--;
	    if(nz[x]==1&&s[x]=='B')Q.push(x);
	}
    }
}
int ecnt[N];
class Dijkstra{
private:
    void dfs(int x,int bef,int len){
	if(ava[x]==0)return;
	if(ecnt[x]%2==1 xor s[x]=='W')len++;
	d[x]=len;
	for(auto y:v[x])if(y!=bef){
	    dfs(y,x,len);
	} 
    }
public:
    int d[N];
    void Solve(int x){
	lol(i,n)d[i]=0;
	dfs(x,-1,0);
    }
};
int main(){
    cin>>n;
    lol(i,n-1){
	int a,b;cin>>a>>b;a--,b--;
	v[a].push_back(b);
	v[b].push_back(a);
    }
    cin>>s;
    int sum=0;lol(i,n)sum+=s[i]=='W';
    if(sum<=1){cout<<sum<<endl;return 0;}
    lol(i,n)ava[i]=1,ecnt[i]=0;
    BFS();
    lol(i,n)for(auto x:v[i])ecnt[i]+=ava[x];
    //lol(i,n)cout<<ava[i]<<" "<<ecnt[i]<<endl;
    Dijkstra a,b;
    lol(i,n)if(ecnt[i]==1&&ava[i]==1){a.Solve(i);break;}
    int pnt=n-1;
    lol(i,n-1)if(a.d[pnt]<a.d[i])pnt=i;
    b.Solve(pnt);
    int maxi=0;
    lol(i,n)maxi=max(maxi,b.d[i]);
    int ans=-2;
    lol(i,n)if(ava[i])ans+=2+(ecnt[i]%2==1 xor s[i]=='W');
    cout<<ans-maxi*2<<endl;
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
double EPS = 0.0000000001;
int sign(double x){
	if (x > EPS){
		return 1;
	} else if (x < -EPS){
		return -1;
	} else {
		return 0;
	}
}
bool equals(double x, double y){
	return abs(x - y) < EPS;
}
struct point{
	double x;
	double y;
	point(){
		x = 0;
		y = 0;
	}
	point(double X, double Y){
		x = X;
		y = Y;
	}
	point operator +(){
		return point(x, y);
	}
	point operator -(){
		return point(-x, -y);
	}
	point operator +(point P){
		return point(x + P.x, y + P.y);
	}
	point operator -(point P){
		return point(x - P.x, y - P.y);
	}
	point& operator +=(point P){
		x += P.x;
		y += P.y;
		return *this;
	}
	point& operator -=(point P){
		x -= P.x;
		y -= P.y;
		return *this;
	}
	point operator *(double k){
		return point(x * k, y * k);
	}
	point operator /(double k){
		return point(x / k, y / k);
	}
	point& operator *=(double k){
		x *= k;
		y *= k;
		return *this;
	}
	point& operator /=(double k){
		x /= k;
		y /= k;
		return *this;
	}
	bool operator ==(point P){
		return equals(x, P.x) && equals(y, P.y);
	}
	bool operator !=(point P){
		return !(*this == P);
	}
	bool operator <(point P){
		return sign(P.x - x) == 1 || (equals(x, P.x) && sign(P.y - y) == 1);
	}
	bool operator >(point P){
		return (P < *this);
	}
	point& rotate(double t){
	    double X = x * cos(t) - y * sin(t);
	    double Y = x * sin(t) + y * cos(t);
	    x = X;
	    y = Y;
	    return *this;
	}
	point& rotate(point P, double t){
	    *this -= P;
	    (*this).rotate(t);
	    *this += P;
	    return *this;
	}
	point& rotate90(){
	    swap(x, y);
	    x = -x;
	    return *this;
	}
};
istream& operator >>(istream &is, point &p){
	double x, y;
	is >> x >> y;
	p = point(x, y);
	return is;
}
ostream& operator <<(ostream &os, point p){
	os << p.x << ' ' << p.y;
	return os;
}
double norm(point P){
	return P.x * P.x + P.y * P.y;
}
double abs(point P){
	return sqrt(norm(P)); 
}
double dot(point P, point Q){
	return P.x * Q.x + P.y * Q.y;
}
double cross(point P, point Q){
  return P.x * Q.y - P.y * Q.x;
}
struct line{
	point A;
	point B;
	line(){
	}
	line(point P){
	  B = P;
	}
	line(point P, point Q){
		A = P;
		B = Q;
	}
	line(double a, double b){
		A = point(0, b);
		B = point(1, a + b);
	}
	line(double a, double b, double c){
		if (sign(b) == 0){
			A = point(-c / a, 0);
			B = point(-c / a, 1);
		} else {
			A = point(0, -c / a);
			B = point(1, -(b + c) / a);
		}
	}
};
istream& operator >>(istream &is, line &L){
	point A, B;
	is >> A >> B;
	L = line(A, B);
	return is;
}
ostream& operator <<(ostream &os, line L){
	os << L.A << ' ' << L.B;
	return os;
}
point vec(line L){
	return L.B - L.A;
}
bool is_orthogonal(line a, line b){
	return sign(dot(vec(a), vec(b))) == 0;
}
bool is_parallel(line a, line b){
  return sign(cross(vec(a), vec(b))) == 0;
}
int main(){
	int q;
	cin >> q;
	for (int i = 0; i < q; i++){
	  line l1, l2;
	  cin >> l1 >> l2;
	  if (is_parallel(l1, l2)){
	    cout << 2 << endl;
	  } else if (is_orthogonal(l1, l2)){
	    cout << 1 << endl;
	  } else {
	    cout << 0 << endl;
	  }
	}
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
const int inf = 1e9 + 7 ;
int n, m, cnt, num, dp[40], Pre[N] ; 
struct Node {
	int a, b ; 
} t[N], p[N], r[N] ;
bool cmp( Node x, Node y ) {
	return x.b < y.b ; 
} 
bool cmp2( Node x, Node y ) {
	return ( 1ll * x.b * y.a + y.a ) < ( 1ll * y.b * x.a + x.a ) ;
}
int check( int x ) {
	int l = 0, r = num, ans = 0 ; 
	while( l <= r ) {
		int mid = ( l + r ) >> 1 ; 
		if( Pre[mid] <= x ) ans = mid, l = mid + 1 ;
		else r = mid - 1 ;
	} return ans ; 
}
signed main()
{
	n = gi(), m = gi() ;
	rep( i, 1, n ) {
		t[i].a = gi(), t[i].b = gi() ; 
		if( t[i].a != 0 ) p[++ cnt] = t[i] ; 
		if( t[i].a == 0 ) r[++ num] = t[i] ; 
	}
	rep( j, 0, 32 ) dp[j] = m + 1 ; 
	sort( p + 1, p + cnt + 1, cmp2 ) ;
	sort( r + 1, r + num + 1, cmp ) ;
	dp[0] = 0 ; 
	for( re int i = 1; i <= cnt; ++ i ) {
		for( re int j = 32; j > 0; -- j ) {
			if( dp[j - 1] > m ) continue ; 	
			if( p[i].a * dp[j - 1] > m ) continue ; 
			dp[j] = min( ( dp[j - 1] + 1 ) * ( p[i].a + 1 ) + p[i].b, dp[j] ) ;
		}
	}
	for( re int i = 1; i <= num; ++ i ) Pre[i] = Pre[i - 1] + r[i].b + 1 ; 
	int Ans = 0 ;
	for( re int i = 0; i <= 32; ++ i ) {
		int ans = i, T = dp[i] ;
		if( T > m ) continue ; 
		ans = ans + check( m - dp[i] ) ;
		Ans = max( Ans, ans ) ;
	}
	printf("%lld\n", Ans ) ;
	return 0 ;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,a[21],b[21],c[21],sum=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
        sum+=b[i];
    }
    rep(i,n-1){
        cin>>c[i];
    }
    rep(i,n-1){
        if(a[i+1]-a[i]==1){
            sum+=c[a[i]-1];
        }
    }
        cout<<sum;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
  ll x=0,f=1;char c=getchar();
  while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
  while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
  return x*f;
}

const int mod = 1e9 + 7;
const int maxn = 200200;
int n, a, b, c;
int fac[maxn], inv[maxn];

int ksm(int x, int p) {
	int ret = 1;
	while (p) {
		if (p & 1) ret = ret * 1ll * x % mod;
		p >>= 1; x = x * 1ll * x % mod;
	}
	return ret;
}

int C(int x, int y) {
	return fac[x] * 1ll * inv[y] % mod * inv[x - y] % mod;
}

void work() {
	n = read();
	fac[0] = 1;
	rep(i, 1, n * 2) fac[i] = fac[i - 1] * 1ll * i % mod;
	inv[n * 2] = ksm(fac[n * 2], mod - 2);
	rrep(i, n * 2 - 1, 0) inv[i] = inv[i + 1] * 1ll * (i + 1) % mod;
	a = read(), b = read(), c = read();
	int sum = a + b;
	a = a * 1ll * ksm(sum, mod - 2) % mod;
	b = b * 1ll * ksm(sum, mod - 2) % mod;
	int fuck = 100 * 1ll * ksm(100 - c, mod - 2) % mod;
	int ans = 0;
	rep(k, n, 2 * n - 1) {
		ans = (ans + C(k - 1, n - 1) * 1ll * k % mod * ((ksm(a, n) * 1ll * ksm(b, k - n) + ksm(a, k - n) * 1ll * ksm(b, n)) % mod) % mod * fuck % mod) % mod;
	}
	printf("%d\n", ans);
}

int main() {
  #ifdef LZT
    freopen("in","r",stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 1792
//============================================================================
// Name        : abc145_b.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : test program
//============================================================================

/*
B - Echo

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 200 点

問題文
正整数 N 及び、長さ N の英小文字から成る文字列 S が与えられます。
この文字列が、ある文字列を二度繰り返したものであるかを判定してください。
則ち、文字列 T であって、 S = T + T となるものが存在するかを判定してください。

制約

・1 ≤ N ≤ 100
・S は英小文字から成る
・|S| = N

 */

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

#define REP(i, m, n) for (ll i = (m); i < (ll)(n); ++(i))
#define REPM(i, m, n) for (ll i = (m); i <= (ll)(n); ++(i))
#define REPR(i, m, n) for (ll i = (m); i >= (ll)(n); --(i))
#define REPD(i, m, n, d) for (ll i = (m); i < (ll)(n); i += (d))
#define REPMD(i, m, n, d) for (ll i = (m); i <= (ll)(n); i += (d))
#define ALL(x) begin(x), end(x)

/**
 * エントリポイント．
 * @return 0.
 */
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    const string yes = "Yes";
    const string no = "No";

    ll n;
    string s;
    cin >> n;
    cin >> s;

    if (n % 2 != 0)
    {
        cout << no << endl;
        return 0;
    }
    string s1 = s.substr(0, n / 2);
    string s2 = s.substr(n / 2, n / 2);
    // cerr << s << endl;
    cout << (s1 == s2 ? yes : no) << endl;
    return 0;
}


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

int main() {
  int d = 0;

  int N;
  int K;

  cin >> N >> K;

  int x[N];
  for (int i = 0; i < N; i++)
    cin >> x[i];

  for (int i = 0; i < N; i++){
    if (x[i] * 2 < abs((x[i] - K) * 2)) 
      d += x[i] * 2; 
    else
      d += abs((x[i] - K) * 2);
  }
  cout << d;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  long long N, M;
  cin >> N >> M;
  if (N > M) swap(N, M);
  if (N == 1) {
    cout << abs(M - 2) << endl;
  } else {
    cout << (N - 2) * (M - 2) << endl;
  }
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std ;

int main()
{
  int N ;
  cin>>N ;
  vector<int>d(N) ;
  for(int i=0;i<N;i++) cin>>d.at(i) ;
  
  sort(d.begin(),d.end()) ;
  cout<<d.at(N/2)-d.at(N/2-1)<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 768
from collections import deque
from copy import copy

row, column = map(int, input().split())
map_ = [[c == "#" for c in input().strip()] for _ in range(row)]

queue = deque([(i, j) for j in range(column) for i in range(row) if map_[i][j]])

def bfs(maze, queue):
    depth = 0
    while True:
        depth += 1
        nextqueue = deque()
        while queue:
            posr, posc = queue.popleft()
            for dr, dc in zip([1, -1, 0, 0], [0, 0, 1, -1]):
                nextr = posr + dr
                nextc = posc + dc
                if 0 <= nextr < row and 0 <= nextc < column and not maze[nextr][nextc]:
                    maze[nextr][nextc] = True
                    nextqueue.append((nextr, nextc))
        if nextqueue:
            queue = copy(nextqueue)
        else:
            return depth - 1

print(bfs(map_, queue))


Measured memory_bytes: 111212
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()    
    val h = readListOfInt().toMutableList()
    var isAble = true
    h[0] = h[0]-1
    for(i in 1 until n) {
       val prev = h[i-1] 
       val current = h[i]
       if(prev > current) {
           isAble = false
           break
       }
       if(prev <= current-1) {
           h[i] = current - 1
       }
    }
    println(if(isAble) "Yes" else "No")
    
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 61828
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  string w;
  cin >> w;
  
  int alph[26] = {};
  for (int i = 0; i < w.size(); i++){
    alph[w[i]-'a']++;
  }

  int ok = 1;
  for (int i = 0; i < 26; i++){
    if (alph[i] % 2 == 1)
      ok = 0;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll sum;
    cin >> n >> sum;
    VL av;
    av.push_back(sum);
    ll ans1 = 0;
    if(sum == 0){
        sum = 1;
        ans1 = 1;
    }
    REP(i, n - 1){
        ll a;
        cin >> a;
        av.push_back(a);
        if((a + sum) * sum >= 0){
            if(sum > 0){
                ans1 += a + sum + 1;
                sum = -1;
            }else{
                ans1 += -(a + sum) + 1;
                sum = 1;
            }
        }else{
            sum += a;
        }
    }

    ll ans2 = 0;
    if(av[0] >= 0){
        sum = -1;
        ans2 = av[0] + 1;
    }else{
        sum = 1;
        ans2 = -av[0] + 1;
    }
    FOR(i, 1, n - 1){
        ll a = av[i];
        if((a + sum) * sum >= 0){
            if(sum > 0){
                ans2 += a + sum + 1;
                sum = -1;
            }else{
                ans2 += -(a + sum) + 1;
                sum = 1;
            }
        }else{
            sum += a;
        }
    }

    cout << min(ans1, ans2) << "\n";

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define YES printf("YES\n")
#define NO printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e15;
const int M = (1e9)+7;
const int N = (1e5);  // check the limit, man
int main()
{
    int x,y,z;
    in2(x,y);
    z=(x/y)+min(1,x%y);
    out(z);
}







Measured memory_bytes: 256
#abc121b

n,m,c=map(int,raw_input().split())
b=map(int,raw_input().split())
a=[]
for i in xrange(n):
 a.append(map(int,raw_input().split()))
res=0
for i in xrange(n):
 temp=0
 for j in xrange(m):
  temp+=a[i][j]*b[j]
 if temp+c>0:
  res+=1
print res


Measured memory_bytes: 2568
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

typedef long long ll;
#define rep(i, n) for(int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
using namespace std;
int main() {
    int N, K, answer = 0;
    cin >> N >> K;
  	vector<int> vec(N);
    rep(i, N) {
        cin >> vec[i];
    }
    rep(i, N) {
        answer += 2 * min(K - vec[i], vec[i]);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
char stage[22][22];
bool vis[22][22];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
class Data{
	public:
	int x;
	int y;
	int cnt;
	Data(){}
	Data(int x,int y,int cnt):x(x),y(y),cnt(cnt){}
};
int main(){
	int w,h;
	while(scanf("%d%d",&w,&h),(w|h)){
		memset(stage,0,sizeof(stage));
		memset(vis,0,sizeof(vis));
		int sx,sy;
		for(int i = 0; i < h; i++){
			scanf("%s",stage[i]);
			for(int j = 0; j < w; j++){
				if(stage[i][j] == '@'){
					sx = j;
					sy = i;
				}
			}
		}
		
		queue < Data > Q;
		int ans = 0;
		Q.push(Data(sx,sy,1));
		
		while( !Q.empty() ){
			Data d = Q.front();Q.pop();
			if(vis[d.y][d.x]++)continue;
			ans += d.cnt;
			for(int i = 0; i < 4; i++){
				if(dx[i]+d.x < 0 || dx[i]+d.x >= w || dy[i]+d.y < 0 || dy[i]+d.y >= h || stage[dy[i]+d.y][dx[i]+d.x] == '#')continue;
				Q.push(Data(dx[i]+d.x,dy[i]+d.y,d.cnt));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define dbg(x) cerr << #x"=" << x << endl;
const int MAX_N = 2*1e3+100;
const int MOD = 1e9+7;
int n,m;
char s[MAX_N][MAX_N];
int dir[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
int r[MAX_N][MAX_N], c[MAX_N][MAX_N];


int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; ++i){
        scanf("%s", s[i]);
    }
    for(int i = 0; i < n; ++i){
        int f = 0, t = 0, now = 0;
        int j;
        for(j = 0; j < m; ++j){
            if(s[i][j] == '.'){
                ++now;
            } else { // 当前是'#'
                for(int k = f; k < t; ++k) r[i][k] = now;
                now = 0;
                f = t;
            }
            ++t;
        }
        for(int k = f; k < t; ++k){
            r[i][k] = now;
        }
    }

    for(int i = 0; i < m; ++i){
        int f = 0, t = 0, now = 0;
        int j;
        for(j = 0; j < n; ++j){
            if(s[j][i] == '.'){
                ++now;
            } else { // 当前是'#'
                for(int k = f; k < t; ++k) c[k][i] = now;
                now = 0;
                f = t;
            }
            ++t;
        }
        for(int k = f; k < t; ++k){
            c[k][i] = now;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            ans = max(ans, r[i][j] + c[i][j] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 38784
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

#define reps(i,j,k) for(int i = j;i < k;i++)
#define rep(i,j) reps(i,0,j)
typedef pair < int,int > Pii;
int fish[1000001];
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	priority_queue < Pii > PQ;
	rep(i,q){
		int a,v;
		scanf("%d%d",&a,&v);
		fish[a] += v;
		PQ.push(Pii(fish[a],-a));
		while( !PQ.empty() ){
			Pii p = PQ.top();
			if(p.first == fish[-p.second]){
				printf("%d %d\n",-p.second,p.first);
				break;
			}
			PQ.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 5984
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int d, n;
    cin >> d >> n;
    cout << (n + n / 100);
    for (int i = 0; i < d; i++) {
        cout << "00";
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int s = a <= 2 * b ? 0 : a - 2 * b;

		System.out.println(s);

	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << "\n"; // cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

class UFT{
public:
    vector<int> par;
    vector<int> siz;
    int find(int x){ return (par[x] == x) ? x : (par[x] = find(par[x])); };
public:
    UFT(int n) : par(vector<int>(n)), siz(vector<int>(n, 1)){ For(i, n) par[i] = i; };
    bool same(int x, int y){ return find(x) == find(y); };
    void unite(int x, int y){ if(!same(x = find(x), y = find(y))){ par[x] = y; siz[y] += siz[x]; } };
    int size(int x){ return siz[find(x)]; };
    void print() const{ Couts(par); };
};

int main(void){
  	Cin(int, n, m);
  	UFT uft(n);
  	Rep(m){
  	    Cin(int, x, y, z); x --, y --;
  	    uft.unite(x, y);
  	}
  	
  	int ans = 0;
  	vector<bool> f(n);
 	For(i, n){
  	    int k = uft.find(i);
  	    if(!f[k]){
  	        f[k] = true;
  	        ans ++;
  	    }
  	}
  	Cout(ans);
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x;
    cin >> x;
    out( (x/500)*1000 + ((x - (x/500)*500)/5)*5 );
    re0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : usize = get_one();
    let xs : Vec<i64> = get_vec();
    let mut x = xs[0];
    let mut y = xs.iter().fold(0, |sm, e| sm + e) - xs[0];
    let mut ans = (x-y).abs();
    for i in 1..(n-1) {
        let k = xs[i];
        x += k;
        y -= k;
        ans = std::cmp::min((x - y).abs(), ans);
    }
    println!("{}", ans);
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){
    int n,d;
    cin >> n >> d;
    int c = 0;
    rep(i,0,n) {
        int x,y;
        cin >> x >> y;
        if(sqrt((1.0*x*x)+(1.0*y*y))<=d) {
            c++;
        }
    }
    cout << c;line

}
int main(){
	fast
	int t=1;
	//cin >> t;
	while(t--){
             solve();
    }

	R 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int [] arr = new int[n + 1];
        long x = 0;
        for (int i = 0; i < n + 1; i++) arr[i] = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            int mo = Math.min(arr[i], num);
            arr[i] -= mo;
            num -= mo;
            x += mo;

            if (num != 0) {
                mo = Math.min(arr[i + 1], num);
                arr[i + 1] -= mo;
                num -= mo;
                x += mo;
            }
        }

        System.out.println(x);

    }
}


Measured memory_bytes: 65028
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if s == "keyence" {
		fmt.Println("YES")
		return
	}

	for i := 0; i < len(s); i++ {
		for j := i + 1; j < len(s); j++ {
			if s[:i]+s[j:] == "keyence" {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,count=0,pount=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    
    {
        for(int j=1;j<=n;j+=2)
        {   
            if(i%j==0)
            {
                count++;
            }
            
        }
        if(count==8)
        {
            pount++;
            count=0;
        }
        else{
        count=0;}
    }
    cout<<pount<<"\n";
    return 0;
}

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

int main() {
  int A, B, X;
  cin >> X >> A >> B;
  
  if ( B <= A ) {
    cout << "delicious" << endl;
  }
  else if ( B-A <= X ) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
def solve(n, s, t):
    match = 0
    for i in range(n):
        if s[i] == t[0]:
            for j in range(n+1):
                if i+j >= n:
                    match = j
                    break
                elif s[i+j] != t[j]:
                    match = 0
                    break
            if match > 0:
                break
    print("{}".format(n*2-match))


def main():
    n = int(input())
    s = input()
    t = input()
    solve(n, s, t)


if __name__ == "__main__":
    main()


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

int main() {
  int m1,m2,d1,d2;
  cin>>m1>>d1>>m2>>d2;
  
  if(m1!=m2 && d2-d1!=1)
    cout<<1<<endl;
  else
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int X;
  cin>>X;
  int Q = X/500;
  int R = X%500;
  cout<<1000*Q + 5*(R/5)<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var (n,x) = (0,0)
  while({val Array(n2,x2) = readLine.split(" ").map(_.toInt);n=n2;x=x2;(n,x)} != (0,0) ) {
    println(
      ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) =>
        sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length
      }
    )
  }
}

Measured memory_bytes: 44148
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, A, B;
int sum;
int main()
{
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++)
    {
        int val = i;
        int result = 0;
        while (val > 0)
        {
            result += val % 10;
            val /= 10;
        }
        if (result >= A and result <= B)
        {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    for (int i = 0; i <= n / 7; i++) {
        int rem = n - i * 7;
        if (rem >= 0 && rem % 4 == 0) return !(cout << "Yes" << endl);
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
d,n=map(int,input().split())
if d==0:
    if n!=100:
        print(n)
    else:
        print(101)
elif d==1:
    if n!=100:
        print(100*n)
    else:
        print(100*101)
elif d==2:
    if n!=100:
        print(10000*n)
    else:
        print(10000*101)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#define ll long long int
#define ld long double
using namespace std;



    map <string,int> m;
vector <pair<string,int>> v;
 
int main(){
    	map<string,int>mp;
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		mp[s]++;
	}
	int ma=0;
	for(auto u:mp) if(u.second>ma)ma=u.second;
	for(auto u:mp)if(u.second==ma) cout<<u.first<<endl;
}

Measured memory_bytes: 25216
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N,L;

	cin >> N >> L;
	
	int minabs=1e9;
	int ans=0;
	int sum=0;
	for(int i=1;i<=N;i++)
		sum+=(L+i-1);
	for(int i=1;i<=N;i++)
	{
		int tans=0;
		for(int j=1;j<=N;j++)
		{
			if(j==i)continue;
			tans+=(L+j-1);
		}
		int abso=abs(sum-tans);
		if(abso<minabs)
		{
			minabs=abso;
			ans=tans;
		}
	}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b == c) || (a + c == b) || (b + c == a))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ull unsigned long long
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define sz size()
#define db double
#define pb push_back
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;

int main()
{
    int n,k=2;
    cin >> n;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin >> h[i];
    vector<int> dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        int ans=INF;
        for(int j=1;j<=k;j++)
        {
            if(j>=i)
                break;
            int cost=abs(h[i-j]-h[i]);
            ans=min(ans,dp[i-j]+cost);
        }
        dp[i]=ans;
    }
    cout << dp[n] << endl;

}


Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns, MultiWayIf #-}

import Prelude
import Data.Bits
import Data.List
import Data.Maybe
import Data.Tuple
import Data.Ord
import Data.Int
import Data.Word
import Data.Char
import Data.Ratio
import Data.Function
import Data.STRef
import Data.IORef
import Data.Monoid
import Data.Functor
import Data.Data
import Data.Typeable
import GHC.Generics
import System.IO
import Control.Arrow
import Control.Applicative
import Control.Monad
import Control.Monad.Primitive
import Control.Monad.State.Strict
import Control.Monad.ST
import Control.Monad.ST.Lazy (strictToLazyST, lazyToStrictST)
import qualified Control.Monad.ST.Lazy as STL
-- import Control.Monad.ST.Safe
import Control.DeepSeq
import Data.Coerce
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import qualified Data.ByteString.Builder as BSB
import Data.IntMap (IntMap)
import qualified Data.IntMap.Strict as IMS
import qualified Data.IntMap.Lazy as IML
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU


main :: IO ()
main = do
  n <- read <$> getLine
  s <- VU.unfoldrN n BS.uncons <$> BS.getLine
  print $ VU.maximum
    $ VU.map (\ !gap -> test gap s (VU.drop gap s))
    $ VU.tail $ VU.generate n id

test :: Int -> VU.Vector Char -> VU.Vector Char -> Int
test threshold v1 v2
 = VU.foldr (\ (!c1, !c2) cont !prev !maxi ->
              let now_ = prev+1 
              in if | c1 /= c2 -> cont 0 maxi
                    | now_ >= threshold -> threshold
                    | otherwise -> cont now_ (max now_ maxi))
   (\ !prev !maxi -> maxi)
   (VU.zip v1 v2) 0 0


Measured memory_bytes: 636