akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

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

    ll money = 100;
    ll year = 0;
    while (true) {
        money *= 1.01;
        year++;
        if (money >= x) {
            cout << year << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int n,k;
  while(scanf("%d%d",&n,&k),n+k){
    int card[n];
    set<int> s;
    for(int i=0; i<n; i++)
      scanf("%d",&card[i]);
    vector<int> v(n);
    for(int i=0; i<k; i++)
      v[n-k+i] = i+1;
    do{
      int a[k];
      for(int i=0; i<n; i++){
	if(card[i]!=0)
	  a[v[i]-1]=card[i];
      }
      int nn = 0;
      for(int i=0; i<k; i++){
	int tmp = a[i];
	int keta = 1;
	while(tmp!=0){
	  keta*=10;
	  tmp/=10;
	}
	nn*=keta;
	nn+=a[i];
      }
      s.insert(nn);
    }while(next_permutation(v.begin(), v.end()));
    cout << s.size() << endl;
  }
  return 0;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n + 1);
	rep(i, 1, n + 1) read(v[i]);
	int a = 0;
	rep(i, 1, n + 1) if (i % 2 == 1 && v[i] % 2 == 1) a++;
	write(a);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};

int main() {
    ll n;
    cin >> n;
    mint a=1,b=1,c=1;
    rep(i,n){
        a*=10;
        b*=9;
        c*=8;
    }
    mint ans=a.x-b.x-b.x+c.x;
    cout << ans.x << endl;

}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[] ary = new int[2];
		ary[0] = Integer.parseInt(s.substring(0, 2));
		ary[1] = Integer.parseInt(s.substring(2));
		String ans;
		if(isMM(ary[0])){
			if(isMM(ary[1])) {
				ans = "AMBIGUOUS";
			}else{
				ans = "MMYY";
			}
		}else{
			ans = (isMM(ary[1])) ? "YYMM" : "NA";
		}
		System.out.println(ans);
	}
	static boolean isMM(int n){
		return n > 0 && n < 13;
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		long ans=0;
		for(int i = 0; i<=k; i++){
			for(int j =0; j<=k; j++){
				if(s-i-j>=0 && s-i-j<=k){
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;

inline void down(int &x,const int &y){if(x>y)x=y;}
const int maxn = 210000;

int n,m;
struct edge{int y,c,nex;}a[maxn]; int len,fir[maxn];
inline void ins(const int x,const int y,const int c){a[++len]=(edge){y,c,fir[x]};fir[x]=len;}

int siz[maxn],rt,uc[maxn];
void dfs(const int x,const int fa)
{
	bool flag=true; siz[x]=1;
	for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y) if(y!=fa)
	{
		uc[y]=a[k].c; dfs(y,x); siz[x]+=siz[y];
		if(siz[y]*2>n) flag=false;
	}
	if((n-siz[x])*2>n) flag=false;
	if(flag) rt=x;
}

ll ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y,c; scanf("%d%d%d",&x,&y,&c);
		ins(x,y,c); ins(y,x,c);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) ans+=uc[i]*2ll*min(siz[i],n-siz[i]);
	int rt2=-1;
	for(int k=fir[rt],y=a[k].y;k;k=a[k].nex,y=a[k].y)
	{
		if(siz[y]>siz[rt])
		{
			if(siz[rt]*2<=n) rt2=y;
		}
		else if((n-siz[y])*2<=n) rt2=y;
	}
	if(rt2==-1)
	{
		int mc=inf;
		for(int k=fir[rt],y=a[k].y;k;k=a[k].nex,y=a[k].y) down(mc,a[k].c);
		ans-=(ll)mc;
	}
	else
	{
		for(int k=fir[rt],y=a[k].y;k;k=a[k].nex,y=a[k].y) if(y==rt2)
			ans-=(ll)a[k].c;
	}
	printf("%lld\n",ans);
	
	return 0;
}


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

int main() {
    int N; cin >> N;
    vec v(N);
    rep(i, N) cin >> v[i];

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

    double res;

    res = (double) (v[0]+v[1])/2;

    for (int i=1; i<N-1; i++) {
        res = (double) (res + v[i+1])/2;
    }

    printf("%.7f\n", res);

}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;
using ll = int64_t;

const int N_MAX = 200001;

// Combination Table
// C[n][k] -> nCk
array<array<ll, 3>, N_MAX> C;

void comb_table(int N)
{
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= 2; j++)
        {
            if (j == 0 || j == i) C[i][j] = 1LL;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
        }
    }
}

map<ll, int> A;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;
    gc(N);

    comb_table(N_MAX);

    ll suma = 0;
    A[suma]++;

    REP(i, N)
    {
        ll a;
        gc(a);
        suma += a;
        A[suma]++;
    }

    ll cnt = 0;
    for (auto &&a : A) if (1 < a.second) cnt += C[a.second][2];

    cout << cnt << endl;
    return 0;
}


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


int main()
{
	int N, num;
	bool flag = 0;
	vector<int> d;

	cin >> N;
	for (int i = 0;i<N; ++i) {
		cin >> num;
		for (int j = 0;j<d.size(); ++j) {
			if (num == d[j]) flag = 1;
		}
		if(flag == 0) d.push_back(num);
		flag = 0;
	}

	cout << d.size() << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


ll a[16][16];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%lld", &a[i][j]);
        }
    }

    int mm=(1<<n);
    int z[17];
    vector<ll> dp(mm);
    int k;
    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }

        dp[k]=0;
        for(i=0; i<siz; i++) {
            for(j=i+1; j<siz; j++) {
                dp[k] += a[z[i]][z[j]];
            }
        }

        ll max=0;
        int MM=(1<<siz);
        for(i=0; i<MM; i++) {
            int tmp0=0;
            for(j=0; j<siz; j++) {
                if(i & (1<<j)) tmp0 |= (1<<z[j]);
            }
            ll val = dp[tmp0]+dp[k^tmp0];
            max = MAX(max, val);
        }
        dp[k] = max;
    }
    printf("%lld\n", dp[mm-1]);

    return 0;
}


Measured memory_bytes: 896
import java.util.*;

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

Measured memory_bytes: 30956
#include <stdio.h>

int main(void) {

    int n, b, f, r, v;
    int a[4][3][10] = {0};

    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b - 1][f - 1][r - 1] += v;
    }

    for(int j = 0; j < 4; j++){
        for(int k = 0; k < 3; k++){
            for(int l = 0; l < 10; l++){
                printf("%2d", a[j][k][l]);
            }
            putchar('\n');
            if(j < 3 && k == 2) printf("####################\n");
        }
    }

    return 0;
}


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

using namespace std;

int main(){

  int m,n;

  while(1){

	cin>>m;

	if(m==0)
	  break;

	cin>>n;
	
	int count = 0;
	
	for(int i=m;i<=n;++i){

	  int result = i;
	  
	  while(1){

		if(result%2==0)
		  result = result/2;
		else if(result%3==0)
		  result = result/3;
		else if(result%5==0)
		  result = result/5;
		else
		  break;
	  }
	  
	  if(result == 1)
		count++;
	  
	}

	cout<<count<<endl;
	
  }
  
}



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

int main() {
	int n;cin>>n;
  	vector<int> a(n);
  	for(int i=0;i<n;i++) cin>>a[i];
    
  	bool exist_odd=false;
  	int ans=0;
  	while(true){
    	for(int i=0;i<n;i++){
        	if(a[i]%2==1)exist_odd=true;
        }
      	if(exist_odd) break;
    	for(int i=0;i<n;i++){
    		a[i]=a[i]/2;
    	}
    		ans++;
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int , input().split()))
s = [0]
d = {0:1}
for i in range(N):
    nex = s[-1]+a[i]
    s.append(nex)
    if nex not in d:
        d[nex] = 0
    d[nex] += 1
    
ans = 0
for v in d.values():
    if v >= 2:
        ans += int(v*(v-1)/2)
print(ans)


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

int n, m, x, y;
int vis[51], adj[51][51];
vector <pair <int, int> > edges;

void dfs(int node){
    if(vis[node]) return;
    vis[node] = 1;
    for(int i = 1 ; i <= n ; i++)
        if(adj[node][i]) dfs(i);
}
bool check(){
    for(int i = 0 ; i < 51 ; i++)
        vis[i] = 0;
    dfs(1);
  //  for(int i = 1 ; i <= n ; i++)
  //      cout << vis[i] << " ";
//cout << endl;
    int ch = 0;
    for(int i = 0 ; i < 51 ; i++)
        ch += vis[i];
    return ch==n;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    while(m-- && cin >> x >> y)
        edges.push_back(make_pair(x, y)), adj[x][y] = adj[y][x] = 1;
  //  for(int i = 1 ; i <= n ; i++)
  //      for(int j = 1 ; j <= n ; j++)
  //          cout << adj[i][j] << " \n"[j==n];
  //  check();
    int ans = 0;
    for(int i = 0 ; i < edges.size() ; i++){
        x = edges[i].first;
        y = edges[i].second;
        adj[x][y] = adj[y][x] = 0;
        if(!check()) ans++;
        adj[x][y] = adj[y][x] = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[]) {
  int H, W;
  std::cin >> H >> W;
  char s[52][52];
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j)
      std::cin >> s[i][j];

  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
      if (s[i][j] == '#' && (s[i + 1][j] != '#' && s[i][j + 1] != '#' &&
                             s[i - 1][j] != '#' && s[i][j - 1] != '#')) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
"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);}

class dijkstra{
  constructor(n){
    this.graph = Array(n).fill().map(a=>[]);
  }
  add(u,v,cost){
    this.graph[u].push(v,cost);
  }
  add2(u,v,cost){
    this.graph[u].push(v,cost);
    this.graph[v].push(u,cost);
  }
  solve(start){
    const INF = 1e18;
    const g = this.graph;
    var pq = new priorityQueue();
    pq.push([0,start]);
    var dp = Array(g.length).fill(INF);
    dp[start] = 0;
    while(pq.size){
      var [t,v] = pq.pop();
      if(dp[v] < t)continue;
      for(var i = 0; i < g[v].length; i+=2){
        var V = g[v][i], c = g[v][i+1] + t;
        if(dp[V] <= c)continue;
        dp[V] = c;
        pq.push([c,V]);
      }
    }
    return dp;
  }
}

class priorityQueue{
  constructor(){
    this.a=[];
  }
  push(x){
    const a = this.a;
    for(var i = a.length, j; i; i = j){
      j = i - 1 >> 1;
      if(x[0] >= a[j][0])break;
      a[i] = a[j];
    }
    a[i] = x;
  }
  pop(){
    const a = this.a;
    var r = a[0];
    var x = a.pop();
    var k = a.length >> 1;
    for(var i = 0, j; i < k; i = j){
      j = (i << 1) + 1;
      if(a[j+1] && a[j][0] > a[j+1][0])j++;
      if(a[j][0] >= x[0])break;
      a[i] = a[j];
      i = j;
    }
    if(a.length)a[i] = x;
    return r;
  }
  get size(){
    return this.a.length;
  }
  get top(){
    return this.a[0];
  }
}

const mx = 2500;

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

function main(){
  var [n,m,s] = nexts(3);
  var g = new dijkstra(mx * n);
  for(var i = 0; i < m; i++){
    var [u,v,a,b] = nexts(4);
    u--,v--;
    u *= mx, v *= mx;
    for(var j = mx; j-- > a;){
      g.add(u+j,v+j-a,b);
      g.add(v+j,u+j-a,b);
    }
  }
  for(var i = 0; i < n; i++){
    var [c,d] = nexts(2);
    var v = i * mx;
    for(var j = 0; j < mx-1; j++)g.add(v+j,v+Math.min(mx-1,j+c),d);
  }
  var dp = g.solve(Math.min(mx-1,s));
  var ans = xArray(1e18,n);
  for(var i = 1; i < n; i++){
    var v = i*mx;
    for(var j = 0; j < mx; j++){
      ans[i] = Math.min(ans[i],dp[v+j]);
    }
  }
  return ans.slice(1).join("\n");
}

Measured memory_bytes: 112848
S = int(input())

mod = 10 ** 9 + 7
f = [1]
for i in range(1,2000):
    f.append((f[-1] * i) % mod)
def comb(n,r):
    return f[n] * (pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod) % mod

ans = 0

for i in range(1,700):
    s = S - (3 * i)
    if s < 0:
        break
    ans += comb(s+i-1, i-1)
    ans %= mod

print(ans)

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

int main() {
  string s;
  cin >> s;
  
  vector<int> c(26);
  bool ok = true;
  for(int i = 0; i < s.size(); i++){
    int k = s.at(i) - 'a';
    c[k]++;
    if(c[k] == 2){
      ok = false;
      break;
    }
  }
  
  if(ok) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
<?php

$str = fgets(STDIN);

if (!preg_match("/^[a-z]+$/", $str)) {
    echo 'No' . "\n";
    exit;
}

$length = strlen($str) - 1;

for ($i=0; $i<$length; $i++) {
    $m[] = substr($str, $i, 1);
}


$av = array_count_values($m);


$ng = False;
foreach ($av as $a) {
    if ( (int)$a % 2 !== 0 ) {
        $ng = True;
    }
}

if ( !$ng ) {
    echo 'Yes';
} else {
    echo 'No';
}

echo "\n";

Measured memory_bytes: 2812
from collections import defaultdict
A = defaultdict(int)
B = defaultdict(int)
C = defaultdict(int)

N = int(input())
a = [k for k in map(int, input().split())]
b = [k for k in map(int, input().split())]
c = [k for k in map(int, input().split())]

for k in range(N):
  A[a[k]] += 1
  B[b[k]] += 1
  C[c[k]] += 1

Aset = sorted(set(a))
Bset = sorted(set(b))
Cset = sorted(set(c))

cnt = 0
index_a = 0
index_c = 0
a = 0
c = N

for b in Bset:
  flag_a = False
  flag_c = False
  if a < N:
    for k in range(index_a, len(Aset)):
      if Aset[k] < b:
        a += A[Aset[k]] 
      else:
        index_a = k
        flag_a = True
        break
  for k in range(index_c, len(Cset)):
    if Cset[k] <= b:
      c -= C[Cset[k]]
    else:
      index_c = k
      flag_c = True
      break
  if flag_a == False:
    a = N
  if flag_c == False:
    break
  cnt += a*c*B[b]
print(cnt)

Measured memory_bytes: 43540
N,M,Q = list(map(int,input().split()))
mp = [[0 for i in range(N+1)] for j in range(N+1)]
ans = []
for i in range(M):
    l,r = map(int,input().split())
    mp[l][r] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        mp[i][j] += mp[i-1][j]
        mp[i][j] += mp[i][j-1]
        mp[i][j] -= mp[i-1][j-1]

for i in range(Q):
    p,q = list(map(int,input().split()))
    
    ans.append(mp[q][q]-mp[p-1][q]-mp[q][p-1]+mp[p-1][p-1])

for i in ans:
    print(i)

Measured memory_bytes: 17940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#include<map>
#define int long long
#define P pair<int,int>
using namespace std;

P dp[201][201][2]{};//first ???????????? second ??????????????? 0 ??? 1 ???
signed main() {
	dp[1][1][0].first = dp[1][1][1].first = 1;
	for (int a = 3; a < 300; a++) {
		for (int b = 1; b < a; b++) {
			if (b > 150 || a - b > 150)continue;
			dp[b][a - b][0].first = (dp[b - 1][a - b][0].first + dp[b - 1][a - b][0].second)%100000;
			dp[b][a - b][0].second = (dp[b][a - b - 1][1].first)%100000;
			dp[b][a - b][1].first = (dp[b][a - b - 1][1].first + dp[b][a - b - 1][1].second)%100000;
			dp[b][a - b][1].second=(dp[b - 1][a - b][0].first)%100000;
		}
	}
	int x, y;
	while (cin >> x >> y,x|y) {
		cout << (dp[x - 1][y][0].first + dp[x - 1][y][0].second + dp[x][y - 1][1].first + dp[x][y - 1][1].second)%100000 << endl;
	}
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using namespace std;

// long long gcd(long long a, long long b){
//     if (a < b){
//         a ^= b;
//         b ^= a;
//         a ^= b;
//     }
//     return b ? gcd(b, a % b) : a;
// }

// long long lcm(long long a, long long b){
//     return a * b / gcd(a, b);
// }

int main(){
    long long n,a,four=0,two=0;
    cin >> n;
    rep(i,n){
        cin >> a;
        if(a%4 == 0){
            four++;
        }else if(a%2 == 0){
            two++;
        }
    }
    
    if(n/2 <= four){
        cout << "Yes" << endl;
    }else if(four*2 + two >= n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
map<ll,char> mp;
ll n;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	int ii=1;
    char t='a';
    while(ii<=26){
        mp[ii++]=t++;
    }
    read(n);
    string ans;
    while(n){
        ll t=n%26;
        n/=26;
        if(t==0){
            t+=26;
            n--;
        }
        ans=mp[t]+ans;
    }
    cout<<ans<<endl;
	//===========================================================
	return 0;
}

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

int main() {
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L=A+B,R=C+D;
  if(L>R){
    cout << "Left" << endl;
  }
  else if(L==R){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3568
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	pairs := make([][]int, n)
	for i := 0; i < n; i++ {
		x := nextInt()
		y := nextInt()
		pairs[i] = []int{x, y}
	}
	sort.Slice(pairs, func(i, j int) bool {
		if pairs[i][0] < pairs[j][0] {
			return true
		} else if pairs[i][0] == pairs[j][0] {
			return pairs[i][1] <= pairs[j][1]
		}
		return false
	})

	for i := 0; i < n; i++ {
		fmt.Println(stringifyArray(pairs[i]))
	}
}



Measured memory_bytes: 11812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=2e5+5;
const ll MOD=1e9+7;
const ll MOD1=13;
ll n,a[MAXN];
multiset<ll,greater<ll> >s;
void solve()
{
    for(ll i=1;i<=n;i++)
    {
        auto it=s.upper_bound(a[i]);
        if(it!=s.end())
        {
            s.erase(it);
        }
        s.insert(a[i]);
    }
    printf("%d\n",s.size());
}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    solve();
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;
#define pb(x) push_back(x)
#define MOD 1000000007

using namespace std;

int main(){

    string str;

    cin >> str;

    int cntW = 0;
    int cntB = 0;

    REP(i,str.size()){
        str[i] == 'W' ? cntW++ : cntB++;
    }

    if(cntW == 0 || cntB == 0){
        cout << 0 << endl;
        return 0;
    }

    int tmp = 0;
    int ans = 0;
    
    REP(i,str.size()){
        //printf("str[%d] = %c\n",tmp,str[tmp]);
        if(str[tmp] != str[i]){
            tmp = i;
            ans++;
        }
    }

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


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String line = scanner.nextLine();
		if(line.length() == 2) {
			System.out.println(line);
		}else {
			for(int i = line.length() -1 ; i >= 0 ; i--) {
				System.out.print(line.charAt(i));
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli k, a, b;
	cin >> k;
	cin >> a >> b;

	loop(i, a, b+1){
		if(i%k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	bool can = false;
	if (a == b && c != a && c != b) can = true;
	else if (b == c && a != b && a != c)can = true;
	else if (c == a && b != a && b != c)can = true;
	if (can)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	return 0;
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = []
flag = False
for i in range(N) :
    b.append(int(input()))

a = [[0,0,0] for i in range(8)]

a[0] = A[0]
a[1] = A[1]
a[2] = A[2]
a[3] = [A[0][0],A[1][0],A[2][0]]
a[4] = [A[0][1],A[1][1],A[2][1]]
a[5] = [A[0][2],A[1][2],A[2][2]]
a[6] = [A[0][0],A[1][1],A[2][2]]
a[7] = [A[0][2],A[1][1],A[2][0]]

for i in range(N) :
    for j in range(8) :
        for k in range(3) :
            if b[i] == a[j][k] :
                a[j][k] = 0
#print(a)
for i in range(8) :
    if a[i] == [0,0,0] :
        print("Yes")
        flag = True
        break

if flag == False :
    print("No")

Measured memory_bytes: 3064
class Card:
    def __init__(self, s):
        self.suit = s[0]
        self.value = int(s[1])

    def __lt__(self, another_card):
        return self.value < another_card.value

    def __repr__(self):
        return self.suit + str(self.value)


def bubble_sort(A):
    n = len(A)
    A = A[:]
    for i in range(n):
        for j in reversed(range(i + 1, n)):
            if A[j] < A[j - 1]:
                A[j - 1], A[j] = A[j], A[j - 1]
    return A


def selection_sort(A):
    n = len(A)
    A = A[:]
    for i in range(n):
        min_idx = i
        for j in range(i + 1, n):
            if A[j] < A[min_idx]:
                min_idx = j
        A[min_idx], A[i] = A[i], A[min_idx]
    return A


N = int(input())
A = [Card(s) for s in input().split()]
A_sorted_by_bsort = bubble_sort(A)
A_sorted_by_ssort = selection_sort(A)
print(*A_sorted_by_bsort)
print("Stable")
print(*A_sorted_by_ssort)
print("Stable" if A_sorted_by_ssort == A_sorted_by_bsort else "Not stable")



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
const int mod=1e9+7;
ll A[maxn], B[maxn], C[maxn], pw[maxn];
string s;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    string s;
    cin>>s;
    int q=0, a=0;
    pw[0]=1;
    for(int i=1; i<sz(s); i++)
        pw[i]=(pw[i-1]*3)%mod;

    for(int i=0; i<sz(s); i++)
    {
        if(s[i]=='A')a++;
        if(s[i]=='?')q++;
        A[i]=(a*pw[q]+(q?q*pw[q-1]:0))%mod;
    }

    for(int i=1; i<sz(s); i++)
    {
        B[i]=B[i-1];
        if(s[i]=='B')B[i]=(B[i]+A[i-1])%mod;
        if(s[i]=='?')B[i]=((B[i]+A[i-1])%mod+(B[i-1]*2)%mod)%mod;
    }

    ll ans=0;

    for(int i=2; i<sz(s); i++)
    {
        C[i]=C[i-1];
        if(s[i]=='C')C[i]=(C[i]+B[i-1])%mod;
        if(s[i]=='?')C[i]=((C[i]+B[i-1])%mod+(C[i-1]*2)%mod)%mod;
    }
    cout<<C[sz(s)-1]<<"\n";
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<int> topological_sort(vector<vector<int>> &G, vector<int> &indegree, int V) {
    // トポロジカルソートを記録する配列
    vector<int> sorted_vertices;
    // 入次数が0の頂点を発見したら、処理待ち頂点としてキューに追加する
    queue<int> que;
    for (int i = 0; i < V; i++) {
        if (indegree[i] == 0) {
            que.push(i);
        }
    }

    // キューが空になるまで、操作1~3を繰り返す
    while (que.empty() == false) {
        // キューの先頭の頂点を取り出す
        int v = que.front();
        que.pop();

        // その頂点と隣接している頂点の入次数を減らし、0になればキューに追加
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i];
            indegree[u] -= 1;
            if (indegree[u] == 0) que.push(u);
        }
        // 頂点vを配列の末尾に追加する 
        sorted_vertices.push_back(v);
    }

    // トポロジカルソートを返す
    return sorted_vertices;
}

int main(void) {
    // 頂点数と辺の本数
    int V, E;
    cin >> V >> E;

    // 隣接リストにより表現されるグラフ
    vector<vector<int>> G(V);
    // 頂点の入次数を記録する配列
    vector<int> indegree(V);
    for (int i = 0; i < E; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        indegree[v] += 1;
    }

    // トポロジカルソートする
    vector<int> sorted_vertices = topological_sort(G, indegree, V);

    // トポロジカルソートを出力
    for (int i = 0; i < sorted_vertices.size(); i++) {
        cout << sorted_vertices[i] << endl;
    }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int w;
  cin >> w;
  cout << w * 32 << '\n';
  return 0;
}



Measured memory_bytes: 3212
n = int(input())
B = list(map(int, input().split()))

A =[]

A.append(B[0])

for i in range(n-2):
    if B[i] < B[i+1]:
        A.append(B[i])
    else:
        A.append(B[i+1])

A.append(B[n-2])

ans = sum(A)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
    ll N; cin >> N;
    vector<ll> a(N+1, 0);
    rep(i, N) cin >> a.at(i);

    ll cnt = 1;
    ll ans = 0;
    a.at(N) = INF;

    sort(a.begin(), a.end());
    for(ll i=0; i<N; i++){
        if(a.at(i) == a.at(i+1)){
            cnt++;
        }
        else{
            if(cnt == a.at(i)) cnt = 1;
            else if(cnt < a.at(i)){
                ans += cnt;
                cnt = 1;
            }
            else{
                ans += cnt - a.at(i);
                cnt = 1;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,A,B;
LL h[100000];

LL ans = 0;

void solve(){
	LL left = 0;
	LL right = 10e9+1;
	while(left+1<right){
		LL center = (left+right)/2;
		auto ok = [&](){
			LL base_damage = B*center;
			int counter = center;
			LL direct_hit_damage = (A-B);
			for(int i=0;i<N;i++){
				LL remain = h[i]-base_damage;
				if(remain>0){
					counter -= remain/direct_hit_damage + (remain%direct_hit_damage!=0);
					if(counter<0) return false;
				}
			}
			return true;
		};
		if(ok()) right = center;
		else left = center;
	}

	ans = right;
}
 
int main(){
    cin >> N >> A >> B;
    for(int i=0;i<N;i++) cin >> h[i];
 
    solve();

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

Measured memory_bytes: 1024
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  String s[]="abcdefghijklmnopqrstuvwxyz".split("",0);
  String po=sc.next();
  String a[]=po.split("",0);
  Map<String,Integer>map=new HashMap<>();
  for(int i=0;i<a.length;i++){
  map.put(a[i],0);
  }
  if(map.size()==26)System.out.println("None");
  else
  for(int i=0;i<s.length;i++){
  if(!map.containsKey(s[i])){
  System.out.println(s[i]);break;
  }
  }
}

}


Measured memory_bytes: 32628
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x+r<=W&&y+r<=H&&y>=r&&x>=r){
    printf("Yes\n");
    }   
    else {
    printf("No\n");
    }
    return 0;
}








Measured memory_bytes: 2104
d = int(input())
x = "Christmas"
y = "Eve"
if d == 25:
    print(x)
elif d == 24:
    print("{} {}".format(x, y))
elif d == 23:
    print("{} {} {}".format(x, y, y))
else:
    print("{} {} {} {}".format(x, y, y, y))

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception {
		Scanner s = new Scanner(System.in);
		int N = 5, sum = 0, n = 10;
		int[] t = new int [N];
		for (int i = 0; i < N; i++){
			t[i] = s.nextInt();
			int[] T = {(int)Math.ceil(t[i] / 10.0), t[i] % 10};
			// System.out.println(T[0] + " " + T[1]);
			sum += T[0];
			// System.out.println(sum);
			if (T[1] < n && T[1] != 0) n = T[1];
			// System.out.println(n);
			// System.out.println();
		}
		System.out.println(sum * 10 + n - 10);
		/*
		29 20 7 35 120 ->215
		101 86 119 108 57 -> 481
		*/
		
	}
}


Measured memory_bytes: 21972
n, m = gets.split.map(&:to_i)
a = Array.new(n){gets.chomp}
b = Array.new(m){gets.chomp}

result = a.each_cons(m).any? do |lines|
  (n - m + 1).times.any? do |i|
    lines.zip(b).all? do|line_a, line_b|
      line_a[i, m] == line_b
    end
  end
end

puts result ? "Yes" : "No"

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        int[] a = new int[4];
        for (int i = 0 ; i < n ; i++) {
            if (s[i] == 'N') {
                a[0]++;
            } else if (s[i] == 'W') {
                a[1]++;
            } else if (s[i] == 'S') {
                a[2]++;
            } else {
                a[3]++;
            }
        }
        if ((a[0] == 0 && a[2] != 0) || (a[0] != 0 && a[2] == 0) || (a[1] == 0 && a[3] != 0) || (a[1] != 0 && a[3] == 0)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

}


Measured memory_bytes: 23892
m, d = map(int, input().split())
count = 0
for i in range(1, d + 1):
    for j in range(1, m + 1):
        d1 = i % 10
        d10 = i // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == j:
            count += 1

print(count)


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

int main(){
  int n,k; cin>>n>>k;
  vector<int> num(k);
  for(int i=0;i<k;i++){
    cin>>num[i];
  }
  while(true){
    int log =n; bool flag=false;
    while(log!=0){
      int a=log%10; log/=10;
      for(int i=0;i<k;i++){
        if(num[i]==a){
          flag=true;
          break;
        }
      }
      if(flag) break;
      if(log==0){
        cout<<n<<endl;
        return 0;
      }
    }
    n++;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int s[200][200],r[200][200],t[200],a[200],b[200],c[200],d[200];
int main(void)
{
	int m,n,i,k,h,x;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++) scanf("%d",&t[i]);
	for(i=0;i<m;i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);
	for(i=0;i<n;i++){
		for(k=0;k<m;k++) s[i][k]=0;
	}
	for(i=0;i<n;i++){
		d[i]=0;
		for(k=0;k<m;k++){
			if(a[k]<=t[i]&&t[i]<=b[k]){
				r[i][d[i]]=c[k];
				d[i]++;
			}
			
		}
	}
	for(i=1;i<n;i++){
		for(k=0;k<d[i];k++){
			for(h=0;h<d[i-1];h++){

				if(s[i][k]<abs(r[i][k]-r[i-1][h])+s[i-1][h]){
					s[i][k]=abs(r[i][k]-r[i-1][h])+s[i-1][h];
				}			
			}
		}
	}
	x=0;
	for(i=0;i<d[n-1];i++){
		if(x<s[n-1][i]) x=s[n-1][i];
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2972
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let[k,s]=t.n(2)
  let c=0
  for(let x=0;x<=k;x++){
    if(x>s)break
    for (let y = 0; y <= k; y++) {
      if(x+y>s) { break }
      if((x+y)<=s&&(x+y+k)>=s)c++
    }
  }
  t.o(c)
}
main()

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;

int main(){
    int n; cin >> n;
    int h[n];
    int max_h = 0;
    REP(i,n) cin >> h[i];

    int pre = -999;
    REP(i,n){
        if(pre <= h[i]-1){
            pre = h[i] - 1;
        }
        else if(pre <= h[i]){
            pre = h[i];
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	_, _ = strconv.Atoi(nextLine())
	S_seq := strings.Split(nextLine(), " ")

	q, _ := strconv.Atoi(nextLine())
	T_seq := strings.Split(nextLine(), " ")

	count := 0
	cvt := convertIntSeq(S_seq)

	for i := 0; i < q; i++ {
		target, _ := strconv.Atoi(T_seq[i])

		res, tmp := getAndRemove(cvt, target)
		copy(cvt, tmp)
		if res {
			count++
		}
	}
	fmt.Println(count)
}

func convertIntSeq(seq []string) []int {
	s := make([]int, len(seq))
	for i, r := range seq {
		s[i], _ = strconv.Atoi(r)
	}
	return s
}

func getAndRemove(seq []int, target int) (bool, []int) {
	for idx, s := range seq {
		// fmt.Printf("s=%d, target=%d\n", s, target)
		if target == s {
			res := make([]int, 0)

			// fmt.Printf("bingo! idx=%d, s=%d, target=%d\n", idx, s, target)

			if idx-1 >= 0 {
				res = append(res, seq[:idx]...)
				res = append(res, seq[idx+1:]...)
			} else {
				res = append(res, seq[idx+1:]...)
			}
			return true, res
		}
	}
	return false, seq
}



Measured memory_bytes: 5808
#include <iostream>

#define SIZE 1001

using namespace std;

int main() {
    long  A,B,D,i,j,k,day;
    long c[26],t[SIZE];
    long s[SIZE][26],last[26];
  //  long long int A[100][100];

    cin >> D;
    // cout << "D = " << D << endl;
    for (i=0;i<26;i++)
      cin >> c[i];
    for (j=0;j<D;j++) {
      for (i=0;i<26;i++)
        cin >> s[j][i];
      }
    for (i=0;i<D;i++)
        cin >> t[i];

    long satisf;

    satisf = 0;
    for (i=0;i<26;i++)
      last[i] = 0;
    for (day=1;day<=D;day++) {
      // t[day-1] est le  type entre 1 et 26
      // donc on augmente la satisfaction de s[day-1][t[day-1]]
      satisf += s[day-1][t[day-1]-1];
      // on met a jour last
      last[t[day-1]-1]=day;
      for (i=0;i<26;i++)
        satisf -= c[i]*(day-last[i]);
      cout << satisf << endl;
      // c[t[day-1]-1] est
    }


  return 0;

}


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

using namespace std;

const int MAX_N = 1e5+10;

int main(int argc, char const *argv[])
{
	int n, k, h[MAX_N];
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}

	sort(h, h+n);
	int ans = h[k-1]-h[0];
	for (int i = 0; i < n-k+1; ++i){
		ans = min(ans, h[k-1+i]-h[i]);
	}
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
    int r;
    scanf("%d", &r);
    r*=2;
    double pi = acos(-1);
    printf("%.20f",pi*r);
    return 0;
}




Measured memory_bytes: 3860
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i < 300_000; i++) {
            boolean[] check = new boolean[4];
            int m = i;
            int d = 1;
            int num = 0;
            while (m > 0) {
                int r = m % 4;
                check[r] = true;
                if (r != 0) num += (2 * r + 1) * d;
                m /= 4;
                d *= 10;
            }
            if (!check[0] && check[1] && check[2] && check[3] && num <= n) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 30036
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define re register
using namespace std;
struct ios{
	template <typename ty> inline ios& operator >> (ty &x)
	{
		register int f=1;x=0;register char c=getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
		for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
		x*=f;return *this;
	}
	template <typename ty>  inline ios& operator << (ty x)
	{
		if(x<0) x=-x,putchar('-');
		if(x>9) *this << x/10;
		putchar(x%10+48);
		return *this;
	}
	inline ios& operator << (char c){putchar(c);return *this;}
}io;
ll n,a[1000],sum,k,fac[1000],tot,b[1000];
inline bool check(ll x)//以x为最大gcd 
{
	for(int i=1;i<=n;i++) b[i] = a[i]%x;//对于每个a[i]找到他的对于x的模数，
	sort(b+1,b+1+n);
	int cnt = 0;
	int l=1,r=n;
	while(l<r)
	{
		
		int dis = x-b[r];
		if(b[l] >= dis) cnt += dis,b[l] -= dis,b[r] += dis;
		else 
		{
			cnt += b[l],b[r] += b[l],b[l] -= b[l];
		}
		while(b[r]==x) r--;
		while(b[l]==0) l++;
//		int tp = b[l]+b[r];
//		if(tp < x)
//		{
//			cnt += b[l];
//			b[r] += b[l];
//			b[l] = 0;
//			++l;
//		}
//		else
//		{
//			cnt += x-b[r];
//			b[r] = x;
//			--r;
//			b[l] = tp - x;//br+bl == tp
//			if(b[l]==0) ++l;
//		}
	}
//	for(int i=1;i<=n;i++) if(b[i]%x!=0) return false;
	return (b[l]%x==0) && (cnt <= k);
}

int main()
{
	io >> n >> k;
	for(int i=1;i<=n;i++) io >> a[i],sum += a[i];
	ll ans = 1;
	for(ll i=1;i*i<=sum;i++)
	{
		if(sum%i==0) 
		{
//			fac[++tot] = i;
//			if(i!=sum/i) fac[++tot] = sum/i;
			if(check(i)) ans = max(ans,i);
			if(check(sum/i)) ans = max(ans,sum/i);
		}
	}
//	sort(fac+1,fac+1+tot);
//	for(int i=tot;i>=1;i--)
//	{
//		if(check(fac[i]))
//		{
//			io << fac[i];
//			return 0;
//		}
//	}
	io << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define int64 long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    int N, M, C;
    cin >> N >> M >> C;
    int A[100][100], B[100];
    rep(i, M) cin >> B[i];
    rep(i, N) rep(j, M){
        cin >> A[i][j];
    }
    int cnt = 0;
    rep(i, N){
        int sum = C;
        rep(j, M){
            sum += A[i][j] * B[j];
        }
        if(sum > 0) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n;cin>>n;
	ll array[n+1],brray[n+1];for(ll i=0;i<n;i++)cin>>array[i+1];
	vector<ll>res;
	brray[0]=0;
	for(ll i=0;i<n;i++)brray[i+1]=0;
	for(ll i=n;i>0;i--)
	{
		brray[i]=array[i];
		for(ll j=i*2;j<=n;j+=i)brray[i]^=brray[j];
	}
	for(ll i=0;i<n;i++)if(brray[i+1])res.pb(i+1);
	cout<<res.size()<<endl;
	for(ll i=0;i<res.size();i++)cout<<res[i]<<" ";
}


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

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

    int sum=0;

    for(int i=1;i<=n;i++){
        int b=i;
        int sum2=1;

        while(i>0){ 
            i/=10;
            if(i>0){
                sum2++;
            }
        }
        if(sum2%2==1) sum++;
        i=b;
    }

    cout<<sum<<endl;
}

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

long long a, b, c, d, m = 0;
const long long M = 1e9 + 7;
long long g[2000003], h[2000003];

long long pow(long long p, long long q) {
	long long r = 1, s = p;

	while (q) {
		if (q & 1)
			r = r * s % M;

		s = s * s % M;
		q >>= 1;
	}

	return r;
}

int main()
{
	cin >> a >> b >> c >> d;

	g[1] = 1;
	h[1] = 1;

	for (long long i = 2; i <= c + d + 2; i++) {
		g[i] = g[i - 1] * i % M;
		h[i] = pow(g[i], M - 2);
	}

	m = (g[c + d + 2] * h[c + 1] % M) * h[d + 1] % M;
	m = (m + (g[a + b] * h[a] % M) * h[b] % M) % M;
	m = (m + M - (g[b + c + 1] * h[b] % M) * h[c + 1] % M) % M;
	m = (m + M - (g[a + d + 1] * h[a] % M) * h[d + 1] % M) % M;

	cout << m << endl;
}


Measured memory_bytes: 31488