akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
int judge(int a);
int main(){

  int i,count=0,a,j,gg=0,n[10000];
  scanf("%d",&a);
  
  for(i=0;i<a;i++){
    scanf("%d",&n[i]);
    count+=judge(n[i]);
  }
    
  
  
  
  printf("%d\n",count);
  
  return 0;
}   

int
judge(int n){
  int i;
  if(n==2){
    return 1;
  }
  if(n<2 || n%2==0){
    return 0;
  }
  i=3;
  while(i<=sqrt(n)){
    if(n%i==0){
      return 0;
    }
    
    i=i+2;
  }
  return 1;
}

Measured memory_bytes: 628
#include <cstdio>
#include <algorithm>
long long I, O, J, L;
int main()
{
	scanf("%lld%lld%*d%lld%lld%*d%*d", &I, &O, &J, &L);
	printf("%lld\n", std::max((I >> 1 << 1) + O + (J >> 1 << 1) + (L >> 1 << 1), I && J && L ? (I - 1 >> 1 << 1) + O + (J - 1 >> 1 << 1) + (L - 1 >> 1 << 1) + 3 : 0));
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        int cap = A - B;
        
        if (cap > 0) {
            if ((C - cap >= 0)) {
                System.out.println(C - cap);
            } else {
                System.out.println(0);
            }
        } else {
            System.out.println(C);
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  int a,b;
  cin>>a>>b;
  int  i=1;
  int ans=-1;
  while(true)
  {
    int r1=floor(i*0.08);
    int r2=floor(i*0.1);
    if(r1==a && r2==b)
    {
      ans=i;
      break;
    }
    else if(r1>a || r2>b)
    {
      break;
    }
    i++;
  }

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

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    int l[310],r[310],x[310];
    vector<P> v[310];
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i]>>x[i];
        v[r[i]].push_back(P(l[i],x[i]));
    }
    ll dp[310][310][310]={};
    ll ans=0;
    dp[0][0][0]=1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                if((i&&j&&k)&&(i==j||j==k||k==i)){
                    continue;
                }
                int ma=max(i,max(j,k));
                bool f=true;
                for(auto e:v[ma]){
                    int c=0;
                    if(e.first<=i&&ma>=i){
                        c++;
                    }
                    if(e.first<=j&&ma>=j){
                        c++;
                    }
                    if(e.first<=k&&ma>=k){
                        c++;
                    }
                    if(c!=e.second){
                        f=false;
                        break;
                    }
                }
                if(!f){
                    dp[i][j][k]=0;
                }
                if(ma==n){
                    (ans+=dp[i][j][k])%=MOD;
                    continue;
                }
                (dp[ma+1][j][k]+=dp[i][j][k])%=MOD;
                (dp[i][ma+1][k]+=dp[i][j][k])%=MOD;
                (dp[i][j][ma+1]+=dp[i][j][k])%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 232960
#include <stdio.h>

int main()
{
    int A,B;
    int tmp1,tmp2,tmp3;
    int max;

   
    scanf("%d", &A); 
    scanf("%d", &B);
   
    tmp1 = A+B;
    tmp2 = A-B;
    tmp3 = A*B;
    
    if(tmp1>tmp2) max = tmp1;
    else max = tmp2;
    
    if(tmp3 > max) max = tmp3;

    
  　printf("%d\n",max);
  
  return 0;
   
}

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

using namespace std;

vector < pair <int, int> > G[100005];

long long dis[100005];

int dep[100005];

int fa[100005][20];

void dfs(int u, int f) {
    fa[u][0] = f;
    for (int i = 1; i < 20; ++i)
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
    for (auto &x : G[u]) {
        int v = x.first;
        if (v == f)
            continue;
        dep[v] = dep[u] + 1;
        dis[v] = dis[u] + x.second;
        dfs(v, u);
    }
}

int lca(int u, int v) {
    if (dep[u] < dep[v])
        swap(u, v);
    for (int i = 19; i >= 0; --i)
        if (dep[fa[u][i]] >= dep[v])
            u = fa[u][i];
    if (u == v)
        return u;
    for (int i = 19; i >= 0; --i)
        if (fa[u][i] ^ fa[v][i])
            u = fa[u][i], v = fa[v][i];
    return fa[u][0];
}

long long cal(int u, int v) {
    return dis[u] + dis[v] - 2 * dis[lca(u, v)];
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        G[u].push_back( {v, w} );
        G[v].push_back( {u, w} );
    }
    dfs(1, 1);
    int q, k;
    scanf("%d%d", &q, &k);
    while (q--) {
        int u, v;
        scanf("%d%d", &u, &v);
        long long ans = cal(u, k) + cal(k, v);
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 20992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = -1;
  if(a <= 9 && b <= 9) {
    ans = a * b;
  }
  cout << ans << '\n';

  return 0;
}


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;
typedef pair<int, int> P;

const ll mod = 1e9 + 7;

vector<ll> fac(300001); //n!(mod mod)
vector<ll> ifac(300001); //k!^{M-2} (mod mod)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main() {
    ll n, k; cin >> n >> k;

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % mod; // n!(mod mod)
        ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; // k!^{mod-2} (mod mod) ←累乗にmpowを採用
    }

    if(k < n-1){
        ll ans = 1;
        for (int i = 1; i <= k; i++){
            ll now = comb(n, i);
            now *= comb(n-1, n-i-1);
            now %= mod;
            ans += now;
            ans %= mod;
        }
        cout << ans << endl;
    } else {
        ll ans = 1;
        for (int i = 1; i <= n-1; i++){
            ll now = comb(n, i);
            now *= comb(n-1, n-i-1);
            now %= mod;
            ans += now;
            ans %= mod;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7856
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i <n;i++)
int main(){
  ll n,m;cin >>n >>m;vector<ll> a(n),sum(n+1,0);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  rep(i,n) sum[i+1] = sum[i] + a[i];
  ll r = 200200,l = 0;
  while(r - l>1){
    ll mid = (r+l)/2,sz=0;
    rep(i,n){
      ll j = lower_bound(a.begin(),a.end(),mid - a[i])-a.begin();
      sz += n- j;
    }if(sz>=m) l = mid;
    else r = mid;
  }ll ans = 0,cnt = 0;
  rep(i,n){
    ll j = lower_bound(a.begin(),a.end(),l - a[i])-a.begin();
    cnt += n- j; ans += sum[n] - sum [j];
    ans += a[i] * (n-j);
  }ans -= max(cnt-m,0LL)*l;
  cout << ans << endl;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 51
 
struct State{
    int x1,y1,x2,y2;
    State(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
 
int H, W;
char f1[MAX][MAX], f2[MAX][MAX];
bool vis[MAX][MAX][MAX][MAX];
const int lx[] = {0,-1,1,0};
const int ly[] = {-1,0,0,1};
const int rx[] = {0,1,-1,0};
const int ry[] = {-1,0,0,1};
 
bool inField(int y, int x){
    return 0 <= y && y < H && 0 <= x && x < W;
}
 
bool bfs(int Lx, int Ly, int Rx, int Ry){
    memset(vis, false, sizeof(vis));
    queue<State> Q;
    Q.push(State(Lx, Ly, Rx, Ry));
 
    while(!Q.empty()){
	State s = Q.front(); Q.pop();
 
	if(f1[s.y1][s.x1] == '%' && f2[s.y2][s.x2] == '%'){
	    return true;
	}
	for(int i = 0 ; i < 4 ; i++){
	    int nlx = s.x1 + lx[i], nly = s.y1 + ly[i];
	    int nrx = s.x2 + rx[i], nry = s.y2 + ry[i];
 
	    if(!inField(nly, nlx) || f1[nly][nlx] == '#'){
		nlx = s.x1;
		nly = s.y1;
	    }
	    if(!inField(nry, nrx) || f2[nry][nrx] == '#'){
		nrx = s.x2;
		nry = s.y2;
	    }
 
	    if((f1[nly][nlx] == '%' && f2[nry][nrx] != '%') ||
	       (f1[nly][nlx] != '%' && f2[nry][nrx] == '%')) continue;
 
	    if(vis[nly][nlx][nry][nrx]) continue;
	    vis[nly][nlx][nry][nrx] = true;
	    Q.push(State(nlx, nly, nrx, nry));
	}
    }
 
    return false;
}
 
int main(){
    while(cin >> W >> H, (W | H)){
	string str;
	int Lx, Ly, Rx, Ry;
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < 2 ; j++){
		cin >> str;
		for(int k = 0 ; k < W ; k++){
		    if(j % 2 == 0){
			f1[i][k] = str[k];
			if(f1[i][k] == 'L'){
			    Lx = k;
			    Ly = i;
			}
		    }else{
			f2[i][k] = str[k];
			if(f2[i][k] == 'R'){
			    Rx = k;
			    Ry = i;
			}
		    }
		}
	    }
	}
	cout << (bfs(Lx, Ly, Rx, Ry) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 10520
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B; cin >> A >> B;
    cout << ((A+B)%2==0?to_string((A+B)/2):"IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 512
blood_groups = Hash.new { |hash, key| hash[key] = 0 }

readlines.each do |inputs|
  _, blood_type = inputs.chomp.split(',')
  blood_groups[blood_type] += 1
end

['A', 'B', 'AB', 'O'].each do |blood_type|
  puts blood_groups[blood_type]
end

Measured memory_bytes: 8716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    map<ll,ll> m;
    rep(i,N){
        m[A[i]]++;
    }
    ll sum=0;
    for(auto x:m){
        sum+=x.b*(x.b-1)/2;
    }
    rep(i,N){
        ll tmp=sum;
        tmp-=m[A[i]]*(m[A[i]]-1)/2;
        ll X=m[A[i]]-1;
        tmp+=X*(X-1)/2;
        
        cout<<tmp<<endl;
    }
}


Measured memory_bytes: 12760
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "No" << endl;
		return 0;
	}
	if (a == b || b == c || a == c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
}









Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  cout << (N<K?N*X:K*X+(N-K)*Y) << endl;
  return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[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(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

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

fn main() {
    let (A, B, C) = read!(usize, usize, usize);

    let s = A + B + C;
    let mut m = max(max(A, B), C);
    if (m * 3 - s) % 2 != 0 {
        m += 1;
    }

    let k = (m * 3 - s) / 2;

    println!("{}", k)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
ll exponent(ll x,ll n,ll m)
{  if(n==0)
    return 1;
    if(n%2!=0)
    {
        return (x*exponent(((x%m)*(x%m))%m,(n-1)/2,m))%m;
    }
    else
    return exponent(((x%m)*(x%m))%m,n/2,m);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(b<=a)
        {
           for(int i=0;i<a;i++)
                cout<<b;
        }
    else
        if(a<b)
        {
            for(int i=0;i<b;i++)
                cout<<a;
        }

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int q;
    cin >> q;
    for (int j = 0; j < q; ++j) {
        int b, e, t;
        cin >> b >> e >> t;
        swap_ranges(a.begin() + b, a.begin() + e, a.begin() + t);
    }
    for (int i = 0; i < n; ++i) {
        if (i == 0) cout << a[0];
        else cout << " " << a[i];
    }
    cout << endl;
}



Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main() {
  int H, N, A;
  int sum = 0;

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

  cout << ((sum < H) ? "No" : "Yes") << endl;

  return 0;
}


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

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

typedef long long ll;

using namespace std;

int main() {
  int K, X;
  cin >> K >> X;

  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
class KagamiMochi:
    def __init__(self):
        self.counter =1
    def count_mochi(self, mochi_num, mochi_list):
        new_list = list(set(mochi_list))
        new_list_int = [int(s) for s in new_list]
        sort_mochi_list = sorted(new_list_int, reverse=True)
        latest_mochi = sort_mochi_list[0]
        for m in sort_mochi_list:
            if int(m) < int(latest_mochi):
                latest_mochi = int(m)
                self.counter += 1
        return self.counter
            


if __name__ == "__main__":
    N = int(input())
    S = [input() for _ in range(N)]
    km = KagamiMochi()
    result = km.count_mochi(N, S)
    print(str(result))

Measured memory_bytes: 38256
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
count = 0
def dice_matching():
    if dice1[1] == dice2[1]:
        for i in range(4):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0

count = 0
while(1):
    if dice_matching() == 1:
        print "Yes"
        break
    else:
        if count < 3:
            rolling('N', dice2)
            count += 1
        elif 7 > count and count >= 3:
            if count == 3:
                rolling('E', dice2)
            rolling('N', dice2)
            count += 1
        else:
            print "No"
            break

Measured memory_bytes: 6496
#include<stdio.h>
int main(){
  int i;
  int n;
  int a;
  int k4;
  int k2;
  int ifEven;
  int lack;
  int result;

  n = 0;
  ifEven = 0;
  lack = 0;
  result = 0;
  scanf("%d\n", &n);

  k4 = 0;
  k2 = 0;
  for(i = 0; i < n; i++){
    scanf("%d", &a);
    if(a % 4 == 0){
      k4++;
    }else if(a % 2 == 0){
      k2++;
    }
  }
  ifEven = n % 2;
  if(ifEven == 0){
    if(k4 >= n / 2){
      result = 1;
    }else{
      lack = n - 2 * k4;
      if(lack <= k2){
        result = 1;
      }else{
        result = 0;
      }
    }
  }else{
    if(k4 >= (n - 1) / 2){
      result = 1;
    }else{
      lack = n - 2 * k4;
      if(lack <= k2){
        result = 1;
      }else{
        result = 0;
      }
    }
  }
  
  if(result == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for(int i = 0; i < n - 1; ++i) {
        cin >> b[i];
    }
    vector<int> a(n);
    a[0] = b[0];
    a.back() = b.back();
    for(int i = 1; i < n - 1; ++i) {
        a[i] = min(b[i], b[i - 1]);
    }
    cout << accumulate(a.begin(), a.end(), 0) << '\n';
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int A[100];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int k = 1;
  while(k <= M){
    for(int i = 0; i < N - 1; i++){
      int temp;
      if(A[i] % k > A[i + 1] % k){
	temp = A[i + 1];
	A[i + 1] = A[i];
	A[i] = temp;
      }
    }
    k++;
  }
  for(int i = 0; i < N; i++){
    cout << A[i] << endl;
  }
}



Measured memory_bytes: 3092
from collections import Counter, deque

s = input()
n = len(s)
d = deque([{char} for char in s])
c = Counter(s)

if s[0] * n == s:
    print(0)
    exit()

for i in range(1, n):
    for j in range(n - i):
        char_j = s[j]
        char_right = s[j + i]
        set_j = d[j]
        if char_right not in set_j:
            set_j.add(char_right)
            c[char_right] += 1
    rightest = d.pop()
    for char in rightest:
        c[char] -= 1
    if max(c.values()) == n - i:
        print(i)
        exit()
print('oops, something wrong')


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

int main() {
int h,w,i,j;
cin>>h>>w;
char a[103][103];
for(i=1;i<h+1;i++)
{for(j=1;j<w+1;j++)
cin>>a[i][j];}
for(i=0;i<h+2;i++)
{a[i][0]='#';
a[i][w+1]='#';}
for(i=0;i<w+2;i++)
{a[0][i]='#';
a[h+1][i]='#';}
for(i=0;i<h+2;i++)
{for(j=0;j<w+2;j++)
{cout<<a[i][j];}
cout<<endl;}
return 0;
}

Measured memory_bytes: 256
use std::cmp::{max, min};
use std::io::prelude::*;

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();

    let n: usize = input_parts_it.next().unwrap().parse().unwrap();
    let k: u64 = input_parts_it.next().unwrap().parse().unwrap();

    let mut a: Vec<u32> = (0..n).map(|_|  input_parts_it.next().unwrap().parse().unwrap()).collect();

    const NONE: usize = 0xffffffff;
    let mut group_end: Vec<usize> = vec![NONE; a.len()];

    let mut next_a_same_value_for_a: Vec<usize> = vec![NONE; a.len()];
    let mut last_a_for_aval: Vec<usize> = vec![NONE; 200001];

    for (i, &aval) in a.iter().enumerate().rev() {
        next_a_same_value_for_a[i] = last_a_for_aval[aval as usize];
        last_a_for_aval[aval as usize] = i;
    }

    for (i, &aval) in a.iter().enumerate() {
        // find the next `aval` elem with an identical value
        let mut k = next_a_same_value_for_a[i];
        if k == NONE {
            k = last_a_for_aval[aval as usize];
            debug_assert!(k != NONE);
            k += a.len();
        }
        k += 1;

        group_end[i] = k;
    }

    // check the cycle length
    let mut cycle_len = 0;
    {
        let mut i = 0;
        loop {
            let mut hop = group_end[i] - i;
            cycle_len += hop as u64;
            i = group_end[i];
            while i >= a.len() {
                i -= a.len();
            }
            if i == 0 {
                break;
            }
        }
    }

    // skip cycles
    let mut step = n as u64 * k;
    step = step %cycle_len;


    let mut state: Vec<u32> = Vec::with_capacity(a.len());
    let mut index: Vec<usize> = vec![NONE; 200001];

    {
        let mut i = 0;
        let mut remaining_steps = step;

        while remaining_steps >= (group_end[i] - i) as u64 {
            remaining_steps -= (group_end[i] - i) as u64;
            i = group_end[i];
            while i >= a.len() {
                i -= a.len();
            }
        }

        while remaining_steps > 0 {
            let aval = a[i];

            if index[aval as usize] == NONE {
                index[aval as usize] = state.len();
                state.push(aval);
            } else {
                while state.len() > index[aval as usize] {
                    let k = state.pop().unwrap();
                    index[k as usize] = NONE;
                }
            }

            i += 1;
            while i >= a.len() {
                i -= a.len();
            }
            remaining_steps -= 1;
        }
    }

    if state.is_empty() {
        println!("");
    } else {
        print!("{}", state[0]);
        for &x in state[1..].iter() {
            print!(" {}", x);
        }
    }
}


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

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	long n = Long.parseLong(br.readLine());
	String array[] = br.readLine().split(" ");
	long ans = 1;
	for (int i = 0; i < n; i++) {
	    long a = Long.parseLong(array[i]);
	    if (a == 0) {
		ans = 0;
	    } else {
		if (ans <= (long) Math.pow(10, 18) / a) {
		    if (ans >= 0)
			ans *= a;
		} else {
		    ans = -1;
		}
	    }

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


Measured memory_bytes: 49188
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n, a;
	scanf("%d", &n);
	long long c[102];
	fill(c, c + 102, 0);
	for (int i = 0; i < n; i++){
		scanf("%d", &a);
		for (int j = 0; j <= 101; j++) c[j] += (a - j) * (a - j);
	}
	printf("%lld\n", *min_element(c, c + 102));
}

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

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

int gcd( vector< int > a )
{
	int ans = a[0];
	for( int i = 1; i < a.size(); ++i )
	{
		ans = gcd( ans, a[i] );
	}
	return ans;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a( n );
	for( int i = 0; i < n; ++i )
	{
		cin >> a[i];
	}
	
	cout << gcd( a ) << endl;

	return 0;
}

Measured memory_bytes: 1024
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
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; }
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N,K;cin>>N>>K;
    const ll sz=110000;
    ll h[sz],dp[sz];
    REP(i,N)cin>>h[i];
    REP(i,sz)dp[i]=INF;dp[0]=0;
    REP(i,N){
        REPS(k,K)chmin(dp[i+k],dp[i]+abs(h[i+k]-h[i]));
    }
    cout<<dp[N-1]<<"\n";
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,K; cin >> N >> K;
	V<V<int>> a(N,V<int>(N,0));
	corner(N==2&&K==1,-1);
	int L = ((N-1)*(N-2))/2; 
	corner(L < K,-1);	
	for(int i = 0; i < N-1; ++i) a[i][N-1] = 1;

	for(int i = 0; i < N-1 && L > K; ++i){
		for(int j = i + 1; j < N-1 && L > K; ++j){
			L--;
			a[i][j] = 1;
		}
	}
	V<int> u,v;
	for(int i = 0; i < N; ++i){
		for(int j = i+1; j < N; ++j){
			if(a[i][j]) {
				u.push_back(i+1);
				v.push_back(j+1);
			}
		}
	}

	cout << u.size() << endl;
	for(int i = 0; i < u.size(); ++i){
		cout << u[i] << " " << v[i] << endl;
	}

	
	return 0;
}


Measured memory_bytes: 384
/*--------------------------*/
// p.122
// 5.3 二分探索
//
// ALDS1_4_B: Binary Search
//
// 配列Aに含まれる，配列Sの要素の個数を出力するプログラム
//
// 入力例:
//     5 (n)
//     1 2 3 4 5 (A: nコの配列)
//     3 (q)
//     3 4 1 (T: qコの配列)
// 出力例:
//     3
//
/*--------------------------*/

#include<stdio.h>

int A[1000000];
int n;

/* 二分探索 */
int binarySearch(int key){
    int left  = 0;
    int right = n;
    int mid;
    while(left < right){
        mid = (left + right) / 2;
        if (key == A[mid]) return 1; // True: keyを発見できた
        if (key > A[mid]) left = mid + 1;   // 後半を探索
        else if (key < A[mid]) right = mid; // 前半を探索
    }
    return 0; // False: keyを発見できない
}

int main(){
    int i, q, k, sum=0;

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

    scanf("%d", &q);
    for(i = 0 ; i < q ; i++){
        scanf("%d", &k);
        if( binarySearch(k) ) sum++;
    }

    printf("%d\n", sum);
    return 0;
}




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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    int a[101000];
    
    rep(i, q) {
        cin >> a[i];
        a[i]--;
    }
    
    int pt[101000] = {0};
    
    rep(i, q) {
        pt[a[i]]++;
    }
    
    rep(i, n) {
        if (pt[i] > (q - k)) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=2e5;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
ll dp[N][20]={0};
int b[N][15];
char s[N];
void f(ll &x){
	if(x>=mod)x%=mod;
};
int main(){
	//freopen("in.txt","r",stdin);
	cin>>(s+1);
	int n=strlen(s+1);
	for(int i=0;i<10;i++){
		b[0][i]=i;
		for(int j=1;j<=n;j++)b[j][i]=b[j-1][i]*10%13;
	}
	if(s[n]=='?'){
		for(int i=0;i<10;i++)dp[1][i]=1;
	}else dp[1][s[n]-'0']=1;
	for(int i=n-1;i>=1;i--){
		int k=n-i+1;
		if(s[i]=='?'){
			for(int j=0;j<10;j++){
				for(int x=0;x<13;x++){
					f(dp[k][(b[k-1][j]+x)%13]+=dp[k-1][x]);
				}
			}
		}else{
			int j=b[k-1][s[i]-'0'];
			for(int x=0;x<13;x++){
				f(dp[k][(j+x)%13]+=dp[k-1][x]);
			}
		}
	}
	o(dp[n][5]);
}


Measured memory_bytes: 24704
use std::collections::BTreeMap;

type Vu = Vec<u8>;

fn count_pairs(s: Vu) -> BTreeMap<Vec<Vu>, i64> {
    let mut ret = BTreeMap::new();
    let n = s.len();
    for flags in 0..1<<n {
        let mut ss = vec![vec![]; 2];
        for i in 0..n {
            ss[flags >> i & 1].push(s[i]);
        }
        *ret.entry(ss).or_insert(0) += 1;
    }
    ret
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let s = sc.read::<String>().into_bytes();
    let map0 = count_pairs(s.clone().into_iter().take(n).collect());
    let map1 = count_pairs(s.clone().into_iter().rev().take(n).collect());
    let ans: i64 = map0.iter().map(|(k, v)| v * map1.get(k).unwrap_or(&0)).sum();
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

Measured memory_bytes: 69884
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX_LEN 32

const char *right_str = "yuiophjklnm"; // ????????§????????????

// ??¢??°?????????
// ???????????£?????????c??????????????§??????????????????1????????????
int is_right(char c) {
	return strchr(right_str, c) != NULL; // c???right_str?????????????????????????????°????????§??????
}

int main() {
	char input[MAX_LEN + 1]; // ??\??????????????????????????????
	int i; // ?????????????????°
	int ans; // ???????????\???????????°
	int prev_right; // ??????????????????????????§?????£?????? (?????£???:1, ?????£?????????:0)

	while(1) {
		scanf("%s", input); // ??\??????????????????

		if(strcmp(input, "#") == 0) break; // input???"#"????????????

		const int len = strlen(input); // input?????????????????????
		ans = 0;
		prev_right = is_right(input[0]); // 0??????????????????????????§??????????????\??????

		for(i = 1; i < len; ++i) { // 1~len-1???????????????????????????????????????
			if(prev_right != is_right(input[i])) { // ??????????????\???????????£??????????????°
				++ans; // ?????????????????????????????°???1?¢???????
				prev_right = !prev_right; // ???????????????????????£???????????\????????????
			}
		}

		printf("%d\n", ans); // ???????????????
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 544
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> num(n);
    for(int i = 0; i < n; i++){
        ll a,b;
        cin >> a >> b;
        num[i] = {a,b};
    }    
    sort(num.begin(),num.end());
    ll sum = 0;
    ll ans;
    for(int i = 0; i < n; i++){
        sum += num[i].second;
        if(sum >= k){
            ans = num[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	nums := make([]float64,n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	
	max_diff := 0.0
	for i := 0; i < n; i++ {
		diff := 0.0
		for j := 0; j < n; j++ {
			diff = math.Abs(nums[i] - nums[j])
			
			if diff > max_diff {
				max_diff = diff
			}
		}
	}
	fmt.Println(int(max_diff))
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if(ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  int key, i, h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key))%M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }

  return 0;
}

int insert(char str[]){
  int key, i, h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }

  return 0;
}

  int main(){
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for (i = 0; i < n; i++){
      scanf("%s %s", com, str);

      if(com[0] == 'i'){
        insert(str);
      }
      else{
        if(find(str)){
          printf("yes\n");
        }
        else{
          printf("no\n");
        }
      }
    }

    return 0;
  }



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

string str;

int pos;

int main()
{
    pos = -1;

    cin >> str;
    int n = str.length();
    for(int i = 0; i < n - 1; i++)
        if(str[i] == str[i + 1] || str[i] == str[i + 2])
        {
            pos = i;
            break;
        }

    if(pos == -1)
        cout << "-1" << ' ' << "-1" << '\n';
    else
    {
        pos++;
        cout << pos << ' ' << min(pos + 2, n) << '\n';
    }

    return 0;
}


Measured memory_bytes: 512
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
///////////////////////////////////////////////////////////////////////////////////////////////////////////
   
   int n, x;
   cin >> n;
   bool check = true;
   for(int i = 0; i < n; i++){
	   cin >> x;
	   if(x % 2 == 0){
		   if((x % 3 == 0) || (x % 5 == 0)){
			   check = true;
		   }
		   else{
			   check = false;
			   break;
		   }
	   }
   }
   
   if(check) cout << "APPROVED" << endl;
   else cout << "DENIED" << endl;
   
   
   
   
   
   
	
	return 0;
}


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

typedef long long ll;

int main()
{
    ll a, b, c;
    scanf("%lld %lld.%lld", &a,&b,&c);
    b = b*100 + c;
    a = (a*b)/100;
    printf("%lld",a);
}


Measured memory_bytes: 3796
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;case 1: return parseInt(i);case 2: return i.split(" ");case 3: return i.split("\n");case 4: return i.split(" ").map((a)=>Number(a));case 5: return i.split("\n").map((a)=>Number(a));case 6: return i.split("");case 7: return i.split("").map((a)=>Number(a));
  }}
function Main(input) {
  input = myconv(input, 3);
  const N = myconv(input[0], 1);
  const D = myconv(input[1], 4)[0];
  const X = myconv(input[1], 4)[1];
  let ans = 0;
  input.shift();
  input.shift();
  input = input.map((a)=>Number(a));
  for(let i = 0; i < N; i++){
    let tmp = 1;
    while (tmp <= D){
      ans++;
      tmp += input[i];
    }
  }
  console.log(ans + X);
}
Main(myin());

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  string a, b;
  cin >> a >> b;

  if (a.length() > b.length()) {
    p("GREATER");
  } else if (a.length() < b.length()) {
    p("LESS");
  } else {
    for (int i = 0; i < a.length(); ++i) {
      if (a[i] > b[i]) {
        p("GREATER");
        return 0;
      } else if(a[i] < b[i]) {
        p("LESS");
        return 0;
      } else {
        continue;
      }
    }
    p("EQUAL");
  }
}

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

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K; i++) {
    if (i == X + K - 1) cout << i << endl;
    else cout << i << " ";
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;

  vector<pair<ll, ll>> vs(n);
  for(int i = 0; i < n; i++)
  {
	cin >> vs[i].first;
	vs[i].second = -i;
  }
  vs.push_back(make_pair(0, 0));
  sort(vs.begin(), vs.end(), greater<pair<ll, ll>>());

  vector<ll> ret(n);
  fill(ret.begin(), ret.end(), 0);
  
  ll minVal = -vs[0].second;
  for(int i = 0; i < n; i++)
  {
	cerr << vs[i].first << ", " << -vs[i].second << endl;
	ret[minVal] += (i + 1) * (vs[i].first - vs[i + 1].first);
	minVal = min(minVal, -vs[i + 1].second);
  }
  for(int i = 0; i < n; i++)
  {
	cout << ret[i] << endl;
  }
}	


Measured memory_bytes: 4864
#include<bits/stdc++.h>
 using namespace std;
#define LL long long
#define P pair<LL,LL>
 const LL inf = 0x3f3f3f3f;
 const LL mod = 1e9+7;
 const LL N = 1e5+10;
 template <typename tp> inline void read(tp &x)
{
		x=0;char c=getchar();int f=0;
			for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
				for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
					if(f) x=-x;
}
int n,k,head[N],cnt,ans;
struct Edge{int next,to;} edge[N*2];
void add(int from,int to)
{
	edge[++cnt].next=head[from];
	edge[cnt].to=to;
	head[from]=cnt;
}
int dfs(int now,int fa)
{
	int flag=0;
	for(int i=head[now];i;i=edge[i].next)
	{
		int to=edge[i].to;
		if(to==fa||to==now) continue;
		int zz=dfs(to,now)+1;
		if(zz==k&&now!=1) ans++,zz=0;
		flag=max(zz,flag);
	}
	if(now==1) return 0;
	if(flag==k) ans++,flag=0;
	return flag;
}
signed main()
{
	read(n),read(k);
	for(int i=1,v;i<=n;i++)
	{
		read(v);
		if(i==1) 
		{
			if(v!=1) ans++;
			continue;
		}
		add(i,v),add(v,i);
	}
	dfs(1,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int a[n],b[n],c[n];
	int i,j;
	int flaga[n],flagb[n],flagc[n];
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		flaga[i]=0;
		flagb[i]=0;
		flagc[i]=0;
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]==a[j]){
				flaga[i]=1;
				flaga[j]=1;
			}
			if(b[i]==b[j]){
				flagb[i]=1;
				flagb[j]=1;
			};
			if(c[i]==c[j]){
				flagc[i]=1;
				flagc[j]=1;
			}
		}
	}
	for(i=0;i<n;i++){
		if(flaga[i]==1){
			a[i]=0;
		}
		if(flagb[i]==1){
			b[i]=0;
		}
		if(flagc[i]==1){
			c[i]=0;
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",a[i]+b[i]+c[i]);
	}
	return 0;
}

Measured memory_bytes: 600