akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int point;
		int max = Math.max(a, b);
		int min = Math.min(a, b);
		if(max == min) {
			point = max * 2;
		}else {
			point = max * 2 - 1;
		}
		System.out.println(point);
	}

}


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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    vector<ll> node;
    rep(n-1) {
        node.emplace_back(a[i+1] - a[i]);
    }
    node.emplace_back((k - a[n-1]) + a[0]);

    Sort(node);

    // for(auto i : node) cout << i << endl;

    ll ans = 0;
    rep(n-1) {
        ans += node[i];
    }
    cout << ans;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May  3 21:27:26 JST 2020
 **/

signed main() {
    Int n, A, B, C;
    std::cin >> n >> A >> B >> C;
    std::vector<std::string> s(n);
    REP(i, n) std::cin >> s[i];
    std::vector<char> ans;
    auto dfs = [&](auto f, Int a, Int b, Int c, Int idx) -> void {
        if (idx == n) {
            std::cout << "Yes" << std::endl;
            for (char c : ans) std::cout << c << "\n";
            exit(0);
        }
        if (s[idx] == "AB") {
            if (a > 0) {
                ans.push_back('B');
                f(f, a - 1, b + 1, c, idx + 1);
                ans.pop_back();
            }
            if (b > 0) {
                ans.push_back('A');
                f(f, a + 1, b - 1, c, idx + 1);
                ans.pop_back();
            }
        } else if (s[idx] == "BC") {
            if (b > 0) {
                ans.push_back('C');
                f(f, a, b - 1, c + 1, idx + 1);
                ans.pop_back();
            }
            if (c > 0) {
                ans.push_back('B');
                f(f, a, b + 1, c - 1, idx + 1);
                ans.pop_back();
            }
        } else {
            if (c > 0) {
                ans.push_back('A');
                f(f, a + 1, b, c - 1, idx + 1);
                ans.pop_back();
            }
            if (a > 0) {
                ans.push_back('C');
                f(f, a - 1, b, c + 1, idx + 1);
                ans.pop_back();
            }
        }
    };
    dfs(dfs, A, B, C, 0);
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 17944
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<string>
#include<math.h>

using namespace std;
#define ll long long
#define pb push_back
#define ld long double
#define mod 1000000007
ll cd(ll a,ll b)
{
	if(a==0)return b;
	else if (b==0)return a;
	else return cd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	char str[5];
	cin>>str;
	int c=0;
	int ans=0;
	for(int i=0;i<3;i++)
	{
		if(str[i]=='R')c++;
		else c=0;
		ans=max(ans,c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string.h>

using namespace std;

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    string first = {S[0], S[1]};
    string second = {S[2], S[3]};
    
    int f = atoi(first.c_str());
    int s = atoi(second.c_str());
    
    if (f > 0 && f < 13) {
        if (s > 0 && s < 13) {
            cout << "AMBIGUOUS";
        } else {
            cout << "MMYY";
        }
    } else if (s > 0 && s < 13) {
        cout << "YYMM";
    } else {
        cout << "NA";
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
  a := nextInt()
  b := nextInt()
  c := nextInt()
  ab2 := 4*a*b
  sa := c - a - b
  if sa < 0 {
    fmt.Println("No")
    return
  }
  sa2 := sa*sa
  if sa2 > ab2 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}


Measured memory_bytes: 640
let () =
    let rec gcd a b = if b = 0 then a else gcd b (a mod b) in
    let lcm a b = a / gcd a b * b in
    let main () =
        let n, m = Scanf.scanf "%d %d" (fun n m -> n, m) in
        let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun p -> p)) in
        let rec loop i acc =
            if i = n then acc else
                loop (i + 1) (lcm acc (a.(i) / 2))
        in
        let l = loop 1 (a.(0) / 2) in
        let r = if Array.fold_left (fun t k -> t || ((l / (k / 2)) mod 2 = 0)) false a then 0 else (m / l + 1) / 2 in
        Printf.printf "%d\n" r
    in
    main ()

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  for(int i=0;i<c;i++) {
    b -= a;
    if(b >= 0) {
      count++;
    }
    else {
      break;
    }
  }
  cout << count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int h, w;
  cin >> h >> w;
  char a[h][w];

  int b[h] = {0};
  int c[w] = {0};

  REP(i, h){
    REP(j, w){
      cin >> a[i][j];
      if(a[i][j] == '#') b[i] = 1;
    }
  }

  REP(j, w){
    REP(i, h){
      if(a[i][j] == '#') c[j] = 1;
    }
  }

  REP(i, h){
    if(b[i] == 1){
      REP(j, w){
        if(c[j] == 1) cout << a[i][j];
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm> 
#include <bits/stdc++.h>

#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
using namespace std;
typedef unsigned long long int ull;


int main(){
	int n,max=0;
	cin>>n;
	int*a =new int[n];
	int*b =new int[n];
	REP(i,0,n-1)
	{
		cin>>*(a+i);
		*(b+i)=*(a+i);
	}
	sort(b,b+n);
	int c=1;
	
	for(int i=n-2;i=0;i--)
	{
		if(b[i]==b[n-1])
		{
			c++;
		}
		else
			break;
	}
	if(c==1)
	{
		REP(i,0,n-1)
		{
			if(a[i]==b[n-1])
			{
				cout<<b[n-2]<<"\n";
			}
			else
				cout<<b[n-1]<<"\n";
		}	
	}	
	else
	{
		REP(i,0,n-1)
			cout<<b[n-1]<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int A=scan.nextInt();
    int B=scan.nextInt();
    if (((1<=A) && (A<=9))&&((1<=B) && (B<=9))){
      System.out.println(A*B);
    }
    else{
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sort_all(T& v) { return std::sort(v.begin(),v.end()); }
template<typename T>
auto sum_all(const T& v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

typedef llint Int;

int main(void)
{
    int N;
    cin >> N;
    if (N==1 || N==2 || N==3 || N==5 || N==6 || N==9 || N==10 || N==13 || N==17) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A,B,C = map(int, input().split())

s = A + B + C
M = max(A,B,C)
if M % 2 == 0 and s % 2 != 0:
    M += 1
elif M % 2 != 0 and s % 2 == 0:
    M += 1

ans = (3 * M - s) / 2
print(int(ans))


Measured memory_bytes: 9112
function Main(input) {
    const n = parseInt(input, 10);
    
    console.log(Math.pow(n,3));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

num_list = sorted([ int(v) for v in input().split() ])

a_sum, b_sum = 0, 0

for i in range(n):
  if i % 2 == 0:
    a_sum += num_list[i]
  else:
    b_sum += num_list[i]

print(abs(a_sum-b_sum))

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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2002;


void solve() {
    int s  , w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe";
    else cout << "safe";
}

/*
 
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    while(testcase --) {
        solve();
        cout << '\n';
    }
    
    return 0;
}
 



Measured memory_bytes: 3584
/*
    B - ROT N
    https://atcoder.jp/contests/abc146/tasks/abc146_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    string s;

    cin >> n;
    cin >> s;

    for (size_t i = 0; i < s.length(); i++) {
        int input = (int)s[i] + n;
        if (input > (int)'Z')
            input -= 26;
        cout << (char)input;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include <math.h>

#include <iostream>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)

typedef long long ll;

int extgcd(int a, int b, int &x, int &y) {
	int res = a;
	if (b) {
		res = extgcd(b, a % b, y, x);	
		y -= (a/b) * x;
	} else {
		x = 1;
		y = 0;
	}
	return res;
}

int main() {
	int a, b;
	int x, y;
	int gcd, lcm;
	while (scanf("%d%d ", &a, &b) != EOF) {
		if (a >= b) {
			gcd = extgcd(a, b, x, y);
		} else {
			gcd = extgcd(b, a, x, y);
		}

		lcm = a / gcd * b;
		printf("%d %d\n", gcd, lcm);
	}

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int main()
{
	int N, P[200010];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	int MIN = 1000000;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (P[i] < MIN) {
			ans++;
			MIN = P[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
S = str(input())

if len(S) == 2 :
  print (S)
else :
  print (S[2]+S[1]+S[0])




Measured memory_bytes: 38292
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias N = Tuple!(int, "v", int, "cnt");

N[10^^5+1] A, B;

void main()
{
    auto n = readln.chomp.to!int;
    foreach (i, v; readln.split.to!(int[])) {
        if (i%2) {
            A[v].v = v;
            ++A[v].cnt;
        } else {
            B[v].v = v;
            ++B[v].cnt;
        }
    }
    sort!"a.cnt > b.cnt"(A[]);
    sort!"a.cnt > b.cnt"(B[]);

    if (A[0].v == B[0].v) {
        if (A[1].v == 0 && B[1].v == 0) {
            writeln(min(A[0].cnt, B[0].cnt));
        } else if (A[1].v == 0) {
            writeln(n/2 - B[1].cnt);
        } else if (B[1].v == 0) {
            writeln(n/2 - A[1].cnt);
        } else {
            writeln(min(
                n - A[0].cnt - B[1].cnt,
                n - A[1].cnt - B[0].cnt
            ));
        }
    } else {
        writeln(n - A[0].cnt - B[0].cnt);
    }
}

Measured memory_bytes: 5944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{

	ll MOD = 1e9 + 7;
	int n;
	cin >> n;
	int a[n];
	map<int, int> m;
	REP(i, n){
		cin >> a[i];
		m[a[i]]++;
	}

	bool flag = 0;

	if (n % 2){
		for (auto x : m){
			if (x.first == 0){
				if (x.second != 1) flag = 1;
			}
			else if (x.second != 2) flag = 1;
		}
	}
	else {
		for (auto x : m){
			if (x.second != 2) flag = 1;
		}
	}

	if (flag) cout << 0 << endl;
	else {
		ll ans = 1;
		for (int i = 0; i < n/2; i++){
			ans *= 2;
			ans %= MOD;
		}

		cout << ans << endl;
	}

}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    /*
    vector<vector<ll>> alfa(N, vector<ll>(26, 0));
    rep(i, N) {
        string S;
        rep(j, S.size()) {
            alfa[i][S[j] - 'a']++;
        }
    }
    */
    map<string, ll> same;
    rep(i, N) {
        string S;
        cin >> S;
        sort(S.begin(), S.end());
        if (same.count(S) == 0) {
            same[S] = 1;
        }
        else {
            same[S]++;
        }
    }

    ll ans = 0;
    for (auto itr = same.begin(); itr != same.end(); itr++) {
        ll tmp = itr->second;
        if (tmp >= 2) ans += (tmp * (tmp - 1)) / 2;
    }

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

Measured memory_bytes: 11136
/*************************************************************************
  >         File: A.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 04 Sep 2016 07:58:58 PM CST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }
  if (a > b) std::swap(a, b);
  if (a > c) std::swap(a, c);
  if (b > c) std::swap(b, c);
  std::cout << 1LL * a * b << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int dp[100010];

int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    for(int i = 0; i < 100010; i++){
        dp[i] = 1<<30;
//        cerr << dp[i] << endl;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++){
//        cerr << dp[i+1] << " " << dp[i]+abs(h[i]-h[i+1]) << endl;
        for(int j = 1; j <= k; j++){
//            cerr << i+j << endl;
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
        cerr << dp[i] << endl;
    }

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


Measured memory_bytes: 1024
def kaijo(m):
    kotae=1
    for i in range(1,m+1):
        kotae*=i
    return kotae

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

for i in range(n):
    p[i]-=1
    q[i]-=1

pnum=0
qnum=0

pki=[[]for i in range(n)]
qki=[[]for i in range(n)]

for i in range(1,n):
    for j in range(i):
        pki[i].append(p[j])
        qki[i].append(q[j])

for i in range(n):
    kai=n-i-1
    count=0
    for j in range(p[i]):
        if(not j in pki[i]):
            count+=1
    pnum+=count*kaijo(kai)

    count=0
    for j in range(q[i]):
        if(not j in qki[i]):
            count+=1
    qnum+=count*kaijo(kai)

ans=pnum-qnum
ans=max(ans,-1*ans)

print(ans)

Measured memory_bytes: 3064
/**
 * ITP1_1_B X cubic
 */
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println((int)(Math.pow(Integer.parseInt(br.readLine()) , 3)));
    }

}

Measured memory_bytes: 24160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#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 ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll dp[102][100002], w[102], v[102], n;
ll solve(int i, int wt)
{
	if(i>=n)return 0;
	if(wt<0)return INT_MIN;
	if(wt == 0)return 0;
	if(dp[i][wt] != -1)return dp[i][wt];
	ll &ret = dp[i][wt];
	ret = INT_MIN;
	if(wt - w[i]>=0)ret = solve(i+1, wt-w[i]) + v[i];
	ret = max(ret, solve(i+1, wt));
	return ret;
}
void fff()
{
	ll wt;
	cin >> n >> wt;
	init(dp, -1);
	FOR(i,0,n)cin >> w[i] >> v[i];
	cout<<solve(0,wt);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

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

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

    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    int ans = 0;
    for(int a=0; a<n; ++a){
        bool ok = true;
        for(int b : edges[a]){
            if(h[a] <= h[b])
                ok = false;
        }
        if(ok)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8776
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n;cin>>n;
	ll a[n+1],b[n+1];for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(ll i=0;i<n;i++)
	{
		if(a[i]==b[n-1])cout<<b[n-2]<<endl;
		else cout<<b[n-1]<<endl;
	}
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	int current = 0;
	int[] heap;
	
	public Main() {
		heap = new int[500000];
	}
	
	public Main(int capacity) {
		heap = new int[capacity];
	}
	
	public void maxHeapify(int i) {
		int l = 2 * i + 1;
		int r = 2 * i + 2;
		int largest;
		
		if (l < heap.length && heap[l] > heap[i]){
			largest = l;
		} else {
			largest = i;
		}
		
		if (r < heap.length && heap[r] > heap[largest]) {
			largest = r;
		}
		
		if (largest != i) {
			int tmp = heap[i];
			heap[i] = heap[largest];
			heap[largest] = tmp;
			this.maxHeapify(largest);
		}
	}
	
	public void buildMaxHeap(int[] A) {
		this.heap = A;
		for (int i = A.length / 2; i >= 0; i--) {
			this.maxHeapify(i);
		}
	}
	
	public String toString() {
		StringBuilder str = new StringBuilder();
		for (int i : heap) {
			str.append(" " + i);
		}
		//str.append("\n");
		return str.toString();
	}
	
	public static void main(String[] args) {
Scanner in = new Scanner(System.in);
		
		int length = Integer.parseInt(in.nextLine());
		String[] data = in.nextLine().split(" ");
		int[] ints = new int[data.length];
		
		Main heapy = new Main(length);

		for (int i = 0; i < data.length; i++) {
			ints[i] = Integer.parseInt(data[i]);
		}
		
		heapy.buildMaxHeap(ints);
		System.out.println(heapy.toString());
	}
}


Measured memory_bytes: 141536
#include <iostream>
#include <string>
using namespace std;
int ctoi(const char);
int main(){
    string n;
    cin >> n;
    int size = n.size();
    int counter = 0;
    for(int i = 0;i < size;i++){
        char buf = n[i];
        counter += ctoi(buf);
        counter %= 9;
    }
    if(counter){
        cout << "No";
    }else{
        cout << "Yes";
    }
    return 0;
}

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  
  vector<int> L(N);
  for( int i = 0; i < N; i++ ) cin >> L.at(i);
  
  int D = 0;
  int count = 1;
  for( int i = 1; i < N+1; i++ ){
    D += L.at(i-1);
    if( D <= X ){
      count++;
    }
  }
  cout << count << endl;
}


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

public class Main {

	void submit() {
		int n = nextInt();
		int[] a = new int[n];
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
		}

		boolean ret = false;

		if (max - min > 1) {
		} else if (min == max) {
			ret |= min == n - 1; // ones
			ret |= n >= 2 * min; // not ones
		} else {
			int cMin = 0;
			int cMax = 0;
			for (int x : a) {
				if (x == min) {
					cMin++;
				} else {
					cMax++;
				}
			}
			
			
			int onesCol = cMin;
			int notOnesCol = max - onesCol;
			
			ret |= onesCol > 0 && notOnesCol > 0 && notOnesCol * 2 <= cMax;
		}
		
		out.println(ret ? "Yes" : "No");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


Measured memory_bytes: 33764
#include <iostream>

using namespace std;

int hist[1100000];

int main()
{
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    hist[a]++;
  }
  
  int ans = -1;
  for (int i = 0; i < 1100000; i++) {
  	ans = max(ans, hist[i - 1] + hist[i] + hist[i + 1]);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
K, S = [int(i) for i in input().split()]

ans = 0
# X <= Y <= Zとしても一般性を失わない
for x in range(K + 1):
    for y in range(x, K + 1):
        z = S - x - y
        if z < y:
            break
        if z <= K:
            if x == y == z:
                ans += 1
            elif x == y or y == z or z == x:
                ans += 3
            else:
                ans += 6
print(ans)


Measured memory_bytes: 41308
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>b(2*m+1);
    ll sum=0;
    REP(i,1,n){
        ll x=a[i-1];
        ll y=a[i];
        if(y<x)y+=m;
        b[x+2]++;
        b[y+1]--;
        sum+=y-x;
    }
    REP(i,1,2*m+1)b[i]+=b[i-1];
    ll ma=0;
    REP(i,1,n){
        ll x=a[i-1];
        ll y=a[i];
        if(y<x)y+=m;
        b[y+1]-=y-x-1;
    }
    REP(i,1,2*m+1){
        b[i]+=b[i-1];
    }
    REP(i,1,m+1){
        b[i]+=b[i+m];
        ma=max(b[i],ma);
    }
    cout<<sum-ma<<endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

bool pr[SIZE];

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

    pr[1] = pr[0] = 1;
    for(int i = 2; i < SIZE; ++i) {
        if(!pr[i]) {
            for(int j = i * 2; j < SIZE; j += i) {
                pr[j] = true;

            }
        }
    }
    int q;
    cin >> q;

    int s[SIZE] = {};
    for(int i = 1; i < SIZE; ++i) {
        if(!pr[i] && !pr[(i + 1) / 2]) {
            s[i]++;

        }
        s[i] += s[i - 1];
    }

    while(q--) {
        int l, r;
        cin >> l >> r;
        cout << s[r] - s[l - 1] << endl;

    }
    return 0;
}



Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define MAX_N (300005)
#define INF (1LL<<60)
#define debug(x) cerr << #x <<":"<< x << endl;
#define debugVec(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define debugVecPair(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define debug2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define debug3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;
typedef pair<int,int> P;

signed main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    char ch = S[K-1];
    string ans;
    for(int i=0; i<S.length(); i++){
        if(S[i] == ch){
            ans.push_back(S[i]);
        } else {
            ans.push_back('*');
        }
    }
    cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	
	for(int i=0;i<N;++i) {
		int K, P, m;
		cin >> K >> P;
		m = K % P;
		cout << (m == 0 ? P : m) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
N = int(input())
 
if N % 2 > 0 or N < 10:
  print(0)
  exit()
else:
  #S = str(N)[::-1]
  ans = 0
  N = N // 10
  for i in range(50):
    ans += N
    N = N // 5
    
print(ans)

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

template <std::uint_fast64_t Modulus> class modint {
  using u64 = int;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const int mod = 1e9+7;
const int MX = 2e5;

int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

signed main(){
  using mint=modint<mod>;
  int n,a,b;
  mint ca,cb;
  cin>>n>>a>>b;
  mint p=power(2,n,mod);
  p-=1;
  ca=cb=1;
  for(int i=0;i<a;++i)ca*=(n-i);
  for(int i=1;i<=a;++i)ca/=i;
  for(int i=0;i<b;++i)cb*=(n-i);
  for(int i=1;i<=b;++i)cb/=i;
  int res=(p-ca-cb).value();
  cout<<res;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9+7;

int[2][] prime_division(int m)
{
    int[2][] r;
    for (int x = 2; x^^2 <= m; ++x) {
        int cnt;
        while (m % x == 0) {
            ++cnt;
            m /= x;
        }
        if (cnt) r ~= [x, cnt];
    }
    if (m != 1) r ~= [m, 1];
    return r;
}

void main()
{
    auto nm = readln.split.to!(int[]);
    long N = nm[0];
    auto M = nm[1];

    long[][] MEMO;
    MEMO.length = 10^^5+1;
    foreach_reverse (i, ref memo; MEMO[0..N+1]) {
        memo.length = 41;
        foreach (j, ref x; memo) {
            if (j == 0) {
                x = 1;
            } else if (i == N) {
                x = 0;
            } else {
                x = (MEMO[i+1][j] + MEMO[i][j-1]) % P;
            }
        }
    }

    long r = 1;
    foreach (p; prime_division(M)) {
        r = (r * MEMO[0][p[1]]) % P;
    }
    writeln(r);
}

Measured memory_bytes: 56956
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;



int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k;
	cin >>n >>k;
	VI d(10,0);
	rep(i,k){
		int dd; cin>>dd;
		d[dd] = 1;
	}
	rep2(i, n ,1000011){
		int w=i, ok = 1;
		for(;w>0;w /=10){
			if(d[w%10] >0){ ok=0; break;}
		}
		if(ok){ cout << i << endl; return 0;}
	}
	cout << -1 <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;
bool used[4];
void solve(){
    int a, b;
    cin >> a >> b;
    used[a] = true;
    used[b] = true;
    for(int i = 1; i <= 3; i++){
        if(!used[i]){
            cout << i;
        }
    }
}

 
int main(){
    barsik;
    int q = 1;
//    freopen("file.txt", "w", stdout);
    //cin >> q;
 
    for(double i = 1; i <= q; i++){
        //cout << "Case " << i << ": ";
        solve();
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1e5+100;
int a[N],p[N],n;
bool cmp(int x,int y){
    return a[x]<a[y];
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        p[i]=i;
    }
    sort(p+1,p+1+n,cmp);
    for(int i=1;i<=n;++i) printf("%d ",p[i]);
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll dp[10007],C[13];
map<ll,ll> M;
string S,D;

int main(){
  ll N,T,A[13],B[13];D="0123456789";
  B[1]=2;B[2]=5;B[3]=5;B[4]=4;B[5]=5;B[6]=6;B[7]=3;B[8]=7;B[9]=6;
  cin >> N >> T;
  S.clear();
  rep(i,T){
    cin >> A[i];
    C[A[i]]++;
    M[B[A[i]]]++;
  }
  Rep(i,1,N+1){
    Rep(j,2,8){
      if(M[j]>0  && i-j>=0){
        if(i-j == 0 || dp[i-j]!=0){
          dp[i]=max(dp[i-j]+1,dp[i]);
        }
      }
    }
  }
  while(N>0){
    rRep(i,9,1){
      if(N-B[i]>=0){
        if(C[i]>0 && dp[N] == dp[N-B[i]] + 1 && (dp[N]!= 1 || N-B[i] == 0)){
          S = S + D[i];
          N = N-B[i];
          break;
        }
      }
    }
  }

  cout << S << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int x;
	cin>>x;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			if(i*j==x)
			{
				cout<<"Yes";
				return 0;
			}
			
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
// ABC080_A.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <algorithm>
//#include "stdafx.h"
#include <iostream>
using namespace std;


int main()
{
	int n, a, b;
	cin >> n >> a >> b; //スペースで区切られたものを別々に入力

	if (n*a < b) {
		cout << n*a<<endl;
	}
	else {
		cout << b<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int f[20],x;
int main(){
	fo(i,1,3){
		scanf("%d",&x);
		f[x]++;
	}
	if (f[5]==2&&f[7]==1) printf("YES\n");else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    char s[11], t[11], u[11];
    int sn, tn;

    scanf("%s %s", s, t);
    scanf("%d %d", &sn, &tn);
    scanf("%s", u);

    if(strcmp(s, u) == 0){
        sn--;
        printf("%d %d", sn, tn);
        return 0;
    }else{
        tn--;
        printf("%d %d", sn, tn);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long ;

int main () {


    ll s = 100;

    ll x;

    cin >> x;

    int ans = 0;

    while (s < x) {
        s = s + s / 100;
        ++ ans;
    }

    cout << ans << endl;

}
/*
    Good Luck
        -Lucina
*/
/*
    I hate Progmeth
*/


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

typedef unsigned long long ULL;

int main()
{
  int A,B,C,D;
  int r;

  cin >> A >> B >> C >> D;

  if(C <= A && B <= D)
    r = B - A;
  else
  if(A < C && D < B)
    r = D - C;
  else
  if(A < C && C < B)
    r = B-C;
  else
  if(A > C && D > A)
    r = D-A;
  else
    r = 0;

  cout << r << endl;
  return 0;
}



Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx = tx-sx
dy = ty-sy
s1 = 'D'+'R'*(dx+1)+'U'*(dy+1)+'L'
s2 = 'U'+'L'*(dx+1)+'D'*(dy+1)+'R'
s3 = 'R'*dx+'U'*dy
s4 = 'L'*dx+'D'*dy
print(s1+s2+s3+s4)

Measured memory_bytes: 3060
//  main.cpp
//  CF
//
//  Created by Shubham Rajput on 25/08/19.
//  Copyright © 2019 Shubham Rajput. All rights reserved.
//

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define ll  long long
#define vi vector<int>
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define revloop(i,n) for(int i=n-1;i>=0;i--)
#define revloop1(i,n) for(int i=n;i>=1;i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define ff first
#define ss second
#define print(x) printf("%.9Lf\n",x)
#define MOD 1000000007
#define MAX 100005
#define MAX6 1000005
#define MAX3 1005
#define nw cout<<endl
#define lc 2*node+1
#define rc 2*node+2
#define PRINT(v) for(int i=0;i!=v.size();i++)cout<<v[i]<<" "
#define modInverse(x) power(x,MOD-2)
#define MINIMUM -100000000000000
#define svec(vct) sort(vct.begin(),vct.end())
#define what_is(qq) cerr << #qq << " is " << qq << endl
#define BIG 1e11
#define S1(xz) scanf("%d",&xz)
using namespace std;
#define MAX4 1025
#define LOW -10000000000
#define INF 1e9

int main()
{
    
    //freopen("A.in","r",stdin);
    //freopen("B.out","w",stdout);
    
    int T,x,y,z;
    //seive();
    //scanf("%d",&T);
    T=1;
    //memset(BIT, 0, sizeof(BIT));
    for(int tc=1; tc<=T; tc++)
    {
        int h,a;
        cin>>h>>a;
        x = h/a;
        if(h%a!=0){
            x++;
        }
        cout<<x<<endl;
        
        
        
    }
    
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  
  set<int> result;
  for (int i = 0; i < K; ++i)
  {
    int d;
    cin >> d;
    vector<int> A(d);
    for (int j = 0; j < d; ++j)
    {
      cin >> A[j];
      result.insert(A[j]);
    }
    A.clear();
  }

  cout << N - result.size() << endl;
}

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

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

int main() {
    int k, n;
    cin >> k >> n;
    int first = 0;
    int prev = 0;
    int max_distance = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if(i==0)    first = a;
        else        max_distance = max(max_distance, a - prev);
        prev = a;
    }
    max_distance = max(max_distance, (first + k) - prev);
    cout << k - max_distance << endl;
    return 0;
}

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

int main () {
  int n, a; cin >>n>>a;
  
  int x = n/500;
  int y = n%500;
  if (x*500 + y == n && y>=0 && y<=a)
    cout << "Yes" << endl;
  else cout << "No" << endl;  
}

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

int main() {

  int N,t;
  int n=0;
  cin >> N;
  t=N;
  while(t>0){
  n+=t%10;
  t/=10;
  }
  if(N%n==0){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int get(int x){
	int ret=0;
	for(int i=2;i<=x;i++){
		int sv=x;
		while(sv>1){
			if(sv%i){
				sv-=i;
			}
			else{
				sv/=i;
			}
		}
		if(sv==1){//&&x%i!=0&&(x-1)%i!=0){
			ret++;
//			printf("%d ",i);
		}
	}
//	putchar('\n');
	return ret;
}
ll x,ans;
ll c1(ll num){
	ll sv=x;
	while(sv%num==0){
		sv/=num;
	}
	if(sv%num==1)	return 1;
	else	return 0;
}
int main(){
	cin>>x;
	if(x==2){
		puts("1");
		return 0;
	}
	ans=0;
	for(ll i=2;i*i<=x;i++){
		if(x%i==0){
			if(i*i==x){
				ans+=c1(i);
			}
			else{
				ans+=c1(i);
				ans+=c1(x/i);
			}
		}
	}
	x--;
	for(ll i=2;i*i<=x;i++){
		if(x%i==0){
			if(i*i==x)	ans++;
			else	ans+=2;
		}
	}
	cout<<ans+2<<endl;
	return 0;
}


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

using ll = long long;

constexpr ll M = 1e9+7;

vector<bool> f;

ll expr(string const& s, int& p);
ll term(string const& s, int& p);
void sp(string const& s, int& p);
ll number(string const& s, int& p);

ll expr(string const& s, int& p) {
    sp(s, p);
    ll v1 = term(s, p);
    sp(s, p);
    while(p+1 < s.size() && f[p]) {
        p += 2;
        sp(s, p);
        ll v2 = term(s, p);
        if(v2 > 63) {
            v1 = 0;
        } else {
            v1 >>= v2;
        }
        sp(s, p);
    }
    return v1;
}

ll term(string const& s, int& p) {
    sp(s, p);
    if(s[p] == 'S') {
        sp(s, ++p);
        p++; // <
        sp(s, p);
        ll v = expr(s, p);
        sp(s, p);
        p++; // >
        v = (v * v) % M;
        return v;
    }
    return number(s, p);
}

void sp(string const& s, int& p) {
    while(p < s.size() && s[p] == ' ') {
        p++;
    }
}

ll number(string const& s, int& p) {
    int res = 0;
    while(p < s.size() && isdigit(s[p])) {
        res *= 10;
        res += s[p++] - '0';
    }
    return res;
}

int main() {
    while(true) {
        string s;
        getline(cin, s);
        if(s[0] == '#') {
            break;
        }
        int p = 0;
        f.assign(s.size(), false);
        for(int i=s.size()-1; i>=0; --i) {
            if(isdigit(s[i]) || s[i] == 'S') {
                if(isdigit(s[i])) {
                    while(i > 0 && isdigit(s[i])) {
                        --i;
                    }
                } else if(s[i] == 'S') {
                    i--;
                }
                while(i > 0 && s[i] == ' ') {
                    i--;
                }
                if(s[i] == '>') {
                    i--;
                    f[i] = true;
                }
            }
        }
        cout << expr(s, p) << endl;
    }
}


Measured memory_bytes: 5852
H,W = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))

b = []
for idx,a in enumerate(A):
  for i in range(a):
    b += [idx+1]

for i in range(H):
  subset = b[i*W:(i+1)*W]
  if i % 2 == 1:
    subset = list(reversed(subset))
  string = " ".join(list(map(str,subset)))
  print(string.strip())

Measured memory_bytes: 40688
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	ll n,k; cin>>n>>k;
	ll ans=n%k;
	ans=min(ans,k-ans);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384