akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N{}, K{}; cin >> N >> K;
  vector<ui> H(N);
  boost::for_each(H, [](auto& h){ cin >> h; });

  boost::sort(H, std::less<ui>());
  ull ans{std::numeric_limits<ull>::max()};
  for(size_t i = 0; i + K - 1 < N; ++i)
  {
    ans = std::min(ans, (ull)H[i + K - 1] - H[i]);
  }

  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n;
  vector<int> x(10);
  for (int i = 1; i <= 5; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      n = i;
    }
  }
  cout << n << endl;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

#define MAX_H 1000
#define MAX_W 1000
int h, w;
int c[MAX_H][MAX_W];
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

inline bool is_in_range(const int y, const int x) {
    return 0 <= y && y < h && 0 <= x && x < w;
}

queue<pii> que;

int bfs() {
    int step = 0;
    while(!que.empty()) {
        pii now = que.front();
        que.pop();
        int y = now.first, x = now.second;
        step = c[y][x] + 1;
        REP(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if(is_in_range(ny, nx) && c[ny][nx] > step) {
                c[ny][nx] = step;
                que.push(make_pair(ny, nx));
            }
        }
    }
    return step - 1;
}

int main() {
    cin >> h >> w;
    REP(j, h) {
        REP(i, w) {
            char a;
            cin >> a;
            c[j][i] = (a == '#' ? 0 : INT_MAX);
            if(a == '#') que.push(make_pair(j, i));
        }
    }
    cout << bfs() << "\n";

    return 0;
}


Measured memory_bytes: 12304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

// 入力
vector<ll> a;

// dp[left][right] := 区間 [left,right] での解
vector<vector<ll>> dp(3005, vector<ll>(3005, -1));

// メモ化再帰
// turn : 手番  (true, false) = (先手, 後手)
ll memo_rec(int left, int right, bool turn = true){
    if(dp[left][right] != -1)   return dp[left][right];

    int sign = (turn) ? 1 : -1;
    if(left == right){
        return dp[left][right] = sign * a[left];
    }
    
    ll x1 = memo_rec(left + 1, right, turn ^ 1) + sign * a[left];
    ll x2 = memo_rec(left, right - 1, turn ^ 1) + sign * a[right];

    if(turn)    return dp[left][right] = max(x1, x2);
    else    return dp[left][right] = min(x1, x2);
}

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

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    cout << memo_rec(0, n - 1) << endl;
}

Measured memory_bytes: 71168
#include <bits/stdc++.h>
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
#define NIL -1
using ll = long long;
const ll MOD = 1000000007;
#define REP(i,n) for (ll i=0; i < (n); ++i)
#define FOR(i,a,b) for (ll i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a), less<int>());

  int sum = 0;
  int i = 0;
  while (i+1 < n) {
    int t = a[i] + a[i+1];
    if (t < 0) sum += -t;
    else break;
    i += 2;
  }
  while (i < n) {
    sum += a[i++];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

int main(void) {
  VI a(3);
  REP(i, 0, 3) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 1e8;
  REP(i, 0, 2) {
    int lim = a[2] + i;
    int tot = 0;
    REP(j, 0, 3) {
      tot += lim - a[j];
    }
    if (tot % 2 == 0) {
      ans = tot / 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int> max_num;
  max_num.push_back(A.at(0));
  for(int i=1;i<N;i++){
    int k=lower_bound(max_num.begin(),max_num.end(),A.at(i))-max_num.begin();
    if(k==0){
      max_num.insert(max_num.begin(),A.at(i));
    }else{
      max_num.at(k-1)=A.at(i);
    }
  }
  cout<<max_num.size()<<endl;
}


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

inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
 
long long solve(long long x, long long c, long long d) {
    return x - x / c - x / d + x / lcm(c, d);
}
 
int main() {
    long long a, b, c, d; cin >> a >> b >> c >> d;
    cout << solve(b, c, d) - solve(a - 1, c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    tmp = n % 1000
    ans = 1000 - tmp
    if ans == 1000:
        ans = 0
    #print('ans') # debug
    print(ans)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 68488
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;


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

	ll N;
	cin >> N;

	ll ans = 1;

	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	rep(i, N) {
		if ((1000000000000000000 / ans) < A[i]) {
			cout << "-1" << endl;
			return 0;
		}
		ans *= A[i];
	}

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


Measured memory_bytes: 3992
module Union_find : sig
  type t
  val make : int -> t
  val find : int -> t -> int
  val size : int -> t -> int
  val same : int -> int -> t -> bool
  val unite : int -> int -> t -> unit
end = struct
  type t = int array
  let make n = Array.make n (-1)
  let rec find x uf =
    if uf.(x) < 0 then x
    else (( let x' = find uf.(x) uf in uf.(x) <- x'; x' ))
  let same x y uf = find x uf = find y uf
  let size x uf = - uf.(find x uf)
  let unite x y uf =
    let x = find x uf and y = find y uf in
    if x <> y then
      if uf.(x) < uf.(y) then ((
        uf.(x) <- uf.(x) + uf.(y);
        uf.(y) <- x
      )) else ((
        uf.(y) <- uf.(x) + uf.(y);
        uf.(x) <- y
      ))
end
module UF = Union_find

module M = Map.Make(struct type t = int let compare = (-) end)
module S = Set.Make(struct type t = int let compare = (-) end)

let () =
  Scanf.scanf "%d" @@ fun n ->
  let uf = UF.make 100000 in
  let xy = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in
  Array.sort (fun (a,_) (c,_) -> a-c) xy;
  let _ = Array.fold_left (fun (u, v) (w, x) ->
    if u = w then UF.unite v x uf; (w, x)
  ) (-1, -1) xy in
  let ss = Array.fold_left (fun ss (x, y) ->
    let k = UF.find y uf in
    let v = try M.find k ss with Not_found -> S.empty in
    M.add k (S.add x v) ss
  ) M.empty xy in
  let t = M.fold (fun k v s -> UF.size k uf * S.cardinal v + s) ss 0 in
  Printf.printf "%d\n" (t - n)


Measured memory_bytes: 9600
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	for _, v := range s {
		if v == "Y" {
			fmt.Println("Four")
			return
		}
	}
	fmt.Println("Three")
}


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

using namespace std;

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

    int w, h, n, mnx, mny, mxx = 0, mxy = 0;
    int x [101], y [101], a [101];
    cin >> w >> h >> n;
    mnx = w;
    mny = h;

    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> a[i];
        if (a[i] == 1){
            mxx = max (mxx, x[i]);
        }
        if (a[i] == 2){
            mnx = min (mnx, x[i]);
        }
        if (a[i] == 3){
            mxy = max (mxy, y[i]);
        }
        if (a[i] == 4){
            mny = min (mny, y[i]);
        }
    }
    if ((mnx > mxx) && (mny > mxy)){
        cout << (-mxx + mnx) * (-mxy + mny);
    }
    else{
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=998244353;
const int maxn=1e6+10;
const int N=1e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}


int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;cout.tie(0);
    string s;
    int n;
    cin>>n>>s;
    if(n<3200) cout<<"red"<<endl;
    else cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
K, N = map(int, input().split())

A = list(map(int,input().split()))

dist_list = []
dist_list.append(K - A[N-1] + A[0])
for i in range(1, N):
  dist_list.append(A[i]-A[i-1])
dist_list.remove(max(dist_list))
print(sum(dist_list))

Measured memory_bytes: 32376
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair <ll, ll> pll;
 
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;
 
int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul
 
	int a, b;
	cin >> a >> b;
	b += a * 3;
	cout << b / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
num = [[0 for _ in range(10)] for j in range(10)]
for i in range(1,N+1):
    s = str(i)
    f = int(s[0])
    l = int(s[-1])
    if l == 0:
        continue
    num[f][l] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        if i == j:
            tmp = num[i][j]*num[j][i]
            ans += 2*tmp
        else:
            tmp = num[i][j]*num[j][i]
            ans += 2*tmp

print(ans//2)

Measured memory_bytes: 9232
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int n, x;
	int count;

	while (1) {
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		count = 0;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (x == i + j + k) 
						count++;
				}
			}
		}
		cout << count << endl;
	}


	return (0);
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    static long[][] aa;
    static long maxx(String[] grid,int x,int y,int h,int w){

            if(x>=h || y>=w ){
                return 0;
            }
            if( grid[x].charAt(y)=='#' ){
                return 0;
            }
            if(x==h-1 && y==w-1 ){
                return 1;
            }
            if(aa[x][y]!=-1){
                return aa[x][y];
            }

            return aa[x][y]=(long)(maxx(grid,x+1,y,h,w)+maxx(grid,x,y+1,h,w))%(long)(Math.pow(10,9)+7);

    }


    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int h=scanner.nextInt();
        int w=scanner.nextInt();
        String[] grid=new String[h];
        for(int j=0;j<h;j++){
            grid[j]=scanner.next();
        }
        aa=new long[h][w];
        for(int j=0;j<h;j++){
            for(int i=0;i<w;i++){
                aa[j][i]=-1;
            }
        }
        System.out.println(maxx(grid,0,0,h,w));


    }


}


Measured memory_bytes: 36552
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		String s = scanner.next();

		Pattern p = Pattern.compile("[0-9]+-[0-9]+");
		Matcher m = p.matcher(s);

		if (m.find() && s.charAt(a) == '-' && s.length() == a + b + 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int n,A[2000001],B[2000001],C[10001];
void countingsort(int k){
  int i,j;
  for(i=0;i<=k;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}
int main(){
  int k=0,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]) k=A[i];
    B[i]=0;
  }
  countingsort(k);
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<n) printf(" ");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 17364
n = int(input())
s = list(input())
box = []
alfa = [chr(ord('a') + i) for i in range(26)]
ans = 1

for hoge in alfa:
    if hoge in s:
        box.append([hoge, s.count(hoge)])

for hoge in range(len(box)):
    ans *= box[hoge][1] + 1

print((ans - 1) % (10 ** 9 + 7))

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

typedef long long int ll;



int main(){
  ll x;
  cin>>x;
  ll i,j;
  ll ans1,ans2;
  for(i=-1000;i<=1000;i++){
    ll flag=0;
    for(j=-1000;j<=1000;j++){
      ll temp1=i*i*i*i*i;
      ll temp2=j*j*j*j*j;
      if(temp1-temp2==x){
        flag=1;
        ans1=i;
        ans2=j;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  cout<<ans1<<" "<<ans2<<endl;
return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	vi v(n);
	REP(i, n)cin >> v[i];
	int time = 0, ans = 0;
	REP(i, n-1) {
		if (time + t < v[i+1]) {
			ans += t;
		}
		else {
			ans += v[i + 1] - time;
		}

		time = v[i+1];
	}

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


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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;
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}


void solve(){
  int r,d,x;
  cin >> r >> d >>x;

  int ans[10];
  ans[0] = r*x-d;
  rep(i,1,10){
      ans[i] = r*ans[i-1]-d;
  }


  rep(i,0,10) {
    cout << ans[i] << endl;
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

void roll_dice(char c, int d[])
{
    int buf;
    switch(c)
    {
        case 'N':
            buf = d[6];
            d[6] = d[5];
            d[5] = d[1];
            d[1] = d[2];
            d[2] = buf;
            break;
        case 'E':
            buf = d[6];
            d[6] = d[3];
            d[3] = d[1];
            d[1] = d[4];
            d[4] = buf;
            break;
        case 'S':
            buf = d[6];
            d[6] = d[2];
            d[2] = d[1];
            d[1] = d[5];
            d[5] = buf;
            break;
        case 'W':
            buf = d[6];
            d[6] = d[4];
            d[4] = d[1];
            d[1] = d[3];
            d[3] = buf;
    }
}

void init_rand()
{
    srand((unsigned int)time(NULL));
}

int return_random_direction()
{
    switch(rand()%4)
    {
        case 0:
            return 'N';
        case 1:
            return 'E';
        case 2:
            return 'S';
        case 3:
            return 'W';
    }
}    

int main()
{
    int d[7];
    for(int i=1;i<7;i++)
    {
        cin >> d[i];
    }
    
    int q;
    cin >> q;

    int top, front;
    for(int i=0;i<q;i++)
    {
        cin >> top >> front;
        
        int count = 0;
        while(!(d[1]==top && d[2]==front))
        {
            char dir = return_random_direction();
            roll_dice(dir, d);
            count++;
        }
//       cout << d[3] << ": count=" << count<< endl;
        cout << d[3] << endl;
    }
    
    return 0;
}



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

using namespace std;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

const int N = 5000, inf = 0x3f3f3f3f;

int dp[N];

signed main()
{
    fastio;
    int n, m;
    cin >> n >> m;
    int c[N], key[N];
    for (int i = 0; i < m; ++i)
    {
        int sz;
        cin >> c[i] >> sz;
        for (int j = 0; j < sz; ++j)
        {
            int x;
            cin >> x;
            key[i] += (1 << (x - 1));
        }
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < (1 << n); ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            dp[i | key[j]] = min(dp[i | key[j]], dp[i] + c[j]);
        }
    }
    cout << (dp[(1 << n) - 1] == inf ? -1 : dp[(1 << n) - 1]);
    return 0;
}

/* input

*/

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <iostream>
#include <climits>

int main()
{
  int ntrees, block;
  std::cin >> ntrees >> block;
  std::vector<int> tree(ntrees);
  for (int i = 0; i < (int)tree.size(); i++) {
    std::cin >> tree.at(i);
  }
  std::sort(tree.begin(), tree.end());
  int min_diff = INT_MAX;
  for (int i = 0; i + block <= (int)tree.size(); i++) {
    min_diff = std::min(min_diff, tree.at(i+block-1) - tree.at(i));
  }
  std::cout << min_diff << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <iostream>
using namespace std;
using ll = long long;

int n, a[110];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a+ i);

	bool v = true;
	for (int i = 0; i < n; i++)
		if (a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 == 0))
			v = false;
	printf(v ? "APPROVED\n" : "DENIED\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
    double w=0.0, h=0.0, x=0.0, y=0.0;
    cin >> w >> h >> x >> y;

    cout << fixed << setprecision(6) << (w*h)/2 << " ";
    if(x==w/2&&y==h/2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
# C after
n = int(input())
s = str(input())

count_dot = 0
for i in range(n):
    if s[i] == ".":
        count_dot += 1
count_sharp = 0

ans = n
# 0: ###
# 1: .##
# 2: ..#
# 3: ...
for i in range(n):
    ans = min(ans, count_dot+count_sharp)
    if s[i] == "#":
        count_sharp += 1
    else:
        count_dot -= 1
ans = min(ans, count_dot+count_sharp)
print(ans)

Measured memory_bytes: 3500
Module _20190422

    Sub Main()

        Dim sStr() As Char = Console.ReadLine().ToCharArray

        Dim sCorrect As String = ""

        For i As Integer = 0 To sStr.Length - 1

            If sStr(i) = "1" Then

                sCorrect = sCorrect + "9"

            Else

                sCorrect = sCorrect + "1"

            End If

        Next

        Console.WriteLine(sCorrect)

    End Sub

End Module

Measured memory_bytes: 20432
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


n = int(input())
s = input()
t = input()

ans = 2 * n
for i in range(n):
	flag = True
	for j in range(n-i):
		if s[i+j] != t[j]:
			flag = False
			break
	if flag:
		ans = n + i
		break
print(ans)


Measured memory_bytes: 3064
def main(dp, n, menue):
  if menue == 0: m1, m2 = 1, 2
  elif menue == 1: m1, m2 = 0, 2
  elif menue == 2: m1, m2 = 0, 1
  dp[n][menue][0] += sum(dp[n-1][m1]) + sum(dp[n-1][m2])
  dp[n][menue][1] += dp[n-1][menue][0]

def run():
  N, K = map(int, input().split())
  dp = [[[0]*2 for _ in range(3)] for n in range(N)]
  k_li = [list(map(int, input().split())) for k in range(K)]
  k_li = sorted(k_li)
  #print(k_li)
  k_i = 0
  ka, kb = k_li[0]
  if ka == 1:
    dp[0][kb-1][0] = 1
    k_i += 1
    ka, kb = k_li[k_i]
  else:
    for k in range(3):
      dp[0][k][0] = 1
      
  for n in range(1, N):
    if (n+1) == ka:
      main(dp, n, kb-1)
      if k_i < K-1:
        k_i += 	1
        ka, kb = k_li[k_i]
    else:
      for menue in range(3):
        main(dp, n, menue)
  print(sum(map(sum, dp[-1]))%10000)
  #print(dp)
      
if __name__ == '__main__':
  run()


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define sc second
#define fs first
vector < pair < int, int > > ans;
vector < int > ans2;
int n, m, x, a[600][600];
int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			scanf("%d", &a[i][j]);
		}
	}

	for (int i = 1; i <= n; i++){
		for (int j = 1; j < m; j++){
			if (a[i][j]%2){
				ans.pb(mk(i, j));
				a[i][j+1]++;
			}
		}
	}
	for (int i = 1; i < n; i++){
		if (a[i][m]%2){
			ans2.pb(i);
			a[i+1][m]++;
		}
	}
	printf("%d\n", ans.size()+ans2.size());
	int size = ans.size();
	int size2 = ans2.size();
	for (int i = 0; i  <size; i++){
		printf("%d %d %d %d\n", ans[i].fs, ans[i].sc, ans[i].fs, ans[i].sc+1);
	}
	for (int i = 0; i < size2; i++){
		printf("%d %d %d %d\n", ans2[i],  m, ans2[i]+1, m);
	}
	return 0;
}

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

int main() {
    vector<vector<int>> a(3, vector<int>(3, 0));
    rep(i, 3) {
        rep(j, 3) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    rep(i, n) {
        int b;
        cin >> b;
        rep(s, 3) {
            rep(t, 3) {
                if (a[s][t] == b) {
                    a[s][t] = -1;
                }
            }
        }
    }

    rep(i, 3) {
        bool all = true;
        rep(j, 3) {
            if (a[i][j] != -1) {
                all = false;
                break;
            }
        }
        if (all) {
            cout << "Yes" << endl;
            return 0;
        }
        all = true;
        rep(j, 3) {
            if (a[j][i] != -1) {
                all = false;
                break;
            }
        }
        if (all) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (a[0][0] == -1 && a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }

    if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
ans = 0
def kai(s):
 for j in range(len(s)):
  if s[j] != s[len(s)-j-1]:
   return(0)
 return(1)
for i in range(a,b+1):
 ans += kai(str(i))
print(ans)

Measured memory_bytes: 3060
N = int(input())
list1 = [i for i in input()]
K = int(input())

list2 = []
for j in list1:
    if j == list1[K-1]:
        list2.append(list1[K-1])
    else:
        list2.append("*")


ans = ''.join(list2)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n,m;
int pa[233333],dis[233333];
pair<int,int> find(int x)
{
	if(pa[x]==0)return make_pair(x,0);
	else
	{
		pair<int,int> tmp=find(pa[x]);
		dis[x]+=tmp.second;pa[x]=tmp.first;
		return make_pair(pa[x],dis[x]);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	int l,r,d;
	while(m--)
	{
		scanf("%d%d%d",&l,&r,&d);
		pair<int,int> pl=find(l),pr=find(r);
		if(pl.first==pr.first&&pl.second+d!=pr.second)
		{
			return printf("No\n"),0;
		}
		else if(pl.first!=pr.first)
		{
			pa[pr.first]=pl.first;
			dis[pr.first]=d-pr.second+pl.second;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 7;
int main(){
    int n;
    cin >> n;
    ll q = 1;
    for(int i = 1; i <= n; i++){
        q = (q%INF * i%INF)%INF;
    }
    cout << q;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

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

func maxInt(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	maxL, minR := 1, n
	for i := 0; i < m; i++ {
		l, r := nextInt(), nextInt()
		maxL, minR = maxInt(maxL, l), minInt(minR, r)
	}

	fmt.Println(maxInt(0, minR-maxL+1))
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

struct Card{
  char mark;
  char number;
};

int isStable(struct Card *, struct Card *, int);

int main(){
  struct Card C1[100], C2[100],k;
  int n, i, j, minj;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf(" %c %c",&C1[i].mark,&C1[i].number);
  }

  for(i=0;i<n;i++){
    C2[i]=C1[i];
  }
  
  for(i=0;i<=n-1;i++){
    for (j=n-1;j>=i+1;j--){
      if (C1[j].number<C1[j-1].number){
	k=C1[j];
	C1[j]=C1[j-1];
	C1[j-1]=k;
      }
    }
  }
  
  for (i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<=n-1;j++){
      if (C2[j].number<C2[minj].number){
	minj=j;
      }
    }
    k=C2[i];
    C2[i]=C2[minj];
    C2[minj]=k;
  }
  
  for (i=0;i<n;i++){
    if (i>=1) printf(" ");
    printf("%c%c",C1[i].mark,C1[i].number);
  }
  printf("\n");
  printf("Stable\n");
  
  for (i=0;i<n;i++){
    if (i>=1) printf(" ");
    printf("%c%c",C2[i].mark,C2[i].number);
  }
  printf("\n");
  
  if ( isStable(C1, C2, n) == 1 ){
    printf("Stable\n");
    } else {
    printf("Not stable\n");
    }
  
  return 0;
}
int isStable(struct Card C1[], struct Card C2[], int n)
{
  int i;
  for ( i = 0; i < n; i++ ){
  if ( C1[i].mark != C2[i].mark ) return 0;
  }
  return 1;
  }

Measured memory_bytes: 612
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

int main()
{
  init_main();

  int a, b;
  cin >> a >> b;
  int cnt = 0;
  if (a < 0)
  {
    if (b < 0)
    {
      cnt = (-a) - (-b) + 1;
    }
    else
    {
      cnt = -a;
    }
  }
  if (a <= 0 && b >= 0)
  {
    cout << "Zero\n";
  }
  else if (cnt % 2 == 0)
  {
    cout << "Positive\n";
  }
  else
  {
    cout << "Negative\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C;
    int K;
    cin >> A >> B >> C >> K;
    int mc = 0;
    while(A >= B) {
        B *= 2;
        mc++;
    }
    while(B >= C) {
        C *= 2;
        mc++;
    }
    // DUMPLN(mc);
    cout << (mc <= K ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF INT_MAX
#define fi first
#define se second
using namespace std;

int main() 
{
	int n;
	string s;
	cin >> n >> s;
	
	string ans = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	for (int i=0; i<s.length(); i++) {
		int index = s[i]-65;
		int shifted = (index+n) % 26;
		cout << ans[shifted];	
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<pair<int,bool>> so;
  for(int i=2;i<=1000;i++){
    so.pb(make_pair(i,true));
  }
  for(int i=0;i<32;i++){
    if(so[i].second == false)continue;
    for(int j=i+1;j<(int)so.size();j++){
      if(so[j].first % so[i].first == 0){
        so[j].second = false;
      }
    }
  }
  vector<int> realso;
  for(auto x: so){
    if(x.second) realso.pb (x.first);
  }
  ll ans = 1;
  for(int i=0;i<(int)realso.size();i++){
    int cnt=0;
    for(int j=1; j<=N; j++){
      int now = j;
      while(1){
        if(now%realso[i]==0){
          cnt++;
          now /= realso[i];
        }
        else break;
      }
    }
    ans *= (cnt+1);
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
Work = Struct.new(:required, :limit)

n = gets.to_i
works = n.times.map{Work.new(*gets.split.map(&:to_i))}

works.sort_by!(&:limit)

sum = 0
yes = true
works.each do |work|
  sum += work.required
  if sum > work.limit
    yes = false
    puts 'No'
    break
  end
end

if yes
  puts 'Yes'
end

Measured memory_bytes: 22520
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> ab(n);
    for(int i = 0; i < n; ++i){
        cin >> ab.at(i).first;
        cin >> ab.at(i).second;
    }
    sort(ab.begin(), ab.end());

    for(int i = 0; i < n; ++i){
        if(k <= ab.at(i).second){
            cout << ab.at(i).first << endl;
            break;
        }
        k -= ab.at(i).second;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define p_q priority_queue
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    fast_io;

    bool x;
    cin>>x;

    cout<<!x<<endl;

return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define P pair<ll,ll>
#define print(n) cout<<n<<endl

#define x first
#define y second
int k, x, y, t;
P a[200020];//a[0]={x,y}をスタートしてゴール{x,y}に向かっていく
P cal(int x, int y) {
	if (x > y) {//y座標のほうが大きくなるようにする
		P t = cal(y, x);
		return {t.y, t.x};
	}
	if (x < 0) {//xを正の数にする
		P t = cal(-x, y);
		return { -t.x, t.y};
	}
	if (x + y >= 2 * k) return {x, y - k};//y>kのとき

	if (x + y == k) return {0, 0};//到達できた
	return  { -k + (x + y) / 2, x + y - (x + y) / 2};//移動する
}
int main() {
	cin>>k>>x>>y;
	if (!(k & 1) && (x + y) & 1) return puts("-1"), 0;//kが偶数でX+Yが奇数の時到達できない
	a[0] = {x, y};
	for (; a[t].x || a[t].y; t++) a[t + 1] = cal(a[t].x, a[t].y);
	print(t);//手数を出力する
	for (; t--;) print(a[t].x<<" "<<a[t].y);
}

Measured memory_bytes: 5632
#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 EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


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

//ここから編集する
ll gcd(ll a,ll b){
    if(a < b) swap(a,b);
    if(a % b == 0) return b;
    return gcd(b, a % b);

}

ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}



int main() {
    ll N,X;
    cin >> N >> X;

    ll g = gcd(N,X);
    ll ans = 3LL * (N / g - 1) * g;

    cout << ans << endl;


    return 0;
}


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

lst = [list(map(str, input().split())) + [s + 1] for s in range(N)]

all = []
for l in lst:
    l[1] = int(l[1])
    all.append(l)

lst.sort(key=lambda x: int(x[1]), reverse=True)
lst.sort(key=lambda x: x[0], reverse=False)

for l in lst:
    print(int(l[2]))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long K, std::vector<long long> h){
    int count = 0;
    REP(i, N) {
        if (h[i] >= K) count++;
    }
    cout << count << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	unsigned long long N, M;
	cin >> N >> M;

	if (N >= 2 && M >= 2)
	{
		cout << (N - 2) * (M - 2) << endl;
	}
	else if(N == 1 && M == 1)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << max(N, M) - 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256