akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  
  val r = (1 to n).foldLeft((0, 1)){ (acc, k) =>
    
    def loop(i: Int, cnt: Int): Int = {
      if(i < 2 || i % 2 != 0) cnt
      else {
        loop(i / 2, cnt + 1)
      }
    }
    val cntMax = loop(k, 0)
      
    if(acc._1 < cntMax) (cntMax, k)
    else acc
  }

  println(r._2)
}


Measured memory_bytes: 25528
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cassert>
using namespace std;
using i64 = int64_t;
constexpr i64 mod = 1e9 + 7;
using vi = vector<i64>;
using vvi = vector<vi>;
using ii = pair<i64, i64>;
using vii = vector<ii>;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << 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<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007


void solve(void)
{ 

  int W ,H, N;
  cin>>W>>H>>N;
  int W_b = 0, W_e = W, H_b = 0, H_e = H;

  for (int i = 0; i < N; i++)
  {
    int X,Y,A;
    cin>>X>>Y>>A;
    if(A == 1)
    {
      W_b = max(W_b,X);
    }
    else if (A ==2)
    {
      W_e = min(W_e,X);
    }
    else if (A ==3)
    {
      H_b = max(H_b,Y);
    }
    else if(A == 4)
    {
      H_e = min(H_e,Y);
    }  
  }
  if((H_e - H_b<0)||(W_e - W_b<0))
  {
    cout<<0<<endl;
    return;
  }

  cout<<max(0LL,(H_e - H_b)*(W_e - W_b))<<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(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    double a,b,x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    a = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    b = sqrt(a);
    printf("%5f\n",b);
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define se second
#define fr first
using namespace std;

const ll N = 2e5 + 7;
const ll mod = 1e9 + 7;

ll n , m , a , cnt , sum , ans , k ;
vector<int>g[N];
set<int>st;
ll used[N];
int main(){
    cin >> n;
    for( int i = 0;i < n;i ++ )
        cout << "ACL";
}



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

int main(){
 
  string str;
  cin >> str;
  
  if (str == "a" || str == "i" || str == "u" || str == "e" || str == "o"){
  	cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 1000 * 1000 * 1000 + 7;

int add(int a, int b)
{
	return a + b < mod ? a + b : a + b - mod;
}

int sub(int a, int b)
{
	return a - b >= 0 ? a - b : a - b + mod;
}

void ADD(int &x, int val)
{
	x += val;
	if(x >= mod)
		x -= mod;
}

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int binPow(int a, int n)
{
	int res = 1;
	while(n)
	{
		if(n & 1)
			res = mult(res, a);
		a = mult(a, a);
		n >>= 1;
	}
	return res;
}

int inv(int a)
{
	return binPow(a, mod - 2);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	a = mult(a, inv(100));
	b = mult(b, inv(100));
	c = mult(c, inv(100));
	int coef = inv(sub(1, c));
	a = mult(a, coef);
	b = mult(b, coef);
	int ans = 0;
	int p1 = 1, p2 = 1;
	FOR(i, 0, n)
	{
		p1 = mult(p1, a);
		p2 = mult(p2, b);
	}
	FOR(i, 0, n)
	{
		ADD(ans, mult(p1, n + i));
		ADD(ans, mult(p2, n + i));
		p1 = mult(p1, mult(mult(n + i, inv(i + 1)), b));
		p2 = mult(p2, mult(mult(n + i, inv(i + 1)), a));
	}
	cout << mult(ans, coef);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cctype>
int main(){
    char ch;
    int count[26] = {};
    while((ch = getchar()) != EOF){
        if(isupper(ch)) ch = tolower(ch);
        if(isalpha(ch)) count[ch -'a'] += 1;
    }
    
    for(int i = 0;i < 26;i++){
        printf("%c : %d\n",i+'a',count[i]);
    }
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  int N;
  cin >> N;
  vector<long long> A(N),W(N);
  long long sum = 0,odd = 0;
  for(int i = 0;i < N;i++) {
      cin >> A.at(i);
      if(i % 2 != 0) {
          odd += A.at(i);
      }
      sum += A.at(i);
  }

  long long X = sum - odd * 2;
  cout << X << " ";

  for(int i = 1;i < N;i++) {
      long long nextX = 2 * A.at(i - 1) - X;
      cout << nextX << " ";
      X = nextX;
  }

  
  cout << endl;

  
}



Measured memory_bytes: 2944
import math
A,B,H,M = map( int ,input().split())
time = H*60+M
Ax = time/720
Bx = (time%60)/60
A_num = 12*Ax
B_num = 12*Bx
aasin = math.sin(math.radians(abs(A_num-B_num)*30))
aacos = math.cos(math.radians(abs(A_num-B_num)*30))
As = A*aasin
Bs = B - A*aacos
c = math.sqrt(As**2 + Bs**2)
print(c)

Measured memory_bytes: 9460
object Main extends App {
  def square(a: Int) = a * a
  (1 to readInt)
    .map(_ => readLine.split(" ").map(_.toInt).sorted.reverse)
    .map(s => if (s.tail.map(square).sum == square(s.head)) "YES" else "NO")
    .foreach(println)
}


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

int n, A[20];
   
bool solve(int i, int m){
    bool res;
    if ( m == 0 ){
        return true;
    }
    if ( i >= n ){
        return false;
    }
    res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main(){
    
    int q, m;
    
    cin >> n;
    for ( int i = 0; i < n; ++i ){
        cin >> A[i];
    }
    
    cin >> q;
    for ( int i = 0; i < q; ++i ){
        cin >> m;
        if ( solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3112
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define Size(x) ((int)(x).size())
const int INF = 1e9 + 10 , MN = 2e5 + 10 , LG = 222;
const long long BIG = 1000ll*1000*1000*1000*1000*1000 + 10;
int n , nxt[MN];
string s;
long long Nx[LG] , Ny[LG] , X[33][LG] , Y[33][LG];
int ps[33][MN];
void prep() {
	int cur = 0;
	for(int i=1;i<n;++i){
		while(cur && s[i] != s[cur]) cur = nxt[cur];
		cur += (s[i] == s[cur]);
		nxt[i+1] = cur;
	}
	Nx[0] = n - nxt[n] , Ny[0] = nxt[n];
	for(int i=0;i<Nx[0];++i)
		X[s[i]-'a'][0]++;
	for(int i=Nx[0];i<n;++i)
		Y[s[i]-'a'][0]++;
	for(int i=1;i<LG;++i){
		Nx[i] = Nx[i-1] + Ny[i-1];
		Nx[i] = min(Nx[i] , BIG);
		Ny[i] = Nx[i-1];
		for(int j=0;j<26;++j){
			X[j][i] = X[j][i-1] + Y[j][i-1];
			Y[j][i] = X[j][i-1];
			X[j][i] = min(X[j][i] , BIG);
		}
	}
	for(int i=0;i<n;++i)
		for(int j=0;j<26;++j)
			ps[j][i+1] = ps[j][i] + (s[i]-'a' == j);
}
long long get(long long val,int c) {
	for(int i=LG-1;~i;--i)
		if(Nx[i] <= val) return min(BIG , X[c][i] + get(val - Nx[i] , c));
	return ps[c][val];
}
int main() {
	cin>>s;
	n = Size(s)/2;
	prep();
	long long l , r;
	cin >> l >> r;
	for(int c=0;c<26;++c) cout << get(r , c) - get(l-1 , c) << ' ';
	puts("");
	return 0;
}
/*
Input

abaaba
6 10

Output

3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Input

xx
1 1000000000000000000

Output

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000000000000000 0 0

Input

vgxgpuamkvgxgvgxgpuamkvgxg
1 1000000000000000000

Output

87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887912905 0 0
*/

Measured memory_bytes: 22404
#include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i<n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s;}
			if (small > s) {small = s;}
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
int m, n;
int book[100];
bool C(int k) {
    int sum=0, cnt=1;
    for (int i=0; i<n; i++) {
        sum+=book[i];
        if (book[i]>k) return false;
        if (sum>k) {
            sum=book[i];
            cnt++;
        }
    }
    if (cnt>m) return false;
    return true;
}
int main() {
    while (scanf("%d%d",&m,&n)) {
        if (!m&&!n) break;
        for (int i=0; i<n; i++) scanf("%d",&book[i]);
        int l=1, u=1500001;
        while (u-l>1) {
            int mid=(u+l)/2;
            if (C(mid)) {
                u=mid;
            } else {
                l=mid;
            }
        }
        printf("%d\n",u);
    }
}

Measured memory_bytes: 0
#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
using namespace std;

inline void down(int &x,const int &y){if(x>y)x=y;}
const ll Mod = 1e9+7;
const int maxn = 810000;

ll pw(ll x,int k)
{
	ll re=1ll;
	for(;k;k>>=1,x=x*x%Mod) if(k&1)
		re=re*x%Mod;
	return re;
}
int n;
ll s[maxn],sN[maxn];
void pre()
{
	s[0]=1ll;
	for(int i=1;i<=2*n;i++) s[i]=s[i-1]*(ll)i%Mod;
	sN[n<<1]=pw(s[n<<1],Mod-2);
	for(int i=2*n-1;i>=0;i--) sN[i]=sN[i+1]*(ll)(i+1)%Mod;
}
ll C(const int i,const int j){return s[i]*sN[j]%Mod*sN[i-j]%Mod;}

struct edge{int y,nex;}a[maxn<<1]; int len,fir[maxn];
inline void ins(const int x,const int y){a[++len]=(edge){y,fir[x]};fir[x]=len;}
struct E{int y,c;};
inline bool operator <(const E x,const E y){return x.c<y.c;}
vector<E>V[maxn];

int nt[maxn],t[maxn],tp,tn,en;
int dfn[maxn],low[maxn],id;
int cir[maxn],cnt; bool inc[maxn];
void tarjan(const int x,const int fa)
{
	dfn[x]=low[x]=++id; t[++tp]=x;
	nt[++tn]=x; en+=V[x].size();
	for(int i=0;i<V[x].size();i++)
	{
		int y=V[x][i].y; if(y==fa) continue;
		if(!dfn[y]) 
		{
			tarjan(y,x);
			if(low[y]==dfn[x])
			{
				cnt=0;
				int la=0;
				while(la!=x)
					inc[cir[++cnt]=la=t[tp--]]=true;
			}
			else if(low[y]>dfn[x]) tp--;
			down(low[x],low[y]);
		}
		else down(low[x],dfn[y]);
	}
}
int match[maxn];
void divide(const int x,const int fa)
{
	for(int i=0;i<V[x].size();i++)
	{
		int y=V[x][i].y; if(inc[y]||y==fa)continue;
		match[y]=x;
		divide(y,x);
	}
}
ll f[maxn]; int siz[maxn];
void dp(const int x)
{
	siz[x]=0;
	f[x]=1ll;
	for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y)
	{
		dp(y);
		f[x]=f[x]*f[y]%Mod*C((siz[x]+=siz[y]),siz[y])%Mod;
	}
	siz[x]++;
}
int In[maxn];
ll count()
{
	len=0; for(int i=1,x=nt[i];i<=tn;i++,x=nt[i]) fir[x]=In[x]=siz[x]=0;
	for(int i=1,x=nt[i];i<=tn;i++,x=nt[i])
	{
		for(int j=0;j<V[x].size()&&V[x][j].y!=match[x];j++)
			ins(x,V[x][j].y),In[V[x][j].y]++;
	}
	ll ret=1; int sn=0;
	for(int i=1,x=nt[i];i<=tn;i++,x=nt[i]) if(!In[x])
	{
		dp(x);
		ret=ret*f[x]%Mod*C((sn+=siz[x]),siz[x])%Mod;
	}
	return ret;
}
ll re;
void solve(const int i)
{
	re=0;
	tn=en=0; tarjan(i,0); en>>=1;
	if(tn!=en) {re=0; return;}
	for(int i=1;i<=cnt;i++) divide(cir[i],0);
	for(int i=1;i<=cnt;i++) match[cir[i]]=i-1>0?cir[i-1]:cir[cnt];
	re+=count();
	for(int i=1;i<=cnt;i++) match[cir[i]]=i+1<=cnt?cir[i+1]:cir[1];
	re+=count();
	re%=Mod;
}

ll ans; int nown;
int main()
{
	scanf("%d",&n); pre();
	for(int i=1;i<=2*n;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		V[x].push_back((E){n+y,x+y});
		V[n+y].push_back((E){x,x+y});
	}
	for(int i=1;i<=2*n;i++)
		sort(V[i].begin(),V[i].end());
	
	nown=0; ans=1ll;
	for(int i=1;i<=n;i++) if(!dfn[i])
	{
		solve(i);
		if(!re) {ans=0; break;}
		ans=ans*re%Mod*C(nown+tn,tn)%Mod;
		nown+=tn;
	}
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 67840
'use strict'
function Main(input) {
    input = input.split("\n")[0].split('')
    let fore = input[0] + input[1]
    let back = input[2] + input[3]

    fore = parseInt(fore)
    back = parseInt(back)

    const isYear = (num) => {
      return 0 <= num && num < 100
    }
    const isMonth = (num) => {
       return 0 < num && num < 13 
    }
    
    const isForeYY = isYear(fore)
    const isBackYY = isYear(back)
    const isForeMM = isMonth(fore)
    const isBackMM = isMonth(back)
    
    const isYYMM = isForeYY && isBackMM
    const isMMYY = isForeMM && isBackYY

     let result = ""

    if(isYYMM && isMMYY ){
       result =  'AMBIGUOUS'
    } else if (isYYMM) {
      result =  'YYMM'
    } else if (isMMYY) {
      result = 'MMYY'
    } else {
      result = 'NA'
    }
    


    console.log(result)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
   int n;cin >> n;
   map<int,int> m;
   rep(i,(1<<n)){
      int a;cin >> a;
      m[-a]++;
   }
   priority_queue<int> q;
   q.push(n);
   for(auto i : m){
      int k = i.second;
      if(k > q.size()){
         cout << "No" << endl;
         return 0;
      }else{
          queue<int> p;
         for(int j = 0;j < k;j++){
            int x = q.top();q.pop();
            p.push(x);
         }
         for(int j = 0;j < k;j++){
            int y = p.front();p.pop();
            for(int l = 0;l < y;l++) q.push(l);
         }
      }
   }
   cout << "Yes" << endl;
   return 0;
   
}


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

using namespace std;

typedef long long int ll;
typedef pair<double,double> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

double dist(P p,P q){
	return sqrt(pow(p.first-q.first,2)+pow(p.second-q.second,2));
}

int main()
{
	int n;
	cin>>n;
	vector<P> p(n);
	rep(i,n){
		cin>>p[i].first>>p[i].second;
	}
	sort(all(p));
	double ans=0;
	do{
		double res=0;
		rep(i,n-1){
			res += dist(p[i+1],p[i]);
		}
		ans += res;
		// cout<<res<<endl;
	}while(next_permutation(all(p)));
	double res=1;
	repi(i,1,n+1) res *= i;


	cout<<setprecision(12)<<ans/res<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
X = [[0 for _ in range(N)] for _ in range(N)]


for _ in range(M):
    l, r = list(map(int, input().split()))
    X[l-1][r-1] += 1
C = []
for line in X:
    tmp = [0, ]
    for c in line:
        tmp.append(tmp[-1] + c)
    C.append(tmp)
query = [map(int, input().split()) for _ in range(Q)]
# print(X)
# print(C)

for p, q in query:
    ans = 0
    for i, line in enumerate(C):
        if p-1 <= i and i <= q-1:
            ans += line[q] - line[p-1]
    print(ans)


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


int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i,s.size()){
    s[i] = (s[i]-'A'+n)%26+'A';
    cout << s[i];
  }  
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    string t; cin >> t;
    s += s;
    if(s.find(t) == string::npos) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	//入力が素数の場合はn-1を出力するのでn-1で初期化
	res := n - 1

	//入力が塁上より低い間ループする
	for i := 1; i*i <= n; i++ {
		//iで割り切れない場合
		if n%i != 0 {
			continue
		}
		//iで割り切れた場合
		if v := i - 1 + (n / i) - 1; v < res {
			res = v
		}
	}
	fmt.Println(res)
}


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

#define ll long long
#define ld long double

using namespace std;

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll v[3000][3000];
ll dp[3000][3000][4];
signed main() {
    ll n, m, k;
    cin >> n >> m >> k;
    fill(&v[0][0], &v[0][0] + n * m, 0);
    fill(&dp[0][0][0], &dp[0][0][0] + n * m * 4, 0);
    for (int i = 0; i < k; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        v[a - 1][b - 1] = c;
    }
    if (v[0][0])
        dp[0][0][1] = v[0][0];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            for (int l = 0; l < 4; ++l) {
                if(j != m - 1) {
                    dp[i][j + 1][l] = max(dp[i][j + 1][l], dp[i][j][l]);
                    if(v[i][j + 1] && l != 3) {
                        dp[i][j + 1][l + 1] = max(dp[i][j + 1][l + 1], dp[i][j][l] + v[i][j + 1]);
                    }
                }
                if(i != n - 1) {
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][l]);
                    if(v[i + 1][j]) {
                        dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][l] + v[i + 1][j]);
                    }
                }
            }
        }
    }
    ll ans = max(max(dp[n - 1][m - 1][0], dp[n - 1][m - 1][1]), max(dp[n - 1][m - 1][2], dp[n - 1][m - 1][3]));
    cout << ans;
}


Measured memory_bytes: 354948
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp;
    auto K = readln.chomp.to!int;

    auto DP = new long[][][](2, K+1, N.length);
    DP[1][K-1][0] += 1;
    foreach (x; 1..N[0]-'0') DP[0][K-1][0] += 1;
    foreach (i; 1..N.length) {
        if (N[i] == '0') {
            foreach (k; 0..K+1) DP[1][k][i] += DP[1][k][i-1];
        } else {
            foreach (k; 1..K+1) DP[1][k-1][i] += DP[1][k][i-1];
            foreach (k; 0..K+1) DP[0][k][i] += DP[1][k][i-1];
        }
        foreach (k; 1..K+1) DP[0][k-1][i] += DP[1][k][i-1] * max(0, (N[i]-'0').to!long-1);

        foreach (k; 1..K+1) DP[0][k-1][i] += DP[0][k][i-1] * 9;
        foreach (k; 0..K+1) DP[0][k][i] += DP[0][k][i-1];
        DP[0][K-1][i] += 9;
    }
    long r;
    foreach (x; 0..2) r += DP[x][0][N.length-1];
    writeln(r);
}

Measured memory_bytes: 256
from collections import deque
a=deque(list(input()))
b=deque(list(input()))
c=deque(list(input()))
x=a.popleft()
while True:
    if x=="a":
        if not a:
            print("A")
            exit()
        x=a.popleft()
    elif x=="b":
        if not b:
            print("B")
            exit()
        x=b.popleft()
    else:
        if not c:
            print("C")
            exit()
        x=c.popleft()


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

const int mx = 200005;
int n, m, k;
int a[mx], b[mx];
int pa[mx] = {}, pb[mx] = {};

template <typename T>

bool chkmax(T a, T b)
{
    return (a > b) ? a : b;
}

void solve()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    pa[1] = a[0];
    pb[1] = b[0];
    for (int i = 2; i <= n; i++) {
        pa[i] = pa[i - 1] + a[i - 1];
    }
    for (int i = 2; i <= m; i++) {
        pb[i] = pb[i - 1] + b[i - 1];
    }
    int res = 0;
    for (int i = 0; i <= n; i++) {
        int left = k - pa[i];
        if (left < 0)
            break;
        auto idx = lower_bound(pb, pb + m, left);
        if (*idx > k - pa[i]) {
            res = max(res, i - 1 + (idx - pb));
            // cout << k - pa[i] << ' ' << (i - 1 + (idx - pb)) << '\n';
        } else {
            res = max(res, i + (idx - pb));
            //cout << left << ' ' << (i + (idx - pb)) << '\n';
        }
    }
    cout << res << '\n';
}

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

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

using namespace std;

long long n;
long long k;
long long sum;
long long minn, maxx;
long long ss = 1000000007;

int main(void)
{
	scanf("%lld %lld", &n, &k);
	
	for(long long i = 0 ; i < k ; i++)
		minn = (minn + i) % ss;
	
	for(long long i = 0 ; i < k ; i++)
		maxx = (maxx + n - i) % ss;
	
	for(long long i = k ; i <= n + 1 ; i++)
	{
		sum = (sum + maxx - minn + 1) % ss;
		minn = (minn + i) % ss;
		maxx = (maxx + n - i) % ss;
	}
	
	sum %= ss;
	
	printf("%lld", sum < 0 ? sum + ss : sum);
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int IINF = INT_MAX;
const ll MAX_N = ll(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, k, x[MAX_N], dmin = IINF;
    cin >> n >> k;
    REP(i,n) cin >> x[i];
    REP(i,n-k+1)dmin = min(dmin, x[i+k-1]-x[i] + min(abs(x[i+k-1]),abs(x[i])));
    cout << dmin << endl;
    return 0;
}


Measured memory_bytes: 640
//半分全列挙
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int V[(1 << 18) + 1], W[(1 << 18) + 1];
int q;
int v[100000], L[100000];
int D;	//深さ
int dp[513][100001];	//dp[v][w] = 最大の価値.

int dfs(int pos, int w) {
	if (pos == 0) return 0;
	if (dp[pos][w] != -1) return dp[pos][w];
	
	int res, ret = 0;
	if (W[pos] <= w) {
		res = dfs(pos / 2, w - W[pos]) + V[pos];
		ret = max(ret, res);
	}
	res = dfs(pos / 2, w);
	ret = max(ret, res);
	return dp[pos][w] = ret;
}

void prepare() {
	int i, j;
	int d = D / 2;
	
	for (i = 1; i < (1 << (d + 1)); i++) {
		rep(j, 100000) dp[i][j + 1] = max(dp[i][j], dp[i][j + 1]);
	}
}

int dfs2(int pos, int w) {
	int d = D / 2;
	if (pos <= (1 << (d + 1)) - 1) return dp[pos][w];
	
	int res, ret = 0;
	if (W[pos] <= w) {
		res = dfs2(pos / 2, w - W[pos]) + V[pos];
		ret = max(ret, res);
	}
	res = dfs2(pos / 2, w);
	ret = max(ret, res);
	return ret;
}

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> V[i + 1] >> W[i + 1];
	cin >> q;
	rep(i, q) cin >> v[i] >> L[i];
	
	for (D = 0; ; D++) {
		if ((1 << (D + 1)) - 1 >= n) break;
	}
	
	//深さD / 2までは、愚直に解く
	int d = D / 2;
	
	for (i = 1; i < (1 << (d + 1)); i++) {
		rep(j, 100001) dp[i][j] = -1;
	}
	
	for (i = 1; i < (1 << (d + 1)); i++) {
		rep(j, 100001) dfs(i, j);
	}
	prepare();
	
	//クエリ
	rep(i, q) {
		int res = dfs2(v[i], L[i]);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 408524
def filla(s):
    sret=""
    for i in range(len(s)):
        if s[i] == '?':
            sret += 'a'
        else:
            sret += s[i]
    return sret

s=input()
t=input()

scand=s
bl=True

for i in range(len(s)):
    if len(s) - len(t) >= i:
        for j in range(len(t)):
            if s[i+j] != t[j] and s[i+j] != '?':
                break
            if j == len(t)-1:
                bl=False
                scand = s
                for k in range(len(t)):
                    str_list=list(scand)
                    str_list[i+k]=t[k]
                    scand="".join(str_list)

if bl:
    print("UNRESTORABLE")
else:
    print(filla(scand))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll arr[maxn], prefix[maxn];
ll check(int val, int n) {
    ll cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int pos = lower_bound(arr + 1, arr + 1 + n, val - arr[i]) - arr;
        cnt += n + 1 - pos;
    }
    return cnt;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, m; cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    sort(arr + 1, arr + 1 + n);
    for (int i = 1; i <= n; ++i) prefix[i] = prefix[i - 1] + arr[i];
    ll left = 0, right = 2 * maxn, res = 0;
    while (left <= right) {
        ll mid = (left + right) / 2; ll cnt;
        if ((cnt = check(mid, n)) < m)
            right = mid - 1;
        else {
            left = mid + 1, res = 0;
            for (int i = 1; i <= n; ++i) {
                int pos = lower_bound(arr + 1, arr + 1 + n, mid - arr[i]) - arr;
                res += (ll)(n + 1 - pos) * arr[i] + prefix[n] - prefix[pos - 1];
            }
            if (cnt > m) res -= (cnt - m) * mid;
        }
    }
    cout << res << '\n';
}

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

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

    long long int count = 0;

    for(int i = 1;i < n+1;i++){
        if(i % 3 != 0 && i % 5 != 0){
            count += i;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3620
using System;

class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for(int i = 1; i <= n; i++)
        {
            if(i.ToString().Contains("3") || i % 3 == 0)
            {
                Console.Write(" " + i);
            }
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 17900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

int n,m,l;
vector<ll> k,s;

ll cost(int a, int b){
    return (s[k[b]]-s[k[a]-1])/l;
}

const int N = 2002;
ll dp[N][N];
ll dfs(int x, int y){
    if(dp[x][y]>=0) return dp[x][y];

    int nx = max(x,y)+1;
    if(nx == n){
        return cost(min(x,y), max(x,y));
    }

    ll ret = min(dfs(nx,y)+cost(x,nx), dfs(x,nx)+cost(y,nx));
    return dp[x][y] = ret;
}

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

    k = vector<ll>(n);
    s = vector<ll>(m+1);
    rep(i,n) cin >>k[i];
    sort(all(k));

    rep(i,m) cin >>s[i+1];
    for(int i=1; i<=m; ++i) s[i] += s[i-1];

    memset(dp,-1,sizeof(dp));
    cout << dfs(0,0) << endl;
    return 0;
}



Measured memory_bytes: 35052
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

double dp[301][301][301];

double solve(int x, int y, int z, int& n)
{
  if(x < 0 or y < 0 or z < 0)
     return 0;
  if (x == 0 and y == 0 and z == 0)
    return 0;
  if (dp[x][y][z] > -0.9)
    return dp[x][y][z];
  double ans = n + x * solve(x - 1, y, z, n) + y * solve(x + 1, y - 1, z, n) + z * solve(x, y + 1, z - 1, n);
  return dp[x][y][z] = ans / (x + y + z);
}

int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;

  for (int i9 = 1; i9 <= t; i9++)
  {
    int n;
    cin >> n;
    int a[n];
    memset(dp, -1, sizeof(dp));
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 1)
        one++;
      else if (a[i] == 2)
        two++;
      else
        three++;
    }
    cout << fixed << setprecision(9) << solve(one, two, three, n);
  }
}



Measured memory_bytes: 216908
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
x, y, z, kk = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


ll = []
count = 0
for i in range(len(a)):
    for j in range(len(b)):
        if i * j > kk:

            break
        for k in range(len(c)):
            if i * j * k > kk:
                break
            ll.append(a[i] + b[j] + c[k])
ll.sort(reverse=True)

for i in range(kk):
    print(ll[i])

# 空白区切り文字列
# t, d = input().split()


Measured memory_bytes: 113504
N = io.read("*n")

N = -N
nb = {}
i = 1
while true do
  nb[i] = N % 2
  N = N // -2
  i = i + 1
  if N == 0 then
    break
  end
end

for v = #nb, 1, -1 do
  io.write(nb[v])
end
print()


Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std ; 
int max(int a,int b){
	if(a>b)return a;
	return b;
}
int main(){
	char c= '\0';  
	int n =0; 
	int ans=0;
	for( int i=0;i< 3;i++){
		cin>>c;
		if(c=='R'){
			n++;
		}
		else {
			ans = max(ans,n);
			n=0;

		}
	}  
	ans =max(ans,n);
	cout<< ans;
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(){
    int i=0, j=0;
    int a, b, c, k;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    while(a>=b){
        b *= 2;
        i++;
    }
    while(b>=c){
        c *= 2;
        j++;
    }
    if(k>=i+j){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

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

#define ll long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define F first
#define S second

int N, M;
vector<int> graph[100009];
ll longest_path[100009], visited[100009];

void dfs(int u) {
	visited[u] = 1;

	for (auto a : graph[u]) {
		if (!visited[a])
			dfs(a);
		longest_path[u] = max(longest_path[u], 1 + longest_path[a]);
	}
}

void solve() {
	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		int u, v;
		cin >> u >> v;
		graph[u].push_back(v);
	}

	memset(longest_path, 0, sizeof(longest_path));
	memset(visited, 0, sizeof(visited));

	for (int i = 1; i <= N; i++) {
		if (!visited[i]) {
			dfs(i);
		}
	}
	ll ans = 0;

	for (int i = 1; i <= N; i++) {
		ans = max(ans, longest_path[i]);
	}

	cout << ans << endl;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("manish.txt", "r", stdin);
	//freopen("ps.txt", "w", stdout);
#endif
	int t; t = 1;

	while (t--) {
		solve();
	}
	return 0;
}

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

#define MOD 1000000007

long long inv_mod(long long x, long long mod)
{
    long long y = mod;
    long long u = 1;
    long long v = 0;
    while (y)
    {
        long long t = x / y;
        x -= t * y;
        swap(x, y);
        u -= t * v;
        swap(u, v);
    }
    u %= mod;
    if (u < 0)
        u += mod;
    return u;
}
long long mul_mod(long long x, long long y, long long mod)
{
    return (x * y) % mod;
}

long long div_mod(long long x, long long y, long long mod)
{
    return mul_mod(x, inv_mod(y, mod), mod);
}

long long calcCombination(long long x, long long y, long long mod)
{
    if (x < y)
    {
        return 0;
    }

    if ((x - y) < y)
    {
        y = x - y;
    }

    long long ans = 1;
    for (long long i = 1; i <= y; i++)
    {
        ans = mul_mod(ans, x, mod);
        ans = div_mod(ans, i, mod);
        x--;
    }
    return ans;
}

long long f(long long n, long long k, long long mod)
{
    return calcCombination(n + k - 1, k, mod);
}

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

    int B = K;
    int R = N - K;

    for (int i = 1; i <= K; i++)
    {
        int remainB = B - i;
        int remainR = R - (i - 1);
        int positionB = i;
        int positionR = 2 + (i - 1);
        long long ans = mul_mod(f(remainB + 1, positionB - 1, MOD), f(remainR + 1, positionR - 1, MOD), MOD);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, x[8], y[8];

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i]; }
	
	vector<int> p(n);
	inc(i, n) { p[i] = i; }
	double sum = 0, c = 0;
	do {
		inc(i, n - 1) { sum += hypot(x[p[i]] - x[p[i + 1]], y[p[i]] - y[p[i + 1]]); }
		c++;
	} while(next_permutation(ALL(p)));
	
	printf("%.9f\n", sum / c);
	
	return 0;
}


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

int main()
{
	string S, T;
	int N;
	bool flag = true;
	cin >> S >> T;
	N = S.size();

	for ( char ch = 'a'; ch <= 'z'; ch++ ) {
		char c = 'N';
		int cnt = 0;
		for ( int i = 0; i < N; i++ ) {
			if ( ch == S[i] ) {
				if ( c != T[i] ) {
					c = T[i];
					cnt++;
				}
			}
		}
		if ( cnt >= 2 ) flag = false;
		c = 'N', cnt = 0;
		for ( int i = 0; i < N; i++ ) {
			if ( ch == T[i] ) {
				if ( c != S[i] ) {
					c = S[i];
					cnt++;
				}
			}
		}
		if ( cnt >= 2 ) flag = false;
	}

	if ( flag ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return ( 0 );
}


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

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

	std :: string code ;
	std :: cin >> code ;

	if ( ( int ) code.size ( ) != a + b + 1 )  return puts ( "No" ), 0 ;

	for ( int i = 0 ; i < a ; ++ i )
		if ( ! isdigit ( code [i] ) )  {
			return puts ( "No" ), 0 ;
		}

	if ( code [a] != '-' )  return puts ( "No" ), 0 ;

	for ( int i = a + 1 ; code [i] ; ++ i )
		if ( ! isdigit ( code [i] ) )  {
			return puts ( "No" ), 0 ;
		}

	return puts ( "Yes" ), 0 ;
}


Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

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

	a, b := scanInt(), scanInt()

	if a>b*2 {
		fmt.Println(a-b*2)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	// your code goes here
	int n,x,sum = 0;
	scanf("%d",&n);
	scanf("%d",&x);
	int L[n-1];
	int j=0;
	for(int i =0;i<n;i++){
		scanf("%d",&L[i]);
		if(x>0&&n>0){
		sum += L[i];	
		if(sum<=x){
		
		
		j += 1;
		}
		}
		
	}
	printf("%d",j+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, q;
    priority_queue<int> Q[1010];
    cin >> n >> q;
    for(int i=0; i<q; i++){
        int a, t, x;
        cin >> a;
        if(a==0){
            cin >> t >> x;
            Q[t].push(x);
        }
        else if(a==1){
            cin >> t;
            if(Q[t].size()>0)
                cout << Q[t].top() << "\n";
        }
        else {
            cin >> t;
            if(Q[t].size()>0)
                Q[t].pop();
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 4016
n=input()
k=int(input())
dp=[[[0]*(k+2) for _ in range(2)] for _ in range(len(n)+1)]
dp[0][0][0]=1
for i,c in enumerate(n):
  c=int(c)
  for j in range(2):
    for l in range(k+1):
      for nxt in range(10*j or c+1):
        dp[i+1][j or nxt<c][l+(nxt>0)]+=dp[i][j][l]
print(dp[-1][1][k]+dp[-1][0][k])

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

int main() {
  int m[10000], f[10000], r[10000];
  int n = 0;
  for (;;n++) {
    cin >> m[n] >> f[n] >> r[n];
    if (m[n] == -1 && f[n] == -1 && r[n] == -1) {
      break;
    }
  }

  for ( int i = 0; i < n; i++) {
    if (m[i] == -1 || f[i] == -1) {
      cout << "F" << endl;
    } else if(m[i] + f[i] >= 80) {
      cout << "A" << endl;
    } else if(m[i] + f[i] >= 65){
      cout << "B" << endl;
    } else if(m[i] + f[i] >= 50){
      cout << "C" << endl;
    } else if(m[i] + f[i] >= 30 && r[i] >= 50) {
      cout << "C" << endl;
    } else if(m[i] + f[i] >= 30) {
      cout << "D" << endl;
    } else {
      cout << "F" << endl;
    }
  }
  
  //  for (int i = 0; i < n; i++) {
  //  cout << m[i] << f[i] << r[i] << endl;
  //}

  return 0;
}



Measured memory_bytes: 3076
N = int(input())

AnStr = input().split(' ')
zyosiList = []
a = {}
for v in AnStr:
  zyosiList.append(int(v))
  if v in a:
    a[v] += 1
  else:
    a[v] = 0

for i in range(1, N + 1):
  if str(i) in a:
    print(a[str(i)]+1)
  else:
    print(0)

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

int main() {

    string s;

    cin >> s;

    vector<int> ans(s.size(), 0);

    int Rcount = 0;
    int Lcount = 0;

    int i_R = 0;
    int i_L = 0;

    while(1) {

        Rcount = 0;
        Lcount = 0;


        while(s[i_R] == 'R') {
            Rcount++;
            i_R++;
        }

        i_L = i_R;
        i_R--;

        while(s[i_L] == 'L') {
            Lcount++;
            i_L++;
        }
        
        // cout << i_R << " " << i_R + 1 << endl;

        ans[i_R] += (Rcount / 2) + Rcount % 2 + Lcount / 2;
        ans[i_R + 1] += Rcount / 2 + (Lcount / 2) + Lcount % 2;

        if(i_L == s.size())
            break;

        i_R = i_L;

    }

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

    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<string>s(n);
    rep(i,n) {
        cin>>s[i];
        sort(rng(s[i]));
    }
    sort(rng(s));
    ll ans = 0;
    ll cnt = 1;
    rep(i,n) {
        if(s[i]!=s[i+1]) {
            ans += cnt*(cnt-1)/2;
            cnt = 1;
            continue;
        }
        cnt++;
    }
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 6328
#include<iostream>
#include <algorithm>
#include<queue>
#include<cmath>
#include<math.h>
using namespace std;


int k, n;
long long a[1000006];
int main() 
{
	cin >> k >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	long long ans = 1e18;
	for (int i = 1; i <= n; i++)
	{
		ans = min(ans, a[i] - a[1] + min(a[n] - a[1], k - (a[n] - a[1]) + a[n] - a[i + 1]));
		ans = min(ans, a[n] - a[i] + min(a[n] - a[1], k - (a[n] - a[1]) + a[i - 1] - a[1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace aoj_ALDS1_1_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int numberCount = int.Parse(Console.ReadLine());
			int[] numberArray = new int[numberCount];
			numberArray = Console.ReadLine().Split(' ').Select(d => int.Parse(d)).ToArray();

			Console.WriteLine(String.Join(" ", numberArray));
            for (int i = 1; i < numberCount; i++)
			{
				int target = numberArray[i];
				//if (numberArray[i - 1] <= target) continue;

				int j = 0;
				for (; j < numberCount - 1;)
				{
					if (i < j + 1) break;
					if (numberArray[i - (j + 1)] <= target) break;

					numberArray[i - j] = numberArray[i - (j + 1)];
					j++;
				}

                if (j > 0)
				{
					numberArray[i - j] = target;
				}

				Console.WriteLine(String.Join(" ", numberArray));
			}
        }
    }
}



Measured memory_bytes: 8784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, k;
int a[100001];
int dp[50][2];
signed main() {
    cin >> n >> k;
    for (int i=0;i<n;i++) cin >> a[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    for (int i=0;i<50;i++) {
        int mask = 1LL<<(50-1-i);       // 2の累乗  
        int num = 0;
        for (int j=0;j<n;j++) if (a[j] & mask) num++;
        int score0 = mask * num;        // Xを0にした時
        int score1 = mask * (n-num);    // Xを1にした時

        // 1 to 1
        if (dp[i][1] != -1) {
            dp[i+1][1] = max(dp[i+1][1], dp[i][1]+max(score1, score0));
        }
        // 0 to 1,0
        if (dp[i][0] != -1) {
            if (k & mask) {
                dp[i+1][1] = max(dp[i+1][1], dp[i][0]+score0);
                dp[i+1][0] = max(dp[i+1][0], dp[i][0]+score1);
            }
             else dp[i+1][0] = max(dp[i+1][0], dp[i][0]+score0);
        }
    }
    cout << max(dp[50][0], dp[50][1]) << endl;
}

// dp[i] = 上からi桁定めた時のfの最大値
// dp[i][is_smaller] = is_smallerはi桁目までがKと一致するか否か
// (1,0) to (1,0) で考える
// 桁DP

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d", $N);
$dp = array_fill(0, $N+1, 0);
for($i = 0; $i < $N; $i++){
    $a = intval(fgets(STDIN));
    $dp[$a] = $dp[$a-1]+1;
}
echo $N-max($dp),"\n";


Measured memory_bytes: 13048
#include <stdio.h>

int main(void) {
  int S, h, a, m, s;
  
  scanf("%d", &S);
  
  h=S/3600;
  a=S%3600;
  m=a/60;
  s=a%60;
  
  printf("%d:%d:%d\n", h, m, s);
  
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    vector<int> A;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    vector<bool> divisible(A[N-1] + 1,true);
    int n = 0;
    for (int i = 0; i < N; i++) {
        if (n == A[i]) continue;
        n = A[i];
        if (i < N-1 && A[i] == A[i+1]) {
            divisible[A[i]] = false;
        }
        for (int j = n+n; j < divisible.size(); j += n) {
            divisible[j] = false;
        }
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (divisible[A[i]]) sum +=1;
    }
    cout << sum;
}


Measured memory_bytes: 4268
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int i;
    cin>>n;
    double x,sum=0.0;
    rep(i,n)
    {
    	cin>>x;
    	sum+=(1/x);
    }
    printf("%.14lf\n",1/sum);

    return 0;
}


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

int main()
{
  long long H,N;
  cin>>H>>N;
  long long k, sum=0;
  for(long long i=0; i<N; i++)
  {
    cin>>k;
    sum+=k;
  }
  if(sum>=H)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		System.out.println(Math.min(a, b) + Math.min(c, d));
	}

}

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

char letter(int n) {return 'a' + n;}

set<string> memo;

void dfs(string s, int step) {
    if(step == 0) {
        memo.insert(s);
        return;
    }

    if(s.find(letter(step)) == string::npos) dfs(s, step - 1);

    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == letter(step)) break;
        if(s[i] != letter(step - 1)) continue;
        s[i] = letter(step);
        dfs(s, step - 1);
        s[i] = letter(step - 1);
    }
}

int main() {
    string s;
    while(cin >> s, s != "#") {
        memo.clear();
        dfs(s, 25);
        cout << memo.size() << endl;
        if(memo.size() < 10) {
            for(const auto& a: memo) cout << a << endl;
        } else {
            vector<string> answer;
            auto it = memo.begin();
            auto rit = memo.rbegin();
            for(int i = 0; i < 5; ++i) answer.push_back(*it++);
            for(int i = 0; i < 5; ++i) answer.push_back(*rit++);
            sort(answer.begin(), answer.end());
            for(const auto& a: answer) cout << a << endl;
        }
    }
}

Measured memory_bytes: 3140