akhauriyash/Code-Regression huggingface dataset:
/**
 *   author: malviyanshiv
 *   created: 12 January 2019  13:52:37
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 401

typedef long long ll;
typedef pair< int, int > PII;

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

ll n;
vector<ll> arr(MAX);
vector< vector<ll> > dp(401, vector<ll>(401, -1));
vector<ll> cum(MAX+1, 0);

ll cal(int l, int r){
    if( l == r )
        return 0;
    if( r-l == 1 )
        return arr[l]+arr[r];
    ll &res = dp[l][r];
    if( res != -1 )
        return res;
    ll mini = (ll)1e18;
    for(int i = l; i < r; i++)
        mini = min( cal(l, i) + cal(i+1, r) + cum[r]-cum[l-1], mini);
    return res = mini;
}

int main(){
    optimizeIO();

    cin >> n;
    cum[0] = 0;
    REP(i, 1, n+1)
        cin >> arr[i];
    cum[1] = arr[1];
    REP(i, 2, n+1)
        cum[i] = cum[i-1] + arr[i];

    cout << cal(1, n) << endl;
    
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int ara[6],i;
    for(i=1;i<=5;i++)
        scanf("%d",&ara[i]);
    for(i=1;i<=5;i++)
    {
        if(ara[i]==0)
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1728
import numpy as np

n = int(input())

a = np.asarray(list(map(int, input().split())))

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 !=0 and a[i] % 5 != 0:
            print("DENIED")
            break
    if i == n-1:
        print("APPROVED")


Measured memory_bytes: 21300
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var ans int
	for i := 0; ; i += 1000 {
		if i >= N {
			ans = abs(i - N)
			break
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}


Measured memory_bytes: 1812
#include<iostream>
using namespace std;
int h1, m1, h2, m2, k, tot1, tot2;
int main(){
    cin>> h1 >> m1 >> h2 >> m2 >> k;
    tot1 = 60 * h1 + m1;
    tot2 = 60 * h2 + m2;
    cout<< tot2 - tot1 - k;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool flag = false;
    if(A == B & A != C) flag = true;
    if(A == C & A != B) flag = true;
    if(B == C & B != A) flag = true;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        long x = in.nextLong();
        long rm = x%11;

        long ans = (x/11)*2;

        if(rm>6) ans+=2;
        else if(rm>0){
            ans+=1;
        }

        out.print(ans);

    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	ll S;
	cin>>S;
	if(S == 1e18){
		cout<<0<<" "<<0<<" "<<1000000000<<" "<<0<<" "<<0<<" "<<1000000000<<endl;
		return 0;
	}
	ll a,b,c,d;
	a = 1e9;
	b = 1;
	d = S / a + 1;
	c = a - S % a;
	cerr<<"ad-bc = "<<(a * d - b * c)<<endl;
	cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,t;
    cin>>n>>t;
    vector<ll> ti(n);
    rep(i,n) cin>>ti[i];
    ll sum=0;
    rep(i,n-1) sum+=min(t,ti[i+1]-ti[i]);
    sum+=t;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int A[52][52];
int B[52][52];
vector<pair<int,int>> que[2501];

void keisan(int d) {
	for (pair<int,int> P : que[d]) {
		int x = P.first;
		int y = P.second;
		if (B[x - 1][y] == 0 && A[x - 1][y]) {
			B[x - 1][y] = d + 1;
			que[d + 1].push_back(make_pair(x - 1, y));
		}
		if (B[x + 1][y] == 0 && A[x + 1][y]) {
			B[x + 1][y] = d + 1;
			que[d + 1].push_back(make_pair(x + 1, y));
		}
		if (B[x][y - 1] == 0 && A[x][y - 1]) {
			B[x][y - 1] = d + 1;
			que[d + 1].push_back(make_pair(x, y - 1));
		}
		if (B[x][y + 1] == 0 && A[x][y + 1]) {
			B[x][y + 1] = d + 1;
			que[d + 1].push_back(make_pair(x, y + 1));
		}
	}
}

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

	int H, W;
	cin >> H >> W;
	int black = 0;
	rep1(i, H) {
		string S;
		cin >> S;
		rep1(ii, W) {
			if (S[ii - 1] == '.') A[i][ii] = 1;
			else black++;
		}
	}

	B[1][1] = 1;
	que[1].push_back(make_pair(1, 1));
	rep1(i, 2500) keisan(i);
	
	if (B[H][W] == 0) co(-1);
	else co(H*W - B[H][W] - black);
	Would you please return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cctype>
#include<cstring>
#define maxn 2007
#define ll long long 
#define SDOI2020 RP++ 
using namespace std;
ll a,b,c; 
inline ll read()
{
	ll x=0;
	ll flag=0;
	char ch;
	ch=getchar();
	while(!isdigit(ch)) 
	{
		if(ch=='-') flag=1;
	ch=getchar();	
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-48;
		ch=getchar();
	}
	if(flag==1) x=-x;	
	return x;
}


int main()
{
	a = read();
	b = read();
	c = read();
	ll pos = b + c;
	ll ans = (ll) a / (pos) * b;
	ans += min(b,a % (pos));
	//if(pos > n) printf("%lld",min(b,a));
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))

a.sort()
h = {}
for i in a:
    if i in h:
        h[i] += 1
    else:
        h[i] = 1
k = []
v = []
for i,j in h.items():
    k.append(i)
    v.append(j)

if len(h) == 1:
    if k[0] == 0:
        print("Yes")
        exit()
elif len(h) == 2:
    if k[0] == 0 and 2*v[0] == v[1]:
        print("Yes")
        exit()
elif len(h) == 3:
    if k[0] ^ k[1] == k[2] and v[0] == v[1] and v[0] == v[1]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 14100
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    const S = lines[0].split("");
    const T = lines[1].split("");

    for (var i = 0; i < S.length; i++) {
        if (S.toString() === T.toString()) { console.log("Yes"); return (0); }
        var tmp = S.pop();
        S.unshift(tmp);
    }

    console.log("No");
});

Measured memory_bytes: 9804
n, m = map(int, input().split())
List = list(map(int, input().split()))
"""
入力
"""

sort = sorted(List)[::-1]
"""
昇順にソート
"""
ans = sort.pop(m - 1)
sum = sum(List)
if ans >= sum / (4 * m):
    print("Yes")
else:
    print("No")




"""
print(n)
print(m)
print(List)
print(sort)
print(ans)
"""


Measured memory_bytes: 3064
using System;
using System.Linq;

namespace _175.C
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToList();
            var x = input[0];
            var singOfX = x > 0;
            var k = input[1];
            var d = input[2];

            var a = Math.Min(k, Math.Abs(x) / d);

            x = singOfX ? x - d * a : x + d * a;
            x = CalcMin(x, singOfX, k - a, d);

            Console.WriteLine(Math.Abs(x).ToString());
        }

        private static long CalcMin(long x, bool singOfX, long k, long d)
        {
            for (var i = 0; i < k; i++)
            {
                if (x == 0)
                {
                    return (k - i) % 2 == 1 ? d : 0;
                }
                if (x > 0 != singOfX)
                {
                    return (k - i) % 2 == 0 ? Math.Abs(x) : x > 0 ? Math.Abs(x - d) : Math.Abs(x + d);
                }
                x = x >= 0 ? x - d : x + d;
            }

            return x;
        }
    }
}

Measured memory_bytes: 18936
#include <stdio.h>
int main(void)
{
  char s[3];
  int i;
  int a=0,b=0,c=0;
  
  scanf("%s",&s);
  
  for(i=0;i<3;i++){
   if(s[i]=='a')  a++;
    
   else if (s[i]=='b')  b++;
    
   else if (s[i]=='c')  c++;
  }
 
  if(a==1 && b==1 && c==1)
       printf("Yes\n");
  
  else 
       printf("No\n"); 
  
  return 0;


}

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

int h,w;
char g[110][110];
int vis[110][110];
map<char,int> di = {
    {'>',0},
    {'<',0},
    {'v',1},
    {'^',-1}
}, dj = {
    {'>',1},
    {'<',-1},
    {'v',0},
    {'^',0}
};

pair<int,int> solve(int ci, int cj){
    if(vis[ci][cj]) return make_pair(-1,-1);
    vis[ci][cj] = true;
    if(g[ci][cj] == '.') return make_pair(ci,cj);
    int c = g[ci][cj];
    return solve(ci+di[c], cj+dj[c]);
}

int main(){
    while(scanf("%d%d",&h,&w), w != 0){
        rep(i,h) scanf("%s",g[i]);
        rep(i,h)rep(j,w) vis[i][j] = false;
        int i,j;
        tie(i,j) = solve(0,0);
        if(i==-1) puts("LOOP");
        else printf("%d %d\n",j,i);
    }
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const string tmp = "NESW";
const int vy[] = {-1, 0, 1, 0}, vx[] = {0, 1, 0, -1};
int H, W;
int64 L;
string C[100];
int sx, sy, sv;
int64 nxt[100][100][4];
void dfs(int x, int y, int v, int64 step)
{
  int nx = x + vx[v], ny = y + vy[v], nv = (v + 1) % 4;
  if(step == 0) {
    cout << y + 1 << " " << x + 1 << " " << tmp[v] << endl;
    return;
  } else if(0 <= nx && 0 <= ny && nx < W && ny < H && C[ny][nx] != '#') {
    int64 loop = ~nxt[nx][ny][v] ? nxt[x][y][v] - nxt[nx][ny][v] + 1 : step;
    nxt[nx][ny][v] = nxt[x][y][v] + 1;
    return(dfs(nx, ny, v, (step - 1) % loop));
  } else {
    nxt[x][y][nv] = nxt[x][y][v];
    return(dfs(x, y, nv, step));
  }
}
int main()
{
  while(cin >> H >> W >> L, H) {
    memset(nxt, -1, sizeof(nxt));
    for(int i = 0; i < H; i++) {
      cin >> C[i];
      for(int j = 0; j < W; j++) {
        int p = tmp.find(C[i][j]);
        if(p != string::npos) sx = j, sy = i, sv = p;
      }
    }
    nxt[sx][sy][sv] = 0;
    dfs(sx, sy, sv, L);
  }
}

Measured memory_bytes: 1564
N,M = map(int,(input().split()))
s = list(input())
s.reverse()
now = 0
me = []
flag = 0

while now != N:
    for i in range(1,M+1,)[::-1]:
        if now + i <= N  and  s[now+i] == "0":
            now += i
            me.append(i)
            break
    else:
        print(-1)
        flag = 1
        break

if flag == 0:
    me.reverse()
    print(*me)

Measured memory_bytes: 54920
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)

for _ in range(M):
  Max = heapq.heappop(A) * -1
  heapq.heappush(A, Max//2 * -1)
  
ans = 0
for i in range(N):
  ans += -1 * A[i]
  
print(ans)

Measured memory_bytes: 20492
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
lis = [[] for _ in range(N)]

plis = []
for _ in range(M):
    p, y = mapint()
    lis[p-1].append(y)
    plis.append((p, y))

for i in range(N):
    lis[i].sort()
    
from bisect import bisect_left
for p, y in plis:
    idx = bisect_left(lis[p-1], y)
    print('{:06}{:06}'.format(p, idx+1))

Measured memory_bytes: 91408
#include<stdio.h>

int main(){
    
int a,b;

while(1){
    scanf("%d %d",&a,&b);
    if(a==0 && b==0){
        break;
    }
    else{
        for(int i=0 ; i<a ; i++){
            for(int j=0 ; j<b ; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

	
	
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

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

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	//ll s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> s >> t;

	ll cnt = 0;
	l_ans = INF;
	rep(i, s.size() - t.size() + 1) {
		cnt = 0;
		rep(j, t.size()) {
			if (s[i + j] != t[j]) {
				cnt++;
			}
		}
		chmin(l_ans, cnt);
	}

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3656
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
N = int(input())
ans = 0
if N%2 == 1:
    print(0)
else:
    N //= 2
    while N >= 5:
        ans += N//5
        N = N //5
    print(ans)


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

using namespace std;

int n;

int v[3];

int main()
{
    cin >> n;
    int ok = 1;
    for(int i = 1; i <= n; i ++)
    {
        int a;
        cin >> a;
        if(a % 2 == 0)
        {
            if(a % 3 != 0 && a % 5 != 0)
                ok  = 0;
        }
    }


    cout << (ok == 1 ? "APPROVED" : "DENIED") << "\n";



    return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;






void printv(vint &V){
  for(auto e:V)cout<<e<<" ";
  cout<<endl;
}

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

vector< int > prime_numbers;



ll n; 

void f(ll pos, ll cnt, string s){
  if(pos == n){
    cout<<s<<endl;
    return ;
  }

  if(pos == 0){
    f(1, 1, "a");
    return;
  }

  rep(i,cnt){
    string tmp = s;
    tmp += ('a'+i);
    f(pos+1, cnt, tmp);
  }
  string tmp = s + (char)('a'+cnt);
  f(pos+1, cnt+1, tmp);
  return;
}

int main() {


  cout<<fixed<<setprecision(10);

  cin>>n;

  f(0, 0, "");

}

//


Measured memory_bytes: 1536
N, x = map(int, input().split())
a = list(map(int, input().split()))
candy = min(a[0], x)
ans = a[0] - candy
a[0] = candy

for i in range(1, N):
    candy = a[i - 1] + a[i]
    if candy > x:
        m = candy - x
        ans += m
        a[i] -= m

print(ans)

Measured memory_bytes: 14060
import java.util.*;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int[] a = new int[n];
      long sum = 0;
      for (int i = 0; i < n; i++) {
         a[i] = Integer.parseInt(sc.next());
         sum += a[i];
      }
      int max = a[0];
      int min = a[0];
      for (int i = 1; i < n; i++ ) {
         if (max < a[i]) {
            max = a[i];
         } else if (min > a[i]) {
            min = a[i];
         }
      }
      System.out.printf("%d %d %d\n", min, max, sum);
   }
}

Measured memory_bytes: 27660
#include<stdio.h>

int main(void)
{
	int n, i, t;
	int S[14], H[14], C[14], D[14];
	char A, temp[50];

	for(i=1; i<=13; i++)
	{
		S[i] = 1;
		H[i] = 1;
		C[i] = 1;
		D[i] = 1;
	}

	scanf("%d\n", &n);
	for( i = 0; i < n; i++)
	{
		scanf("%c %d\n", &A, &t);
		if( 'S' == A )
			S[t] = 0;
		else if( 'H' == A )
			H[t] = 0;
		else if( 'C' == A )
			C[t] = 0;
		else if( 'D' == A )
			D[t] = 0;
	}

	for(i=1; i<=13; i++)
		if(S[i])
			printf("S %d\n", i);
	for(i=1; i<=13; i++)
		if(H[i])
			printf("H %d\n", i);
	for(i=1; i<=13; i++)
		if(C[i])
			printf("C %d\n", i);
	for(i=1; i<=13; i++)
		if(D[i])
			printf("D %d\n", i);

	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;

double v_max[40010];
double time_seq[105], v_seq[105];

int main() {
    int N;
    double dist_sum = 0.0;
    cin >> N;
    time_seq[0] = 0.0;
    v_seq[0] = 0.0;
    for (int i = 1; i <= N; i++) {
        cin >> time_seq[i];
        time_seq[i] += time_seq[i - 1];
    }
    for (int i = 1; i <= N; i++) cin >> v_seq[i];

    // 時間0から徐々に加速する場合の速度の書き込み
    for (int i = 0; i <= 2 * time_seq[N]; i++) v_max[i] = 0.5 * i;
    // 入力された各区間の最大速度を考慮した各時間における速度の書き込み
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= 2 * time_seq[N]; j++) {
            if (0.5 * j <= time_seq[i - 1]) {
                v_max[j] = min(v_max[j], v_seq[i] + (time_seq[i - 1] - 0.5 * j)); 
            }
            else if (0.5 * j >= time_seq[i - 1] && 0.5 * j <= time_seq[i]) {
                v_max[j] = min(v_max[j], v_seq[i]);
            }
            else {
                v_max[j] = min(v_max[j], v_seq[i] + (0.5 * j - time_seq[i]));
            }
        }
    }
    // 時間0から徐々に減速していく場合の速度の書き込み
    for (int i = 0; i <= 2 * time_seq[N]; i++) v_max[i] = min(v_max[i], time_seq[N] - 0.5 * i);

    for (int i = 0; i < 2 * time_seq[N]; i++) {
        dist_sum += 0.25 * (v_max[i] + v_max[i + 1]);
    }

    cout << fixed << setprecision(12) << dist_sum << endl;

    return 0;

}

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

int main() {
    int a[101]={0};
    int x,y,z;
    cin>>x>>y>>z;
    a[x]++;a[y]++;a[z]++;
    int count=0;
    for(int i=0;i<101;i++)if(a[i]>0)count++;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = [0] * (10**5)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            ans[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i-1] += 1
for i in range(n):
    print(ans[i])


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


int main() {
	int n, m, l; cin >> n >> m >> l;
	long long sp[n + 1][n + 1], G[n + 1][n + 1];
	for(int i = 0 ; i <= n ;i ++){
		for(int j = 0 ; j <= n ; j ++){
			sp[i][j] = 1e18;
			G[i][j] = 1e18;
		}
	}
	for(int i = 0 ; i <= n ; i ++ ){
		sp[i][i] = 0;
	}
	for(int i = 0 ; i < m ; i ++ ) {
		int x, y, z; cin >> x >> y >> z;
		sp[x][y] = z , sp[y][x] = z;
	}
	
	for(int k = 1; k <= n ;k ++) {
		for(int i = 1; i <= n ;i ++ ){ 
			for(int j = 1 ; j <= n ;j ++) {
				sp[i][j] = min(sp[i][j], sp[i][k] + sp[k][j]);
			}
		}
	}
	
	for(int i = 0 ; i <= n ;i ++ ) {
		for(int j = 0 ;j <= n ; j ++ ) {
			if(sp[i][j] <= l) G[i][j] = 0;
		}
	}
	
	for(int k = 1 ; k <= n ;k ++ ){
		for(int i = 1; i <= n ;i ++){
			for(int j = 1; j <= n ; j ++){
				G[i][j] = min(G[i][j] , G[i][k] + G[k][j] + 1);
			}
		}
	}
	
	int q; cin >> q;
	while(q--){
		int a , b; cin >> a >> b;
		cout << (G[a][b] == 1e18 ? -1 : G[a][b]) << '\n';
	} 
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int lightDonut = X;
        for (int i = 0; i < N ; i++) {
            int m = sc.nextInt();
            X -= m;
            lightDonut = Math.min(lightDonut, m);
        }
        System.out.println(N + X/lightDonut);
    }

}

Measured memory_bytes: 22740
import scala.annotation.tailrec
object Main extends App {
  import scala.io.StdIn._

  val l = readInt
  val n = readInt
  var bias = 0
  for (_ ← 0 until n){
    val Array(x, w) = readLine.trim.split(' ').map(_.toInt)
    bias += x * w
  }
  if (bias == 0){
    println(0)
  }else if (bias > 0){
    val weights = additionalWeight(bias)
    println(weights.length)
    println(weights.map(it ⇒ s"-${it._1} ${it._2}").mkString("\n"))
  }else {
    val weights = additionalWeight(math.abs(bias))
    println(weights.length)
    println(weights.map(it ⇒ s"${it._1} ${it._2}").mkString("\n"))
  }

  @tailrec
  def additionalWeight(bias: Int, result: List[(Int, Int)] = Nil, weightMax: Int = 500000): List[(Int, Int)] = {
    if (bias == 0) result
    else if (weightMax >= bias) (1 , bias)::result
    else additionalWeight(bias - weightMax, (1, weightMax)::result)
  }

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int h, w, c[20][20], a[300][300];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < 10; i++)for (int j = 0; j < 10; j++)cin >> c[i][j];
	for (int pw = 0; pw <= 50; pw++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h*w; i++) {
		int k; cin >> k;
		if (k >= 0)ans += c[k][1];
	}
	cout << ans << endl;
}

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

using namespace std;
typedef pair<int,int> P;
const int INF = 5000;
vector<vector<int>> d(55,vector<int>(55,INF));

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};
int h, w;

int bfs(int sx, int sy, int gx, int gy,vector<vector<char>> &grid){
    
    queue<P> que;
    
    que.push(P(sx,sy));
    d[sx][sy] = 0;
    
    while(que.size()){
        P p = que.front();
        que.pop();
        
        if (p.first == gx && p.second == gy) break;
        
        for (int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            
            if (0 <= nx && nx < h && 0 <= ny && ny < w && grid[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    
    return d[gx][gy];
    
}

int main(void){
  
   cin >> h >> w;
   
   vector<vector<char>> grid(h,vector<char>(w));
   
   int totalNumber = h * w;
   int blackNumber = 0;
   
   for (int i = 0; i < h; i++){
       for (int j = 0; j < w; j++){
           cin >> grid[i][j];
           if (grid[i][j] == '#') blackNumber++;
       }
   }
   
   // BFSにより最短経路帳を求める
   int minimumPath = bfs(0,0,h-1,w-1,grid);
   
   if (minimumPath == INF){
       cout << -1 << endl;
       return 0;
   }
   else{
       int ans = totalNumber - blackNumber - minimumPath-1;
       cout << ans << endl;
   }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end



int main(){
    int x,y; scanf("%d%d",&x,&y);
    ll ans=0;
    if(x<=3){
        rep(i,1,4)if(i==x)ans+=100000*(4-i);
    }
    if(y<=3){
        rep(i,1,4)if(i==y)ans+=100000*(4-i);
    }
    if(x==1&&y==1)ans+=400000;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef vector<int> VE;
#define int long long
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
#define MAXN 100005

int n, a[MAXN], ans;

signed main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i - 1] == 1 && a[i] && i != 0){
            a[i]--;
            a[i - 1]--;
            ans++;
        }
        ans += a[i] / 2;
        a[i] %= 2;
    }
    cout << ans << endl;



    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < k - x) ans += 2 * x;
        else ans += 2 * (k - x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* ex5_3
    sak_Citrus*/

#include <stdio.h>

int main(void){
    //行数、列数を標準入力で受け取る
    int row,col;
    scanf("%d %d",&row,&col);
    //出力すべき行、列には1がつく配列、全て-1で初期化
    int checkRow[100],checkCol[100];
    for(int i=0;i<100;i++){
        checkRow[i] = -1;
        checkCol[i] = -1;
    }
    //盤面の初期状態を受け取る
    char table[row][col];
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            scanf(" %c",&table[i][j]);
        }
    }
    //どの行を出力すべき列か走査
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            if(table[i][j]=='#'){
                checkRow[i] = 1;
                break;
            }
        }
    }
    //どの列を出力すぺきか走査
    for(int i=0;i<col;i++){
        for(int j=0;j<row;j++){
            if(table[j][i]=='#'){
                checkCol[i] = 1;
                break;
            }
        }
    }
    //出力
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            //出力すべき行、列にどちらも該当しているときのみ書き込む
            if(checkRow[i]==1 && checkCol[j]==1){
                printf("%c",table[i][j]);
            }
            //出力が存在した行末尾で改行
            if(j==col-1 && checkRow[i] == 1){
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
	int i, n;
	char t[4];
	int c[4];
	for (i=0; i<4; ++i) c[i]=0;
	while (scanf("%d,%s", &n, t) != EOF) {
		switch (t[0]) {
			case 'A': if (t[1]=='B') c[2]++; else c[0]++; break;
			case 'B': c[1]++; break;
			case 'O': c[3]++; break;
		}
	}
	if (c[3] == 1) return 1;
	for (i=0; i<4; ++i) printf("%d\n", c[i]);
	return 0;
}

Measured memory_bytes: 0
import fractions

A, B, C, D = map(int, input().split())
E = fractions.gcd(C, D)
F = C * D // E

S = 1 + B - A
S1 = (B // C) - ((A-1) // C) 
S2 = (B // D) - ((A-1) // D)
S3 = (B // F) - ((A-1) // F)
print(S - S1 - S2 + S3)

Measured memory_bytes: 63980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		for (int i=0;i<=N;i++) {
			for (int j=0;j<=M;j++) {
				if (i*M+j*N-2*i*j==K) {
					System.out.println("Yes");
					return ;
				}
			}
		}
		System.out.println("No");
		return ;
	}

	public class People implements Comparable<People> {
		int a;
		int b;
		@Override
		public int compareTo(People o) {
			return this.a - o.a;
		}

	}
}

Measured memory_bytes: 35700
#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct process{
	char name[100];
	int time;
}P;

P Q[LEN];

int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b){
	return a < b ? a : b;
}

int main(){
	int elaps = 0;
	int c = 0;
	int i = 0;
	int q = 0;
	P u;

	scanf("%d%d", &n, &q);
	for (i = 1; i <= n; i++)
	{
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}

	head = 1;
	tail = n + 1;
	while (head != tail){
		u = dequeue();
		c = min(q, u.time);
		u.time -= c;
		elaps += c;
		if (u.time > 0){
			enqueue(u);
		}
		else{
			printf("%s %d\n", u.name, elaps);
		}
	}

	return 0;
}



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

	typedef long long ll;
	using namespace std;

	int main(){
		ll n,m;
		cin >> n >>m;
		vector<pair<ll,ll> > p;
		for(ll i=0; i < n;i++){
			ll price, piece;
			cin >> price >> piece;
			p.push_back({price, piece});
		}

		sort(p.begin(), p.end());

		ll price = 0,i=0;
		while(m > 0){
			if(p[i].second < m){
				price += p[i].first*p[i].second;
				m -= p[i].second;
			}else{
				price += p[i].first*m;
				m = 0;
			}
			i++;
		}
		cout << price <<endl;

		return 0;
	}

Measured memory_bytes: 2420
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <set>

using namespace std;

int main()
{
    const char *yes = "yes";
    const char *no = "no";

    char S[27];

    set<char> s;
    if (scanf("%s", S) < 1) return 0;

    for (int i = 0; i < strlen(S); i++)
    {
        s.insert(S[i]);
    }

    printf("%s\n", s.size() == strlen(S) ? yes : no);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	int index[6] = {0};
	while(n--)
	{
		double height;
		cin >> height;
		if(height < 165)
		{
			++index[0];
		}
		else if(height < 170)
		{
			++index[1];
		}
		else if(height < 175)
		{
			++index[2];
		}
		else if(height < 180)
		{
			++index[3];
		}
		else if(height < 185)
		{
			++index[4];
		}
		else
		{
			++index[5];
		}
	}
	cout << "1:";
	for(int i = 0; i < index[0]; ++i)
	{
		cout << "*";
	}
	cout << endl;
	cout << "2:";
	for(int i = 0; i < index[1]; ++i)
	{
		cout << "*";
	}
	cout << endl;
	cout << "3:";
	for(int i = 0; i < index[2]; ++i)
	{
		cout << "*";
	}
	cout << endl;
	cout << "4:";
	for(int i = 0; i < index[3]; ++i)
	{
		cout << "*";
	}
	cout << endl;
	cout << "5:";
	for(int i = 0; i < index[4]; ++i)
	{
		cout << "*";
	}
	cout << endl;
	cout << "6:";
	for(int i = 0; i < index[5]; ++i)
	{
		cout << "*";
	}
	cout << endl;
}

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

Measured memory_bytes: 1224
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine((n == 7 || n == 5 || n == 3) ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 11092
let i=readLine()!.characters.split(" ").map{Int(String($0))!},N=i[3]
var ans=0
for r in 0...N {
  for g in 0...N {
    let b=N-r*i[0]-g*i[1]
    if b>=0&&b%i[2]==0{ans++}
  }
}
print(ans)

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

int N;
string S;

int main() {
    cin >> N >> S;

    string ans = "";
    bool f = false;
    int a = 0, b = 0;
    int j = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '(') {
            if (f) {
                if (b > a) {
                    ans = string(b-a, '(') + ans;
                    ans += S.substr(j, i-j);
                    j = i;
                    f = false;
                    a = 0;
                    b = 0;
                }
            }
            a++;
        }
        else {
            f = true;
            b++;
        }
    }

    if (b > a) {
        ans = string(b-a, '(') + ans;
        ans += S.substr(j, N-j);
    }
    else {
        ans += S.substr(j, N-j);
        ans += string(a-b, ')');
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var edgeOut = new List<int>[N + 1].Select(e => new List<int>()).ToArray();
            var edgeIn = new List<int>[N + 1].Select(e => new List<int>()).ToArray();
            var cntIn = new int[N + 1];
            for (int i = 0; i < N - 1 + M; i++)
            {
                input = ReadArrayInt();
                var A = input[0];
                var B = input[1];
                edgeOut[A].Add(B);
                edgeIn[B].Add(A);
                cntIn[B]++;
            }
            var zero = new Queue<int>();
            for (int i = 1; i <= N; i++) if (cntIn[i] == 0) { zero.Enqueue(i); break; }
            var seq = new List<int>();
            var cnt = 0;
            var idx = new int[N + 1];
            while (zero.Any())
            {
                var num = zero.Dequeue();
                seq.Add(num);
                idx[num] = cnt;
                cnt++;
                foreach(var i in edgeOut[num])
                {
                    cntIn[i]--;
                    if (cntIn[i] == 0) zero.Enqueue(i);
                }
            }
            var ans = new int[N + 1];
            ans[seq[0]] = 0;
            for (int i = 1; i < seq.Count(); i++)
            {
                var max = -1;
                var ret = -1;
                foreach (var j in edgeIn[seq[i]])
                {
                    if (idx[j] > max)
                    {
                        max = idx[j];
                        ret = j;
                    }
                }
                ans[seq[i]] = ret;
            }

            for (int i = 1; i <= N; i++) Console.WriteLine(ans[i]);

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 38416
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;
int main(){
    long X, Y, Z;
    int cnt = 0;
    cin >> X >> Y >> Z;
    if(X == Y + 2 * Z){
        cout << "1" << endl;
    }else{
        long Dis = X - 2*Z - Y;
        while(Dis > 0){
            Dis = Dis - (Y + Z);
            if(Dis >= 0) cnt++;
            if(Dis < 0) break;
        }
        cout << cnt + 1 << endl;
    }
    
        return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<ll> a(N), sum(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 1e16));
	for (int i = 0; i < N; i++) dp[i][i + 1] = 0;
	for (int l = 2; l <= N; l++) {
		for (int i = 0; i + l <= N; i++) {
			int j = i + l;
			for (int k = i + 1; k < j; k++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + (sum[j] - sum[i]));
			}
		}
	}
	cout << dp[0][N] << endl;
	return 0;
}


Measured memory_bytes: 1536
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    vl b=a;
    sort(all(b));
    rep(i,n){
        cout<<(a[i]<=b[n/2-1]?b[n/2]:b[n/2-1])<<endl;
    }
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	int k=0,ans=0;
	for(int i=0;i<n;++i)
	  {
	  	  if(s[i]=='S')
	  	  {
	  	  	  if(k>ans) ans=k;
	  	  	  k=0;
	  	  }
	  	  else k++;
	  } 
	if(k>ans) ans=k;  
	cout<<ans<<endl;  
}


Measured memory_bytes: 3620
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


int main()
{

    int N;
    cin >> N;

    int cnt = 1;
    cnt <<= N;

    multiset< int, greater<int> > S; 

    for (int i = 0; i < cnt; ++i) {
        int life;
        cin >> life;
        S.insert(life);
    }

    bool ok = true;
    multiset< int, greater<int> > curr; //! current slimes
    curr.insert(*S.begin());
    S.erase(S.begin());

    for (int i = 0; ok && i < N; ++i) { //! repeat N generations
        // cout << "Generation " << i << endl;
        // dump(S);
        // dump(curr);
        auto ik = S.begin(); //! iterator to find new kids
        vector<int> newKids;
        for (int p : curr) { //! for each slime in the current generation
            // cout << "\tparent = " << p << endl;
            while (ik != S.end() && p <= *ik) ++ik;
            if (ik == S.end()) {
                // cout << "\t\tno valid kid" << endl;
                ok = false;    
                break;    
            } else {
                // cout << "\t\tkid = " << (*ik) << endl;
                newKids.push_back(*ik);
                ++ik;
            }
        }
        if (ok) {
            for (int k : newKids) {
                curr.insert(k);
                S.erase(S.find(k));
            }
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 13304
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int main(){
    int q; cin >> q;
    map<string,int> mp;
    for(int i = 0; i < q; i++){
        int n; string s; cin >> n >> s;
        if (n == 0){
            int x; cin >> x;
            mp[s] = x;
        } else if (n == 1){
            cout << mp[s] << endl;
        }
    }
}
  




Measured memory_bytes: 27824
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 1e5+10;
template <typename tp> inline void read(tp &x)
{
	x=0;char c=getchar();int f=0;
	for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
	for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	if(f) x=-x;
}
LL n,m,flag,len[N];
int main()
{
	read(n),read(m);
	for(int i=1;i<=n;i++) read(len[i]);
	for(int i=1;i<n;i++) if(len[i]+len[i+1]>=m) {flag=i;break;}
	if(flag==0) return 0*puts("Impossible");
	puts("Possible");
	for(int i=1;i<flag;i++) printf("%d\n",i);
	for(int i=n-1;i>flag;i--) printf("%d\n",i);
	printf("%lld\n",flag);
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
	int a,b;
	cin>>a>>b;
	int ans=1;
	int c=0;
	while(ans<b)
	{
		c++;
		ans+=a-1;
	}
	cout<<c;
    return 0;
}


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

ll mygcd(ll a, ll b){
    if(a<b)swap(a,b);
    ll res=0;
    while(b!=0){
        ll c=a;
        a=b;
        b=c%b;
        if(b==0)break;
    }
    res=a;
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll a[n];

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

    vector<ll> L(n+1),R(n+1);
    L[0]=0;R[n]=0;
    for(int i=0;i<n;++i){
        L[i+1]=mygcd(L[i],a[i]);
        R[n-i-1]=mygcd(R[n-i],a[n-i-1]);
    }
    vector<ll> M;
    for(int i=0;i<=n;++i){
        M.push_back(mygcd(L[i],R[i+1]));
    }
    sort(M.begin(),M.end(),greater<ll>());
    cout << M[0] << endl;
}

Measured memory_bytes: 3704
#include <stdio.h>

int main(void) {
    int n, k, h[100100], count = 0;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
        if(h[i] >= k) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 512