akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll dfs(ll n){
  if(n==1){
    return 1;
  }else{
    ll ret;
    ret = dfs(n/2);
    return 2*ret+1;
  }
}

int main(){
  ll n; cin >> n;
  cout << dfs(n) << endl;
}

Measured memory_bytes: 256
#problem-D needs priority queue
import heapq
n,m = map(int, input().split())
price = list(map(int, input().split()))
for i in range(n):
    price[i] = -price[i]
heapq.heapify(price)

for i in range(m):
    x = heapq.heappop(price)
    if x%2 == 0:
        heapq.heappush(price,x//2)
    else:
        heapq.heappush(price,x//2+1)
print(-sum(price))

Measured memory_bytes: 14180
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    ll a, b;
    cin >> a >> b;
    cout << a*b/__gcd(a, b);
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

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

int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int mdtod(int m, int d){
    int accum = 0;
    for(int i = 0; i < m-1; i++)    accum += month[i];
    accum += d;
    return accum;
}

int main(){
    int n;
    while(scanf("%d\n", &n), n){
        map<int, vector<int>> record;

        int M, D, h, m, p;
        char e;

        for(int i = 0; i < n; i++){
            scanf("%d/%d %d:%d %c %d\n", &M, &D, &h, &m, &e, &p);
            record[p].push_back(mdtod(M, D)*1440 + 60*h + m);
        }

        int ans = 0;
        for(auto x : record){
            if(x.first == 0)    continue;
            int tmp = 0;
            for(int i = 0; i < x.second.size(); i+=2){
                for(int j = 0; j < record[0].size(); j+=2){
                    tmp += max(0, min(x.second[i+1],record[0][j+1])-max(x.second[i],record[0][j]));
                }
            }
            ans = max(ans, tmp);
        }

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


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

int main() {
    int N, M; cin >> N >> M;
    int mi = 1;
    int ma = N;
    for (int i = 0; i < M; i++) {
        int l, r; cin >> l >> r;
        if (l > mi) mi = l;
        if (r < ma) ma = r;
    }
    if (ma - mi < 0) {
        cout << 0 << endl;
    } else {
        cout << ma - mi + 1 << endl;
    }
}

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

using namespace std;

int main () {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    int limit = ceil(sum /(double)(4 * m));
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (arr[i] >= limit)
            cnt++;
    }
    if (cnt >= m) 
        puts ("Yes");
    else puts ("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ;
const int N = 2e5 + 100;
const int mod = 1e9 + 7;
int binpow(int a, int b) {
    a %= mod;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int h , w;
std::vector< std::vector<char> > v;

int32_t main(){
 L_T_S_K;
 cin >> h >> w;
 for(int i = 0 ; i < h ; i++){
    std::vector<char> vv;
    for(int j = 0 ; j < w ; j++){
        char c;
        cin >> c;
        vv.push_back(c);
    }
    v.push_back(vv);
 }
 int dp[h + 1][w + 1];
 memset(dp , 0 , sizeof dp);
 for(int i = 0 ; i < w ; i++){
    if(v[0][i]!='#')dp[0][i] = 1;
    else break;
 }
 for(int i = 0 ; i < h ; i++){
    if(v[i][0]!='#')dp[i][0] = 1;
    else break;
 }
 for(int i = 0 ; i < h ; i++){
    for(int j = 0 ; j < w ; j++){
        if(!i || !j) continue;
        if(v[i][j] == '#')dp[i][j] = 0;
        else dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] %  mod)%mod;
    }
 }
 cout << dp[h - 1][w - 1] << "\n";

return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll r;
    cin >> r;
    ll d;
    cin >> d;
    ll x;
    cin >> x;
    for(ll i=0;i<10;i++){
        x=r*x-d;
        cout<<x<<endl;
    ;}
return 0;
}


Measured memory_bytes: 256
#define LOCAL

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353LL;
const double PI = acos(-1);

int main() {
	IOS;
	int n; cin >> n;
	llong ans = 0;
	for (int i = 1; i < n ; i++) {
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				ans++;
				if (j != i / j) ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 15
#define MAXM 15
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = INF;
int N,M,X;
vi C, A[MAXN];
bool flag;

bool checkAlgo(vi v){
    bool res = true;
    rep(i, M){
        if(v[i] < X){
            res = false;
            break;
        }
    }
    return res;
}

void solve(){
    
    for(int i = 0; i < (1 << N); i++) {
        vi U;
        U.resize(M, 0);
        ll tmp = 0;

		for(int j = 0; j < N; j++) {
			if (i & (1 << j)){
                tmp += C[j];
                rep(k, M){
                    U[k] += A[j][k];
                }
            }
		}

        if(checkAlgo(U)){
            flag = true;
            // cout << tmp << endl;
            ans = min(ans, tmp);
        }

	}
    

    if(flag) cout << ans << endl;
    else cout << -1 << endl;
}

int main(){
    cin >> N >> M >> X;
    C.resize(N);

    rep(i, N){
        A[i].resize(M);
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    solve();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a <= b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a >= b) { a = b; return true; } return false; }
const int INF = 1e9;

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

    int now = -INF, ans = 0;
    for (int i = 0; i < N; i++) {
        if (chmax(now, A[i])) {
            ans++;
        }
    }

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

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

sum = sum(W)

s = 0
for i in range(N):
    s += W[i]
    if s >= sum/2:
        print(min(abs(s-(sum-s)),abs(s-W[i]-(sum-s+W[i]))))
        break

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define all(arr) arr.begin(), arr.end()
#define va vector<long long int> a 
#define vb vector<long long int> b
#define debug() for(ll l=0;l<50;l++){}
const ll M = 1e9+7;
const ll inf = 1e18+5;
const ll val = 10000020;
const ll INF=INT_MAX;
using namespace std;
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll cs(vector<ll> &a,ll x){
	return upper_bound(all(a),x)-a.begin();
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
ll arr[500000],st[500000];
void buildtree(int si,int ss,int se){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	st[si]=min(st[2*si],st[2*si+1]);
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si];
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
void update(int si,int ss,int se,int qi){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi);
	else update(2*si+1,mid+1,se,qi);
	st[si]=min(st[2*si],st[2*si+1]);
}
ll mm(ll a,ll b,ll mod){ 
    ll res = 0;
    a %= mod; 
    while(b){
        if (b & 1) res = (res + a) % mod; 
        a = (2 * a) % mod; 
        b >>= 1; // b = b / 2 
    } 
    return res; 
} 

void DFS_ITR(vector<vector<ll>>& adj,ll src,vector<ll>& a,vector<ll>& f,vector<ll>& d,ll day,vector<bool>& visited){
	vector<ll>s;
    s.push_back(src);
    vector<ll>s2;
    visited[src]=true;
    while(s.size()>0){
		ll u=s[s.size()-1];
        s.pop_back();
        for(auto c:adj[u]){
            if(!visited[c]){
                ll eat=min(a[src-1],f[c-1]);
                f[c-1]-=eat;
                if(f[c-1]==0 && d[c]==-1) d[c]=day;
                s.push_back(c);
                s2.push_back(c);
                visited[c]=true;
			}
		}
	}
    for(auto i:s2) visited[i]=false;
}
ll nCr(ll n, ll r){
    return (n*(n-1)*(n-2))/6;
}

void solve(){
	string n;
	cin>>n;
	ll sum=0;
	for(auto i:n) sum+=i-'0';
	if(sum%9) cout<<"No\n";
	else cout<<"Yes\n";
}
int main(){
	fast;
	ll t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3760
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) => {
        (0..$n).map(|_| read!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {{
        rl()
            .split_whitespace()
            .map(|word| word.parse().unwrap())
            .collect::<Vec<$t>>()
    }};
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace().into_iter();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn recurse<X, Y, F: FnMut(&mut FnMut(X) -> Y, X) -> Y>(x: X, mut f: F) -> Y {
    fn call<X, Y>(x: X, f: &mut FnMut(&mut FnMut(X) -> Y, X) -> Y) -> Y {
        let fp = f as *mut FnMut(&mut FnMut(X) -> Y, X) -> Y;
        let f1 = unsafe { &mut *fp };
        let f2 = unsafe { &mut *fp };
        f1(&mut |x: X| call(x, f2), x)
    }
    call(x, &mut f)
}

pub fn main() {
    let (N, M) = read!(usize, usize);
    let mut g = vec![vec![]; N + M];
    for v in 0..N {
        let w = read!([usize]);
        for &w in &w[1..] {
            g[v].push(N + w - 1);
            g[N + w - 1].push(v);
        }
    }

    let mut done = vec![false; N + M];
    recurse(0, |go, v| {
        if done[v] {
            return;
        }
        done[v] = true;
        for &w in g[v].iter() {
            go(w);
        }
    });

    println!("{}", if (0..N).all(|v| done[v]) { "YES" } else { "NO" });
    return;
}


Measured memory_bytes: 14588
#include <stdio.h>

int queue[1000020][3];
char instr[1000][1001];
int checked[1000][1000];
int st = 0;
int en = 0;

void append(int i, int j, int k) {
  queue[en][0] = i;
  queue[en][1] = j;
  queue[en][2] = k;
  checked[i][j] = 1;
  en++;
  return;
}

int main() {
  int H;
  int W;
  int res = 0;
  scanf("%d %d\n",&H,&W);
  for (int i = 0; i < H; i++) {
    gets(instr[i]);
  }
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) checked[i][j] = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (instr[i][j] == '#') {
        checked[i][j] = 1;
        queue[en][0] = i;
        queue[en][1] = j;
        queue[en][2] = 0;
        en++;
      }
    }
  }
  // printf("sdsafa\n");

  while (st < en) {
    int i = queue[st][0];
    int j = queue[st][1];
    int k = queue[st][2];
    st++;
    // printf("%d %d %d\n", st, k, res);
    
    if (i+1<H && !checked[i+1][j]) {
      append(i+1, j, k+1);
      if (res < k+1) {
        res = k+1;
      }
    }
    if (i-1>=0  && !checked[i-1][j]) {
      append(i-1, j, k+1);
      if (res < k+1) {
        res = k+1;
      }
    }
    if (j+1<W  && !checked[i][j+1]) {
      append(i, j+1, k+1);
      if (res < k+1) {
        res = k+1;
      }
    }
    if (j-1>=0 && !checked[i][j-1]) {
      append(i, j-1, k+1);
      if (res < k+1) {
        res = k+1;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 16768
#!/usr/bin/env python

n = int(input())
a = list(map(int, input().split()))
d = [0 for _ in range(n-1)]
for i in range(n-1):
    d[i] = a[i+1]-a[i]

# print(d)
ans = 1 
state = 'flat'
for i in range(n-1):
    if i == 0:
        if d[i] > 0:
            state = 'up'    
        elif d[i] < 0:
            state = 'down'

    else:
        if d[i] > 0:
            if state == 'flat':
                state = 'up'
            elif state == 'down':
                state = 'flat'
                ans += 1

        elif d[i] < 0:
            if state == 'flat':
                state = 'down'
            elif state == 'up':
                state = 'flat'
                ans += 1

print(ans)


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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int a_ = (a + 9) / 10 * 10;
  int b_ = (b + 9) / 10 * 10;
  int c_ = (c + 9) / 10 * 10;
  int d_ = (d + 9) / 10 * 10;
  int e_ = (e + 9) / 10 * 10;
  cout << min(a + b_ + c_ + d_ + e_,
              min(a_ + b + c_ + d_ + e_,
                  min(a_ + b_ + c + d_ + e_,
                      min(a_ + b_ + c_ + d + e_, a_ + b_ + c_ + d_ + e))))
       << endl;
}


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

using namespace std;
typedef long long int lli;

const int LOG = 60;
const int MOD = 1000000007;

int n;

int freq[LOG][2];

int curBit(lli v, int k)
{
    if( v & (1LL << k) ) return 1;
    return 0;
}

int main()
{
    scanf("%d",&n);
    
    lli ans = 0;
    
    for(int i = 1 ; i <= n ; i++)
    {
        lli x;
        scanf("%lld",&x);
        
        for(int j = 0 ; j < 60 ; j++)
        {
            lli curPot = (1LL << j);
            curPot %= MOD;
            
            ans += freq[ j ][ 1 - curBit( x , j ) ]*curPot;
            ans %= MOD;
        }
        
        for(int j = 0 ; j < 60 ; j++)
            freq[ j ][ curBit( x , j ) ]++;
    }
    
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [0] * n
ndp = [0] * n
for tj in t:
    for i in range(n):
        ndp[i] = 0
    acc = 0
    for i, si in enumerate(s):
        if si == tj:
            ndp[i] = (dp[i] + acc + 1) % MOD
        else:
            ndp[i] = dp[i]
        acc = (acc + dp[i]) % MOD
    dp, ndp = ndp, dp
print((sum(dp) + 1) % MOD)


Measured memory_bytes: 44316
def f(n):
    if n == 1:
        return []
    if n % 2 == 0:
        r = f(n//2)
        k = len(r)
        return r + [k+1]
    if n % 2 == 1:
        r = f(n - 1)
        k = len(r)
        return [k+1] + r

n = int(input())
r = f(n+1)
k = len(r)
res = r + list(range(1, k+1))
print(len(res))
for x in res:
    print(x, end=' ')
print()



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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> B(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	long long ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		if ((A[i] + ans) % B[i] != 0) ans += B[i] - (A[i] + ans) % B[i];
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 2040
import collections
N = int(input())
a = list(map(int,input().split()))
B = collections.Counter(a)
k = list(B.keys())
v = list(B.values())

if len(B) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(B) == 2 and 0 in k and (v[0] == 2*v[1] or v[1] == 2*v[0]):
    print("Yes")
elif len(B) == 1 and 0 in k:
    print("Yes")
else: print("No")

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

int main() {
    while(true){
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0) break;

        int count = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i+1; j <= n; j++){
                for(int k = j+1; k <= n; k++){
                    if(i + j + k == x){
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
}



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

using namespace std;

int main(){
  vector<bool> v(2020);
  int n;cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
    v[x[i]] = true;
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
    int a;cin>>a;
    if(!v[x[a-1]+1] && x[a-1]!=2019){
      v[x[a-1]+1] = true;
      v[x[a-1]] = false;
      x[a-1]++;
    }
  }
  for(int i=0;i<x.size();i++){
    cout<<x[i]<<endl;
  }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define MAX_N 500000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, d[MAX_N+5], a[MAX_N+5], b[MAX_N+5];
int main() {
	read(n), read(a[0]), b[n] = 1;
	for (int i = 1; i <= n; i++) read(d[i]);
	for (int i = 1; i <= n; i++)
		a[i] = min(a[i-1], abs(a[i-1]-d[i]));
	for (int i = n-1; i; i--)
		if (b[i+1] <= d[i+1]/2) b[i] = b[i+1];
		else b[i] = b[i+1]+d[i+1];
	int m; read(m);
	while (m--) {
		int p; read(p);
		if (b[p] <= a[p-1]) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    double sum=0;
    sum+=((double)(v.at(0)))/pow(2.0,(double)(n-1));
    for(int i=1;i<n;i++){
        sum+=((double)(v.at(i)))/pow(2.0,(double)(n-i));
    }
    cout<<sum<<endl;
}

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

using namespace std;

main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << n * n * n << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    int a,b;
    cin >> a >> b;
    int ans = b*10;
    while(1){
        if(floor(ans * 0.08) == a){
            cout << ans << endl;
            return 0;
        }
        if(floor(++ans * 0.1) != b){
            cout << -1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];

bool cmp(string a,string b) {
        return a.compare(b)<0;
}

int main() {
    int n,i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int m=1,cnt=1;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        m=max(cnt,m);
    }
    cnt=1;
    if(m==1)
        cout<<s[0]<<endl;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        if(cnt==m)
            cout<<s[i]<<endl;
    }
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	int l = a + b + 1;
	bool flag = true;
	rep(i, l) {
		if (i == a && s[i] != '-')flag = false;
		else if (i != a && s[i] == '-')flag = false;
	}
	if (flag)puts("Yes");
	else puts("No");
	return 0;
}


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

int main() {
	char n[3];
	cin >> n;
	for (int i = 0; i < 3; i++) {
		if (n[i] == '1') {
			n[i] = '9';
		}
		else if (n[i] == '9') {
			n[i] = '1';
		}
	}
	cout << n << endl;
}

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

k = []
half_k = []
for i in range(1,N+1):
    if(i%K == 0):
        k.append(i)
    elif(i%(K/2) == 0):
        half_k.append(i)

if(K%2 == 0):
    print((len(k) ** 3) + (len(half_k) ** 3))
else:
    print(len(k) ** 3)


Measured memory_bytes: 11064
//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long 

const int N=1e5+200;

vector<int> a[N],b[N];
int h[N];

void dfs(int v){
	for(int i=0;i<a[v].size();i++){
		dfs(a[v][i]);
		b[v].PB(h[a[v][i]]);
	}
	if(b[v].empty()){
		h[v]=0;
		return ;
	}
	sort(b[v].begin(),b[v].end(),greater<int> () );
	int tmp=1;
	for(int i=0;i<b[v].size();i++){
		h[v]=max(h[v],b[v][i]+tmp);
		tmp++;
	}
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
 	int n; 
	cin>>n; 
	for(int i=0,u;i<n-1;i++){
		cin>>u;
		u--;
		a[u].PB(i+1);
	}
	dfs(0);
	cout<<h[0]<<"\n";
	return 0;
}

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

int getpoint(char hand, int P_R, int P_S, int P_P){
  if (hand == 'r'){
    return P_P;
  }
  else if (hand == 's'){
    return P_R;
  }
  else if (hand == 'p'){
    return P_S;
  }
}

int main(){
  int N, K, P_R, P_S, P_P, ans = 0;
  string T;
  char prehand;
  
  cin >> N >> K >> P_R >> P_S >> P_P;
  cin >> T;
  
  for (int j = 0; j < K; j++){
    prehand = 'z';
  	for (int i = j; i < N; i += K){
      if (i == j){
        ans += getpoint(T.at(i), P_R, P_S, P_P);
        prehand = T.at(i);
      }
      else{
        if (T.at(i) != T.at(i - K) || T.at(i) != prehand){
          ans += getpoint(T.at(i), P_R, P_S, P_P);
          prehand = T.at(i);
        }
        else{
          prehand = 'z';
        }
      }
    }
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 3740
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int ab[] = new int[3];
	    ab[0] = scan.nextInt();
	    ab[1] = scan.nextInt();
	    ab[2] = scan.nextInt();
	    Arrays.sort(ab);
	    if(ab[0] == 5 && ab[1] == 5 && ab[2] == 7) {
	    	System.out.println("YES");
	    } else {
	    	System.out.println("NO");
	    }
	}
}


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

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

using namespace std;

int gcd(int a, int b) {
    while (b) {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main() {
    int K;
    cin >> K;
    int result = 0;
    FOR(a, 1, K + 1) FOR(b, 1, K + 1) FOR(c, 1, K + 1) {
        result += gcd(gcd(a, b), c);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3644
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())

c = [[-1]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            c[i][j] += 1
            if i != 0: c[i][j] += (S[i-1][j] == '#')
            if i != H-1: c[i][j] += (S[i+1][j] == '#')
            if j != 0: c[i][j] += (S[i][j-1] == '#')
            if j != W-1: c[i][j] += (S[i][j+1] == '#')

if any(list(map(lambda s: 0 in s, c))):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
n = int(input())
c = []
not_c = []
chosen = set()
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	not_c.append([max(a, b), i])
	c.append([min(a, b), i])
	ans += min(a, b)
	if a < b:
		chosen.add("a")
	elif a > b:
		chosen.add("b")

if len(chosen) < 2:
	print(ans)
else:
	c = sorted(c, reverse=True)
	not_c = sorted(not_c)
	#print(c, not_c)
	#used_c = [False] * n
	#used_n = [False] * n

	if c[0][1] != not_c[0][1]:
		ans = ans - c[0][0] + not_c[0][0]
		c_cur = 1
		not_cur = 1
	else:
		ans = min(ans - c[1][0] + not_c[0][0], ans - c[0][0] + not_c[1][0])
		if ans - c[1][0] + not_c[0][0] <= ans - c[0][0] + not_c[1][0]:
			c_cur = 2
			not_cur = 1
		else:
			c_cur = 1
			not_cur = 2
	if c_cur < n and not_cur < n:
		while c[c_cur][0] > not_c[not_cur][0]:
			if c[c_cur][1] != not_c[not_cur][1]:
				ans = ans - c[c_cur][0] + not_c[not_cur][0]
				c_cur += 1
				not_cur += 1
			else:
				ans = min(ans - c[c_cur+1][0] + not_c[not_cur][0], ans - c[c_cur][0] + not_c[not_cur+1][0])
				if ans - c[c_cur+1][0] + not_c[not_cur][0] <= ans - c[c_cur][0] + not_c[not_cur+1][0]:
					c_cur += 2
					not_cur += 1
				else:
					c_cur += 1
					not_cur += 2
			if c_cur >= n or not_cur >= n:
				break
	print(ans)


Measured memory_bytes: 34300
#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;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll inf=mod;
    ll n,num;
    set<ll> s;
    queue<ll> q;
    cin>>n;
    for(ll i=1;i<10;i++){
    	s.insert(i);
    	q.push(i);
    }
    while(!q.empty()){
    	ll m=q.front();
    	if(m%10!=0LL){
    		num=m*10+m%10-1;
    		s.insert(num);
    		if(num<inf)q.push(num);
    	}
    	num=m*10+m%10;
    	s.insert(num);
    	if(num<inf)q.push(num);
    	if(m%10!=9LL){
    		num=m*10+m%10+1;
    		s.insert(num);
    		if(num<inf)q.push(num);
    	}
    	q.pop();
    }
    auto itr=s.begin();
    while(--n)itr++;
    cout<<*itr<<endl;

    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    int flag[n];
    for(int i = 0; i < n; i++){
        flag[i] = 0;
    }

    for(int i = 0; i < k; i++){
        int a;
        cin >> a;
        for(int j = 0; j < a; j++){
            int b;
            cin >> b;
            b--;
            flag[b] = 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(flag[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    string s;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    while(cin>>s){
        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="TLE")
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N;
	cin >> N;
	vector<pair<lint, lint>>A(N);
	rep(i, N) {
		cin >> A[i].first >> A[i].second;
	}
	sort(A);
	rep(i, N) {
		cout << A[i].first << ' ' << A[i].second << endl;
	}
}




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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define      TEST    ll t ; cin >> t ; while( t -- )


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

#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

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

const ll big = 10e15 + 11 ;


int  main (  ) {

    FASTIO ;

    string s ;
    cin >> s ;

    if( s == "ABC" ) cout << "ARC" ;
    else cout << "ABC" ;


    return  0 ;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;

typedef long long ll;

const int N = 25;
int a[N + 5], b[N + 5], c[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++) cin>>a[i];
	for(int i = 1;i <= n;i++) cin>>b[i];
	for(int i = 1;i < n;i++) cin>>c[i];
	int tot = 0;
	for(int i = 1;i <= n;i++) {
		tot += b[a[i]];
		if(a[i] - 1 == a[i - 1]) tot += c[a[i - 1]];
	}
	cout<<tot<<endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.setf(ios::showpoint), cout.precision(10);
	int ntc = 1;
//	cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) {
		hora(tc);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> t(N), a(N);
    REP(i, N) { cin >> t[i] >> a[i]; }
    ll A = 1;
    ll T = 1;
    REP(i, N) {
        ll x = (T + t[i] - 1) / t[i];
        ll y = (A + a[i] - 1) / a[i];
        ll n = max(x, y);
        T = n * t[i];
        A = n * a[i];
    }
    cout << T + A << endl;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll n,m,k,i,j;
	cin>>n>>m>>k;
	ll a[n+1],b[m+1];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	i=0;
	j=0;
	ll cnt=0;
	// while(i<n&&j<m){
	// 	//cout<<cnt<<" "<<k<<endl;
	// 	if(a[i]<b[j]&&k>=a[i]){
	// 		k-=a[i];
	// 		cnt++;
	// 		i++;
	// 	}
	// 	else if(a[i]>=b[j]&&k>=b[j]){
	// 		k-=b[j];
	// 		cnt++;
	// 		j++;
	// 	}
	// 	else{
	// 		break;
	// 	}
	// }
	while(i<n){
		//cout<<cnt<<" "<<k<<endl;
		if(k>=a[i]){
			k-=a[i];
			i++;
			cnt++;
		}
		else break;
	}
	while(j<m){
		//cout<<cnt<<" "<<k<<" "<<b[j]<<endl;
		if(k>=b[j]){
			k-=b[j];
			j++;
			cnt++;
		}
		else break;
	}
	if(i==n&&j==m){
		cout<<cnt<<endl;
		return 0;
	}
	ll maxcnt = cnt;
	i--;
	while(j<m){
		k-=b[j];
		cnt++;
		while(i>=0&&k<0){
			k+=a[i];
			i--;
			cnt--;
		}
		if(k<0){
			break;
		}
		maxcnt = max(cnt,maxcnt);
		j++;
	}
	cout<<maxcnt<<endl;
	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2e5 + 5;

int n, k;
int arr[N];
int pref[N];

bool isSorted(int i, int j)
{
  if(i >= j)
    return true;
  int s = pref[j];
  if(i) s -= pref[i];
  return s == 0;
}

int main()
{
  scanf("%d%d", &n, &k);
  for(int i = 0 ; i < n ; i++)
    scanf("%d", arr + i);
  for(int i = 1 ; i < n ; i++)
    pref[i] = (arr[i - 1] > arr[i]) + pref[i - 1];
  vector<int> pos = {0};
  set<int> cur;
  for(int i = 0 ; i < k ; i++)
    cur.insert(arr[i]);
  for(int i = 1 ; i <= n - k ; i++){
    bool can = (arr[i - 1] == *(cur.begin())) && (arr[i + k - 1] > *(cur.rbegin()));
    if(!can)
      pos.pb(i);
    cur.erase(arr[i - 1]);
    cur.insert(arr[i + k - 1]);
  }
  int sorted = 0;
  for(int i = 0 ; i < sz(pos) ; i++)
    if(isSorted(pos[i], pos[i] + k - 1))
      sorted++;
  // cout << sorted << endl;
  cout << sz(pos) - max(0, sorted - 1) << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
 
using namespace std;
 
int main() {
    int n;
    long long a;
    long long maxValue = -1000000;
    long long minValue = 1000000;
    long long sum = 0;
 
    cin>>n;
 
    for(int i=0;i<n;i++){
        cin>>a;
        if(a < minValue) minValue = a;
        if(a > maxValue) maxValue = a;
        sum += a;
    }
 
    cout<< minValue <<" "<< maxValue <<" "<< sum << endl;
 
    return 0;}

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

 int A[500000], S = 0;

int merge(int l, int m, int r){
	int n1 = m - l, n2 = r - m, i, j;
	int L[n1 + 1], R[n2 + 1];
	for(i = 0;i < n1;i++)L[i] = A[i + l];
	for(i = 0;i < n2;i++)R[i] = A[i + m];
	i = 0;j = 0;
	//printf("%d %d : \n", L[0], R[0]);
	for(int k = 0;k < r - l;k++){
		if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
		else A[k + l] = R[j++];
		S++;
	}
	//for(int i = 0;i < 4;i++)printf(" %d", A[i]);
	//puts("");
}

int mergeSort(int l, int r){
	if(l + 1 < r){
		int m = (l + r) / 2;
		mergeSort(l, m);
		mergeSort(m, r);
		merge(l, m, r);
	}
}

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)scanf("%d", &A[i]);
	mergeSort(0, n);
	for(int i = 0;i < n;i++){
		if(i)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", S);
	
	return 0;
}

Measured memory_bytes: 7080
#include<stdio.h>
int main(){
 int c=1,d=0;
char a[3];
scanf ("%s",a);
  for (int i=0;i<3;i++){
  if (a[i]=='a'){
    d=d+1;
  }
  else if(a[i]=='b'){
  c=c*2;
  d=d+2;
  }
  else if(a[i]=='c'){
    c=c*3;
  d=d+3;
  }
  }
  if(c==6 & d==6){
    printf("Yes");
  }
  else{
  printf ("No");
  }
   return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int X,Y,c;
int map[17][17];
void search(int ,int);
int main(){
	int x,y,i,j,n;
	for(;scanf("%d %d",&x,&y)&&(x||y);){
		c=0;
		X=x;Y=y;
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++)map[i][j]=1;
		}
		scanf("%d",&n);
		for(;n>0;n--){
			scanf("%d %d",&x,&y);
			map[y][x]=0;
		}
		search(1,1);
		printf("%d\n",c);
	}
	return 0;
}
void search(int x,int y){
	if(x<1||y<1||x>X||y>Y||map[y][x]==0)return;
	if(x==X && y==Y){
		c++;
		return;
	}
	search(x+1,y);
	search(x,y+1);
}

Measured memory_bytes: 408
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
map<int, int> mp;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		int x;
		scanf("%d", &x);
		++mp[x];
		if(mp[x] > 1) 
		{
			mp[x] -= 2;
			v.push_back(x);
		}
	}
	sort(v.begin(), v.end());
	if(v.size() < 2) 
	{
		puts("0");
		return 0;
	}
	int x = v.size() - 1;
	printf("%lld\n", (long long)v[x] * (long long)v[x - 1]);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int N, K;
vector<int> A;

int main() {
    while (cin >> N >> K) {
      A.resize(N);
      for (int i = 0; i < N; ++i) cin >> A[i];
      int res = 0;
      int right = 0;
      while (true) {
        if (res == 0) right += K;
        else right += K-1;
        ++res;

        if (right >= N) break;
      }
      cout << res << endl;
    }
}




Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int k;
    ll ans = 0;

    cin >> k;

    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int N, M;
int c[20];
int num[50001];

void calc(int k){
    Rep(i, 0, M){
        if(k - c[i] < 0) continue;
        num[k] = Min2(num[k], num[k - c[i]] + 1);
    }
}

int main(){
    cin >> N >> M;
    Rep(i, 0, M) cin >> c[i];
    Rep(i, 0, N + 1) num[i] = i;
    Rep(i, 0, N + 1) calc(i);
    Print(num[N]);
    return 0;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    ll x, y; 
    cin >> x >> y;
    v_ll a;

    a.push_back(x);
    
    while(1) {
        ll b = a.back(); 
        if(b*2 > y) { break; }
        a.push_back(b*2);
    }
    cout << a.size() << endl;
    return 0;
}

/*atcoder*/



Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    int h,a;cin>>h>>a;
    int count=0;
    while(h>0)
    {
        h-=a;
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    int N,A,B;cin >> N >> A >> B;
    cout<<min(N*A,B)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    mp[a]++;
  }

  for(auto p : mp){
    if(p.second >= 2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 12800
import sys

alist = list('abcdefghijklmnopqrstuvwxyz')
r = {}
for al in alist:
    r[al] = 0

line = sys.stdin.read().lower()

for i in range(len(line)):
    if line[i] in r.keys():
        r[line[i]] += 1

for k,v in r.items():
    print("{} : {}".format(k, v))



Measured memory_bytes: 5560