akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_state,int arg_count){
		state = arg_state;
		count = arg_count;
	}
	int state,count;
};

int main(){

	int POW[17] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536};
	int N,M,K,limit;

	scanf("%d %d %d",&N,&M,&K);

	limit = POW[M];

	int* min_Count = new int[limit];

	for(int i = 0; i < limit; i++){
		min_Count[i] = BIG_NUM;
	}

	bool isDark[N];
	int  dark_Index[M],reverse_dark_Index[N];

	for(int i = 0; i < N; i++)isDark[i] = false;

	vector<int> V[N];

	int tmp;

	for(int i = 0; i < M;i++){
		scanf("%d",&tmp);
		tmp--;
		isDark[tmp] = true;
		dark_Index[i] = tmp;
		reverse_dark_Index[tmp] = i;
	}

	for(int i = 0; i < N; i++){
		for(int p = 0; p < K; p++){
			scanf("%d",&tmp);
			tmp--;
			V[i].push_back(tmp);
		}
	}

	queue<Info> Q;
	Q.push(Info(limit-1,0));
	min_Count[limit-1] = 0;

	int ans,state,next_state,room,next_room,next[M];

	while(!Q.empty()){

		if(Q.front().state == 0){
			ans = Q.front().count;
			break;
		}else if(Q.front().count > min_Count[Q.front().state]){
			Q.pop();
		}else{

			state = Q.front().state;

			for(int instruction = 0; instruction < K; instruction++){

				for(int a = 0; a < M; a++)next[a] = 0;

				for(int a = 0; a < M; a++){

					if(state & (1 << a)){
						room = dark_Index[a];
						next_room = V[room][instruction];
						if(isDark[next_room]){
							next[reverse_dark_Index[next_room]] = 1;
						}
					}
				}

				next_state = 0;
				for(int i = 0; i < M; i++)next_state += POW[i]*next[i];

				if(min_Count[next_state] > Q.front().count+1){
					min_Count[next_state] = Q.front().count+1;
					Q.push(Info(next_state,Q.front().count+1));
				}
			}

			Q.pop();
		}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n);
  for (auto&& u : a) cin >> u;
  for (auto&& u : b) cin >> u;
  int s = 0, r = a[n], x = 0;
  repr(i, n) {
    x = min(b[i], r);
    s += x;
    r = a[i] - (b[i] - x);
    if (r < 0) r = 0;
    s += a[i] - r;
  }

  cout << s << endl;
}

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

#define ls st<<1
#define rs st<<1|1
#define CLR(a,b) memset(a,(b),sizeof(a))

const int MAXN = 1e5+11;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;

/*-------------------------------------------------------*/
int abc(int x)
{
    if(x < 0) return -x;
    return x;
}
int x[MAXN], y[MAXN], t[MAXN];
int main() {
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) {
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    x[0] = 0, y[0] = 0, t[0] = 0;
    bool flag = true;
    for(int i = 1; i <= n; i++) {
        int tt = (t[i] - t[i-1]);
        int st = abc(x[i]-x[i-1])+abc(y[i]-y[i-1]);
        if(tt<st || st%2 !=tt%2) {
          flag = false; break;
        }

        }
        //if(t[i]==(x[i]-x[i-1]+y[i]-y[i+1]) continue;
    if(flag) printf("Yes\n");
    else printf("No\n");
return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int L, R;
signed main() {
    cin >> L >> R;
    if (R - L > 2019) { fin(0); }
    int ans = LLONG_MAX;
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            chmin(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main()
{

	int a, b;

	cin >> a >> b;

	int wa, seki, hiku;

	wa = a + b;
	seki = a * b;
	hiku = a - b;

	if (wa >= seki) {
		if (wa >= hiku) {
			cout << wa << endl;
		}
		else {
			cout << hiku << endl;
		}
	}
	else {
		if (seki >= hiku) {
			cout << seki << endl;
		}
		else {
			cout << hiku << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
	map<int, int> bubble;
	vector<int> a;
	int N, ans = 0, tmp;
	scanf("%d", &N);
	for(int i=0;i<N;i++) {
		scanf("%d", &tmp);
		a.push_back(tmp);
		bubble[tmp] = i;
	}
	sort(a.begin(), a.end());
	for(int i=0;i<N;i++) {
		if(bubble[a[i]] % 2 != i % 2) ans++;
	}
	ans >>= 1;
	printf("%d\n", ans);
	return 0;
}


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

namespace ABC042
{
	class Q2
	{
		static void Main()
		{
			List<int> buff = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			int N = buff[0];
			int L = buff[1];
			List<string> strs = Enumerable.Range(1, N).Select(x => Console.ReadLine()).ToList();
			for(int i = L-1; i >= 0; i--)
			{
				strs = strs.OrderBy(x => x[i]).ToList();
			}
			string ans = strs.Aggregate("", (sum, x) => (sum + x).Trim());
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 4696
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();
      int count = 0;
      for(int i = 0;i <= a;i++){
      	for(int j = 0;j <= b;j++){
        	for(int k = 0;k <= c;k++){
            	if(500*i+100*j+50*k==x)count++;
            }
        }
      }
      System.out.println(count);
    }
}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) {
    cout << 0.5 << endl;
  } else {
    cout << 1.0 * (n / 2 + 1) / n << endl;
  }
  return 0;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

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

    vector<int>a1(n),a2(n),a1s(n),a2s(n);
    rep(i,n)cin>>a1[i];
    rep(i,n)cin>>a2[i];

    a1s[0]=a1[0];
    a2s[n-1]=a2[n-1];

    rep2(i,1,n-1)a1s[i]=a1s[i-1]+a1[i];
    repr(i,n-2,0)a2s[i]=a2s[i+1]+a2[i];

    int ans=0;

    rep(i,n)ans=max(ans,a1s[i]+a2s[i]);

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

const int N = 101;

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

	vector<int> p(N);
	for (int i = 1; i <= n; i++)
	{
		cin >> p.at(i - 1) >> p.at(i);
	}

	vector<vector<int>> m(N, vector<int>(N));

	for (int l = 2; l <= n; l++)
	{
		for (int i = 1; i <= n - l + 1; i++)
		{
			int j = i + l - 1;
			m.at(i).at(j) = (1 << 21);
			for (int k = i; k < j; k++)
			{
				m.at(i).at(j) = min(m.at(i).at(j), m.at(i).at(k) + m.at(k + 1).at(j) + p.at(i - 1) * p.at(k) * p.at(j));
			}
		}
	}

	cout << m.at(1).at(n) << endl;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
ll dp[(int)1e5+9];
bool b[(int)1e5+9];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x,m,l;
    cin>>x>>m;
    for (int i=0;i<m;i++){
        cin>>l;
        b[l]=true;
    }
    dp[0]=1;
    if (!b[1])
        dp[1]=1;
    for (int i=2;i<=x;i++){
        if (!b[i])
            dp[i]=(dp[i-1]%mod+dp[i-2]%mod)%mod;
    }
    cout<<dp[x]%mod<<endl;
}


Measured memory_bytes: 1152
n = int(input())
a = list(map(int, input().split()))
b = []
if n % 2 == 0:
	b = a[1:: 2][:: -1] + a[:: 2]
	print(" ".join(map(str, b)))
else:
	b = a[:: 2][:: -1] + a[1:: 2]
	print(" ".join(map(str, b)))


Measured memory_bytes: 28616
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    int ans=1e5;
    REP(c,26){
        string from=s,to;
        int cnt=0;
        while(1){
            to.clear();
            bool ok=true;
            REP(j,from.size()-1){
                if(from[j]!=from[j+1]){
                    ok=false;
                }
                if(from[j]==char(c+'a')||from[j+1]==char(c+'a')){
                    to+=char(c+'a');
                }
                else to+=from[j];
            }
            if(ok) break;
            cnt++;
            swap(from,to);
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    stringstream c(a+b);
    int n=0;
    c>>n;
    int n1=sqrt(n);
    if(n1*n1==n) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

using namespace std;

int main() {
  while(1) {
    int b, r, g, c, s, t;
    cin >> b >> r >> g >> c >> s >> t;
    if(!(b|r|g|c|s|t)) break;
    int B = b*5+r*3;
    cout << 
      (100
       + B*15 - B*2
       + g*7 + c*2 + (b+r)*15
       - (t-s-B)*3)
         << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    int f;
    int d;
    cin>>a>>b>>c;
    f=a-b;
    d=c-f;
    if(d<0)
    {
        cout<<0;
    }
    else
    {
       cout<<d;
    }




    return 0;
}


Measured memory_bytes: 256
use proconio::*;
use std::cmp::*;

const F: usize = 26;

#[fastout]
fn run() {
    input! {
        d: usize,
        c: [i64; F],
        s: [[i64; F]; d],
    }
    let mut last = [0; 26];
    for (i, s) in s.iter().enumerate() {
        let i = i as i64 + 1;
        let mut score = (std::i64::MIN, 0);
        for t in 0..F {
            let mut v = 0;
            v += s[t];
            let save = last[t];
            last[t] = i;
            for (c, last) in c.iter().zip(last.iter()) {
                v -= *c * (i - *last);
            }
            score = max(score, (v, t));
            last[t] = save;
        }
        println!("{}", score.1 + 1);
        last[score.1] = i;
    }
}

fn main() {
    run();
}


Measured memory_bytes: 2340
import math
a = input().split()
n = int(a[0])
A = int(a[1])
b = int(a[2])
c = int(a[3])
d = int(a[4])
seta = math.ceil(n / A)
setc = math.ceil(n / c)
costa = seta * b
costb = setc * d
if costa < costb:
    print(costa)
elif costb < costa:
    print(costb)
else:
    print(costa)


Measured memory_bytes: 5664
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int dp[1001][1001];


signed main() 
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int h,w;
    cin>>h>>w;
    dp[1][1]=1;
    rep(i,1,h)
    {
        string s;
        cin>>s;
        rep(j,1,w) 
        {
            if(i==1 && j==1) continue;
            if(s[j-1]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
    cout<<dp[h][w];
}   

Measured memory_bytes: 8064
import std.stdio, std.string, std.array, std.conv, std.algorithm;

long P = 10^^9+7;

void main()
{
    auto n = readln.chomp.to!long;
    long ret = 1;
    foreach (i; 0..n) {
        ret *= i + 1;
        ret %= P;
    }
    writeln(ret);
}

Measured memory_bytes: 256
using System;

namespace question1
{
    class Program
    {
        static void Main(string[] args)
        {
            int largeN;
            largeN = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int a = -1;
            int b = -1;
            int c = -1;
            
            //本当に 3 種類以内か?
            foreach (string tempstr in str)
            {
                int test = int.Parse(tempstr);
                if (test != a && test != b && test != c)
                {
                    if (a == -1) a = test;
                    else if (b == -1) b = test;
                    else if (c == -1) c = test;
                    else
                    {
                        Console.WriteLine("No");
                        Environment.Exit(0);
                    }
                }
            }
            //数のカウント
            int ac = 0;
            int bc = 0;
            int cc = 0;


            foreach (string tempstr in str)
            {
                int test = int.Parse(tempstr);
                if (test == a) ac += 1;
                else if (test == b) bc += 1;
                else if (test == c) cc += 1;
            }
            //Console.WriteLine("ac={0},bc={1},cc={2}", ac, bc, cc);
            if (ac==bc && bc == cc)
            {
                if ((a ^ b ^ c) == 0) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }
            else if (bc==0 && cc == 0)
            {
                if (a == 0) Console.WriteLine("Yes");
                else Console.WriteLine("No");

            }
            else if (bc != 0 && cc==0){
                if ((a == 0) && (ac * 2 == bc)) Console.WriteLine("Yes");
                else if ((b == 0) && (bc * 2 == ac)) Console.WriteLine("Yes");
                else Console.WriteLine("No");

            }
            else Console.WriteLine("No");

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 21600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int diff=b-a;
		int height = diff*(diff-1)/2 - a;
		System.out.println(height);
	}
}


Measured memory_bytes: 21588
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <string>

using ll = long long;

using namespace std;

void solve() {
    ll n;
    vector<ll> vars(3);
    cin >> n >> vars[0] >> vars[1] >> vars[2];
    vector<string> reqs(n);
    vector<char> result;
    for (int i = 0; i < n; ++i) {
        cin >> reqs[i];
    }
    for (int i = 0; i < n; ++i) {
        string str = reqs[i];
        int p1 = str[0] - 'A';
        int p2 = str[1] - 'A';
        if (vars[p1] == 0 && vars[p2] == 0) {
            cout << "No\n";
            return;
        } else if (vars[p1] == 0) {
            ++vars[p1];
            --vars[p2];
            result.push_back(str[0]);
        } else if (vars[p2] == 0 || i + 1 == n) {
            --vars[p1];
            ++vars[p2];
            result.push_back(str[1]);
        } else {
            int p3 = reqs[i + 1][0] - 'A';
            int p4 = reqs[i + 1][1] - 'A';
            if (p3 == p1 || p4 == p1) {
                ++vars[p1];
                --vars[p2];
                result.push_back(str[0]);
            } else {
                --vars[p1];
                ++vars[p2];
                result.push_back(str[1]);
            }
        }
    }

    cout << "Yes\n";
    for (int i = 0; i < n; ++i) {
        cout << result[i] << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}


Measured memory_bytes: 6696
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    s, t = LS()
    a, b = LI()
    u = S()
    if u == t:
        print(" ".join([str(a), str(b-1)]))
    else:
        print(" ".join([str(a-1), str(b)]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<iostream>
using namespace std;
int main(void)
{
	int i,n,ans1=0,ans2=0,ans3=0,ans4=0,ans5=0;
	cin>>n;
	string s[n];
	for(i=0;i<n;i++){
		cin>>s[i];
		if(s[i][0]=='P') ans1++;
		if(s[i][0]=='W') ans2++;
		if(s[i][0]=='G') ans3++;
		if(s[i][0]=='Y') ans4++;
	}
	if(ans1!=0) ans5=ans5+1;
	if(ans2!=0) ans5=ans5+1;
	if(ans3!=0) ans5=ans5+1;
	if(ans4!=0) ans5=ans5+1;
	if(ans5==3) cout<<"Three"<<endl;
	if(ans5==4) cout<<"Four"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int X = sc.nextInt();
		for (int i = 1; i <= X; i++) {
			if (i * (i + 1) / 2 >= X) {
				System.out.println(i);
				return;
			}
		}
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23764
def solve(n, a, b):
    for t in range(n*2):
        if t % 2 == 0:
            if a < b + 1:
                a += 1
            elif a == b + 1:
                a += 1
            elif a == b - 1:
                a -= 1
            elif a > b - 1:
                a -= 1
            else:
                return "Borys"
        else:
            if b < a + 1:
                b += 1
            elif b == a + 1:
                b += 1
            elif b == a - 1:
                b -= 1
            elif b > a - 1:
                b -= 1
            else:
                return "Alice"
        if a == b:
            return "Borys" if t % 2 == 0 else "Alice"
        if (a <= 0) or (n < a):
            return "Borys"
        elif (b <= 0) or (n < b):
            return "Alice"
    return "Draw"

n, a, b = map(int, input().split())
print(solve(n, a, b))

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

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

    int i = 0;
    bool is_true = false;
    set<int> st;
    while (1) {
        i++;
        if ((a * i) % b == c) {
                is_true = true;
                break;
        }
        st.insert((a * i) % b);
        if (st.size() != i)
            break;
    }

    cout << (is_true ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	map<int,int> cnt;
	rep(i,n){
		cin >> a[i];
		++cnt[a[i]];
	}
	if(cnt[0] == n){
		cout << "Yes" << endl;
		return 0;
	}
	if(n % 3 !=0){
		cout << "No" << endl;
		return 0;
	}
	vector<int> all;
	for(auto &p:cnt){
		for(int i = 0;i< p.second /(n/3);i++){
			all.push_back(p.first);
		}
	}
	if(all.size() == 3 && (all[0]^all[1]^all[2]) == 0 ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 4224
x, n = [int(i) for i in input().split()]
if n > 0:
  p = [int(i) for i in input().split()]
  x1 = x
  while True:
    if x1 not in p:
      a = x1
      break
    else:
      x1 -= 1
  x1 = x
  while True:
    if x1 not in p:
      b = x1
      break
    else:
      x1 += 1
  if abs(x-b) < abs(x-a):
    print(b)
  elif abs(x-a) < abs(x-b):
    print(a)
  else:
    print(a) if a<b else print(b)
else:
  print(x)

Measured memory_bytes: 9216
function main(input) {
	var inputs = input.split("\n");
	var money = Number(inputs[0].split(" ")[0]);
    var kRegexp = new RegExp("["+inputs[1].replace(" ","")+"]");
    while(kRegexp.test(String(money))){
    	money++;
    }
    return money;
}
 
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 34284
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    string S, T; cin >> S >> T;

    int res = INF;
    for (int i = 0; i < S.size(); i++) {
        if (i > (S.size() - T.size())) {
            break;
        }

        int cnt = 0;
        for (int j = 0; j < T.size(); j++) {
            if (T.at(j) != S.at(i + j)) {
                cnt++;
            }
        }

        res = min(res, cnt);
    }

    cout << res << endl;
}


Measured memory_bytes: 3628
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 1e6 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll s;
    cin >> s;
    map<ll, int> mp;
    mp[s] = 1;
    ll i = 2;
    function<ll(ll)> f = [&](ll n){
        if(n & 1){
            return 3 * n + 1LL;
        }
        return n / 2;
    };
    ll ans = LLONG_MAX;
    while(1){
        ll yo = f(s);
        if(mp.find(yo) != mp.end()){
            ans = min(ans, i);
            if(yo == 4) break;
        }
        s = yo;
        mp[yo] = i++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
#define ALL(a) begin(a),end(a)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int  ui;
const int INF=numeric_limits<int>::infinity();
const int MOD=1000000007;
const double EPS=1e-9;

#define MAX_N 300001
int N,minn=MAX_N,temp=0;
string S(MAX_N,'a');

int main(int argc,char**argv)
{
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin>>N;
  REP(i,N){
      cin>>S[i];
  }
  FOR(i,1,N){
      if(S[i]=='E')temp++;
  }
  minn=temp;
  FOR(i,1,N){
      if(S[i-1]=='W')temp++;
      if(S[i]=='E')temp--;
      if(minn>temp)minn=temp;
  }
  cout<<minn<<endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 512
ret = ''
while True:
   h,w = map(int, raw_input().split())
   if h == w == 0:
       break
   ret += '#'*w+'\n'
   ret += ('#' + '.' * (w-2) + '#\n') * (h - 2)
   ret += '#'*w+'\n\n'
print ret,

Measured memory_bytes: 6444
# C

import bisect

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p_list = {int(x) for x in input().split()}
    q_list = {int(x) for x in range(102)}
    q_list = list(q_list - p_list)

    p = bisect.bisect_left(q_list, x)
    if p == 0:
        print(q_list[p])
    elif p == len(q_list):
        print(q_list[p-1])
    else:
        if abs(q_list[p-1] - x) <= abs(q_list[p] - x):
            print(q_list[p-1])
        else:
            print(q_list[p])

Measured memory_bytes: 61984
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int c[200005];
vector<int> g[200005];

void dfs(int x, int p) {
    for (int i : g[x]) if (i != p) {
        c[i] = 3 - c[x];
        dfs(i, x);
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, u, v, w, z[200005] = {};
    cin >> n;
    for (int i = 1; i < n; i++) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    c[1] = 1;
    dfs(1, 1);
    int d = 0, e = 0;
    for (int i = 1; i <= n; i++) {
        if (c[i] == 1) d++;
        else e++;
    }
    u = 1; v = 2; w = 3;
    if (d >= (n + 2) / 3 && e >= (n + 1) / 3) {
        for (int i = 1; i <= n; i++) {
            if (c[i] == 1) {
                if (u <= n) cout << u, u += 3;
                else cout << w, w += 3;
            } else {
                if (v <= n) cout << v, v += 3;
                else cout << w, w += 3;
            }
            cout << ' ';
        }
    } else if (d > e) {
        for (int i = 1; i <= n; i++) {
            if (c[i] == 1) {
                if (u <= n) cout << u, u += 3;
                else if (v <= n) cout << v, v += 3;
                else cout << w, w += 3;
            } else {
                cout << w, w += 3;
            }
            cout << ' ';
        }
    } else {
        for (int i = 1; i <= n; i++) {
            if (c[i] == 2) {
                if (u <= n) cout << u, u += 3;
                else if (v <= n) cout << v, v += 3;
                else cout << w, w += 3;
            } else {
                cout << w, w += 3;
            }
            cout << ' ';
        }
    }
}


Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define maxn 1000010
#define mod 2147483647
#define int ll
#define PI 3.14159265358979
signed main(){
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	double a,b,x;
	cin>>a>>b>>x;
	if(x>=a*a*b/2)printf("%.10lf\n",atan((b-2*x/a/a+b)/a)/PI*180);
	else printf("%.10lf\n",90-atan(x/a*2/b/b)/PI*180);
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		double mark = (double)1/((4*m));
		int count = 0;
		int total = 0;
		int[] arr = new int[n];
		for(int i = 0;i<n;i++)
		{
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		for(int i = 0;i<n;i++)
		{
			int votes = arr[i];
			if(votes >= (total * mark))
				count++;
		}
		System.out.println(count>=m?"Yes":"No");
	}
}

Measured memory_bytes: 23764
import math
N,L = input().split()
N,L = int(N),int(L)


if(L>=0):
    print(int(0.5*N*(N+1)+N*L-N-(L)))
else:
    n = min([-L,N-1])
    print(int(0.5*N*(N+1)+N*L-N-(L+n)))

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

int main(){
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<pair<char, char>> td(Q);
    for(int i=0; i<Q; i++)
        cin >> td[i].first >> td[i].second;

    reverse(td.begin(), td.end());

    int l = -1, r = N;
    for(auto x : td){
        if(x.second == 'L'){
            if(s[l+1] == x.first)
                l++;
            if(r < N && s[r] == x.first)
                r++;
        }else{
            if(s[r-1] == x.first)
                r--;
            if(l >= 0 && s[l] == x.first)
                l--;
        }
        if(l == r-1) break;
    }
    int ans = N-(l+1+N-r);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll r[maxn], n, k;
ll bp(ll a, ll p) {
	ll r = 1;
	while(p) {
		if(p&1) r = (r*a)%mod;
		p>>=1, a = a*a%mod;
	}
	return r;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= k; i++) {
		r[i] = bp(k/i, n);
	}
	ll ans = 0;
	for(int i = k; i; i--) {
		for(int j = i+i; j <= k; j+=i)
			r[i] = (mod+r[i]-r[j])%mod;
		ans = (ans + r[i]*i)%mod;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define mod 1000000007
#define N 10001
using namespace std;
typedef long long ll;
int n,m,cmp[N],used[N];
vector <int> G[N],rG[N],vs;

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int pos){
  used[pos]=1;
  for(int i=0;i<G[pos].size();i++)
    if(!used[G[pos][i]])dfs(G[pos][i]);
  vs.push_back(pos);
}

void rdfs(int pos,int k){
  used[pos]=1;
  cmp[pos]=k;
  for(int i=0;i<rG[pos].size();i++)if(!used[rG[pos][i]])rdfs(rG[pos][i],k);
}

int ssc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int i=0;i<n;i++) if(!used[i])dfs(i);
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],k++);
  return k;
}

ll calc(int pos){
  if(used[pos]) return 1;
  used[pos]=1;
  ll res=1;
  for(int i=0;i<rG[pos].size();i++)res=res*calc(rG[pos][i])%mod;
  return (res+1)%mod;
}


void mk_G(){
  int k=ssc();
  vector <int> tmp[N],rtmp[N];
  for(int i=0;i<n;i++){
    for(int j=0;j<G[i].size();j++)
      if(cmp[i]!=cmp[G[i][j]]) tmp[cmp[i]].push_back(cmp[G[i][j]]);
    for(int j=0;j<rG[i].size();j++)
      if(cmp[i]!=cmp[rG[i][j]]) rtmp[cmp[i]].push_back(cmp[rG[i][j]]);
    G[i].clear();
    rG[i].clear();
  }
  n=k;
  for(int i=0;i<k;i++) G[i]=tmp[i],rG[i]=rtmp[i];
}


int main(){
  cin>>n>>m;
  for(int i=0,a,b;i<m;i++)cin>>a>>b,add_edge(a-1,b-1);
  mk_G();
  ll ans=1;
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++) if(!G[i].size())ans=ans*calc(i)%mod;
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 2316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007

double tick() {
	static clock_t oldt; clock_t newt = clock(); double diff =

		1.0*(newt - oldt) / CLOCKS_PER_SEC; oldt = newt; return diff;
}
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}


int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	int a, b;
	cin >> a >> b;
	string s3;
	cin >> s3;
	if (s3 == s1) {
		cout << a - 1 << " " << b << endl;
	}
	else
	{
		cout << a << " " << b - 1 << endl;
	}
}

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

using namespace std;

int main(){
	int n,r;
	while(cin >> n >> r,n||r){
		vector<pair<pair<int,int>,pair<int,int>>> v;
		for(int i=0;i<n;i++){
			int x1,y1,x2,y2;
			cin >> x1 >> y1 >> x2 >> y2;
			v.emplace_back(make_pair(make_pair(x1,y1),make_pair(x2,y2)));
		}
		int s[10001] = {0};
		int p[10001] = {0};
		int edge = 0;
		for(int y=0;y<=10000;y++){
			int w[10001] = {0};
			for(int unsigned j = 0;j<v.size();j++){
				if(v[j].first.second <= y && y < v[j].second.second){
					w[v[j].first.first]++;
					w[v[j].second.first]--;
				}
			}
			int c = 0;
			for(int unsigned x = 0;x <= 10000;x++){
				int px = c;
				c += w[x];
				if((px > 0 && c == 0) || (px == 0 && c > 0)){
					//cout << "left: ("  << x << "," << y << ")" << endl;
					edge++;
				}
				if((c > 0 && p[x] == 0) || (c == 0 && p[x] > 0)){
					//cout << "up: ("  << x << "," << y << ")" << endl;
					edge++;
				}
				p[x] = c;
				if(c) s[x]++;
			}
		}
		int area = 0;
		for(int x=0;x<=10000;x++){
			area += s[x];
		}
		cout << area << endl;
		if(r == 2){
			cout << edge << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n;
	string s;
	cin >>n;
	cin >>s;
	vector<int> west(n,0);
	vector<int> east(n,0);
	for(int i=0;i<n;i++){
		east[i]=(i==0)?0:east[i-1];
		if(s[i]=='W'){
			east[i]++;
		}

	}
	for (int i = n-1; i >= 0; i--)
	{
		west[i] = (i == n-1) ? 0 : west[i + 1];
		if (s[i] == 'E')
		{
			west[i]++;
		}
	}
	int ans=INF;
	for(int i=0;i<n;i++){
		//cout<<east[i]<<"   -   "<<west[i]<<endl;
		chmin(ans,((i!=0)?east[i-1]:0)+((i!=n-1)?west[i+1]:0));
	}
	cout<<ans<<endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> number(N);
  for(int n = 0; n < N; n++)
    number.at(n) = n+1;
  for(int i = 0; i < K; i++){
    int d;
    cin >> d;
    vector<int> A(d);
    for(int j = 0; j < d; j++)
      cin >> A.at(j);
    for(int k = 0; k < d; k++){
      for(int l = 0; l < N; l++){
        if(number.at(l) == A.at(k))
          number.at(l) = 0;
      }
    }
  }
  int count = 0;
  for(int a = 0; a < N; a++)
    if(number.at(a) != 0)
      count++;
  cout << count << endl;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    int N, W[100], sum = 0, S1;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
        sum += W[i];
    }

    int min_value = (1 << 21);
    for (int T = 0; T < N - 1; T++)
    {
        S1 = 0;
        for (int i = 0; i < T + 1; i++)
        {
            S1 += W[i];
        }
        if(min_value > abs(sum - S1 - S1)){
            min_value = abs(sum - S1 - S1);
        }
    }

    cout << min_value << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    forn(i, n) cin >> a[i];
    forn(i0, k) {
        vi f(n + 1);
        forn(i, n) {
            int l = max(0, i - a[i]);
            int r = min(n - 1, i + a[i]);
            f[l]++, f[r + 1]--;
        }
        bool flag = true;
        forn1(i, n){
            f[i] += f[i - 1];
            if (f[i] < n) flag = false;
        }
        a = f;
        if (flag) break;
    }
    a.pop_back();
    printvi(a)
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 5576
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

const int maxn = 10050;
typedef long long ll;

int n,m;
double dp[maxn];
vector<int>G[maxn];

double slove(int p){
    dp[n]=0;
    for(int i=n-1;i>=1;i--){
        int all=G[i].size();
        if(!all||(i==p&&all==1)){dp[i]=0x3f3f3f3f;continue;};
        double MAX=0,ret=0;
        for(int j=0;j<all;j++){
            MAX=max(dp[G[i][j]]+1,MAX);
            ret+=1/double(all-(i==p))*(dp[G[i][j]]+1);
        }
        if(i==p)ret-=1/double(all-1)*MAX;
        dp[i]=ret;
    }
    return dp[1];
}

int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int s,t;
        scanf("%d%d",&s,&t);
        G[s].push_back(t);
    }
    double ans=slove(0);
    for(int i=1;i<=n-1;i++){
        ans=min(ans,slove(i));
    }
    printf("%.10f",ans);
}


Measured memory_bytes: 1664
N = int(input())
S = input().split()

# G W W G P W P G G
v = {'G': 0, 'W': 0, 'P': 0, 'Y': 0}
for s in S:
    v[s] += 1

res = 0
for r in ['G', 'W', 'P', 'Y']:
    if v[r] > 0:
        res += 1

if res == 3:
    print('Three')
else:
    print('Four')



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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int h, n;
    cin >> h >> n;

    long long sum = 0;

    while(n--)
    {
        int x;
        cin >> x;

        sum += x;
    }

    if(sum >= h)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int h,a;
    cin >> h >> a;
    if(h % a == 0){
        println(h / a);
    }
    else println(h / a + 1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n;
    cin >> n;
    VI a(n);
    //REP(i,0,n) cin >> a[i];
    int v4 = 0, v2 = 0, in;
    REP(i,0,n) {
        cin >> in;
        if (in % 4 == 0) ++v4;
        else if (in % 2 == 0) ++v2;
    }
    int re = n - 2 * v4;
    if (re > 1) {
        if (re <= v2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (v4 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    while(true) {
        int a,b;
        cin>>a>>b;
        if(a==0)break;

        int n;
        cin>>n;
        set<pair<int,int>> us;
        for(int i = 0;i < n;++i) {
            int x,y;
            cin>>x>>y;
            --x;--y;
            us.insert(make_pair(x,y));
        }
        vector<vector<int>> dp(a,vector<int>(b,0));
        for(int i = 0;i < b;++i) {
            if(us.find(make_pair(0,i))!=us.end())break;
            dp[0][i]=1;
        }
        for(int i = 0;i < a;++i) {
            if(us.find(make_pair(i,0))!=us.end())break;
            dp[i][0]=1;
        }

        for(int i = 1;i < a;++i) {
            for(int j = 1;j < b;++j) {
                if(us.find(make_pair(i,j))!=us.end())continue;
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }
        }
        cout<<dp[a-1][b-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3116
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    d = dict()
    for a in A: d[a] = d.get(a, 0) + 1

    count = 0
    for a in d:
        if d[a] > a:
            count += d[a] - a
        elif d[a] < a:
            count += d[a]
    return count

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 17780
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
#define maxn 200010
using namespace std;
typedef long long LL;
int a[maxn], b[maxn], bb[maxn];
int main() {
    int n;
    scanf("%d", &n);
    F(i, 0, n) scanf("%d", &a[i]);
    F(i, 0, n) scanf("%d", &b[i]);
    int mod=1, ans=0;
    F(k, 0, 29) {
        F(i, 0, n) bb[i] = b[i] % (mod<<1);
        sort(bb, bb+n);
        int cnt=0;
        F(i, 0, n) {
            int temp=a[i]%(mod<<1);
            int p1=lower_bound(bb, bb+n, mod-temp)-bb,
                p2=lower_bound(bb, bb+n, (mod<<1)-temp)-bb,
                p3=lower_bound(bb, bb+n, mod*3-temp)-bb,
                p4=lower_bound(bb, bb+n, (mod<<2)-temp)-bb;
            cnt += p2-p1+p4-p3;
        }
        ans += cnt&1 ? mod : 0;
        mod <<= 1;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int main()
{
   int n, m;
   int count = 0;
   cin >> n >> m;

   vector<int> l(m), r(m);

   for(int i=0;i<m;i++){
      cin >> l[i] >> r[i];
   }

   int min = 1;
   int max = n;

   for(int i=0;i<m;i++){
      if(l[i] > min) min = l[i];
      if(r[i] < max) max = r[i];
   }

   int ans = max - min + 1;
   cout << ((ans>=1) ? ans : 0) << endl;

   return 0;
}


Measured memory_bytes: 1024