akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from itertools import combinations


def gen_step(s, n):
    # 和がsとなるn個の非負整数列
    # a1 + a2 + ... + an = s
    if n == 0:
        yield []
        return
    if n == 1:
        yield [s]
        return
    for i in range(s + 1):
        for step in gen_step(s - i, n - 1):
            yield [i] + step


def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    ans = 0
    for s in range(M):
        for steps in gen_step(s, N - 1):
            ret = 0
            A = [1] * N
            for i, step in enumerate(steps):
                A[i + 1] = A[i] + step
            for q in range(Q):
                if A[b[q] - 1] - A[a[q] - 1] == c[q]:
                    ret += d[q]
            ans = max(ans, ret)
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<int, int>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;

struct edge {
    int to;
    int cost;
};

const int MAX_V = 40005;
vector<edge> G[MAX_V];
int d[8][MAX_V];
int n;

map<int, int> invR;

void dijkstra(int s) {
    int idx = invR[s];

    priority_queue<P, vector<P>, greater<P> > que;
    fill(d[idx], d[idx]+n+1, INF);
    d[idx][s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[idx][v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[idx][e.to] > d[idx][v] + e.cost) {
                d[idx][e.to] = d[idx][v] + e.cost;
                que.push(P(d[idx][e.to], e.to));
            }
        }
    }
}

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

  int m, r;
  cin >> n >> m >> r;

  vector<int> R(r);
  fillInt(R, r);
  sortv(R);

  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }

  rep(i, r) {
    invR.insert({R[i], i});
    dijkstra(R[i]);
  }

  int res = INF;

  do {
    int tmp = 0;
    rep(i, r-1) {
      tmp += d[invR[R[i]]][R[i+1]];
    }
    res = min(tmp, res);
  } while (next_permutation(R.begin(), R.end()));
 
  cout << res << endl;
}


Measured memory_bytes: 1664
h, w = gets.chomp.split.map(&:to_i)
arr = []
h.times{
    line = gets.chomp
    arr << line if line.count("#") != 0
}
(w-1).downto(0){|x|
    if arr.all?{|line| line[x] == "."}
        arr.each{|line| line[x, 1] = ""}
    end
}
arr.each{|line| puts line}

Measured memory_bytes: 1788
a=int(input())
c=0
z=[]
y=[]
b=[]
for i in range(a):
    x=str(input())
    z.append(x[0])
    y.append(x[-1])
    if i==0:
        b.append(x)
    if x not in b and z[i]==y[i-1]:
        b.append(x)
        c+=1
if c==a-1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
const bool unsyncedio=std::ios::sync_with_stdio(false);
using namespace std;
typedef unsigned int uint;
typedef long long ll;

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

int main() {
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    int c=s[k-1]-'A';
    s[k-1]='a'+c;
    cout<<s<<endl;

}



Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
R = [[] for i in range(N + 1)]
for i in range(M):
    A, B = map(int, input().split())
    R[A].append(B)
    R[B].append(A)
P = [-1] * (N + 1)
P[1] = 0
Q = deque()
Q.append(1)

while Q:
    v = Q.popleft()
    for r in R[v]:
        if P[r] == -1:
            P[r] = v
            Q.append(r)
print('Yes')
for p in P[2:]:
    print(p)

Measured memory_bytes: 34940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int N = (1 << n);
  vector<int> a(N), ret(N);
  vector<pair<int, int>> M(N), m(N);
  for (int bs = 0; bs < N; bs++) cin >> a[bs];
  M[0] = make_pair(a[0], 0);
  m[0] = make_pair(0, 0);
  for (int bs = 1; bs < N; bs++) {
    set<pair<int, int>> rpr;
    for (int i = 0; i < n; i++) if ((bs >> i) & 1) {
      int cs = bs - (1 << i);
      rpr.emplace(M[cs]);
      rpr.emplace(m[cs]);
    }
    rpr.emplace(make_pair(a[bs], bs));
    auto it = rpr.end();
    M[bs] = *(--it);
    m[bs] = *(--it);
    ret[bs] = M[bs].first + m[bs].first;
  }
  for (int bs = 2; bs < N; bs++) {
    ret[bs] = max(ret[bs], ret[bs - 1]);
  }
  for (int bs = 1; bs < N; bs++) {
    cout << ret[bs] << endl;
  }
  return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    int ans = 0;
    for(int i = 0 ; i <= n ; i++){
      if(i*i > n) break;
      for(int j = i ; j <= n ; j++){
	if(i*i+j*j > n) break;
	for(int k = j ; k <= n ; k++){
	  if(i*i+j*j+k*k > n) break;
	  for(int l = k ; l <= n ; l++){
	    if(i*i+j*j+k*k+l*l > n) break;
	    if(i*i+j*j+k*k+l*l == n) ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
	int N, M, ans = 0;
	cin >> N >> M;
	int H[N], Z[N], A[M], B[M];
	for(int k = 0; k < N; k++){
		cin >> H[k];
		Z[k] = 0;
	}
	for(int k = 0; k < M; k++){
		cin >> A[k] >> B[k];
		if(H[A[k]-1] > H[B[k]-1]){
			Z[B[k]-1]++;
		}else if(H[A[k]-1] < H[B[k]-1]){
			Z[A[k]-1]++;
		}else{
			Z[A[k]-1]++;
			Z[B[k]-1]++;
		}
	}

	for(int k = 0; k < N; k++){
		if(Z[k] == 0){
			ans++;
		}
	}

	cout << ans;


	return 0;
}

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

#define print(n) cout  << n << "\n"

int main() {
	int input;
	int max, min;
	cin >> input;
	int roop = 0;
	while (roop < input){
		int nb;
		cin >> nb;
		if (roop == 0) {
			min = nb;
			max = nb;
		}
		if (nb < min) {
			min = nb;
		}
		if (max < nb) {
			max = nb;
		}
		roop++;
	}
	print(max - min);

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <list>
using namespace std;

// ?°´?????????????????±???????´????????§???????
struct PUDDLE{
    int begin; // ????§???????
    int area; // ??¢???
};

int main(int argc, char const *argv[]) {
    int totalArea = 0; // ?°´?????????????????¢???
    char crossSection[20001]; // ?????¢???
    stack<int> downhill; // ?????????????§???????
    list<PUDDLE> puddleList; // ?°´????????????????????¨??¢???

    scanf("%s", crossSection);
    for(int current=0 ; crossSection[current]!='\0' ; current++){
        switch (crossSection[current]) {
            case '\\':
                downhill.push(current);
                break;
            case '/' :
                if(downhill.empty()) break;
                // ?????¨????°´??????????????¢???????±???????
                PUDDLE currentPuddle;
                currentPuddle.begin = downhill.top();
                downhill.pop();
                currentPuddle.area = current - currentPuddle.begin;
                totalArea += currentPuddle.area; // ?????¢????????´??°
                // ???????°´????????????????????°????????????
                while(!puddleList.empty() && currentPuddle.begin<puddleList.back().begin){
                    currentPuddle.area += puddleList.back().area;
                    puddleList.pop_back();
                }
                puddleList.push_back(currentPuddle);
                break;
            case '_' : break; // ???????????????
        }
    }

    printf("%d\n", totalArea);
    printf("%zu", puddleList.size());
    list<PUDDLE>::iterator itr = puddleList.begin();
    for( ; itr!=puddleList.end() ; itr++){
        printf(" %d", itr->area);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 2872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define rep2(i, a, b) for(int i=a; i<=(int)(b); ++i)
#define all(v) v.begin(),v.end()
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  unordered_set<string> us;
  string s;
  rep(i, n) {
    cin >> s;
    us.insert(s);
  }
  cout << us.size() << endl;
}

Measured memory_bytes: 17724
#include <bits/stdc++.h>
#define ll long long
#define WEIGHTSUM weight + i
#define VALUESUM maxValue[i] + value
using namespace std;
ll maxValue[100005];

int main() {
    ll n, w, weight, value;

    cin >> n >> w;
    for (int i = 1; i <= n; i++) {
        cin >> weight >> value;

        for (int i = w; i >= 0; i--)
            if (WEIGHTSUM <= w)
                maxValue[WEIGHTSUM] = max(maxValue[WEIGHTSUM], VALUESUM);
    }

    cout << maxValue[w];

    return 0;
}


Measured memory_bytes: 4348
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	solve_c()
}

func solve_c() {
	s := read_line()
	var sum = 0
	var seps = make([]int, 0, 10)
	dfs(s, 0, &sum, seps...)
	fmt.Println(sum)
}

func dfs(s string, i int, sum *int, seps ...int) {
	if i > len(s)-2 {
		splitToNums(s, seps, sum)
	} else {
		dfs(s, i+1, sum, seps...)
		seps = append(seps, i)
		dfs(s, i+1, sum, seps...)
	}
}

func splitToNums(s string, seps []int, sum *int) {
	if len(seps) == 0 {
		num, _ := strconv.Atoi(s)
		*sum += num
	} else {
		preindex := 0
		for _, index := range seps {
			newS := s[preindex : index+1]
			num, _ := strconv.Atoi(newS)
			*sum += num
			preindex = index + 1
		}
		newS := s[preindex:]
		num, _ := strconv.Atoi(newS)
		*sum += num
	}
}

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


Measured memory_bytes: 640
#include <cstdio>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int n = 3;
    if(a == b){
        n--;
    }
    if(b == c){
        n--;
    }
    if(c == a){
        n--;
    }
    if(n == 0){
        n = 1;
    }
    printf("%d\n",n);

    return 0;
}

Measured memory_bytes: 128
class Dice(object):
    def __init__(self, faces):
        self.top = faces[0]
        self.front = faces[1]
        self.right = faces[2]
        self.left = faces[3]
        self.back = faces[4]
        self.bottom = faces[5]

    def rotate(self, command):
        pre_top = self.top
        if command == "N":
            self.top = self.front
            self.front = self.bottom
            self.bottom = self.back
            self.back = pre_top
        elif command == "E":
            self.top = self.left
            self.left = self.bottom
            self.bottom = self.right
            self.right = pre_top
        elif command == "W":
            self.top = self.right
            self.right = self.bottom
            self.bottom = self.left
            self.left = pre_top
        elif command == "S":
            self.top = self.back
            self.back = self.bottom
            self.bottom = self.front
            self.front = pre_top
        elif command == "R":
            pre_front = self.front
            self.front = self.left
            self.left = self.back
            self.back = self.right
            self.right = pre_front


def main() -> None:
    dice_x = Dice(list(map(int, input().split())))
    dice_y = Dice(list(map(int, input().split())))

    for i in range(4):
        dice_x.rotate("N")
        for j in range(4):
            dice_x.rotate("E")
            for k in range(4):
                dice_x.rotate("R")

                if dice_x.top != dice_y.top:
                    pass
                elif dice_x.bottom != dice_y.bottom:
                    pass
                elif dice_x.left != dice_y.left:
                    pass
                elif dice_x.right != dice_y.right:
                    pass
                elif dice_x.front != dice_y.front:
                    pass
                elif dice_x.back != dice_y.back:
                    pass
                else:
                    print("Yes")
                    return

    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 5608
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: u64 = input();
    let a_vec = input_vec();
    let mut target = 1;
    for a in a_vec {
        if a == target {
            target += 1;
        }
    }
    if target == 1 {
        println!("-1");
    } else {
        println!("{}", n + 1 - target);
    }
}


Measured memory_bytes: 10492
x1,y1,x2,y2 = gets.strip.split.map(&:to_i)

difx=x1-x2
dify=y1-y2

x3=x2+dify
y3=y2-difx
x4=x1+dify
y4=y1-difx

print x3
print ' '
print y3
print ' '
print x4
print ' '
print y4



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

using namespace std;

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

  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if (u == s)
    a--;
  else
    b--;
  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		Comparator<int[]> comparator_0 = new Comparator<int[]>() {
		    @Override
		    public int compare(int[] o1, int[] o2) {
		        return Integer.compare(o1[0], o2[0]);
		    }
		};
		Comparator<int[]> comparator_1 = new Comparator<int[]>() {
		    @Override
		    public int compare(int[] o1, int[] o2) {
		        return Integer.compare(o1[1], o2[1]);
		    }
		};
		Comparator<int[]> comparator_2 = new Comparator<int[]>() {
		    @Override
		    public int compare(int[] o1, int[] o2) {
		        return Integer.compare(o1[2], o2[2]);
		    }
		};
		ArrayList<int[]> list = new ArrayList<int[]>();
		for (int i=0;i<M;i++) {
			int P = Integer.parseInt(sc.next());
			int Y = Integer.parseInt(sc.next());
			int[] tmp = {i, P, Y , 0};
			list.add(tmp);
		}
		Collections.sort(list, comparator_2);
		Collections.sort(list, comparator_1);
		int index=1;
		int former=0;
		for (int i=0;i<M;i++) {
			if (former==list.get(i)[1]) {
				index++;
				list.get(i)[3]=index;
				former=list.get(i)[1];
			} else {
				index=1;
				list.get(i)[3]=index;
				former=list.get(i)[1];
			}
		}

		Collections.sort(list, comparator_0);
		for (int i=0;i<M;i++) {
			String ans = String.format("%06d%06d",list.get(i)[1],list.get(i)[3]);
//			System.out.printf("%06d%06d",list.get(i)[1],list.get(i)[3]);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 111548
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

class Point{
private:
    double x_;
    double y_;
public:
    Point();
	Point(double x, double y);
	Point(const Point& P);

    ~Point();
    Point& operator=(const Point &P);
	Point& operator+(const Point &P);
    Point& operator+(double k);
	Point& operator-(const Point &P);
    Point& operator-(double k);

	//?????????
	Point& operator*(double k);

    void disp(){
        //printf("%3f %3f\n", x_, y_);
        cout << x_ << " " << y_ << endl;}
    double length(){return x_*x_ + y_*y_;};
    double cross(Point Q){return x_*Q.y() - Q.x()*y_;};
    double dot(Point Q){return x_*Q.x() + y_*Q.y();};

    inline double x() const {return x_;}
    inline double y() const {return y_;}
};


Point::Point():
	x_(0.0),
	y_(0.0)
{

}

Point::Point(double x, double y):
	x_(x),
	y_(y)
{

}

Point::Point(const Point& P):
    x_(0.0),
    y_(0.0)
{
	this->operator=(P);
}

Point::~Point(){

}

Point& Point::operator=(const Point &P){
	this->x_ = P.x_;
	this->y_ = P.y_;
	return *this;
}

Point& Point::operator+(const Point &P){
	x_ += P.x_;
	y_ += P.y_;
	return *this;
}

Point& Point::operator+(double k){
	x_ += k;
	y_ += k;
	return *this;
}

Point& Point::operator-(const Point &P){
	x_ -= P.x_;
	y_ -= P.y_;
	return *this;
}

Point& Point::operator-(double k){
	x_ -= k;
	y_ -= k;
	return *this;
}


Point& Point::operator*(double k){
	x_ *= k;
	y_ *= k;
	return *this;
}





int main(){
    int n;
    double a,b,c,d,e,f,g,h;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a >> b >> c >> d >> e >> f >> g >> h;
        Point P(c-a, d-b);
        Point Q(g-e, h-f);
        if(P.cross(Q)==0) cout << 2 << endl;
        else{
            if(P.dot(Q)==0) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(int(input()))

Ap = []
for i in range(N):
    Ap.append(0)

for i in range(Q):
    Ap[A[i]-1] += 1

for i in range(N):
    if K - (Q - Ap[i]) > 0:
        print('Yes')
        #print(K - (Q - Ap[i]))
    else:
        print('No')
        #print(K - (Q - Ap[i]))


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

int main()
{
	int a,b;
	cin >> a >> b;
	if ( a>= 13)
	{
		cout << b << endl;
	}
	else if( a >= 6 && a <= 12)
	{
		cout << b/2 << endl;
	}
	else if(a <= 5)
	{
		cout << "0" << endl;
	}
	
	return 0;
}

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

using namespace std;

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

    set<int> S;
    int cmd, x;
    while (q--)
    {
        cin >> cmd >> x;
        if (cmd == 0)
        {
            S.insert(x);
            cout << S.size() << endl;
        }
        else if (cmd == 1)
        {
            // cout << (S.find(x) != S.end()) << endl;
            cout << S.count(x) << endl;
        }
        else
        {
            S.erase(x);
        }
        
    }
}


Measured memory_bytes: 12468
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <time.h>
#pragma comment (linker, "/STACK:200000000")
#define ll long long
#define mod 1000000007ll
#define maxn 1000000ll
using namespace std;


//fstream cin("input.txt"); ofstream cout("output.txt");
//fstream cin("hobby.in"); ofstream cout("hobby.out");
ll gcd(ll a, ll b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9') cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int h,w,k;
  cin >> h >> w >> k;
  long** map = new long*[100];
  long N = 1000000007;
  long* rest = new long[8];
  rest[0] = 1;
  rest[1] = 2;
  rest[2] = 3;
  rest[3] = 5;
  rest[4] = 8;
  rest[5] = 13;
  rest[6] = 21;
  rest[7] = 34;
  for(int i=0;i<h;i++) {
    map[i] = new long[8];
    for(int j=0;j<w;j++){
      map[i][j] = 0;
    }
  }
  map[0][0] = rest[max(0,w-2)];
  map[0][1] = rest[max(0,w-3)];
  for(int i=1;i<h;i++){
    for(int j=0;j<w;j++){
      long sum = map[i-1][j] * rest[max(0,j-1)] * rest[max(0,w-j-2)] % N;
      if(j!=0) sum += map[i-1][j-1] * rest[max(0,j-2)] * rest[max(0,w-j-2)] % N;
      if(j!=w-1) sum += map[i-1][j+1] * rest[max(0,j-1)] * rest[max(0,w-j-3)] % N;
      map[i][j] = sum%=N;
    }
  }

  cout << map[h-1][k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int A = int.Parse(imp[0]);
            int B = int.Parse(imp[1]);
            int C = int.Parse(imp[2]);
            int count = 0;

            for ( int sc = C; (B-A>=0); --sc)
            {
                B = B - A;
                count += 1;
                //Console.WriteLine(count);
            }

            if(count>C)
            {
                Console.Write(C);
            }
            else
            {
                Console.Write(count);
            }
           

            System.Threading.Thread.Sleep(1000);
        }
    }
}


Measured memory_bytes: 11092
package main

import (
  "fmt"
)

func main() {
  var N int
  fmt.Scan(&N)
  var A int
  s := 0
  cnt := -1
  for i := 0; i < N; i++ {
    fmt.Scan(&A)
    if A > i + 1 {
      cnt = -1
      break
    }
    if i - A < s {
      cnt = -1
      break
    }
    if i - A == s {
      cnt += 1
    } else {
      cnt += A
      s = i - A
    }
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 7552
import java.util.Scanner;

class Main {
    static Scanner sc;

    private static void nextArr(int[] h) {
        for(int i = 0; i < h.length; i++) h[i] = sc.nextInt();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int[][] item = new int[n][2];
        for(int i = 0; i < n; i++) nextArr(item[i]);

        long[][] dp = new long[n][w + 1];
        for(int j = 0; j <= w; j++) dp[0][j] = j >= item[0][0] ? item[0][1] : 0;
        for(int i = 1; i < n; i++) {
            for(int j = 0; j <= w; j++) {
                dp[i][j] = Math.max(dp[i][j], dp[i - 1][j]);
                if (j - item[i][0] >= 0) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - item[i][0]] + item[i][1]);
                }
            }
        }
        print(dp[n - 1][w]);

    }
}


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

int main() {
    int n, d; cin >> n >> d;
    int manege = d * 2 + 1;
    if(n % manege != 0) cout << n / manege + 1 << endl;
    else cout << n / manege << endl;
    return 0;
}


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

int N, ans;

int getNumOfDivisor(int n) {
    int res = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res++;
            if (n/i != i) res++;
        }
    }
    return res;
}

int main() {
    cin >> N;
    int C, P;
    for (C = 1; C < N; C++) {
        P = N - C;
        ans += getNumOfDivisor(P);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {

		Scanner scaner = new Scanner( System.in );

		int x1	= Integer.parseInt( scaner.next());
		int x2	= Integer.parseInt( scaner.next());

		System.out.print( Math.multiplyExact( x1, x2 ) + " " );

		System.out.println( (x1 * 2) + (x2 * 2) );
	}

}

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

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);


int expr(string& s, int& i) {
  int val = term(s, i);
  while(s[i] == '+' || s[i] == '-') {
    char op = s[i];
    i++;
    int val2 = term(s, i);
    if (op == '+') val += val2;
    else val -= val2;
  }
  return val;
}

int term(string& s, int& i) {
  int val = factor(s, i);
  while(s[i] == '*' || s[i] == '/') {
    char op = s[i];
    i++;
    int val2 = factor(s, i);
    if (op == '*') val *= val2;
    else val /= val2;
  }
  return val;
}

int factor(string& s, int& i) {
  if (isdigit(s[i])) return number(s, i);

  // ここで構文が正しければ s[i] == '(' となる
  i++; // '('を読み飛ばす
  int ret = expr(s, i);
  i++; // ')'を読み飛ばす
  return ret;
}

int number(string& s, int& i) {
  int n = s[i++] - '0';
  while(isdigit(s[i])) n = n*10 + s[i++] - '0';
  return n;
}


int main() {
  int n = 0;
  cin >> n;
  string s;
  getline(cin, s);
  for(int i = 0; i < n; i++) {
    getline(cin, s);
    s = s.substr(0, s.size() - 1);
    int i = 0;
    cout << expr(s, i) << endl;
  }
  return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> d(n);
  std::cin >> d;
  std::sort(d.begin(), d.end());

  const auto i = n / 2;
  std::cout << d[i] - d[i - 1] << std::endl;
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int ch(string c){
	for(int i=0;i<c.size();i++) if(c[i]!=c[(int)c.size()-1-i]) return 0;
	return 1;
}
int main(){
	string c;
	cin>>c;
	int n=c.size();
	if(ch(c)&&ch(c.substr(0,(n-1)/2))&&ch(c.substr((n+3)/2-1,n))) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {

  string s;
  cin>>s;

  bool flag[2] = {false, false};
  for(int l=0; l<s.size()-1; l++){
    int st = 1;
    if(s[l] == s[l+1]){
      cout<<l+1<<" "<<l+2<<endl;
      return 0;
    }
    if(l < s.size() - 2 && s[l] == s[l+2]){
      cout<<l+1<<" "<<l+3<<endl;
      return 0;
    }
  }

  cout<<-1<<" "<<-1<<endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>

#define MAX 104

using namespace std;

class CNum{
public:
	CNum():num(0),cost(0){}
	int num;
	int cost;
};

int main(void){
	int l = 0;
	int num = 0;
	CNum M[MAX][MAX];

	cin >> M[l++][num].num;
	M[0][0].cost = M[0][0].num;
	cin.ignore(MAX,'\n');
	while( true ){
		num = 0;
		while( true ){
			char c;
			cin >> M[l][num++].num;
			c = cin.get();
			if( c != ',' ) break;
		}
		if(cin.eof())break;
		l++;
	}

	for(int i = 1; i < l; i++){
		for(int j = 0; j < (i > l/2 ? l-i: i+1); j++){
			int d = M[i][j].num;
			
			if( i <= l / 2 ){
				if( j == 0 ) M[i][j].cost = M[i - 1][j].cost + d;
				else M[i][j].cost = max(M[i-1][j-1].cost + d, M[i-1][j].cost + d);
			}else M[i][j].cost = max(M[i-1][j].cost + d, M[i-1][j+1].cost + d);
		}
	}
	cout << M[l-1][0].cost << endl;
	return 0;
}

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

int a[100000];

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	
	int flg = 1;

	for (int i = 0;i < n / 2;i++) {
		if((a[i * 2] != a[i * 2 + 1]||a[i*2+1] != n - (i * 2) - 1||a[i*2]!=n-(i*2)-1)) {
			flg = 0;
			break;
		}
	}

	if (n % 2 == 1) {
		if (a[n - 1] != 0) { flg = 0; }
	}
	long long ans=1;

	if (flg == 0) { ans = 0; }
	if(flg==1) {
		for (int i = 0;i < n / 2;i++) {
			ans *= 2;
			if (ans >= 1000000007) { ans %= 1000000007; }
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
n = int( input() )
s = list( input() )
r = []
g = []
b = []

for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
    elif s[i] == "B":
        b.append(i) 

cnt = 0
for i in range(n - 2):
    for k in range(i + 2, n):
        if ( i + k ) % 2 != 0:
            continue
        j = ( i + k ) // 2
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            cnt += 1

print( len(r) * len(g) * len(b) - cnt )

Measured memory_bytes: 9192
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;


int main()
{
	ll a, b, x;
	cin >> a >> b >> x;

	x = min(b-1, x);

	ll ans = ((a * x) / b);

	lprin(ans);
	
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    s.at(k-1) += 32;
    cout << s << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int sum = a*100 + b*10 + c;
	if(sum % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

string str;

int calc(int idx){
    if(str[idx]=='('){
        int depth=1;
        int idx2=idx+1;
        while(depth>0){
            if(str[idx2]=='(') depth++;
            if(str[idx2]==')') depth--;
            if(str[idx2]=='*' && depth==1){
                return min(calc(idx+1),calc(idx2+1));
            }
            if(str[idx2]=='+' && depth==1){
                return max(calc(idx+1),calc(idx2+1));
            }
            idx2++;
        }
    }else{
        if(str[idx]=='-'){
            return 2-calc(idx+1);
        }else{
            return str[idx]-'0';
        }
    }
    return 0;
}

int main(){
    while(1){
        string tmp;
        cin >> tmp;
        if(tmp[0] == '.') break;
        
        str=tmp;
        int count=0;
        for(int i=0; i<=2; i++){
            for(int j=0; j<=2; j++){
                for(int k=0; k<=2; k++){
                    for(int idx=0; idx<(int)tmp.length(); idx++){
                        str[idx] = tmp[idx];
                        if(tmp[idx]=='P') str[idx] ='0'+i;
                        if(tmp[idx]=='Q') str[idx] ='0'+j;
                        if(tmp[idx]=='R') str[idx] ='0'+k;
                    }
                    if(calc(0)==2) count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

vector<bool> prime(100000,true);

const ll mod = 1e9+7;

ll modpow(ll b, ll e, ll p) {
  if(e==0) return 1;
  if(e%2==0) {
    ll t = modpow(b,e/2,p);
    return (t*t)%p;
  }
  return (b*modpow(b,e-1,p))%p;
}

ll modinv(ll n, ll p) {
  return modpow(n,p-2,p);
}

ll modcomb(ll n, ll k, ll p) {
  ll ans=1;
  for(ll i=n; i>=n-k+1; i--) {
    ans*=i;
    ans%=p;
  }
  for(ll i=1; i<=k; i++) {
    ans*=modinv(i,p);
    ans%=p;
  }
  return ans;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n,m;
  cin>>n>>m;
  prime[0]=false;
  prime[1]=false;
  for(ll i=2; i<100000; i++) {
    if(prime[i]) {
      for(ll k = 2; k*i<100000; k++) {
        prime[k*i]=false;
      }
    }
  }
  vector<pair<ll,ll>> ps;
  ll t = m;
  repeat(i,2,100000) {
    if(prime[i]&&t%i==0) {
      ll c=0;
      while(t%i==0) {
        t/=i;
        c++;
      }
      ps.push_back(make_pair(i,c));
    }
  }
  if(t!=1) ps.push_back(make_pair(t,1));
  ll ans=1;
  for(auto& p : ps) {
    ll x,c;
    tie(x,c)=p;
    ans*=modcomb(c+n-1,c,mod);
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, tar = gets.chomp.split.map(&:to_i)

n_10sen = -1
n_5sen = -1
n_1sen = -1

(0..n).each do |a|
  (0..n-a).each do |b|
    c = n - a - b
    result = 10_000 * a + 5000 * b + 1000 * c
    if result == tar
        n_10sen = a
        n_5sen = b
        n_1sen = c
    end
  end
end

puts("#{n_10sen} #{n_5sen} #{n_1sen}")

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int> P;
typedef pair<double,double> P_f;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define bitrep(bit,n) for(int bit=0; bit<=(1<<n);bit++)
#define MAX 100100
#define MAX_N 200100
#define MAX_T 2001001
#define SENTINEL 20010010010
#define NIL -1
static const int INF = 1 << 29;
const ll INFTY = 1LL<<50;
const int MOD=1e9+7;
int main(){
    string S;
    cin>>S;
    int count=0;
    rep(i,S.length()-1){
        if(S[i]!=S[i+1])count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(n);
    rep(i,n) cnt[a[i]]++;
    if(n % 2 == 0){
        for(int i = 1; i < n; i+=2){
            if(cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    else{
        if(cnt[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 2; i < n; i+=2){
            if(cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << modpow(2,n/2,MOD) << endl;
}

Measured memory_bytes: 1024
#include <cmath>
#include <stdio.h>

const double PI = 3.141592653589;

int main()
{
	int len,deg;
	double x,y,deg_sum;
	x = 0;
	y = 0;
	deg_sum = 0;
	scanf("%d,%d",&len, &deg);
	while(len != 0 || deg != 0){
		x += sin(deg_sum * PI / 180) * (double)len;
		y += cos(deg_sum * PI / 180) * (double)len;
		deg_sum += (double)deg;
		scanf("%d,%d",&len, &deg);
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

int n; cin>>n; string s;
map<string,int> map;
std::vector<string> v;
for (int i = 0; i < n; ++i)
{
	cin>>s;
	map[s]+=1;
}

for(auto i:map)
	  cerr<<i.first<<"  "<<i.second<<endl;

int freq=0;
  
  for (auto i: map)
   {
   	     freq=max(i.second,freq);    
   } 
 // cerr<<"freq= "<<freq<<endl;

  for(auto i:map)
  {
  	if(i.second==freq)
  		v.push_back(i.first);
  }
  for(auto i:v)
  	  cout<<i<<" "<<endl;
	
	return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

const string V = "keyence";

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

  string T;
  for(int i = 0; i < S.size(); i++) {
    T += S[i];
    for(int j = i + 1; j < S.size(); j++) {
      string q;
      for(int k = S.size() - 1; k >= j; k--) {
        q += S[k];
      }
      reverse(begin(q), end(q));
      if(T + q == V) {
        cout << "YES\n";
        exit(0);
      }
    }
  }
  cout << "NO\n";


}


Measured memory_bytes: 256
# PROXY

import functools
import fractions
N, X = [int(i) for i in input().split()]
X_N = [int(i) for i in input().split()]
list = []
for e in X_N:
    list.append(abs(e - X))
gcd = functools.reduce(fractions.gcd, list)
print(gcd)

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

using namespace std;

#define MOD 1000000007
#define N 200005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

vector <int> g[N];
int n, m, q;
int c[N];

void dfs(int node, int par, int val){
	c[node] = c[node] + val;
	for(auto it : g[node]){
		if(it == par) continue;
		dfs(it, node, c[node]);
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int x, y, p, i;
	cin>>n>>q;
	m = n-1;
	while(m--){
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	while(q--){
		cin>>p>>x;
		c[p] = c[p] + x;
	}
	dfs(1, -1, 0);
	for(i=1; i<=n; i++){
		cout<<c[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 23552
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,M,K,c,ans=inf;
  cin>>N>>M>>K;
  vec a(N),b(M);
  rep(i,N)cin>>a[i];
  rep(i,M)cin>>b[i];
  while(K--){
    cin>>i>>j>>c;
    i--;j--;
    chmin(ans,a[i]+b[j]-c);
  }
  vsort(a);
  vsort(b);
  chmin(ans,a[0]+b[0]);
  print(ans);
  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#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 repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0, ans = 0;
    rep(i, n) {
        if (a[i] > 0) sum += a[i];
        else {
            ans += sum / 2;
            sum = 0;
        }
    }
    if (sum > 0) ans += sum / 2;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,K,i=0,h=1;
  
  cin >> N >> K;
  
  for (i=0;i<N;i++){
    if(h<K){
      h += h;
    }
    else if(h>=K){
      h += K;
    }
  }
  cout << h << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

    int a,b;

    public void input(){
	Scanner scan = new Scanner(System.in);
	a = scan.nextInt();
        b = scan.nextInt();
        
    }
 


    public void output(){
	if(a > b){
	    System.out.println("a > b");
	}else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
	} 
      
    }
 public static void main(String[] args){
     Main p = new Main();
     p.input();
     p.output();
 }
}
  

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;

string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}

int main() {
    string w;
    cin >> w;
    w = to_upper(w);

    vector<string> terms;
    while (true) {
        string term;
        cin >> term;
        if (term == "END_OF_TEXT") break;
        terms.push_back(term);
    }

    int count = 0;
    for (int i = 0; i < terms.size(); i++) {
        string term = terms[i];
        term = to_upper(term);
        if (term == w) {
            count++;
        }
    }
    cout << count << endl;

}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()

vvi matmul(vvi a, vvi b){
	int n=a.size();
	vvi d(n,vi(n,0));
	rep(i,n)rep(j,n)rep(k,n) d[i][j]|=a[i][k]&b[k][j];
	return d;
}

unordered_map<int,vvi> memo;
inline vvi matpow(vvi a,int p){
	return memo[p]=memo.find(p)==memo.end()?p%2?matmul(matpow(a,p-1),a):matmul(matpow(a,p/2),matpow(a,p/2)):memo[p];
}

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvi z(n,vi(n,0)), e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=1;
		}
		memo.clear();
		memo[1]=e;

		vector<vvi> d(3);
		rep(p,3) d[p]=matpow(e,a[p]);
		
		vi g(n,0), ng(n,0);
		g[n-1]=1;
		rep(t,1000){
			bool next=0;
			fill(all(ng),0);
			rep(i,n) if(!g[i]){
				bool ok=1,r;
				rep(p,3) [&]{r=0; rep(j,n) r|=(g[j] and d[p][i][j]); ok&=r;}();
				if(ok) ng[i]=next=1;
			}
			if(!next){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng[0]){
				cout<<t+1<<endl;
				break;
			}
			rep(i,n)g[i]|=ng[i];
		}
	}
	return 0;
}



Measured memory_bytes: 3376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
#define sp(k) setprecision(k)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     int t,kk;
     double sum;
     vector<double>vec;
     cin>>t;
     for(int i=0;i<t;i++)
        {
            cin>>kk;
            vec.push_back(kk);
        }
     sort(vec.begin(),vec.end());
     sum=vec[0];
     for(int i=1;i<t;i++)
     {
         sum=((sum+vec[i])/2.0);
     }
     cout<<sp(10)<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	int a,x; cin>>x>>a;
	if(x<a) cout<<0;
	else cout<<10;
	return 0;
}

Measured memory_bytes: 256