akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

template<typename T> T MV(T v) { return v; }
template<typename T, typename ... U> auto MV(T v, int a, U ... b) { return vector<decltype(MV(v, b ...))>(a, MV(v, b ...)); }

#define bit(b, i) (((b) >> (i)) & 1)
#define PC __builtin_popcountll
#define BL(a) (a ? 64 - __builtin_clzll(a) : 0)

int main() {
	IN(LL, n, k);
	vector<int> a(n);
	cin >> a;
	
	map<int, int> nex;
	dec(i, n) { nex[a[i]] = (n + 1) + i; }
	auto dp = MV(0, 40, n + 1);
	dp[0][n] = n + 1;
	dec(i, n) {
		int p = nex[a[i]] + 1;
		if(p < n + 1) { p = dp[0][p]; }
		dp[0][i] = p;
		nex[a[i]] = i;
	}
	inc(i, n + 1) { dp[0][i] %= (n + 1); }
	
	inc(l, 40 - 1) {
	inc(i, n + 1) {
		dp[l + 1][i] = dp[l][dp[l][i]];
	}
	}
	
	int p = 0;
	inc(l, 40) { if(bit(k - 1, l) == 1) { p = dp[l][p]; } }
	
	vector<int> ans;
	set<int> se;
	incID(i, p, n) {
		if(se.count(a[i]) == 0) { ans.PB(a[i]); se.insert(a[i]); }
		else {
			while(true) {
				int x = ans.BA;
				ans.pop_back();
				se.erase(x);
				if(x == a[i]) { break; }
			}
		}
	}
	OUT(ans);
}


Measured memory_bytes: 53232
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

INF = float('inf')

DP = [INF] * N
DP[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            DP[i+j] = min(DP[i+j], DP[i] + abs(H[i+j] - H[i]))
    # print(DP)

print(DP[N-1])

Measured memory_bytes: 55264
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            long A = in.nextLong();
            long B = in.nextLong();
            long C = in.nextLong();
            long D = in.nextLong();
            System.out.println(count(B, C, D) - count(A - 1, C, D));
        }
    }

    private static long count(long N, long C, long D) {
        long countC = N / C;
        long countD = N / D;
        long countCandD = N / (C * D / gcd(C, D));
        return N - countC - countD + countCandD;
    }

    public static final long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}


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

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a + (a <= b ? 0 : -1) << endl;
    return 0;
}


Measured memory_bytes: 888
aryPrm = gets.split.map{|x|x.to_i}
inW = 0
inH = 1
inX = 2
inY = 3
inR = 4

if 0 <= aryPrm[inX] - aryPrm[inR] && aryPrm[inR] + aryPrm[inX] <= aryPrm[inW]
    if 0 <= aryPrm[inY] - aryPrm[inR] && aryPrm[inR] + aryPrm[inY] <= aryPrm[inH]
        puts "Yes"
    else
        puts "No"
    end
else
    puts "No"
end

Measured memory_bytes: 8688
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
char s[SIZE];
LL dp[SIZE][5];
int main(){
    RS(s+1);
    int n=LEN(s+1);
    int k;
    R(k);
    int now=0;
    FOR(i,1,n){
        REPP(j,0,s[i]-'0'){
            ADD(dp[i][min(now+(j!=0),4)],1);
        }
        FOR(j,0,k){
            ADD(dp[i][j],dp[i-1][j]);
            ADD(dp[i][j+1],dp[i-1][j]*9);
        }
        now+=(s[i]!='0');
    }
    LL an=dp[n][k];
    if(now==k)an++;
    W(an);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

def sol():
    n,m=map(int,input().split())
    d={}
    for i in range(m):
        u,v=map(int,input().split())
        if u in d:
            d[u].append(v)
        else:
            d[u]=[v]
    s,t=map(int,input().split())
    ans=0
    w=deque([0,s])
    tmp=[[0,0,0] for i in range(n+1)]
    ans=1
    n*=3
    while n:
        x=w.pop()
        if x==0:
            ans+=1
            n-=1
            w.appendleft(0)
        elif x in d:
            for j in d[x]:
                if ans%3==0 and j==t:
                    print(ans//3)
                    exit()
                if tmp[j][ans%3]==0:
                    w.appendleft(j)
                    tmp[j][ans%3]=1
    print(-1)

if __name__=="__main__":
    sol()

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

int main() {
    string s;
    cin >> s;
    int pos, lcnt=0, rcnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='*'){
            pos = i;
            break;
        }
    }
    for(int i=0;i<pos;i++){
        if(s[i]=='(') lcnt++;
        else if(lcnt>0) lcnt--;
    }
    for(int i=(int)s.size()-1;i>pos;i--){
        if(s[i]==')') rcnt++;
        else if(rcnt>0) rcnt--;
    }
    cout << min(lcnt, rcnt) << endl;
    return 0;
}



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

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

  a = N / 1000;
  b = N % 1000 / 100;
  c = N % 1000 % 100 / 10;
  d = N % 1000 % 100 % 10;
    
  if (( a == b && b == c ) || ( b == c && c ==d )) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include <vector>
#include <iomanip>
#include <limits>
using namespace std;

double dist(int &i, int &j , vector<int> &x ,vector<int> &y) {
    double dx = x.at(i) - x.at(j);
    double dy = y.at(i) - y.at(j);
    return pow(dx * dx + dy * dy, 0.5);
}

int main(){
  int n , a , b;
  double sum = 0;
  cin >> n;
  vector<int> ab , x(n) , y(n);
  for (int i = 0 ; i < n ; i ++) {
    cin >> x.at(i) >> y.at(i);
  }
  for (int i = 0 ; i < n - 1 ; i ++) {
    for (int j = i + 1 ; j < n ; j ++) {
      sum += dist(i , j , x , y);
    }
  }
  cout << fixed << setprecision(10) << sum * 2 / n << endl;
}

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N,K;
    int R,S,P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    // resolve
    map<char, char> victoryHand;
    victoryHand['r'] = 'p';
    victoryHand['s'] = 'r';
    victoryHand['p'] = 's';
    map<char, int> points;
    points['r'] = R;
    points['s'] = S;
    points['p'] = P;
    points['a'] = 0;    
    int count = 1;
    map<int, char> pastHand;
    
    ll ansPont = 0;
    for (auto c: T)
    {
        char myHand = victoryHand[c];
        if (myHand == pastHand[count-K]) myHand = 'a';
        pastHand[count] = myHand;
        ansPont += points[myHand];
        count++;
    }

    // output
    cout << ansPont << endl;

    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;cin>>n>>m;
    if(n > m){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }
    return 0;
}
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;cin>>n>>m;
    if(n > m){
        for (size_t i = 0; i < n; i++) {
            cout<<m;
        }
    }
    else{
        for (size_t i = 0; i < m; i++) {
            cout<<n;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll a,b,c,d,k; cin >> a >> b >> c >> d >> k;
  
  cout << -60*a - b +(60*c + d) - k << endl;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int,input().split()))
#N = 5
#A = [10, -4, -8, -11, 3]

num_minus = 0
for i in A:
    if i < 0:
        num_minus +=  1
        
A_abs = [abs(i) for i in A]
if num_minus % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs)- 2*min(A_abs))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;

int main(){
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='1') s[i]='9';
		else s[i]='1';
	}
	cout<<s<<endl;
}

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

int main()
{
    int n;
    list<long long> l;

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        char s[20];
        scanf("%s", s);
        if (s[6] == 'F')
        {
            l.pop_front();
        }
        else if (s[6] == 'L')
        {
            l.pop_back();
        }
        else if (s[0] == 'i')
        {
            long long x;
            scanf("%lld", &x);
            l.push_front(x);
        }
        else
        {
            long long x;
            scanf("%lld", &x);
            list<long long>::iterator it = l.begin();
            while (it != l.end())
            {
                if (*it == x)
                {
                    l.erase(it);
                    break;
                }
                it++;
            }
        }
    }

    while (!l.empty())
    {
        printf("%lld", l.front());
        l.pop_front();
        if (!l.empty())
        {
            printf(" ");
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 33876
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007

int n;
ll a[212345];

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

  if(n==0) puts("1");
  else puts("0");
  
  return 0;
}


Measured memory_bytes: 1656
#include <cmath>
#include <iostream>

using namespace std;

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

  for (int x = 0; x <= 1300; x++) {
    int a1 = (x * 8) / 100;
    int b1 = x / 10;
    if (a1 == a && b1 == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define maxn 2086

using namespace std;

bitset<maxn * maxn> bs;

int n, x, sum;

int main(){
	scanf("%d", &n);
	bs[0] = 1;
	while(n--){
		scanf("%d", &x);
		bs |= bs << x;
		sum += x;
	}
	for(int i = (sum + 1) / 2;;i++) if(bs[i]) return printf("%d", i), 0;
}

Measured memory_bytes: 5412
#include <stdio.h>

int main(void){
	char str[105];
	int h, w;
	scanf("%d %d", &h, &w);
	for(int i = 0; i < h; i++){
		scanf("%s", str);
		printf("%s\n%s\n", str, str);
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, Q;
    cin >> N >> Q;
    vector<tuple<ll, ll, ll>> roadwork;
    Rep (i, N) {
        ll s, t, x;
        cin >> s >> t >> x;
        roadwork.push_back(make_tuple(s-x, 1, x));
        roadwork.push_back(make_tuple(t-x, -1, x));
    }
    vector<ll> D(Q);
    Rep (i, Q) {
        cin >> D[i];
    }

    sort(roadwork.begin(), roadwork.end());
    set<ll> stop;
    ll now = 0;
    vector<ll> dist(Q, -1);
    for (auto e : roadwork) {
        ll time = get<0>(e);
        ll kind = get<1>(e);
        ll place = get<2>(e);

        while (now < Q && time > D[now]) {
            if (!stop.empty()) {
                dist[now] = *stop.begin();
            }
            now++;
        }

        if (kind == 1) {
            stop.insert(place);
        } else {
            stop.erase(place);
        }
    }

    for (auto e : dist) {
        cout << e << "\n";
    }

    cout << flush;
}

Measured memory_bytes: 23272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 2e5+10;
int a[N], b[N], tb[N];
vector<int> dat[2][N];
int cnt[N];
int ans[N];

void solve() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a+i);
        dat[0][a[i]].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", b+i);
        dat[1][b[i]].push_back(i);
    }

    for (int i = 1; i <= n; i++) {
        int m = dat[0][i].size()+dat[1][i].size();
        if (m > n) {
            printf("No\n");
            return ;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] == b[i]) {
            cnt[a[i]]++;
        }
    }
    int ma = 0, sum = 0;
    int index = 0;
    for (int i = 1; i <= n; i++) {
        if (cnt[i] > ma) {
            ma = cnt[i];
            index = i;
        }
        sum += cnt[i];
    }
    int left = max(0, 2*ma - sum);
    ma -= left;
    //cout << left << ' ' << index << ' ' << ma << endl;
    vector<int> vec1, vec2;
    for (int i = 1; i <= n && vec1.size() < left; i++) {
        if (a[i] == b[i] && a[i] == index) {
            vec1.push_back(i);
        }
    }
    for (int i = 1; i <= n && vec2.size() < left; i++) {
        if (a[i] != index && b[i] != index && a[i] != b[i]) {
            vec2.push_back(i);
        }
    }
    assert(vec1.size() == left);
    assert(vec2.size() == left);
    for (int i = 0; i < left; i++) {
        swap(b[vec1[i]], b[vec2[i]]);
    }
    // for (int i = 1; i <= n; i++) printf("%d%c", b[i], (i<n)?' ':'\n');

    vector<int> vec3;
    for (int i = 1; i <= n; i++) {
        if (a[i] == b[i]) {
            vec3.push_back(i);
        }
    }
    for (int i = 1; i <= n; i++) tb[i] = b[i];
    for (int i = 0; i < vec3.size(); i++) {
        b[vec3[i]] = tb[vec3[(i+ma)%vec3.size()]];
    }

    printf("Yes\n");
    for (int i = 1; i <= n; i++) printf("%d%c", b[i], (i<n)?' ':'\n');

}

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

Measured memory_bytes: 28844
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <ctype.h>
int main() {
	string s;
	cin >> s;
	int k = 0;
	cin >> k;
	for (int i = 0; i < s.length();++i) {
		if (s[i] == '1') {
			k--;
			if (k == 0) {
				cout << 1 << endl;
				return 0;
			}
		}
		else {
			cout << s[i] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int,input().split()))
    
    tmp = 0
    tmpans1 = 0
    for i in range(N):
        tmp += A[i]
        if i%2==0 and tmp<=0:
            tmpans1 += 1-tmp
            tmp = 1
        elif i%2==1 and tmp >= 0:
            tmpans1 += 1+tmp
            tmp = -1
    tmp = 0
    tmpans2 = 0
    for i in range(N):
        tmp += A[i]
        if i%2==0 and tmp>=0:
            tmpans2 += 1+tmp
            tmp = -1
        elif i%2==1 and tmp <= 0:
            tmpans2 += 1-tmp
            tmp = 1
    #print(tmpans1,tmpans2)
    print(min(tmpans1,tmpans2))
    
    
    
main()

Measured memory_bytes: 59248
bingo = [list(map(int, input().split())) for i in range(3)]
N = int(input())
number = [int(input()) for i in range(N)]

for el in number:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == el:
                bingo[i][j] = 0
flag = 0
for i in range(3):
    for j in range(3):
        if bingo[i][j] != 0:
            break
    else:
        flag = 1
        
for i in range(3):
    for j in range(3):
        if bingo[j][i] != 0:
            break
    else:
        flag = 1
    
if bingo[0][0] == 0:
    if bingo[1][1] == 0:
        if bingo[2][2] == 0:
            flag = 1
            
if bingo[0][2] == 0:
    if bingo[1][1] == 0:
        if bingo[2][0] == 0:
            flag = 1
            
if flag == 1:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 3064
//答えを見てから書き直し
#include<iostream>
using namespace std;
int main() {
  int a[7],b,count[5];
  for (int i=1;i<7;i=i+1) a[i]=0;
  for (int i=1;i<6;i=i+1) count[i]=0;
  
  //出てくる数字を保存する
for (int j=1;j<7;j=j+1) cin >> a[j];
  
  //出てくる数字の回数を数える
  for (int i=1;i<5;i=i+1) {
    for (int j=1;j<7;j=j+1) {
  if (i==a[j]) count[i]=count[i]+1;
  
    }
  }
  
  //出てくる回数の最大値を求める
  int max;
  max=0;
  for (int i=1;i<5;i=i+1) {
    if (max<count[i]) max=count[i]; 
  }
  
  
  if (max<3) cout <<"YES";
  else cout <<"NO";
  cout << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 1000005;
string s;
int a[MX], n;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(a, -1, sizeof(a));

	cin >> s;
	n = s.size();
	
	for (int i = 0; i < n; i++)
		if (s[i] == '<') {
			if (a[i] == -1)
				a[i] = 0;
			a[i+1] = a[i] + 1;
		}

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') {
			if (a[i+1] == -1)
				a[i+1] = 0;
			if (a[i] == -1 || a[i] <= a[i+1])
				a[i] = a[i+1] + 1;
		}
	}
	
	cout << accumulate(a, a+n+1, 0ll) << endl;

	return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll n,k;
      cin>>n>>k;
      if(k>=n)
      cout<<min(n,k-n);
      else
      {
        cout<<min(n%k,k - n%k);
      }
        
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    REP(i, tx-sx){
        ans += "R";
    }
    REP(i, ty-sy){
        ans += "U";
    }
    REP(i, tx-sx){
        ans += "L";
    }
    REP(i, ty-sy){
        ans += "D";
    }
    ans += "D";
    REP(i, tx-sx+1){
        ans += "R";
    }
    REP(i, ty-sy+1){
        ans += "U";
    }
    ans += "LU";
    REP(i, tx-sx+1){
        ans += "L";
    }
    REP(i, ty-sy+1){
        ans += "D";
    }
    ans += "R";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,m,c;cin >> n >> m >> c;
  int ans = 0;
  int b[m];
  rep(i,m) cin >> b[i];
  int a[n][m];
  rep(i,n){
    rep(j,m){
      cin >> a[i][j];
    }
  }
  rep(i,n){
    int s = c;
    rep(j,m){
      s+= a[i][j]*b[j];
    }
    if(s>0) ans++;
  }
  cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    for(int i=0; i<n; i++){
        cin >> L[i];
    }

    sort(L.begin(), L.end());
    int ans = 0;
    for(int l=0; l<n-2; l++){
        int r=n-2;
        int c=r+1;
        while(l<r){
            if(L[l]+L[r] > L[c]){
                while(L[l]+L[r] > L[c] and c<=n-1){
                    ans++;
                    c++;
                }
                r--;
                c = r+1;
                continue;
            }else{
                r--;
                c = r+1;
                continue;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np 
IN = lambda:map(int, input().split())
 
n, k = IN()
dp = np.zeros(k + 1)
 
for i in range(n):
    w, c = IN()
    dp[w:] = np.maximum(dp[w:], dp[:-w] + c)
    
print(int(dp[-1]))

Measured memory_bytes: 15476
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int H = input.nextInt();
		int A = input.nextInt();
		int K=H/A;
		
		if(H%A==0) {
			System.out.println(K);
		}
		else {
			System.out.println(K+1);
		}
	}

}


Measured memory_bytes: 23764
#include<stdio.h>
int main() {
	int x, y,temp;

	while (1) {
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0)break;

		if (x > y) {
			temp = y;
			y = x;
			x = temp;
		}
		printf("%d %d\n", x, y);
		
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while(cin>>n,n){  //,演算子、最後の式を評価
        vector<vector<int>> graph(10,vector<int>(10,99999999));
        int used[10]={0};
        for(int i=0;i<n;i++){
            int a,b,c;
            cin>>a>>b>>c;
            graph[a][b]=c;
            graph[b][a]=c;
            used[a]++;
            used[b]++;
        }
        for(int i=0;i<10;i++){
            if(used[i])
                graph[i][i]=0;
        }
        for(int k=0;k<10;k++){
            for(int i=0;i<10;i++){
                for(int j=0;j<10;j++){
                    if(graph[i][j]>graph[i][k]+graph[k][j])
                        graph[i][j]=graph[i][k]+graph[k][j];
                }
            }
        }
        int min=99999999;
        int minpos;
        for(int i=0;i<10;i++){
            if(used[i]==0) continue;
            int sum=0;
            for(int j=0;j<10;j++){
                if(used[j]>0){
                    sum+=graph[i][j];
                }
            }
            if(min>sum){
                min=sum;
                minpos=i;
            }
        }
        cout<<minpos<<" "<<min<<endl;
    }
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a,a+n+1);
    double half=a[n]/2;
    int x=lower_bound(a,a+n,half)-a;
    if(a[x]-half<=half-a[x-1] && n!=x)cout<<a[n]<<" "<<a[x]<<endl;
    else cout<<a[n]<<" "<<a[x-1]<<endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/02  Problem: 087_arc_b / Link: https://abc082.contest.atcoder.jp/tasks/arc087_b?lang=en  ----- */
/* ------問題------

二次元平面の原点にロボットが置かれています。 最初、ロボットは x 軸の正の向きを向いています。
このロボットに命令列 s が与えられます。 s は次の 2 文字のみからなり、先頭から末尾まで順に実行されます。

F : 今向いている向きに長さ 1 だけ移動する。
T : 時計回りまたは反時計回りの好きな方向に 90 度だけ向きを変える。
ロボットの目標は、命令列をすべて実行し終わった後に座標 (x,y) にいることです。 この目標が達成可能か判定してください。

-----問題ここまで----- */
/* -----解説等-----
列を成分ごとに分解するとこれは典型DP
dp(i,j):=i個終えたときに値jが存在する
負の値も存在するけどこれは下駄をはかせればよい。
----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s; cin >> s;
	int x, y;
	cin >> x >> y;
	VI xs(SZ(s)), ys(SZ(s));
	int xp = 0, yp = 0;
	int mode = 0;
	FOR(i, 0, SZ(s)) {

		if (mode == 0) {// x
			if (s[i] == 'T') { mode = 1; xp++; continue; }
			else {
				xs[xp]++;
			}
		}
		else {//y
			if (s[i] == 'T') { mode = 0; yp++; continue; }
			else {
				ys[yp]++;
			}

		}
	}
	if (mode == 0) {// x
		{ mode = 1; xp++; }
	}
	else {//y
		{ mode = 0; yp++; }
	}

	//FOR(i, 0, xp) {
	//	cout << xs[i] << " ";
	//}cout << endl;
	//FOR(i, 0, yp) {
	//	cout << ys[i] << " ";
	//}cout << endl;

	// dp
	vector<vector<bool>> dpx(8000, vector<bool>(20000));
	vector<vector<bool>> dpy(8000, vector<bool>(20000));
	dpx[0][xs[0] + 10000] = 1;
	dpy[0][ys[0] + 10000] = 1;
	dpy[0][-ys[0] + 10000] = 1;

	FOR(i, 0, xp) {
		FOR(j, 0, 20000) {//10000 base
			if (dpx[i][j]) {
				dpx[i + 1][j - xs[i + 1]] = 1;
				dpx[i + 1][j + xs[i + 1]] = 1;
			}
		}
	}
	FOR(i, 0, yp) {
		FOR(j, 0, 20000) {//10000 base
			if (dpy[i][j]) {
				dpy[i + 1][j - ys[i + 1]] = 1;
				dpy[i + 1][j + ys[i + 1]] = 1;
			}
		}
	}
	if (dpx[xp][10000 + x] && dpy[yp][10000 + y]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 40192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);
 
int main(){
    IOS;
    ll n,m;cin>>n>>m;
    ll a[n+1]={0};
    f(i,0,m){
        ll x;cin>>x;
        a[x]++;
    }
    ll dp[n+1]={0};
    dp[0]=1;
    f(i,0,n){
        f(j,i+1,min(i+2,n)+1){
            if(!a[j]){
                dp[j]+=dp[i];
                dp[j]%=mod;
            }
        }
    }
    cout<<dp[n];
    return 0;
}   

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
 
int main() {
   string n;cin >> n;
   int s = n.size();
  
   ll ans = 0;
   for(int bit = 0;bit < (1 << s-1);bit++) {
       ll a = n[0] - '0';
       rep(i, s-1) {
           ll j = n[i] - '0';
           if(bit & (1<<i)) {
               ans += a;
               a = n[i+1]- '0';
           }else {
               a = a *10 + (n[i+1]-'0');
           }
          
       }
       ans += a;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 400010
#define MOD 1000000007
#define INF 0x3FFFFFFF
using namespace std;
typedef long long ll;
ll c[MAXN],w[MAXN],col[MAXN];
ll n,x,y,cnt;
vector<ll> a[MAXN];
ll fac[MAXN],ifac[MAXN];
ll fsp(ll d,ll t){
	ll res=1;
	while(t){
		if(t&1ll)
			res=res*d%MOD;
		d=d*d%MOD;
		t>>=1ll;	
	}
	return res;
}
int main(){
	SF("%lld%lld%lld",&n,&x,&y);
	ll mminw=INF;
	int minc;
	for(ll i=1;i<=n;i++){
		SF("%lld%lld",&c[i],&w[i]);
		a[c[i]].push_back(i);
		if(w[i]<mminw){
			mminw=w[i];
			minc=c[i];	
		}
	}
	ll mminw1=INF;
	for(ll i=1;i<=n;i++){
		ll minw=INF;
		for(ll j=0;j<ll(a[i].size());j++)	
			minw=min(minw,w[a[i][j]]);
		for(ll j=0;j<ll(a[i].size());j++)
			if(w[a[i][j]]+minw<=x)
				w[a[i][j]]=minw;
		if(minc!=i)
			mminw1=min(mminw1,minw);
	}
	for(ll i=1;i<=n;i++){
		if(c[i]==minc){
			if(w[i]+mminw1<=y){
				col[c[i]]++;
				cnt++;	
			}
		}
		else if(w[i]+mminw<=y){
			col[c[i]]++;
			cnt++;
		}
	}
	fac[0]=1;
	for(ll i=1;i<=cnt;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[cnt]=fsp(fac[cnt],MOD-2);
	for(ll i=cnt;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
	ll ans=fac[cnt];
	for(ll i=1;i<=n;i++)
		ans=ans*ifac[col[i]]%MOD;
	PF("%lld",ans);
}

Measured memory_bytes: 28800
n = int(input())

clues = [tuple(map(int, input().split())) for i in range(n)]

sam_x, sam_y, sam_h = next((x, y, h) for x, y, h in clues if h > 0)

centers = [(x, y) for x in range(101) for y in range(101)]
for cx, cy in centers:
    ch = sam_h + abs(sam_x - cx) + abs(sam_y - cy)
    identified = True
    for x, y, h in clues:
        if h != max(ch - abs(x - cx) - abs(y - cy), 0):
            identified = False
            break
    if identified:
        print(cx, cy, ch)
        exit()

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

int main(){
	int a[4], b[4], hit, blow, n1[10], n2[10];

	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		hit = 0;
		blow = 0;
		for(int i=0 ; i<10 ; i++){
			n1[i] = 0;
			n2[i] = 0;
		}

		for(int i=0 ; i<4 ; i++){
			if(a[i]==b[i]) hit++;
			n1[ a[i] ] = 1;
			n2[ b[i] ] = 1;
		}
		for(int i=0 ; i<10 ; i++){
			if( n1[i]==n2[i] && n1[i]==1) blow++;
		}
		cout << hit << " " << blow-hit << endl;
	}
}

Measured memory_bytes: 3072
n=int(input())
a=list(map(int,input().split()))

mod=1000000007
ans=1
r,b,g=0,0,0
for i in a:
    if i==r and i==b and i==g:
        ans*=3
        ans%=mod
        r+=1
    elif (i==r and i==b) or (i==g and i==r):
        ans*=2
        ans%=mod
        r+=1
    elif i==b and i==g:
        ans*=2
        ans%=mod
        g+=1
    elif i==r:
        r+=1
    elif i==b:
        b+=1
    elif i==g:
        g+=1
    else:
        print(0)
        exit()
print(ans)

Measured memory_bytes: 14072
#include <cstdio>

int main() {
  int A, B, C;
  long long K;
  scanf("%d %d %d %lld", &A, &B, &C, &K)+1;

  if (K % 2) 
	printf("%d", B - A);
  else
    printf("%d", A - B);
  return 0;
}


Measured memory_bytes: 128
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	ll a;
  	cin >> a;
  	ll sum=100;
    ll ans=0;
  while(sum<a){
  		sum*=1.01;
    	ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll big = 1e9;

  ll N, K, S; cin >> N >> K >> S;
  vector<ll> A(N);
  if (S < big) {
    for (ll i = 0; i < K; i++) A.at(i) = S;
    for (ll i = K; i < N; i++) A.at(i) = big;
  }else if (N == K) {
    for (ll i = 0; i < N; i++) A.at(i) = S;
  }else if (K == 0) {
    for (ll i = 0; i < N; i++) A.at(i) = 1;
  }else {
    for (ll i = 0; i < K-1; i++) A.at(i) = S;
    ll x = S / (N-(K-1));
    for (ll i = K-1; i < N-1; i++) A.at(i) = x;
    A.at(N-1) = S - x * (N-K);
  }
  for (ll i = 0; i < N; i++) {
    if (i == 0) cout << A.at(i);
    else        cout << " " << A.at(i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  string S_ = S;
  while(1){
    bool end = true;
    for(int i=1;i<(int)S.size();i++){
      if(S[i-1]=='(' && S[i]==')'){
        S.erase(i-1,2);
        end = false;
      }
    }
    if(end) break;
  }
  //cout << S << endl;
  int countl=0,countr=0;
  if((int)S.size()!=0){
    rep(i,(int)S.size()){
      if(S[i]==')') countr++;
      if(S[i]=='(') countl++;
    }
  }
  string adda="",addb="";
  rep(i,countr) adda += '(';
  rep(i,countl) addb += ')';
  S = adda + S_ + addb;
  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String answer ="No";
    int qq[][] = new int[9][9];
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
        qq[i][j]=(i+1)*(j+1);
      }
    }
    
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){        
        if(N==qq[i][j]){
          answer ="Yes";
        }
      }
    }
    System.out.println(answer);
      
      
    
    
    
  }
  

  
}

Measured memory_bytes: 23124
H,W = map(int,input().split(" "))
table = []
for i in range(H):
  table.append(list(input()))
row = [False]*H
col = [False]*W
for i in range(H):
  for j in range(W):
    if table[i][j] == "#":
      row[i] = True
      col[j] = True
for i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        print(table[i][j],end='')
    print()

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i, j, k) for (int i = j; i <= k; ++i)
#define per(i, j, k) for (int i = j; i >= k; --i)
#define int long long
using namespace std;

const int N = 1000001;
int a[N], sum[N];

inline int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}

int Abs(int x) {return x < 0 ? -x : x;}

signed main() {
	int n = read();
	rep(i, 1, n) {
		a[i] = read();
		sum[i] = sum[i - 1] + a[i];
	}
	int ans = 1e18, s1 = a[1], s2 = a[2], s3 = a[3], s4 = sum[n] - sum[3], l = 2, r = 4;
	rep(i, 3, n) {
		while (l < i && Abs(s1 - s2) > Abs(s1 + a[l] - s2 + a[l])) {
			s1 += a[l];
			s2 -= a[l];
			l++;
		}
		while (r <= n && Abs (s3 - s4) > Abs(s3 + a[r] - s4 + a[r])) {
			s3 += a[r];
			s4 -= a[r];
			r++;
		}
		int mn = min(s1, min(s2, min(s3, s4)));
		int mx = max(s1, max(s2, max(s3, s4)));
		ans = min(ans, mx - mn);
		s2 += a[i];
		s3 -= a[i];
//		printf("%d %d %d %d %d %d %d\n", s1, s2, s3, s4, mn, mx, ans);
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
 int a,b,c;
  cin>>a>>b>>c;
  bool flag=false;
  
  if((a+b)==c)flag=true;
  if((b+c)==a)flag=true;
  if((c+a)==b)flag=true;
  
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
  int D;
  scanf("%d",&D);
  switch(D){
    case 22:
      printf("Christmas Eve Eve Eve\n");
      break;
    case 23:
      printf("Christmas Eve Eve\n");
      break;
    case 24:
      printf("Christmas Eve\n");
      break;
    case 25:
      printf("Christmas\n");
      break;
  }

  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
constexpr long long modPow(long long n, long long p, const int mod = int(1e9)+7)
{
    long long ret = 1;
    while(p) {
        if (p & 1) ret = (ret * n) % mod;
        n = (n * n) % mod;
        p >>= 1;
    }
    return ret;
}

template<int MOD> class ModInt {
private:
    long long n;
    using T = ModInt<MOD>;
public:
    static constexpr const int mod = MOD;
    constexpr inline ModInt(long long n_) : n(n_ % MOD) {}
    template<class Int> constexpr explicit inline operator Int() const { return n; }
    friend ostream& operator<<(ostream &os, T m) { os << m.n; return os; }
    constexpr inline T operator~() const { return modPow(n, MOD-2, MOD); }
    constexpr inline T& operator+=(T o) { n = (n + o.n) % MOD; return *this; }
    constexpr inline T& operator-=(T o) { n = (n - o.n + MOD) % MOD; return *this; }
    constexpr inline T& operator*=(T o) { n = (n * o.n) % MOD; return *this; }
    constexpr inline T& operator/=(T o) { n = (n * (~o).n) % MOD; return *this; }
};
using Mint = ModInt<int(1e9)+7>;
Mint operator+(Mint a, Mint b) { return Mint(a) += b; }
Mint operator-(Mint a, Mint b) { return Mint(a) -= b; }
Mint operator*(Mint a, Mint b) { return Mint(a) *= b; }
Mint operator/(Mint a, Mint b) { return Mint(a) /= b; }

template<size_t N, int MOD=int(1e9)+7> struct Factrial {
    using Mint = ModInt<MOD>;
    long long a[N+1];

#ifdef YDK
    inline Factrial() : a{1} { for (int i = 1; i <= N; ++i) a[i] = (a[i-1] * i) % MOD; }
#else
    constexpr inline Factrial() : a{1} { for (int i = 1; i <= N; ++i) a[i] = (a[i-1] * i) % MOD; }
#endif

    constexpr inline Mint operator[] (size_t i) const { return a[i]; }
};

Factrial<3010> fact;

Mint nCr(int n, int r) { return (r < 0 || n < r) ? 0 : (fact[n] / (fact[r] * fact[n-r])); }

Mint nPr(int n, int r) { return (r < 0 || n < r) ? 0 : (fact[n] / fact[r]); }

Mint nHr(int n, int r) { return nCr(n+r-1, r); }
// }}}


signed main()
{
    int N, B, R;
    cin >> N >> B;

    R = N - B;

    for (int i = 1; i <= B; ++i) {
        cout << nCr(R+1, i) * nCr(B-1, i-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int A1 = sc.nextInt();
            int A2 = sc.nextInt();
            int A3 = sc.nextInt();

            if (A1 + A2 + A3 >= 22) {
                System.out.println("bust");
            } else {
                System.out.println("win");
            }
        }
    }

}


Measured memory_bytes: 23764
import java.util.Scanner;

// 素数系
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] arr = new long[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        long res = 0;
        for(int j = 0; j < N; j++) {
            long tmp = 0;
            while(arr[j] % 2 == 0) {
                tmp++;
                arr[j] /= 2;

            }
            res += tmp;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 36120
#include <iostream>
using namespace std;
int x,y;
int main(){
    cin>>x>>y;
    int ans=0;
    if(x<=3)ans+=(4-x)*100000;
    if(y<=3)ans+=(4-y)*100000;
    if(x==1&&y==1)ans+=400000;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    string s;
    cin >> s;

    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < alphabet.size(); i++)
    {
        bool isExist = false;
        for (int j = 0; j < s.size(); j++)
        {
            if (s[j] == alphabet[i])
            {
                isExist = true;
                continue;
            }
        }
        
        if (!isExist)
        {
            cout << alphabet[i] << endl;
            return 0;
        }
    }
    
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512