akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input! {
        N: usize, 
        A: usize,
        B: usize,
        h: [usize; N],
    }

    let max = h.iter().max().unwrap();
    let mut max = (max+B-1)/B+1;
    let mut min = 0;
    loop {
        if max - min <= 1 {
            println!("{}", max);
            return
        }
        let t = min + (max - min) / 2;
        let times = h.iter()
        .fold(0, |acc, hi| acc + (hi.saturating_sub(t*B)+A-B-1)/(A-B));
        if times <= t {
            max = t;
        } else {
            min = t;
        }
    }
}

Measured memory_bytes: 4352
N, M = map(int, input().split())
L = list(map(int, input().split()))

count = 0
vouch = 0
A = []

for i in range (0, N-1):
	if count == 0:
		if L[i]+L[i+1] >= M:
			count=1
			A.append(N-1)
		else:
			A.append(i+1)
	else:
		A.append(N-2-vouch)
		vouch+=1

if count == 0:
	print('Impossible')
	exit()
else:
	print('Possible')
    
for i in range (0, N-1):
	print(A[i])

Measured memory_bytes: 19972
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
struct UnionFind {
    vector<int> par;
    UnionFind(int n) :par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll a, b;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        cin >> a >> b;
        a--;b--;
        uf.connect(a, b);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4000
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	ll n, s;
	cin >> n >> s;
	if (n == 1 && s == 1) {
		cout << 2 << endl;
		return 0;
	}
	for (ll i = 2; i*i <= n; i++) {
		ll sum = 0;
		ll m = n;
		while (m) {
			sum += m % i;
			m /= i;
		}
		if (sum == s) {
			cout << i << endl;
			return 0;
		}
	}
	ll ans = INF;
	for (ll i = 1; i*i < n; i++) {
		if (s < i) break;
		ll j = s - i;
		if (n < j || (n - j) % i) continue;
		ll b = (n - j) / i;
		if (i >= b || j >= b) continue;
		ans = min(ans, b);
	}
	if (s == 1) {
		cout << n << endl;
		return 0;
	}
	if (s == n) {
		cout << n + 1 << endl;
		return 0;
	}
	if (ans < INF) cout << ans << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
Pn = [0] * N
Wrong = 0
Accept = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA" and Pn[p-1] >= 0:
        Pn[p-1] += 1
    elif S=="AC" and Pn[p-1] >= 0:
        Wrong += Pn[p-1]
        Pn[p-1] = -1
        Accept += 1
print(Accept, Wrong)

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

int main(){

int x, y;
cin >> x >> y;
bool can=false;
for(int a=0; a<=x; a++){
    if(2*a+4*(x-a)==y) can=true;
}
if(can) cout << "Yes" << endl;
else cout << "No" << endl;

}

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  int64_t c = N / K;
  int64_t mini1 = N - K * c;
  int64_t mini2 = K * (c + 1) - N;
  
  cout << min(mini1, mini2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(x,y) x=min(x,y)
using namespace std;
using P = pair<int,int>;

const int INF = 1001001001;

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int ans = n / max(h,w);
  if(n % max(h,w) != 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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, 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")
    };
}

fn main() {
    input! {
        n: usize
    }
    let mut ln_list: Vec<u64> = vec![2, 1];
    for i in 2..(n + 1) {
        let l = ln_list[i - 1] + ln_list[i - 2];
        ln_list.push(l);
    }
    println!("{}", ln_list.last().unwrap());
}


Measured memory_bytes: 4352
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
b = LIST()
a = [0 for _ in range(n)]
for i in range(n - 1):
    if i > 0:
        if b[i - 1] >= b[i]:
            a[i] = b[i]
        else:
            a[i] = b[i - 1]
    else:
        a[i] = b[i]
a[-1] = b[-1]
print(sum(a))

Measured memory_bytes: 59628
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while (true) {
		    int n = sc.nextInt();
		    int m = sc.nextInt();
		    if (n == 0 && m == 0) {
		        break;
		    }
		    boolean[] years = new boolean[8000000];
		    int idx = n;
		    for (int i = 0; i <= m; i++) {
		        while (years[idx]) {
		            idx++;
		        }
		        for (int j = 1; j * idx < years.length; j++) {
		            years[j * idx] = true;
		        }
		    }
	        sb.append(idx).append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 147336
# ABC085C - Otoshidama
n, total = list(map(int, input().split()))
total //= 1000
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        if i * 10 + j * 5 + k == total:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 40812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 11

void solver(int nStrLen, char *pcStr, int k) {
	if (pcStr == NULL) {
		return;
	}

	int i = 0;
	char c = pcStr[k-1];

	FOR(i, 0, nStrLen) {
		if (pcStr[i] != c) {
			pcStr[i] = '*';
		}
	}

	printf("%s\n", pcStr);
}

int main() {
	int i,n,k;
	char a[MAXN] = {0};

	scanf("%d", &n);
	scanf("%s", a);
	scanf("%d", &k);

	solver(n, a, k);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int f=0,n;
  char s;
  cin >> n;
  REP(i,n){
    cin >> s;
    if(s == 'Y')
      f = 1;
  }
  
  if(f)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
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(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll r, D, x;

int main()
{
  scanf( "%lld%lld%lld", &r, &D, &x );

  rep( i, 10 )
  {
    x = r*x-D;
    printf( "%lld\n", x );
  }

  return 0;
}

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

const int MAX_N = 104;
const int MAX_W = 100004;

long long dp[MAX_N][MAX_W] = {0};

int main() {
  int N, W;
  cin >> N >> W;
  int w[MAX_N], v[MAX_N];
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j - w[i] >= 0) dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      else dp[i + 1][j] = dp[i][j];
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
#include <stdio.h>

void merge_list(
    long *list,
    long list_member_num,
    long *forward_list,
    long forward_list_member_num,
    long *backward_list,
    long backward_list_member_num
) {
    long i = 0, j = 0, forward_list_index = 0, backward_list_index = 0;

    /* Merge forward_list and backward_list to one list */
    for ( i = 0; i < list_member_num; i++ ) {
        if ( forward_list[forward_list_index] >
             backward_list[backward_list_index] ) {
            list[i] = backward_list[backward_list_index];
            if ( backward_list_index < backward_list_member_num - 1 ) {
                    backward_list_index++;
            }
            /* If all backward_list member were added, 
             * add all rest forward_list member to the end of list */
            else {
                for ( j = i + 1; j < list_member_num; j++ ) {
                    list[j] = forward_list[forward_list_index];
                    forward_list_index++;
                }
                break;
            }
        }
        else {
            list[i] = forward_list[forward_list_index];
            if ( forward_list_index < forward_list_member_num - 1 ) {
                    forward_list_index++;
            }
            /* If all forward_list member were added, 
             * add all rest backward_list member to the end of list */
            else {
                for ( j = i + 1; j < list_member_num; j++ ) {
                    list[j] = backward_list[backward_list_index];
                    backward_list_index++;
                }
                break;
            }
        }
    }

    return;
}

void merge_sort(
    long *list,
    long list_member_num
) {
    long i = 0;
    long middle_index = (list_member_num) / 2;
    long forward_list[middle_index];
    long backward_list[list_member_num - middle_index];

    /* If list size == 1, return */
    if ( list_member_num <= 1 ) {
        return;
    }

    /* Divide list into two lists */
    for ( i = 0; i < middle_index; i++ ) {
        forward_list[i] = list[i];
    }
    for ( i = middle_index; i < list_member_num; i++ ) {
        backward_list[i - middle_index] = list[i];
    }

    /* Sort each of the divided list */
    merge_sort(forward_list, middle_index);
    merge_sort(backward_list, list_member_num - middle_index);

    /* Merge the sorted lists */
    merge_list(list, list_member_num,
               forward_list, middle_index,
               backward_list, list_member_num - middle_index);

    return;
}

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

    merge_sort(d, n);
    printf("%ld\n", d[n / 2] - d[n / 2 - 1]);

    return 0;
}

Measured memory_bytes: 2560
//1時間
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] k = new int[M];
		int[][] s = new int[M][];
		int[] p = new int[M];

		for(int i=0; i<M; i++) {
			k[i] = sc.nextInt();

			s[i] = new int[k[i]];
			for(int j=0; j<k[i]; j++) {
				s[i][j] = sc.nextInt();
			}
		}

		for(int i=0; i<M; i++) {
			p[i] = sc.nextInt();
		}

		int ans = 0;
		for(int i=0; i<(1 << N); i++) {
			boolean allTrunOn = true;
			for(int index=0; index<M; index++) {
				int sum = 0;
				for(int j: s[index]) {
					if((1 & (i >> (j-1))) == 1) {
						sum++;
					}
				}

				if(sum % 2 != p[index]) {
					allTrunOn = false;
					break;
				}

			}

			//すべて点灯
			if(allTrunOn)
				ans++;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>

int main(void)
{
char sen;
int i;
int al[26];

for(i = 0; i < 26; i++)
 al[i] = 0;

while(scanf("%c", &sen) != EOF){

if(sen >= 'a' && sen <= 'z')
 al[sen - 97] += 1;
else if(sen >= 'A' && sen <= 'Z')
  al[sen - 65] += 1;

}


for(i = 0; i < 26; i++)
printf("%c : %d\n", 'a'+i, al[i]);


return 0;

}




Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    for(int i=0;i<S.size()/2;i++){
        if(S[i]!=S[S.size()-i-1]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main(){
    string S;
    int count = 0;

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



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

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s.at(i);
	rep(i, w+2) cout << '#';
	cout << endl;
	rep(i, h){
		cout << '#';
		cout << s.at(i);
		cout << '#';
		cout << endl;
	}
	rep(i, w+2) cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll n, m;
ll ans = 0;
vector<ll> g[9];
bool x[9] = {true};

void search(ll p, ll q){
    if(q == n){
        ans++;
        return;
    }
    for(auto val : g[p]){
        if(!x[val]){
            x[val] = true;
            search(val, q+1);
            x[val] = false;
        }
    }
}

int main(){
    cin>>n>>m;
    for(ll i=0;i<m;++i){
        ll a, b;
        cin>>a>>b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    search(0, 1);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define ll long long
const ll INF = 1e18L;
int main()
{
    ll n, w, sum_value = 0;   cin >> n >> w;
    vector <ll> value(n), weight(n);
    for (int i = 0; i < n; i++)
        scanf("%lld %lld", &weight[i], &value[i]), sum_value += value[i];
    
    vector <ll> dp (sum_value + 1, INF);

    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int k = sum_value - value[i]; k >= 0; k--)
            dp[k + value[i]] = min(dp[k + value[i]], weight[i] + dp[k]);   
    }
 
    ll ans = 0;
    for (int i = 0; i <= sum_value; i++)
        if (dp[i] <= w)
            ans = max(ans, (ll)i);
    
    cout << ans << "\n";
    
    

    
    
}

Measured memory_bytes: 1024
N, A, B = gets.split.map(&:to_i)


base = (N.to_f / (A + B)).floor
mod = N % (A + B)

# p base, mod

add = if mod == 0
      elsif mod == 1
      elsif mod == 2

      else
        A
      end

ans = base * A + [mod, A].min

p ans


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s, t;
    cin >> s >> t;
    bool ans = s.length() + 1 == t.length();
    if (ans) {
        for (int i = 0; i < s.length(); i++) {
            ans &= s[i] == t[i];
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll n , a[N] , mx=2e18 , ans=1;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];

    }
    sort(a+1 , a+n+1);

    for(int i=1; i<=n; i++)
    {
        if (ans == -1) continue;
        if (a[i] == 0)
        {
            return cout << "0\n" , 0;
        }
        if (mx/a[i] <= ans) ans = -1;
        else ans *= a[i];
    }

    if (ans > (ll)1e18) cout << "-1\n";
    else cout << ans << '\n';

    return 0;
}

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

int main(){
  int n,A,B;
  cin >> n >> A >> B;
  int ans=0;
  for(int i=1;i<=n;i++){
    int sum=0;
    int x=i;
    for(int j=0;j<5;j++){
      sum+= x%10;
      x/=10;
    }
    if(A <= sum && sum <=B){
      ans += i;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,m,q,L;
typedef pair<int,int> pii;
vector<pii>g[310];
int ans[310][310],f[310][310],vis[310];
struct ppo{
    int u,v,cos;
    bool operator<(const ppo &r)const{
        if(cos==r.cos) return v<r.v;
        return cos>r.cos;
    }
};
void bfs(int st){
    for(int i=1;i<=n;i++) vis[i]=0;
    priority_queue<ppo>q;
    q.push(ppo{st,L,0});
    while(!q.empty()){
        int u=q.top().u;q.pop();
        vis[u]=0;
        for(pii x:g[u]){
            int v=f[st][u];
            int cost=ans[st][u];
            if(v<x.second) v=L-x.second,cost++;
            else v-=x.second;
            if(cost<ans[st][x.first]||(cost==ans[st][x.first]&&v>f[st][x.first])){
                ans[st][x.first]=cost;
                f[st][x.first]=v;
                if(!vis[x.first]){
                    vis[x.fi]=1;
                    q.push(ppo{x.first,v,cost});
                }
            }
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    cin>>n>>m>>L;
    for(int i=1,a,b,c;i<=m;i++){
        cin>>a>>b>>c;
        if(c>L) continue;
        g[a].pb(pii(b,c));
        g[b].pb(pii(a,c));
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) ans[i][j]=inf;
    }
    for(int i=1;i<=n;i++){
        ans[i][i]=0,f[i][i]=L,bfs(i);
    }
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        if(ans[s][t]==inf) ans[s][t]=-1;
        cout<<ans[s][t]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, ans = 0;

int A[100005];
int B[100005];
int sum[100005];
main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> A[i];
    for(int i = 0; i < n; ++i) cin >> B[i];
    sort(A, A+n); sort(B,B+n);
    sum[0] = 0;
    for(int i = 0; i < n; ++i)
    {
        sum[i+1] = sum[i] + (lower_bound(A,A+n,B[i]) - A);
       // cout << i << " " << sum[i+1] << endl;
    }
    for(int i = 0; i < n; ++i)
    {
        int temp; cin >> temp;
        int ind = lower_bound(B,B+n, temp) - B;
        ans += sum[ind];
        //cout << temp << " ind " << ind << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int T,n,a,b,c,d;
map<int,int>mp;//val->cost
int dfs(int x){
	if(x==0)return 0;
	if(mp.count(x))return mp[x];
	int rem,ret=9e18;
	rem=x%2;
	ret=min(ret,dfs(x/2)+a+d*rem);
	if(rem&&x/2+1<x)ret=min(ret,dfs(x/2+1)+a+d*(2-rem));
	rem=x%3;
	ret=min(ret,dfs(x/3)+b+d*rem);
	if(rem&&x/3+1<x)ret=min(ret,dfs(x/3+1)+b+d*(3-rem));
	rem=x%5;
	ret=min(ret,dfs(x/5)+c+d*rem);
	if(rem&&x/5+1<x)ret=min(ret,dfs(x/5+1)+c+d*(5-rem));
	if(x<=8e9)ret=min(ret,d*x);
	return mp[x]=ret;
}
signed main(){
	cin>>T;
	while(T--){
		cin>>n>>a>>b>>c>>d;
		mp.clear();
		cout<<dfs(n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4412
#include<stdio.h>

int main(void){
    int r;
    scanf("%d",&r);
    if(r<1200){
        printf("ABC\n");
    }
    if(1200<=r&&r<2800){
        printf("ARC\n");
    }
    if(2800<=r){
        printf("AGC\n");
    }
    return 0;
}

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

#define MAX 100005
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dp[101][100005];

int helper(int weight[], int value[], int n, int maxWeight, int index, int weightTillNow){
	if(index == n){
		return 0;
	}
	if(dp[index][weightTillNow] != -1){
		return dp[index][weightTillNow];
	}
	int ans1 = 0, ans2 = 0;
	if(weightTillNow + weight[index] <= maxWeight){
		ans1 = value[index] + helper(weight, value, n, maxWeight, index + 1, weightTillNow + weight[index]);
	}
	ans2 = helper(weight, value, n, maxWeight, index + 1, weightTillNow);

	dp[index][weightTillNow] = max(ans1, ans2);
	return max(ans1, ans2);
}

int32_t main(){
	int N, W;
	cin>>N>>W;

	//Initialize DP Array with value -1.
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 100005; j++)dp[i][j] = -1;
	}

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

	//cout<<helper(weight, value, N, W, 0, 0);//Memoization
    int K[N + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (int i = 0; i <= N; i++) { 
        for (int w = 0; w <= W; w++) {
            if (i == 0 || w == 0) {//Base Case
                K[i][w] = 0; 
            }
            else if (weight[i - 1] <= w){ 
            	int include = value[i - 1] + K[i - 1][w - weight[i - 1]], exclude = K[i - 1][w];
                K[i][w] = max(include, exclude); 
            }
            else{
                K[i][w] = K[i - 1][w]; 
            }
        } 
    } 
  	cout<<K[N][W];
}

Measured memory_bytes: 158080
n = int(input())
a = list(map(int,input().split()))
dict = {}
ans = 0

for i in a:
  if i not in dict:
    dict[i] = 1
  else:
    dict[i] += 1
    
for k,v in dict.items():
  if k > v:
    ans += v
  else:
    ans += v-k
    
print(ans)

Measured memory_bytes: 17780
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll a, b, x[100010];

int main() {
    cin >> n >> a >> b;
    rep(i, n) cin >> x[i];

    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (a * (x[i] - x[i-1]) < b) ans += a * (x[i] - x[i-1]);
        else ans += b;
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;

#define clr(a) (a.clear())
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a))
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define pb push_back
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

#define X first
#define Y second

using pii = pair <int, int>;
using pll = pair <ll, ll>;

const ll inf = 1;
const ll mod = 1E9;


#define SZ 100010



int main() {
#if defined JESI
//        freopen("1.txt", "r", stdin);
//        freopen("2.txt", "w", stdout);
#endif

    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int mask = 0, free = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x >= 1 && x <= 399) {
            mask |= (1 << 1);
        } else if (x >= 400 && x <= 799) {
            mask |= (1 << 2);
        } else if (x >= 800 && x <= 1199) {
            mask |= (1 << 3);
        } else if (x >= 1200 && x <= 1599) {
            mask |= (1 << 4);
        } else if (x >= 1600 && x <= 1999) {
            mask |= (1 << 5);
        } else if (x >= 2000 && x <= 2399) {
            mask |= (1 << 6);
        } else if (x >= 2400 && x <= 2799) {
            mask |= (1 << 7);
        } else if (x >= 2800 && x <= 3199) {
            mask |= (1 << 8);
        } else free++;
    }

    mask = __builtin_popcount(mask);

    int mn = (mask == 0? 1: mask);
    int mx = mask + free;

    cout << mn << ' ' << mx << endl;

    return 0;
}






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

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var ans = Math.Max(0,(B+C)-A);
        Console.WriteLine(ans);
    }

}


Measured memory_bytes: 13268
import java.util.*;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A*N<=B){
            System.out.println(A * N);
        }
        else{
            System.out.println(B);
        }
    }
}

Measured memory_bytes: 23380
// B - Digital Gifts
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	double rate = 380000.0, ans = 0.;
	for(int i=0; i<N; ++i){
		double x; string u; cin>>x>>u;
		ans += u=="JPY"? x: x*rate;
	}
	cout<< ans <<endl;
}

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

int main(){

    string s;
    cin >> s;
    for(int a = s.size()/2 - 1;a >=0;a--){
        if(s.substr(0, a) == s.substr(a, a)){
            cout << a + a << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    double a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double per=0;
    double wa=a*100,ma_su=0,su_re=0,wa_re=a*100;
    for(int i=0;i<=f/(100*a);i++){
        for(int j=0;j<=(f-100*i*a)/(100*b);j++){
            wa=100*a*i+100*b*j;
            ma_su=(wa/100)*e;
            for(int k=0;k<=ma_su/c;k++){
                for(int l=0;l<=(ma_su-k*c)/d;l++){
                    int pre_su=k*c+l*d;
                    if(100*pre_su/(wa+pre_su)>per && pre_su+wa<=f && pre_su<=(wa/100)*e){
                        per=100*pre_su/(wa+pre_su);
                        su_re=k*c+l*d;
                        wa_re=wa;
                    }

                }
            }
        }

    }
    cout<<wa_re+su_re<<" "<<su_re<<endl;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll A;

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

  cin >> n >> A >> b;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        if (a[i] == -1 || a[j] == -1 || a[k] == -1) continue;
        if (a[i] <= A && A + 1 <= a[j] && a[j] <= b && b + 1 <= a[k]) {
          ans++;
          a[i] = -1;
          a[j] = -1;
          a[k] = -1;
        }
      }
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int a,b;
    cin >> a >> b;
    if ((a*b)%2==0) cout << "No" << endl;
    else cout << "Yes" <<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int R = scanner.nextInt();
		
		if (R < 1200) {
			System.out.println("ABC");
		} else if (1200 <= R && R < 2800) {
			System.out.println("ARC");
		} else if (2800 <= R && R <= 4208) {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 21332
// finish date: 2019/2/22

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, W;
    cin >> N >> W;
    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvl dp(N, vl(W + 1, 0));
    dp[0][w[0]] = v[0];
    ll ma = 0;
    FOR(i, 1, N) {
        dp[i][w[i]] = v[i];
        rep(j, W + 1) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j + w[i] <= W ) dp[i][j + w[i]] = max(dp[i][j + w[i]], v[i] + dp[i - 1][j]);
        }
    }
    rep(i, N) rep(j, W + 1) ma = max(ma, dp[i][j]);
    cout << ma << endl;

    return 0;
}

Measured memory_bytes: 79488
S = input()
temp0 = S[:int(len(S)/2)]
temp1 = S[int(len(S)/2):]
temp01 = min(temp0.count('0'), temp1.count('1'))
temp10 = min(temp0.count('1'), temp1.count('0'))
print(temp01 * 2 + temp10 * 2)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    REP(i,n) cin>>h[i];
    vector<int> dp(n+k+1,INF);
    dp[0]=0;
    REP(i,n){
        REP(j,k) dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

int main(int argc, char** argv){
	int n;
	cin >> n;
	int a[n];
	double d = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d *= a[i];
	}
	double nu = 0;
	for(int i = 0; i < n; i++){
		nu += d / a[i];
	}
	cout << d/nu << endl;
	return 0;
}


Measured memory_bytes: 256
import Foundation
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let n = Int(readLine()!)!
var ai = readInts()
var ans = 0
for i in 1..<n {
  if ai[i-1] > ai[i] {
    let d = ai[i-1] - ai[i]
    ans += d
    ai[i] += d
  }
}
print(ans)

Measured memory_bytes: 26496
import java.util.Scanner;

public class Main {

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

			long result = 0;
			int before = Integer.MAX_VALUE;
			for (int i = 0; i < n - 1; i++) {
				int b = sc.nextInt();
				result += b < before ? b : before;
				before = b;
			}
			result += before;
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{ int n,k;
 cin>>n>>k;
 string s;
 cin>>s;
 if(s[k - 1] == 'A') s[k - 1] = 'a';
 if (s[k - 1] == 'B') s[k - 1] = 'b';
 if (s[k - 1] == 'C') s[k - 1] = 'c';
 cout << s;
}

Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int a[5];

int main()

{ 
	cin>>a[0]>>a[1]>>a[2];
	sort (a,a+3);
	//7,5,5
	//5,5,7
	if(a[0]==5&&a[1]==5&&a[2]==7){
		printf("YES\n");
	}
	else{printf("NO\n");

	}
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);printf("%d\n",a*a*a);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        for(int i = 0; i < 3; i++) sum += sc.nextInt();
        System.out.println(sum < 22 ? "win" : "bust");
    }
}


Measured memory_bytes: 23764
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    if(n & 1){
        cout << (n << 1) << endl;
    }else{
        cout << n << endl;
    }

    return 0;
}

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

int main() {
	int n;
	cin>>n;
	set<string>s;
	for(int i=0;i<n;i++){
		string d;
		cin>>d;
		s.insert(d);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 19180
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	string s,t;
	cin>>s>>t;
	for(int i=0;i<26;i++)
	{
		string tt=s;
		tt+=('a'+i);
		if(tt==t)
		{
			cout<<"Yes";
			return;
		}
	}
	cout<<"No";
}

signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}




Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
using namespace std;
int ans;
int main(){
	int n,d;
    cin>>n>>d;
    while(n--){
    	double x,y;
        cin>>x>>y;
        if((double)sqrt(1.0*x*x+y*y)<=(double)d)
          ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	map<int, int> A;
	for (int i = 0; i < n - 1; ++i)
	{
		int in;
		cin >> in;
		++A[in];
	}
	for (int i = 1; i <= n; i++)
	{
		cout << A[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 13004
#include<stdio.h>

int main()
{
   int x[3000], y[3000];
   int i, j;

   for(i=0; i<3000; i++) {
      scanf("%d %d", &x[i], &y[i]);
      if(x[i]==0 && y[i]==0) {
      j = i;
      break;
      }
   }
   
   for(i=0; i<j; i++) {
      if(x[i]<=y[i]) {
         printf("%d %d\n", x[i], y[i]);
      } else if(y[i]<x[i]) {
         printf("%d %d\n", y[i], x[i]);
      }
   }
   
   return 0;
}

Measured memory_bytes: 624
import math

def wareru(s):

    buff = s
    c = 0
    while True:
        if buff % 2 == 0:
            c+=1
            buff = buff / 2
        else:
            return c

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

ans = 0
for i in range(N):
    ans += wareru(A[i])
    # if A[i] == 2:
    #     ans += 1

    # for el in buff:
    #     if el == 2:
    #         ans += 1

print(ans)




Measured memory_bytes: 4148