akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

#define MAX_N (105)
#define MAX_D (200)
#define MAX_COST ( MAX_D * MAX_D * MAX_N )
int a[MAX_N];

int main()
{
    int N;

    scanf("%d", &N);
    
    for ( int i = 0; i < N; i++ ) scanf("%d", &a[i]);

    int ans = MAX_COST;

    for ( int i = -100; i <= 100; i++ ) {
	int cost = 0;
	for ( int j = 0; j < N; j++ ) {
	    cost += ( i - a[j] ) * ( i - a[j] );
	}

	ans = ( cost < ans ) ? cost : ans;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = 342;
const int mod = 998244353;

string s;
int n;
int k;

void read() {
	cin >> s >> k;
	n = SZ(s);
	chkmin(k, n);
}

int dp[MAXN][MAXN][MAXN];

void add(int &x, int a) {
	x += a;
	if(x >= mod) x -= mod;
}

void solve() {
	vector<int> pos0;
	pos0.pb(-1);
	for(int i = 0; i < n; i++) {
		if(s[i] == '0') pos0.pb(i);
	}

	pos0.pb(n);

	dp[0][0][0] = 1;

	int m = SZ(pos0) - 1, z = n + 1 - m;
	for(int i = 1; i <= m; i++) {
		int actual_cnt_1 = pos0[i] - pos0[i - 1] - 1;
		for(int q = 0; q <= k; q++) {
			for(int bal = 0; bal <= z; bal++) {
				if(dp[i - 1][bal][q]) {
					for(int c = 0; c <= z; c++) {
						int delta = c - actual_cnt_1;
						int new_q = q + max(delta, 0);
						if(new_q <= k && delta + bal >= 0) {
							add(dp[i][delta + bal][new_q], 
							    dp[i - 1][bal][q]);
						}
					}
				}
			}
		}
	}

	int ans = 0;
	for(int i = 0; i <= k; i++) {
		add(ans, dp[m][0][i]);
	}
	
	cout << ans << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 64004
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    long MOD = (long)Math.pow(10, 9) + 7;
    int[] s = new int[n];
    int[] t = new int[m];
    for(int i = 0; i < n; i++) {
      s[i] = sc.nextInt();
    }
    for(int i = 0; i < m; i++) {
      t[i] = sc.nextInt();
    }
    long[][] dp = new long[n][m];
    long[][] sum = new long[n][m];
    if(s[0] == t[0]) {
      dp[0][0] = 1;
      sum[0][0] = 1;
    }
    for(int j = 1; j < m; j++) {
      if(s[0] == t[j])  dp[0][j] = 1;
      sum[0][j] = (sum[0][j - 1] + dp[0][j]) % MOD; 
    }
    for(int i = 1; i < n; i++) {
      if(s[i] == t[0])  dp[i][0] = 1;
      sum[i][0] = (sum[i - 1][0] + dp[i][0]) % MOD; 
    }
    for(int i = 1; i < n; i++) {
      for(int j = 1; j < m; j++) {
        if(s[i] == t[j]) dp[i][j] = (sum[i - 1][j - 1] + 1) % MOD;
        sum[i][j] = (sum[i - 1][j] + sum[i][j - 1] + dp[i][j] + MOD - sum[i - 1][j - 1]) % MOD;
      }
    }
    long ans = 0;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < m; j++) {
        ans = (ans + dp[i][j]) % MOD;
      }
    }
    ans = (ans + 1) % MOD;
    System.out.println(ans);
  }
}

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

using namespace std;

int main()
{
  int n; cin >> n;
  int a[n+1];
  memset(a, 0, sizeof(a));
  for(int i = 1; i < n; i++)
  {
  	int x; cin >> x;
  	a[x]++;
  }
  for(int i= 1; i <= n; i++)
  cout << a[i] << endl;
}

Measured memory_bytes: 4436
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

string s;

int main() {
  cin >> s;

  solve();

  return 0;
}

void solve() {

  ll size = (int)(s.size());

  ll ans = 0;
  for(int mask=0; mask<(1<<size-1); ++mask) {
    ll keep = s[0]-'0';
    for(int i=0; i<size-1; ++i) {
      if(mask >> i & 1) {
        ans += keep;
        keep = 0;
      }
      keep = keep*10 + s[i+1]-'0';
    }
    ans += keep;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int n,k;
	cin>>n>>k;
	ll l=0,r=1e18;
	while(r-l>1){
	    ll c=(r+l)/2,p=c;;
	    bool is=true;
	    rep(shokei,n-1){
	        c-=(c-1)/k+1;
	        if(c<=0) {is=true;goto end;}
	    }
	    is=false;
	    end:;
	    if(is){
	        l=p;
	    }else r=p;
	}
	cout<<r-1<<endl;

	
	return 0;
}



Measured memory_bytes: 3124
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 10;
const int LG = 20;
const int MOD = 1e9 + 7;

int arr[N];

int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

void solve()
{
	precompute();
	int n, k;
	cin >> n >> k;
	int ret = 0;
	int rooms = min(n - 1, k);
	for(int i = 0; i <= rooms; i++)
	{
		int nn = n;
		int kk = n - i;
		int no = nCr(n, i);
		int temp = no * nCr(nn - 1, kk - 1);
		ret += temp;
		ret %= MOD;
	}
	cout << ret << endl;
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    	solve();
    return 0;
}

Measured memory_bytes: 4352
void main() {
  problem();
}

void problem() {
  auto S = scan;

  void solve() {
    writefln(S == "ABC" ? "ARC" : "ABC");
  }

  solve();
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 2844
#include <iostream>
using namespace std;
int main(){
        int N,t;
        cin >> N >> t;
        long long int counter=0;
        int y=0;
        cin >> y;
        for(int i=0 ; i<N-1 ; i++ ){
                int x;
                cin >> x;
                if(x<y+t)
                        counter+=x-y;
                else
                        counter+=t;
                y=x;
        }
        counter+=t;
        cout << counter << endl;
        return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let c1 = read::<String>();
    let c2 = read::<String>();
    println!("{}", if c1 == c2 {
        "H"
    } else {
        "D"
    });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MN 200005
typedef std::pair<int,int> P;
int n,a[MN],lst;
int pos[MN],val[MN],cnt;
bool check(int x)
{
    cnt=0;
    for(int i=2;i<=n;i++)
    {
        if(a[i]>a[i-1]) continue;
        for(;cnt&&pos[cnt]>a[i];cnt--);
        if(pos[cnt]<a[i]) pos[++cnt]=a[i],val[cnt]=0;
        for(;1;)
        {
            val[cnt]++;
            if(val[cnt]<x) break;
            if(pos[cnt]==1) return 0;
            val[cnt]=0;
            if(pos[cnt-1]!=pos[cnt]-1) pos[cnt]--;
            else cnt--;
        }
    }
    return 1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int l=1,r=n+1,ans;
    while(l<=r)
    {
        int mid=l+r+1>>1;
        if(check(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> c(n);
	for(int i = 0; i < n; i++) scanf("%lld", &c[i]);
	sort(begin(c), end(c));

	const int MOD = 1e9 + 7;

	std::vector<i64> pow(2 * n + 1, 1);
	for(int i = 1; i < pow.size(); i++) pow[i] = pow[i - 1] * 2LL % MOD;

	i64 ans = 0;
	for(int i = 0; i < n; i++) {
		i64 X = pow[2 * i + 1] * pow[n - i - 1] % MOD;
		i64 Y = (i < n - 1 ? (n - i - 1) * pow[n - i - 2] % MOD + pow[n - i - 1]: 1);
		(ans += X * Y % MOD * c[i] % MOD) %= MOD;
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main ()
{
	string s;
	cin >> s;
	int cek = 1;
	for (int i=0; i<s.length(); i++){
		if (i%2==0){
			if (s[i] == 'L'){
				cek = 0;
				break;
			}
		}
		else {
			if (s[i] == 'R'){
				cek = 0;
			}
		}
	}
	if (cek == 0){
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int n;
int a[1000100];
pair<int,int> b[1000100];

void upd(int x,int y){
	int num1=b[x].first,num2=b[x].second,num3=b[y].first,num4=b[y].second;
	b[x].first=max(num1,num3);
	if(num1>num3) b[x].second=max(num2,num3);
	else b[x].second=max(num1,num4);
}

int main(){
	#ifdef LZT
	freopen("in","r",stdin);
	#endif
	n=read();
	for(int i=0;i<(1<<n);i++)
		a[i]=read();
	for(int i=0;i<(1<<n);i++)
		b[i].first=a[i],b[i].second=-1e9;
	for(int k=0;k<n;k++){
		//cout<<k<<endl;
		for(int i=0;i<(1<<n);i++){
			if((i&(1<<k))!=0) continue;
			upd(i|(1<<k),i);
			//cout<<(i|(1<<k))<<' '<<i<<endl;
		}
	}/*
	for(int i=0;i+1<(1<<n);i++){
		upd(i+1,i);
	}*/
	int lastans=0;
	for(int i=1;i<(1<<n);i++){
		lastans=max(lastans,b[i].first+b[i].second);
		printf("%d\n",lastans);
	}
	return 0;
}

/*
2
1 2 3 1
*/


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

result = False
t = 0
for _ in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        t += 1
    else:
        t = 0
    if t >= 3:
        result = True
        break
if result:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9164
#include<bits/stdc++.h> 
using namespace std;
typedef long long llong;
llong a,b,c;
llong f(llong x){
	if(x>=0) return x;
	else return -x;
}
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2==0||b%2==0||c%2==0){
		printf("%lld",0);
	}
	else {
		llong a1=a/2,a2=a-a1;
		llong s1=a1*b*c, s2=a2*b*c;
		llong b1=b/2,b2=b-b1;
		llong s3=a*b1*c, s4=a*b2*c;
		llong c1=c/2,c2=c-c1;
		llong s5=a*b*c1, s6=a*b*c2;
		llong ans1 = f(s1-s2),ans2=f(s3-s4),ans3=f(s5-s6);
		cout<<min(min(ans1,ans2),ans3);
	}
	return 0;
} 

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


int walk(int, int);
char f[100][100];
int H, W;

int main(void){
	while (cin >> H >> W, (H || W)){
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cin >> f[i][j];
			}
		}
		walk(0, 0);
	}
}

int walk(int y, int x){
	switch (f[x][y]){
	case '.':
		printf("%d %d\n", y, x);
		break;
	case 'v':
		f[x][y]= 'a';
		walk(y, x+1);
		break;
	case '^':
		f[x][y] = 'a';
		walk(y, x-1);
		break;
	case '>':
		f[x][y] = 'a';
		walk(y+1, x);
		break;
	case '<':
		f[x][y] = 'a';
		walk(y-1, x);
		break;
	case 'a':
		printf("LOOP\n");
		break;

	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

int N, A[10101];
//---------------------------------------------------------------------------------------------------
void _main() {
	while (cin >> N) {
		if (N == 0) return;
		rep(i, 0, N) cin >> A[i];

		int sm = 0;
		rep(i, 0, N) sm += A[i];

		int ans = 0;
		rep(i, 0, N) if (A[i] * N <= sm) ans++;
		printf("%d\n", ans);
	}
}




Measured memory_bytes: 3204
#include <stdio.h>

int main(void)
{
	int a[3],result;
	int max=-1;
	int min=101;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	
	for(int i=0;i<3;i++){
		
		if(max<a[i]){
			max=a[i];
		}
		
		if(min>a[i]){
			min=a[i];
		}
	}
	
	result=max-min;
	printf("%d\n",result);
	
	return 0;
}
		
	
	
		
		

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<set>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,0,N)cin>>A[i];
    sort(A.begin(),A.end());
    cout<<A[N-1]-A[0]<<endl;

    return 0;
}

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] buf = Console.ReadLine().Split(' ');
            int N = int.Parse(buf[0]);
            int M = int.Parse(buf[1]);
            int mcp = 0;
            int min = 999999999;
            
            int[] pX = new int[N];
            int[] pY = new int[N];
            for(int i = 0 ; i < N ; i++)
            {
                buf = Console.ReadLine().Split(' ');
                pX[i] = int.Parse(buf[0]);
                pY[i] = int.Parse(buf[1]);
            }
            
            int[] cX = new int[M];
            int[] cY = new int[M];
            for(int i = 0 ; i < M ; i++)
            {
                buf = Console.ReadLine().Split(' ');
                cX[i] = int.Parse(buf[0]);
                cY[i] = int.Parse(buf[1]);
            }
            
            for(int i = 0 ; i < N ; i++)
            {
                min = 999999999;
                mcp = 0;
                for(int j = 0 ; j < M ; j++)
                {
                    int kyori = Math.Abs(pX[i] - cX[j]) + Math.Abs(pY[i] - cY[j]);
                    if(kyori < min)
                    {
                        min = kyori;
                        mcp = j+1;
                    }
                }
                Console.WriteLine(mcp);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef long long Int;

string int2str(Int src, int base) {
  string res;
  while(src != 0) {
    char c = src%base;
    if (c < 10) c += '0';
    else c += 'a'-10;
    res = string(1,c) + res;
    src /= base;
  }
  return res;
}

int main() {
  double a;
  while(cin>>a, a>=0) {
    int i = (int)a;
    if (i>=256) {
      cout << "NA" << endl;
      continue;
    }
    string s;
    REP(j,8) {
      s = string(1,'0'+i%2) + s;
      i /= 2;
    }
    double d = a-(int)a;
    string s1;
    REP(j,4) {
      d *= 2;
      if (d>=1) {
        s1 += "1";
        d -= 1;
      } else
        s1 += "0";
    }
    if (d == 0) {
      cout << s + "." + s1 << endl;
    } else
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 0
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        int q = sc.nextInt();

        StringBuffer sb = new StringBuffer();

        SegTree st = new SegTree(n);

        for (int i=0; i<n; i++) {
            st.update(i, arr[i] - 'a');
        }

        for (int i=0; i<q; i++) {
            int t = sc.nextInt();
            if (t == 1) {
                int idx = sc.nextInt() - 1;
                char c = sc.next().charAt(0);
                st.update(idx, c - 'a');
            } else {
                int l = sc.nextInt() - 1;
                int r = sc.nextInt() - 1;
                int u = st.query(l, r + 1);
                sb.append( Integer.bitCount(u)+ "\n");
            }
        }

        System.out.println(sb.toString());
    }

    public class SegTree {

        int n = 1;
        int[] val;

        public SegTree(int n) {
            while (this.n < n) this.n *= 2;
            val = new int[2*this.n-1];
        }

        void update(int k, int a) {
            k += n - 1;
            val[k] = (1 << a);
            while (k > 0) {
                k = (k - 1) / 2;
                val[k] = val[2*k+1] | val[2*k+2];
            }
        }

        int query(int a, int b) {
//            for (int i=0; i<val.length; i++) {
//                System.out.println(val[i]);
//            }
            return query(0, n, a, b, 0);
        }

        int query(int l, int r, int a, int b, int k) {
            if (r<=a || b<=l) return 0;
            if (a<=l && r<=b) return val[k];
            else {
                int vl = query(l, (l+r)/2, a, b, 2*k+1);
                int vr = query((l+r)/2, r, a, b, 2*k+2);
                return vl | vr;
            }
        }
    }

}


Measured memory_bytes: 60756
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::string s; cin >> s;
	int q; scanf("%d", &q);
	
	std::vector<i64> sum(n + 1, 0);
	std::vector<int> latte;
	for(int i = 0; i < n; i++) sum[i + 1] = sum[i] + (s[i] == 'M');
	for(int i = 0; i < n; i++) if(s[i] == 'D') latte.push_back(i);
	
	while(q--) {
		int k; scanf("%d", &k);
		
		i64 ans = 0, tmp = 0, c = 0, size = 0;
		for(int i = 0; i < n; i++) {
			if(s[i] == 'D') {
				tmp += sum[i + 1];
				size++;
			} else if(s[i] == 'C') {
				while(c < latte.size() and latte[c] < i and i - latte[c] >= k) {
					tmp -= sum[latte[c++] + 1];
					size--;
				}
				
				ans += size * sum[i + 1] - tmp;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 13820
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<=n;i++)

/*int main(){//A
    int N;cin>>N;
    if(N%2==0) cout<<(double)N/2/N<<endl;
    else cout<<(double)(N/2+1)/N<<endl;
    return 0;
}*/

/*int main(){//B
    int N,K;cin>>N>>K;
    vector<int> h(N);
    int c=0;
    rep(i,0,N) {
        cin>>h[i];
        if(h[i]>=K) c++;
    }
    cout<<c<<endl;
    return 0;
}*/

/*int main(){//C
    int N;cin>>N;
    vector<pair<int,int>> p(N);
    rep(i,0,N){
        cin>>p[i].first;
        p[i].second=i;
    }
    sort(p.begin(),p.end());
    rep(i,0,N) cout<<p[i].second+1<<" ";
    cout<<endl;
    return 0;
}*/

int main(){
    long long A,B;cin>>A>>B;
    long long c,d,count=1;
    c=max(A,B);
    d=min(A,B);
    long long r=c%d;
    while(r!=0){
        c=d;
        d=r;
        r=c%d;
    }
   // cout<<d<<endl;
 /*  vector<long long> p(1,1);そら10^12個の配列ひとつづつ見ようとしたらTLEでしょうね
    rep2(i,2,d){
        if(d%i==0) p.push_back(i);
    }
   // rep(i,0,p.size()) cout<<p[i]<<endl;
    vector<bool> P(p.size(),false);
   // P[0]=false;
   for(int i=1;i<p.size();i++){
       for(int j=2;j<=sqrt(p[i]);j++){
           if(p[i]%j==0) {
               P[i]=true;
               break;
           }
       }
   }
   long long count =0;
   rep(i,0,p.size()) if(P[i]==false) count++;
   cout<<count<<endl;*/
   for(int i=2;i<=sqrt(d);i++){
       if(d%i==0){
           count++;
           while(d%i==0){
               d/=i;
           }
       }
   }
   if(d>1) count++;//たとえば2*3^4みたいなとき、最後にfor文入るときのdは素数じゃないので足す必要ない
   cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int m,f,r;
	char grade;
	while(1){
		scanf("%d %d %d", &m, &f, &r);
		if(m==-1 && f==-1 && r == -1)break;
		if(m==-1 || f==-1)grade = 'F';
		else if(m + f >= 80)grade = 'A';
		else if(m + f >= 65)grade = 'B';
		else if(m + f >= 50)grade = 'C';
		else if(m + f >= 30 && r >= 50)grade = 'C';
		else if(m + f >= 30)grade = 'D';
		else grade = 'F';
		printf("%c\n", grade);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

ll dp[110][4][2]={0};

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

  std::string s;
  std::cin>>s;

  ll k;
  std::cin>>k;

  ll n=s.size();

  dp[0][0][0]=1;
  dp[0][1][0]=s[0]-'1';
  dp[0][1][1]=1;

  rep(i,1,n){
    if(s[i]=='0'){
      dp[i][0][0]=dp[i-1][0][0];
      rep(j,1,k+1){
        dp[i][j][1]=dp[i-1][j][1];
        dp[i][j][0]=dp[i-1][j][0]+9*dp[i-1][j-1][0];
      }
    }else{
      dp[i][0][0]=dp[i-1][0][0];
      rep(j,1,k+1){
        dp[i][j][1]=dp[i-1][j-1][1];
        dp[i][j][0]=dp[i-1][j][0]+dp[i-1][j][1]+9*dp[i-1][j-1][0]+dp[i-1][j-1][1]*(s[i]-'1');
      }
    }
  }

  std::cout<<dp[n-1][k][0]+dp[n-1][k][1]<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <complex>
#include <unordered_map>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MODU 33
#define Range(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;

////???????????¬////
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> Pt;//???
namespace std {
	bool operator < (const Pt& a, const Pt& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const Pt& a, const Pt& b) {
	return imag(conj(a)*b);
}
double dot(const Pt& a, const Pt& b) {
	return real(conj(a)*b);
}

struct Ln : public vector<Pt> {//???
	Ln(const Pt &a, const Pt &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<Pt> Pol;//????§???¢

struct Cir {//???
	Pt p; double r;
	Cir(const Pt &p, double r) : p(p), r(r) { }
};

int ccw(Pt a, Pt b, Pt c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

Pt projection(const Ln &l, const Pt &p) {
	double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
	return l[0] + t*(l[0] - l[1]);
}
bool intersectSP(const Ln &s, const Pt &p) {//????????????
	return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS; // triangle inequality
}
double distanceSP(const Ln &s, const Pt &p) {
	const Pt r = projection(s, p);
	if (intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0] - p), abs(s[1] - p));
}

bool intersectCL(const Ln &s, const Cir &c) {
	double dis = distanceSP(s, c.p);
	return dis <= c.r;
}
double distancePP(const Pt &p, const Pt &q) {
	return hypot(p.real() - q.real(), p.imag() - q.imag());
}
bool insideCir(Pt &p, Cir &c) {
	return distancePP(p, c.p) <= c.r;
}
int main() {
	int n, m;
	while (scanf("%d", &n)) {
		if (n == 0)
			return 0;
		vector<Cir> walls;
		REP(i, n) {
			double px, py, r;
			scanf("%lf %lf %lf", &px, &py, &r);
			walls.push_back({ {px,py},r });
		}

		scanf("%d", &m);
		REP(i, m) {
			Pt t, s;
			double x, y;
			scanf("%lf %lf", &x, &y);
			t = { x,y };
			scanf("%lf %lf", &x, &y);
			s = { x,y };

			bool f = 0;
			REP(j, n) {
				f = intersectCL({ t,s }, walls[j]);
				if (f) {
					if (insideCir(t, walls[j]) && insideCir(s, walls[j]))
						f = 0;
					else
						break;
				}
			}
			if (f) {
				printf("Safe\n");
			}
			else
				printf("Danger\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3264
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int N, Q, M, A[20];
bool Check[2005];

int Prepare(){
  int all = pow(2, N);
  for (int i = 1; i < all; i++){
    int num = i, sum = 0;
    for (int j = 0; j < N; j++){
      if (num % 2 == 1) sum += A[j];
      num /= 2;
    }
    if (sum <= 2000) Check[sum] = true;
  }
  return 0;
}

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

  cin >> Q;
  for (int i = 0; i < Q; i++){
    cin >> M;
    if (Check[M]) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 3284
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
d = {}
for i,num in enumerate(a):
    d[num] = i+1
ans = 0

### BIT 
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return

# a1,...,aiの和がv以上になる最小のindexを求める
def index(bit, v):
    i = 0
    k = 1
    n = len(bit)-1
    while 2*k<n:
        k *= 2
    while k>0:
        if i+k<n+1 and bit[i+k]<v:
            v -= bit[i+k]
            i += k
        k //= 2
    return i+1
bit = [0] * (n+2)
bit[n+1] = 1
for num in range(1,n+1):
    v = query(bit, d[num])
    v1 = index(bit, v) if v>0 else 0
    v2 = index(bit, v+1)
    ans += num * (d[num]-v1) * (v2 - d[num])
#     print(num, d[num], v1, v2, v, bit)
    add(bit, d[num], 1)
print(ans)

Measured memory_bytes: 123704
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define fr(n, x) for (ll n = 0; n < x; n++)
#define pf(x) cout << x << '\n'
const ll mx = 3e5 + 4;
const ll mod = 1e9 + 7;
#pragma GCC optimize("O3")

vll graph[mx];
bool vis[mx] = {0};
ll res = 0;

void dfs(ll node)
{
    vis[node] = 1;
    queue<ll> bfs;
    bfs.push(node);
    while (!bfs.empty())
    {
        ll top = bfs.front();
        bfs.pop();
        res++;
        for (auto j : graph[top])
        {
            if (!vis[j])
            {
                bfs.push(j);
                vis[j] = 1;
            }
        }
    }
}

int main()
{

    ll x, y;
    cin >> x >> y;
    set<pair<ll, ll>> edg;

    fr(n, y)
    {
        ll a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ll mx = 0;
    for (ll n = 1; n <= x; n++)
    {
        if (!vis[n])
        {
            res = 0;
            dfs(n);
            mx = max(mx, res);
            //cout << res << ' ' << n << '\n';
        }
    }
    cout << mx;
}


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

int main(void){
  unsigned long a, b, k;
  scanf("%lu %lu %lu", &a, &b, &k);

  if(k<=a)
    a = a-k;
  else if(a<k&&k<a+b){
    b = b - k + a;
    a = 0;
  }
  else if(k>=a+b){
    a = 0;
    b = 0;
  }

  printf("%lu %lu\n", a, b);
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 100005;
const int MAXM = 200005;

// dsu
int par[MAXN], dis[MAXN];

void init(int n)
{
	memset(dis, 0, sizeof(dis));
	memset(par, 0, sizeof(par));
	for (int i = 1; i <= n; i++)
		par[i] = i;
}

int find(int x)
{
	if (par[x] == x)
		return x;
	find(par[x]);
	dis[x] += dis[par[x]];
	par[x] = par[par[x]];
	return par[x];
}

bool link(int u, int v, int d)
{
	int x = find(u), y = find(v);
	if (x == y)
	{
//		cout << "dis[" << u << "]: " << dis[u] << endl;
//		cout << "dis[" << v << "]: " << dis[v] << endl;
		return (dis[u] - dis[v] == d);
	}
	else
	{
		par[x] = y, dis[x] = d + dis[v] - dis[u];
		return 1;
	}
}

int n, m, u, v, d;

bool tag = 1;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	init(n);
	for (int i = 1; i <= m; i++)
	{
		cin >> u >> v >> d;
		tag &= link(u, v, d);
		if (!tag)
			break;
	}
	cout << (tag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  cout << n/2 * min({q*8, h*4, s*2, d}) + n%2 * min({q*4, h*2, s}) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a, b, c, d, e, f, g, h, sumA, sumB;
   scanf("%d %d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &g, &h);
   sumA = a + b + c + d;
   sumB = e + f + g + h;
   if ( sumA >= sumB ) printf("%d\n", sumA);
   else printf("%d\n", sumB);
   return 0;
}

Measured memory_bytes: 1796
N,C,K=map(int,input().split())
T=sorted([int(input()) for i in range(N)])
cnt=0
i=0
while(i<N):
    j=i
    lim=T[i]+K
    while(j<N and T[j]<=lim and j-i+1<=C):
        j+=1
    cnt+=1
    i=j
print(cnt)

Measured memory_bytes: 81872
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n, k;
	cin >> n >> k;
	vector<int>v(n + k);
	vector<int>ans(n + k, inf);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	ans[0] = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 1; j <= k; ++j)
			ans[i + j] = min(ans[i + j], ans[i] + abs(v[i] - v[i + j]));
	cout << ans[n - 1];
}

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

#define REP(i,n) for(int i=0; i< int(n); (i)++)
int odd(int *);
int main()
{
    int n, sum_all=1, sum_odd=1, a[101]={0};
    cin >> n;
    REP(i,n)
    {
        cin >> a[i];
        sum_all *= 3;
        sum_odd *= odd(&a[i]);
    }
    cout << sum_all - sum_odd << endl;
    return 0;
}
int odd(int *a)
{
    if(*a%2==0)
    {
        return 2;
    }
    else
    {
        return 1;
    }
}

Measured memory_bytes: 256
import java.util.*;

	public class Main {

		public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int sum = 0;
        for (int i = 1; i <= a; i++) {
          if(!(String.valueOf(i).length()%2==0)){
            sum++;
          }
        }
          System.out.println(sum);
	}
}

Measured memory_bytes: 26452
n,x=map(int,input().split())
a=list(map(int,input().split()))
if n<=x:#ｎこのDPを作りたいのでｘが超えたらそれを変える必要がある
    x=n-1#でもこれは実際甘え

dp=[-1]*n

dp[0]=0#さいしょのところは０かかる
for i in range(1,x+1):#飛べる距離までとべるところから最初の値を引く
    dp[i]=abs(a[i]-a[0])

for i in range(x+1,n):#さいしょのいちから飛べないところからDPを入れる
    min1=10**9
    for j in range(i-(x),i): # 最小を調べる繰り返し
        if min1>dp[j]+abs(a[j]-a[i]):               
            min1=dp[j]+abs(a[j]-a[i])#Xの数最小の値を調べる
    dp[i]=min1
print(dp[-1])

Measured memory_bytes: 52448
#include <stdio.h>

int main()
{
    long long int x, y, num1, num2, keep;
    
    scanf("%lld %lld", &x, &y);
    num1 = x; num2 = y;
    while(num2 != 0){
        keep = num2;
        num2 = num1 % num2;
        num1 = keep;
    }    
    printf("%lld\n", num1);
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

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

void solve(long long N, long long K, long long Q, std::vector<long long> A){
  vector<int> v(N+1);
  REP(x, Q) {
    v.at(A.at(x)) += 1;
  }
  da(v);
  FOR1(x, N) cout << (K - Q + v.at(x) > 0 ? YES : NO) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> A(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, K, Q, std::move(A));
}


Measured memory_bytes: 2176
N,K=map(int,input().split())
A=list(map(int,input().split()))

data=[0 for i in range(45)]
for a in A:
    b=list(bin(a)[2:])
    b.reverse()
    for i in range(len(b)):
        if b[i]=="1":
            data[i]+=1
numlst=[]
bink=list(bin(K)[2:])
bink.reverse()
K_nagasa=len(bink)
num1=0
#print(data)
for k in range(len(data)-1,-1,-1):

    if K_nagasa>k and bink[k]=="1":
        #print(k,"k")
        num=num1+data[k]*(2**k)
        for i in range(k):
            num+=max(N-data[i],data[i])*(2**i)
        numlst.append(num)
        num=num1+max(N-data[k],data[k])*(2**k)
        num1+=(N-data[k])*(2**k)
        k-=1

        if k>=0:
            while k>0 and bink[k]!="1":
                num+=data[k]*(2**k)
                k-=1
            num+=data[k]*(2**k)
            if bink[k]!="1":
                for i in range(k):
                    num+=max(N-data[i],data[i])*(2**i)
        numlst.append(num)


    else:
        num1+=data[k]*(2**k)
    numlst.append(num1)
print(max(numlst))


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

int main() {
    long long N, K;
    cin >> N >> K;

    // cout << N << " " << K << endl;

    long long minv = N;

    // while(true) {
    //     N = N - K;
    //     if (N < 0) N *= -1;

    //     if (N == minv) break;
    //     else minv = min(minv, N);
    // }

    long long t = N % K;
    long long ans = min(t, K - t);

    cout << ans << endl;
}

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

int main(void) {
	using namespace std;
	int N;
	cin >> N;
	long long res = 0;
	for(int i = 0; i < N; ++i) {
		long long l, r;
		cin >> l >> r;
		res += (r - l) + 1;
	}
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 256
n=gets.to_i
s1=gets.split.map(&:to_i)
s2=gets.split.map(&:to_i)
a,b=0,0
[*1..n].permutation.to_a.each_with_index do |p,i|
  a=i if p==s1
  b=i if p==s2
end
p (b-a).abs


Measured memory_bytes: 20484
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll h,w;
	cin>>h>>w;
	ll res=1e18;
	for(ll i=1;i<=h-1;++i){
		ll A=i*w;
		ll B=(h-i)/2LL*w;
		ll C=(h-i-(h-i)/2LL)*w;
		res=min(res,max({A,B,C})-min({A,B,C}));
		B=(h-i)*(w/2LL);
		C=(h-i)*(w-w/2LL);
		res=min(res,max({A,B,C})-min({A,B,C}));
	}
	for(ll i=1;i<=w-1;++i){
		ll A=i*h;
		ll B=(w-i)/2LL*h;
		ll C=(w-i-(w-i)/2LL)*h;
		res=min(res,max({A,B,C})-min({A,B,C}));
		B=(w-i)*(h/2LL);
		C=(w-i)*(h-h/2LL);
		res=min(res,max({A,B,C})-min({A,B,C}));
	}
	cout<<res<<'\n';
}



Measured memory_bytes: 3640
n,k=map(int,input().split())
candle=list(map(int,input().split()))
ans=float("inf")
for l in range(n-k+1):
    r=l+k-1
    ans=min(ans,
            abs(candle[l])+abs(candle[l]-candle[r]),
            abs(candle[r])+abs(candle[r]-candle[l])
            )
print(ans)

Measured memory_bytes: 62576
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string a,b,c;
  cin >> a >> b >> c;
  cout <<"A"<<b.front()<<"C"<<endl;
}


Measured memory_bytes: 256
import numpy as np

inp = input()
A, B, K = int(inp.split(' ')[0]), int(inp.split(' ')[1]), int(inp.split(' ')[2])
  
if K>A:
  B = np.max([0, B-(K-A)])
A = np.max([0, A-K])

print(f'{A} {B}')

Measured memory_bytes: 27172
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    for i in range(n-1):
        a[i+1] += a[i]
    a.insert(0,0)
    f = defaultdict(lambda : 0)
    ans = 0
    for i in a:
        ans += f[i]
        f[i] += 1
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 103632
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

int max(int i,int j){
	if(i>j){return i;}
	else{return j;}
}

int solve(int *A,int i,int m,int n){
	if(i>n){
		return 0;
	}else{
	if(m-A[i]==0){
		return 1;
	}else{
		return max(solve(A,i+1,m-A[i],n),solve(A,i+1,m,n));
 	}}
}

main(){
	int i,n,q,*A,m;
	scanf("%d",&n);
	mymalloc(A,n);
	for(i=0;i<n;i++){
		scanf(" %d",&A[i]);
	}
	scanf(" %d",&q);
	for(i=0;i<q;i++){
		scanf(" %d",&m);
		if(solve(A,0,m,n-1)==1){
			printf("yes\n");
		}
		else{
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;

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

  string stones;
  cin >> stones;

  int l = 0;
  int r = n - 1;
  int cnt = 0;
  while (l < r) {
    while (l < r && stones[l] != 'W') {
      l++;
    }

    while (r > l && stones[r] != 'R') {
      r--;
    }

    if (l == r) {
      break;
    }

    cnt++;
    l++;
    r--;
  }

  cout << cnt << endl;

  return 0;
}


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

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
    cout << "YES" << endl;
  } else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long sum = 0;
    for(int i = 1; i <= N; i++) {
      if(i % 3 == 0 || i % 5 == 0) {
        continue;
      } else {
        sum += i;
      }
    }
    
    System.out.println(sum);
  }
}

Measured memory_bytes: 27116
import java.util.*;

public class Main {
    //YYMM or MMYY
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sln(s);
    }

    public static void sln(String s) {
        int first = Integer.parseInt(s.substring(0, 2));
        int second = Integer.parseInt(s.substring(2));
        if ((first > 0 && first < 13) && (second > 0 && second < 13)) System.out.println("AMBIGUOUS");
        else if (first > 0 && first < 13) System.out.println("MMYY");
        else if (second > 0 && second < 13) System.out.println("YYMM");
        else System.out.println("NA");
    }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

using namespace std;

int main()
{

	ll s;
	cin >> s;

	int digits = 0;
	for (ll tmp = s; tmp > 0;) {
		digits++;
		tmp /= 10;
	}

	ll sum = 0;
	for (int i = 0; i < 1 << (digits - 1); i++) {
		ll s_tmp = s;
		int div = 10;
		for (int j = 0; j < digits - 1; j++) {
			if (1 & i >> j) {
				sum += (s_tmp % div);
				s_tmp /= div;
				div = 10;
			} else {
				div *= 10;
			}

		}
		sum += s_tmp;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256