akhauriyash/Code-Regression huggingface dataset:
import math

a,b = tuple(map(int,input().split(" ")))
if a>0:
    print("Positive")
elif a<0 and b>0:
    print("Zero")
elif a%2==0 and b%2==0 or a%2==1 and b%2==1:
    print("Negative")
else:
    print("Positive")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B;
	string S;
	cin>>A>>B>>S;
	static int sum=0;
	if(S[A]=='-')
	{
		for(int i=0;i<S.size();i++)
		{
			if(i!=A&&isdigit(S[i]))
			{
				
				sum++;
			}
		}
		if(sum==A+B)
		cout<<"Yes";
		else cout<<"No";
	}
	else cout<<"No";
	return 0;
}

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

typedef long long ll;
const int MAXN=1e7+5;

int n,ans;
int deq[MAXN],l,r;
char s[MAXN],t[MAXN];

int main(){

    scanf("%d%s%s",&n,s+1,t+1);
    if(strcmp(s+1,t+1)==0) return puts("0"),0;
    l=1,r=0;
    for(int i=n,j=n;i>=1;i--){
        if(t[i]==t[i-1]) continue;
        j=min(i,j);
        while(j&&t[i]!=s[j]) j--;
        if(!j) return puts("-1"),0;
        while(l<=r){
            if(deq[l]-(r-l)>i) l++;
            else break;
        }
        deq[++r]=j;
        if(i!=j) ans=max(ans,r-l+1);
    }
    printf("%d",ans+1);

    fclose(stdin);
    fclose(stdout);
}


Measured memory_bytes: 11392
'use strict'
function Main(input){
  var M=Math.pow(2,50);
  const K=998244353;
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var sum=input.reduce((a,c)=>a+c);
  var half=Math.floor(sum/2);
  
  var dp=[];
  //dp[i][j]でinput[0~i]のうち任意個のg,bを使って合計をjにする場合の数
  for(let i=0;i<=N;i++){
    dp[i]=[];
    for(let j=0;j<=half;j++){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(let i=0;i<N;i++){
    for(let j=0;j<=half;j++){
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=K;
      if(j+input[i]<=half){
        dp[i+1][j+input[i]]+=2*dp[i][j];
        dp[i+1][j+input[i]]%=K;
      }
    }
  }
  
  var ans=1;
  for(let i=0;i<N;i++){
    ans*=3;
    ans%=K;
  }
  dp[N].forEach(function(x,i,arr){
    ans-=3*x;
  });
  
  var DP=[];
  //DP[i][j]でinput[0~i]のうち任意個のgを使って合計をjにする場合の数
  for(let i=0;i<=N;i++){
    DP[i]=[];
    for(let j=0;j<=half;j++){
      DP[i][j]=0;
    }
  }
  DP[0][0]=1;
  for(let i=0;i<N;i++){
    for(let j=0;j<=half;j++){
      DP[i+1][j]+=DP[i][j];
      DP[i+1][j]%=K;
      if(j+input[i]<=half){
        DP[i+1][j+input[i]]+=DP[i][j];
        DP[i+1][j+input[i]]%=K;
      }
    }
  }
  
  if(sum%2===0){
    ans+=3*DP[N][half];
    ans%=K;
  }
  ans%=K;
  ans+=K;
  ans%=K;
  console.log(ans);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));


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

using namespace std;

int main() {
    int n;
    cin>>n;
    double p[n];
    for (int i = 0; i < n; i++) cin>>p[i];
    double d[n+1][n+1];
    d[0][0] = 1;
    for (int i = 1; i <= n; i++) d[0][i] = 0;
    for (int i = 1; i <= n; i++) d[i][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            double ph = p[i-1];
            double pt = 1 - ph;
                d[i][j] = (ph*d[i-1][j-1] + pt*d[i-1][j]);
        }
    }
    printf("%.10f", d[n][n/2+1]);
    return 0;
}


Measured memory_bytes: 70272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int MOD = 100000007;
const int MAXN = 1000000;
const int inf = 0x3f3f3f3f;
ll book[100005];
int n;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &book[i]);
	}
	ll sum = 0, Min = 0xffffffff, t = 0;
	int fo = 0;
	for (int i = 0; i < n; i++)
	{
		sum += abs(book[i]);
		if (book[i] == 0) fo = 1;
		if (book[i] < 0) t++;
		if (Min > abs(book[i])) Min = abs(book[i]);
	}
	if (fo == 1 || t % 2 == 0) printf("%lld\n", sum );
	else
	{
		sum -= 2 * Min;
		printf("%lld\n", sum );
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double s=0;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		double t;
		scanf("%lf",&t);
		char tmp[4];
		scanf("%s",tmp);
		if(strcmp(tmp,"JPY")!=0)
			s+=t*380000;
		else
			s+=t;
	}
	printf("%g",s);
	return 0;
}

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

int main(){
  int n;
  cin>>n;
	int a[100]={};
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      a[i*j]=1;
    }
  }
  if(a[n]==1)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
//Coded by tzc_wk
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
忘文件操作，爆零两行泪。
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
signed main(){
	int s=read(),w=read();
	if(w>=s)	puts("unsafe");
	else		puts("safe");
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  VI XX(N),YY(M);
  rep(i,N) cin>>XX[i];
  rep(i,M) cin>>YY[i];
  XX.push_back(X);
  YY.push_back(Y);
  sort(all(XX));
  sort(all(YY));
  if(XX[N]<YY[0]) cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int count[10], n, i, j, x, y, max, min;
    char ch;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        for (j = 0; j < 10; j++) count[j] = 0;
        max = 0; min = 0;
        x = 10000000; y = 1;
        for (j = 0; j <= 8; j++){
            scanf("%c", &ch);
            count[ch - '0']++;
        }
        for(j = 9; j >= 0;){
            if(count[j]){
                max += j * x;
                min += j * y;
                x /= 10;
                y *= 10;
                count[j]--;
            }
            else{
                j--;
            }
        }
        printf("%d\n", max - min);
    }
    return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

enum class Type { N, S, P };

struct D {
    vector<D> children;
    Type type = Type::N;
    int value = -1;
    int level = -1;
};

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }

        vector<string> vs;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            vs.push_back(s);
        }

        auto parse = [](const string& s) {
            int i = 0;
            while (s[i] == '.') {
                ++i;
            }
            if (s[i] == '+') {
                return D{{}, Type::S, -1, i};
            }
            else if (s[i] == '*') {
                return D{{}, Type::P, -1, i};
            }
            else {
                return D{{}, Type::N, stoi(s.substr(i)), i};
            }
        };

        unordered_map<int, vector<D>> mm;
        for (int i = vs.size() - 1; i >= 0; --i) {
            auto x = parse(vs[i]);
            if (x.type == Type::N) {
                mm[x.level].push_back(x);
            }
            else {
                x.children = mm[x.level + 1];
                mm.erase(x.level + 1);
                mm[x.level].push_back(x);
            }
        }

        function<int(const D&)> eval = [&eval](const D& d) {
            if (d.type == Type::N) {
                return d.value;
            }
            else if (d.type == Type::S) {
                return accumulate(begin(d.children), end(d.children), 0,
                                  [&eval](int a, const D& b) {
                                      return a + eval(b);
                                  });
            }
            else {
                return accumulate(begin(d.children), end(d.children), 1,
                                  [&eval](int a, const D& b) {
                                      return a * eval(b);
                                  });
            }
        };

        cout << eval(mm[0][0]) << endl;
    }
}

Measured memory_bytes: 3168
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe";
    else cout << "safe";
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;

int main(){
    int n;
    cin >> n;
    if (n<3) {
        cout << n%2 + 1 << endl;
    }else{
        cout << 0 <<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=100+5;
char a[maxn][maxn];
int dp[maxn][maxn];
int main()
{
    int m,n;
    cin >> m >> n;
    memset(a,0,sizeof(a));
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=m;i++)
        scanf("%s",a[i]+1);
    dp[1][1]=(a[1][1]=='#');
    for(int i=2;i<=n;i++){
        if(a[1][i]=='.')
            dp[1][i]=dp[1][i-1];
        else
            dp[1][i]=dp[1][i-1]+(a[1][i-1]=='.');
        if(a[i][1]=='.')
            dp[i][1]=dp[i-1][1];
        else
            dp[i][1]=dp[i-1][1]+(a[i-1][1]=='.');
    }
    for(int k=2;k<=m;k++){
        for(int l=2;l<=n;l++){
            if(a[k][l]=='.')
                dp[k][l]=min(dp[k-1][l],dp[k][l-1]);
            else
                dp[k][l]=min(dp[k-1][l]+(a[k-1][l]=='.'),dp[k][l-1]+(a[k][l-1]=='.'));
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int H = int.Parse(s[0]);
            int W = int.Parse(s[1]);

            int[,] g = new int[W + 2, H + 2];

            for (int h = 0; h < H; h++)
            {
                string s2 = Console.ReadLine();

                for (int w = 0; w < W; w++)
                {
                    if (s2[w] == '#')
                    {
                        g[w + 1, h + 1] = 1;
                    }
                }
            }

            for (int h = 1; h < H + 1; h++)
            {
                for (int w = 1; w < W + 1; w++)
                {
                    if (g[w,h] == 1)
                    {
                        if (g[w - 1, h] == 0 &&
                            g[w + 1, h] == 0 &&
                            g[w, h - 1] == 0 &&
                            g[w, h + 1] == 0 )
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 11072
n, m = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
a.sort()
pm = s = 0
m_minus_1 = m - 1
for item in a:
    tmp = pm + item[1]
    if tmp > m_minus_1:
        print(s + item[0] * (m - pm))
        break
    else:
        pm = tmp
        s += item[0] * item[1]


Measured memory_bytes: 27884
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int ans[30] = { 0 };
int main() {
	int n, m, k, a[30][30], ans1 = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> a[i][j];
			ans[a[i][j]-1]++;
		}
	}
	for (int k = 0; k < m; k++) {
		if (ans[k] == n) {
			ans1++;
		}
	}
	cout << ans1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    std::set<int> a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if (a.find(temp) == a.end()) {
            a.insert(temp);
        } else {
            a.erase(temp);
        }
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 4992
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: i64 = s.next().unwrap().parse().unwrap();
	let s: i64 = s.next().unwrap().parse().unwrap();

	let ans = calc(n, s);
	println!("{}", ans);
}

fn calc(n: i64, s: i64) -> i64 {
	use num::integer::Roots;
	let sqrtn = n.sqrt();
	for b in 2..=sqrtn {
		let ds = f(b, n);
		if ds == s {
			return b;
		}
	}

	if n > s {
		for d in divisors(n - s) {
			let b = d + 1;
			let p = (n - s) / d;
			if b > sqrtn && p < b {
				let ds = p + n % b;
				if ds == s {
					return b;
				}
			}
		}
	}
	if n == s {
		return n + 1;
	}

	-1
}

fn f(b: i64, mut n: i64) -> i64 {
	let mut r = 0;
	while n > 0 {
		r += n % b;
		n /= b;
	}
	r
}

pub fn divisors<T>(n: T) -> impl std::iter::Iterator<Item = T>
where
	T: num::PrimInt,
{
	let n = if n < T::zero() { T::zero() - n } else { n };
	let mut d = T::one();
	let mut divs = vec![];
	std::iter::from_fn(move || {
		while d * d <= n {
			if n % d == T::zero() {
				let r = d;
				if d != n / d {
					divs.push(n / d);
				}
				d = d + T::one();
				return Some(r);
			}
			d = d + T::one();
		}

		divs.pop()
	})
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;


int main() {
  ll r, d, x;
  cin >> r >> d >> x;
  rep(i,10) {
    x = x*r -d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

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

	unsigned long long L[N];

	L[0] = 2;
	L[1] = 1;
	if(N == 1){
		printf("%d\n",L[N]);
	}

	else{
		for(int i=2; i<=N; i++){
			L[i] = L[i-1] +L[i-2];
			// printf("L[%d] = %ld\n",i,L[i]);
		}
		printf("%ld\n",L[N]);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b > c+d){
    cout<<"Left"<<endl;
  }else if(a+b < c+d){
    cout<<"Right"<<endl;
  }else{
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define MIN(x,y) ((x)<(y)?(x) : (y))
#define MAX(x,y) ((x)>(y)?(x) : (y))
#define PI 3.1415926535
#include <set>
#define E 2.718281828459
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=1e9;

const int maxn=1e6+5;

const ll mod=10000007;
const double eps=1e-10;
ll n,m,k;
char str[maxn];
int main()
{
    ll cnt1=0,cnt2=0;
    scanf("%lld%s",&n,str+1);
    for(int i=1;i<=n;i++)
        if(str[i]=='B') cnt1++;
        else cnt2++;
    if(cnt2>cnt1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
def YYMM(sub):
    if 1 <= sub <= 12:
        return True
    else:
        return False

def MMYY(up):
    if 1 <= up <= 12:
        return True
    else:
        return False

if __name__ == '__main__':
    S = input()
    up = int(''.join([S[0],S[1]]))
    sub = int(''.join([S[2],S[3]]))
    a = [YYMM(sub),MMYY(up)]
    if a[0] == a[1]:
        if a[0] == True and a[1] == True:
            ans = 'AMBIGUOUS'
        else:
            ans = 'NA'
    else:
        if a[0] == True:
            ans = 'YYMM'
        else:
            ans = 'MMYY'

    print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int a,b,k; cin >> a >> b >> k;
  if((b-a+1)/2<k){for(int i=a;i<b+1;i++) cout<<i<<endl;}
  else{
    for(int i=0;i<k;i++) cout<<a+i<<endl;
    for(int i=k-1;0<=i;i--) cout<<b-i<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int N,ans,i,ansa;
    scanf("%lld",&N);
    ans=1;
    for(i=0;i<N;i++){
        ans=(ans*10)%1000000007;
    }
    ansa=1;
    for(i=0;i<N;i++){
        ansa=(ansa*9)%1000000007;
    }
    ans=(ans-ansa-ansa)%1000000007;
    ansa=1;
    for(i=0;i<N;i++){
        ansa=(ansa*8)%1000000007;
    }
    ans=(ans+ansa)%1000000007;
  
    while(ans<0){
      ans=ans+1000000007;
    }
  
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
const int maxn=2e5+5;
int a[maxn];
int n;
int dp[maxn][2];
int sum[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		dp[i][0]=(dp[i-1][0]+dp[i-1][1])%MOD;
		if(a[i]!=a[i-1]){
			dp[i][1]=sum[a[i]];
			sum[a[i]]=(sum[a[i]]+dp[i][0])%MOD; 
		}
	}
	printf("%d\n",(dp[n][0]+dp[n][1])%MOD);
	return 0;
}

Measured memory_bytes: 3456
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, k = getList()

s = input().strip()
s = s

state = "X"
cur_seq = 0
seq_nums = []
n_separate = 0


for c in s:
    # print(c, state == c)
    if state == c:
        cur_seq += 1
    else:
        state = c
        seq_nums.append(cur_seq)
        cur_seq = 1
        n_separate += 1


# print(n_separate)
print(min(n - n_separate + 2 * k, n - 1))



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

int main() {
  int N;
  cin >> N;
  vector<int>A(N+1);
  vector<int>B(N);
  for(int i=0; i<N+1; i++)cin >> A.at(i);
  for(int i=0; i<N; i++)cin >> B.at(i);
  
  int64_t ans=0;
  int m;
  for(int i=N-1; i>=0; i--){
    m = min(A.at(i+1), B.at(i));
    ans += m;
    B.at(i) -= m;
    
    m= min(A.at(i), B.at(i));
    ans += m;
    A.at(i) -=m;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3944
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=1e5+5;

ll sum;
int a[N],n;

int gcd(int x,int y) {return y?gcd(y,x%y):x;}

bool dfs() {
	sum=0;
	fo(i,1,n) sum+=a[i];
	if (!(sum&1)) {
		if (n&1) return 1;
		else return 0;
	}
	if (!(n&1)) return 1;
	int cnt=0,id=0;
	fo(i,1,n) if ((a[i]&1)&&a[i]!=1) cnt++,id=i;
	if (cnt!=1) return 0;
	a[id]--;int g=a[1];
	fo(i,2,n) g=gcd(g,a[i]);
	fo(i,1,n) a[i]/=g;
	return dfs()^1;
}

int main() {
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	if (!(sum&1)) {
		if (n&1) puts("First");
		else puts("Second");
		return 0; 
	}
	if (!(n&1)) {puts("First");return 0;}
	bool ok=dfs();
	if (ok) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  ll cum[200001] = {};
  cum[0] = 0;
  FOR(i, 1, n + 1)
  {
    int a;
    cin >> a;
    cum[i] = cum[i - 1] + a;
  }

  sort(cum, cum + n + 1);

  ll ans = 0;
  ll count = 1;
  REP(i, n)
  {
    if (cum[i] == cum[i + 1])
    {
      count++;
    }
    else
    {
      ans += count * (count - 1) / 2;
      count = 1;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 1792
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nums = inputs.head.split(" ").map(_.toInt)
  val w = nums(0)
  val a = nums(1)
  val b = nums(2)

  println(solve(w, a, b))

  private def solve(w: Int, a: Int, b: Int): Long = {
    val diff = Math.abs(a - b)
    if (w < diff) {
      return diff - w
    } else {
      0
    }
  }
}

Measured memory_bytes: 54844
n, k, q = map(int, input().split())

cnt = [0] * n
ans = []
for i in range(q):
    x = int(input())
    cnt[x - 1] += 1

for i in range(n):
    ans.append(k - q + cnt[i])

for i in range(n):
    if ans[i] <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 8644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

const ll M = 1e9 + 7;

vector<ll> fac(300001);   // n!(mod M)
vector<ll> ifac(300001);  // k!^{M-2} (mod M)
// a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n) {  // x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0) {
        if(n & 1) ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b) {  // aCbをmod計算
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

int main() {
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i < 300000; i++) {
        fac[i + 1] = fac[i] * (i + 1) % M;               // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;  // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll n, k;
    cin >> n >> k;
    ll N = min(k, n - 1), ans = 0;
    for(ll i = 0; i <= N; i++) {
        ans += (comb(n - 1, i) * comb(n, i)) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4992
package main

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

const Inf = 1 << 60

func main() {
	L, R := ReadInt(), ReadInt()
	min := Inf
	for i := L; i <= R-1 && i <= L+2019; i++ {
		for j := L + 1; j <= R && j <= L+1+2019; j++ {
			if min > i*j%2019 {
				min = i * j % 2019
			}
		}
	}
	fmt.Println(min)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1868
n = int(input())
s = []
for i in range(n):
    i = input()
    s.append(i)

AC_cnt = s.count('AC')
WA_cnt = s.count('WA')
TLE_cnt = s.count('TLE')
RE_cnt = s.count('RE')

print('AC x', AC_cnt)
print('WA x', WA_cnt)
print('TLE x', TLE_cnt)
print('RE x', RE_cnt)

Measured memory_bytes: 16088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int a, b;
	ll ans = 0;
	cin >> a >> b;
	if (b == 1)cout << 0 << endl;
	else {
		for (int i = 1;; i++) {
			ll x;
			if (i == 1)  x = a;

			else  x = a + (i - 1) * (a - 1);

			if (x >= b) {
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
		return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = 10 ** 9

for c in range(max(X, Y)+1):
    a = max(X - c, 0)
    b = max(Y - c, 0)

    cost = A * a + B * b + C * 2 * c
    ans = min(cost, ans)

print(ans)

Measured memory_bytes: 9012
import java.io.*;

class Main{
	
	public static void main(String[] args)throws IOException{
		
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder result = new StringBuilder();
		
		while(true){
			String tmp = input.readLine();
			String[] strInput = tmp.split(" ");
			int x = Integer.parseInt(strInput[0]);
			int y = Integer.parseInt(strInput[1]);
			
			if(x == 0 && y == 0){
				break;
			}
			
			if(x > y){
			    int temp = x;
			    x = y;
			    y = temp;
			   
			}

			result.append(x + " " + y + "\n");
		}
	       
		System.out.print(result);
		
	}
	
}

Measured memory_bytes: 25104
#include <cstdio>
#include <cstring>
#include <utility>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
int n,m;
P par[100001];
P operator +(P p1,P p2){
	return P(p1.first+p2.first,p1.second+p2.second);
}
int rank[100001];

void init(){
	for(int i=1;i<=n;i++){
		par[i]=P(i,0);
		rank[i]=0;
	}
}

P find(int x){
	if(par[x].first==x)return par[x];
	return par[x]=(find(par[x].first)+P(0,par[x].second));
}

bool same(int a,int b){
	return find(a).first==find(b).first;
}

void unite(int a,int b,int w){
	P da=find(a);
	P db=find(b);
	a=da.first;
	b=db.first;
	ll aa=da.second,bb=db.second;
	if(rank[a]<rank[b]){
		par[a]=P(b,-w-aa+bb);
	}else{
		par[b]=P(a,w-bb+aa);
		if(rank[a]==rank[b])rank[a]++;
	}
}

int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		init();
		for(int i=0;i<m;i++){
			string q;
			cin >> q;
			int a,b,w;
			if(q=="!"){
				scanf("%d %d %d",&a,&b,&w);
				unite(a,b,w);
			}else if(q=="?"){
				scanf("%d %d",&a,&b);
				if(!same(a,b))printf("UNKNOWN\n");
				else printf("%lld\n",par[b].second-par[a].second);
			}
		}
	}
	return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


inline li calc(li x) {
    li res = 0;
    li xx = x;
    repp(i, 1, xx + 1) {
        if (x < i) {
            break;
        }
        res++;
        x -= i;
    }
    return res;
}

int main() {
    li n;
    cin >> n;
    li res = 0;
    li nn = n;
    repp(i, 2, min(nn, 1000002ll)) {
        li cnt = 0;
        while (n % i == 0) {
            n = n / i;
            cnt++;
        }
        res += calc(cnt);
    }
    if (n > 1)res++;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"

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

	var cnt int
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		if h >= k {
			cnt++
		}
	}
	fmt.Println(cnt)

}


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

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  ll n;
  cin >> n;
  ll b[n];
  REP(i, n - 1) { cin >> b[i]; }
  ll ans = b[0];
  FOR(i, 1, n - 1) {
    ans += min(b[i - 1], b[i]);
  }
  ans += b[n - 2];
  PRINT(ans);

  return;
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    //解説あり
    int Q;
    cin >> Q;
    rep(i, 0, Q) {
        ll A, B;
        cin >> A >> B;
        ll X = A*B;
        if (A>B) swap(A, B);

        ll l = 0, r = A+B-1;
        while (r-l>1) {
            ll m = (r+l)/2;
            ll k = m/2;
            ll mx = 0;
            if (m>=1 && m<2*(A-1)) mx = k*(m-k+1);
            else if (m<2*(B-1)) mx = (k+1)*(m-k+1);
            else mx = k*(m-k+2);

            if (mx<A*B) l = m;
            else r = m;
            
        }

       
      
        cout << l << endl;
    }

    return 0;
}





Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int res[100500];
int main() {
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    int x;
    for(int i=0;i<q;i++) {
            scanf("%d",&x);
            res[x]++;
    }
    for(int i=1;i<=n;i++) {
        if(k-(q-res[i])<=0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 1024
using System;
class aoj
{
    static void Main()
    {
        string a;
        while (true)
        {
            a= Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            char[] b = a.ToCharArray();
            string g = a;
            for (int i = 0; i < a.Length; i++)
            {
                if (b[i] == '@')
                {
                    char c = b[i + 1], d = b[i + 2];
                    int l = (int)(c - '0');
                    char[] e = new char[l];
                    for(int j = 0; j < l; j++)
                    {
                        e[j] = d;
                    }
                    string f = new string(e);
                    char[] h = { '@', c, d };
                    string u = new string(h);
                    g=g.Replace(u, f);
                }
            }
            Console.WriteLine(g);
        }
    }
}

Measured memory_bytes: 8720
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

int main() {
  int a,b;
  cin >>a>>b;
  if(a+b==15){
  	ce('+');
  }else if(a*b==15){
  	ce('*');
  }else{
  	ce('x');
  }
}

Measured memory_bytes: 256
def com(q,p):
    if q<p:
        return p
    else:
        return q

a,b,c=map(int,input().split())
k=int(input())
h=com(com(a,b),c)
if h==a:
    sum=b+c
if h==b:
    sum=c+a
if h==c:
    sum=a+b
while k>0:
    k=k-1
    h=h*2
print(sum+h)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
    int a,b;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(int i=s.size()-1;i>0;i--){
        if(s[i]=='Z'){
            b=i;
            break;
        }
    }
    cout<<b-a+1<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "complex"
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "complex"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	if (N >= 2 * M) {
		cout << 0 << endl;
		return 0;
	}
	if (2 * M > N&&N >= M) {
		cout << 2 << endl;
		return 0;
	}
	if (M >= 2 * N) {
		cout << 1 << endl;
		return 0;
	}
	long long int box = 0;
	long long int bag = 0;
	box += N;
	bag += M - (box / 2);
	box += N - max((long long int)0, bag - N);
	int ans = 100;
	if (M*2 <= box) {
		ans = min(ans,2);
	}
	else {
		bag += M - (box / 2);
		if (N*4 <= bag * 2) {
			ans = min(ans, 3);
		}
		else {
			box += N - max((long long int)0, bag - N);
			if (M*4 <= box * 2) {
				ans = min(ans, 4);
			}
			else {
				bag += M - (box / 2);
				if (N*4 <= bag * 2) {
					ans = min(ans, 5);
				}
			}
		}
	
	}
	//cout << ans << endl;
	box = 0;
	bag = 0;
	box += N;
	bag += M - max((long long int)0, box - M);
	box += N - (bag / 2);
	if (M*4 <= box * 2) {
		ans = min(ans, 2);
	}
	else {
		bag += M - max((long long int)0, box - M);
		if (N*4 <= bag * 2) {
			ans = min(ans, 3);
		}
		else {
			box += N - (bag / 2);
			if (M*4 <= box * 2) {
				ans = min(ans, 4);
			}
			else {
				bag += M - max((long long int)0, box - M);
				if (N*4 <= bag * 2) {
					ans = min(ans, 5);
				}
			}
		}

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



Measured memory_bytes: 3152
import numpy as np


def frog(h):
    c = np.full_like(h, 0)
    c[0] = 0
    c[1] = abs(h[0] - h[1])
    for i in range(2, len(c)):
        c[i] = min(c[i-1] + abs(h[i-1] - h[i]), c[i-2] + abs(h[i-2] - h[i]))
    return c[-1]
    
N = int(input())
h = np.array(list(map(int, input().split())))
print(frog(h))

Measured memory_bytes: 22664
n=int(input())
l=list(map(int,input().split()))

counter=0
for i in range(n):
    minimum=i
    for j in range(i,n):
        if l[minimum]>l[j]:
            minimum=j
    if i!=minimum:
        l[minimum],l[i]=l[i],l[minimum]
        counter+=1
print(*l)
print(counter)

Measured memory_bytes: 7652
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
using namespace std;
int main() {
    IO;
    int n; cin>>n;
    cout<<(n+1)/2;


}


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){out << q.F << " " << q.S; return out;}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F-p2.F, p1.S-p2.S};}


void solve() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    // cin >> t;
    
    for(int i = 1; i <= t; ++i){
        solve();
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 3636
# coding: utf-8
# Your code here!
# ITP1_4_C


while(True):
    x,k,y=input().split()
    x=int(x)
    y=int(y)
    if k=='?':
        break
    else:
        if k=='+':
            print(x+y)
        elif k=='-':
            print(x-y)
        elif k=='*':
            print(x*y)
        elif k=='/':
            print(int(x/y))


Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<string>


using namespace std;

int main(void)
{
	long long int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+')
	{
		cout << a + b << endl;
	}
	else if (op == '-')
	{
		cout << a - b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <cfloat>
#include <iomanip>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long ans = 0;
  for(int i = 1; i <= N; i++){
    ans += (long long) (i) * (long long) (i + 1) / 2;
  }

  for(int i = 0; i < N - 1; i++){
    int u;
    int v;
    cin >> u >> v;
    ans -= (long long) min(u, v) * (long long)(N - max(u, v) + 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //白、A個の連結成分
        //黒、B個の連結成分

        //全体を二分割してそれぞれにドットを打っていく.
        //当初の考えに近い
        char[][] res = Enumerable.Range(0, 100).Select(x => Enumerable.Repeat((x < 50 ? '#' : '.'), 100).ToArray()).ToArray();
        
        a[0]--;//まず白について
        for (int i = 0; i < 25; i++)
        {
            for (int j = 0; j < 50; j++)
            {
                if (a[0] == 0) goto end1;
                res[i * 2][j * 2] = '.';
                a[0]--;
            }
        }

        end1:;

        a[1]--;
        for (int i = 0; i < 25; i++)
        {
            for (int j = 0; j < 50; j++)
            {
                if (a[1] == 0) goto end2;
                res[51 + i * 2][j * 2] = '#';
                a[1]--;
            }
        }

        end2:;

        Console.WriteLine("100 100");
        Console.WriteLine(string.Join("\n",res.Select(x => string.Join("",x)).ToArray()).ToArray());
    }
}


Measured memory_bytes: 13536
main = do
  k <- readLn
  let arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  print $ last $ take k arr

Measured memory_bytes: 508
abcde = []
abcde.append(int(input()))
abcde.append(int(input()))
abcde.append(int(input()))
abcde.append(int(input()))
abcde.append(int(input()))

min_remainder_index = -1
for i in range(len(abcde)):
    remainder = abcde[i] % 10
    if remainder != 0:
        if min_remainder_index == -1:
            min_remainder_index = i
        elif abcde[min_remainder_index] % 10 > remainder:
            min_remainder_index = i

sum = 0
for i in range(len(abcde)):
    if i == min_remainder_index:
        sum += abcde[i]
    elif abcde[i] % 10 == 0:
        sum += abcde[i]
    else:
        sum += abcde[i] + (10-abcde[i] % 10)
print(sum)


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


const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007;
const int INF = 1000000000 + 1;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

ll gcd(ll x, ll y) {
  if (x == 0) return y;
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}

double dfs(int v, vector<bool>& visited, vector<vector<int>>& gr) {
  visited[v] = true;
  double res = 0.;
  int num = 0;
  for (int next : gr[v]) {
    if (!visited[next]) {
      num++;
      double resv = dfs(next, visited, gr);
      res += resv;
    }
  }
  if (num == 0) {
    return 0;
  }
  res /= num;
  return res + 1;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;
  cout << fixed << setprecision(6);

  while (q-- >0) {
    int n;
    cin >> n;
    int a[n + 1];
    ll maxnonleaf[n + 1];
    ll cur = 1ll;
    const ll INF = 100000000000000000ll;
    bool fail = false;
    for (int i = -1; i < n; ++i) {
      cin >> a[i + 1];
      if (cur >= INF) maxnonleaf[i + 1] = INF;
      else {
        maxnonleaf[i + 1] = (cur - a[i + 1]);
        if (maxnonleaf[i + 1] < 0) fail = true;
        cur = min(INF, 2* ( cur - a[i + 1]));
      }
    }
    if (fail) {
      cout << -1 << endl;
      continue;
    }
    ll res = 0ll;
    cur = 0;
    for (int i = n; i >= 0; --i) {
      cur = min(cur, maxnonleaf[i]) + a[i];
      res += cur;
    }
    cout << res << endl;
  }
  return 0;
}



Measured memory_bytes: 4780