akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n,s)		for(i=s;i<n;i++)
#define repr(i,n,s)		for(i=s;i>=n;i--)
#define remax(x,y)		x = max(x,(y))
#define remin(x,y)		x = min(x,(y))
#define all(c)			(c).begin(),(c).end()
#define allr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define loopr(c,i)      for(typeof(c.end()) i = c.end(); i != c.begin(); )
#define ll long long
#define ittr(v) typeof(v)::iterator

#define pb	push_back
#define mp 	make_pair
#define vi 	vector<int>
#define vl 	vector<long>
#define vpii 	vector< pair<int,int> >
#define vpil 	vector< pair<int,long> >
#define vpll 	vector< pair<long,long> >

#define pii 	pair<int,int>
#define piii	pair< pair<int,int>,int >
#define pll 	pair<long,long>
#define plll 	pair< pair<long,long>,long >

#define umii 	unordered_map<int,int>

using namespace std;
int main()
{
	int i,n,d,x;
	cin>>n;
	int a[n];
	cin>>d>>x;
	rep(i,n,0)
		cin>>a[i];
	ll ans=x;
	rep(i,n,0)
	{
		ans += (d-1)/a[i] + 1;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#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)
#define all(x) (x).begin(),(x).end()
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;
typedef pair<int, int> P;
int main()
{
    int A, B;
    cin >> A >> B;

    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    if (s.size() <= n) {
        cout << s;
    } else {
        cout << s.substr(0, n) << "...";
    }
}

Measured memory_bytes: 3644
package main

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

var N int

func main() {
	fmt.Scan(&N)
	A := make([]int, N)
	m := make(map[int]int, N)

	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	for i := 0; i < N; i++ {
		reader.Scan()
		A[i], _ = strconv.Atoi(reader.Text())
	}

	for i := 0; i < N; i++ {
		if m[A[i]] == 0 {
			m[A[i]]++
		} else {
			delete(m, A[i])
		}
	}
	fmt.Println(len(m))
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 4992
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  cin>>n;
  cout<<(n-1)/2<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char a[1000000],b[1000000];
int lena;
int main()
{
    cin>>a;
    lena=strlen(a);
    for(int i=lena-1;i>=0;i--)b[lena-i-1]=a[i];
    for(int i=0;i<lena;i++)
    {
        if(b[i]=='q')b[i]='p';
        else if(b[i]=='p')b[i]='q';
        if(b[i]=='b')b[i]='d';
        else if(b[i]=='d')b[i]='b';
    }
    for(int i=0;i<lena;i++)
    if(b[i]!=a[i])
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
    int n,i,sum=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i]-1;
    }
    printf("%d\n",sum);
    return 0;
}




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

int main(){
  int A, B, C, X, Y, price = 0;
  cin >> A >> B >> C >> X >> Y;
  price = min(X, Y) * min(A+B, C*2);
  if(X < Y){
  	price += (Y - X) * min(B, C*2);
  }else if(X > Y){
  	price += (X - Y) * min(A, C*2);
  }
  cout << price << endl;
  return 0;
}

Measured memory_bytes: 256
import copy

N = int(input())
A = list(map(int,input().split()))
ans = 0
while 1:
  newA = []
  for a in A:
    if a % 2 == 0:
      newA.append(a//2)
    else:
      print(ans)
      exit()
  ans += 1
  A = copy.deepcopy(newA)
print(ans)

Measured memory_bytes: 40176
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
using namespace std;
long long n,k,sol=1;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        if(sol*2<sol+k)
            sol*=2;
        else
            sol+=k;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
# ALDS1_7_C: Tree Walk

class BinaryTree

  class Node
    attr_reader :id, :parent, :left, :right

    def initialize(id)
      @id = id
    end

    def set_children(left, right)
      @left  = left
      @right = right
      @left.set_parent self
      @right.set_parent self
    end

    def root?
      @parent.nil?
    end

    def nil_node?
      self == NIL
    end

    protected
      def set_parent(parent)
        @parent = parent
      end
  end

  NIL = Node.new(-1)

  def initialize(data)
    nodes = Array.new(data.size).map.with_index do |_, i|
      Node.new(i)
    end

    data.each do |id, left_id, right_id|
      left  = left_id  == -1 ? NIL : nodes[left_id]
      right = right_id == -1 ? NIL : nodes[right_id]
      bind nodes[id], left, right
    end

    @root = nodes.find { |n| n.root? }
  end

  def preorder_walk(node = @root)
    return [] if node.nil_node?
    [node] + preorder_walk(node.left) + preorder_walk(node.right)
  end

  def inorder_walk(node = @root)
    return [] if node.nil_node?
    inorder_walk(node.left) + [node] + inorder_walk(node.right)
  end

  def postorder_walk(node = @root)
    return [] if node.nil_node?
    postorder_walk(node.left) + postorder_walk(node.right) + [node]
  end

  private
    def bind(parent, left, right)
      parent.set_children left, right
    end
end

def nodes_to_s(nodes)
  ' ' << nodes.map(&:id).join(' ')
end

n_nodes = gets.to_i
node_data = n_nodes.times.map do
  gets.split.map &:to_i
end

tree = BinaryTree.new node_data

puts [
  'Preorder',
  nodes_to_s(tree.preorder_walk),
  'Inorder',
  nodes_to_s(tree.inorder_walk),
  'Postorder',
  nodes_to_s(tree.postorder_walk)
]

Measured memory_bytes: 8676
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

unsigned gcd(unsigned a, unsigned b)
{

	if (a % b == 0)
	{
		return b;
	}
	
	return gcd(b, a % b);
}

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

	unsigned A, B, K;
	cin >> A >> B >> K;
	unsigned D = gcd(A, B);

	unsigned div = 1;
	vector<unsigned> divs;
	for (; div <= D; ++div)
	{
		if (D % div == 0)
		{
			divs.emplace_back(div);
		}
	}

	cout << divs[divs.size() - K];

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
h,w,n = map(int,input().split())
need = []
for i in range(n):
    a,b = map(int,input().split())
    for x in range(-2,1):
        for y in range(-2,1):
            s = a + x
            t = b + y
            if 1 <= s <= h-2 and 1 <= t <= w-2:
                need.append(s*10**10 + t)

data = Counter(need).most_common()
ans = [0 for i in range(10)]
for x,y in data:
    ans[y] += 1

print((h-2)*(w-2)-sum(ans))
for i in ans[1:]:
    print(i)


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

namespace ABC100C
{
    static class MainClass
    {

        public static void Main(string[] args)
        {


            int N = int.Parse(Console.ReadLine());
            var alst = Console.ReadLine().Split(' ');//.AsQueryable();//.Cast<int?>();
            int ans = 0;


            foreach (string a in alst)
            {
                ans += PF2(int.Parse(a));
            }

            Console.WriteLine(ans);
          

            return;


        }

        public static int PF2(int n)
        {
            int ans = 0;
            while (n > 0)
            {
                int res = n % 2;
                if (res == 0)
                {
                    ans++;
                    n = n / 2;
                }
                else
                {
                    n = 0;
                }
            }


            return ans;
        }


        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }




    }

}






Measured memory_bytes: 13792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	long long a, b, k, buf;
	cin >> a >> b >> k;

	if (k > a)
	{
		buf = a;
		a = 0;
		k -= buf;
		if (k > b)
		{
			b = 0;
		}
		else
		{
			b -= k;
		}
	}
	else
	{
		a -= k;
	}

	cout << a << " " << b << endl;
}

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

#define INF 1111111111

#define KI_MAX (1 << 18) /* 262144 */

int ki[KI_MAX * 2 - 1];

void ki_set(int idx, int value) {
	int pos = KI_MAX - 1 + idx;
	ki[pos] = value;
	do {
		pos = (pos - 1) / 2;
		ki[pos] = ki[pos * 2 + 1] < ki[pos * 2 + 2] ? ki[pos * 2 + 1] : ki[pos * 2 + 2];
	} while (pos > 0);
}

int ki_get_i(int idx, int qstart, int qend, int sstart, int send) {
	if (qend <= sstart || send <= qstart) { /* 完全にはずれている */
		return INF;
	} else if (qstart <= sstart && send <= qend) { /* セグメントがクエリに完全に含まれる */
		return ki[idx];
	} else {
		int smid = sstart + (send - sstart) / 2;
		int left = ki_get_i(idx * 2 + 1, qstart, qend, sstart, smid);
		int right = ki_get_i(idx * 2 + 2, qstart, qend, smid, send);
		return left < right ? left : right;
	}
}

int ki_get(int start, int end) {
	return start < end ? ki_get_i(0, start, end, 0, KI_MAX) : INF;
}

int N;
int a[271828];

int ec[271828];
int* es[271828];

void ae(int f, int t) {
	es[f] = realloc(es[f], sizeof(*es[f]) * (ec[f] + 1));
	if (es[f] == NULL) exit(2);
	es[f][ec[f]++] = t;
}

int kotae[271828];

int mareitaso(int query) {
	int l = 0, r = N + 99;
	while (l + 1 < r) {
		int m = l + (r - l) / 2;
		if (ki_get(m, N + 100) < query) l = m; else r = m;
	}
	return l;
}

void dfs(int node, int parent) {
	int neko = mareitaso(a[node]) + 1;
	int bak = ki_get(neko, neko + 1);
	int i;
	if (bak > a[node]) ki_set(neko, a[node]);
	kotae[node] = mareitaso(INF);
	for (i = 0; i < ec[node]; i++) {
		int next = es[node][i];
		if (next != parent) dfs(next, node);
	}
	ki_set(neko, bak);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 1; i <= N + 100; i++) ki_set(i, INF);
	for (i = 1; i <= N - 1; i++) {
		int u, v;
		if (scanf("%d%d", &u, &v) != 2) return 1;
		ae(u, v);
		ae(v, u);
	}
	dfs(1, 0);
	for (i = 1; i <= N; i++) {
		printf("%d\n", kotae[i]);
	}
	return 0;
}


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


#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 MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	auto bin_pows =[](ll x, ll n, ll mod){
		ll res = 1LL;
		for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
		return res;
	};
	fct[0] = fct[1] = inv[1] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	inv[cmx] = bin_pows(fct[cmx], mod-2, mod);
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k;
	cin >>n >>k;
	
	finit(n*2+1000);
	
	if(n<= k){
		cout << nCk(n+n-1, n) <<"\n";
		return 0;
	}
	ll ans = 0;
	rep(i, k+1){
		(ans += nCk(n, i) * nCk(n-1, i)) %=MD;
	}
	cout << ans%MD <<"\n";
	return 0;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main {
    static final int[] dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
    static ArrayDeque<Board> que = new ArrayDeque<>();

    static class Board {
        int[][] board;
        int x, y, cnt;

        Board(int[][] b, int x, int y, int cnt) {
            board = new int[b.length][];
            for (int i = 0; i < b.length; ++i) {
                board[i] = new int[b[i].length];
                System.arraycopy(b[i], 0, board[i], 0, b[i].length);
            }
            this.x = x;
            this.y = y;
            this.cnt = cnt;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int w, h;
        while (true) {
            w = scanner.nextInt();
            h = scanner.nextInt();

            if (w == 0 && h == 0) break;

            int[][] board = new int[h][w];
            int sx = 0, sy = 0, ans = 100;

            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    board[i][j] = scanner.nextInt();
                    if (board[i][j] == 2) {
                        sx = j;
                        sy = i;
                    }
                }
            }

            que.push(new Board(board, sx, sy, 0));
            while (!que.isEmpty()) {
                Board b = que.poll();
                for (int i = 0; i < 4; ++i) {
                    for (int j = 1; j <= 20; ++j) {
                        int nx = b.x + j * dx[i], ny = b.y + j * dy[i];
                        if (nx < 0 || nx >= w || ny < 0 || ny >= h) break;

                        int bx = nx - dx[i], by = ny - dy[i];
                        if (b.board[ny][nx] == 1) {
                            b.board[ny][nx] = 0;
                            if ((bx != b.x || by != b.y) && b.cnt < 10) que.push(new Board(b.board, bx, by, b.cnt + 1));
                            b.board[ny][nx] = 1;
                            break;
                        } else if (b.board[ny][nx] == 3) {
                            ans = Math.min(ans, b.cnt + 1);
                        }
                    }
                }
            }

            System.out.println((ans > 10 ? -1 : ans));
        }
    }
}


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

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

	ll n,k; cin >> n >> k;
	ll ans = n%k;
	ans = min(ans,abs(ans-k));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A,B,C,X;

int main() {
  INCANT;
  cin >> A >> B >> C>> X;
  int res=0;
  rep(i, A+1) {
    rep(j, B+1) {
      rep(k, C+1) {
        if (X == i*500+j*100+k*50) res++;
      }
    }
  }
  cout << res << "\n";
  return 0;
}

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

int par[100000],rnk[100000];

void init(int n){
	for(int i = 0;i < n;i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]) par[x] = y;
	else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}

int main(){
	int n,m,k,bukatu[100000];
	cin >> n >> m >> k;
	for(int i = 0;i < n;i++) bukatu[i] = -1;
	init(n);
	for(int i = 0;i < k;i++){
		int t,a,b;
		cin >> t >> a >> b;
		if(t == 1){
			a--;b--;
			a = find(a);
			b = find(b);
			if(bukatu[a] == -1 && bukatu[b] != -1){
				int bu = bukatu[b];
				unite(a,b);
				bukatu[find(a)] = bu;
			}else if(bukatu[a] != -1 && bukatu[b] == -1){
				int bu = bukatu[a];
				unite(a,b);
				bukatu[find(a)] = bu;
			}
			else if(bukatu[a] != bukatu[b]){
				cout << i + 1 << endl;
				return 0;
			}else unite(a,b);
		}else{
			a--;
			a = find(a);
			if(bukatu[a] == -1) bukatu[a] = b;
			else if(bukatu[a] != b){
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 4288
#include<iostream>
#include<queue>

using namespace std;

int main(){
  int n, a, sma=0, smb=0;
  cin >> n;
  priority_queue<int> q;
  for(int i=0;i<n;i++){
    cin >> a;
    q.push(a);
  }
  while(!q.empty()){
    sma+=q.top();q.pop();
    if(q.empty())break;
    smb+=q.top();q.pop();
  }
  cout << sma - smb << endl;
}

Measured memory_bytes: 256
N, M, C = map(int,input().split())
B = input().split()
A = [(input().split()) for i in range(N)]   

res = 0
count = 0

for i in range(N):    
    for j in range(M):
        res += int(B[j])*int(A[i][j])
    if res + C > 0:
        count += 1
    res = 0
print(count)

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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

const int dxy[5] = {-1, 0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int H, W;
    cin >> H >> W;

    vector<string> f;
    queue<pair<int, int>> q;

    vector<vector<int>> d(H, vector<int>(W, -1));
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        f.push_back(s);
        for (int j = 0; j < W; j++)
        {
            if (s[j] == '#')
            {
                q.push({i, j});
                d[i][j] = 0;
            }
        }
    }

    int ans = 0;
    while (q.size())
    {
        pair<int, int> p = q.front();
        q.pop();

        int y = p.first, x = p.second;
        for (int i = 0; i < 4; i++)
        {
            int ny = y + dxy[i], nx = x + dxy[i + 1];
            if (ny >= 0 && ny < H && nx >= 0 && nx < W && d[ny][nx] == -1)
            {
                d[ny][nx] = d[y][x] + 1;
                ans = max(ans, d[ny][nx]);
                q.push({ny, nx});
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13456
import re

while True:
    d = input()
    if d == 'END OF INPUT':
        break
    lst = re.split('[ ]',d)
    p = []
    for i in range(len(lst)):
        p.append(len(lst[i]))
    
    for i in range(len(lst)):
        if lst[i] == ' ':
            p[i] = 0
    P = [str(j) for j in p]
    P = ''.join(P)
    print(P)


Measured memory_bytes: 6484
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)

int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    string S;
    cin >> S;
    S[K-1] += 32;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  int N,K;
  cin >> N >> K;
  vector<int>L(N);
  for(int i=0; i < N; i++)
    cin >> L[i];
  sort(L.begin(),L.end());
  int ans=0;
  for(int i=0; i < K; i++)
    ans += L[N-1-i];
  cout << ans << endl;

  return 0;
}


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

int main() {
    ll N;
    cin>>N;
    int pmax=(int)ceil(sqrt(N));
    int ans=0;
    for(int p=2; p<=pmax; p++){
        int count=0;
        while (N%p==0)
        {
            N/=p;
            count++;
        }
        int m=0;
        while((m+1)*(m+2)<=2*count){
            m++;
        }
        ans+=m;

    }
    if(N>1)ans+=1;
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    if ((b - a) / 2 < k)
        rep2(i, a, b + 1) cout << i << '\n';
    else
    {
        rep2(i, a, a + k) cout << i << '\n';
        rep2(i, b + 1 - k, b + 1) cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 3584
from math import ceil
n, h = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
b.sort()
b.reverse()
cnt = 0
ma = max(a)
for i in range(n):
    if b[i] > ma:
        h -= b[i]
        cnt += 1
    if h <= 0:
        print(cnt)
        exit()
cnt += ceil(h / ma)
print(cnt)

Measured memory_bytes: 46780
n=int(input())
a,b,c,d=0,0,0,0
l=[input() for _ in range(n)]
for i in range(n):
    if l[i]=='AC':a+=1
    elif l[i]=='WA':b+=1
    elif l[i]=='TLE':c+=1
    else:d+=1
print('AC','x',a)
print('WA','x',b)
print('TLE','x',c)
print('RE','x',d)

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

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long ans = 0;
        var inp = new long[n][];
        for (int i = 0; i < n; i++)
            inp[i] = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        inp = inp.Reverse().ToArray();
        for (int i = 0; i < n; i++)
        {
            if ((inp[i][0] + ans) % inp[i][1] == 0) continue;
            ans += inp[i][1] - (inp[i][0] + ans) % inp[i][1];
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 27840
S=input()
h=S.split("L")
h2=S.split("R")
c=0
r=[]
l=[]
for k in range(len(h)):
  if h[k]!="":
    r.append(len(h[k]))
for j in range(len(h2)):
  if h2[j]!="":
    l.append(len(h2[j]))
for i in range(len(l)):
  if r[i]-2>=0:
    for s in range(r[i]-1):
    	print(0,end=" ")
  if r[i]%2==1:
    print(r[i]//2+1+l[i]//2,end=" ")
  else:
      print(r[i]//2+l[i]//2,end=" ")
  if l[i]%2==1:
    print(r[i]//2+l[i]//2+1,end=" ")
  else:
    print(r[i]//2+l[i]//2,end=" ")
  if l[i]-2>=0:
    for t in range(l[i]-1):
      print(0,end=" ")

Measured memory_bytes: 6536
using System;
using System.Collections.Generic;
class Solve{
    public long n;
    public long s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        if(n <= s){
            if(n == s){
                Console.WriteLine(n+1);
            }
            else{
                Console.WriteLine(-1);
            }
        }
        else{
            long i;
            for(i=2;i*i<=n;i++){
                long sum = 0;
                long a = n;
                while(a > 0){
                    sum += a%i;
                    a /= i;
                }
                if(sum == s){
                    Console.WriteLine(i);
                    return;
                }
            }
            if(i > s)
                i = s;
            for(;i>=1;i--){
                if((n-s+i)%i == 0 && (n-s+i)/i > i && s-i < (n-s+i)/i){
                    Console.WriteLine((n-s+i)/i);
                    return;
                }
            }
            Console.WriteLine(-1);
        }
    }
    void getinput(){
        n = Int64.Parse(Console.ReadLine());
        s = Int64.Parse(Console.ReadLine());
    }    
}

Measured memory_bytes: 2648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    // dp1[i][j]は左からi個までで和をjに出来るかどうかを表す。
    boolean[][] dp1 = new boolean[N + 1][K + 1];
    dp1[0][0] = true;
    for(int i = 1; i < N + 1; i++) {
      for(int j = 0; j < K + 1; j++) {
        if(a[i - 1] <= j) {
          dp1[i][j] = dp1[i - 1][j] || dp1[i - 1][j - a[i - 1]];
        } else {
          dp1[i][j] = dp1[i - 1][j];
        }
      }
    }
    // dp2[i][j]は右からi個までで和を0～jの内何個作れるかを表す。
    int[][] dp2 = new int[N + 1][K + 1];
    for(int j = 0; j < K + 1; j++) {
      dp2[0][j] = 1;
    }
    for(int i = 1; i < N + 1; i++) {
      dp2[i][0] = 1;
      for(int j = 1; j < K + 1; j++) {
        int count = 0;
        if(a[N - i] <= j) {
          if(a[N - i] == j) {
            count++;
          } else {
            if(dp2[i - 1][j] > dp2[i - 1][j - 1] || dp2[i - 1][j - a[N - i]] > dp2[i - 1][j - a[N - i] - 1]) count++;
          }
        } else {
          if(dp2[i - 1][j] > dp2[i - 1][j - 1]) count++;
        }
        dp2[i][j] = dp2[i][j - 1] + count;
      }
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
      int count = 0;
      for(int j = 0; j < K; j++) {
        if(K - a[i] - j - 1 >= 0) {
          if(dp1[i][j] && (dp2[N - 1 - i][K - j - 1] > dp2[N - 1 - i][K - a[i] - j - 1])) {
            count++;
            break;
          }
        } else {
          if(dp1[i][j] && (dp2[N - 1 - i][K - j - 1] > 0)) {
            count++;
            break;
          }
        }
      }
      if(count > 0) ans++;
    }
    System.out.println(N - ans);
  }
}


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

int main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int>x(N);
  vector<int>y(M);
  for(int i=0; i<N; i++){
   cin>>x[i];
   if(X<x[i]){
     X=x[i];}}
  
  for(int i=0; i<M; i++){
   cin>>y[i];
   if(y[i]<Y){
     Y=y[i];}}
  
  if(X<Y){cout<<"No War"<<endl;}
  else{cout<<"War"<<endl;}
  
}

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

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

	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a.at(i);

	sort(a.rbegin(), a.rend());

	int Alice = 0;
	int Bob = 0;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)Alice += a.at(i);
		else Bob += a.at(i);
	}

	cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
N, W = [int(_) for _ in input().split()]
INF = 1e12
dp = [[INF] * (((10 ** 3) * N) + 10) for _ in range(N + 1)]

dp[0][0] = 0
sum_v = 0
for i in range(1, N + 1):
    w, v = [int(_) for _ in input().split()]
    sum_v += v

    for j in range(len(dp[i])):
        if j > sum_v: break
        # if dp[i-1][j] ==INF:continue
        if j < v:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)

    # print(dp[i][:20])
ans = 0
for i, v in enumerate(dp[N]):
    if v <= W:
        ans = i
print(ans)


Measured memory_bytes: 301256
#include<cstdio>
using namespace std;
int main(){
    int n,k,b;
    double ans=0.0,a;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        a=1.0;
        b=i;
        while(b<k){
            b*=2;
            a/=2.0;
        }
        ans+=a;
    }
    printf("%.11f\n",ans/(double)n);
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

// const int MAX = 510000;
const int MAX = 2000010;

ll fac[MAX], finv[MAX], inv[MAX];

void init_ncr() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll ncr(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll npr(ll val1, ll val2) {
  ll c = ncr(val1, val2);
  return c * fac[val2] % MOD;
}

int main() {
  init_ncr();

  ll X, Y;
  scanf("%lld %lld", &X, &Y);

  ll h = -1;
  ll v = -1;

  for (ll c1 = 0; c1 <= X; c1++) {
    ll c2 = (X - c1) / 2;
    if ((X - c1) % 2 == 1) {
      continue;
    }

    if (Y == c1 * 2 + c2) {
      h = c1;
      v = c2;
      break;
    }
  }

  if (h == -1) {
    cout << (0) << endl;
    return 0;
  }

  cout << (ncr(h + v, v)) << endl;
}


Measured memory_bytes: 50652
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

void Rect(int h, int w){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int k = i+j;
			
			if(k%2==0) cout << '#';
			else cout << '.';
			
			if (j==w-1) cout << endl;
		}
	}
}

int main(){
	int H,W;
	
	while(true){
		
		cin >> H >> W;
		if(H==0&&W==0) break;
		Rect(H,W);
		cout << endl;
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
#define rep(i,n) for (ll i = 0; i < (n); i++)
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){ p("YES"); }else{ p("NO"); }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll mygcd(ll a, ll b){
    if(b > a)swap(a, b);
    if(a == b || b == 0)return a;
    return mygcd(b, a % b);
}
/*

ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

// auto res = NTT::conv(mod, 3ll, atable, btable);

bool multicase = false;

ll n,m,num,a,b,c,d,e,q, w, ans ;
ll x[500005], y[500005];
ll r, k;
string s;

ll sum(ll num){
    ll res = 0;
    while(true){
        if(num == 0)return res;
        res += num % 10;
        num /= 10;
    }
    return -INF;
}

void solve(){
    cin >> n;
    ans = INF;
    for(ll i=1;i<n;i++){
        ll a = i, b = n - i;
        ll res = sum(a) + sum(b);
        ans = min(ans, res);
    }
    p(ans);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        double B = sc.nextDouble();
        int b = (int)Math.floor(B*100+0.5);
        System.out.println(A*(b/100)+(A*(b%100))/100);
    }
}

Measured memory_bytes: 36840
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int l;
  scanf("%d", &l);
  int r;
  scanf("%d", &r);
  int d;
  scanf("%d", &d);

  int num = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0) ++num;
  }

  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 3720
def comp(a,b):
    s = 0
    for i,j in zip(a,b):
        if not i == j:
            s += 1
    return s

s = input()
t = input()
ans = len(t)

for i in range(len(s) - len(t) + 1):
    score = comp(s[i:i+len(t)],t)
    if score == 0:
        ans = score
        break
    if ans > score:
        ans = score

print(ans)


Measured memory_bytes: 9124
# AGC002B - Box and Ball
import sys
input = sys.stdin.readline

def main():
    N, M = tuple(map(int, input().split()))
    X = tuple(tuple(map(int, input().split())) for _ in range(M))
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in X:
        if R[x]:
            R[y] = 1
        C[x] -= 1
        C[y] += 1
        if C[x] == 0:
            R[x] = 0
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18856
#include <iostream>
#include <deque>
#include <utility>
int main() {
    std::string s;
    std::getline(std::cin, s);
    std::deque<std::pair<int, int>> a;
    std::deque<int> b;
    for (size_t i = 0; i < s.size(); ++i) {
        if (s[i] == '\\') {
            b.push_back(i);
        } else if (s[i] == '/' && !b.empty()) {
            int c = b.back();
            b.pop_back();
            int d = i - c;
            while (!a.empty() && c <= a.back().first) {
                d += a.back().second;
                a.pop_back();
            }
            a.emplace_back(c, d);
        }
    }
    int x = 0;
    for (auto&& e: a) {
        x += e.second;
    }
    std::cout << x << std::endl << a.size();
    for (auto&& e: a) {
        std::cout << ' ' << e.second;
    }
    std::cout << std::endl;
}



Measured memory_bytes: 3320
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int k, x;
    cin >> k >> x;
    for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) {
        cout << i << ' ';
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
d = {}
l = []
for i in range(n):
  w = str(input())
  if w in d.keys():
    d[w]+=1
  else:
    d[w] = 1
m = max(d.values())
for k, v in sorted(d.items(), key=lambda x: -x[1]):
  if m == v:
    l.append(k)
  else:
    break
for j in sorted(l):
  print(j)

Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll K;
    cin >> K;
    vector<ll> A(50);
    for (int i = 0; i < 50; i++) {
        A[i] = 49 + K/50;
    }

    K = K % 50;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < 50; j++) {
            if(j == i){
                A[j] += 50;
            }
            else{
                A[j] -= 1;
            }
        }
    }

    printf("50\n");
    for (int i = 0; i < 50; i++) {
        printf("%lld ", A[i]);
    }
    printf("\n");
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int x,y;
    Scd2(x,y);
    if( x%y == 0 ) x = -1;
    printf("%d\n", x);

    return 0;
}



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

int main()
{
	int h, w, n;

	cin >> h;
	cin >> w;
	cin >> n;

	int a;
	if (w > h)
	{
		a = n / w;
		if (n % w != 0) a++;
	}
	else
	{
		a = n / h;
		if (n % h != 0) a++;
	}
	cout << a << endl;
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

ll conv3(ll x){
  return x * (x-1) * (x-2) / (6);
}

ll conv2(ll x){
  return x * (x-1) / (2);
}

int main() {

  string s ;
  int N ;
  ll m=0 ,a=0 ,r=0 ,c=0 , h=0 ;
  ll D[5];
  int P[10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
  int Q[10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
  int R[10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};

  cin >> N;
  for ( int i =0; i < N ; i ++){
    cin >> s ;
    if ( s[0]== 'M') m++;
    if ( s[0]== 'A') a++;
    if ( s[0]== 'R') r++;
    if ( s[0]== 'C') c++;
    if ( s[0]== 'H') h++;
  }
  D[0]= m , D[1]= a , D[2]= r , D[3]= c , D[4]= h ;
  ll res =0;
  for ( int d =0; d <10; d ++)
  res += D [P[ d ]]* D[Q[ d ]]* D[R[ d ]];
  cout << res << endl;

  



 
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a>b*2) {
    cout << a-b*2 << endl;
  }else {
    cout << 0 << endl;
  }
  return 0;
}

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

int main()
{
	int n;
	cin>>n;
	long double A[n];
	for(int i=0;i<n;i++)
	cin>>A[i];
	vector<vector<long double> > v(2, vector<long double> (n+1,0));
	v[0][0]=A[0];
	v[0][1]=1-A[0];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			v[1][j]+=v[0][j]*A[i];
			v[1][j+1]+=v[0][j]*(1-A[i]);
		}
		v[0]=v[1];
		for(int o=0;o<=n;o++)
		v[1][o]=0;
	}
	long double ans=0;
	for(int i=0;i<(n+1)/2;i++)
	ans+=v[0][i];
	cout<<setprecision(9)<<ans;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}


int info[100000];
int to[100000] , done[100000] , re[100000];
int n,m;
int dfs(int x){
	if(~to[x]) return to[x];
	if(done[x]) return -2;
	else done[x] = true;
	return to[x] = info[x] == 0 ? x : dfs(x+info[x]);
}

int main(){
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++) info[i] = in();
		
		queue<int> Q;
		memset(re,-1,sizeof(re));
		memset(to,-1,sizeof(to));
		Q.push(0);
		re[0] = 0;
		while(Q.size()){
			int q = Q.front(); Q.pop();
			if(q == n-1){
				cout << re[q] << endl;
				break;
			}else{
				for(int i = 1 ; i <= 6 ; i++){	
					int next = dfs(min(q+i,n-1));
					if(next == -2) continue;
					if(re[next] == -1) Q.push(next),re[next] = re[q]+1;
				}
			}
		}
	}
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL i,j,x,y,n;
    cin >> n;
    for(i=-150;i<151;i++)
    {
        x=pow(i,5);
        for(j=-150;j<151;j++)
        {
            y=pow(j,5);
            if(x-y == n)
            {
                cout << i << ' ' << j;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4076
N=int(input())
L=list(map(int,input().split()))
c=0
s=0
mi=10**10
for i in range(N):
    if(L[i]<0):
        c+=1
    s+=abs(L[i])
    if(abs(L[i])<mi):
        mi=abs(L[i])
if(c%2==0):
    print(s)
    exit()
print(s-(2*mi))

Measured memory_bytes: 64752
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();

		long sum = 0;
		for( int i=1 ; i<= n ; i++ )
			for( int j=1 ; j<= n ; j++ )
				for( int k=1 ; k<= n ; k++ ) 
					sum+=gcd(i,j,k);
		
		System.out.println(sum);
		
	}
		
	static int gcd(int... array) {
		int gcd = 0;
		for(int i = 0; i < array.length; i ++) { gcd = gcd(gcd, array[i]); }
		return gcd;
	}
	
	static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

}

Measured memory_bytes: 43368
#include<iostream>
#include<algorithm>
using namespace std;
int a[5],b[100000];
int main(){
  cin>>a[1]>>a[2]>>a[3];
  sort(a+1,a+1+3);
  if(a[1]==a[2])  cout<<a[3]<<endl;
  else  cout<<a[1]<<endl;
  return 0;
}

Measured memory_bytes: 256