akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
l=list(input())
l=l[::-1]
now=0
ans=[]
while now<n:
  num=min(n-now,m)#進める最大
  b=True
  for i in range(num):
    num1=num-i
    if l[now+num1]!="1":
      ans.append(str(num1))
      now+=num1
      b=False
      break
  if b:
    now=n+1
if b:
  print(-1)
else:
  ans=ans[::-1]
  print(" ".join(ans))

Measured memory_bytes: 11080
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


x, y = map(int, input().split())
if y > 4*x or  2*x >y:
        print("No")
elif (4*x - y) % 2 == 0:
        print("Yes")
else:
        print("No")

Measured memory_bytes: 9104
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=500100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,i,f[N],ps[N],ans;
int main(){
	n=read();ans=n;
	for(i=1;i<=n;i++)ps[read()]=i;
	for(i=n;i;i--){
		f[i]=ps[i+1]>ps[i]?f[i+1]+1:1;
		ans=min(ans,n-f[i]);
	}printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, y, i, j, k;
     cin >> n >>y;
     for(i=0;i<=n;i++){
         for(j=0;j<=n;j++){
             k=n-i-j;
             if(k>=0 && 1000*i+5000*j+10000*k==y){
                 cout << k << " " << j << " " << i <<endl;
                 return 0;
             }
         }
     }
     cout << -1 << " " << -1 << " " << -1 <<endl;
     return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	bool yes=true;
	for(int i=0,nwt=0,nwp=0;i<n;++i){
		int t,x,y; cin>>t>>x>>y;
		int cos=abs(t-nwt),dis=abs(x+y-nwp);
		if(dis>cos||(cos+dis)&1)yes=false;
		nwt=t,nwp=x+y;
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

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

int main() {
    int N, K, a, b, t, c = 0;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; i++) {
        cin >> t;
        a = t * 2;
        if (t > K) {
            b = (t - K) * 2;
        }
        else if (t < K) {
            b = (K - t) * 2;
        }
        c += a < b ? a : b;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

const int N_MAX = 300007;
int n, p[N_MAX];
struct FenwickTree {
  int sum[N_MAX];
  void modify(int x) {
    while (x <= n)
      ++sum[x], x += x & -x;
  }
  int query(int x) {
    int ret = 0;
    while (x)
      ret += sum[x], x -= x & -x;
    return ret;
  }
}bit[3];

int main() {
  
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &p[i]);
  
  bool flag = 1;
  long long I[3] = {0, 0, 0};
  for (int i = n; i; --i) {
    flag &= (i & 1) == (p[i] & 1);
    I[i & 1] += bit[i & 1].query(p[i]);
    I[2] += bit[2].query(p[i]);
    bit[i & 1].modify(p[i]);
    bit[2].modify(p[i]);
  }
  printf(flag && (I[0] + I[1]) * 3 == I[2] ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
void file() {
    freopen("read.in", "r", stdin);
    freopen("write.out", "w", stdout);
}
const int N = 500010;
inline int read() {
    int sym = 0, res = 0;char ch = getchar();
    while (!isdigit(ch)) sym |= (ch == '-'), ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    return sym ? -res : res;
}
int n, m, ans, minn=1<<30, a[N];
int main() {
    n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) {
        if (a[i] < minn) ans++, minn = a[i];
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
		if(x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	priority_queue<int> Q;
	vector<int> A;
	vector<int> nyu;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		A.push_back(a);
		nyu.push_back(a);
	}
	sort(A.begin(), A.end());
	for (auto o : nyu)
	{
		cout << (o == A[A.size()-1]?A[A.size()-2] : A[A.size()-1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3436
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-07 20:54:16
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    sort(all(a));

    int max = a[n-1];
    int f = max/2;
    int c = ceil((float)max/2);
    int min_gap = max;
    int r;
    for (int i = 0; i < n; i++) {
        int gap = min((abs)(a[i] - f), (abs)(a[i] - c));
        if (gap < min_gap) {
            min_gap = gap;
            r = a[i];
        }
    }

    cout << max << " " << r << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    for(int i=0;i<H;++i)cin>>S[i];
    vector<string> T(H);
    for(int i=0;i<H;++i)
        for(int j=0;j<W;++j) T[i]+='0';
    for(int i=0;i<H;++i)
        for(int j=0;j<W;++j){
            if(S[i][j]=='#'){
                T[i][j]='#';
                for(int k=-1;k<2;++k)
                    for(int l=-1;l<2;++l){
                        if(i+k<0 || H<=i+k || j+l<0 || W<=j+l || (k==0&&l==0) || T[i+k][j+l]=='#') continue;
                        T[i+k][j+l]++;
                    }
            }
        }
    for(int i=0;i<H;++i) cout<<T[i]<<endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(void) {
	int N;
	int four = 0;
	int two = 0;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		if (t % 2 == 0) {
			if (t % 4 == 0)
				four++;
			else
				two++;
		}
	}
	//cout << two << " " << four << endl;
	if (two % 2 == 1)  two--;
	if ((N - two)/2 <=  four)
		cout << "Yes\n";
	else
		cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define srep(i,j,n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi; 
const ll inf = 1001001001;
const int V = 100*1000+1;
ll dp[101][V];

int main(){
    int N,W;
    
    cin >> N >> W;
    vector<ll> w(N),v(N);
    rep(i,N){
        cin >> w[i] >> v[i];
    }

    rep(i,101) rep(j,V) dp[i][j] = inf;

    dp[0][0] = 0;

    rep(i,N){
        rep(j,V){
            if(j-v[i] >=0)
                dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        }
    }
    ll ans = 0;
    rep(v,V){
        if(dp[N][v]<=W) ans = v;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 79104
# BinaryHeapの優先度付きキュー MinPriorityQueue
# #enq(obj,priority), #deq, #peek, #size, #empty?
class PQueue
  Node = Struct.new(:value, :priority)
  def initialize
    @heap = []
  end
  def size; @heap.size; end
  def empty?; @heap.empty?; end
  def peek; empty? ? nil : @heap[0].value; end
  def enq(value, priority)
    el = Node.new(value, priority)
    j = @heap.size
    @heap << nil
    while j > 0
      up = (j - 1) / 2
      break if @heap[up].priority < el.priority
      @heap[j] = @heap[up]
      j = up
    end
    @heap[j] = el
    self
  end
  def deq
    return nil if empty?
    return @heap.shift.value if size == 1
    
    ret = @heap[0]
    @heap[0] = nil
    el = @heap.pop
    
    i = 0
    while 2 * i + 1 < @heap.size
      l = 2 * i + 1
      r = 2 * i + 2
      j = (r == @heap.size || @heap[l].priority <= @heap[r].priority) ? l : r
      break if el.priority <= @heap[j].priority
      @heap[i] = @heap[j]
      i = j
    end
    @heap[i] = el
    return ret.value
  end
end
def min(a,b); a < b ? a : b; end

N = gets.to_i
A = gets.split.map(&:to_i).sort.reverse
pq = PQueue.new
a_max = A.shift
score = 0
pq.enq([a_max, a_max], 0)
until A.empty?
  a = A.shift
  l,r = pq.deq
  score += min(l,r)
  pq.enq([l,a], -min(l,a))
  pq.enq([a,r], -min(a,r))
end
puts score





Measured memory_bytes: 45008
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    std::ios::sync_with_stdio(0);
    int n,W;cin>>n>>W;
    int wt[n],val[n];
    for(int i=0;i<n;i++){
        cin>>wt[i];
        cin>>val[i];
    }
    /*
    int dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
        if(j==0 || i==0)dp[i][j]=0;
        else if (w[i-1] <= w)
                 dp[i][j] = max(v[i-1] + dp[i-1][j-w[i-1]],  dp[i-1][j]);
        else
                 dp[i][j] = dp[i-1][j];
       }
        //    dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
        }*/

   int K[n+1][W+1];
   for (int i = 0; i <= n; i++)
   {
       for (int w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }


    cout<<K[n][W];

return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <string.h>
#define N 36

int main(){
    int i, j, stability = 1, num, mini_j;
    char array_bub[N][3], array_sec[N][3], tmp[3];

    //input area
    scanf("%d", &num);
    for (i = 0; i<num; i++){
	scanf("%s", array_bub[i]);
	strcpy(array_sec[i], array_bub[i]);
    }

    //bubble sort area
    for (i = 0; i < num; i++){
	for (j = num-1; j >= i+1; j--){
	    if (array_bub[j-1][1] > array_bub[j][1]){
		//exchange value
		strcpy(tmp, array_bub[j]);
		strcpy(array_bub[j], array_bub[j-1]);
		strcpy(array_bub[j-1], tmp);
	    }
	}
    }

    //selection sort area
    for (i = 0; i < num; i++){
	mini_j = i;
	//find smallest value
	for (j = i+1; j < num; j++){
	    if (array_sec[j][1] < array_sec[mini_j][1])
		mini_j = j;
	}
	//exchange the values
	if (mini_j != i){
	    strcpy(tmp, array_sec[i]);
	    strcpy(array_sec[i], array_sec[mini_j]);
	    strcpy(array_sec[mini_j], tmp);
	}
    }

    //compare the results of bubble-sort and selection-sort
    for (i = 0; i < num; i++){
	if (strcmp(array_sec[i], array_bub[i]) != 0)
	    stability = 0;
    }

    //-----display area-----
    //bubble sort
    for (i = 0; i < num; i++){
	printf("%s", array_bub[i]);
	if (i < num-1)
	    printf(" ");
    }
    printf("\nStable\n");

    //selection sort
    for (i = 0; i < num; i++){
	printf("%s", array_sec[i]);
	if (i < num-1)
	    printf(" ");
    }
    if (stability == 1)
	printf("\nStable\n");
    else
	printf("\nNot stable\n");

    return 0;
}



Measured memory_bytes: 2100
#include<string>
#include<iostream>
using namespace std;
string s;
int main()
{
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<s.length();j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
open Batteries
open BatPervasives
open Printf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> BatString.split_on_char ' '
  |> List.map cnv

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let (n, k) = scan "%d %d" BatTuple.Tuple2.make
let ps = scan_list float_of_string

let exp n = n *. (n +. 1.0) /. 2.0 /. n

let hold_max (m, p) (x, y) =
  let n = p -. x +. y in
  (BatFloat.max m n, n)

let () =
  let sums = List.map exp ps in
  let init = BatList.fsum @@ BatList.take k sums in
  BatList.fold_left hold_max (init, init) (zip sums @@ BatList.drop k sums)
  |> BatTuple.Tuple2.first
  |> printf "%f\n"


Measured memory_bytes: 37120
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        char c;
        vector<int> len(10);
        for(int i=0; i<10; ++i){
            if(!(cin >> len[i] >> c))
                return 0;
        }
        int v1, v2;
        cin >> v1 >> c >> v2;

        int sumLen = accumulate(len.begin(), len.end(), 0);
        int tmp = 0;
        for(int i=0; i<10; ++i){
            tmp += len[i];
            if(sumLen * v1 <= tmp * (v1 + v2)){
                cout << (i+1) << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  long N,tmp;
  int a[100005];
  fill_n(a,100005,0);
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> tmp;
    ++a[tmp+1];
    ++a[tmp];
    ++a[tmp+2];
  }
  sort(a,a+100005,greater<int>());
  cout << a[0] << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>                                                
#include<cstdio>                                                   
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<cctype>
#include<sstream>
#include<queue>
using namespace std;


int main()
{
	int n;
	cin >> n;
	int a, b, c;
	a = n / 100;
	b = (n / 10) % 10;
	c = n % 10;
	if (a == 1)
		a = 9;
	else if (a == 9)
		a = 1;
	if (b == 1)
		b = 9;
	else if (b == 9)
		b = 1;
	if (c == 1)
		c = 9;
	else if (c == 9)
		c = 1;
	cout << a << b << c << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
// #define int cpp_int
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
cpp_int dp[1000005],mod=(long)1e9+7;
inline void solve(void){
  long N,M;
  in(N,M);
  long a;
  rep(i,M){
    in(a);
    dp[a]=-1;
  }
  if(dp[1]==-1&&dp[2]==-1){
    out(0);
    return;
  }
  dp[1]=dp[1]!=-1?1:-1;
  if(dp[2]!=-1&&dp[1]!=-1)dp[2]=2;
  else if(dp[1]==-1)dp[2]=1;
  up(i,3,N){
    if(dp[i]==-1)continue;
    if(dp[i-1]!=-1)dp[i]+=dp[i-1],dp[i]%=mod;
    if(dp[i-2]!=-1)dp[i]+=dp[i-2],dp[i]%=mod;
  }
  out(dp[N]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 31488
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto a = readNums!int;
  foreach(i; 0 .. (2*a[0]-2)){
    write(i + a[1]-a[0]+1, " ");
  }

  writeln(a[1]+a[0]-1);
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())
X=list(map(int,input().split()))

start=X[0]
cost=0
for i in range(len(X)):
    goto=X[i]
    if((goto-start)*A>B):
        cost+=B
    else:
        cost+=(goto-start)*A
    start=goto

print(cost)

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(begin(a), end(a));
    vector<int> ans;
    for(int i = 0; i < min(10, n); ++i) {
        for(int j = 0; j < min(10, n); ++j) {
            if(i == j) continue;
            ans.push_back(stoi(to_string(a[i]) + to_string(a[j])));
        }
    }
    sort(begin(ans), end(ans));
    cout << ans[2] << endl;
}



Measured memory_bytes: 3208
A,B,C,D = list(input().strip())
if int(A)+int(B)+int(C)+int(D) == 7:
    print(A+"+"+B+"+"+C+"+"+D+"=7")
elif int(A)+int(B)+int(C)-int(D) == 7:
    print(A+"+"+B+"+"+C+"-"+D+"=7")
elif int(A)+int(B)-int(C)+int(D) == 7:
    print(A+"+"+B+"-"+C+"+"+D+"=7")
elif int(A)+int(B)-int(C)-int(D) == 7:
    print(A+"+"+B+"-"+C+"-"+D+"=7")
elif int(A)-int(B)+int(C)+int(D) == 7:
    print(A+"-"+B+"+"+C+"+"+D+"=7")
elif int(A)-int(B)+int(C)-int(D) == 7:
    print(A+"-"+B+"+"+C+"-"+D+"=7")
elif int(A)-int(B)-int(C)+int(D) == 7:
    print(A+"-"+B+"-"+C+"+"+D+"=7")
elif int(A)-int(B)-int(C)-int(D) == 7:
    print(A+"-"+B+"-"+C+"-"+D+"=7")


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

int main(){
  int n;cin>>n;
  vector<pair<int,int>> a;
  rep(i,n){
    int st;cin>>st;
    a.push_back(make_pair(st,i+1));
  }
  sort(a.begin(),a.end());
  rep(i,n){
    printf("%d ",a[i].second);
  }
  return 0;

}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> table(2,vector<int>(n));
  for(int i=0;i<2;i++)for(int j=0;j<n;j++)cin >> table.at(i).at(j);

  int high = 0,low = 0;
  for(int i=0;i<n;i++){
    high += table.at(0).at(i);
    low = max(low,high)+table.at(1).at(i);
  }
  cout << max(high+table.at(1).at(n-1),low)  << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int a[110];
int main(){
	ll x,y,z,w;
	scanf("%lld%lld%lld%lld",&x,&y,&z,&w);
	rep(i,x,y)a[i]++;
	rep(i,z,w)a[i]++;
	ll ans=0;
	rep(i,0,105)if(a[i]==2)ans++;
	printf("%lld",ans);
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    rep(i, b) cout << a;
  }
  else {
    rep(i, a) cout << b;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3564
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
int n,m;
int dp[233][233];
int main(){
	scanf("%d",&n);
	rep(i,1,n)
		rep(j,i+1,n)
			dp[i][j]=1;
	if(n&1){
	m=n*(n-1)/2;
	rep(i,1,n/2)
		dp[i][n-i]=0,--m;
	printf("%d\n",m);
	rep(i,1,n)
		rep(j,1,n)
			if(dp[i][j])
				printf("%d %d\n",i,j);
	return 0;
	}
	else{
		m=n*(n-1)/2;
	rep(i,1,n/2)
		dp[i][n+1-i]=0,--m;
	printf("%d\n",m);
	rep(i,1,n)
		rep(j,1,n)
			if(dp[i][j])
				printf("%d %d\n",i,j);
	return 0;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n;
int k;
cin>>n>>k;
int u=1000000;
int a[n];
for(int i=0;i<n;i++){
         cin>>a[i];
}
long long int b[n];
int r=0;
for(int i=0;(i+k)-1<n;i++){
           b[i]=abs(a[(i+k)-1]-a[i]);
           b[i]+=min(abs(a[i]),abs(a[(i+k)-1]));
           r=i;
}

sort(b,b+(r+1));
cout<<b[0];
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll sum = 0;
    rep(i,N){
        sum += A[i];
    }
    vector<ll> divisors(0);
    for (ll i = 1; i * i <= sum; i++){
        if (sum % i == 0){
            divisors.push_back(i);
            divisors.push_back(sum / i);
        }
    }
    sort(all(divisors));
    ll len = divisors.size();
    ll ans = 1;
    rep(i,len){
        ll ans_sub = 0;
        vector<ll> count(0);
        rep(j,N){
            ll count_sub = divisors[i] - A[j] % divisors[i];
            count.push_back(count_sub);
        }
        sort(all(count));
        vector<ll> count_sum(N);
        vector<ll> count_sum_reverse(N);
        count_sum[0] = count[0];
        rep(j,N - 1){
            count_sum[j + 1] = count_sum[j] + count[j + 1];
        }
        count_sum_reverse[N - 1] = divisors[i] - count[N - 1];
        rep(j,N - 1){
            count_sum_reverse[N - 2 - j] = count_sum_reverse[N - 1 - j] + (divisors[i] - count[N - 2 - j]);
        }
        /*rep(j,N){
            cout << count_sum[j] << " ";
        }
        cout << endl;
        rep(j,N){
            cout << count_sum_reverse[j] << " ";
        }
        cout << endl;*/
        rep(j,N - 1){
            if (count_sum[j] == count_sum_reverse[j + 1]) ans_sub = count_sum[j];
        }
        if (ans_sub <= K) ans = max(ans, divisors[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
using namespace std;

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double sum = w*h;
  sum = sum/2.0;
  int flag = 0;
  if (x*2 == w && y*2 == h) flag = 1;
  cout << fixed;
  cout << setprecision(10) << sum << " " << flag << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/
int a[1100][1100] = {};

int main()
{
	int n;
	while (cin >> n&&n)
	{
		memset(a, 0, sizeof a);
		int x, y;
		x = n / 2 + 1; y = n / 2 + 2;
		for (int i = 1; i <= n*n; i++)
		{
			while (1)
			{
				int X = x, Y = y;
				if (y > n)y = 1;
				if (x > n)x = 1;
				if (x < 1)x = n;
				if (a[y][x] != 0)
				{
					y++; x--;
				}
				if (X == x&&Y == y)break;
			}
			a[y][x] = i;
			x++; y++;
			
		}
		for (int i = 1; i <= n; i++)
		{
			for (int l = 1; l <= n; l++)
			{
				printf("%4d", a[i][l]);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        if (n >= 10) {
                cout << r << endl;
        } else {
                cout << r + 100 * (10 - n) << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    cout << 1000 * ((a + 999) / 1000) - a << '\n';
    return 0;
}


Measured memory_bytes: 3640
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    string n; cin >> n;
    ll ans = 0;
    rep(i,n.size()){
        ans += n[i] - '0';
    }
    cout << (ans%9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,num,x[100001];
int main()
{
    cin>>n>>k;
    for (int i=0;i<n;i++) cin>>x[i];
    if (n==1)
	{
        cout<<x[0];
        return 0;
    }
	ll ans=9999999999999;
    for (ll i=0;i<n-k+1;i++)
	{
        ll left=abs(x[i])+abs(x[i+k-1]-x[i]);
        ll right=abs(x[i+k-1])+abs(x[i]-x[i+k-1]);
        ans=min(ans,left);
        ans=min(ans,right);
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int r = sc.nextInt();
            int D = sc.nextInt();
            int x = sc.nextInt();
            int z = r * x - D;
        	System.out.println(z);
            for(int i = 1; i < 10; i++){
              int sab = r * z - D;
              z = sab;
              System.out.println(sab);
            }
          }
}

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

void solve(){
  string a, b; cin >> a >> b;
  int an = a.size(), bn = b.size();
  if(an < bn){
    cout << "LESS\n";
    return;
  }
  else if(an > bn){
    cout << "GREATER\n";
    return;
  }
  for(int i = 0; i < an; i++){
    if(a[i] < b[i]){
      cout << "LESS\n";
      return;
    }
    else if(a[i] > b[i]){
      cout << "GREATER\n";
      return;
    }
  }
  cout << "EQUAL\n";
  return;
}

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


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

using namespace std;


int main(){
    
    int N;
    cin >> N;
    vector<long int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    long int sum = 0;
    int zero = 0;
    long int mi = 1000000000;
    
    for (int i = 0; i < N-1; i++) {
        if (A[i] < 0) {
            A[i] = -1*A[i];
            sum += A[i];
            mi = min(mi, A[i]);
            A[i+1] = -1*A[i+1];
        }else if(A[i] == 0){
            zero = 1;
        }else{
            sum += A[i];
            
            mi = min(mi, A[i]);
        }
        
    }

    if (A[N-1] >= 0) {
        
        sum += A[N-1];
        
    }else{
        
        if (zero == 1) {
            sum -= A[N-1];
        }else{
            mi = min(mi, -A[N-1]);
            A[N-1] = -1*A[N-1];
            sum = sum + A[N-1] - 2*mi;
        }
        
    }
    
    
    
    cout << sum << endl;
    
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n,x,i,j,k,iCount;
    
    while(1){
        cin >> n >> x;
        
        iCount=0;
        if (n==0 && x==0){
            break;
        }
        for (i=1;i<n;i++){
            for (j=i+1;j<n;j++){
                k=x-i-j;
                if (k>j && k<=n){
                    iCount+=1;    
                }
            }
        }
        cout << iCount <<endl;
    }
}


Measured memory_bytes: 3104
import sys

N,M,X,Y=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()

for Z in range(X+1,Y+1,1):
	if x[-1]<Z and y[0]>=Z:
		print("No War")
		sys.exit()

print("War")



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

int main(){
	string s;
	cin >> s;
	int j = 0;
	int res, cnt;
	res = 0;
	cnt = 0;
	for(int i=j; i<s.length(); i=j){
		cnt = 0;
		while(j!=s.length()){
			if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T'){
				cnt++;
				j++;
				continue;
			}else{
				j++;
				break;
			}
		}
		if(cnt > res){
			res = cnt;
		}
	}
	cout << res << endl;
}


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

judge = 0
counter = 0
list = []
while judge == 0:
	if N % 2 == 0:
		list.append(0)
		a = 0
	else:
		list.append(1)
		a = 1
	N -= a
	N = N //(-2)
	if N == 0:
		judge = 1
list.reverse()
for i in list:
	print(i,end="")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <string>
#include <queue>
#include <cstring>
#include <cmath>

using namespace std;

namespace fastinput
{
	/** Interface */

	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);

	/** Read */

	static const int buf_size = 16384;

	inline int getChar() {
		static char buf[buf_size];
		static int len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static int write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

const int N = 1e5;
int a[N];

int main()
{
	::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n = readInt();
	for (int i = 0; i < n; ++i)
		a[i] = readInt(),
		--a[i];
	int ans = 0;
	for (int i = 0; i < n; ++i)
		if (a[a[i]] == i)
			++ans;
	cout << ans / 2 << endl;
	
	return 0;
}

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

int dp(vector<int>& h, vector<int>& mem, int n) {

    if(n == 0 || n == 1) {
        mem[n] = abs(h[n] - h[0]);
        return mem[n];
    }
    int x = mem[n-1] > -1 ? mem[n-1] : dp(h, mem, n-1);
    int y = mem[n-2] > -1 ? mem[n-2] : dp(h, mem, n-2);
    mem[n] = min(x + abs(h[n]-h[n-1]), y + abs(h[n]-h[n-2]));
    return mem[n];

}

int main() {
    int n;
    cin >> n;
    vector<int> height(n, 0);
    vector<int> mem(n, -1);
    for(int i = 0; i < n; i++) {
        cin >> height[i];
    }
    dp(height, mem, n-1);
    cout << mem[n-1];

    return 0;
} 

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <climits>
using namespace std;

typedef pair<int,int> P;

int n, m;
int dp[102];
vector<P> v;

void solve(){
  for(int i = 0; i < 102; i++){
    dp[i] = INT_MAX;
  }

  dp[0] = 0;

  for(int i = 0; i < n; i++){
    if(dp[i] == INT_MAX) continue;

    for(int j = 0; j < m; j++){
      if(v[j].first <= i && i <= v[j].second){
        int idx = v[j].second + 1;
        dp[idx] = min(dp[idx], dp[i] + 1);
      }
    }
  }

  if(dp[n] == INT_MAX){
    cout << "Impossible\n";
  }
  else{
    cout << dp[n] << endl;
  }
}

int main(){
  while(cin >> n >> m){
    v.clear();

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      v.push_back(P(a - 1, b - 1));
    }

    solve();
  }
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    if(a >= 3200) {
      System.out.print(s);
    } else {
      System.out.print("red");
    }
  }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for (int i = 1; i < n; i++)

int main() {
  int n;
  cin >> n;
  vector<int> ans(10001);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int calc = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
        if (calc <= 10000) ans[calc]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 3720
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	x := readInt64()
	y := readInt64()

	a := calc(x, y)
	b := calc(-x, y) + 1
	c := calc(x, -y) + 1
	d := calc(-x, -y) + 2
	println(min(a, min(b, min(c, d))))
}

func calc(x, y int64) int64 {
	if x <= y {
		return y - x
	}
	return math.MaxInt32
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// -----------------------------------------------------------------------------


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    cout << (char)((s[i] - 'A' + n) % 26 + 'A');
  }
  cout << "\n";
  return 0;
}

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

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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int n = read<int>();
	int a = read<int>(), b = read<int>();
	int c = read<int>();
	int d[n];
	rep(i,n){
		d[i]=read<int>();
	}
	sort(d,d+n,greater<int>());
	
	int cal = c, price = a;
	int ans = cal / price;
	rep(i,n){
		cal += d[i];
		price += b;
		ans = max(ans, cal / price);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}






int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    char a;
    cin >> a;
    if(isupper(a)){
        cout << 'A' << endl; 
        return 0;
    }else{
        cout << 'a' << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    string w; cin >> w;
    vector<int> v(27, 0);
    for (int i = 0; i < w.size(); i++)
    {
        v[w[i] - 'a']++;
    }

    for(int i: v){
        if(i%2==1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
a,b,c,x = 4.times.map { gets.to_i}
cnt = 0
  (0..a).each do |i|
    (0..b).each do |j|
      (0..c).each do |k|
        cnt += 1 if i * 500 + j * 100 + k * 50 == x
      end
    end
  end
puts cnt

Measured memory_bytes: 1788
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
    string S;
    cin>>S;
    int counter;
    counter=0;
    for(int i=0;i<S.size()/2;i++){
        if(S.at(i)!=S.at(S.size()-1-i)) counter++;
    }
    cout<<counter<<endl;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e9;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main(){
    //freopen("input00.txt","r",stdin);
    ll T = 1;
    //cin>>T;
    while(T--){
       ll n,a,b;
       cin>>n>>a>>b;
       ll ans = (n/(a+b))*a;
       ans += min( n%(a+b) , a );
       cout << ans << endl; 
    }
    return 0;
}

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

const int MOD = 1e9 + 7;

int main() {
    ll s; cin >> s;
    vector<int> dp(s + 1, 0);
    dp[s] = 1;
    for (int i = s; i >= 0; i--) {
        for (int j = i - 3; j >= 0; j--) {
            dp[j] += dp[i];
            dp[j] %= MOD;
        }
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int main()
{
  int i,j=0,k;
  int key;
  int A[100];
  int ans,num=0;

  scanf("%d",&num);
  for(i=0;i<num;i++)
    {
      ans=scanf("%d",&A[i]);
    }

  for(i=0;i<num;i++)
    {
      key=A[i];
      j=i-1;
      while(j>= 0 && A[j]>key)
	{
	  A[j+1] = A[j];
	  j--;
	  A[j+1] = key;
	}
      for(k=0;k<num;k++)
	{
	  if(k==num-1) printf("%d",A[k]);
	  else printf("%d ",A[k]);
	}
      printf("\n");
    } 
return 0;
}

Measured memory_bytes: 604
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    private int[] a;

    AtCoder(FastScanner sc) {
        a = new int[3];
        a = IntStream.range(0, 3).map(i -> sc.nextInt()).toArray();
    }

    void solve(PrintWriter out) {
        if (a[0] + a[1] + a[2] <= 21) {
            out.println("win");
        } else {
            out.println("bust");
        }
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 28500