akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, K;
    cin >> n >> K;
    string s;
    cin >> s;

    int res = 0;
    vector<pair<int,int>> P;
    for (int i = 0; i < n; ++i) {
        int x = s[i] - '0';
        int cnt = 1;
        while (i + 1 < n && s[i + 1] == s[i]) {
            ++i;
            ++cnt;
        }
        P.emplace_back(x, cnt);
        if (x == 1) {
            res = max(res, cnt);
        }
    }

    int N = P.size();

    int sum = 0;
    for (int i = 0, j = 0, k = 0; i < N; ++i) {
        sum += P[i].second;
        if (P[i].first == 0) {
            ++k;
        }
        while (k > K) {
            if (P[j].first == 0) {
                --k;
            }
            sum -= P[j].second;
            ++j;
        }
        res = max(res, sum);
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 1528
N = int(input())
ans = 0
coeff = 380000.0
for _ in [0]*N:
    x, u = input().rstrip().split()
    x = float(x)
    if u == 'JPY':
        ans += x
    elif u == 'BTC':
        ans += x * coeff
print('%.06f' % ans)

Measured memory_bytes: 3060
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

#[test]
fn test_primes(){
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1,2,2,5,7])
}
fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"12 18
" => r"3",

r"420 660
" => r"4",

r"1 2019
" => r"1"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        a:i64,
        b:i64,
//        a:[i32;n],
    }
    let a: i64 = a;
    let b: i64 = b;

    let gcd = gcd(a, b);
    let mut primes = primes(gcd);
//    dbg!(&primes);
    primes.dedup();

    let ans = primes.len();
    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string N;
    cin >> N;
    cout << "ABC" + N << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;


int main() {
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end(), greater<int>());
    cout << a[0] * 10 + a[1] + a[2] << endl;
}



Measured memory_bytes: 256
# Problem  https://atcoder.jp/contests/abc069/tasks/abc069_b
str = gets.chomp('\n')
strSize = str.size
firstChar = str[0]
lastChar = str[strSize-2]
# puts(firstChar)
# puts(lastChar)
answer = firstChar << (strSize-3).to_s << lastChar
puts(answer)



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

const int N = 2e5+7, M = 1e9+7;
typedef long long LL;

LL power(LL a, LL p) {
    if (p == 0) return 1;
    LL ans = power(a, p/2);
    ans = (ans * ans)%M;
    if (p%2)    ans = (ans*a)%M;
    return ans;
}

LL fac[N], invfac[N], p2[N];
void pre() {
    fac[0] = 1;
    for(int i=1; i<N; i++)  fac[i] = (i*fac[i-1])%M;
    invfac[N-1] = power(fac[N-1], M-2);
    for (int i=N-2; i>=0; i--)  invfac[i] = (invfac[i+1]*(i+1))%M;
    p2[0] = 1;
    for(int i=1; i<N; i++)  p2[i] = (2*p2[i-1])%M;
}

int sz[N];
LL dp[N], invdp[N], prod[N], invprod[N], dpprod[N], invdpprod[N];
vector<int> adj[N];


void dfs1(int u, int p) {
    sz[u] = 1;
    dpprod[u] = invprod[u] = invdpprod[u] = prod[u] = 1;
    for (int v: adj[u]) {
        if (v == p)   continue;
        dfs1(v, u);
        sz[u] += sz[v];
        invprod[u] = (invprod[u] * invfac[sz[v]])%M;
        prod[u] = (prod[u] * fac[sz[v]])%M;
        dpprod[u] = (dpprod[u] * dp[v])%M;
        invdpprod[u] = (invdpprod[u] * invdp[v])%M;
    }
    dp[u] = (dpprod[u] * invprod[u])%M;
    dp[u] = (dp[u] * fac[sz[u]-1])%M;
    invdp[u] = (invdpprod[u] * prod[u])%M;
    invdp[u] = (invdp[u] * invfac[sz[u]-1])%M;
}

LL ans[N], over[N], invover[N];
int n;

void dfs2(int u, int p) {
    if (p == -1)    ans[u] = dp[u];
    else {
        LL dpp = (dpprod[p] * invdp[u])%M;
        LL invp = (invprod[p] * fac[sz[u]])%M;
        LL invdpp = (invdpprod[p] * dp[u])%M;
        LL invinvp = (prod[p] * invfac[sz[u]])%M;

        over[u] = (dpp*invp)%M;
        over[u] = (over[u] * fac[n-sz[u]-1])%M;
        invover[u] = (invdpp*invinvp)%M;
        invover[u] = (invover[u] * invfac[n-sz[u]-1])%M;

        dpprod[u] = (dpprod[u] * over[u])%M;
        invprod[u] = (invprod[u] * invfac[n-sz[u]])%M;
        invdpprod[u] = (invdpprod[u] * invover[u])%M;
        prod[u] = (prod[u] * fac[n-sz[u]])%M;

        ans[u] = (dpprod[u] * invprod[u])%M;
        ans[u] = (ans[u] * fac[n-1])%M;
    }
    for (int v: adj[u]) {
        if (v == p) continue;
        dfs2(v, u);
    }
}

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

    cin>>n;
    for (int i=1; i<n; i++) {
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs1(1, -1);
    dfs2(1, -1);

    for (int i=1; i<=n; i++)    cout<<ans[i]<<"\n"; cout<<endl;
}



Measured memory_bytes: 33524
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>

using int64 = long long;

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

    int N;
    std::cin >> N;

    std::map<int, int> counter;
    int64 exor = 0;
    for (int i = 0; i < N; i++) {
        int64 a;
        std::cin >> a;
        exor ^= a;

        // 1になっている1番下の桁を取得
        int b = 0;
        while (((a >> b) & 1) == 0) b++;
        counter[b]++;
    }
    // std::cerr << std::bitset<8>(exor) << std::endl;
    // 

    int i = 0,
        ans = 0,
        bit = exor & 1;

    while (true) {
        // 現在の状態と下からi+1桁目のビットが異なる位置を探す
        while (i < 40 and ((exor >> (i + 1)) & 1) == bit) i++;

        if (i == 40) break;

        if (counter[i] == 0) {
            // std::cerr << "i: " << i << std::endl;
            std::cout << -1 << std::endl;
            return 0;
        }
        // std::cerr << "i: " << i << " " << bit << std::endl;
        i++;
        bit = bit ^ 1;
        ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int d, g;
int p[10], c[10];
int ans = 1e9;
void f(int a, bool b[], int cnt, int num) {
	if (a == d) {
		if (g <= num) {
			chmin(ans, cnt);
		} else {
			rrep(i, d - 1, -1) {
				if (b[i])
					continue;
				if (g <= num + (i + 1) * 100 * (p[i] - 1)) {
					chmin(ans, cnt + ceil((g - num) / ((i + 1) * 100.0)));
					break;
				}
			}
		}
		return;
	}
	f(a + 1, b, cnt, num);
	b[a] = true;
	f(a + 1, b, cnt + p[a], num + (a + 1) * 100 * p[a] + c[a]);
}
int main() {
	cin >> d >> g;
	rep(i, 0, d) cin >> p[i] >> c[i];
	bool b[10] = {};
	f(0, b, 0, 0);
	print(ans);
	return 0;
}


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


int main() {
    vector<int> X(3);
    for (int i = 0; i < 3; i++) {
        cin >> X[i];
    }
    sort(X.begin(), X.end());

    if ((X[2] - X[0]) % 2 == (X[2] - X[1]) % 2) {
        if ((X[2] - X[0]) % 2 == 0) {
            cout << (X[2] - X[0]) / 2 + (X[2] - X[1]) / 2 << endl;
        } else {
            cout << (X[2] - X[0] - 1) / 2 + (X[2] - X[1] - 1) / 2 + 1 << endl;
        }
    } else {
        X[2]++;
        X[0]++;
        if ((X[2] - X[0]) % 2 == 0) {
            cout << (X[2] - X[0]) / 2 + (X[2] - X[1]) / 2 + 1 << endl;
        } else {
            cout << (X[2] - X[0] - 1) / 2 + (X[2] - X[1] - 1) / 2 + 2 << endl;
        }
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    double R, G;
    cin >> R >> G;
    cout << 2 * G - R << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
	FOR(i, 1,  10) {
		FOR(j, 1,  10) {
			if (i*j == N) {
				cout << YES << "\n";
				return;
			}
		}
	}
	cout << NO << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

struct Card{
    public:
    char mark;
    char value;
};

void bubbleSort(Card *C, int N);
void selectSort(Card *C, int N);
void display(Card *C, int N);
int isStable(Card *C1, Card *C2, int N);

int main(){
    int N;
    Card C1[101], C2[101];
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> C1[i].mark >> C1[i].value;
        C2[i].mark = C1[i].mark;
        C2[i].value = C1[i].value;
    }
    bubbleSort(C1,N);
    display(C1, N);
    cout << "Stable" <<endl;
    selectSort(C2, N);
    display(C2, N);
    if(isStable(C1, C2, N)){
        cout << "Stable" <<endl;
    }else{
        cout << "Not stable" <<endl;
    }
}

void bubbleSort(Card *C, int N){
    for(int i=0; i<N; i++){
        for(int j=N-1; j>i; j--){
            if (C[j].value < C[j-1].value){
                Card tmp;
                tmp = C[j];
                C[j] = C[j-1];
                C[j-1] = tmp;
            }
        }
    }
}

void selectSort(Card *C, int N){
    for(int i=0; i<N; i++){
        int minj = i;
        for(int j=i; j<N; j++){
            if (C[j].value < C[minj].value){
                minj =j;
            }
        }
        Card tmp;
        tmp = C[i];
        C[i] = C[minj];
        C[minj] = tmp;
    }
}

void display(Card *C, int N){
  for(int i=0; i<N-1 ;i++){
    cout <<C[i].mark<< C[i].value << " ";
  }
  cout <<C[N-1].mark<< C[N-1].value<<endl;
}

int isStable(Card *C1, Card *C2, int N){
  for ( int i = 0; i <N; i++ ){
    if ( C1[i].mark != C2[i].mark ) return 0;
  }
  return 1;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int n;
long long int a, b, c, s;
 int main()
 {
     cin >> n;
     while(n--)
     {
         cin >> a >> b >> c;
         a = a*a;
         b = b*b;
         c = c*c;
         if (a == b + c || c  == b + a || b == a + c)
            cout << "YES" << endl;
         else
            cout << "NO" << endl;
     }
     return 0;
 }

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int ok[] = { 111, 222, 333, 444, 555, 666, 777, 888, 999 };
  int N; std::cin >> N;

  for(int i=0; i<9; i++) {
    if ( N <= ok[i] ) {
      std::cout << ok[i] << std::endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int amount = sc.nextInt();
		int number = sc.nextInt();
		boolean [] discard = new boolean[10];
		int smallest = 0;
 		for(int i = 0; i < number; i ++) {
 			int d = sc.nextInt();
			discard[d] = true; 		
			if(smallest == d) smallest = d + 1;
		}
 		String amountString = "" + amount;
 		boolean [] add = new boolean[amountString.length()];
 		for(int i=add.length-1; i>=0; i--) {
 			if(i==add.length-1) add[i] = discard[amountString.charAt(i)-'0'];
 			else add[i] = (add[i+1] || discard[amountString.charAt(i)-'0']);
 		}

		int result = 0;
		int remain = 0;
		int base = 1;
		int pos = 0;
		while(amount != 0 || remain != 0) {
			int digit = amount % 10 + remain;
			int upDigit = digit + 9;
			while((digit <= upDigit) && discard[digit % 10]) digit ++;
			
			remain = digit / 10;
			digit = digit % 10;
			amount /= 10;
			if((pos+1<add.length) && add[pos+1]) digit = smallest;
			
			result += digit * base;
			base *= 10;
			pos ++;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 8788
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

ans = None
for x in it.product([0, 1], repeat=10):
    if not any(x):
        continue
    sumP = 0
    for i in range(N):
        c = sum(map(lambda fijkxjk: (1 if all(fijkxjk) else 0), zip(F[i], x)))
        dump(i, c, list(x), P[i][c])
        sumP += P[i][c]
    ans = max([ans, sumP]) if ans else sumP
dump(N, F, P)
print(ans)


Measured memory_bytes: 50780
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        long a = Long.parseLong(s.next());
        long b = Long.parseLong(s.next());
        long c = Long.parseLong(s.next());
        long k = Long.parseLong(s.next());

        if (k <= a) {
            System.out.println(k);
        } else if(a + b >= k) {
            System.out.println(a);
        } else {
            System.out.println(a - (k - a - b));
        }
    }
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    ll K;
    cin >> K;
    vector<string> v;
    REP(i, S.length())
    {
        string s = "";
        REP(j, K)
        {
            if (j + i >= S.length())
                break;
            s.push_back(S[j + i]);
            v.push_back(s);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
j = 0
while j < 20:
    n = int(input())
    if n == 0:
        break
        
    ice = []
    for i in range(n):
        a = int(input())
        ice.append(a)

    for i in range(10):
        b = ice.count(i)
        if b == 0:
            print('-')
        else:
            print('*'*b)


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

int f(int x, int y) {
	if(y == 0) return x;
	else return f(y, x % y);
}

int main() {
	int n, x; cin >> n >> x;
	int d[n];
	for (int i = 0; i < n; i++)
	{
		int s; cin >> s;
		d[i] = abs(s - x);
	}

	int res = d[0];
	for (int i = 1; i < n; i++)
	{
		res = f(res, d[i]);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>
int main(void) {
    int ac = 0, wa = 0, tle = 0, re = 0, n;
    char count[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s",count);
        if (count[0] == 'A') {
            ac = ac + 1;
        } else if (count[0] == 'W') {
            wa = wa + 1;
        } else if (count[0] == 'T') {
            tle = tle + 1;
        } else {
            re = re + 1;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int digits(int64_t N){
  string s = to_string(N);
  return s.size();
}

int main(){
  int64_t N;
  cin >> N;
  int ans = 11;
  double root = sqrt(N);
  for(int i = 1; i <= root ; i++){
    int a = 11;
    if (N % i == 0){
      a = max(digits(i), digits(N/i));
    }
    ans = min(ans, a);
  }
  cout << ans << endl;
}

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

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long int ll;
typedef unsigned long long int ull;
#define inf INT_MAX
#define minf INT_MIN
#define watch(x)	cout<<(#x)<<"=>"<<x<<'\n';
#define sz(a) (int)(a).size()

ll ans;
int arr[300009];
vi vr;
void solve()
{
				string s;	cin>>s;
				for(int i = 0; s[i] != '\0';++i){
								ans += (s[i]-48);
				}
				if(ans % 9 == 0){
								cout<<"Yes\n";
				}
				else	cout<<"No\n";
}

int main()
{
				ios_base::sync_with_stdio(false);
				cin.tie(NULL);
				int testc = 1;
				for(int t = 0; t < testc; ++t)
								solve();
				return 0;
}

		//Sat 22 Aug 2020 05:40:02 PM IST


					/***astrainL3gi0N***/


Measured memory_bytes: 3708
#include <stdio.h>

int main(){
    int d1,d2,d3;
    scanf("%d %d %d",&d1,&d2,&d3);

    if(!(d1 < d2 && d2 < d3)){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<bool> isSnack(N);
    REP(i, K)
    {
        ll d;
        cin >> d;
        REP(i, d)
        {
            ll a;
            cin >> a;
            a--;
            isSnack[a] = true;
        }
    }
    ll ans = 0;
    REP(i, N) if (!isSnack[i]) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 3632
import queue

k = int(input())

q = queue.Queue()

for i in range(9):
    q.put(i + 1)

for i in range(k):
    x = q.get()
    y = x % 10
    if x % 10 != 0:
        q.put(10*x + y - 1)
    q.put(10*x + y)
    if x % 10 != 9:
        q.put(10*x + y + 1)
print(x)

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;
    cout << (b + a - 3) / (a - 1) << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e16
ll n0,k0;
ll dp[100005][3]={0};

void solv()
{
    ll a,b,c,d,e,f,n,m,k,t,q;
    cin>>n;
    ll arr[n+1][3];
    
    n0=n;
    for(int i=0;i<n;i++) 
    {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=max(dp[i][j],arr[i][j]+dp[i-1][(j+1)%3]);
            dp[i][j]=max(dp[i][j],arr[i][j]+dp[i-1][(j+2)%3]);
        }
    }
    a=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
    cout<<a<<"\n";
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,e,f,n,m,k,t,q;
    t=1;
    //cin>>t;
    string s1,sf,phrase;
    while(t--)
    {
        solv();
    }
    return 0;
}

Measured memory_bytes: 4992
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = input()
cnt = 0
ans = 0
for i in range(len(S)):
    if S[i] == 'S':
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 78080
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}



int main(){
    // Failed to predict input format
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){

  int N;
  cin>>N;
  int count=0;
  int ans=0;
  vector<long long>a(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>a[i];
    while(a[i]%2==0){
    
      a[i]/=2;
      count++;
    }
    ans+=count;
    count=0;
  }
  cout<<ans;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int n;
cin>>n;
ll a[n];
rep(i,n){
    cin>>a[i];
}
int ans=INF;
rep(i,n){
int count=0;
while(a[i]%2==0){
    a[i]/=2;
    count++;
}
ans=min(ans,count);
}
cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[200010];
ll mp[11][11];
int main(){
    int n, x,y, m, k;
    while(cin>>n){
        ll ans=0;
        for(int i=1; i<10; ++i){
            if(i<=n){
                ++mp[i][i];
            }
            for(int j=1; j<10;++j){
                if(i*10+j<=n){
                    ++mp[i][j];
                }
                int x=1;
                for(int l=1; l<=4; ++l) {
                    x*=10;
                    for (int k = 0; k<x; ++k){
//                        cout<<i*x*10+k*10+j<<" "<<j*x*10+k*10+i<<endl;
                        if(i*x*10+k*10+j<=n){
                            ++mp[i][j];
                        }
                    }
                }
            }
        }
        for(int i=1; i<10; ++i){
            for(int j=1; j<10; ++j){
                ans+=mp[i][j]*mp[j][i];
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

const int maxn = 1e3+10, maxh = 1e4+10;
int h, n;
int a[maxn], b[maxn], f[maxh];

int main() {
	cin >> h >> n;
	memset(f, 0x3f, sizeof(f));
	f[0] = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
		for (int j = 0; j <= h; ++j) {
			if (j <= a[i]) f[j] = min(f[j], b[i]);
			else f[j] = min(f[j], b[i]+f[j-a[i]]);
		}
	}
	cout << f[h] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    map<ll, ll> mp;
    REP(i, n){
        cin >> a[i];
        mp[a[i]] = i + 1;
    }
    REP(i, n){
        ll res = mp[i + 1];
        cout << res << " ";
    }
    return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string aa[2] = {"GREATER\n", "LESS\n"};
    string a, b; cin >> a >> b;
    if (a.size() != b.size()) {
        cout << aa[a.size() < b.size()];
        return 0;
    }
    rep (i, a.size()) {
        if (a[i] != b[i]) {
            cout << aa[a[i] < b[i]];
            return 0;
        }
    }
    cout << "EQUAL\n";
    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, W;
int v[111], weight[111];
int dp[111][11111];

void print() {
   repp (i, 1, N+1) {
      for (int w = 0; w <= W; w++) {
         printf("%3d ", dp[i][w]);
      }
      puts("");
   }
}

int main() {
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i+1] >> weight[i+1];
   }

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

   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7392
/* C - A x B + C */

#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, ans = 0;
  cin >> N;
  for(int c = 1; c < N; c++){
    int x = N - c, cnt = 0;
    for(int i = 1; i * i <= x; i++){
      if(i * i == x){
        ans++;
        break;
      }
      if(x % i == 0) cnt++;
    }
    ans += cnt * 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include <stdio.h>
#define MAX_H 300
 
int main(void) {
  int i, n;
  int A[MAX_H];
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
 
  for (i = 1; i <= n; i++) {
    printf("node %d: key = %d, ", i, A[i]);
    if (i != 1) {
      printf("parent key = %d, ", A[i/2]);
    }
    if (2*i <= n) {
      printf("left key = %d, ", A[2*i]);
    }
    if (2*i + 1 <= n) {
      printf("right key = %d, ", A[2*i + 1]);
    }
    putchar('\n');
  }
 
  return 0;
}


Measured memory_bytes: 2048
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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 $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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(m: i32, d: i32);
    let mut ans = 0;
    for x in 2..10 {
        for y in 2..10 {
            if 10 * x + y > d {
                continue;
            }
            if x * y <= m {
                ans += 1;
            }
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int mod = pow(10, 9) + 7;

int main(){
    string s;
    cin >> s;
    rep(i, s.length()){
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())

ans = [0] * n 
for i in range(1, n + 1):
  # D[j]はiとjの最短距離
  D = [0] * (n  + 1)
  for j in range(i, n + 1):
    D[j] = min(j - i, abs(x - i) + abs(y - j) + 1)
  for d in D:
    ans[d] += 1
    
for a in ans[1:]:
  print(a)

Measured memory_bytes: 3444
import collections
k,n = map(int, raw_input().split(' '))
cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
	i,res = raw_input().split(' ')
	i = int(i)
	if res == 'AC':
		cc['AC'][i] += 1
	elif res == 'WA' and cc['AC'][i] == 0: 
		cc['WA'][i] += 1

print len(cc['AC']), sum([cc['WA'][p] for p in cc['AC']] or [0]) 

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

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

    string s;
    cin >> s;

    LL L = s.size(), b = -1, e = -1;
    for(LL i = 0; i < L; i++){
        if(s[i] == 'A'){
            b = i;
            break;
        }
    }

    for(LL i = L - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            e = i;
            break;
        }
    }

    cout << e - b + 1 << '\n';
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define de(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

///----------------------------------------------
pii p[10];
int main() {
	
	///read
	rep(i, 1, 5) scanf("%d", &p[i].fi);
	p[1].fi *= 8; p[1].se = 2;
	p[2].fi *= 4; p[2].se = 4;
	p[3].fi *= 2; p[3].se = 8;
	p[4].fi *= 1; p[4].se = 16;
	
	///work
	sort(p + 1, p + 1 + 4);
	rep(i, 1, 5) {
		if (p[i].se / 2 == 1) p[i].fi /= 8;
		if (p[i].se / 2 == 2) p[i].fi /= 4;
		if (p[i].se / 2 == 4) p[i].fi /= 2;
		if (p[i].se / 2 == 8) p[i].fi /= 1;
	}
	
	///
	ll n; cin >> n; n *= 8;
	ll ans = 0;
	rep(i, 1, 5) {
		ans += 1ll * (n / p[i].se) * p[i].fi;
		n %= p[i].se;
	}
	cout << ans;



}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,V=MI()
    B,W=MI()
    T=I()
    if abs(A-B)<=T*(V-W):
        print("YES")
    else:
        print("NO")

main()


Measured memory_bytes: 61932
#include <bits/stdc++.h>
    
#define INF 0x3F3F3F3F
#define DINF 1e+12
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define pb push_back
#define pi 3.1415926535897932384626433832795028841971
#define debug(x) if(1) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " " << y << "\n";
#define all(S) (S).begin(), (S).end()
#define MAXV 1005
#define F first
#define S second
#define EPS 1e-9
#define mp make_pair
    
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
    
using namespace std;
    
typedef long long ll;
typedef pair < int, int >  ii;

int main(){

	ll n, a, b;
	
	while(cin >> n >> a >> b){
		cout << (n-a+1) * (n-b+1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
int main(){
	int n=read(),ans=0;
	REP(i,1,n){
		int x=read(),y=read();
		while(x%y!=0){
			int r=(x/y)*y;
			x-=(x/y+1)*max((x-r)/(x/y+1),1);
			if(x<y) break;
		}
		ans^=x/y;
	}
	if(ans) printf("Takahashi\n");
	else printf("Aoki\n");
	return 0;
}


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

int main() {
  
  int m, f, r;
  cin >> m >> f >> r;
  while ( m!=-1 || f!=-1 || r!= -1 ) {
    char gd;
    if ( m == -1 || f == -1 ) {
      gd = 'F';
    }else if (m+f >= 80) {
      gd = 'A';
    }else if (m+f >= 65) {
	  gd = 'B';
    }else if (m+f >= 50) {
	  gd = 'C';
    }else if (m+f >= 30) {
	  gd = 'D';
      if ( r>=50 ) {
        gd = 'C';
      }
    }else gd = 'F';
    
    cout << gd << endl;
    cin >> m >> f >> r;
  }
  
  return 0;
}



Measured memory_bytes: 3100
from collections import deque

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

A = sorted(A, reverse=True)

ring = deque()
ring.append(A[0])
ans = 0
for i in range(1, N):
    ans += ring.popleft()
    ring.append(A[i])
    ring.append(A[i])
    
print(ans)


Measured memory_bytes: 32392
#include<cmath>
#include<cstdio>

#define	f(x)	((((a*x)+b)*x+c)*x+d)

using namespace std;

const double inf=1e9,eps=1e-9;
int a,b,c,d;

double bisection_method(double l,double r){
	double m,fm,fl,fr;
	while(1){
		m=(l+r)/2;
		fl=f(l);	fr=f(r);	fm=f(m);
		if(abs(fm)<eps)	return m;
		if((fm<-eps && fl<-eps)||(eps<fm && eps<fl))	l=m;
		else	r=m;
	}
}

int main(){
	int n;	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(a<0)	a=-a,b=-b,c=-c,d=-d;

		int aa=3*a,bb=2*b,cc=c;
		int D=bb*bb-4*aa*cc;
		int posi=0,nega=0;
		if(D<0){
			double x=bisection_method(-inf,inf);
			if(eps<x)	posi++;
			if(x<-eps)	nega++;
		}
		else if(D==0){
			double x=-bb/(2.*aa);
			if(abs(f(x))<eps){
				if(eps<x)	posi+=3;
				if(x<-eps)	nega+=3;
			}
			else{
				double x=bisection_method(-inf,inf);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
			}
		}
		else{
			double x1=(-bb-sqrt(D))/(2.*aa),x2=(-bb+sqrt(D))/(2.*aa);
			if(f(x1)<-eps){
				double x=bisection_method(-inf,inf);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
			}
			else if(abs(f(x1))<eps){
				if(eps<x1)	posi+=2;
				if(x1<-eps)	nega+=2;
				double x=bisection_method(x2,inf);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
			}
			else if(eps<f(x1) && f(x2)<-eps){
				double x=bisection_method(-inf,x1);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
				x=bisection_method(x1,x2);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
				x=bisection_method(x2,inf);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
			}
			else if(abs(f(x2))<eps){
				if(eps<x2)	posi+=2;
				if(x2<-eps)	nega+=2;
				double x=bisection_method(-inf,x1);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
			}
			else{
				double x=bisection_method(-inf,inf);
				if(eps<x)	posi++;
				if(x<-eps)	nega++;
			}
		}

		printf("%d %d\n",posi,nega);
	}

	return 0;
}

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

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  for(int i=0; i<n; ++i) cin >> a[i];
  
  ll count = 1;
  for(int i=0; i<n; ++i){
    if(a[i] == count) ++count;    
  }
  
  ll res;
  if(count == 1) res = -1;
  else res = n-(count-1);
  cout << res << endl;
  return 0;  
}

Measured memory_bytes: 1792
import math
n=int(input())
ans=1
dic={}
for i in range(2,n+1):
    tmp=i
    for j in range(2,i+1):
        while tmp%j==0:
            tmp//=j
            if j in dic:
                dic[j]+=1
            else:
                dic[j]=1
for v in dic.values():
    ans=(ans*(v+1))%(10**9+7)
print(ans)

Measured memory_bytes: 9128