akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<set<pair<int,long> > >hen(n+1);
  int i;
  int u,v;
  long w;
  for(i=0;i<n-1;i++){
    cin >> u >> v >> w;
    hen[u].insert(make_pair(v,w));
    hen[v].insert(make_pair(u,w));
  }
  vector<int>colors(n+1,-1);
  colors[1] = 0;
  queue<int>que;
  que.push(1);
  while(!que.empty()){
    int tmp = que.front();
    que.pop();
    for(auto j:hen[tmp]){
      if(colors[j.first]==-1)que.push(j.first);
      colors[j.first] = (colors[tmp]+j.second)%2;
    }
  }
  for(i=1;i<=n;i++){
    cout << colors[i] << endl;
  }
}


Measured memory_bytes: 18048
// AOJ 2326: Number Sorting
// 2017.11.27 bal4u@uu

#include <stdio.h>
#include <string.h>

long long dp[100002];
long long a, b, p;

long long tbl[12] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 
100000000LL, 1000000000LL, 10000000000LL, 100000000000LL };

long long bsch(long long x)
{
	int m, l = 0, r = 12;

    while (l < r) {
        m = (l + r) >> 1;
		if (tbl[m] == x) return x;
        if (tbl[m] < x) l = m + 1; else r = m;
    }
	return tbl[l-1];
}

void calc(long long n)
{
    long long k, v = dp[n-a], m = n;

	while (m < b) {
		if (m == n) { dp[m-a+1] += v; if (dp[m-a+1] >= p) dp[m-a+1] -= p; }
		else        { dp[m-a  ] += v; if (dp[m-a]   >= p) dp[m-a  ] -= p; }
        m *= 10;
		k = bsch(m); if (k > b) k = b;
		k -= a, dp[k] -= v; if (dp[k] < 0) dp[k] += p;
    }
}

int main()
{
	long long i, ii, ans;

	while (scanf("%lld%lld%lld", &a, &b, &p) && p > 0) {
		memset(dp, 0, sizeof(dp));
	    b++;
		dp[0] = 1, calc(a);
		ans = dp[0]; if (ans >= p) ans -= p;
		for (ii = 1, i = a+1; i < b; i++, ii++) {
			dp[ii] += dp[ii-1]; if (dp[ii] >= p) dp[ii] -= p;
			calc(i);
	        ans += dp[ii]; if (ans >= p) ans -= p;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2520
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int y,n;
	while(scanf("%d %d %d", &a, &b, &c) != EOF){
		y = 0;
		n = 0;
		for(int i = 1; i <= 10; i++){
			if(i == a || i == b || i == c){
				continue;
			}
			if(a + b + i <= 20){
				y++;
			}else{
				n++;
			}
		}
		if(y > n){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1008
#include<iostream>


using namespace std;
int main(){
    int N;
    cin >> N;

    //$4と$7というコインがあったとして
    //この二つのコインで$Nを払えるかどうかを全探索すればいい
    int i, j;
    bool flag = false;
    //まず、大きい値(大きいコイン)から使用したい
    //その後$7で調整できないときにより細かい$4を使用する
    //これを2重ループで表現
    //かつ$Nを$7で支払う際の47を使用する回数は$N/$7
    //すなわち、これがループの上限になる
    //$4も同様
    for(i=0;i<=N/4;i++){
        for(j=0;j<=N/7;j++){

            if(N==(i*4 + j*7)){
                flag = true;
            }

        }
    }

    if(flag == true){
        cout << "Yes" << endl;
    }else{

        cout << "No" << endl;
    }




    return 0;
}

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

using namespace std;
typedef long long ll;

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    REP(i,n)cin >> a[i] >> b[i];
    vector<pair<ll,ll>> p(n);
    REP(i,n)p[i] = make_pair(a[i], b[i]);

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

    vector<pair<ll,ll>> ruip(n + 1, p[0]);
    ruip[0] = make_pair(0, 0);
    REP(i,n - 1)ruip[i + 2] = make_pair(p[i + 1].first, ruip[i + 1].second + p[i + 1].second);

    vector<ll> si_adv(n);
    vector<ll> su_adv(n);
    REP(i,n){
        si_adv[i] = ruip[i + 1].first - ruip[i].second;
        su_adv[i] = ruip[i + 1].second - ruip[i + 1].first;
    }

    ll ans = 0;
    ll ma_adv = 0;
    REP(i,n){
        ma_adv = max(ma_adv, si_adv[i]);
        ans = max(ans, su_adv[i] + ma_adv);
    }

    cout << ans << endl;
}



Measured memory_bytes: 33976
//https://atcoder.jp/contests/abc150/tasks/abc150_a
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long a , yen ;
    cin >> a >> yen ;
    if (a * 500 > yen or a * 500 == yen) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

turn = 1
while True:
    if turn == 1:
        c -= b
        if c <= 0:
            print("Yes")
            break
    else:
        a -= d
        if a <= 0:
            print("No")
            break
    turn = (turn + 1) % 2



Measured memory_bytes: 9172
INF = 10 ** 15
MOD = 10 ** 9 + 7
    
def main():
    N,P,Q = map(int,input().split())
    C = [int(input()) for _ in range(N)]
    ret = sum(C)
    C = [c + P*i for i,c in enumerate(C)]
    C.sort()
    x = 0
    ans = ret
    for i in range(N):
        ret += -C[i] + P*(2*x + Q)
        ans = max(ans,ret)
        x += 1
    print(ans)      
if __name__ == '__main__':
    main()



Measured memory_bytes: 49128
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedOutputStream;
public class Main
{
    public static void main(String [] args)
    {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int s = sc.nextInt(); int w = sc.nextInt();
        if (w >= s) {
            out.println("unsafe");
        } else out.println("safe");

        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }



    }

}

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

int main(void){
    string S; int K; cin >> S >> K;

    for (int i = 0; i < K; i++)
    {
        if(S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
     
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int q;
	int inp;
	cin >>q;
	for(int i =0;i<q;i++){
		cin >>inp;
		int counter =0;
		int a[5]={0};
		while(inp>9){
			int max = 0;
			for(int i = 1;i<6;i++){
				int num=1;
				for(int j= 0; j<i ; j++){
					num *=10;
				}
				a[i-1] =(inp/num)*(inp%num);
				if(max<a[i-1]) max = a[i-1];
			}
			counter++;
			inp = max;
		}
		cout << counter <<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 0;
    ans += v[n-1]/2;
    rep(i, n-1){
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;


int main() {
	ll hBit = 0;
	ll wBit = 0;
	ll h, w, k;
	cin >> h >> w >> k;
	vector<vector<bool>> grid(h);
	for (ll i = 0; i < h; i++) {
		grid[i].resize(w);
		string s;
		cin >> s;
		for (ll j = 0; j < w; j++) {
			if (s[j] == '#') {
				grid[i][j] = true;
			}
		}
	}
	ll ans = 0;
	for (ll hBit = 0; hBit < (1LL << h); hBit++) {
		for (ll wBit = 0; wBit < (1LL << w); wBit++) {
			vector<vector<bool>> tmp = grid;
			ll hb = hBit;
			ll wb = wBit;
			ll nowh = 0;
			while (hb > 0) {
				if (hb % 2 == 1) {
					for (ll j = 0; j < w; j++) {
						tmp[nowh][j] = false;
					}
				}
				hb /= 2;
				nowh++;
			}
			ll noww = 0;
			while (wb > 0) {
				if (wb % 2 == 1) {
					for (ll i = 0; i < h; i++) {
						tmp[i][noww] = false;
					}
				}
				wb /= 2;
				noww++;
			}
			ll tmpAns = 0;
			for (ll i = 0; i < h; i++) {
				for (ll j = 0; j < w; j++) {
					if (tmp[i][j] == true) {
						tmpAns++;
					}
				}
			}
			if (tmpAns == k) {
				ans++;
			}
		}
	}
	cout << ans << endl;


	

}


Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    string s;
    int k;

    cin >> s >> k;

    // bool flag = true;

    // for(auto i = s.begin(); i != s.end() - 1; ++i){
    //     flag = flag && *i == *(i + 1);
    // }

    // if (s.size() == 1 || flag) {
    //     cout << s.size() * k / 2;
    //     return 0;
    // }

    string s2 = s + s;
    string s3 = s + s + s;

    long long cnt = 0, cnt2 = 0, cnt3 = 0;

    char b = '$', b2 = '$', b3 = '$';

    for(auto &x : s){

        if (x == b){
            ++cnt;
            x = '$';
        }
        b = x;
    }

    for(auto &x : s2){

        if (x == b2){
            ++cnt2;
            x = '$';
        }
        b2 = x;
    }
    for(auto &x : s3){

        if (x == b3){
            ++cnt3;
            x = '$';
        }
        b3 = x;
    }

    cout << cnt + (cnt3 - cnt) * ((k - 1) / 2)
        + ((k - 1) % 2 == 1 ? (cnt2 - cnt) : 0);

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader stdReader =
        new BufferedReader(new InputStreamReader(System.in));
      String line;
      while ((line = stdReader.readLine()) != null) { 
    	  int x = Integer.parseInt(line);
        System.out.println(x*x*x);
      }
      stdReader.close();
    } catch (Exception e) {
      e.getStackTrace();
      /*?????´??????0??????*/
    //  System.exit(0); 
    }
  }
}

Measured memory_bytes: 24124
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const x = parseInt(args[0][0]);

let year = 0;
let tmp = 100;
while (true) {
    year++;
    tmp = Math.floor(tmp * 1.01);
    if (tmp >= x) break
}

console.log(year);

Measured memory_bytes: 29716
//https://atcoder.jp/contests/abc090/tasks/arc091_a
#include <bits/stdc++.h>
using namespace std;
#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(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    long long H, W;
    cin >> H >> W;
    /*if( H == 1 && W == 1 ){
        cout << 1 << endl;
    }
    else if( H == 1 && W > 1 ){
        cout << W-2 << endl;
    }
    else if( H > 1 && W == 1 ){
        cout << H-2 << endl;
    }
    //if( H > 1 && W > 1 )
    else {
        cout << (H-2)*(W-2) << endl;
    }*/
    cout << ( H==1&&W==1?1:H==1&&W>1?W-2:H>1&&W==1?H-2:(H-2)*(W-2)) << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
ans = "Yes"
for i in range(len(s)//2):
    if s[i] != s[len(s)-1-i]:
        ans = "No"
for i in range(len(s)//4):
    if s[i] != s[len(s)//2-1-i]:
        ans = "No"
    if s[len(s)//2+1+i] != s[len(s)-1-i]:
        ans = "No"
print(ans)

Measured memory_bytes: 3060
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n := input.NextInt()
  s := make([]string,n)
  d := 1
  pool := make([]Trie,400005)
  for i:=0;i<400005;i++ { pool[i] = NewTrie() }
  for i:=0;i<n;i++ {
    s[i] = input.NextLine()
    x := 0
    for j:=0;j<len(s[i]);j++ {
      k := ord(s[i][j:j+1])
      if pool[x].child[k] == -1 {
        pool[x].child[k] = d
        x = d
        d++
      } else {
        x = pool[x].child[k]
      }
      pool[x].size++
    }
    pool[x].flag = true
  }
  q := input.NextInt()
  ans := make([]int,q)
  qs := make(Queries,q)
  for i:=0;i<q;i++ {
    k,p := input.NextQuery()
    qs[i] = Query{k-1,i,p}
  }
  sort.Sort(qs)
  r := make([][]int,sig)
  for i:=0;i<sig;i++ { r[i] = make([]int,sig) }
  v := 0
  for i:=0;i<n;i++ {
    for j:=0;j<sig;j++ {
      for k:=0;k<sig;k++ { r[j][k] = 0 }
    }
    d := 0
    x := 0
    for j:=0;j<len(s[i]);j++ {
      if pool[x].flag { d++ }
      l := ord(s[i][j:j+1])
      for k:=0;k<sig;k++ {
        if pool[x].child[k] != -1 && l != k {
          r[k][l] += pool[pool[x].child[k]].size
        }
      }
      x = pool[x].child[l]
    }
    for v < q && qs[v].k == i {
      tmp := d+1
      for j:=0;j<sig;j++ {
        a := ord(qs[v].p[j:j+1])
        for k:=j+1;k<sig;k++ {
          b := ord(qs[v].p[k:k+1])
          tmp += r[a][b]
        }
      }
      ans[qs[v].i] = tmp
      v++
    }
  }
  for i:=0;i<q;i++ { fmt.Println(ans[i]) }
}

func ord(s string) int { return int([]rune(s)[0])-97 }

type Query struct { k,i int;p string }
type Queries []Query
func(q Queries) Len() int { return len(q) }
func(q Queries) Swap(i,j int) { q[i],q[j] = q[j],q[i] }
func(q Queries) Less(i,j int) bool { return q[i].k < q[j].k }

const sig = 26
type Trie struct {
  child []int
  size int
  flag bool
}
func NewTrie() Trie {
  c := make([]int,sig)
  for i:=0;i<sig;i++ { c[i] = -1 }
  return Trie{c,0,false}
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextQuery() (int,string) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  return x,s[1]
}

Measured memory_bytes: 121184
#include<stdio.h>

int main (){
  int i, n, a[100];
  scanf("%d", &n);

  for ( i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for ( i = 0; i < n; i++ ){
    printf("%d",a[n - 1 - i]);
    if ( i < n - 1 )
      printf(" ");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int n, N, sum = 0, ans;
    cin >> N;
    n = sqrt(N-1);
    for(int i = 1; i < N; i++){
        sum += (N-1) / i;
    }
    cout << sum;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


bool is_valid(long long m, vector<long long> & H, long long A, long long B){
    long long counts = 0LL;
    long long AB = A - B;
    for (auto h : H){
        long long dif = h - B * m;
        if (dif <= 0) break;
        counts += dif/AB;
        if (dif % AB) ++counts;
        if (counts > m) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, A, B;
    cin >> N >> A >> B;
    vector<long long> H(N, 0);
    for (auto & h : H) cin >> h;
    sort(H.begin(), H.end(), greater<long long>());
    long long lower = 0;
    long long upper = 1e9;
    while (lower + 1LL < upper){
        long long mid = (lower + upper)/2LL;
        if (is_valid(mid, H, A, B)){
            upper = mid;
        }else{
            lower = mid;
        }
    }
    cout << upper << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <chrono>

using namespace std;
using namespace std::chrono;

using mix_t = pair<int, int>;

int get_gcd(int a, int b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, ma, mb;
  cin >> n >> ma >> mb;
  int g = get_gcd(ma, mb);
  ma /= g;
  mb /= g;

  map<mix_t, int> st, buf;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    buf.clear();

    buf[mix_t(a, b)] = c;

    for (const pair<mix_t, int>& it : st) {
      int ca = it.first.first;
      int cb = it.first.second;
      int cc = it.second;

      if (buf.find(it.first) == buf.end())
        buf[it.first] = it.second;
      else
        buf[it.first] = min(buf[it.first], it.second);

      ca += a;
      cb += b;
      cc += c;

      if (buf.find(mix_t(ca, cb)) == buf.end())
        buf[mix_t(ca, cb)] = cc;
      else
        buf[mix_t(ca, cb)] = min(buf[mix_t(ca, cb)], cc);
    }

    swap(st, buf);
  }

  int ans = -1;
  for (const pair<mix_t, int>& it : st) {
    int ca = it.first.first;
    int cb = it.first.second;
    g = get_gcd(ca, cb);
    ca /= g;
    cb /= g;
    if (ca == ma && cb == mb) {
      if (ans == -1)
        ans = it.second;
      else
        ans = min(ans, it.second);
    }
  }

  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 2944
N, P = map(int,input().split())
A = list(map(int,input().split()))

odd = 0
even = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

if odd == 0:
    if P % 2 == 0:
        print(2 ** N)
    else:
        print(0)
else:
    print(2 ** (N - 1))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  ll N;
  IN(N);
  vll A(N);
  REP(i,N) IN(A[i]);

  vll A_left(N);
  vll A_right(N);

  A_left[0] = -(INFLL-1);
  A_right[N-1] = -(INFLL-1);

  FOR(i,1,N){
    A_left[i] = max(A_left[i-1], A[i-1]);
    A_right[N-1-i] = max(A_right[N-i], A[N-i]);
  }

  REP(i,N){
    printf("%lld\n", max(A_left[i], A_right[i]));
  }

  return 0;
}

Measured memory_bytes: 6272
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;
static const long k10E7 = 1000000007;

int main()
{
    long n, k ,q;
    cin >> n >> k >> q;

    vector<long> participants(n);
    for(long i = 0; i < q ; i++){
        long a;
        cin >> a;
        participants[a - 1]++;
    }
    
    for(long& p : participants){
        if (k - q + p > 0){
            cout << "Yes" <<endl;
        } else {
            cout << "No" <<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };


int main() {
	int n, x;
	cin >> n >> x;
	int ans = n - x;
	if (ans < 0)ans = 0;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N,Y;
  cin >> N >> Y;
  bool a=false;
  for(int i=0;i<N+1;i++){
    for(int j=0;j<N-i+1;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout << i << " " << j << " " << N-i-j << endl;
        a=true;
        break;
      }
    }
    if(a){
      break;
    }
  }
  if(!a){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
from collections import deque
H,W = map(int,input().split())
#A = list(map(int,input().split()))
S = []

def bfs(maze,sy, sx):
    visited = [[-1 for i in range(W)] for j in range(H)]
    queue = deque()
    queue.append([sy, sx])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <=new_y<=H-1 and 0<= new_x<=W-1:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
    maxa = 0
    for i in range(H):
        maxa = max(maxa,max(visited[i]))
    for i in range(H):
        if maxa in visited[i]:
            ret = [i,visited[i].index(maxa)]
            break
    return ret
def bfs2(maze,sy, sx):
    visited = [[-1 for i in range(W)] for j in range(H)]
    queue = deque()
    queue.append([sy, sx])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <=new_y<=H-1 and 0<= new_x<=W-1:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
    maxa = 0
    for i in range(H):
        maxa = max(maxa,max(visited[i]))
    return maxa
    

for i in range(H):
    s = list(input())
    S.append(s)
ans2 = []
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            start = [i,S[i].index('.')]
            ret = bfs(S,start[0],start[1])
            ans = bfs2(S,ret[0],ret[1])
            ans2.append(ans)

print(max(ans2))

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
  
long long euclid(long long a, long long b){
  long long c;
  if(a>b){
    c = a%b;
    if(c==0) return b;
    else return euclid(b,c);
  }else if(b>a){
    c = b%a;
    if(c==0) return a;
    else return euclid(a,c);
  }else return a;
}

long long calc(long long start, long long end, vector<long long> A){
  if(start==end) return A[start];
  else return euclid(calc(start,(start+end)/2,A),calc((start+end)/2+1,end,A));
}
int main(){
  long long N;
  long long ans;
  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  ans = euclid(A[0],A[1]);
  for(int i=2;i<N;i++){
    ans = euclid(ans,A[i]);
  }
      
  cout << ans << "\n";
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	string S;
	cin >> S;

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int k,n;
    s2(k,n);
    vi a(n);
    f(i,0,n){
        s(a[i]);
    }
    int d = 0;
    f(i,0,n){
        if(i == 0){
            d = max(d, abs(k- a[n-1]  + a[0]));
        }
        else{
            d = max(d, abs(a[i] - a[i-1]));
        }
    }
    out<<k -d <<endl;
}

class CTravelingSalesmanAroundLake {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        in.tie(0);out.tie(0);
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	CTravelingSalesmanAroundLake solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a == b && a != c){
        
        cout << "Yes" << endl;
        
    }
    
    else if(a != b && a == c){
        
        cout << "Yes" << endl;
        
    }
    
    else if(a == c && b !=c){
        
        cout << "Yes" << endl;
        
    }
    
    else if(a != c && b == c){
        
        cout << "Yes" << endl;
        
    }
    
    
    else{
        
        cout << "No" << endl;
        
    }
        
        
        
    
}

Measured memory_bytes: 3644
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ses=a*c;
    ses=max(ses,a*d);
    ses=max(ses,b*c);
    ses=max(ses,b*d);
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 3648
def solve():
    N, D = map(int, input().split())
    points = [list(map(int, input().split())) for _ in range(N)]

    count = 0
    for p in points:
        if p[0]**2 + p[1]**2 <= D**2:
            count += 1

    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 45412
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF=1e9;

void print(vi v){
	for(int i = 0; i < v.size(); i++){
		cout<<" "<<v[i];
	}
	cout<<endl;
}

int main(){
	string s;

	cin>>s;

	vi v(s.size(), 1);
	
	for(int i = 1; i < s.size(); i++){
		if(s[i]==s[i-1]){
			v[i]=v[i-1]+1;
		}
		else{
			reverse(v.begin()+(i-v[i-1]),v.begin()+i);
		}
	}
	reverse(v.begin()+(v.size()-1-v[v.size()-2]),v.begin()+(v.size()));
	//print(v);
	//print(v);
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i]=='J'){
			if(i+v[i]<s.size() && s[i+v[i]]=='O' && v[i+v[i]]==v[i]){
				if(i+v[i]*2<s.size() && s[i+v[i]*2]=='I' && v[i+v[i]*2]>=v[i+v[i]]){
					ans=max(ans,v[i]);
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6004
#include <stdio.h>

int main(void){
	int a,b,n,next;
	int sum;
	
	while (scanf("%d%d%d", &a, &b, &n)!=EOF){
		sum = 0;
		for (int i=0; i<n;i++){
//			printf("%d %d %d\n", a, b, sum);
			next = a*10 % b;
			sum += (a*10 / b) % 10;
			a = next;
			if (a==0) break;
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;

//入力

int main(){
    int x;
    cin >> x;
    if(x>=30)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include <numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int ans = 1;
	int start = -MOD;
	rep(i, n) {
		if (a[i] == 1) {
			start = i; break;
		}
	}
	if (start == -MOD) {
		cout << -1; return 0;
	}
	int now=1;
	rep2(i,start, n) {
		if (a[i] == now + 1) {
			ans++;
			now++;
		}
	}
	cout << n - ans;

	}

	

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
int n,m;
int dp[5005][5005];
int p[5005];
inline void add(int & a,int b){
    a+=b;
    a=(a>=m?a-m:a);
}
void work(){
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    fo(i,1,n){
        if(i>n+1-i) break;
        p[i]=p[n+1-i]=i;
    }
    fo(i,1,n-1){
        fo(j,0,n-1){
            int mul=p[i];
            fo(k,0,n-1){
                if(k*mul+j>n-1) break;
                add(dp[i][j+k*mul],dp[i-1][j]);
            }
        }
    }
    int ans=0;
    fo(j,0,n-1){
        add(ans,1ll*(n-j)*dp[n-1][j]%m);
    }
    cout<<ans<<endl;
}
int main(){
    cin>>n>>m;
    work();
    return 0;
}

Measured memory_bytes: 98176
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);

  int ans = 0;
  REP(i, N) cin >> A[i];
  REP(i, N){
    cin >> B[i];
    ans += B[i];
  }
  REP(i, N-1) cin >> C[i];

  FOR(i, 1, N){
    if(A[i-1] == A[i]-1) ans += C[A[i-1]-1];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 998244353;
const ll maxn = 1000005;
const ll mm = 1e+18;
void solve()
{
	int n;
	cin>>n;
	int a[n];
	int b[n];
	rep0(i,n){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	if(n&1){
		cout<<b[n/2]-a[n/2]+1;
	}
	else{
		cout<<b[(n-1)/2]+b[n/2]-a[(n-1)/2]-a[n/2]+1;
	}
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 6784
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int x,a,b;
    cin>>x>>a>>b;
    if(b-a<=0){
        cout<<"delicious"<<endl;
    }else if(b-a<=x){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }
}   




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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#define co(n) cout << (n) << endl;
#define cn(n) cin >> n;
#define all(x) (x).begin(), (x).end()

int main(){
  string s;
  cin >> s;
  if ( s=="SUN"){
    puts("7");
  }else if(s=="MON"){
    puts("6");
  }else if(s=="TUE"){
    puts("5");
  }else if (s=="WED"){
    puts("4");
  }else if (s=="THU"){
    puts("3");
  }else if(s=="FRI"){
    puts("2");
  }else if (s=="SAT"){
    puts("1");
  }
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    map<ll,ll> mp;
    rep(i,N){
        mp[A[i]]++;
    }
    ll ans = 0;
    for (map<ll,ll>::iterator itr = mp.begin(); itr != mp.end(); itr++){
        ans += (itr->second - 1);
    }
    ll count = (ans + 1) / 2;
    cout << N - count * 2 << endl;
}


Measured memory_bytes: 10288
import numpy as np

n = int(input())
an = np.array([int(i) for i in input().split(" ")])
suma = 0
suma = np.sum(an <= 0)
minus = np.empty(0)
if suma % 2 == 0:
    print(np.sum(np.abs(an)))
else:
    print(int(np.sum(np.abs(an)) - 2 * np.min(np.abs(an))))

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

typedef long long ll;
typedef struct {
	ll x,y;
} _pos;
int main () {
	int n,K;cin >> n >> K;
	_pos pos[n];for (int i = 0;i < n;i++) {
		cin >> pos[i].x >> pos[i].y;
	}
	ll ans = 9223372036854775000;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			for (int k = 0;k < n;k++) {
				for (int l = 0;l < n;l++) {
					ll x[]={pos[i].x,pos[j].x,pos[k].x,pos[l].x};
					ll y[]={pos[i].y,pos[j].y,pos[k].y,pos[l].y};
					sort(x,x+4);
					sort(y,y+4);
					int cnt=0;
					for (int m = 0;m < n;m++) {
						if (x[0]<=pos[m].x&&pos[m].x<=x[3]&&y[0]<=pos[m].y&&pos[m].y<=y[3]) {
							cnt++;
						}
					}
					if (cnt>=K) ans = min(ans,(x[3]-x[0])*(y[3]-y[0]));
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A <= C){
  if(B<=C){
    cout << 0 << endl;
  }
  else{
    cout << min(B,D)-C << endl;
  }
}

else if(A > C){
  if(D<=A){
    cout << 0 << endl;
  }
  else {
    cout <<min(B,D)-A << endl;
  }
  
}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int K, X;
    cin >> K >> X;
    Fp(i, X - ( K - 1), X + (K - 1)){
        cout << i << ' ' ;
    }
    cout << X + (K - 1) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
ll a,b,c,k;
int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>c>>k;
    if (k%2) swap(a,b);
    cout<<a-b;
    return 0; 
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
import numpy as np

k,n = mi()
a=np.array(li())

b = a[1:] - a[:n-1]
b_max = np.max(b)
c = a[0] + k-a[n-1]

print(k-max(b_max,c))


Measured memory_bytes: 42496
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vector<ll> sa(a), sb(b);
    sort(all(sa));
    sort(all(sb));

    ll ma, mb;
    if (n % 2 == 1) {
        ma = sa[n / 2];
        mb = sb[n / 2];
    } else {
        ma = sa[(n - 1) / 2] + sa[n / 2];
        mb = sb[(n - 1) / 2] + sb[n / 2];
    }
    cout << mb - ma + 1 << "\n";
    return 0;
}


Measured memory_bytes: 9544
object Main extends App{
    override def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        var sum = 0L
        Iterator.continually(new Datum(sc.nextLine)).takeWhile(_.isContinue)
        .foreach(d=>println(d.getValue))
       
    }
    
    case class Datum(buf:String){
    	val isContinue = buf != "0"
    	
    	val getValue = {
    		buf.foldLeft(0){(z,n) => z + n - '0'}
    	}
    }
}

Measured memory_bytes: 45208
#include <iostream>

using namespace std;

int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

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

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; i++) {
        if (i)cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

}

Measured memory_bytes: 3092
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        int b = in.nextInt();
        out.println(Math.max(Math.max(a+a-1,b+b-1),a+b));
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21204
a=[]
n=int(input())
a=[int(x) for x in input().split()]
flag=0

for i in range(len(a)):
    if a[i]%2==0:
        if a[i]%3==0 or a[i]%5==0:
            continue
        else:
            flag+=1
            
if flag==0:
    print("APPROVED")
else:
    print("DENIED")
          

Measured memory_bytes: 3060