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

int coin(int s){
if(s < 0) return 1<<28;
return s/500 + (s%500)/100 + (s%100)/50 + (s%50)/10;
}

int main(){
bool flag = false;

int n; 
while(1){
int a, b, c, d;
cin >> n;
if(n == 0) break;
if(flag) cout << endl;
else flag = true;
cin >> a >> b >> c >> d;
int ans = INT_MAX;
int x, y, z, w;
for(int i = 0; i <= a; i++){
for(int j = 0; j <= b; j++){
for(int t = 0; t <= c; t++){
for(int s = 0; s <= d; s++){
int rem = coin(-n+i*10+j*50+t*100+s*500);
rem += a-i+b-j+c-t+d-s;
if(ans > rem){
ans = rem;
x = i;
y = j;
z = t;
w = s;
}
}
}
}
}
if(x) cout << 10 << " " << x << endl;
if(y) cout << 50 << " " << y << endl;
if(z) cout << 100 << " " << z << endl;
if(w) cout << 500 << " " << w << endl;
}

}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)

int dp[1000001] , dp2[1000001];

vector<int> item;

int main(){
	int n;
	for(int i = 1 ; i * (i+1) * (i+2) / 6 <= 1000000 ; i++) item.push_back(i * (i+1) * (i+2) / 6);
	rep(i,1000001) dp[i] = 9999;
	rep(i,1000001) dp2[i]= 9999;
	dp[0] = dp2[0] = 0;

	for(int i = 0 ; i <= 1000000 ; i++){
		for(int j = 0 ; j < item.size() && item[j]+i <= 1000000 ; j++){
			dp[i + item[j]] = min(dp[i + item[j]] , dp[i] + 1);
		}
	}
	for(int i = 0 ; i <= 1000000 ; i++){
		for(int j = 0 ; j < item.size() && item[j]+i <= 1000000 ; j++){
			if(item[j] % 2) dp2[i + item[j]] = min(dp2[i + item[j]] , dp2[i] + 1);
		}
	}
	
	while(cin >> n && n){
		cout << dp[n] << " " << dp2[n] << endl;
	}
}

Measured memory_bytes: 8608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

vector<int> G[51];
bool used[51];

void clear(){
    for(int i = 0; i <= 50; i++) used[i] = false;
}

bool dfs(int s, int t){
    used[s] = true;
    if(s == t) return true;
    for(int i = 0; i < G[s].size(); i++){
        if(!used[G[s][i]]){
            if(dfs(G[s][i], t)) return true;
        }
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    vector<int> ans;
    int N, a[50], b[50];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int cur = 49; cur >= 0; cur--){
        for(int i = 0; i <= 50; i++){
            G[i].clear();
        }
        for(int i = 0; i < ans.size(); i++){
            for(int j = 0; j <= 50; j++){
                int r = j%ans[i];
                G[j].push_back(r);
            }
        }
        for(int i = cur; i >= 1; i--){
            for(int j = 0; j <= 50; j++){
                int r = j%i;
                G[j].push_back(r);
            }
        }
        bool ok = true;
        for(int i = 0; i < N; i++){
            clear();
            if(!dfs(a[i], b[i])) ok = false;
        }
        if(!ok) ans.push_back(cur+1);
        if(cur == 49 && !ok){
            cout << -1 << endl;
            return 0;
        }
    }
    ll res = 0;
    for(int i= 0; i < ans.size(); i++){
        res += (ll)1<<ans[i];
        //cout << ans[i] << endl;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("avx,avx2,fma")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define all(x) ((x).begin()),((x).end())
    #define int ll
    using pii = pair <int, int>;
    #define INF 0x7f7f7f7f7f7f7f7f
    const bool debug = 0;
    const int mod = 998244353;

    int n, x, y;
    vector <int> G[2020];
    int dpd[2020];
    int dt[2020];
    int32_t main()
    {
        usecppio
        cin >> n >> x >> y;
        for (int i = 1; i<n; i++)
        {
            G[i].push_back(i+1);
            G[i+1].push_back(i);
        }
        G[x].push_back(y);
        G[y].push_back(x);
        for (int i = 1; i<=n; i++)
        {
            memset(dt, 0x7f, sizeof(dt));
            queue <int> q;
            q.push(i);
            dt[i] = 0;
            while(!q.empty())
            {
                int p = q.front();
                q.pop();
                for (auto it:G[p])
                {
                    if (dt[it]==INF)
                    {
                        dt[it] = dt[p]+1;
                        q.push(it);
                    }
                }
            }
            for (int j = 1; j<=n; j++)
            {
                dpd[dt[j]]++;
            }
        }
        for (int i = 1; i<n; i++)
        {
            cout << dpd[i]/2 << '\n';
        }
    }


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,ans=0;
    cin>>a>>b>>c;
    if(c<=b)cout<<c+b<<endl;
    else
    {
        c-=b;
        ans+=2*b;
        if(c<=a)
        {
            ans+=c;
        }
        else
        {
            ans+=a;
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*GRATITUDE*/
/*1916057*/
//Arise Awake and Stop Not Till the Goal is reached. 
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

/*************************************************************************************************/
//Write your functions here..............................
 


/***************************************************************************************************/

void solve() {
/*Write your code here*/
   double d,t,s; cin>>d>>t>>s;
   
   if((d/s)<=t) cout<<"Yes";
   else cout<<"No";
 
  
}
int32_t main()
{

ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<string>>date(H,vector<string>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>date[i][j];
    }
  }
   for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<date[i][j]<<endl<<date[i][j]<<endl;
    }
   }
}

Measured memory_bytes: 512
#include <iostream>

int main(void){
    using namespace std;
    int A,B;//Aが8%の課税額、Bが10%の課税額
    
    cin >> A >> B;
    int ans=-1;
    
    for(int i=0;i<1010&&ans==-1;i++){
        if(int(i*0.08)==A&&int(i*0.1)==B)ans=i;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])
print(f(N, X))

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int ans = 0;
    int N; cin >> N;
    REP(i,N){
        int a; cin >> a;
        if (((i + 1) % 2 == 1) and (a % 2 == 1)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

class Node{
    public:
    int parent = -1;
    int parent_edge_id = -1;
    vector<pair<int,int>> child;
};

int main(void)
{
    int n;
    cin >> n;
    vector<Node> tree(n);
    vector<int> colors(n-1);

    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        tree[a-1].child.push_back(pair<int,int>(i,b-1));
        tree[b-1].child.push_back(pair<int,int>(i,a-1));
    }

    int max = 0;
    int max_idx = 0;
    REP(i,n){
        if(tree[i].child.size() + ((tree[i].parent == -1)?0:1) > max){
            max = tree[i].child.size();
            max_idx = i;
        }
    }

    queue<int> mks;
    mks.push(max_idx);
    while(!mks.empty()){
        int v = mks.front();
        mks.pop();
        REP(i,tree[v].child.size()){
            int child_id = tree[v].child[i].second;
            tree[child_id].parent = v;
            tree[child_id].parent_edge_id = tree[v].child[i].first;
            auto e = remove(all(tree[child_id].child),pair<int,int>(tree[v].child[i].first,v));
            tree[child_id].child.erase(e,tree[child_id].child.end());
            mks.push(child_id);
        }
    }

    int color_num = max;
    queue<int> s;
    s.push(max_idx);
    while(!s.empty()){
        int v = s.front();
        s.pop();
        int color_cnt;
        if(tree[v].parent == -1){
            color_cnt = 0;
        }
        else{
            color_cnt = colors[tree[v].parent_edge_id];
        }
        REP(i,tree[v].child.size()){
            colors[tree[v].child[i].first] = color_cnt++%color_num + 1;
            s.push(tree[v].child[i].second);
        }
    }

    cout << max << endl;
    REP(i,colors.size()){
        cout << colors[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long X=sc.nextLong();
    long K=sc.nextLong();
    long D=sc.nextLong();
    long div=0;
    long num=0;
    long ndiv=0;
    if(X>0){
    div=(long)Math.ceil
    ((double)X/(double)D);
    ndiv=Math.min(div,K);
    num=X-D*ndiv;
    }
    else if(X<0)
    {
      div=(long)Math.ceil
    ((double)Math.abs(X)/(double)D);
    ndiv=Math.min(div,K);
    num=X+D*ndiv;
    }
    K-=ndiv;
    long ans=0;
    if(K%2==0)
    {
      ans=Math.abs(num);
    }
    else
    {
      if(num<0)
      ans=Math.abs(num+D);
      else
      ans=Math.abs(num-D);
    }
    System.out.println(ans);
  }
}
    

Measured memory_bytes: 36116
N = gets.to_i

def count753(num, keta, three, five, seven)
  return 0 if N < num
  # puts "#{num} #{keta}"
  [3, 5, 7].inject(three && five && seven ? 1 : 0) do |c, n|
    c + count753(num + n * keta, keta * 10, three || n == 3, five || n == 5, seven || n == 7)
  end
end

puts count753(0, 1, false, false, false)


Measured memory_bytes: 1788
def number():
    return int(input())


def space():
    return list(map(int, input().split()))


N = number()
H = space()

dp = [0] * N
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[-1])



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

int main() {
	int a,b,c,k;
	cin >> a >> b >> c >> k; // a<b<c
	int cnt=0;
	for(;b<=a;){
		cnt++;
		b=2*b;
	}
	for(;c<=b;){
		cnt++;
		c=c*2;
	}
	if(cnt<=k){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// ---------------------------  TEMPLATE ENDS  -------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9+7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 1e5 + 2;

vvi adj;

void solve(){
      int i = 0, j = 0, k = 0, n = 0, m = 0;
      cin>>n>>k;
      if(k == 1) cout<<"0\n";
     	else cout<<(n-k )<<el;
}

int32_t main(){
#ifndef TRACE
      ios::sync_with_stdio(false); cin.tie(0); 
#endif
      int T = 1, tc;
      // cin >> T;
      for(tc = 1; tc <= T; tc++){
            solve();
      }
      return 0;
}

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

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

long long int n5[10000];

int main()
{
    int x;
    cin >> x;
    n5[0] = 0;
    for( long long int i = 1; ; i++ )
    {
        n5[i] = i * i * i * i * i;
        if( n5[i] + n5[i] < x ) continue;
        if( n5[i] == x )
        {
            cout << i << " " << 0;
            return 0;
        }
        if( n5[i] < x )
        {
            long long int d = x - n5[i];
            for(int j = 0; j <= i && n5[j] <= d; j++ )
            {
                if( n5[j] == d )
                {
                    cout << i << " " << -j;
                    return 0;
                }
            }
        }
        else
        {
            long long int d = n5[i] - x;
            for(int j = 0; j <= i && n5[j] <= d; j++ )
            {
                if( n5[j] == d )
                {
                    cout << i << " " << j;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 3532
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

priority_queue<Int,vector<Int>, greater<Int>> R;
priority_queue<Int> L;

int Q;
Int ans;
int main(void) {
    cin>>Q;
    int q;
    Int a,b;
    cin>>q>>a>>b;
    L.push(a);
    R.push(a);
    ans += b;

    for(int i = 1;i < Q;i++) {
        cin>>q;
        if(q == 1) {
            cin>>a>>b;
            ans += b;
            L.push(a);
            R.push(a);
            Int left = L.top();
            Int right = R.top();
            if(left > right) {
                L.pop();
                R.pop();
                L.push(right);
                R.push(left);
                ans += abs(left-right);
            }
        } else {
            cout<<L.top()<<" "<<ans<<endl;
        }
    }

    return 0;
}


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

#define int long long

int32_t main()
{
    int n,d;
    cin>>n>>d;

    d*=d;
    int ans=0;
    while(n--)
    {
        int x,y;
        cin>>x>>y;

        if(x*x+y*y<=d)
        {
            ans++;
        }
    }

    cout<<ans;
}

Measured memory_bytes: 3584
#include <stdio.h>

typedef unsigned int	U32;
typedef unsigned char	U08;

#define INPUT_NUM_MIN	1							/* 入力値の範囲下限 */
#define INPUT_NUM_MAX	1000000000					/* 入力値の範囲上限 */

static U32 CalcGcd_U32(U32 u32_large_num, U32 u32_small_num);



/***********************************************************************************
 ++module <main>
 ++outline
	メイン関数
 ++arguments
	<>	<u32_return_val>	[戻り値]
 ++supp
	<戻り値>
		0：正常終了
		1：異常終了
	<引数>
		なし
	<補足説明>
		なし
 ++end_module
************************************************************************************/
int main(void)
{
													/* 入力値1 */
	U32 u32_x   = 0;								/* 変数定義 */
	U32 u32_y   = 0;								/* 入力値2 */
	U32 u32_gcd = 0;								/* 最大公約数(Greatest Common Divisor) */
	U08 u08_return_val = (U08)0;					/* 戻り値 */
	
	scanf("%d %d", &u32_x, &u32_y);					/* 数値入力 */
	
	if( (u32_x < INPUT_NUM_MIN) || (INPUT_NUM_MAX < u32_x)
		|| (u32_y < INPUT_NUM_MIN) || (INPUT_NUM_MAX < u32_y) )		/* 入力値が範囲外だった場合 */
	{
		u08_return_val = (U08)1;					/* 戻り値に1を設定 */
	}
	else
	{
		if(u32_x > u32_y)							/* 1つ目の入力値の方が大きかった場合 */
		{
			u32_gcd = CalcGcd_U32(u32_x, u32_y);	/* 最大公約数の計算 */
		}
		else
		{
			u32_gcd = CalcGcd_U32(u32_y, u32_x);	/* 最大公約数の計算 */
		}
		
		printf("%d\n", u32_gcd);					/* 最大公約数の表示 */
	}
	
	return u08_return_val;
}



/***********************************************************************************
 ++module <CalcGcd_U32>
 ++outline
	2つの自然数の最大公約数を計算する関数
 ++arguments
	<>	<>				[最大公約数]
	<>	<u32_large_num>	[大きい方の自然数]
	<>	<u32_small_num>	[小さい方の自然数]
 ++supp
	<戻り値>
		最大公約数
	<引数>
		u32_large_num：大きい方の自然数
		u32_small_num：小さい方の自然数
	<補足説明>
		ヒントによると、「x>yの場合、xとyの最大公約数は、yとx%yの最大公約数と一致する」らしい
		→ x%yの結果がゼロになるまでxにyの値を、yにx%yの結果を格納し続け、
		   x%yの結果がゼロになった時のyが最大公約数
 ++end_module
************************************************************************************/
static U32 CalcGcd_U32(U32 u32_large_num, U32 u32_small_num)
{
														/* u32_large_num % u32_small_numの結果を保持する変数 */
	U32 u32_rem = 0;									/* 変数定義 */
	
	while(1)											/* u32_large_num % u32_small_numの結果がゼロではない間ループ */
	{
		if(0 == u32_small_num)							/* 除数がゼロの場合 */
		{
			break;
		}
		else
		{
			u32_rem = u32_large_num % u32_small_num;	/* u32_large_num % u32_small_numを計算 */
			
			if(0 == u32_rem)							/* u32_large_num % u32_small_numの結果がゼロの場合 */
			{
				break;
			}
			else
			{
				u32_large_num = u32_small_num;			/* u32_large_numを更新 */
				u32_small_num = u32_rem;				/* u32_small_numを更新 */
			}
		}
	}
	
	return u32_small_num;
}



Measured memory_bytes: 2104
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

long long powll(long long a, long long b) {
    long long ret = 1;
    for (long long i = 0; i < b; i++) {
        ret *= a;
    }
    return ret;
}

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

    cout << K * powll(K - 1, N - 1) << endl;

    return 0;
}


Measured memory_bytes: 760
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a%3==0 || b%3==0 || (a+b)%3==0){
            System.out.println("Possible");
        }else{
            System.out.println("Impossible");
        }
        
    }
}

Measured memory_bytes: 23764
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size()){
    if(i % 2){
      ans += (s[i] == 'g');
    }else{
      ans -= (s[i] == 'p');
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> v;
	while(n--){
		int s;
		cin >> s;
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	int suma = accumulate(v.begin(),v.end(),0);
	if(suma%10 == 0){
		for(auto x:v){
			if((suma-x)%10 != 0){
				cout << suma-x;
				return 0;
				}
			}

		cout << 0;
				}
	else{cout<< suma;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for (int x=y; x<=z; x++)
#define downrep(x,y,z) for (int x=y; x>=z; x--)
#define ms(x,y,z) memset(x,y,sizeof(z))
#define LL long long
#define repedge(x,y) for (int x=hed[y]; ~x; x=edge[x].nex)
inline int read(){
	int x=0; int w=0; char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}
const int maxn=200005;
int n,m,a[35];
char S[maxn],T[maxn];
int main(){
	scanf("%s",&S); scanf("%s",&T); n=strlen(S); m=strlen(T);
	if (n!=m){ puts("No"); return 0; }
	ms(a,-1,a);
	rep(i,0,n-1){
		if (a[S[i]-'a']==-1){ a[S[i]-'a']=T[i]-'a'; continue; }
		if (a[S[i]-'a']!=T[i]-'a'){ puts("No"); return 0; }
	}
	ms(a,-1,a);
	rep(i,0,n-1){
		if (a[T[i]-'a']==-1){ a[T[i]-'a']=S[i]-'a'; continue; }
		if (a[T[i]-'a']!=S[i]-'a'){ puts("No"); return 0; }
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

typedef long long ll;

int main() {
	string S; ll K;
	cin >> S >> K;
	for (ll i = 0; i < min((ll)S.size(),K); i++) {
		if (S[i] >= '2') { cout << S[i] << endl; return 0; }
	}
	cout << '1' << endl;

	return 0;
}

Measured memory_bytes: 256
nums = []
while True:
    in_line = raw_input().split()
    h = int(in_line[0])
    w = int(in_line[1])
    if h == 0 and w == 0:
        break
    else:
        nums.append([h,w])
for num in nums:
    for i in range(0,num[0]):
        if i%2 == 0:
            if num[1]%2 == 1:
                print "#."*(num[1]/2) + "#"
            else:
                print "#."*(num[1]/2)
        else:
            if num[1]%2 == 1:
                print ".#"*(num[1]/2) + "."
            else:
                print ".#"*(num[1]/2)
    print ""

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

//https://atcoder.jp/contests/abc168/tasks/abc168_e

//mod
const int mod = 1e9 + 7;
int powmod(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
int inverce(int x) {
	return powmod(x, mod - 2);
}

int n, z = 0;
map<pair<long long, long long>, pair<int, int>> m;
long long ans = 1;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		if (!(a || b)) {
			z++;
			continue;
		}
		long long g = gcd(a, b);
		a /= g, b /= g;
		if (b < 0)
			a *= -1, b *= -1;
		if (a > 0)
			m[make_pair(a, b)].first++;
		else
			m[make_pair(b, -a)].second++;
	}
	for (auto &p : m) {
		ans = ans * (powmod(2, p.second.first) + powmod(2, p.second.second) - 1)
				% mod;
	}
	ans = (ans + z - 1) % mod;
	if (ans < 0)
		ans += mod;
	cout << ans << endl;
}


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

typedef vector<int> vi;

const int MOD = (int)1e9 + 7;
int N, K;
vi A;
vector<vi> dp;
vi sum;

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

	cin >> N >> K;
	A.resize(N + 1);
	for (int i = 1; i <= N; ++i)
		cin >> A[i];

	dp.resize(N + 1, vi(K + 1, 0));
	sum.resize(K + 2, 0);
	dp[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= K; ++j)
			sum[j + 1] = (sum[j] + dp[i - 1][j]) % MOD;
		for (int j = 0; j <= K; ++j)
			dp[i][j] = (sum[j + 1] - sum[max(0, j - A[i])] + MOD) % MOD;
	}

	int ans = dp[N][K];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 40192
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>
#include <array>
#include <climits>
//#include "debug.h"
using namespace std;
 
#define A first
#define B second
 
typedef long long ll;
constexpr int MOD = 1e9 + 7;

void solve() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i].A >> A[i].B;
  }
  for(int i = 2; i < N; i++){
    if(A[i].A == A[i].B && A[i - 1].A == A[i - 1].B && A[i - 2].A == A[i - 2].B){
      cout << "Yes";
      return;
    }
  }
  cout << "No";
}   
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

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

int main(){
  char b;
  cin >> b;
  
  if(b == 'A'){
    cout << "T";
  }
  else if(b == 'T'){
    cout << "A";
  }
  else if(b == 'C'){
    cout << "G";
  }
  else{
    cout << "C";
  }


}

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

int main(){
  int N,M;
  int A[30][30];
  int B[30];
  int C;
  cin >> N >> M >> C;
  for(int j=0;j<M;j++)
    cin >> B[j];
  for(int i=0;i<N;i++)
    for(int j=0;j<M;j++)
      cin >> A[i][j];
  
  int res=0;
  for(int i=0;i<N;i++){
    int sum=C;
    for(int j=0;j<M;j++){
      sum+=A[i][j]*B[j];
    }
    if(sum>0) res++;
  }
  cout << res << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

vvi g;
vi seen,low,ord;
vii bridge;
void dfs(int v,int cnt,int par){
	seen[v]=1;
	ord[v]=cnt++;
	low[v]=ord[v];
	for(auto to:g[v]){
		if(!seen[to]){
			dfs(to,cnt,v);
			low[v]=min(low[v],low[to]);
			if(ord[v]<low[to])bridge.PB(MP(min(v,to),max(v,to)));
		}
		else if(to!=par){
			low[v]=min(low[v],ord[to]);
		}
	}
}

int main(){
	int n,m;cin>>n>>m;
	g.resize(n);
	seen.resize(n);
	low.resize(n);
	ord.resize(n);
    rep(i,n){seen[i]=0;low[i]=1e9;ord[i]=1e9;}
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	dfs(0,0,-1);
    int k=0;
    rep(i,n){
		if(!seen[i])dfs(i,k,-1);
	}
	int l=bridge.size();
	cout<<l<<endl;
}

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

using namespace std;

int main()
{
  int N, K;
  cin >> N;
  cin >> K;
  
  vector <int> indices(N);
  vector <int> prices(N);
  
  for (int i = 0; i < N; ++i)
  {
    indices[i] = i;
    cin >> prices[i];
  }
  sort(indices.begin(), indices.end(), 
       [&prices](int a, int b){ 
         return prices[a] < prices[b]; 
       });
  int sum = 0;
  for (int i = 0; i < K; ++i)
  {
    sum += prices[indices[i]];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int apos = 0;
    for( int i = 0; i < s.size(); ++i ) {
        if( s[i] == 'A' ) { apos = i; break; }
    }

    int zpos;
    for( int i = apos + 1; i < s.size(); ++i ) {
        if( s[i] == 'Z' ) zpos = i;

    }

    cout << 1 + zpos - apos << endl;
    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>

#define mod 1000000007

int main(){

    long long N;

    scanf("%lld", &N);

    long long A[N];

    long long sum[N+1];

    sum[0] = 0;

    for(int i=0;i<N;i++){
        scanf("%lld", &A[i]);
        sum[i+1] = sum[i] + A[i];
    }

    long long ans = 0;

    for(int i=0;i<N;i++){
        ans += (A[i]%mod) * ((sum[N] - sum[i+1])%mod);
        ans %= mod;
    }

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

    return 0;
}

Measured memory_bytes: 5200
#include "bits/stdc++.h"

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
ll dp[100001][3];
ll inp[100001][3];
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	fr(i,0,n) {
		cin >> inp[i][0] >> inp[i][1] >> inp[i][2];
	}
	fr(i,1,n+1) {
		fr(j,0,3) {
			fr(l,0,3) {
				if (j == l)
					continue;
				dp[i][j] = max(dp[i][j],inp[i-1][j] + dp[i-1][l]);
			}
		}	
	}
	ll ans = 0;
	fr(i,0,3)
		ans = max(ans,dp[n][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>

typedef long long ll;

using namespace std;

int main()
{
    string c;
 
    cin >> c;

    ll r = (c[2] - 48)*10 + c[3]-48;
    ll l = (c[0] - 48)*10 + c[1]-48;

    if (1<=l && l<=12)
    {
        if (1<=r && r<=12)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "MMYY" << endl;
    }
    else if (1<=r && r<=12)
    {
        if (1<=l && l<=12)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "YYMM" << endl;
    }
    else
        cout << "NA" << endl;

    //cout << left << ' ' << right << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

grid = [list(map(int, input().split())) for i in range(3)]

# 組み合わせてイコールになる箇所を考えてみる
if grid[0][1] + grid[1][0] - grid[1][1] == grid[0][0]\
        and grid[0][1] + grid[1][2] - grid[1][1] == grid[0][2]\
        and grid[1][0] + grid[2][1] - grid[1][1] == grid[2][0]\
        and grid[1][2] + grid[2][1] - grid[1][1] == grid[2][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            bool isArrival = true;

            if (input.Contains('N') ^ input.Contains('S')) isArrival = false;
            if (input.Contains('W') ^ input.Contains('E')) isArrival = false;

            Console.WriteLine(isArrival ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 2904
#include<iostream>
#define INT_MX 2147483646
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int heights[n], dp[n];
    for (int i=0; i<n; i++)
        cin>>heights[i];
    dp[n-1]=0;
    dp[n-2]=abs(heights[n-2]-heights[n-1]);
    for (int i=n-3; i>=0; i--){
        dp[i]=INT_MX;
        for (int j=k;j>0;j--){
            if (i+j<n)
            dp[i]=min(dp[i], abs(heights[i+j]-heights[i]) + dp[i+j]);
        }
    }
    cout<<dp[0];
    return 0;
}


Measured memory_bytes: 1024
H,W = gets.split.map(&:to_i)
S = H.times.map{gets.chomp}
D = [[1,0],[0,1],[-1,0],[0,-1]]

H.times do |h|
  W.times do |w|
    if S[h][w] == "."
      next
    end

    dont = true
    D.each do |d|
      x, y = d
      ww = w + x
      hh = h + y
      next if ww < 0 || W <= ww
      next if hh < 0 || H <= hh
      dont = false if S[hh][ww] == "#"
    end
    if dont
      puts "No"
      exit
    end
  end
end

puts "Yes"

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long int ll;
const ll mod = 998244353;
const ll INF = 1e9 + 5;

void solve()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}

int main()
{
//	int t;
//	cin >> t;
//	while(t-->0)
	solve();
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') cout << 'A' << '\n';
    else cout << 'a' << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
vector<int> vec;
int prime(int a)
{
    int i;
    for(i=2;i<=sqrt(a);i++)
    {
	if(a%i==0)
	{
	    return 0;
	}
    }  
    return 1;
}
int main()
{
    int n;
    int i,ans=0;
    scanf("%d",&n);
    for(i=11;ans!=n;i+=30)
    {
    	if(prime(i))
	{
	    vec.push_back(i);
	    ans++;	
	}
    }
    int len=vec.size();
    for(i=0;i<len-1;i++)
    {
	printf("%d ",vec[i]);
    }
    printf("%d\n",vec[i]);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
const int MAXS = 200;

using VVI = vector<vector<int>>;
using VVVI = vector<VVI>;
VVVI dp;

int solve(string& str, int now, bool smaller, int nonZero, int K) { // notice that K >= 1 && 0 is illegal, so no special handling needed
    if (now == str.size()) {
        return (int)(nonZero == K);
    }

    if (dp[now][smaller][nonZero] >= 0) {
        return dp[now][smaller][nonZero];
    }

    int ret = 0;
    int c = str[now] - '0';
    int nzd = 0; //non zero digit

    for (int d = 0; d < 10; ++d) {
        if (d == 0 || nonZero < K) {
            if (smaller || d <= c) {
                ret += solve(str, now+1, smaller || (d < c), nonZero + nzd, K);
            }
        }
        nzd = 1;
    }

    return dp[now][smaller][nonZero] = ret;
}

int main() {
    string str;
    int K;

    cin >> str;
    cin >> K;

    dp = std::forward<VVVI>(VVVI(str.size(), VVI(2, vector<int>(K+1, -1))));

    cout << solve(str, 0, false, 0, K) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

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


Measured memory_bytes: 256
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        # print(s)
        # print(index)
        # print(ope_num)
        # print()
        si = s[index]
        if si == "A":
            if b_stock > 0:
                a_stock = 1
            else:
                a_stock = a_stock + 1
            b_stock = 0
        elif a_stock > 0:
            if b_stock == 0:
                if si == "B":
                    b_stock = 1
                else:
                    a_stock = 0
                    b_stock = 0
            elif si == "C":
                ope_num = ope_num + a_stock
                # s[index - 2 - a_stock + 1] = "B"
                # s[index - 1 - a_stock + 1] = "C"
                # s[index] = "A"
                # index = index - 1
                a_stock = a_stock
                b_stock = 0
            else:
                a_stock = 0
                b_stock = 0
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)

# ABCの数
# ABCの前にあるAの分だけ追加で操作できる
# ABCの後にある(BC)の分だけ追加で操作できる

# Aがあれば覚えておく
# ABCと来たら、それより前側に隣接しているAの回数だけ追加で操作できる
# 見つかったABCをBCAに置き換える
# BCAのAから走査を継続する


Measured memory_bytes: 4968
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int left = 0,right=s.size()-1;
    int res = 0;
    while(left<right){
        if(s[left]==s[right]){
            left++;right--;
        }else if(s[left]=='x'){
            res++;
            left++;
        }else if(s[right]=='x'){
            res++;
            right--;
        }else{
            res = -1;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
from functools import reduce
from operator import xor

N, *A = map(int, open(0).read().split())

x = reduce(xor, A)

ans = 0
K = x.bit_length()
for k in reversed(range(K)):
    if (x >> k) & 1:
        for a in A:
            t = a ^ (a - 1)
            if t == 2 ** (k + 1) - 1:
                x ^= t
                ans += 1
                break

if x == 0:
    print(ans)
else:
    print(-1)

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

int main(){
    string a; cin >> a;
    int prev;
    for (int i = 0; i < a.size(); i++)
    {
        if(i!=0){
            if(a[i]==prev) {
                cout << "Bad" << endl;
                return 0;
            }
        }
        prev = a[i];
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int n,k;
    	n = in.nextInt();
    	k = in.nextInt();
    	String ans = "NO";
    	if (k <= (n/2 + n%2)) ans = "YES";
    	
    	System.out.println(ans);
    }
}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    vector<ii> input;
    for (int i = 0; i < m; ++i){
        int l, r; cin >> l >> r;
        input.pb({l, r});
    }
    sort(input.begin(), input.end());
    int a = -1, b = prime;
    for (int i = 0; i < m; ++i){
            b = min(b, input[i].ss);  
            a = max(a, input[i].ff);
    }
    cout << max(0, b-a+1) << endl;


    return 0;
}

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

int main(){
   
  int n;cin>>n;
  int k; cin>>k;
  
  if(n == 1) {
    cout<<0<<endl;
    return 0;
  }
  
  int a[1000000];
  for(int i =0 ; i<n; i++){
    cin>>a[i];
  }
  
  long long int dp[10000000];

  for(int i = 0; i<10000000; i++)
  dp[i] = INT_MAX;

  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);

  
  for(int i = 2; i<n; i++){
    for(int j = i-1; j>=0 && i-j<=k; j--)
    	dp[i] = min(dp[i],(dp[j] + abs(a[i] - a[j])));
  }
  
  cout<<dp[n-1]<<endl;
                
  return 0;
}

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


int main(){
  int n;bool flag =false;
  cin>>n;
  
    for(int i=1;i<10;i++){
     if(n%i==0) {
    if(n/i>=1 &&n/i<=9){
    flag=true;
    break;}}
    }
    if(flag==true) cout<<"Yes";
    else cout<<"No";

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  vector<pair<ll, ll>> a(n);
  rep(i, n) cin >> a[i].first >> a[i].second;

  sort(a.begin(), a.end());
  int ans = n;
  rep(i, n) {
    rep(j, i) {
      ll p = a[i].first - a[j].first, q = a[i].second - a[j].second;
      int res = 0;
      vector<bool> used(n, false);
      rep(k, n) {
        if (used[k]) continue;
        res++;
        used[k] = true;
        int resx = a[k].first, resy = a[k].second;
        while (1) {
          int idx = find(a.begin(), a.end(), make_pair(resx + p, resy + q)) - a.begin();
          if (idx == n || used[idx]) break;
          used[idx] = true;
          resx += p, resy += q;
        }
      }
      chmin(ans, res);
    }
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#168D
def main():
    import sys
    
    N, M =map(int, sys.stdin.readline().split())
    AB = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]
    
    edge = [[] for _ in range(N)]
    for ab in AB:
        edge[ab[0]-1] += [ab[1]-1]
        edge[ab[1]-1] += [ab[0]-1]
    
    #print(edge)
    
    L = [-1 for i in range(N)] #道標(親p)を調べる
    
    #p:親 c:子
    def bfs(p):
        from collections import deque
        queue = deque([p])
        L[p] =0
        while queue:
            p = queue.popleft()
            for c in edge[p]:
                if L[c]==-1: #-1のとき未開
                    #print(c)
                    L[c] = p+1 #道標(どこから来たか)
                    #L[c] = L[now]+1 #階層の深さ
                    queue.append(c)
        
    
    bfs(0)
    print('Yes')
    for i in L[1:]:
        print(i)


if __name__=='__main__':
    main()


Measured memory_bytes: 64424
from heapq import heappush, heappop
from operator import itemgetter
import sys

input = sys.stdin.readline

n, k = map(int, input().split())
e = []
for _ in range(n):
    t, d = map(int, input().split())
    t -= 1
    e.append((d, t))

e.sort(key=itemgetter(0), reverse=True)

b = e[:k]  # 暫定選択（おいしさ基礎ポイント降順取得）

used = [False] * n
hq = []

ans = 0  # 暫定選択（おいしさ基礎ポイント降順取得）
tn = 0  # 種類数
for d, t in b:
    if not used[t]:
        used[t] = True
        tn += 1
    else:
        heappush(hq, (d, t))
    ans += d
ans += pow(tn, 2)  # 種類ボーナス

c = e[k:]  # 取得しなかった予備

# print(b)
# print(c)
# print(hq)
# print(used)
s = ans
cur = 0
while hq:
    d, t = heappop(hq)
    s -= d
    changed = False
    while cur < n - k:
        cd, ct = c[cur]
        cur += 1
        if not used[ct]:
            used[ct] = True
            changed = True
            s += cd
            s += tn * 2 + 1
            tn += 1
            if s > ans:
                ans = s
            break
    if not changed:
        break
print(ans)


Measured memory_bytes: 20556
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		int count = 0;
		boolean flag = true;
		while (flag) {
			for (int i = 0; i < n; i++) {
				if (a[i] %2 != 0) {
					flag = false;
					break;
				} else {
					a[i] = a[i]/2;
				}
			}
			if (flag) count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $count = 0; $two=0;
  for($i=0; $i<$n; $i++){
      if($a[$i]%4 == 0){
          $count++;
      }else if($a[$i]%2 == 0){
          $two++;
      }
  }
  if($two > 0) $two--;
  echo $count >= (int)(($n-$two)/2) ? "Yes" : "No";

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




V<LL>v;
const LL bs=3234566667LL;

void solve(LL x)
{
    if(x > bs)return;
    v.emplace_back(x);
    int y=x%10;
    solve(x*10+y);
    if(y > 0)solve(x*10+y-1);
    if(y < 9)solve(x*10+y+1);
}

int main()
{
    FAST();

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

    int i,n;
    for(i=1;i<10;i++)solve(i);
    sort(v.B,v.E);
    cin >> n;
    cout << v[n-1];
    return 0;
}


Measured memory_bytes: 1400
A, B = map(int, input().split())
S = list(input())
suji = [str(i) for i in range(0, 10)]
try:
    a = int("".join(S[:A]))
    b = int("".join(S[B:]))
    if (S[A] in suji):
        print("No")
    else:
        print("Yes")
except:
    print("No")


Measured memory_bytes: 3060