akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
template<class T>std::vector<boost::optional<T>> dijkstra(std::vector<std::map<index_t, T>>const& edge, index_t start)
{
	p_queue<std::pair<T, index_t>> queue;
	queue.emplace(T(), start);
	std::vector<boost::optional<T>> ret(edge.size());
	while (queue.size())
	{
		auto top = queue.top();
		queue.pop();
		if (ret[top.second])
		{
			continue;
		}
		ret[top.second] = top.first;
		for (auto&& p : edge[top.second])
		{
			queue.emplace(top.first + p.second, p.first);
		}
	}
	return ret;
}

void Main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<std::map<index_t, std::int64_t>> edge(N);
	for (auto i : boost::irange(1, N))
	{
		edge[i][i - 1] = 0;
	}
	for (auto _ : boost::irange(0, M))
	{
		index_t L, R;
		std::int64_t C;
		std::cin >> L >> R >> C;
		--L;
		--R;
		if (edge[L].count(R))
		{
			edge[L][R] = std::min(edge[L][R], C);
		}
		else
		{
			edge[L][R] = C;
		}
	}
	auto result = dijkstra(edge, 0);
	std::cout << result.back().get_value_or(-1) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 19832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans = n/x;
    if(n%x!=0) ans++;
    cout << ans*t << endl;
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 3000;

double dp[MN][MN];

int main() {
	int N; cin >> N;
	dp[0][0] = 1.0;

	rep(i, N) {
		double p;
		cin >> p;
		for (int j = 0; j <= i; ++j) {
			dp[i+1][j+1] += dp[i][j] * p;
			dp[i+1][j] += dp[i][j] * (1-p);
		}
	}
	double ans = 0.0;
	rep(j, N+1) {
		if (j > (N-j)) {
			ans += dp[N][j];
		}
	}
	printf("%.10f\n", ans);
	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll n, a, b;
    cin >> n >> a >> b;
    ll res = (n / (a + b)) * a + min(a, n % (a + b));
    cout << res;
    return 0;
}


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

namespace ABC175
{
    public class A
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (s == "RRR")
            {
                Console.WriteLine(3);
            }
            else if (s.StartsWith("RR") || s.EndsWith("RR"))
            {
                Console.WriteLine(2);
            }
            else if (s.Contains("R"))
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}

Measured memory_bytes: 26252
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
e = [set([x for x in range(1, N + 1) if i != x]) for i in range(N + 1)]
for _ in range(M):
  u, v = map(int, input().split())
  e[u].discard(v)
  e[v].discard(u)

cl = [0] * (N + 1)
dp = [0] * (N + 1)
dp[0] = 1
for x in range(1, N + 1):
  if cl[x]: continue
  s = [x]
  qs = []
  cl[x] = 1
  while len(s):
    p = s.pop()
    qs.append(p)
    for q in e[p]:
      if cl[q]:
        if cl[q] % 2 == cl[p] % 2:
          print(-1)
          exit(0)
        continue
      cl[q] = cl[p] % 2 + 1
      s.append(q)
  predp = dp[: ]
  for i in range(N, -1, -1):
    if dp[i] == 0: continue
    u = 0
    v = 0
    for q in qs:
      u += cl[q] % 2
      v += cl[q] % 2 == 0
    dp[i] -= predp[i]
    dp[i + u] += 1
    dp[i + v] += 1
  #print(dp)
res = N * (N - 1) // 2
for i in range(1, N + 1):
  if dp[i] == 0: continue
  u = i * (i - 1) // 2
  v = (N - i) * (N - i - 1) // 2
  res = min(res, u + v)
print(res)

Measured memory_bytes: 66012
n=int(input())
l=sorted([list(map(int,input().split()))+[i] for i in range(n)])
xs=[(x,i)for x,y,i in l]
ys=sorted([(x,i)for y,x,i in l])
edges={}
for i in range(1,n):
    a,s=xs[i-1];d,f=xs[i]
    if (s,f)in edges:
        edges[(s,f)]=min(edges[(s,f)],abs(a-d))
    else:edges[(s,f)]=abs(a-d)
    a,s=ys[i-1];d,f=ys[i]
    if (s,f)in edges:
        edges[(s,f)]=min(edges[(s,f)],abs(a-d))
    else:edges[(s,f)]=abs(a-d)
edges=sorted(edges.items(),key=lambda x:x[1])
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
uf=UnionFind(n)
ans=edges[0][1]
uf.unite(*edges[0][0])
for f,c in edges:
    if uf.same(*f):continue
    uf.unite(*f)
    ans+=c
print(ans)

Measured memory_bytes: 86036
//
//  main.cpp
//  AOJ1186
//
//  Created by aki33524 on 2014/07/07.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int H, W;

void solve(){
    int diag = 2*150*150;
    int rw;
    int rh;
    
    for(int h=1; h<=150; h++){
        for(int w=h+1; w<=150; w++){
            if(H*H + W*W <= h*h + w*w && h*h + w*w < diag){
                if(H*H + W*W == h*h + w*w){
                    if(H < h){
                        cout << h << " " << w << endl;
                        return;
                    }
                }else{
                    diag = h*h + w*w;
                    rw = w;
                    rh = h;
                    break;
                }
            }
        }
    }
    cout << rh << " " << rw << endl;
}

int main(int argc, const char * argv[])
{
    while(cin>>H>>W, H|W){
        solve();
    }
    
    return 0;
}

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

int a[100];

int main() {

	int n,k,ans=0;

	cin>>n>>k;

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

	sort(a,a+n);

	reverse(a,a+n);

	for(int i=0;i<k;++i) ans+=a[i];

	cout<<ans<<'\n';



}

Measured memory_bytes: 256
#include<stdio.h>
#define maxn 100005
#define inf 0x3f3f3f3f
using namespace std;
typedef long int ll;
ll a[maxn];
int main()
{
    int n, A, B;
    scanf("%d %d %d", &n, &A, &B);
    for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);
    int C = A - B, l = 0, r = 1e9, ans;
    while (l <= r){
        int m = (l + r) / 2, cnt = 0;
        for (int i = 0; i < n; ++i){
            if ((a[i] - (ll)m * B) <= 0) continue;
            if ((a[i] - (ll)m * B) % C == 0) cnt += (a[i] - (ll)m * B) / C;
            else cnt += (a[i] - (ll)m * B) / C + 1;
            if (cnt > m) break;
        }
        if (cnt > m) l = m + 1;
        else r = m - 1, ans = m;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int main()
{
int a,b,c,d;
long int a1,a2;
if(scanf("%d %d %d %d",&a,&b,&c,&d)!=0);
{
a1=a*b;
a2=c*d;
if(a1>a2)
printf("%ld",a1);
else
printf("%ld",a2);
}
return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# スペース区切りの整数の入力

from collections import deque

def calc(seq):
    score = 0
    for a, b, c, d in data:
        if seq[b-1] - seq[a-1] == c:
            score += d
    return score

# スペース区切りの整数の入力
N, M, Q = map(int, input().split())
#配列の入力
data = [list(map(int, input().split())) for _ in range(Q)]

ans = -1

que = deque()

for i in range(1, M+1):
    que.append([i])


while que:
    seq = que.popleft()

    if len(seq) == N:
        score = calc(seq)
        ans = max(ans, score)
    else:
        for i in range(seq[-1], M+1):
            seq_next = seq + [i]
            que.append(seq_next)

print(ans)


Measured memory_bytes: 23320
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 3e5 + 15;
const ll MOD = 1e15 + 7;
const double EPS = 1e-9;
const int BLOCK = 500;
const double PI = acos(-1);
//auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
auto seed = 194113341;
mt19937 rnd(seed);

bool is_equal(double a, double b) {
    return abs(a - b) <= EPS;
}


#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) % m + (x < 0 ? m: 0))


inline void IO() {
#if buyolitsez
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    int n;
    cin >> n;
    vector <int> c(n, 0);
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        x--;
        c[x]++;
    }
    for (auto u : c) {
        cout << u << "\n";
    }
}

signed main() {
    IO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3980
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial



def union_r(node):
    global road_union
    if road_union[node] != node:
        road_union[node] = union_r(road_union[node])
    return road_union[node]

def union_t(node):
    global train_union
    if train_union[node] != node:
        train_union[node] = union_t(train_union[node])
    return train_union[node]


road_union, train_union = [], []


def main():
    node_num, road_num, train_num = map(int, input().split())

    global road_union
    road_union = [i for i in range(node_num + 1)]
    for i in range(road_num):
        a, b = map(int, input().split())
        parent_a = union_r(a)
        parent_b = union_r(b)
        road_union[min(parent_a, parent_b)] = max(parent_a, parent_b)
        # print(road_union)

    global train_union
    train_union = [i for i in range(node_num + 1)]
    for i in range(train_num):
        a, b = map(int, input().split())
        parent_a = union_t(a)
        parent_b = union_t(b)
        train_union[min(parent_a, parent_b)] = max(parent_a, parent_b)

    # print(train_union, road_union)

    ryouhou = [0 for i in range(node_num + 1)]
    for i in range(1, node_num + 1):
        parent_r = union_r(i)
        parent_t = union_t(i)
        ryouhou[i] = (parent_r, parent_t)

    # print(train_union, road_union, 'uuu')

    count_d = Counter(ryouhou)

    for i in range(1, node_num + 1):
        now_flg = ryouhou[i]
        print(count_d[now_flg], end=' ')
    print()





if __name__ == '__main__':
    main()

Measured memory_bytes: 111360
package main

import "fmt"

func main() {
	// Code for C - A x B + C
	var N int
	fmt.Scan(&N)

	var count int
	for a := 1; a <= N; a++ {
		for b := a; b <= N; b++ {
			if a*b >= N {
				break
			} else if a == b {
				count++
			} else {
				count += 2
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1788
n,m = map(int, input().split())
h = list(map(int, input().split()))
n = [1 for i in range(n)]
for i in range(m):
    a,b =  map(int, input().split())
    if h[a-1] > h[b-1]:
        n[b-1]=0
    elif h[a-1]<h[b-1]:
        n[a-1]=0
    else:
        n[a-1]=0
        n[b-1]=0
print(sum(n))

Measured memory_bytes: 19984
class BIT(val n: Int) {
  var bit: LongArray
  init {
    bit = LongArray(n + 1) { 0L }
  }
  fun sum(i: Int): Long {
    var res = 0L
    var k = i
    while (k > 0) {
      res += bit[k]
      k -= k and -k
    }
    return res
  }
  fun add(i: Int, x: Long) {
    var k = i
    while (k < n + 1) {
      bit[k] += x
      k += k and -k
    }
  }
}

fun f(m: Int, n: Int, a: List<Int>): Boolean {
  var s = IntArray(n + 1) { 0 }
  for (i in 0 until n) {
    s[i + 1] = s[i] + if (a[i] >= m) 1 else -1
  }
  val mn = s.min()!!
  s = s.map { it - mn + 1 }.toIntArray()

  val mx = s.max()!!
  var bit = BIT(mx)
  var res = 0L
  for (j in 0..n) {
    res += bit.sum(s[j])
    bit.add(s[j], 1L)
  }
  val nn = 1L * n * (n + 1) / 2
  return (res >= (nn + 1) / 2)
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val a = readLine()!!.split(" ").map { it.toInt() }
  var ok = 1
  var ng = a.max()!! + 1
  while (ng - ok > 1) {
    val m = (ok + ng) / 2
    if (f(m, n, a)) {
      ok = m
    } else {
      ng = m
    }
  }
  println(ok)
}


Measured memory_bytes: 95704
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
int a[315][315];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	int ope = 0;
	ll ans = 0;
	
		
	for (int i = 0; i < n; i++) {
		int ijope = 0;
		for (int j = 0; j < n; j++) {
			int kope = 0;
			for (int k = 0; k < n; k++) {
				if (a[i][j] > a[i][k] + a[k][j])ope++;
				if (a[i][j] == a[i][k] + a[k][j]&&i!=j&&i!=k&&k!=j)kope++;
				
			}
			if (kope == 0)ans += a[i][j];
		}
	
	}

	if (ope != 0)cout << -1 << endl;
	else cout << ans/2 << endl;

	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<vector<ll>> dp(n, vector<ll>(3));

    rep(i,n){
        ll a,b,c;
        cin >> a >> b >> c;

        if(i == 0){
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }else{
            dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a);
            dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b);
            dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c);
        }
    }

    ll ans = 0;

    rep(i,3){
        ans = max(ans, dp[n - 1][i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b;
  cin >> a >> b;
  cout << a * b - (a + b - 1) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int M = 998244353;
const ll inf = 1e18;
const ld pi = acos(-1.0);
void solve(){
   ld b,c,h,m;
   cout<<fixed<<setprecision(12);
   cin>>b>>c>>h>>m;
   ld H = h*5+(5*m/60);
   ld M = m;
   ld A = min(H-M,60-H+M)/60;
   A*=2*pi;
   ld a = sqrt(b*b+c*c-2*b*c*cos(A));
   cout<<a<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
 //   cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 4184
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9 + 7;

vector<int> p;
vector< vector<int> > s;
int n, m; 

bool func(int a) {
  vector<bool> f(10, false);
  for(int i=0; i<10; i++) {
    int q = (1 << i);
    if((q&a) == q) {
      f[i] = true;
    }else{
      f[i] = false;
    }
  }

  for(int i=0; i<m; i++) {
    int cnt = 0;
    for(int j=0; j<s[i].size(); j++) {
      if(f[s[i][j]]) {
        cnt++;
      }
    }
    if(cnt%2 != p[i]) return false;
  }
  return true;
}

int main(void) {
  cin >> n >> m;
  p.resize(m);
  s.resize(m);

  long long ans = 0;
  for(int i=0; i<m; i++) {
    int k; cin >> k;
    vector<int> ss(k);
    for(int j=0; j<k; j++){
      cin >> ss[j];
      ss[j]--;
    }
    s[i] = ss;
  }

  for(int i=0; i<m; i++) cin >> p[i];

  for(int i=0; i<(1<<n); i++) {
    ans += func(i);
  }

  cout << ans << endl;
  
  return 0;
}



// EOF


Measured memory_bytes: 256
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		int sca=0,scb=0,a,b,x;
		while((x=Integer.parseInt(s.next()))!=0) {
			sca=0;scb=0;a=0;b=0;
			for(int i=x;i>0;--i) {
				a=Integer.parseInt(s.next());
				b=Integer.parseInt(s.next());
				if(a>b) {
					sca+=a+b;
				}else if(a<b) {
					scb+=a+b;
				}else {
					sca+=a;
					scb+=b;
				}
			}
			System.out.printf("%d %d\n",sca,scb);
		}
	}
}

Measured memory_bytes: 41924
def main():
    import string

    N = int(input())
    sb = []

    def rec(n):
        if 1 <= n <= 26:
            return string.ascii_lowercase[n-1]
        else:
            r = n%26
            q = n//26
            if r == 0:
                r = 26
                q -= 1
            return rec(q) + rec(r)

    print(rec(N))
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 9868
#include <stdio.h>
int main()
{
    int x,a,b,c,d,A,B;
    scanf("%d%d%d",&x,&a,&b);
    c=a-x;
    if (c<0)
        c=c*(-1);
    d=b-x;
    if (d<0)
        d=d*(-1);

    if(c<d)
    {
        printf("A");
    }
    else
    {
        printf(" B ");
    }

}


Measured memory_bytes: 128
N,M=gets.split.map(&:to_i)
E=M.times.map{gets.split.map(&:to_i)}
d=0
l=r=nil
E.sort{|l,r|r[0]<=>l[0]}.each do |(a,b)|
  d=1 unless l
  l=r=a unless l
  next if a==l
  next if l<b
  d += 1
  l = a
end
p d


Measured memory_bytes: 11128
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int a,b,c;
  cin>>a>>b>>c;
  ans(max((int)0,c-(a-b)));
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll a = in(), b = in(), c = in();
	cout << (a <= c && c <= b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	string s;
	int n;
	cin>>n>>s;
	if(n%2!=0) {
		cout<<"No";
		return 0;
	}
	for (int i = 0; i < n/2; ++i)
	{
		if(s[i]!=s[n/2+i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	

   return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    cin >> A >> B >> C;
    sort(all(A));
    sort(all(B));
    sort(all(C));

    int ans = 0;
    rep(i, 0, N) {
        int a = lower_bound(all(A), B[i]) - A.begin();
        int c = N - (upper_bound(all(C), B[i]) - C.begin());
        ans += a * c;
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 2560
import queue

n,m = map(int,input().split())
li = [[0 for _ in range(n)] for i in range(n)]
edge = []

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    li[a][b]=1
    li[b][a]=1
    edge.append([a,b])

def jdg(a,b,ans):
    li[a][b] = 0
    li[b][a] = 0

    srch = [0 for i in range(n)]
    q = queue.Queue()
    q.put(0)
    while(not q.empty()):
        memo = q.get()
        if srch[memo]==1:
            continue

        for i in range(n):
            if li[memo][i]==1:
                q.put(i)
        srch[memo] = 1

    #print(a,b,srch)
    if 0 in srch:
        ans += 1
    
    li[a][b] = 1
    li[b][a] = 1

    return ans

ans = 0
for i in range(len(edge)):
    ans = jdg(edge[i][0],edge[i][1],ans)
    #print(ans)

print(ans)


Measured memory_bytes: 3952
#include<cstdio>
int main(){
  int n, a, ans = 0;
  bool t = false;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++){
    scanf("%d", &a);
   if(t = a == i && !t) ans++;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[100005],cnt[100005];
set<int> v;
vector<int> ans;
void print(){
	for(i=0;i<n;i++){
		printf("%d%c",ans[i],(i+1==n?'\n':' '));
	}
	exit(0);
}
void inc(int x){
	ans.push_back(x);
	v.erase(x);
}
void dec(){
	v.insert(ans.back());
	ans.pop_back();
}
void dfs(int ban){
	if(ans.size()==n){
		print();
	}
	if(v.count(ban)&&cnt[ban]==n-ans.size()){
		return;
	}
	cnt[ban]--;
	for(set<int>::iterator it=v.begin();it!=v.end();it++){
		if(*it==ban) continue;
		inc(*it);
		dfs(a[*it]);
		dec();
	}
	cnt[ban]++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		v.insert(i);
	}
	dfs(0);
	puts("-1");
	return 0;
}

Measured memory_bytes: 11008
n = int(input())
alp='abcdefghij'
ansls=[list() for _ in range(n)]
ansls[0]=[('a',1)]
for i in range(1,n):
    for s,c in ansls[i-1]:
        for j in range(c+1):
            aps = s + alp[j]
            if j==c:
                c+=1
            ansls[i].append((aps,c))

ansls[-1].sort(key=lambda x:x[0])
for s,c in ansls[-1]:
    print(s)

    


Measured memory_bytes: 67036
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,x;
	cin >> n >> x;
	if(x==1 || x==2*n-1){
		cout << "No\n";
		return 0;
	}
	if(n==2){
		cout << "Yes\n1\n2\n3\n";
		return 0;
	}
	int nb=2*n-1; //bottomの数
	int ans[nb];

	ans[nb/2]=x;
	ans[nb/2 -1]=1;
	ans[nb/2 +1]=nb;
	int l,r,skip;
	if(x==2){
		ans[nb/2-2]=3;
		skip=3;
		l=nb/2-2;
		r=nb/2+2;
	}else{
		ans[nb/2+2]=x-1;
		skip=x-1;
		l=nb/2-1;
		r=nb/2+3;
	}
	int i=2;
	int pos=0;
	for(;;i++){
		if(i!=x && i!=skip){
			ans[pos++]=i;
		}
		if(pos==l) break;
	}
	i++;
	pos=r;
	if(r!=nb){
		for(;;i++){
			if(i!=x && i!=skip){
				ans[pos++]=i;
			}
			if(pos==nb) break;
		}
	}
	assert(i <= nb);
	cout << "Yes\n";
	rep(j,nb){
		cout << ans[j] << "\n";
	}

	return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    string c="";
    for(int i=0;i<26;i++){
        int t = i+n;
        t %= 26;
        c += ('A'+t);
    }
    for(int i=0;i<s.size();i++){
        s[i] = c[s[i]-'A'];
    }
    cout << s << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

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

ll n,k;
ll cx,j;
ll ans=0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    cx=n/k;
    ans+=cx*cx*cx;
    if(k%2==0)
    {
        j=k/2;
        cx=(n+j)/k;
        ans+=cx*cx*cx;
    }
    cout<<ans<<"\n";
    return 0;
}
/**

**/


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

class dice{

public:
  int _1,_2,_3,_4,_5,_6,temp;

  void moveN(){
    temp=_1;
    _1=_2;
    _2=_6;
    _6=_5;
    _5=temp;
  }

  void moveE(){
    temp=_1;
    _1=_4;
    _4=_6;
    _6=_3;
    _3=temp;
  }

  void moveW(){
    temp=_1;
    _1=_3;
    _3=_6;
    _6=_4;
    _4=temp;
  }

  void moveS(){
    temp=_1;
    _1=_5;
    _5=_6;
    _6=_2;
    _2=temp;
  }

  void spin(){
    temp=_2;
    _2=_3;
    _3=_5;
    _5=_4;
    _4=temp;
  }

};
int main(){
  dice d[100];
  int i,j,k,l,n;
  cin>>n;
  for(i=0; i<n; i++)cin>>d[i]._1>>d[i]._2>>d[i]._3>>d[i]._4>>d[i]._5>>d[i]._6;
  for(i=0; i<n; i++)for(j=0; j<n; j++){
     if(i==j)continue;
      for(k=0; k<3; k++){
        if(k==1){d[i].moveE();d[i].moveE();}
        if(k==2){d[i].moveE();}
          for(l=0; l<4; l++){
            d[i].spin();
            if(d[i]._1==d[j]._1 &&
               d[i]._2==d[j]._2 &&
               d[i]._3==d[j]._3 &&
               d[i]._4==d[j]._4 &&
               d[i]._5==d[j]._5 &&
               d[i]._6==d[j]._6){cout<<"No"<<endl;return 0;}
        }
      }
    }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

a,b, n = map(int, input().split())

if n >= b-1:
    x= b-1
    ans = int(a*x/b) - a*int(x/b)
    print(ans)
else:
    x = n
    ans = int(a*x/b) - a*int(x/b)
    print(ans)


Measured memory_bytes: 9164
def sqrtjudge(n):
    m = int(pow(n,0.5))
    return 1 if abs(m*m - n) < 1e-6 else 0

n,d = [int(i) for i in input().split()]
x = [[int(i) for i in input().split()] for j in range(n)]
ans = 0

for i in range(n):
    for j in range(i+1,n):
        ans += sqrtjudge(sum(pow(x[i][k]-x[j][k],2) for k in range(d)))

print(ans)

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

int main() {
  int N,i=0;
  string S;
  int p=0,w=0,g=0,y=0;
  
  cin >> N;
  
  for (i=0;i<=N;i++){
    cin >> S;
    if (S == "P"){
      p = 1;
    }
    else if (S == "W"){
      w = 1;
    }
    else if (S == "G"){
      g = 1;
    }
    else if (S == "Y"){
      y = 1;
    }
  }
  if (p+w+g+y == 4){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

string s;
int n=700;

int main(){
  cin>>s;
  rep(i,s.size()){
    if(s[i]=='o') n+=100;
  }

  cout<<n<<endl;

  return 0;
}


Measured memory_bytes: 256
while True:
    N,M=map(int,input().split())
    if N == 0 and M == 0:
        break
    mp = {}
    for _ in [0]*N:
        d,v=map(int,input().split())
        if d in mp:
            mp[d] = max(mp[d],v)
        else :
            mp[d] = v
            maxi=0
    for v in mp.values():
                maxi+=v
    print(maxi)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define int long long 
using namespace std;
using Graph = vector<vector<int>>;

signed main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if( A+B >= K ){
    cout << min(A, K) << endl;
  }else{
    K -= A+B;
    cout << A-K << endl;
  }
}

Measured memory_bytes: 3636
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<list>
#include<vector>
using namespace std;
vector<int>a;
int main() {
	int t,n;
	cin >> t;
	n = t;
	while (n--)
	{
		int temp;
		cin >> temp;
		a.push_back(temp);
	}
	int c=unique(a.begin(), a.end())-a.begin();
	for (int i = 0; i < c; i++)
	{
		if (i != 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
}




Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int flag=0;
    for(int i=n-2;i>=0;i--){
        if(arr[i]>arr[i+1]+1){
            flag=1;
          //  cout<<i<<endl;
            break;
        }
        if(arr[i]>arr[i+1]) arr[i]--;
    }
    if(flag==1) cout<<"No\n";
    else cout<<"Yes\n";
}

Measured memory_bytes: 640
mo=10^9+7
main=do
 [n,k]<-map read.words<$>getLine
 print$f 0 1 1(min(n-1)k)n
p a n
 |n==0=1
 |even n=p(a*a`mod`mo)(div n 2)
 |odd n=a*(p a$n-1)`mod`mo
f i x y lim n
 |i==lim=x*y`mod`mo
 |i<lim=(x*y`mod`mo+f(i+1)(x*(n-i)`mod`mo*r`mod`mo)(y*(n-i-1)`mod`mo*r`mod`mo)lim n)`mod`mo where r=p(i+1)(mo-2)

Measured memory_bytes: 56828
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end() 
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

const int MOD = 1e9 + 7;

int add(int x,int y){
	return (x + y) % MOD;
}

int mul(int x,int y){
	return (1LL*x*y) % MOD;
}

const int N = 2e5 + 5;

int p[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	p[0] = 1;
	rep(i,1,n+1){
		p[i] = mul(p[i-1], 2);	
	}
	int ans = 0;
	vector<int> a(n);
	rep(i,0,n){
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	rep(i,0,n){
		int x = a[i];
		int co = mul(mul(p[i],p[n-i-1]), mul(p[n-i-1], add(p[i], mul(i, (i == 0 ? 0 : p[i-1])))));
		co = mul(2, co);
		ans = add(ans,mul(co, x));
	}
	cout << ans << '\n';
}


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

/*
典型的なDP問題だがCなので全探索でいける難易度
三つの数字のgcdは二つのgcdのgcdを求めればよい
*/

int gcd(int x, int y) {
    if (x < y) {
        x, y = y, x;
    }
    while (x % y != 0) {
        int m = x % y;
        x = y;
        y = m;
    }
    return y;
}

int main() {
    int K;
    cin >> K;
    int sum = 0;

    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++)
        {
            for (int l = 1; l <= K; l++)
            {
                int a = gcd(i, j);
                int b = gcd(j, l);
                int x = gcd(a, b);
                sum += x;
            }
                }
        
    }
    cout << sum << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<math.h>
int main(void){
	double x1,x2,y1,y2,dis;
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	dis = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	printf("%lf\n",dis);
	return 0;
}

Measured memory_bytes: 652
#include <cstdio>
#include <cmath>
#include <algorithm>

int main() {
	long long N;
	std::scanf("%lld", &N);
	long long ans = 0;
	long long count = 0;
	long long prev;
	for (long long i = 0; i < N; ++i) {
		long long H;
		std::scanf("%lld", &H);
		if (i != 0) {
			if (prev >= H && i != N - 1) {
				++count;
			} else {
				if (prev >= H && i == N - 1) {
					++count;
				}
				ans = std::max(ans, count);
				count = 0;
			}
		}
		prev = H;
	}
	std::printf("%lld", ans);
}

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

#include <bits/stdc++.h>

using namespace std;

class arc098d {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        long long res = 0;
        for (int i = 0, j = 0, cur = 0; i < N; ++i) {
            while (j < N && cur + A[j] == (cur ^ A[j])) {
                cur += A[j];
                ++j;
            }
            res += j - i;
            cur -= A[i];
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc098d solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x), b(x), c(x);

    REP(i, x)
    cin >> a[i];
    REP(i, y)
    cin >> b[i];
    REP(i, z)
    cin >> c[i];
#if 0
    vector<ll> ab;
    for (int i = 0; i < x; ++i)
    {
        for (int j = 0; j < y; ++j)
        {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());

    vector<ll> abc;

    for (int i = 0; i < min(k, (int)ab.size()); i++)
    {
        for (int j = 0; j < z; ++j)
        {
            abc.push_back(ab[i] + c[j]);
        }
    }

#else
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());

    vector<ll> abc;
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            if ((i + 1) * (j + 1) > k)
                break;
            //1 3000
            //2 1500
            //3 1000
            //30 100

            for (int l = 0; l < z; l++)
            {
                if ((i + 1) * (j + 1) * (l + 1) > k)
                    break;
                abc.push_back(a[i] + b[j] + c[l]);
            }
        }
    }
#endif

    sort(abc.rbegin(), abc.rend());
    for (int i = 0; i < k; ++i)
    {
        Cout(abc[i]);
    }

    return 0;
}

Measured memory_bytes: 1532
N,K = map(int, input().split())

mylist= list(map(int, input().split()))

sortedmylist=sorted(mylist, reverse=True)
#print(sortedmylist)


if N<=K:
    print(0)
    
else:
    del sortedmylist[:K]
    #print(sortedmylist)
    print(sum(sortedmylist))

Measured memory_bytes: 26180
# import sys
# input = sys.stdin.readline

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

x,n = mp()
p = lmp()
for i in range(200):
    if x - i not in p:
        print(x-i)
        exit()
    elif x + i not in p:
        print(x + i)
        exit()






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

using namespace std;
using ll = long long;
ll a[202020],n,ans;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(i){
            if(a[i] < a[i-1]){
                ans += a[i-1] - a[i];
                a[i] = a[i-1];
            }
        }
    }
    cout<<ans<<'\n';
}


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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	int H, A;

	scanf("%d%d", &H, &A);

	printf("%d\n", (H-1)/A + 1);

	return 0;
}


Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
    
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long a=s.nextLong();
		long b=s.nextLong();
		long c=s.nextLong();
		long d=s.nextLong();
		while(a>0 && c>0)
		{c-=b;
		if(c<=0)
		break;
		a-=d;}
		if(a>0)
		System.out.println("Yes");
		else
		System.out.println("No");
		
	}
}
		
		
		   

Measured memory_bytes: 35796
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans = n-1;
    for (char c = 'a'; c <= 'z'; ++c) {
        int i;
        string t = s;
        for (i = n; count(t.begin(), t.begin()+i, c) != i && i > 0; --i) {
            for (int j = 0; j < n-1; ++j) {
                if (t[j] == c || t[j+1] == c) {
                    t[j] = c;
                }
            }
        }
        if (i != 0) ans = min(ans, n-i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {

		final Set<Character> wl = new HashSet<Character>();
		wl.add('a');
		wl.add('i');
		wl.add('u');
		wl.add('e');
		wl.add('o');

		char numN = next().charAt(0);

		out.println(wl.contains(numN) ? "vowel" : "consonant");
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

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

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

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

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

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

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

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

Measured memory_bytes: 21588
S=input()

max_bubun_length=0
tmp_bubun_length = 0
for i in range(len(S)):
    # print(S[i])
    # print(tmp_bubun_length)
    # print(max_bubun_length)
    if S[i] in "ACGT":
        tmp_bubun_length += 1
    else:
        if tmp_bubun_length > max_bubun_length:
            max_bubun_length = tmp_bubun_length
            # print(S[(i-tmp_bubun_length):i])
        tmp_bubun_length = 0
if tmp_bubun_length > max_bubun_length:
    max_bubun_length = tmp_bubun_length
print(max_bubun_length)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int M;
    cin >> M;
    cout << 48 - M << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  set<char> A;
  for(int i=0; i<L; i++){
    A.insert(S.at(i));
  }
  if(A.size()==L){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll n;
ll a[100005];

int main()
{
	ll ans = 1;
	ll s = 0;

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

	for (ll i = 1; i < n; i++) {
		if (s != 0) {
			if (s > 0 && a[i] - a[i - 1] < 0) {
				s = 0;
				ans++;
			} else if (s < 0 && a[i] - a[i - 1] > 0) {
				s = 0;
				ans++;
			}
		} else {
			if (a[i] - a[i - 1] > 0) {
				s = 1;
			} else if (a[i] - a[i - 1] < 0) {
				s = -1;
			} else {
				s = 0;
			}
		}
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 896
struct B{int w,s,v;}A[1111];n,i;long p[22222],s;c(a,b)struct B*a,*b;{s=a->w+a->s-b->w-b->s;}main(j){for(scanf("%*d");~scanf("%d%d%d",A+n,&A[n].s,&A[n].v);n++);for(qsort(A,n,12,c);i<n;i++)for(j=A[i].s;~j;)s=fmax(s,p[j+A[i].w]=fmax(p[j--+A[i].w],p[j]+A[i].v));printf("%ld",s);}

Measured memory_bytes: 380
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 100;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,a,b;
    cin >> n >> k;
    vector<P> s;
    rep(i,n){
        cin >> a >> b;
        s.push_back(P(a,b));
    }
    SORT(s);
    ll c = 0;
    rep(i,n){
        tie(a,b) = s[i];
        if (c < k && k <= c+b){
            PRINT(a);
            return 0;
        }
        c += b;
    }
}


Measured memory_bytes: 2420