akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N + 1, 0);
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    A.at(i + 1) = A.at(i) + a;
  }
  vector<ll> sum((N * (N + 1)) / 2);
  ll cnt = 0;
  for (ll i = 0; i < N; ++i) {
    for (ll j = i + 1; j < N + 1; ++j) {
      sum.at(cnt) = A.at(j) - A.at(i);
      cnt += 1;
    }
  }
  // cout << "sum" << endl;
  // for (ll i = 0; i < N * (N + 1) / 2; ++i) {
  //   cout << sum.at(i) << ' ';
  // }


  for (ll i = 40; i >= 0; --i) {
    vector<ll> temp;
    for (ll j = 0; j < sum.size(); ++j) {
      ll i_pow = pow(2, i);
      if (sum.at(j) & i_pow) {
        // cout << "sum" << sum.at(j) << "ipow" << i_pow << "i" << i << endl;
        temp.push_back(sum.at(j));
      }
    }
    if (temp.size() < K) {
      continue;
    }
    if (temp.size() == K) {
      ll ans = temp.at(0);
      for (ll j = 0; j < K; ++j) {
        ans = (ans & temp.at(j));
      }
      cout << ans << endl;
      return 0;
    }
    sum = temp;
  }
  ll ans = sum.at(0);
  for (ll j = 0; j < sum.size(); ++j) {
    ans = (ans & sum.at(j));
  }
  // cout << "sum" << endl;
  // for (ll i = 0; i < sum.size(); ++i) {
  //   cout << sum.at(i) << endl;
  // }
  cout << ans << endl;

}


Measured memory_bytes: 5372
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign, Range};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet, HashMap};
use std::fmt::Display;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}

macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn solve(egg: usize, trial: usize, memo: &mut Vec<Vec<i64>>) -> i64 {
    if egg == 0 || trial == 0 {
        0
    }else if memo[egg][trial] >= 0 {
        memo[egg][trial]
    }else {
        let ret = solve(egg - 1, trial - 1, memo) + solve(egg, trial - 1, memo) + 1;
        memo[egg][trial] = ret;
        ret
    }
}
fn main() {
    let t: usize = read_value!();
    let mut memo = vec![vec![-1_i64; 51]; 51];
    for _ in 0 .. t {
        let_all!(n: i64, e: usize);
        for i in 1 .. 51 {
            if solve(e, i, &mut memo) >= n {
                println!("{}", i);
                break
            }
        }
    }
}



Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
//#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};
typedef long long ll;

int ans;

signed main(){

    int n,a[1111];
    cin>>n;
    int l=0,r=0;
    rep(i,n){
        cin>>a[i];
        r+=a[i];
    }
    int min=INF;
    rep(i,n){
        l+=a[i];
        r-=a[i];
        min=std::min(abs(l-r),min);
    }
    cout<<min<<endl;
    
}


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

w = [0]*(N)
v = [0]*(N)
for i in range(0, N):
    w[i], v[i] = map(int, input().split())

# dp[w]: n番目までのを使用して、重さwの時の価値
dp = [-1]*(W+1)

dp[0] = 0
for i in range(N):
    for j in reversed(range(W+1)):
        prew = j - w[i] 
        if ((prew >= 0) and (dp[prew] >= 0)):
            dp[j] = max(dp[j], dp[prew] + v[i])

ans = 0
for val in dp:
    ans = max(ans, val)

print(ans)


Measured memory_bytes: 74336
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n;
  string s;

  cin >> n >> s;

  int ans = 0;
  REP(i, n - 2){
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

const int INF = 1000000000;
const int M = 10000;

int dp[20002];

int main()
{
    int h, n;
    cin >> h >> n;
    int a[1002], b[1002];
    for(int i = 0; i < n; i++)cin >> a[i] >> b[i];
    for(int i = 0; i <= h + M; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = a[i - 1]; j <= h + M; j++) dp[j] = min(dp[j], dp[j - a[i - 1]] + b[i - 1]);
    }
    int ans = INF;
    for(int j = h; j <= h + M; j++) ans = min(ans, dp[j]);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    int a,b,i;
    cin>>a>>b;
    if(a<b){
        for(i=1;i<=b;i++) cout<<a;
        return;
    }
    else{
        for(i=1;i<=a;i++) cout<<b;
        return;
    }
}
int main()
{
    solve();
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cctype>

using namespace std;

vector<int> ge_do;
void f_gedo(){
    for(int i=2; i<=300000; i++){
        if(i%7==1||i%7==6){
            ge_do.push_back(i);
        }
    }
}

bool box[300000+1]={0};
vector<int> sosu;
void f_sosu(){
    for(int i=0; i<ge_do.size(); i++){
        if(box[ge_do[i]]==0){
            sosu.push_back(ge_do[i]);
            int temp=ge_do[i];
            for(int j=0; j<ge_do.size(); j++){
                if(temp*ge_do[j]>300000.0)break;
                box[temp*ge_do[j]]=1;
            }
        }
    }
}

int main()
{
    f_gedo();
    f_sosu();
    /*
    for(int i=0; i<10000; i++){
        cout<< ge_do[i]<<" "<<sosu[i]<<endl;
    }
     */
    int n;
    while(cin>>n){
        if(n==1)break;
        cout<<n<<":";
        for(int i=0; i<sosu.size(); i++){
            if(n%sosu[i]==0)cout<<" "<<sosu[i];
        }
        cout<<endl;
    }
    
    return 0;
}


/*
 6
 8
 13
 15
 20
 22
 27
 29
 34
 41
 43
 50
 55
 57
 62
 69
 71
 76
 83
 85
 92
 97
 99
 106
 111
 113
 118
 125
 127
 134
 139
 141
 146
 148
 153
 155
 167
 0
*/

Measured memory_bytes: 1988
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};





int main(){
  int N;
  cin >> N;
  int A[N];
  vector<P> t[N];
  rep(i,N){
    cin >> A[i];
    rep(j,A[i]){
      int x,y;
      cin >> x >> y;
      x--;
      t[i].push_back(make_pair(x,y));
    }
  }
  
  int ans = 0;
  for(int bit = 0; bit < (1<<N);bit++){
    int b[20];
    rep(i, N) b[i] = -1;
    bool f = true;
    int tmp = 0;
    rep(i,N){
      if(bit & (1<<i)){
	if(b[i] == false) f = false;
	b[i] = true;
	rep(j,A[i]){
	  int x = t[i][j].first;
	  int y = t[i][j].second;
	  if((y==1 && b[x] == 0) || (y==0 && b[x] == 1)) f = false;
	  if(y) b[x] = 1;
	  else b[x] = 0;
	}
      }
      else{
	if(b[i] == true) f = false;
	b[i] = false;
      } 
    }
    rep(i,N) if(b[i] == 1) tmp++;
    if(f) ans = max(ans,tmp);
  }
  cout << ans << endl;  
  
  return 0;
}



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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

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

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;

struct edge
{
	int to,cap,cost,rev;
};
int nn=505;
vector<edge>G[505];
int dist[505];
int prevv[505],preve[505];

void add_edge(int from,int to,int cap,int cost)
{
	G[from].pb((edge){to,cap,cost,G[to].size()});
	G[to].pb((edge){from,0,-cost,G[from].size()-1});
}

int mincost_maxflow(int s,int t,int f)
{
	int res=0;
	while(f>0)
	{
		//このnはフローを流すグラフの頂点数でありもとのグラフの頂点数ではない!!!!!!
		fill(dist,dist+nn,INF);
		dist[s]=0;
		bool upd=true;
		while(upd)
		{
			upd=false;
			for(int v=0;v<nn;v++)
			{
				if(dist[v]==INF) continue;
				for(int i=0;i<G[v].size();i++)
				{
					edge &e = G[v][i];
					if(e.cap>0 && dist[e.to]>dist[v]+e.cost)
					{
						dist[e.to]=dist[v]+e.cost;
						prevv[e.to]=v;
						preve[e.to]=i;
						upd=true;
					}
				}
			}
		}
		if(dist[t]==INF) return -1;
		int d=f;
		for(int v=t;v!=s;v=prevv[v])
		{
			d = min(d,G[prevv[v]][preve[v]].cap);
		}
		f-=d;
		res+=d*dist[t];
		for(int v=t;v!=s;v=prevv[v])
		{
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

int main(){
	while(1){
		cin>>n;
		if(n == 0) return 0;
		rep(i,505) G[i].clear();
		rep(i,n){
			int a,b,c; cin>>a>>b>>c;
			add_edge(a,b+1,1,-c);
		}
		for(int i=0;i<400;i++) add_edge(500,i,2,0);
		for(int i=0;i<400;i++) add_edge(i,501,2,0);
		for(int i=0;i<400;i++) add_edge(i,i+1,2,0);
		cout << mincost_maxflow(500,501,2)*-1 << endl;
	}
}


Measured memory_bytes: 3320
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int[] array = new int[n];

        for(int i = 0; i < n; i++){
            array[i] = scanner.nextInt();
        }

        for(int i = n-1; i > 0; i--){
            System.out.print(array[i] + " ");
        }
        System.out.println(array[0]);
        scanner.close();
    }
}



Measured memory_bytes: 26328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

int lcm(int a, int b){
   return a * b / gcd(a, b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    if(a[n-1]<k){
        cout << "IMPOSSIBLE" << "\n";
        return 0;
    }
    bool ok=false,ok1=false;
    ll x=a[0];
    rep(i,n){
        x=gcd(a[i],x);
    }
    rep(i,n){
        if(a[i]%x!=0) ok=true;
        if(a[i]%2!=0) ok1=true;
    }
    if(ok && ok1){
        cout << "POSSIBLE" << "\n";
        return 0;
    }
    else{
    if(k%x==0){
            cout << "POSSIBLE" << "\n";
            return 0;
        }else{
            cout << "IMPOSSIBLE" << "\n";
            return 0;
        }
    }
}   

Measured memory_bytes: 3956
#pragma once

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define ooi 1000000007

using namespace std;
string S;
long long int N, A, B ,X,M;
long long int a[100002];
bool b[100002] = {};
long long int myMax,myMin;
long long int result=0;




int main() {
	cin >>N>>M;
	A = 1;
	if (N == M) {
		for (int i = N; i >0; i--) {
			A *= i;
			A %= ooi;
		}
		for (int i = M; i >0; i--) {
			A *= i;
			A %= ooi;
		}
		A *= 2;
		A %= ooi;
		cout << A << endl;
	}
	else if (N + 1 == M) {
		for (int i = N; i >0; i--) {
			A *= i;
			A %= ooi;
		}
		for (int i = M; i >0; i--) {
			A *= i;
			A %= ooi;
		}
		cout << A << endl;
	}
	else if (M + 1 == N) {
		for (int i = N; i >0; i--) {
			A *= i;
			A %= ooi;
		}
		for (int i = M; i >0; i--) {
			A *= i;
			A %= ooi;
		}
		cout << A<<endl;
	}
	else {
		cout << 0 << endl;
	}


	return 0;
}




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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll  int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e4+2;

//vector<ll>dp[N];
vector<ll>v;
int main()
{
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        ll d,ti,s;
        cin>>d>>ti>>s;
        ll cnt=d/s;
        if(d%s)
            cnt++;
        if(cnt<=ti)
            cout<<"Yes"<<"\n";
        else
            cout<<"No"<<"\n";
    }

    return 0;
}


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

#define ll long long
#define vi vector<long long>
#define endl "\n"

int main()
{
	int n;
	ll w;
	cin>>n>>w;
	vector<int>  a(n),b(n);
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
  vector<vi > dp(n, vi(w+1));
  for(ll k=0;k<w+1;k++)
    {
    	if(k-a[0]>=0)
    		dp[0][k]=b[0];
    }

  for(ll i=1;i<n;i++)
  {
  	for(ll j=0;j<w+1;j++)
  	{
  		if(j-a[i]>=0)
  		dp[i][j]=max(dp[i-1][j],b[i]+dp[i-1][j-a[i]]);
  	else
  		dp[i][j]=dp[i-1][j];
  	}
  }
  cout<<dp[n-1][w]<<endl;
	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);

using namespace std;

const int MOD = 1e9 + 7;

typedef long long ll;

ll bin_exp(ll a, ll b, ll mod) {
  if (b == 0) {
    return 1;
  }
  ll temp = bin_exp(a, b / 2, mod);
  ll ans;
  if (b % 2 == 0) {
    ans = (temp * temp) % mod;
  } else {
    ans = (temp * temp) % mod;
    ans = (ans * a) % mod;
  }
  return ans;
}

int32_t main() {
  ll n;
  cin >> n;
  ll ans;
  ans = bin_exp(10, n, MOD);  // total
  ans -= bin_exp(9, n, MOD);  // without 1
  ans = (ans + MOD) % MOD;
  ans -= bin_exp(9, n, MOD);  // without 0
  ans = (ans + MOD) % MOD;
  ans += bin_exp(8, n, MOD);  // without both 0 and 1
  ans = (ans + MOD) % MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3604
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
#define N 100001
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}
*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
template <class x>
void max(x &a,x &b)
{
	return (a>=b?a:b);
}
template <class x>
void min(x &a,x &b)
{
	return (a>=b?b:a);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll y,m,d;
	char a,b;
	cin>>y>>a>>m>>b>>d;
	if(m<4)
	{
		cout<<"Heisei";
	}
	else if(m==4&&d<=30)
	{
		cout<<"Heisei";
	}
	else
	{
		cout<<"TBD";
	}

	return 0;
}


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

typedef long long LL;

const int maxn=200020;
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a, b, c = [], [], []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(int(input()))

for i in range(n):
    r = 0
    for j in range(m):
        r += a[i][j] * b[j]
    print(r)



Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vv;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
vi to[1000];
int can[1000][1000][2];

void dfs0(int u, int st = -1, int en = -1) {
  if (en == -1) {
    for (int i = 0; i < to[u].size(); i++) {
      int ku = to[u][i];
      if (can[u][ku][0] != -1) continue;
      can[u][ku][0] = i;
      dfs0(ku, u, i);
    }
    return;
  }
  for (int i = 0; i < to[u].size(); i++) {
    int ku = to[u][i];
    if (ku == st) continue;
    if (can[st][ku][0] != -1) continue;
    can[st][ku][0] = en;
    dfs0(ku, st, en);
  }
  return;
}

void dfs1(int u, int st = -1, int en = -1) {
  if (en == -1) {
    for (int i = to[u].size() - 1; i >= 0; i--) {
      int ku = to[u][i];
      if (can[u][ku][1] != -1) continue;
      can[u][ku][1] = i;
      dfs1(ku, u, i);
    }
    return;
  }
  for (int i = to[u].size() - 1; i >= 0; i--) {
    int ku = to[u][i];
    if (ku == st) continue;
    if (can[st][ku][1] != -1) continue;
    can[st][ku][1] = en;
    dfs1(ku, st, en);
  }
  return;
}

int main() {
  rep(i, 1000) rep(j, 1000) rep(k, 2) can[i][j][k] = -1;
  int n, m;
  cin >> n >> m;
  vv ee;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    ee.push_back({a, b});
    to[a].push_back(b);
  }
  vector<bool> fin(n, false);
  for (vi e : ee) {
    for (int u : e) {
      if (fin[u] == false) {
        fin[u] = true;
        dfs0(u);
        dfs1(u);
      }
    }
    int u = e[0], v = e[1];
    bool b0 = (can[u][v][0] == can[u][v][1]);
    bool b1 = (can[v][u][0] + can[v][u][1] == -2);
//    cout << can[u][v][0] << " " << can[u][v][1] << endl;
    if (b0 == b1)
      puts("same");
    else
      puts("diff");
  }
  return 0;
}


Measured memory_bytes: 22444
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 100000000000007LL
#define ll long long
using namespace std;
ll dp[610][9],sum[610];
ll amari[610];
signed main(){
	int k;
	cin>>k;
	for(int i=1;i<=8;i++){
		dp[1][i]=1;
	}
	for(int i=2;i<=600;i++){
		dp[i][1] = 1;
		for(int j=2;j<=8;j++){
			dp[i][j]=dp[i][j-1]+dp[i-1][j];
		}
	}
	/* for(int i=1;i<=20;i++){
		cout<<i<<": ";
		for(int j=1;j<=8;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	} */
	sum[1] = dp[1][8];
	for(int i=2;i<=600;i++){
		sum[i] = sum[i-1] + dp[i][8];
	}
	string str;
	int start = 1;
	for(int i=1;i<=600;i++){
		if(sum[i] <= k)start = i;
	}
	k = k - sum[start];
	for(int i=start;i>=1;i--){
		amari[i] = k / dp[i][8];
		k %= dp[i][8];
		//cout<< amari[i] << " "<< k << endl;
	}
	for(int i=start;i>=1;i--){
		for(int j=0;j<amari[i];j++){
			str += 'F';
		}
		str += "FESTIVAL";
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String str=sc.next();
			int cnt=0;
			for(int i=0;i<str.length();){
				cnt++; char now=str.charAt(i);
				while(i<str.length() && str.charAt(i)==now) i++;
			}
			System.out.println(cnt-1);
		}
	}
}

Measured memory_bytes: 24916
#include<cstdio>
#include<vector>
#define mod 1000000007
using namespace std;
int n,c[200001],dp[200001],sum[200000]={},l[200001];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
    }
    c[n]=100000000;
    dp[0]=1;
    for(int i=0;i<n;i++){
        dp[i+1]=dp[i];
        dp[i+1]%=mod;
        if(i==0||c[i-1]!=c[i]){
            l[c[i]]=i;
            dp[i+1]+=sum[c[i]];
            dp[i+1]%=mod;
        }
        if(c[i]!=c[i+1]){
            sum[c[i]]+=dp[l[c[i]]];
            sum[c[i]]%=mod;
        }
    }
    printf("%d\n",dp[n]);
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> grid(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }
    int n = 0;
    bool flag = true;
    typedef pair<int, int> index;

    vector<pair<index, index>> process;
    for (int i = 0; i < h; ++i) {
        if (flag) {
            for (int j = 0; j < w; ++j) {
                if (grid[i][j] % 2 == 1) {
                    if (j == w - 1) {
                        if (i != h - 1) {
                            index from(i + 1, j + 1);
                            index to(i + 1 + 1, j + 1);
                            grid[i][j] -= 1;
                            grid[i + 1][j] += 1;
                            ++n;
                            process.push_back(pair<index, index>(from, to));
                        }
                    } else {
                        index from(i + 1, j + 1);
                        index to(i + 1, j + 1 + 1);
                        grid[i][j] -= 1;
                        grid[i][j + 1] += 1;
                        ++n;
                        process.push_back(pair<index, index>(from, to));
                    }
                }
            }
        } else {
            for (int j = w - 1; j >= 0; --j) {
                if (grid[i][j] % 2 == 1) {
                    if (j == 0) {
                        if (i != h - 1) {
                            index from(i + 1, j + 1);
                            index to(i + 1 + 1, j + 1);
                            grid[i][j] -= 1;
                            grid[i + 1][j] += 1;
                            ++n;
                            process.push_back(pair<index, index>(from, to));
                        }
                    } else {
                        index from(i + 1, j + 1);
                        index to(i + 1, j - 1 + 1);
                        grid[i][j] -= 1;
                        grid[i][j - 1] += 1;
                        ++n;
                        process.push_back(pair<index, index>(from, to));
                    }
                }
            }
        }
        flag = !flag;
    }
    cout << n << endl;
    for (auto elem : process) {
        cout << elem.first.first << " " << elem.first.second << " " << elem.second.first << " " << elem.second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 5236
a, b, c = gets.chomp.split.map(&:to_i)
k = gets.chomp.to_i

while (a >= b && k > 0) do
  b = b * 2
  k = k - 1
end

while (b >= c && k > 0) do
  c = c * 2
  k = k - 1
end

if (a < b && b < c)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14276
map = ["qwertasdfgzxcvb".chars.to_a, "yuiophjklnm".chars.to_a]

loop do
  s = gets.chomp
  break if s=='#'

  k = s.chars.map{|x| map[0].include?(x) ? 1 : 2}.join
  puts k.scan(/12/).size + k.scan(/21/).size
end

Measured memory_bytes: 8808
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        } 
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  string ans;
  if(a == 1){
    if(a == b) ans = "Draw";
    else ans = "Alice";
  }
  else if(b == 1) ans = "Bob";
  else if(a == b) ans = "Draw";
  else if(a > b) ans = "Alice";
  else ans = "Bob";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
	ans1="node "+str(i+1)+": "
	ans2="key = "+str(a[i])+", "
	if (i+1)//2>=1:
		ans3="parent key = "+str(a[(i+1)//2-1])+", "
	else:
		ans3=""
	if (i+1)*2<=n:
		ans4="left key = "+str(a[(i+1)*2-1])+", "
	else:
		ans4=""
	if (i+1)*2+1<=n:
		ans5="right key = "+str(a[(i+1)*2])+", "
	else:
		ans5=""
	print(ans1+ans2+ans3+ans4+ans5)




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

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
const int INF = numeric_limits<int>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
#define ALL(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(b); a > l(c); a--)

// #define ONLINE_JUDGE
#if defined ONLINE_JUDGE
const bool enable_log = false;
#else
const bool enable_log = true;
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(enable_log) ? (void) 0 : VoidStream() & cerr

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  l n;
  while (cin >> n) {
    vl counts(26, numeric_limits<l>::max());
    while (n--) {
      string s; cin >> s;
      vl sc(26);
      for (char c : s) sc[c - 'a']++;
      F(i, 0, 26) counts[i] = min(counts[i], sc[i]);
    }
    F(i, 0, 26) F(j, 0, counts[i]) cout << (char)('a' + i);
    cout << '\n';
  }
}


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

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

	int c[s.size()];
	for (int i = 0; i < s.size(); i++) { c[i] = (int)(s.at(i) - '0'); }

	int u = c[0] * 10 + c[1];
	int d = c[2] * 10 + c[3];

	bool u_mm_flag = false;
	bool d_mm_flag = false;

	if (1 <= u && u <= 12) u_mm_flag = true;
	if (1 <= d && d <= 12) d_mm_flag = true;

	string ans;

	if (u_mm_flag && d_mm_flag) { 
		ans = "AMBIGUOUS";
	}
	else if (!u_mm_flag && d_mm_flag) {
		ans = "YYMM";
	}
	else if (u_mm_flag && !d_mm_flag) {
		ans = "MMYY";
	}
	else {
		ans = "NA";
	}
	
	cout << ans << endl;

	return 0;
}

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

ll maxval(ll w[],ll v[],ll i,ll n,ll W,ll V,ll s[100005][105])
{
  if(i==n)
  {
    //cout<<V<<endl;
    return V;
    
  }
  else
  {
    //cout<<"i= "<<i<<endl;
      ll r1,r2;
      if(s[W][i+1]==-1)
      {
        r1=maxval(w,v,i+1,n,W,V,s);
        s[W][i+1]=r1-V;
      }
      else
      {
        r1=s[W][i+1]+V;
      }
      //cout<<"i= "<<i<<" "<<"nt= "<<r1<<endl;
      if(W-w[i]<0)
      {
        // if(i==0)
        // {
        //   for(int j=0;j<8;j++)
        //   {
        //     for(int k=0;k<5;k++)
        //       cout<<s[j][k]<<" ";
        //     cout<<endl;
        //   }
        // }
        // cout<<"i= "<<i<<" "<<"t=-1"<<endl;
        return r1;
      }
      else
      {
          if(s[W-w[i]][i+1]==-1)
          {
            r2=maxval(w,v,i+1,n,W-w[i],V+v[i],s);
            s[W-w[i]][i+1]=r2-V-v[i];
          }
          else
          {
            r2=s[W-w[i]][i+1]+V+v[i]; 
          }
         //cout<<"i= "<<i<<" "<<"t= "<<r2<<endl;
        // if(i==0)
        // {
        //   for(int j=0;j<8;j++)
        //   {
        //     for(int k=0;k<6;k++)
        //       cout<<s[j][k]<<" ";
        //     cout<<endl;
        //   }
        // }
        
          return max(r1,r2);
        
      }
  }
}
int main()
{
  ll n,W;
  cin>>n>>W;
  ll w[n],v[n],i;
  
  for(i=0;i<n;i++)
  {
    cin>>w[i]>>v[i];
  }
  ll s[100005][105];
  memset(s,-1,sizeof(s));
  //cout<<s[0][0];
  //cout<<n<<endl;
  ll a=maxval(w,v,0,n,W,0,s);
  cout<<a;
  return 0;
}


Measured memory_bytes: 82432
from queue import Queue
goal = [1,2,3,4,5,6,7,8,0]
SIZE = 3
cmds = ['up','down','left','right']

def puz_hash(p):
    hash = ''.join(map(str, p))
    return hash

def up(p,z,c):
    if z >= 3 and c != 'down':
        p[z], p[z - 3] = p[z - 3], p[z]
    return p

def down(p,z,c):
    if z <= 5 and c != 'up':
        p[z], p[z + 3] = p[z + 3], p[z]
    return p

def left(p,z,c):
    if z % 3 != 0 and c != 'right':
        p[z], p[z - 1] = p[z - 1], p[z]
    return p

def right(p,z,c):
    if z % 3 != 2 and c != 'left':
        p[z], p[z + 1] = p[z + 1], p[z]
    return p

def search(p):
    q = Queue()
    # init
    q.put((p,0,''))
    visited = set()#[]

    while True:
        if(q.empty()):
            return None
        current_p, current_d, prev_move = q.get()
        current_z = current_p.index(0)
        current_p_hash = puz_hash(current_p)

        if(current_p_hash in visited):
            continue
        if(current_p_hash == goal_hash):
            return current_d
        visited.add(current_p_hash)

        next_p = current_p.copy()
        next_p = up(next_p, current_z, prev_move)
        if(next_p.index(0) != current_z):
            q.put((next_p, current_d+1, cmds[0]))

        next_p = current_p.copy()
        next_p = down(next_p, current_z, prev_move)
        if(next_p.index(0) != current_z):
            q.put((next_p, current_d+1, cmds[1]))

        next_p = current_p.copy()
        next_p = left(next_p, current_z, prev_move)
        if(next_p.index(0) != current_z):
            q.put((next_p, current_d+1, cmds[2]))

        next_p = current_p.copy()
        next_p = right(next_p, current_z, prev_move)
        if(next_p.index(0) != current_z):
            q.put((next_p, current_d+1, cmds[3]))

        # kkkkkusso jikan kakaru
        # for cmd in cmds:
        #     next_p = current_p.copy()
        #     next_p = get_next_states(cmd,next_p,current_z,prev_move)#eval(cmd)(next_p, current_z, prev_move)
        #     if(next_p is not None):
        #         print(current_d+1)
        #         q.put((next_p, current_d+1, cmd))

p = []
for i in range(3):
    p.extend(map(int, input().split()))

goal_hash = puz_hash(goal)
res = search(p)
print(res)



Measured memory_bytes: 37472
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
using namespace std;
string s;
int main()
{
    //freopen("in.txt","r",stdin);
    while(cin>>s)
    {
        if(s=="Sunny")
            cout<<"Cloudy"<<endl;
        if(s=="Cloudy")
            cout<<"Rainy"<<endl;
        if(s=="Rainy")
            cout<<"Sunny"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define pi M_PI

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

  FOR(i, 1, n + 1){
    int flag = 0;
    if(i % 3 == 0) cout << " " << i;
    else{
      int x = i;
      while(x){
        if(x % 10 == 3) flag++;
        x /= 10;
      }
    }
    if(flag) cout << " " << i;
  }
  cout << endl;
}



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

bool isPrime(int x) {
        if(x == 2) return true;
        else if(x < 2 || x % 2 == 0) return false;
        for(int i = 3; i <= sqrt(x); i += 2) {
                if(x % i == 0) return false;
        }
        return true;
}

int main() {
        int x, n, r;
        r = 0;
        cin >> n;
        for(int i = 0; i < n; i++) {
                cin >> x;
                if(isPrime(x)) r++;
        }
        cout << r << endl;
        return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int L = A+B;
  int R = C+D;
  if(L==R){
    cout << "Balanced";
  }else{
    if(L>R){
      cout << "Left";
    }else{
      cout << "Right";
    }
  }
}

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

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl

long long count(vector<int>& a) {
    long long sol = 0;
    for (int i = 1; i < a.size(); i++)
        sol += abs(a[i] - a[i - 1]);

    return sol;
}


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

    int n; 
    cin >> n;

    vector<int> a(n);

    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());

    vector<int> b(n - n % 2);

    for (int i = 0; i < n / 2; i++) {
        b[2 * i + 1] = a[i];
        b[2 * i] = a[(n + 1) / 2 + i];
    }
    
    if (n % 2 == 0) cout << count(b);
    else {
        vector<int> b1, b2;
        b1 = b;
        b1.push_back(a[n / 2]);

        b2 = b;
        reverse(b2.begin(), b2.end());
        b2.push_back(a[n / 2]);
        
        cout << max(count(b1), count(b2));
    }


    return 0;
}



Measured memory_bytes: 2168
#include<stdio.h>
int main(){
  int n,a[200],i,count=0,end=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  while(1){
    for(i=0;i<n;i++){
      if(a[i]%2==1){end=1;}
      a[i]/=2;
    }
    if(end==1){break;}
    count++;
  }
  printf("%d\n",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  ll A,B;
  char op;
  cin >> A >> op >> B;

  if(op == '+'){

cout << A + B << endl;

  }else{

cout << A - B << endl;
  }

    return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int> A;
	for (int i = 0; i < n; i++) {
		int a;  cin >> a;
		A.push_back(a);
	}

	int maxv = *max_element(A.begin(), A.end());
	int minv = *min_element(A.begin(), A.end());

	cout << maxv - minv << endl;

	return 0;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> arr(m,0);
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
    }
    int sum=0;
    for(int i=0;i<m;i++)
    sum+=arr[i];
    
    if(sum>n)
    cout<<-1<<endl;
    
    else
    {
        int ans= n-sum;
        cout<<ans<<endl;
    }
    
    
}

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

int n, a, b, c, d;
string s;
vector<int> v, w;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> a >> b >> c >> d >> s;
	--a; --b; --c; --d;
	for(size_t i=0; i<s.size()-1; ++i)
		if(s.substr(i, 2) == "##") v.push_back(i);
	for(size_t i=1; i<s.size()-1; ++i)
		if(s.substr(i-1, 3) == "...") w.push_back(i);
	for(size_t i=0; i<v.size(); ++i)
		if(a < v[i] && v[i] < max(c, d)){
			cout << "No\n";
			return 0;
		}
	if(c < d){
		cout << "Yes\n";
		return 0;
	}
	for(size_t i=0; i<w.size(); ++i)
		if(b <= w[i] && w[i] <= d){
			cout << "Yes\n";
			return 0;
		}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>

using namespace std;


int main() {

	long long n;
	cin >> n;
	n--;
	long long markn = n;
	long long limits = 26;
	char* a = new char[20];

	
	for (long long i = 1; ; i++) {
		if (markn < limits) {
			for (long long j = 0; j < i; j++) {
				*(a + j) = 96 + n % 26 + 1;
				n = n / 26 - 1;
			}

			for (long long j = i - 1; j >= 0; j--) {
				cout << *(a + j);
			}
			cout << endl;

			return 0;
		}

		markn -= limits;
		limits = limits * 26;
	}
	

	return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ans = 0, n = (int)s.length();
    int left = 0, right = n-1;
    while(left < right){
        if(s[left] == s[right]){
            left++; right--;
            continue;
        }else if(s[left] == 'x'){
            left++;
            ans++;
        }else if(s[right] == 'x'){
            right--;
            ans++;
        }else{
            ans = -1;
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 512
#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 10001

int main()
{
	while (1) {
		int n, x, cou[10] = { 0 };
		char m[10][MAX];
		scanf_s("%d", &n);
		if (n == 0) break;
		for (int i = 0; i < 10; ++i) { m[i][0] = '-'; }
		for (int i = 0; i < n; ++i) {
			scanf_s("%d", &x);
			m[x][cou[x]] = '*';
			++cou[x];
		}
		for (int i = 0; i < 10; ++i) { 
			if (cou[i] == 0)++cou[i];
			m[i][cou[i]] = '\0';
		}
		for (int i = 0; i < 10; ++i) {
			printf("%s\n", m[i]);
		}
	}

}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }

    int mx = 0;
    for (auto x : mp) mx = max(mx, x.se);

    vstr S;
    for (auto x : mp) if (x.se == mx) S.push_back(x.fi);

    sort(all(S));
    for (auto s : S) cout << s << endl;
    return 0;
}

Measured memory_bytes: 26868
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		if(n%1000)
		{
			cout<<1000-(n%1000);
		}		
		else
		{
			cout<<0;
		}
    }
    return 0;
}


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

//簡単なすごろくの問題
//サイコロの目と進んだ先の数だけ移動させてやればよい

int main(){
	int n, m;
	int field[1001];
	int dice[1001];
	int location;
	int times;

	while(cin >> n >> m, n || m){
		location = 1;
		times = 0;
		for(int i=1; i <= n; i++) cin >> field[i];
		for(int i=1; i <= m; i++) cin >> dice[i];

		while(location < n){
			times++;
			location += dice[times];
			if(n <= location) break;
			location += field[location];
		}
		cout << times << endl;
	}
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cstdlib>
using namespace std;
char s[10];
struct node {
	int key;
	node *p,*left,*right;
};
node *NIL,*root=NIL;
void ins (int key) {
	node *p=NIL,*cur=root,*n=(node *)malloc(sizeof(node));
	n->key=key;
	n->left=NIL;
	n->right=NIL;
	while (cur!=NIL) {
		p=cur;
		if (key<cur->key) cur=cur->left;
		else cur=cur->right;
	}
	n->p=p;
	if (p==NIL) root=n;
	else if (key<p->key) p->left=n;
	else p->right=n;
}
void preOrder (node *u) {
	if (u==NIL) return;
	printf (" %d",u->key);
	preOrder (u->left);
	preOrder (u->right);
}
void inOrder (node *u) {
	if (u==NIL) return;
	inOrder (u->left);
	printf (" %d",u->key);
	inOrder (u->right);
}
int main () {
	int m;
	scanf ("%d",&m);
	for (int i=0;i<m;i++) {
		scanf ("%s",s);
		if (s[0]=='i') {
			int key;
			scanf ("%d",&key);
			ins (key);
		} else {
			inOrder (root);
			printf ("\n");
			preOrder (root);
			printf ("\n");
		}
	}
    return 0;
}


Measured memory_bytes: 26036
#include<bits/stdc++.h>
using namespace std;
const int maxn=100;
int n,m,c,b[maxn],ans;
int main()
{
	scanf("%d%d%d",&n,&m,&c);
	for(register int i=1;i<=m;i++)
		scanf("%d",&b[i]);
	for(register int i=1,sum;i<=n;i++)
	{
		sum=c;
		for(register int j=1,x;j<=m;j++)
		{
			scanf("%d",&x);
			sum+=b[j]*x;
		}
		if(sum>0)
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll min3(ll a, ll b, ll c){
    if(a < b){
        if(b < c) return a;
        else{
            if(a < c) return a;
            else return c;
        }
    }else{
        if(b < c) return b;
        else return c;
    }
}


int main(){
    string s,t; cin >> s >> t;
    ll S = s.size();
    ll T = t.size();
    ll dp[S+1][T+1];
    rep(i,S+1) dp[i][0] = i;
    rep(j,T+1) dp[0][j] = j;
    rep(i,S){
        rep(j,T){
            ll c = (s[i] == t[j]) ? 0 : 1;
            dp[i+1][j+1] = min3(dp[i][j+1]+1, dp[i+1][j]+1, dp[i][j]+c);
        }
    }
    cout << dp[S][T] << endl;
}


Measured memory_bytes: 11012
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int X = sc.nextInt();
    if(X>=A&&X<=A+B){
     System.out.println("YES");
    }else{
    	System.out.println("NO");
    }
  }
}

Measured memory_bytes: 22996