akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    int i, j, k, sum;
    int month[12] = {0,31,29,31,30,31,30,31,31,30,31,30};
    while(1){
        sum = 0;
        scanf("%d %d",&i,&j);
        if(i == 0)break;
        for(k = 0;k < i;k++){
            sum = sum + month[k];
        }
        sum = sum + j;
        if(sum % 7 == 1){
            printf("Thursday\n");
        }
        else if(sum % 7 == 2){
            printf("Friday\n");
        }
        else if(sum % 7 == 3){
            printf("Saturday\n");
        }
        else if(sum % 7 == 4){
            printf("Sunday\n");
        }
        else if(sum % 7 == 5){
            printf("Monday\n");
        }
        else if(sum % 7 == 6){
            printf("Tuesday\n");
        }
        else if(sum % 7 == 0){
            printf("Wednesday\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main  implements Runnable {
    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
/*		FastScanner sc = new FastScanner("6 6 \r\n" +
				"..#..#\r\n" +
				"......\r\n" +
				"#..#..\r\n" +
				"......\r\n" +
				".#....\r\n" +
				"....#.");*/
    	//FastScanner sc = new FastScanner("1000000000000");
    	int n = Integer.parseInt(sc.next());
    	int k = Integer.parseInt(sc.next());
    	//char a[]= sc.next().toCharArray();
		//ArrayList<Long> ttest = new ArrayList<Long>();
		//ttest.add(n);
		//int b = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		PrintWriter out = new PrintWriter(System.out);
		double total = 0;
		for(int i = 1; i <= n; i++)
		{
			double rate=1;
			for(int j = i; j < k; j=j*2)
			{
				rate = rate /2;
			}
			total += rate;
		}
		

//N=(N%M)*M
//a=N%M
//a+Ma=N =1+M=N/a
    	//a[k-1] = Character.toLowerCase(a[k-1]);
		double ans=0;
		ans = total/n;
		out.println(ans);
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

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

int main(){
  string s; cin >> s;
  int n = s.size();
  s += "T";
  int x, y; cin >> x >> y;
  vector<int> lx, ly;
  int nx, ny; nx = ny = 0;
  int cur, cntt; cur = cntt = 0;
  bool flag = false;
  rep(i, n+1){
    if(s[i] == 'F') cur++;
    else{
      cntt++;
      if(cntt==1 && cur==0){
        flag = true; continue;
      }
      else if(cntt%2 == 0) ly.push_back(cur), ny++, cur = 0;
      else lx.push_back(cur), nx++, cur = 0;
    }
  }
  if(lx.empty()) lx.push_back(0), nx++;
  if(ly.empty()) ly.push_back(0), ny++;
  bool dpx[nx][2*n+1], dpy[ny][2*n+1];
  rep(i, nx)rep(j, 2*n+1) dpx[i][j] = false;
  rep(i, ny)rep(j, 2*n+1) dpy[i][j] = false;
  dpx[0][lx[0]+n] = true;
  if(flag) dpx[0][n-lx[0]] = true;
  for(int i=1; i<nx; i++)for(int j=-n; j<n+1; j++)if(dpx[i-1][j+n]) dpx[i][j+lx[i]+n] = dpx[i][j-lx[i]+n] = true;
  dpy[0][ly[0]+n] = dpy[0][n-ly[0]] = true;
  for(int i=1; i<ny; i++)for(int j=-n; j<n+1; j++)if(dpy[i-1][j+n]) dpy[i][j+ly[i]+n] = dpy[i][j-ly[i]+n] = true;
  cout << ((dpx[nx-1][x+n] && dpy[ny-1][y+n]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 123264
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
 
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
 
int main(){
    int n;
    while(cin>>n && n){
        typedef pair<double,string> P;
        vector<P> v(n);
        rep(i,n){
            string l;
            int p,a,b,c,d,e,f,s,m;
            cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;
            double x=a+b+c+(d+e)*m;
            double y=f*m*s-p;
            v[i] = make_pair(y/x,l);
        }
        sort(v.begin(),v.end(), [](const P& a, const P& b){
                if(abs(a.first-b.first)>1e-8) return a.first > b.first;
                return a.second<b.second;
            });
        rep(i,n)cout<<v[i].second<< endl;
        cout << "#" << endl;
    }
}

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

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

  string S; cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int FuncCmpInt(const void* big, const void* small);

int main(void)
{
  int num[5];
  int i;

  for (i = 0; i < 5; i++) {
    scanf("%d", &num[i]);
  }
  qsort(num, sizeof(num)/sizeof(num[0]), sizeof(num[0]), FuncCmpInt);

  for (i = 0; i < 5; i++) {
    printf("%d", num[i]);
    if (i < 4) 
      putchar(' ');
    else
      putchar('\n');
  }

  return 0;
}

int FuncCmpInt(const void* big, const void* small)
{
  int *a, *b;

  a = (int *)big;
  b = (int *)small;

  return (*b - *a);
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> data(M);
  for(int i=0;i<M;i++){
    cin>>data.at(i);
  }
  int answer=N;
  for(int j=0;j<M;j++){
    answer-=data.at(j);
  }
  if(answer>=0){
    cout<<answer<<endl;
  }
  else{
    cout<<-1<<endl;
  }
 
}

Measured memory_bytes: 3628
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int ans=0;
        int n=sc.nextInt();
        int x=sc.nextInt();
        int[] a=new int[n];
        long sum=0;
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
            sum+=a[i];
        }
        if(sum==x){
            ans=n;
        }else if(sum<x){
            ans=n-1;
        }else{
            Arrays.sort(a);
            for (int i = 0; i < n; i++) {
                x-=a[i];
                if(x>0){
                    ans++;
                }else if(x==0){
                    ans++;
                    break;
                }else{
                    break;
                }
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 22740
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ar := make([]int64, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	var ans int64 = 3000000000
	for i := 0; i < n-k+1; i++ {
		var v int64 = f(ar[i], ar[i+k-1])
		if v < ans {
			ans = v
		}
	}
	fmt.Println(ans)
}

func f(s, e int64) int64 {
	if s <= 0 && e <= 0 {
		return -s
	}
	if s <= 0 && 0 <= e {
		if -s < e {
			return -s*2 + e
		}
		return -s + e*2
	}
	return e
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    if(N%2==0){
        int Ans =0;
        for(int i=0;i<N/2;i++){
            if(S[i]!=S[i+N/2])Ans = 1;
        }
        if(Ans==0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define long long long


int main(){
	long H, N;
	cin >> H >> N;
	long Total_A = 0;
	long a;
	rep(i, N) {
		cin >> a;
		Total_A += a;
	}
	if (Total_A >= H) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a, b, ans = 0;
    cin >> a >> b;
    if (a & 1) ans ^= a;
    if (!(b & 1)) ans ^= b;
    if ((((b+1)/2)-(a/2)) & 1) ans |= 1;
    else {
        if (ans & 1) ans -= 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (A <= X && X <= A + B) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int64_t total = 0;
    rep(i, N)
    {
        int x;
        cin >> x;
        total += 2 * min(x, K - x);
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <cstdio>
int main(void){
    // Here your code !
   int h, w;
   while (1){
       scanf("%d %d", &h, &w);
       if (h == 0 && w == 0) break;
       for (int i = 0; i < h; i++){
           if (i == 0 || i == (h - 1)){
               for (int j = 0; j < w; j++){
                   printf("#");
                }
           }
           else {
               for (int j = 0; j < w; j++){
                   if (j == 0 || j == (w - 1)){
                       printf("#");
                   }
                   else {
                       printf(".");
                   }
               }
           } 
           
           printf("\n");
       }
       printf("\n");
   }
    return 0;
}

Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')
from collections import deque
def solve():
    n, q = MI()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        e[a].append(b)
        e[b].append(a)

    point = [0] * n
    for _ in range(q):
        p, x = MI()
        p -= 1
        point[p] += x

    d = deque([(0, point[0])])
    used = [0] * n
    used[0] = 1

    l = 1
    while l > 0:
        v, p = d.popleft()
        l -= 1
        for nv in e[v]:
            if used[nv]: continue
            used[nv] = 1
            point[nv] += p
            d.append((nv, point[nv]))
            l += 1

    printlist(point, " ")

if __name__ == '__main__':
    solve()


Measured memory_bytes: 67208
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n; cin>>n;
	vector<ll> a(n+1);
	rep(i,n+1)cin>>a[i];
	vector<ll> b(n);
	rep(i,n)cin>>b[i];
	ll ans = 0;
	rep(i,n){
		if(a[i]>=b[i]){
			ans += b[i];
			continue;
		}
		ans += a[i];
		ll rest = b[i]-a[i];
		if(a[i+1]>=rest){
			ans+=rest;
			a[i+1] -= rest;
			continue;
		}
		ans += a[i+1];
		a[i+1] = 0;
	}
	cout<<ans<<endl; return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::fixed;
using std::pow;
using std::setprecision;
using std::fabs;

int main(void){
  int n;
  int x[150];
  int y[150];
  cin >> n;
  for(int i = 0; i < n;i++){
    cin >> x[i];
  }
  for(int i = 0;i < n;i++){
    cin >> y[i];
  }

  double d1 = 0.0;
  double d2 = 0.0;
  double d3 = 0.0;
  double di = 0.0;
  int j;
  double zet;
  for(int i = 0;i < n;i++){
   zet = double(fabs(x[i]-y[i]));
   d1 += zet;
   d2 += pow(zet,2);
   d3 += pow(zet,3);
   if(i == 0 || zet > di){
     di = zet;
   }
  }
  d2 = pow(d2,1.0/2.0);
  d3 = pow(d3,1.0/3.0);
  cout << setprecision(10) << d1 << endl;
  cout << setprecision(10) << d2 << endl;
  cout << setprecision(10) << d3 << endl;
  cout << setprecision(10) << di << endl;
  }

Measured memory_bytes: 3484
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

vector<int> a;
vector<vector<int> > edges;

void solve(int curr, int prev, vector<vector<long long> >& ans)
{
    // ans[0] : コンピュータが存在しない
    // ans[1] : 電力供給が不足
    ans.assign(2, vector<long long>(1, a[curr]));
    if(a[curr] < 0)
        ans[0][0] = INF;
    else
        ans[1][0] = INF;

    for(int next : edges[curr]){
        if(prev == next)
            continue;

        vector<vector<long long> > v;
        solve(next, curr, v);

        int n = ans[0].size();
        int m = v[0].size();
        vector<vector<long long> > ans2(2, vector<long long>(n+m, INF));
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                ans2[0][i+j] = min(ans2[0][i+j], ans[0][i] + v[0][j]);
                ans2[1][i+j] = min(ans2[1][i+j], ans[1][i] + v[0][j]);
                ans2[1][i+j] = min(ans2[1][i+j], ans[0][i] + v[1][j]);
                ans2[1][i+j] = min(ans2[1][i+j], ans[1][i] + v[1][j]);
                if(v[0][j] < INF/2 || v[1][j] < 0){
                    ans2[0][i+j+1] = min(ans2[0][i+j+1], ans[0][i]);
                    ans2[1][i+j+1] = min(ans2[1][i+j+1], ans[1][i]);
                }
            }
        }
        ans = move(ans2);
    }
}

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

    edges.assign(n, vector<int>());
    for(int i=0; i<n-1; ++i){
        int u, v;
        cin >> u >> v;
        -- u;
        -- v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }

    vector<vector<long long> > ans;
    solve(0, -1, ans);
    for(int i=0; ; ++i){
        if(ans[0][i] < INF/2 || ans[1][i] < 0){
            cout << i << endl;
            return 0;
        }
    }
}


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

int main(){
  string s;
  cin >> s;
  bool p = s[0] == 'R';
  bool q = s[1] == 'R';
  bool r = s[2] == 'R';
  if(p and q and r){
    cout << 3 << endl;
  } else if((p and q) or (q and r)){
    cout << 2 << endl;
  } else if(p or q or r){
    cout << 1 << endl;
  } else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S  = keyboard.next();
		
		int ans = 0;
		
		if(S.charAt(1) == 'S') {
				if(S.charAt(0) == 'R' || S.charAt(2) == 'R') {
					ans++;
			}
		}else {
			if(S.charAt(0) == 'R') {
				ans++;
			}
			if(S.charAt(1) == 'R') {
				ans++;
			}
			if(S.charAt(2) == 'R') {
				ans++;
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}

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

string who_wins(vector<int> throws, int k)
{ 
  int n = throws.size();
  
  vector<bool> win(k+1, false);
  
  for(int stones = 0; stones<=k; stones++)
  {
    for(int x : throws)
    {
      if(stones >= x && !win[stones-x])
        win[stones] = true;
    }
  }
  
  if(win[k] == true)
    return "First";
  
  return "Second";
}

int main()
{
  int n,k;
  cin >> n;
  cin >> k;
  
  vector<int> throws(n,0);
  
  for(int i=0; i<n; i++)
  {
    cin >> throws[i];
  }
  
  cout << who_wins(throws, k) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



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

  bool isfor = true;
  string pre = "";
  string back = "";

  cout << pre << " " << back;

  REP(i,q){
    int t;
    cin >> t;
    if(t == 1) isfor = !isfor;

    if(t == 2){
      int f;
      char c;
      cin >> f >> c;

      if(isfor){
        if( f == 1) pre += c;
        if( f == 2) back += c;
      }
      else{
        if( f == 1) back += c;
        if( f == 2) pre += c;
      }
    }
  }

  string ans;

  if(isfor){
    reverse(ALL(pre));
    ans = pre + s + back;
  }
  else{
    reverse(ALL(back));
    reverse(ALL(s));
    ans = back + s + pre;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4312
Imports System

Public Class Program

    Public Shared Sub Main(args As String())

        Dim N As Integer = Integer.Parse(Console.ReadLine)
        Dim tn(N) As Integer
        Dim xn(N) As Integer
        Dim yn(N) As Integer

        tn(0) = 0
        xn(0) = 0
        yn(0) = 0

        For i As Integer = 1 To N
            Dim input() As String = Console.ReadLine.Split(" ")
            tn(i) = Integer.Parse(input(0))
            xn(i) = Integer.Parse(input(1))
            yn(i) = Integer.Parse(input(2))
        Next

        Dim flag As Boolean = True

        For i As Integer = 1 To N
            Dim td As Integer = tn(i) - tn(i - 1)
            Dim distance As Integer = Math.Abs(xn(i) - xn(i - 1)) + Math.Abs(yn(i) - yn(i - 1))

            If td < distance Then
                flag = False
                Exit For
            ElseIf (td - distance) Mod 2 = 1 Then
                flag = False
                Exit For
            End If
        Next

        If flag Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If

    End Sub
End Class

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

int N, X[24], Y[24], R[24], C[24];
int r[24], m[24];
char dp[16777216];

int f(char n, int s) { return ((s & r[n]) & m[n]) == 0; }

int main(void) {
  m[0] = 0;
  REP(i, 0, 23) m[i + 1] = m[i] | (1 << i);
  while(cin >> N, N) {
    REP(i, 0, N) cin >> X[i] >> Y[i] >> R[i] >> C[i];
    REP(i, 0, 1 << N) dp[i] = -1;
    REP(i, 0, N) r[i] = 0;
    REP(i, 0, N) REP(j, 0, N) {
      if(pow(R[i] + R[j], 2) > pow(X[i] - X[j], 2) + pow(Y[i] - Y[j], 2)) {
        r[i] = r[i] | (1 << j);
        r[j] = r[j] | (1 << i);
      }
    }
    char ans = dp[(1 << N) - 1] = 0;
    for(int s = (1 << N) - 1; s >= 0; s--) if(dp[s] != -1) {
      ans = max(ans, dp[s]);
      REP(i, 0, N) {
        int mi = (1 << i);
        if((~s & mi) || !f(i, s)) continue;
        REP(j, i + 1, N) {
          int mj = (1 << j);
          if(C[i] != C[j] || (~s & mj) || !f(j, s)) continue;
          int ns = ~(~s | mi | mj);
          dp[ns] = dp[s] + 2;
        }
      }
    }
    cout << (int) ans << endl;
  }
  return 0;
}

Measured memory_bytes: 19412
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int N,Z,W;
	int a[2000];
	int nextgetX[2001],nextgetY[2001];
	int scoreX[2001],scoreY[2001];
	int scoreXmin,scoreYmax;
	scan(N);scan(Z);scan(W);
	rep(i,N){
		scan(a[i]);
	}
	if(N==1) prin(abs(W-a[0]));
	else{
		nextgetX[N-1]=N-1;
		scoreX[N-1]=abs(a[N-1]-a[N-2]);
		scoreXmin=scoreX[N-1];
		nextgetY[N-1]=N-1;
		scoreY[N-1]=abs(a[N-1]-a[N-2]);
		scoreYmax=scoreY[N-1];
		for(int i=N-2;i>0;i--){
			int Ynow=a[i-1];
			int Xnow=a[i-1];
			scoreX[i]=max(scoreYmax,abs(a[N-1]-Ynow));
			scoreY[i]=min(scoreXmin,abs(a[N-1]-Xnow));
			scoreXmin=min(scoreXmin,scoreX[i]);
			scoreYmax=max(scoreYmax,scoreY[i]);
		}
		int Ynow=W;
		int Xnow=Z;
		scoreX[0]=max(scoreYmax,abs(a[N-1]-Ynow));
		scoreY[0]=min(scoreXmin,abs(a[N-1]-Xnow));
		scoreXmin=min(scoreXmin,scoreX[0]);
		scoreYmax=max(scoreYmax,scoreY[0]);
		prin(scoreX[0]);
	}
	return 0;
}


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

typedef long long ll;

int main() {
    ll N, x, ans = 0;
    cin >> N >> x;
    vector<ll> a(N + 1, 0);
    rep(i, N) cin >> a[i + 1];
    rep(i, N) {
        ll y = a[i] + a[i + 1] - x;
        if (y < 0) y = 0;
        ans += y;
        a[i + 1] -= y;
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int func(int time, int f){
    int val;
    for(int i = time; i <= time+f; i++){
        if(i % f == 0){
            val = i;
            break;
        }
    }
    return val;
}

int main(){
    int N;
    cin >> N;
    vector<int> c(N, 0), s(N, 0), f(N, 0);
    rep(i, N-1){
        cin >> c[i] >> s[i] >> f[i];
    }

    //iを出発駅としたときの、N駅にたどり着くための時間
    vector<int> time(N, 0);
    rep(i, N-1){
        for(int j = i; j < N-1; j++){
            if(j == i) time[i] = s[j];
            else{
                time[i] = max(s[j], func(time[i], f[j]));
            }
            time[i] += c[j];
        }
    }
    rep(i, N) cout << time[i] << endl;
    return 0;
}

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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int q;
  cin >> q;
  vector<int> v;
  vector<int> output;
  int tmp;
  int tmp2;
  rep_i(i, q){
    cin >> tmp;
    if(tmp == 0){
      cin >> tmp2;
      v.push_back(tmp2);
    }else if(tmp == 1){
      cin >> tmp2;
      cout << v[tmp2] << endl;
    }else{
      v.pop_back();
    }
    // debug_vi(v);
    // cout << endl;
  }

//   rep_i(i, output.size()){
//     say(output[i]);
//   }
}


Measured memory_bytes: 3916
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

a = 0
b = 0
for i, j in enumerate(list(itertools.permutations(range(1, n+1)))):
    j = list(j)
    if j == p:
        a = i
    if j == q:
        b = i

print(abs(a-b))

Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    for (int i = 2; i <= 55555 && n > 0; i += 5) {
        int flag = 1;
        int num = i;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                flag = 0;
                break;
            }
        }
        if (flag == 1) {
            cout << i << " ";
            n--;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n,m;
	int ans=0;
	cin >> n>>m;
	int bef;
	int state;
	bool flag=true;
	vector<int>k(m+1,0);
	vector<int>now(m+1,0);
	vector<int>mod(m+1,0);
	rep(i,m){
		cin>>bef;
		rep(_,bef){
			cin>>state;
			state--;
			k[i]|=(1<<state);
		}
	}
	rep(i,m){
		cin>>mod[i];
	}
	rep(bit,(1<<n)){
		flag=true;
		rep(i,m){
			now[i]=(bit&k[i]);
			if(__builtin_popcount(now[i])%2!=mod[i]){
				flag=false;
			}
		}
		if(flag){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC161A()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n, i, j, m = 0, f = 0;
	int A[10001] = {};
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &i);
		A[i]++;
		if (i > m) m = i;
	}
	for (i = 0; i <= m; i++)
		for (j = 0; j < A[i]; j++) {
			if (f) printf(" ");
			printf("%d",i),f=1;
		}
	puts("");
	return 0;
}

Measured memory_bytes: 664
#include <string>
#include <iostream>
#include <vector>
#include <cassert>
#include <random>
#include <algorithm>
#include <deque>
#include <cstring>
#include <time.h>
#include <cstdio>
#include <tuple>
#include <utility>

std::vector<std::vector<std::pair<int,int>>> g;
std::vector<int> d;

void dfs(int cur,int par,int dist) {
  d[cur]=dist;
  for (auto e:g[cur]) {
    if (e.first==par) continue;
    dfs(e.first,cur,e.second^dist);
  }
}

main() {
  int n;
  std::cin >> n;
  g.resize(n);
  d.resize(n);
  for (int i=0;i<n-1;++i) {
    int u,v,w;
    std::cin>>u>>v>>w;
    --u;--v;
    w%=2;
    g[u].push_back({v,w});
    g[v].push_back({u,w});
  }
  dfs(0,-1,0);
  for (int i=0;i<n;++i) {
    printf("%d\n",d[i]);
  }
}


Measured memory_bytes: 8192
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    string s,t;cin>>s>>t;
    int n=s.length();
    int cnt=0;
    rep(i,0,n)if(s[i]!=t[i])cnt++;
    cout<<cnt;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vi tetra;
vi tetra_odd;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

//    construct
    int p;
    for(int i = 1; ; ++i) {
        p = i*(i+1)*(i+2)/6;
        if(p > 1e6) break;
        tetra.push_back(p);
        if(p%2==1) tetra_odd.push_back(p);
    }
//    cout << tetra.size() << '\n';

    vi dp(1e6 + 1, inf);  // dp[i] : iを表現するために必要な正四面体数の最小個数
    vi dp_odd(1e6 + 1, inf);
    dp[0] = 0;
    dp_odd[0] = 0;

    for(int i = 0; i <= 1e6; ++i) {
        for(int j = 0; j < tetra.size(); ++j) {
            if(i+tetra[j]<=1e6) chmin(dp[i+tetra[j]], dp[i] + 1);
        }
    }
    for(int i = 0; i <= 1e6; ++i) {
        for(int j = 0; j < tetra_odd.size(); ++j) {
            if(i+tetra_odd[j]<=1e6) chmin(dp_odd[i+tetra_odd[j]], dp_odd[i] + 1);
        }
    }

//    solve
    int n;
    while(cin >> n) {
        if(n==0) break;
        cout << dp[n] << ' ' << dp_odd[n] << '\n';
    }
//    printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


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

// change minimum
// aよりbが小さかったら、aの値をbの値に置き換えて、trueを返す
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    // DPの初期値
    const long long INF = 1LL << 60;

    // DPテーブル (少し大きめに確保)
    long long dp[100010];

    // DPの初期化
    for (int i = 0; i < 100010; ++i)
        dp[i] = INF;

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);

    dp[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        chmin(dp[i], dp[i - 1] + abs(h.at(i) - h.at(i - 1)));
        if (i > 1)
        {
            chmin(dp[i], dp[i - 2] + abs(h.at(i) - h.at(i - 2)));
        }
    }

    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
// New Year

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

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

    cout << 24 + 24 - m << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n, k; cin >> n >> k;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  int dp[k+1];

  rep(i, k+1) {
    dp[i] = -1;
  }

  // 2: win second
  // 1: win first

  rep(i, a[0]) {
    dp[i] = 2;
  }
  rep(i, n) {
    dp[a[i]] = 1;
  }

  for(int i=1; i<=k; i++) {
    if (dp[i] != -1) {
      continue;
    }
    bool flag = false;
    rep(j, n) {
      int pos = i - a[j];
      if (pos >= 0) {
        if (dp[pos] == 2) {
          flag = true;
          break;
        }
      } else {
        break;
      }
    }
    if (flag) {
      dp[i] = 1;
    } else {
      dp[i] = 2;
    }
  }

  if (dp[k] == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>

bool sort_pair( std::pair< int, int > origin, std::pair< int, int > another )
{
    return origin.first < another.first;
}


int main()
{
    int64_t a,b;
    std::cin>> a;
    std::cin>> b;
    int64_t c,d,e;
    d = 2019;
    e = 2019;
    c = 2019;

    if( a % 2019 == 0
        || b % 2019 == 0
        || ( b - a ) >= 2019
        || ( a < 2019
             && 2019 < b ) )
    {
        c = 0;
    }
    else
    {
        for( int64_t i = a; i < b; i++ )
        {
            for( int64_t r = i + 1; r <= b; r++ )
            {
                d = ( i * r ) % 2019;
                
                if( d < c )
                {
                    c = d;
                }
            }
        }
    }

    std::cout<< c;
}


Measured memory_bytes: 256
from copy import deepcopy


def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))

def readmap():
    return map(int, input().split())


N = read()
A = readlist()
A.sort()

Acum = deepcopy(A)

for i in range(1, N):
    Acum[i] += Acum[i-1]

ans = 0
for i in reversed(range(N)):
    if i == N-1:
        ans += 1
    elif 2 * Acum[i] >= A[i+1]:
        ans += 1
    else:
        print(ans)
        quit()
print(N)



Measured memory_bytes: 15156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ld long double

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) begin(x), end(x)
#define rall(x) end(x), begin(x)

#define endl '\n'


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

ll solve(ll A, ll B) {
  int taps = 1;
  int res = 0;
  while (not (B <= taps)) res++, taps--, taps += A;
  return res;
}

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

  ll A, B;
  cin >> A >> B;

  auto ans = solve(A, B);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

template <class T>
struct CumulativeSum {
   private:
    ::std::vector<T> data;

   public:
    CumulativeSum(){};
    CumulativeSum(int sz) : data(sz, 0){};
    CumulativeSum(::std::vector<T> v) { build(v); }

   private:
    T query(int k) {
        if(k < 0) return (0);
        return (data[std::min(k, (int)data.size() - 1)]);
    }

   public:
    T query(int l, int r) {
        if(l < 0 || r > data.size()) return (0);
        return query(r - 1) - query(l - 1);
    }
    void add(int k, T x) { data[k] += x; }
    void build() {
        for(int i = 1; i < data.size(); i++) data[i] += data[i - 1];
    }
    void build(::std::vector<T> &v) {
        data = v;
        for(int i = 1; i < data.size(); i++) data[i] += data[i - 1];
    }
};

void solve() {
    int n;
    scanf("%d", &n);
    std::vector<i64> a(n);
    rep(i, n) scanf("%lld", &a[i]);
    CumulativeSum<i64> s(a);
    std::vector<std::pair<i64, i64>> left(n), right(n);
    int ok, ng;
    std::vector<i64> ans;
    repeat(i, 2, n - 1) {  // iで真ん中をぶった切る
        i64 sum_of_left = s.query(0, i);
        i64 sum_of_right = s.query(i, n);
        ok = i, ng = -1;
        while(ok - ng > 1) {
            int mid = ng + (ok - ng) / 2;
            if(s.query(0, mid) > sum_of_left / 2) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if(abs(s.query(0, ok) - (sum_of_left - s.query(0, ok))) > abs(s.query(0, ng) - (sum_of_left - s.query(0, ng)))) {
            left[i].first = s.query(0, ng);
            left[i].second = sum_of_left - s.query(0, ng);
        } else {
            left[i].first = s.query(0, ok);
            left[i].second = sum_of_left - s.query(0, ok);
        }
        ok = n, ng = i;
        while(ok - ng > 1) {
            int mid = ng + (ok - ng) / 2;
            if(s.query(i, mid) > sum_of_right / 2) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if(abs(s.query(i, ok) - (sum_of_right - s.query(i, ok))) > abs(s.query(i, ng) - (sum_of_right - s.query(i, ng)))) {
            right[i].first = s.query(i, ng);
            right[i].second = sum_of_right - s.query(i, ng);
        } else {
            right[i].first = s.query(i, ok);
            right[i].second = sum_of_right - s.query(i, ok);
        }
        // printf("%lld %lld %lld %lld\n", left[i].first, left[i].second, right[i].first, right[i].second);
        ans.emplace_back(std::max({left[i].first, left[i].second, right[i].first, right[i].second}) - std::min({left[i].first, left[i].second, right[i].first, right[i].second}));
    }
    printf("%lld\n", *std::min_element(begin(ans), end(ans)));
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 13284
#include <bits/stdc++.h>
using namespace std;
void chmin(long long &a, long long b)
{
    if (a > b)
        a = b;
}

int main()
{
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A), t(B);
    for (int i = 0; i < A; ++i)
        cin >> s[i];
    for (int i = 0; i < B; ++i)
        cin >> t[i];
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for (int _ = 0; _ < Q; ++_)
    {
        long long x;
        cin >> x;

        long long res = 1LL << 60;

        // 先に s
        int it = lower_bound(s.begin(), s.end(), x) - s.begin();
        for (int i = max(0, it - 1); i < min(A, it + 1); ++i)
        {
            long long y = s[i];
            int it2 = lower_bound(t.begin(), t.end(), y) - t.begin();
            for (int j = max(0, it2 - 1); j < min(B, it2 + 1); ++j)
            {
                chmin(res, abs(x - y) + abs(y - t[j]));
            }
        }

        // 先に t
        it = lower_bound(t.begin(), t.end(), x) - t.begin();
        for (int i = max(0, it - 1); i < min(B, it + 1); ++i)
        {
            long long y = t[i];
            int it2 = lower_bound(s.begin(), s.end(), y) - s.begin();
            for (int j = max(0, it2 - 1); j < min(A, it2 + 1); ++j)
            {
                chmin(res, abs(x - y) + abs(y - s[j]));
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 2944
#include<iostream>

using namespace std;

int main(){

    char  s[11];
    char out[sizeof(s)];
    for (size_t i = 0; i < 11; i++){
        s[i] = out[i] = '\0';
    }
    cin >> s ;
    int i = 0;
    int j = 0;

    for (i = 0; i <= sizeof(s); i++){
        
        if (s[i] == '0') {
            out[j] += '0';
            j++;
        }
        else if (s[i] == '1'){ 
            out[j] += '1';
            j++;
        }
        
        if (s[i]== 'B') {
            
            if (j > 0){
                out[j-1] = '\0';
                j--;
            
            }
        }
    }
    

    cout << out << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y,res,c=0;
    cin>>x>>y;
    if(x>y)	cout<<"No";
    else{
    for(int i=0;i<=x;i++){
    	for(int j=0;j<=x;j++){
    		res=(2*i)+(4*j);
    		if(res==y && i+j==x){
    			c++;
			}
		}
	}
	if(c>0) cout<<"Yes";
	else cout<<"No";
	}
    
}


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

if n == 1:
    print("0")
    exit()

ans = 0

factor = []
tmp = n
for i in range(2 , int(-(-n**0.5//1))+1):
    if tmp % i == 0:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp //= i
        factor.append(cnt)

if tmp != 1:
    factor.append(1)
if factor == []:
    factor.append(1)

for i in factor:
    j = 1
    while True:
        i -= j
        if i < 0:
            break
        j += 1
        ans += 1

print(ans)

Measured memory_bytes: 63656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c[105],d[200],sum=0,sum1=0;
    cin>>a>>b;
    for(int i=0; i<a; i++)
    {
        cin>>c[i];
        d[i+1]=sum+c[i];
        sum=sum+c[i];
    }
    d[0]=0;
    for(int i=0; i<=a; i++)
    {
        if(d[i]<=b)
        {
            sum1++;
        }
        else
        {
            break;
        }
    }
    cout<<sum1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int N = 0;
  int A[100];
  int i,j,k,v;

  scanf("%d",&N);

  for(i = 0; i < N; i++){

    scanf("%d",&A[i]);

  }

  for(i = 0; i < N; i++){

    if(i == N -1){

      printf("%d\n",A[i]);

    }

    else{

      printf("%d ",A[i]);

    }
  }



  for(i = 1; i < N; i++){

    v = A[i];

    j = i -1;

    while(j >= 0 && A[j] > v){

      A[j + 1] = A[j];

      j = j -1;

    }

    A[j + 1] = v;

    
    for(k =0; k < N; k++){

      if(k == N-1){

	printf("%d\n",A[k]);

      }

      else{
      
      printf("%d ",A[k]);

      }
    
    }


  }


  return 0;

}

Measured memory_bytes: 600
#include<iostream>

bool cards[4][13];

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

	for (int i = 0; i < n; i++){
		char a;
		int b;
		std::cin >> a >> b;
		b--;

		if (a == 'S')cards[0][b] = true;
		if (a == 'H')cards[1][b] = true;
		if (a == 'C')cards[2][b] = true;
		if (a == 'D')cards[3][b] = true;
	}

	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			if (!cards[i][j]){
				if (i == 0)std::cout << "S " << j + 1 << std::endl;
				if (i == 1)std::cout << "H " << j + 1 << std::endl;
				if (i == 2)std::cout << "C " << j + 1 << std::endl;
				if (i == 3)std::cout << "D " << j + 1 << std::endl;
			}
		}
	}

	return 0;
}

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


int main() {
    // 2019 = 3*613;
    ll L, R; cin >> L >> R;
    if(R - L > 5000) R = L+5000;
    ll ans = 1e18;
    
    for(int i = L; i < R; i++){
        for(int j = i+1; j <= R; j++){
            ans = min(ans, (ll)((ll)i*(ll)j)%2019);
            //if((i*j)%2019 == 0) cout << i << " " << j <<  " " << (i*j)%2019 << endl;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		if(a%2==0&&a%3!=0&&a%5!=0){
			cout<<"DENIED\n";
			return 0;
		}
	}
	cout<<"APPROVED\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int num;
		double hen = 0;
		double sum = 0;
 		double hei = 0;
		double ten[];
		
		String str;
		
		
		
		while(true){
		
		
			num = as.nextInt();
			
			if(num == 0){
				
				break;
				
			}
			
			ten = new double[num];
			
			for(int i=0;i<num;i++){
							
				ten[i] = as.nextDouble();
				hei = hei + ten[i];
				
			}
			
			hei = hei / num;
			//System.out.println(hei);
			
			for(int i=0;i<num;i++){
				
				//System.out.println(ten[i]-hei);
				sum = sum + (ten[i]-hei)*(ten[i]-hei);
				
			}
			//System.out.println(sum);
			
			hen = Math.sqrt(sum/num);
			str = String.valueOf(hen);
			System.out.println(str);
			hei = 0;
			sum = 0;
			hen = 0;
			
			
		}
		
		
		
	}

}

Measured memory_bytes: 39352
#include<bits/stdc++.h>
using namespace std;
#define pi 2*acos(0.0)
int main(){
      string s;
      int d;
      cin>>s;
      cin>>d;
      if(d>s.size())cout<<endl;
      else{

        for(int i=0;i<s.size();i+=d){
            cout<<s[i];
        }
        cout<<endl;


      }
}


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

int main() {
	int n, count = 0;
	long long int sum = 0;
	std::cin >> n;

	std::vector<long long int> v(n);
	for (long long int& x : v) {
		std::cin >> x;
	}


	for (int i = 0; i < n; i++) {
		if (v[i] < 0) {
			count++;
			v[i] = v[i] * -1;
		}
		sum += v[i];
	}

	if (count % 2 == 1) {
		int min = *min_element(v.begin(), v.end());

		sum = sum - 2 * min;
	}

	

	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int c[n];
	for(int i=0;i<n;i++){
		cin>>c[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;;j++){
			if(c[i]*j+1<=a){
				ans++;
			}
			else{
				break;
			}
		}
	}
	ans+=b;
	cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
int main(){
	int i,j;
	char s[12]={},t[12]={};
	for(;~scanf("%s",s);printf("%d\n",*s)){
		for(i=0;i<12;++i)s[i]-=48;
		for(i=0;i<9;memcpy(s,t,12),++i)
			for(j=0;i<9-j;++j)
				t[j]=(s[j]+s[j+1])%10;
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	char S[100010];
	scanf ("%s",S);
	int l=0;
	while (S[l]) l++;

	char T[100010];
	for (int i=0;i<l;i++){
		if (S[i] == 'd') T[l-i-1] = 'b';
		if (S[i] == 'b') T[l-i-1] = 'd';
		if (S[i] == 'p') T[l-i-1] = 'q';
		if (S[i] == 'q') T[l-i-1] = 'p';
	}
	for (int i=0;i<l;i++) if (S[i] != T[i]){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.charAt(0)==(S.charAt(1))&&S.charAt(1)==S.charAt(2)){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
		{
			
		}
	}

}


Measured memory_bytes: 22484