akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
 
    	int n = sc.nextInt();
    	int[] seq = new int[n];
    	
    	for(int i=0;i<n;i++){
    		seq[i] = sc.nextInt();
    	}
    	
    	System.out.println(lengthOfLIS(seq));
 
    }
    
	static int lengthOfLIS(int[] seq) {
	    int[] dp = new int[seq.length];
	    int len = 0; //長さ
	 
	    for(int num: seq){
	        int idx = Arrays.binarySearch(dp, 0, len, num); //dpテーブルは単調増加なので二分探索できる
	 
	        //keyがなければ(-(挿入ポイント) - 1)が返されているので
	        if(idx < 0){
	            idx = - (idx + 1);
	        }
	 
	        dp[idx] = num;
	 
	        //長さが増えるなら更新
	        if(idx==len){
	            len++;
	        }
	    }
	 
	    return len;
	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 27604
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  }
  else {
    ll A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}


Measured memory_bytes: 256
n,k = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
l.sort()
#print(l)
m = 1000000000
for i in range(n-k+1):
#    print(str(l[i+k-1])+":"+str(l[i]))
    a = l[i+k-1]-l[i]
    if m > a:
        m = a
print(m)

Measured memory_bytes: 7384
# 2, 5 以外にも実現不能なのがあるかも？ Modループして調べる場合。
def main():
    k = int(input())
    tmp = 7 % k
    digits = 1
    rems = set()
    while tmp != 0:
        if tmp in rems:
            return - 1
        rems.add(tmp)
        tmp = (tmp * 10 + 7) % k
        digits += 1
    return digits


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 77900
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> n;
	if (n % 2 == 0) {
		ans = (n / 2) * (n / 2);
	}
	else {
		ans = (n / 2) * (n / 2 + 1);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  	ll x, a, b;
  	cin>>x>>a>>b;
  	if(-a + b <= 0)
      	cout<<"delicious";
  	else if(-a + b <= x)
      	cout<<"safe";
  	else
      	cout<<"dangerous";
	return 0;
}


Measured memory_bytes: 256
numbers = list(map(int, list(str(input()))))
n = len(numbers) - 1

for i in range(2 ** n):
    ans = numbers[0]
    ops = []
    for j in range(n):
        if i >> j & 1:
            ans += numbers[j+1]
            ops.append("+")
        else:
            ans -= numbers[j+1]
            ops.append("-")
    if ans == 7:
        break

print("{0}{4}{1}{5}{2}{6}{3}=7".format(numbers[0], numbers[1], numbers[2], numbers[3], ops[0], ops[1], ops[2]))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  string s;
  cin>>s;
  
  ll cnt=0;
  REP(i,n){
    if(s[i]=='R')
      cnt++;
  }
  
  if(cnt>n-cnt)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;


    
}

Measured memory_bytes: 256
#!python3.4
# -*- coding: utf-8 -*-
# abc156/abc156_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MAX = 2 * 10**5 + 10
MOD = 10**9 + 7

fac = [1, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD

def getP(n, a, b):
    _n = n
    for i in range(1, a):
        _n = (_n * (n - i)) % MOD
    P_a = _n
    for i in range(a, b):
        _n = (_n * (n - i)) % MOD
    P_b = _n
    return (P_a, P_b)

def main():
    n, a, b = i2nn()
    all_C = (pow(2, n, MOD) - 1) % MOD
    P_a, P_b = getP(n, a, b)
    C_a = (P_a * pow(fac[a], MOD-2, MOD)) % MOD
    C_b = (P_b * pow(fac[b], MOD-2, MOD)) % MOD
    print((MOD + all_C - C_a - C_b) % MOD)
    return

main()


Measured memory_bytes: 10968
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {
 
  string S;
  cin >> S;
  ll ans = 0;
  for(ll i = 0; i < S.length()/2; i++){
  	if(S[i] != S[S.length()-1-i]){
    	ans++;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int horizontal_num,vertical_num;
  while(~scanf("%d %d",&vertical_num,&horizontal_num)){
    if(vertical_num == 0 && horizontal_num == 0) break;
    vector<int> horizontals;
    vector<int> verticals;
    for(int i=0;i<vertical_num;i++){
      int h;
      scanf("%d",&h);
      verticals.push_back(h);
    }

    map<int,int> freq;
    for(int start=0;start<verticals.size();start++){
      int len = verticals[start];
      freq[len]++;
      for(int last=start+1;last<verticals.size();last++){
	len += verticals[last];
	freq[len]++;
      }
    }

    for(int i=0;i<horizontal_num;i++){
      int w;
      scanf("%d",&w);
      horizontals.push_back(w);
    }

    int res = 0;
    for(int start=0;start<horizontals.size();start++){
      int len = horizontals[start];
      res += freq[len];
      for(int last=start+1;last<horizontals.size();last++){
	len += horizontals[last];
	res += freq[len];
      }
    }
    
    printf("%d\n",res);
  }
}

Measured memory_bytes: 19000
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
a.each do |x|
  h[x] += 1
end
l = 0
s = 0
h.keys.sort.reverse.each do |k|
  if h[k] >= 4 then
    l = k if l.zero?
    s = k if s.zero?
  elsif h[k] >= 2 then
    if l.zero? then
      l = k
    elsif s.zero?
      s = k
    end
  end
end
puts l * s

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

int t[4] = {6000, 4000, 3000, 2000};

int main(){
    for(int x = 0; x < 4; x++){
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", t[--a]*b);
    }
    return 0;
}

Measured memory_bytes: 1188
function Main(input)
{
  input = input.split("\n");

  var a = parseInt(input[0], 10);
  // for(let i = 1; i <= a; i++)
  // {
  //   if (Math.pow(a, 0.5) % 1 != 0) {
  //     a -= 1;
  //   }else{
  //     console.log(a);
  //     break;
  //   }
  // }
  console.log(Math.pow(parseInt(Math.pow(a, 0.5), 10), 2));



  // console.log('%d', a);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

// 插入此處
const int MAXN = 200000 + 2;
vector<int> A(MAXN), B(MAXN);

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> B[i];
	}
	LL res_n = 0, res_m = 0;
	int ans = 0;
	for (int i = 0, j = 0; i <= N; ++i) {
		if (i == 0) {
			while (j < M && res_m + B[j] <= K) {
				res_m += B[j];
				++j;
			}
			ans = j;
			j--;
		} else {
			res_n += A[i-1];
			while (res_n + res_m > K && j >= 0) {
				res_m -= B[j];
				--j;
			}
			if (res_n + res_m <= K) {
				ans = max(ans, i + j+1);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define equal(a, b, c) ((a) == (b) && (b) == (c) && (a) == (c))
using namespace std;

int main(){
  int n, num[12], v;
  char c;
  scanf("%d", &n);
  while(n--){
    int card[3][9] = {}; // 0:R 1:G 2:B
    memset(card, 0, sizeof(card));
    rep(i, 9) scanf("%d", num+i);
    rep(i, 9){
      v = num[i]-1;
      scanf(" %c", &c);
      if(c == 'R') card[0][v]++;
      if(c == 'G') card[1][v]++;
      if(c == 'B') card[2][v]++;
    }
    int res = 1, j;
    rep(i, 3){
      for(j = 0; j < 9;){
	if(card[i][j]&&card[i][j+1]&&card[i][j+2]){card[i][j]--; card[i][j+1]--; card[i][j+2]--;}
	else  if(card[i][j] > 2) card[i][j]-=3;
	else ++j;
      }
      rep(j, 9) if(card[i][j]) res = 0;
      //      rep(j, 9) printf("%d ", card[i][j]);
      //      puts("");
    }
    
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1188
let popcnt x =
  let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in
  let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in
  let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in
  let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in
  let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in
  (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let () = Scanf.scanf "%d\n%s" @@ fun n x ->
  let x = Array.init n @@ String.get x in
  let pop = Array.fold_right (function '0' -> Fun.id | '1' -> succ) x 0 in
  let dp = Array.make (pop + 2) 0 in
  for i = 1 to pop + 1 do
    dp.(i) <- 1 + dp.(i mod popcnt i)
  done;
  let m0 = Array.fold_left (fun m0 c -> (2 * m0 + if c = '0' then 0 else 1) mod (pop + 1)) 0 x in
  let m1 = Array.fold_left (fun m1 c -> (2 * m1 + if c = '0' then 0 else 1) mod max 1 (pop - 1)) 0 x in
  Fun.flip Array.iteri x @@ fun i c ->
    Printf.printf "%d\n" @@
    try
      succ @@ Array.get dp @@
      if c = '0'
      then (m0 + power (fun x y -> (x * y) mod (pop + 1)) 1 2 (n - i - 1)) mod (pop + 1)
      else (m1 - power (fun x y -> (x * y) mod (pop - 1)) 1 2 (n - i - 1) + pop - 1) mod (pop - 1)
    with Division_by_zero -> 0

Measured memory_bytes: 8988
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int nCount = 0;
    for(int i = 0; i < n; i++){
        int a,b;
        scanf("%d %d", &a, &b);
        if(a == b){
            nCount++;
        } else {
            nCount = 0;
        }
        if(nCount >= 3){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
string s;
stack<int> q;
int top;
struct data
{
    int L,R,c;
}st[100005];

void push(int a, int b){
    top++;
    st[top].L = a;
    st[top].R = b;
    st[top].c = b - a;
}

void solve() {
    cin >> s;
    char ch = char(92);
    //cout << ch;
    for (int i = 0; i < s.length(); i++)
        if (s[i] == ch) q.push(i);
        else
            if (s[i] == '/' && q.size() > 0){
                int a = q.top(), b = i;
                if (top == 0 || (st[top].R < a))
                    push(a,b);
                else {
                    int x = 0;
                    while (top > 0 && a < st[top].L && st[top].R < b) {
                        x += st[top].c;
                        top--;
                    }
                    push(a,b);
                    st[top].c += x;
            }
            q.pop();
        }
    int sum = 0;
    for (int i = 1; i <= top; i++) sum += st[i].c;
    if (top == 0) cout << 0 << '\n' << 0 << '\n';
    else {
        cout << sum << '\n' << top << " ";
        for (int i = 1; i < top; i++)
            cout << st[i].c <<" ";
        cout << st[top].c << '\n';
    }
}

int main() {

    solve();
}



Measured memory_bytes: 3284
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int N = Integer.parseInt(n);
        char[] num = new char[n.length()];
        int[] Num = new int[n.length()];
        int ans = 0;
        for(int i = 0;i < n.length();i++){
            num[i] = n.charAt(i);
            Num[i] = Character.getNumericValue(num[i]);
        }
        for(int i = 0;i < n.length();i++){
            ans += Num[i];
        }
        if(N % ans == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
N, T = map(int, input().split())
c_t_list = [list(map(int, input().split())) for _ in range(N)]
c_t_list = [c_t for c_t in c_t_list if c_t[1] <= T]
if c_t_list:
    print(sorted(c_t_list)[0][0])
else:
    print('TLE')


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

int main()
{
    ll n, k;
    cin >> n >> k;

    if (n % k < abs(n % k - k))
        cout << n % k << endl;
    else
        cout << abs(n % k - k) << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class UnionFind {
    vector<int> p;//p[i]はiの属する組織
public:
    UnionFind(int n) {
        p = vector<int>(n);
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
        return;
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        p[find(x)] = p[find(y)];
    }

/* xとyが属する集合が同じかを判定する */
    bool same(int x, int y) {
        return find(x) == find(y);
    }

};

class Solve {
public:
    int N, M;
    vector<int> p;
    vector<int> x, y;

    void input() {

        cin >> N >> M;

        rep(i, 0, N) {
            int tmp;
            cin >> tmp;
            tmp--;
            p.push_back(tmp);
        }

        rep(i, 0, M) {
            int tx, ty;
            cin >> tx >> ty;
            tx--;
            ty--;
            x.push_back(tx);
            y.push_back(ty);
        }

    }

    void solve() {
        input();

        UnionFind uf(N);
        for(int i = 0; i < M; ++i){
            uf.unite(x[i],y[i]);
        }

        vector<vector<int> > gr(N);
        for(int i = 0; i < N; ++i){
            gr[uf.find(i)].push_back(i);
        }

        ll ans = 0;
        for(int i = 0; i < N; ++i){
            vector<int> a(all(gr[i]));
            vector<int> b;
            for(auto e : gr[i]){
                b.push_back(p[e]);
            }

            sort(all(a));
            sort(all(b));

            int pt1 = 0;
            int pt2 = 0;

            int val = 0;
            while(pt1 < gr[i].size() && pt2 < gr[i].size()){
                if(a[pt1] == b[pt2]){
                    pt1++;
                    pt2++;
                    val++;
                }else if(a[pt1] < b[pt2]){
                    pt1++;
                }else if(a[pt1] > b[pt2]){
                    pt2++;
                }
            }
            ans += val;
        }
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 7416
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll a[5];
    ll n;
    cin>>n>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    ll time=0;
    ll mina=INF;
    for(ll i=0;i<5;i++)
        mina=std::min(mina,a[i]);
    time=(n-1)/mina+5;
    cout<<time<<endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int d[n];
	for(int i=0;i<n;i++){
		cin >> d[i];
	}
	int c[101]={0};
	int count = 0;
	for(int i=0;i<n;i++){
		c[d[i]]++;
	}
	for(int i=0;i<101;i++){
		if(c[i]!=0) count++;
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x)
#define mid (l + r) / 2
#define fi first
#define sc second
#define N 1000000009

using namespace std;

typedef long long int lli;

int main(){
	ios::sync_with_stdio(0);
	string a, b;
	cin >> a >> b;

	vector <vector <pair <int, pair <int, int>>>> dp(a.size()+1, vector <pair <int, pair <int, int>>>(b.size()+1, {0, {0, 0}}));

	for(int i=0; i<a.size(); i++){
		for(int j=0; j<b.size(); j++){
			if(a[i] == b[j]){
				if(dp[i+1][j+1].fi < dp[i][j].fi + 1){
					dp[i+1][j+1].fi = dp[i][j].fi + 1;
					dp[i+1][j+1].sc = {i, j};
				}
			}
			if(dp[i+1][j].fi < dp[i][j].fi){
				dp[i+1][j].fi = dp[i][j].fi;
				dp[i+1][j].sc = {i, j};
			}
			if(dp[i][j+1].fi < dp[i][j].fi){
				dp[i][j+1].fi = dp[i][j].fi;
				dp[i][j+1].sc = {i, j};
			}
		}
	}

	int answer = 0;
	pair <int, int> co;
	for(int i=0; i<=a.size(); i++){
		for(int j=0; j<=b.size(); j++){
			if(answer < dp[i][j].fi){
				co = {i, j};
				answer = dp[i][j].fi;
			}
		}
	}

	stack <char> res;
	while(co.fi > 0 and co.sc > 0){ 
		int i = co.fi, j = co.sc;
		if(dp[i][j].sc == mp(i-1, j-1))
			res.push(a[i-1]);
		co = dp[i][j].sc;
	}

	while(!res.empty()){
		cout << res.top();
		res.pop();
	}

	return 0;
}

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

/*
    AOJ 2249 Road Construction
    本题本质上是Dijkstra形成的生成树问题.
*/

struct edge {
    int to;
    int dist;
    int cost;

    edge(int to = 0, int dist = 0, int cost = 0): to(to), dist(dist), cost(cost) {}
};

typedef pair<int, int> P; // first代表目的顶点, second代表最短距离dist

const int INF = 1e8;
const int MAX_N = 1e4 + 10;
const int MAX_M = 2e4 + 10;

int N = 0;
int M = 0;
vector<edge> G[MAX_N];

int d[MAX_N];
int min_cost[MAX_N];
void dijkstra(int s) {
    fill(d, d + N, INF);
    fill(min_cost, min_cost + N, INF);

    d[s] = 0;
    min_cost[s] = 0;
    priority_queue<P, vector<P>, greater<P> > pque;
    pque.push(P(0, s));

    while (pque.size()) {
        P p = pque.top();
        pque.pop();

        int v = p.second;
        if (p.first > d[v]) {
            continue;
        }

        d[v] = p.first;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[v] + e.dist < d[e.to] || (d[v] + e.dist == d[e.to] && e.cost < min_cost[e.to])) {
                d[e.to] = d[v] + e.dist;
                min_cost[e.to] = e.cost;
                pque.push(P(d[e.to], e.to));
            }
        }
    }
}

void solve() {
    dijkstra(0);
    int res = 0;
    for (int i = 1; i < N; i++) {
        res += min_cost[i];
    }

    printf("%d\n", res);
}

int main() {
    while (scanf("%d %d", &N, &M) != EOF) {
        if (N == 0 && M == 0) {
            break;
        }

        for (int i = 0; i < MAX_N; i++) {
            G[i].clear();
        }
        int from = 0;
        int to = 0;
        int dist = 0;
        int cost = 0;
        for (int i = 0; i < M; i++) {
            scanf("%d %d %d %d", &from, &to, &dist, &cost);
            from--;
            to--;
            G[from].push_back(edge(to, dist, cost));
            G[to].push_back(edge(from, dist, cost));
        }

        solve();
    }

    return 0;
}



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

bool comparator(string a,string b)
{
    return a<b;
}
int main()
{
  int n;
  cin>>n;
  string arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  sort(arr,arr+n,comparator);
  int p=1;
  for(int i=1;i<n;i++)
  {
      if(arr[i]!=arr[i-1])
      {
          p++;
      }
  }
  cout <<p<<endl;
}

Measured memory_bytes: 9884
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int k;
    string s;
    cin>>k>>s;
    if(k>=s.size())cout<<s<<endl;
    else {
        rep(i,k){
            cout<<s[i];

        }
        cout<<"..."<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll powerm(ll a, ll n, ll m) {
	ll res = 1; 
	while (n) { if (n % 2) {res = (res * a) % m;}
		n >>= 1;
		a = (a * a) % m;
	}
	return res;
}
const int M=1e9+7;
ll mod(ll x){
      return ((x%M + M)%M);
}
ll add(ll a, ll b){
      return mod(mod(a)+mod(b));
}
ll mul(ll a, ll b){
      return mod(mod(a)*mod(b));
}
ll minu(ll a, ll b){
	return mod(mod(a)-mod(b));
}
const int maxx = 2e5;

int main(){
	fast();
	int test=1;
	//cin>>test;
	while(test--){
		string s;
		cin>>s;
		int n = s.length();
		if(s[n-1]!='s'){
			s+="s";
		}
		else{
			s+="es";
		}
		cout<<s;
	}
	return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
bool solve(vector<ll> v, ll pos) {
    const ll n = v.size();
    ll sum = 0;
    rep(i, n) {
        sum += v[i];
    }
    if (sum < pos) return false;
    ll tgt = sum - pos;
    each(x, v) x *= 2;
    vector<bool> dp(tgt+1, false);
    dp[0] = true;
    rep(i, n) rrep(j, tgt+1) {
        if (!dp[j]) continue;
        if (j + v[i] <= tgt) {
            dp[j + v[i]] = true;
        }
    }
    return dp[tgt];
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    ll x, y; cin >> x >> y;
    vector<ll> len; len.pb(0);
    each(c, s) {
        if (c == 'F') {
            len.back()++;
        }
        else {
            len.pb(0);
        }
    }
    vector<ll> X, Y;
    const ll n = len.size();
    ll x0 = 0;
    rep(i, n) {
        if (i == 0) {
            x0 = len[i];
        }
        else if (i % 2 == 0) {
            X.pb(len[i]);
        }
        else {
            Y.pb(len[i]);
        }
    }
    if (solve(X, x-x0) && solve(Y, y)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  for (int i = 0; i < A + B + 1; i++) {
    if (i == A && S[i] != '-' || i != A && !isdigit(S[i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  string s, t;
  cin >> s >> t;

  vector<set<ll>> charlist(26);
  rep(i, s.length()) charlist[s[i]-'a'].insert(i);
  ll ans = 0, idx = -1;
  for(char c : t){
    if(charlist[c-'a'].size() == 0){
      ans = -1;
      break;
    }
    auto it = charlist[c-'a'].upper_bound(idx);
    if(it != charlist[c-'a'].end()){
      idx = *it;
    }
    else{
      idx = *charlist[c-'a'].begin();
      ans += s.length();
    }
    // cout << idx << endl;
  }
  if(ans >= 0) ans += idx + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5120
#!/usr/bin/env pypy3

import sys
import math
import itertools
import bisect

INF = int(1e18)

n, t = map(int, sys.stdin.readline().split())

nzshops = []
zshops = []
for _ in range(n):
    a, b = map(int, sys.stdin.readline().split())
    (zshops if a == 0 else nzshops).append((a, b))

nzshops.sort(key=lambda x: x[0] / (x[0] + x[1] + 1), reverse=True)
zshops.sort()

dp = [0]
for i in range(len(nzshops)):
    a, b = nzshops[i]
    dp.append(INF)
    for c in range(len(dp) - 1, 0, -1):
        x = dp[c - 1] + 1
        dp[c] = min(dp[c], x + x * a + b)
    dp = [x for x in dp if x <= t]

rs = list(itertools.accumulate(1 + b for _, b in zshops))
ans = max(c + bisect.bisect(rs, t - dp[c])
        for c in range(len(dp)) if dp[c] <= t)

print(ans)

Measured memory_bytes: 71900
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define SCORE first
#define TEAM second.second

using namespace std;

typedef pair<int, pair<int, string> > piis;

int main(void){
    for(int n, end = 0; cin >> n, n;){
        if(end ++) cout << endl; 
        vector<piis> table;
        while(n --){
            int w, l, d;
            string team;
            cin >> team >> w >> l >> d;
            table.push_back(make_pair(3 * w + d, make_pair(n, team)));
        }
        sort(ALL(table), greater<piis>());

        rep(i, table.size())
            cout << table[i].TEAM << ',' << table[i].SCORE << endl;
    }

}

Measured memory_bytes: 1220
# -*- coding utf-8 -*-
L, R = map(int, input().split())

a = L // 2019
L -= a * 2019
R -= a * 2019
R = min(R, L + 2018)

ans = 10000


for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i*j) % 2019)

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct vertex{
    vector<int> E;//cost,to
};
#define MAX_V 10000
#define MAX_E 100000

bool isVisited[MAX_V];
bool isChecked[MAX_V];
vertex V[MAX_V];
vector<int> A;

void rec(int i){
    isChecked[i]=true;
    for(auto&e:V[i].E){
        if(!isChecked[e]) rec(e);
    }
    A.push_back(i);
    return;
}

int main(){
    int nv,ne;
    cin>>nv>>ne;
    
    for(int i=0;i<ne;i++){
        int s,t;
        cin>>s>>t;
        V[s].E.emplace_back(t);
    }
    
    fill(isChecked,isChecked+MAX_V,false);
    for(int i=0;i<nv;i++){
        if(!isChecked[i]) rec(i);
    }
    for(auto ite=A.rbegin();ite!=A.rend();ite++)cout<<*ite<<endl;
    return 0;
}

Measured memory_bytes: 3832
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans=0;
    rep(i,(n+1)/2-1){
        ans+=a[i];
    }
    for(int i=0;i<(n+1)/2-1;i++){
    ans+=a[(n+1)/2-1-i];
  
    }
      if(n%2==0)ans+=a[(n+1)/2-1];
      cout<<ans<<endl;

}





























































































Measured memory_bytes: 4772
#include <iostream>
#include <string>

using namespace std;

int main(){
	long long N, P[3];
	cin >> N >> P[0] >> P[1] >> P[2];
	string S[N];
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}
	const long long sum = P[0] + P[1] + P[2];

	char ans[N];
	if(sum == 0){
		cout << "No" << endl;
		return 0;
	} else if (sum == 1) {
		for(int i = 0; i < N; i++){
			int p = S[i][0]-'A', n = S[i][1]-'A';
			if(P[p] == 0 && P[n] == 0){
				cout << "No" << endl;
				return 0;
			} else {
				if(P[p] == 1){
					P[p]--;
					P[n]++;
					ans[i] = 'A' + n;
				} else {
					P[p]++;
					P[n]--;
					ans[i] = 'A' + p;
				}
			}
		}
	} else {
		for(int i = 0; i < N; i++){
			int p = S[i][0]-'A', n = S[i][1]-'A';
			if (i == 0 && P[p] == 0 && P[n] == 0){
				cout << "No" << endl;
				return 0;
			} else if(P[n] == 0 && P[p] > 0){
				P[p]--;
				P[n]++;
				ans[i] = 'A' + n;
			} else if(P[p] == 0 && P[n] > 0){
				P[p]++;
				P[n]--;
				ans[i] = 'A' + p;
			} else if(sum == 2 && P[p] == 1 && P[n] == 1 && i != N - 1 && S[i] != S[i + 1]){
				int np = S[i + 1][0]-'A', nn = S[i + 1][1]-'A';
				if(p == np || p == nn){
					P[p]++;
					P[n]--;
					ans[i] = 'A' + p;
				} else {
					P[p]--;
					P[n]++;
					ans[i] = 'A' + n;
				}
			} else {
				if (P[n] > P[p]){
					P[p]++;
					P[n]--;
					ans[i] = 'A' + p;
				} else {
					P[p]--;
					P[n]++;
					ans[i] = 'A' + n;
				}
			}
		}
	}

	cout << "Yes" << endl;
	for(int i = 0; i < N; i++){
		cout << ans[i] << endl;
	}
	cerr << "test: " << P[0] << ", " << P[1] << ", " << P[2] << endl;
	return 0;
}


Measured memory_bytes: 6832
// AOJ Volume 0 Problem 0081

#include <stdio.h>

int main(void)
{
	double x1, y1, x2, y2, xq, yq;
	double a1, b1;
	double a2, b2;
	double xr, yr;

	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF){
		if (x1 == x2){
			xr = xq + (x1 - xq) * 2;
			yr = yq;
		}
		else if (y1 == y2){
			xr = xq;
			yr = yq + (y1 - yq) * 2;
		}
		else {
			a1 = (y2 - y1) / (x2 - x1);
			b1 = y1 - a1 * x1;
			
			a2 = (x1 - x2) / (y2 - y1);
			b2 = yq - a2 * xq;
			
			xr = (yq + b2 - a1 * xq - 2 * b1) / (a1 - a2);
			yr = a2 * xr + b2;
			
//			printf("(%lf %lf    %lf %lf)", a1, b1, a2,b2);
		}

		printf("%lf %lf\n", xr, yr);
	}
	
	return (0);
}

Measured memory_bytes: 0
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j = j - 1
        A[j + 1] = v
        print(' '.join(map(lambda x: str(x), A)))
    return A

N = input()

while True:
    try:
        line = raw_input()
        print(line)
        num_list = map(lambda x : int(x), line.strip().split())
        insertionSort(num_list, N)
    except EOFError:
        break


Measured memory_bytes: 4668
#include <stdio.h>
int main(void){
    int n, x, min, max;
    long sum;
    scanf("%d%d", &n, &x);
    min = max = sum = x;
    while (--n > 0) {
        scanf("%d", &x);
        if (min > x) min = x;
        if (max < x) max = x;
        sum += x;
    }
    printf("%d %d %ld\n", min, max, sum);
}



Measured memory_bytes: 2088
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		String s = saori.nextHayami();
		if(a >= 3200){
			System.out.println(s);
		} else {
			System.out.println("red");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

long long int f(long long int n,long long int w,long long int wt[],long long int val[]){
    
    long long int dp[n+1][w+1];
    
    for(long long int i=0;i<=n;i++){
        for(long long int j=0;j<=w;j++){
            if(i==0||j==0){dp[i][j]=0;continue;}
            
            if(wt[i-1]<=j){
            dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            }
            else{
            dp[i][j]=dp[i-1][j];
            }
            
        }
    }
  return dp[n][w];
}
 
int main() {
	    long long int n;cin>>n;
	    long long int w;cin>>w;
	    long long int wt[n],val[n];
	    
	    for(long long int i=0;i<n;i++){
	        cin>>wt[i]>>val[i];
	    }
	    
	    cout<<f(n,w,wt,val)<<endl;
	
	return 0;
}

Measured memory_bytes: 82340
#include <stdio.h>
int main(){
char a[100],b[100],c[100];
char t,x;
int g=0,h=0,q=0;
int end =1;
scanf("%s%s%s",a,b,c);
t = a[g];
while(end){
switch (t){
case('a'):
  g++;
  t = a[g];
  x = 'A';
  break;
case('b'):
  t= b[h];
  h++;
  x = 'B';
  break;
case('c'):
  t= c[q];
  q++;
  x='C';
  break;
default:
  printf("%c",x);
  end =0;
}
}
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int A, B, C, D, P, amount_X, amount_Y;
    
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &D);
    scanf("%d", &P);
    
    amount_X = A * P;
    
    amount_Y = B;
    if(P > C){ // Y社の水道料金に追加料金がかかる場合
        amount_Y += D * (P - C);
    }
    
    if(amount_X <= amount_Y){
        printf("%d\n", amount_X);
    }else{
        printf("%d\n", amount_Y);
    }
    
    return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double A,B;
    int a,b;
    cin >>A>>B;
    for(int i=1;i<=1000;i++){
        a=i*0.08;
        b=i*0.1;
       if(a==A&&b==B){
           cout <<i<<endl;
           return 0;
       } 
    }
    cout << -1 <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    //static long ans = 0;
    static long[] c;
    static long[][] dc;
    static int[] last;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int d = sc.nextInt();
        c = sc.nextLongArray(26);
        dc = new long[d][26];
        last = new int[26];
        int[] schedule = new int[d];
        for(int i = 0; i < d; i++){
            long maxV = -Integer.MAX_VALUE;
            int max = 0;
            for(int j = 0; j < 26; j++){
                dc[i][j] = sc.nextInt();
                if(maxV < dc[i][j]){
                    maxV = dc[i][j] + (c[j] * (i-last[j]));
                    max = j;
                }
            }
            schedule[i] = max;
            last[max] = i;
        }
        printSchedule(schedule);
    }
    
    public static void checkAns(int[] s){
        int d = s.length;
        last = new int[26];
        long ans = 0;
        for(int i = 0; i < d; i++){
            int hold = s[i];
            last[hold] = i+1;
            ans += dc[i][hold];
            ans = calc(i+1,ans);
        }
        System.out.println(ans);
        return;
    }
    
    public static long calc(int d, long ans){
        for(int i = 0; i < 26; i++){
            ans -= c[i] * (d-last[i]);
        }
        return ans;
    }
    
    public static void printSchedule(int[] schedule){
        for(int d : schedule){
            System.out.println(d+1);
        }
        return;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 28000
n,m,target=map(int,input().split())

a=[[int(i) for i in input().split()] for i in range(n)]

ans=10**9
for i in range(2**n):
    status=[False]*n
    for j in range(n):
        if ((i>>j)&1):
            status[j]=True
            
    score=[0]*m
    total=0
    
    for k in range(n):
        if status[k]==True:
            for x in range(m+1):
                if x==0:
                    total+=a[k][0]
                else:
                    score[x-1]+=a[k][x]

    flag=True
    for i in score:
        if i<target:
            flag=False
    
    if flag:
        ans=min(ans,total)
if ans ==10**9:
    ans=-1
print(ans)


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

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

int main()
{
	int n;cin >> n;
	vector<int> v(n);
	for(int i = 0;i < n;i++)cin >> v[i];
	sort(v.begin(),v.end());
	int ans = -1;
	
	for(int i = 0;i < n;i++){
		if(max(v[i],v[v.size()-1]-v[i]) < max(ans,v[v.size()-1]-ans)){
			ans = v[i];
		}
	}
	cout << v[v.size()-1] << ' ' << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int a, b, k, i=101, count=0;

    cin >> a >> b >> k;

    while(count<k){
        while(b%i!=0 || a%i!=0){
            i--;
        }

        count++;

        i--;
    }

    i++;

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 6e5 + 7;

int n, a[N], k, tree[4 * N];

#define m (l + r) / 2
#define lson 2 * node
#define rson 2 * node + 1

void update(int pos, int v, int l, int r, int node) {
    if (l == r) {
        tree[node] = v;
        return;
    }
    if (pos <= m) update(pos, v, l, m, lson);
    else update(pos, v, m + 1, r, rson);
    tree[node] = max(tree[lson], tree[rson]);
}

int query(int ql, int qr, int l, int r, int node) {
    if (ql <= l && qr >= r) {
        return tree[node];
    }
    int ans = 0;
    if (ql <= m) ans = max(ans, query(ql, qr, l, m, lson));
    if (qr > m) ans = max(ans, query(ql, qr, m + 1, r, rson));
    return ans;
}



int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int res = query(max(a[i] - k, 0), a[i] + k, 0, N, 1) + 1;
        ans = max(ans, res);
        update(a[i], res, 0, N, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9000
import math
N=int(input())
genka=float(N)/1.08
genka2=float(math.floor(genka))
genka3=float(math.ceil(genka))
N2=math.floor(genka2*1.08)
N3=math.floor(genka3*1.08)
if N2==N:
    print(int(genka2))
elif N3==N:
    print(int(genka3))
else:
    print(':(')

Measured memory_bytes: 3060