akhauriyash/Code-Regression huggingface dataset:
a,b,c,d,e,f = map(int,input().split())

# 作れるか判定
def check(goal,ac,bd):
    flag = 0
    for x in range(int(goal//ac)+1):
            if (goal-ac*x)%bd == 0 : flag = 1 ; break
    return flag

# 水W、砂糖Sをまわす
anss = []
for w in range(100,f+1,100):
    for s in range(1,f-w+1):
        if check(w,100*a,100*b) and check(s,c,d) and s<=((w*e)/100):
            conc = 100*s/(w+s) # concentration
            anss.append([conc,w,s])

anss.sort(reverse=1)
(w,s) = (anss[0][1],anss[0][2]) if anss else (100*a,0)
print(w+s,s)


Measured memory_bytes: 45788
import java.lang.Math

fun main(args: Array<String>) {
    val (K, N) = readInputLine().split(" ").map { it.toLong() }
    val AArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    var ans = K - (AArr[0] + (K - AArr[N.toInt() - 1]))

    for (i in 1 until N.toInt()) {
        ans = Math.min(ans, K - (AArr[i] - AArr[i - 1]))
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 83284
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll a, b;
  ll w = 100;
  cin >> a >> b;
  a--;
  b--;
  char grid[101][101];
  REP(i, w) {
    REP(j, w) { grid[i][j] = (j < w / 2 ? '#' : '.'); }
  }
  REP(i, w) {
    if (i % 2)
      continue;
    REP(j, w / 2) {
      if (j % 2)
        continue;
      if (a) {
        grid[i][j] = '.';
        a--;
      }
    }
    FOR(j, w / 2, w) {
      if (!(j % 2))
        continue;
      if (b) {
        grid[i][j] = '#';
        b--;
      }
    }
  }
  cout << w << " " << w << endl;
  REP(ide1, w) {
    REP(ide2, w) { cout << grid[ide1][ide2]; }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 610
char a[maxn][maxn]={0};
int sum[maxn][maxn]={0},ans=0,n,i,j,x,y,k,t;
int max(int x,int y)
{
	return x>y ? x : y;
}
int min(int x,int y)
{
	return x<y ? x : y;
}
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%s",a[i]+1);
		for (j=1;j<=n;j++)
			a[i][j+n]=a[i+n][j]=a[i+n][j+n]=a[i][j];
	}
	for (i=1;i<n*2;i++)
		for (j=1;j<n*2;j++)
			for ((x=i-n+1,y=i+j-x);y>=j-n+1;(x++,y--))
				if ((x>0) && (y>0) && (x<n*2) && (y<n*2) && (a[i][j]==a[x][y]))
				{
					k=max(i,x)-n+1;
					t=max(j,y)-n+1;
					if (k<=0)
					{
						t+=1-k;
						k=1;
					}
					if (t<=0)
					{
						k+=1-t;
						t=1;
					}
					sum[k][t]++;
					sum[min(i,x)+1][min(j,y)+1]--;
				}
	for (i=1;i<n*2;i++)
		for (j=1;j<n*2;j++)
		{
			sum[i][j]+=sum[i-1][j-1];
			if (sum[i][j]==n*n) ans++;
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;


#define MaxN 1000

int par[MaxN];
int rank[MaxN];

//要素数nで木を初期生成
void init(int n){
   rep(i,n){
       par[i] = i;
       rank[i] = 0;
   }
   return;
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if ( x == y ) { return; }

    if( rank[x] < rank[y] ){
        par[x] = y;
    } else {
        par[y] = x;
        if( rank[x] == rank[y] ) { rank[x]++; }
    }
}

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




struct edge{ 
    int u, v, cost;

    edge(int a, int b, int c){
        u = a; v = b; cost = c;
    }
}; 

//typedef struct edge edge;

bool comp( const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}


#define MaxE 1000
vector<struct edge> vec;
//struct edge es[MaxE];

int E;
int N;
int kruskal() { 
    sort(vec.begin(), vec.end(), comp);
    init(1000);
    int res = 0;
    rep(i,E){
        struct edge e = vec[i];
        if(!same(e.u,e.v)) { 
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}





int main()
{
    while ( cin >> N >> E ){
        vec.clear();
        init(100);
        if( N == 0 && E == 0 ) { break; }
        int a,b,c;
        rep(i,E){
            cin >> a >> b >> c;
            vec.push_back( edge( a, b, c) );
        }
        cout << kruskal() << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, d;
int x[11][11];
int cnt;
vector<int> sq;

signed main() {
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    for (int i = 0; i < 500; i++) sq.push_back(i * i);

    for (int j = 0; j < n; j++) {
        for (int i = 0; i < j; i++) {

            int distance = 0;
            for (int k = 0; k < d; k++) distance += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            if (binary_search(sq.begin(), sq.end(), distance)) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

res = 0
tmp = 0
pair = False
if a // 2 + b // 2 < c:
    res = a+b
else:
    res = c*2

tmp = res * min(x, y)

if x > y:
    print(tmp + abs(x - y) * min(res, a))
else:
    print(tmp + abs(x - y) * min(res, b))


Measured memory_bytes: 3060
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec x(n);
	rep(i, n) cin >> x[i];

	ll ans = LINF;
	rep(i, 105){
		ll sum = 0;
		rep(j, n) sum += (x[j]-i)*(x[j]-i);
		chmin(ans, sum);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    N = I()
    s = S()

    R = s.count("R")
    G = s.count("G")
    B = s.count("B")

    dup = 0
    for i in range(N):
        for k in range(i+1, N):
            if (i + k) % 2 == 0:
                j = (i + k) // 2
                if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                    dup += 1

    print(R * G * B - dup)

main()


Measured memory_bytes: 74064
n = int(input())
a_list = list(map(int, input().split()))

def gcd(a,b):
    '''
    3 個以上の値の最大公約数を求めるためには、
    res = 0 と初期化
    各 i に対して res = GCD(res, x[i]) と更新する
    '''
    while b!=0:
        a,b = b,a%b
    return a

ans = 0
for i in range(0,n):
    ans = gcd(ans, a_list[i])

print(ans)

Measured memory_bytes: 15020
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
###############################################################################\
def power(a,p,m):
    if m==0:
        return 0
    res=1
    while(p>0):
        if p&1:
            res=(res*a)%m
        a=(a*a)%m
        p//=2
    return res%m
n=int(input())
s=input()
A=list(int(i) for i in s)
R=[]
for i in range(n-1,-1,-1):
    R.append(A[i])
one=0
for e in A:
    if e==1:
        one+=1
max=one+1
min=one-1
ansmax=0
ansmin=0
#print(one)
for i in range(n):
    ansmax=(ansmax+power(2,i,max)*(R[i]))%max
    if min!=0:
        ansmin=(ansmin+power(2,i,min)*R[i])%min
def popcount(z):
    ans=0
    while(z!=0):
        if z%2==1:
            ans+=1
        z//=2
    return ans
#print(ansmax,ansmin)
B=[]
for i in range(n):
    if R[i]==1:
        if min!=0:
            r=(ansmin-power(2,i,min))%min
            count=1
            while(r!=0):
                count+=1
                r=r%popcount(r)
        else:
            count=0
        B.append(count)
    else:
        r=(ansmax+power(2,i,max))%max
        count=1
        while(r!=0):
            count+=1
            r=r%popcount(r)
        B.append(count)
B.reverse()
for ele in B:
    print(ele)


Measured memory_bytes: 95248
from itertools import accumulate

N,M,Q=map(int,input().split())

Station=[[0 for x in range(N+2)] for y in range(N+2)]

for i in range(M):
  s,t=map(int,input().split())
  Station[1][t]+=1
  Station[s+1][t]-=1
  Station[1][N+1]+=1
  Station[s+1][N+1]-=1

ST1 = [list(accumulate(l)) for l in zip(*Station)]
ST2 = [list(accumulate(l)) for l in zip(*ST1)]
  
for i in range(Q):
  l,r=map(int,input().split())
  print(ST2[l][r])
  
  
  

Measured memory_bytes: 17396
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  int K,X;
  int tmp;

  cin >> K >> X;

  REP( i, (K-1) * 2 + 1 ){
    tmp = X - ( K - 1 ) + i;
    if( tmp >= -1000000 && tmp <= 1000000  ){
      cout << tmp << " ";
    }
  }
  cout << endl;

}

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

Measured memory_bytes: 256
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])

Measured memory_bytes: 105804
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int x;
	cin >> x;
	int ans = 1,cnt = 0;
	while(cnt < x){
		cnt += ans;
		ans++;
	}
	cout << ans - 1 << endl;
}

Measured memory_bytes: 256
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]

count = 0
for i in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == i:
            count += 1
            break
        elif i < S[mid]:
            right = mid
        else:
            left = mid + 1
print(count)



Measured memory_bytes: 16896
// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: i64
    };

    let cnt = n / 100;
    let md = n % 100;

    println!("{}", ifv!(cnt * 5 >= md, 1, 0));

}


Measured memory_bytes: 4352
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 a, b, c, d, e, k;
  std::cin >> a >> b >> c >> d >> e >> k;
  std::cout << (e - a <= k ? "Yay!" : ":(") << std::endl;
  return 0;
}

Measured memory_bytes: 256
# N = gets.chomp.to_i
N, K = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

cnts = N.times.to_a.map { 0 }
0.upto(K-1).each do |i|
  d = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  a.each do |j|
    cnts[j-1] += 1
  end
end

ans = 0
0.upto(N-1).each do |i|
  if (cnts[i] == 0)
    ans += 1
  end
end

p ans

Measured memory_bytes: 14388
n, m = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(m)]
ans = -1
for i in range(1000):
    if len(str(i)) != n:
        continue
    else:
        s = 0
        for j in lis:
            if str(i)[j[0]-1] == str(j[1]):
                s += 1

    if s == m:
        ans = i
        break
print(ans)            

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main() {
    ll n, k; cin >> n >> k;
    ll gcd = 0;
    set<ll> s;
    rep(i, n) {
        ll a; cin >> a;
        s.insert(a);
        gcd = GCD(gcd, a);
    }
    cout << (s.count(k) || (k <= *s.rbegin() && k%gcd == 0) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 8068
N = int(input())
A = list(map(int,input().split()))

Sum = 0

for i in range(N-1):
    if A[i] - A[i+1] > 0:
        Sum += A[i] - A[i+1]
        A[i+1] += A[i] - A[i+1]
        
print(Sum)

Measured memory_bytes: 32236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int H,W;
		String work[] = new String[2];

		while(true){

			try {
				work = br.readLine().split("[\\s]+");

				if(work[0].equals("0") && work[1].equals("0"))break;

				H = Integer.parseInt(work[0]);
				W = Integer.parseInt(work[1]);

				StringBuilder ans = new StringBuilder();

				for(int row = 0; row < H; row++){
					for(int col = 0; col < W; col++){
						if((row+col)%2 == 0){
							ans.append("#");
						}else{
							ans.append(".");
						}
					}
					ans.append("\n");
				}

				System.out.println(ans.toString());


			} catch (IOException e) {

				e.printStackTrace();
			}
		}
	}
}




Measured memory_bytes: 25736
#include <iostream>
#include <cmath>
#include <cstdlib> // rand
#include <cfloat> // DBL_MAX
#include <map>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair

typedef long long ll;
using namespace std;

int main(){
  ll N, A, B;
  cin >> N >> A >> B;

  vector<int> xs(N);
  for(int i=0; i<N; i++){
    cin >> xs[i];
  }

  ll ans = 0;
  for(int i=1; i<N; i++){
    ans += min((xs[i]-xs[i-1]) * A, B);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
//@samraj2k
//#2ksr
//Don't copy my codes. They produce wrong output.
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int h,w;
  cin>>h>>w;
  char arr[h][w];
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      cin>>arr[i][j];
    }
  }

  char arr2[h+2][w+2];
  for (int i = 0; i < h+2; ++i)
  {
    for (int j = 0; j < w+2; ++j)
    {
      if (i==0 || j==0 ||i==h+1 || j==w+1)
      {
        arr2[i][j]='#';
      }
      else{arr2[i][j]=arr[i-1][j-1];}
    }
  }
  for (int i = 0; i < h+2; ++i)
  {
    for (int j = 0; j < w+2; ++j)
    {
      cout<<arr2[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  if (n % 4 == 0 || n % 7 == 0) {
    cout << "Yes" << "\n";
    return 0;
  }

  for (int i = 1; 4 * i <= n; ++i) {
    int cake = 4 * i;
    if ((n - cake) % 7 == 0) {
      cout << "Yes" << "\n";
      return 0;
    }
  }

  cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
public class Main
{
	public static void main(String[] args)
	{
		int i,j;
		for(i = 1;i <= 9;i++)
		{
			for(j = 1;j <= 9;j++)
			{
				System.out.println(i + "x" + j + "=" + i*j);
			}
			
		}
		
	}
	
}

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(ll x) {
  cout << x << endl;
  exit(0);
}

void no() {
  cout << -1 << endl;
  exit(0);
}

int main() {
  ll a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    yes(a * b);
  } else {
    no();
  }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for (auto& d : D) {
        cin >> d;
    }
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += D.at(i) * D.at(j);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] strL = Console.ReadLine().Split(' ');
        int[] L = new int[N];
        for (var i = 0; i < N; i++)
        {
            L[i] = int.Parse(strL[i]);
        }
        int count = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                for (int k = j + 1; k < N; k++)
                {
                    if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k])
                        continue;
                    if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j])
                    {
                        count++;
                    }
                }
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 27428
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
using namespace std;
#define ll long long
#define inf (999999999)
#define fi first
#define se second
#define MOD 1e9+7
#define PI acos(-1.0)
//--------------------------------------------------------------------------------------------------//
int n;
int df[100001];
int ds[100001];
bool pastf[100001];
bool pasts[100001];
vector<int> v[100001];
inline void bfs(int s,int dare) {
	for (int i = 0; i < 100001; i++) {
		pastf[i] = 0;
		pasts[i] = 0;
	}
	pastf[0] = 1;
	pasts[n - 1] = 1;
	queue<pair<int,int>> q;
	q.push(make_pair(s, 0));
	while (!q.empty()) {
		int now = q.front().first;
		int cost = q.front().second;
		q.pop();
		if (dare == 1) df[now] = cost;
		else ds[now] = cost;
		int nowsize = (int)v[now].size();
		for (int i = 0; i <nowsize; i++) {
			int next = v[now][i];
			if (dare == 1 && !pastf[next]) {
				pastf[next] = 1;
				q.push(make_pair(next, cost + 1));
			}
			else if (dare != 1 && !pasts[next]) {
				pasts[next] = 1;
				q.push(make_pair(next, cost + 1));
			}
		}
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		int to, from; cin >> to >> from;
		to--; from--;
		v[to].push_back(from);
		v[from].push_back(to);
	}
	bfs(0, 1);
	bfs(n - 1, -1);
	int contf = 0;
	int conts = 0;
	for (int i = 0; i < n; i++) {
		if (df[i] > ds[i]) conts++;
		else contf++;
	}
	if (contf > conts) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}

Measured memory_bytes: 6952
import std.stdio, std.range, std.conv, std.string, std.array, std.functional;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;

void main()
{
    auto input = readln().strip.split.to!(int[]);
    const N = input[0];
    const Q = input[1];
    const S = readln().strip;

    ulong[] list;
    list.length = S.length;
    char pc = S[0];
    foreach(i; 1..S.length) {
        char c = S[i];
        if(pc=='A' && c == 'C')
        {
            list[i] = list[i-1]+1;
        }else{
            list[i] = list[i-1];
        }
        pc = c;
    }

    foreach(i; 0..Q) {
        input = readln().strip.split.to!(int[]);
        const s = input[0]-1;
        const g = input[1]-1;
        writeln(list[g] - list[s]);
    }
}


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

int main(){
  int N;
  int d[101];
  cin >> N;
  for(int i=0;i<N;i++) cin >> d[i];
  
  int num[101] = {0};
  for(int i=0;i<N;i++){
    num[d[i]]++;
  }
  int res = 0;
  for(int i=1;i<=100;i++){
    if(num[i])res++;
  }
  cout << res << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a>b and b!=1){
    cout<<"Alice";
  }
  if(a<b and a!=1){
    cout<<"Bob";
  }
  if(a==b){
    cout<<"Draw";
  }
  if(a==1 and b!=1){
    cout<<"Alice";
  }
  if(b==1 and a!=1){
    cout<<"Bob";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			double x = sc.nextDouble();
			double h = sc.nextDouble();
			if (x == 0 && h == 0)
				break;
			double a = Math.sqrt(h * h + (x / 2) * (x / 2));
			System.out.println((x * x + 2 * a * x));
		}
	}
}

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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N;
    int64_t K, A[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];

    int64_t opt = 0, opt_less = -1e18;

    for(int d=40; d>=0; d--){
        int64_t D = 1LL<<d;
        
        int num1 = 0;
        for(int i=0; i<N; i++) if(nth_bit(A[i], d)) num1++;
        int num0 = N - num1;

        opt_less += D * max(num0, num1);

        if(nth_bit(K, d)){
            opt_less = max(opt_less, opt + D * num1);
            opt += D * max(num0, num1);
        }else{
            opt += D * num1;
        }
    }

    cout << max(opt, opt_less) << endl;
    return 0;
}

Measured memory_bytes: 1024
l,r=[int(i) for i in input().split()]
ss=2019
ans=200000000
if r-l<2019:
    for j in range(l,r+1):
        for k in range(l,r+1):
            if j==k:
                cnt=0
            else:
                ans=min(ans,j*k%2019)
    print(ans)
else:
    for i in range(1,10**9):
        ss=2019*i
        if l<=ss<=r:
            for j in range(ss,ss+2019):
                for k in range(ss,ss+2019):
                    if j==k:
                        cnt=0
                    else:
                        ans=min(ans,j*k%2019)
            print(ans)
            break

Measured memory_bytes: 41692
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1e9 + 7;
int f[N], dp[N], s[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, d, h;
    dp[0] = 1;
    s[0] = 1;
    cin >> n >> h >> d;
    f[0] = 1;
    int q = 0;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= n; i++){
        q = (q + f[i]) % mod;
    }
    for (int i = 1; i <= h; i++){
        int z = 0;
        if (i <= d) z = s[i - 1]; else z = (s[i - 1] - s[i - 1 - d] + mod) % mod;
        dp[i] = q * z % mod;
        s[i] = (s[i - 1] + dp[i]) % mod;
    }
    int ans = 0;
    for (int i = 1; i <= d; i++){
        ans = (ans + dp[h - i]) % mod;
    }
    cout <<ans * f[n] % mod;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int arr[n];
	int dp[n];
	dp[n-1] = 0;
	for(int i=0; i<n; i++){
	    cin >> arr[i];
	}
	for(int i=n-2; i>=0; i--){
	    int minm = INT_MAX;
	    for(int j=i+1; j<min(i+k+1, n); j++){
	        minm = min((abs(arr[i]-arr[j])+dp[j]), minm);
	    }
	    dp[i] = minm;
	}
	cout << dp[0] << "\n";
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

int sqrtN;
int N, Q;
vector<int> data, backet;

int getSum(int l, int r) {
    int res = 0;
    for (int i = l; i <= r; ++i) {
        if (i % sqrtN == 0 && i + sqrtN <= r) {
            res += backet[i / sqrtN];
            i += sqrtN - 1;
        } else {
            res += data[i];
        }
    }
    return res;
}

void update(int p, int val) {
    data[p] += val;
    backet[p / sqrtN] += val;
}

void debug() {
    cerr << "data = ";
    for (int e : data) cerr << e << " ";cerr << endl;
    cerr << "backet = ";
    for (int e : backet) cerr << e << " ";cerr << endl;
}

int main() {
    scanf("%d%d", &N, &Q);
    sqrtN = sqrt(N);
    data.resize(N, 0);
    backet.resize(sqrtN + 2, 0);
    while (Q--) {
        int c, x, y;
       // debug();
        scanf("%d%d%d", &c, &x, &y);
        if (c) {
            cout << getSum(x - 1, y - 1) << endl;
        } else {
            update(x - 1, y);
        }
    }
}

Measured memory_bytes: 3404
S = input()
table = {}
for s in S:
    if s not in table:
        table[s] = 1
    else:
        table[s] += 1

if len(table) != 2:
    print('No')
    exit()
for t in table:
    if table[t] != 2:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int main() {
  int n;
  int cnt=0;
  cin >> n;
  vector<long long> a(n);

  for (int i=0; i<n; i++) {
    cin >> a[i];
    if(a[i]<0) cnt++;
    a[i] = abs(a[i]);
  }

  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i=0; i<n; i++) ans+=a[i];
  if(cnt%2) ans-= 2*a[0];

  cout << ans << endl;
}

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

const ll INF = 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  
  vector<ll> dp(n, INF);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i-j < 0) continue;
      dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]));
    }
  }
  
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int op(int a, int b){return max(a,b);}
int e(){return (int)(0);}

int main(){
  int N, K; cin >> N >> K;
  vector<int> A(N); rep(i,N) cin >> A[i];
  atcoder::segtree<int,op,e> sg(300001);
  rep(i,N){
    sg.set(A[i],sg.prod(max(0,A[i]-K), min(300001,A[i]+K+1))+1);
  }
  cout << sg.all_prod() << endl;
  return 0;
}


Measured memory_bytes: 9624
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int K=sc.nextInt();
		pw.println((K/2)*((K+1)/2));
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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 int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

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

template <class T>
vector<T> make_v(size_t size, const T &init) {
    return vector<T>(size, init);
}
template <class... Ts>
auto make_v(size_t size, Ts... rest) {
    return vector<decltype(make_v(rest...))>(size, make_v(rest...));
}

enum { D, R, DD, RR };
const int MOD = 1e5;
#define add(a, b) (a += b) %= MOD
#define get(i, j) (dp[i][j][D] + dp[i][j][R] + dp[i][j][DD] + dp[i][j][RR]) % MOD
int main() {
    int h, w;
    while (cin >> h >> w, h) {
        auto dp = make_v(h + 1, w + 1, 4, 0);
        dp[0][0][D] = dp[0][0][R] = 1;
        for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
            add(dp[i + 1][j][DD], dp[i][j][ D]);
            add(dp[i][j + 1][RR], dp[i][j][ R]);
            add(dp[i + 1][j][DD], dp[i][j][DD]);
            add(dp[i][j + 1][ R], dp[i][j][DD]);
            add(dp[i + 1][j][ D], dp[i][j][RR]);
            add(dp[i][j + 1][RR], dp[i][j][RR]);
        }
        cout << get(h - 1, w - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
using namespace std;
int len;
char n[100010];
int main() {
	scanf("%s",n+1);
	len=strlen(n+1);
	if ((n[len]=='1') || (n[1]=='0')) {
		printf("-1\n");return 0;	
	}
	for (int i=1; i<=len/2+1; i++) 
		if (n[i]!=n[len-i]) {
			printf("-1\n");return 0;
		}
	int root=1;
	for (int i=2; i<=len; i++) {
		printf("%d %d\n",root,i);
		if (n[i-1]=='1') root=i;
	}
	return 0;
} 

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vint h(n);
    REP(i,n){
        cin >> h[i];
    }
    sort(ALL(h));
    int ans = INF;
    for(int i=0;i+k<=n;i++){
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

// デバッグ用
#define _DEBUG
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
// ここまで
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    LLI N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    B = min(A, B);
    C = min(B, C);
    D = min(C, D);
    E = min(D, E);

    cout << (N - 1) / E + 5;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}

int main(void){
    string s;
    cin>>s;
    string ans = "";
    for(int i=0;i<s.length();i++){
        if(s[i]=='B'){
            if(ans!="")ans.pop_back();
        }
        else ans.push_back(s[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
K = int(input())

ans = -1
history = set()
b = 0

for i in range(K):
    b = (10 * b + 7) % K

    # loop
    if b in history:
        break

    # success
    if b == 0:
        ans = i + 1
        break

    history.add(b)

print(ans)

Measured memory_bytes: 77916
#include <iostream>
#include <vector>

#define MAX_N 300

using namespace std;

typedef long long ll;

int N, K;
vector<ll> H;

ll solve() {
  vector<vector<ll>> dp(N, vector<ll>(N + 1, 1e11));

  if (N == K) {
    return 0;
  }

  for (int i = 0; i < N; ++i) {
    dp[i][1] = H[i];
  }

  for (int i = 1; i < N; ++i) {
    for (int j = 1; j <= i + 1; ++j) {
      for (int k = 0; k < i; ++k) {
        dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0ll, H[i] - H[k]));
      }
    }
  }

  ll result = 1e11;

  for (int i = 0; i < N; ++i) {
    result = min(result, dp[i][N - K]);
  }

  return result;
}

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

  H = vector<ll>(N);

  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  cout << solve() << endl;

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    string S;
    cin >> S;
    int val = 0, ret = 0;
    FOR(i, 0, S.size()) {
        if (S[i] == 'I') val++;
        else val--;
        ret = max(ret, val);
    }
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
constexpr double eps = 1e-6;
constexpr ll LINF = 100200300400500600ll;
constexpr int INF = 2*((1<<30)-1)+1;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {-1,0,1,0};
constexpr int mod = 1000000007;
#define Yes(ifeq) cout<<(( ifeq )? "Yes":"No")<<endl;

void Main(){
  int r;
  cin>>r;
  cout<<setprecision(10)<<2*r*M_PI<<endl;
  
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 3792
fun main(args: Array<String>) {
  // ABセットで買うほうか、AやBを単体で買ったほうが安いのかが鍵となる問題
  // AとBの合計が >= AB か< ABかで分岐が行われる
  val (A,B,C,X,Y) = readLine()!!.split(" ").map{
    it.toInt()
  }
  val min = Math.min(X,Y)
  // 数量が多いほうの値段と数量を結びつけておく
  val maxM = maxMap(X,Y,A,B)
  if(A + B >= 2*C) {
    if(maxM.second >= 2*C) {
      val sum = 2*C*maxM.first
      println(sum)
      return
    }
    val sum = 2*C*min + maxM.second * (maxM.first - min)
    println(sum)
    return
  }
  val sum = A*X + B*Y
  println(sum)
}

// AとX,BとYがむすびついたMapを返して欲しい
fun maxMap(X: Int, Y: Int, A: Int, B: Int): Pair<Int, Int> {
  if(Math.max(X,Y) == X) {
    return Pair(X,A)
  }
  return Pair(Y,B)
}

Measured memory_bytes: 37852