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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long double ld;

const int MAX = 501,IINF = INT_MAX;
const ld LDINF = 1e100;
int H,W,sx,sy,gx,gy;
ld mincost[MAX][MAX][2]; // mincost[][][0] => from start, [1] = > from star
char c[MAX][MAX];
bool ban[MAX][MAX];
vector<int> star,plane;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

inline bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; }

inline void bfs(vector<int> sp,vector<int> Forbidden,int type){
  rep(i,H)rep(j,W) mincost[i][j][type] = LDINF, ban[i][j] = false;
  queue<int> que;
  rep(i,(int)sp.size()) que.push(sp[i]), mincost[sp[i]/W][sp[i]%W][type] = 0;
  rep(i,(int)Forbidden.size()) ban[Forbidden[i]/W][Forbidden[i]%W] = true;

  while(!que.empty()){
    int cur = que.front(); que.pop();

    rep(i,4){
      int nx = cur % W + dx[i], ny = cur / W + dy[i];
      if( c[ny][nx] == '#' ) continue;
      if( ban[ny][nx] ) continue;
      if( mincost[ny][nx][type] == LDINF ) {
        mincost[ny][nx][type] = mincost[cur/W][cur%W][type] + 1;
        que.push(nx+ny*W);
      }
    }

  }

}

bool check(ld E){
  ld T = 0;

  rep(i,(int)plane.size()){
    int x = plane[i] % W, y = plane[i] / W;
    T += min(mincost[y][x][0],mincost[y][x][1]+E);
  }

  ld len = plane.size();
  return len * E > T;
}

int main(){
  cin >> W >> H;
  rep(i,H)rep(j,W){
    cin >> c[i][j];
    if( c[i][j] == 's' ) sx = j, sy = i, c[i][j] = '.';
    if( c[i][j] == 'g' ) gx = j, gy = i;
    if( c[i][j] == '*' ) star.push_back(j+i*W);
    if( c[i][j] == '.' ) plane.push_back(j+i*W);
  }

  vector<int> sp,forbidden;
  sp.push_back(gx+gy*W);
  forbidden = star;
  forbidden.push_back(gx+gy*W);
  bfs(sp,forbidden,0);

  sp = star;
  forbidden.push_back(gx+gy*W);
  //forbidden.clear();
  bfs(sp,forbidden,1);

  ld L = 0, R = 1e160, M = 0;
  rep(i,1020){
    M = ( L + R ) * (ld)0.5;
    if( check(M) ) R = M;
    else           L = M;
  }

  cout << setiosflags(ios::fixed) << setprecision(20) << min((ld)mincost[sy][sx][0],(ld)mincost[sy][sx][1]+L) << endl;

  return 0;
}

Measured memory_bytes: 10456
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    string s;
    s = to_string(n);

    rep(i, s.size()){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll>p(a),q(b),r(c);
  priority_queue<ll,vector<ll>,greater<ll>>pq,pq2,pq3;
  rep(i,a)cin>>p[i];
  rep(i,b)cin>>q[i];
  rep(i,c)cin>>r[i],pq3.emplace(r[i]);
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  rep(i,x){
    pq.emplace(p[i]);
  }
  rep(i,y)pq2.emplace(q[i]);
  while(!pq3.empty()){
    ll s=-1;
    if(!pq.empty())s=pq.top();
    ll t=-1;
    if(!pq2.empty())t=pq2.top();
    ll v=pq3.top();
    pq3.pop();
    //cerr<<s<<t<<v<<endl;
    if(s<=t){
      if(s<v){
        pq.pop();
        pq.emplace(v);
      }
    }
    else{
      if(t<v){
        pq2.pop();
        pq2.emplace(v);
      }
    }
  }
  ll sum=0;
  vector<ll>vv,vvv;
  while(!pq.empty()){
    vv.pb(pq.top());
    pq.pop();
  }
  while(!pq2.empty()){
    //cerr<<pq2.top()<<endl;
    vvv.pb(pq2.top());
    pq2.pop();
  }
  sort(vv.rbegin(),vv.rend());
  sort(vvv.rbegin(),vvv.rend());
  rep(i,x)sum+=vv[i];
  rep(i,y)sum+=vvv[i];
  cout<<sum;
}

int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);
    cout<<fixed<<setprecision(15);
  solve();
    return 0;
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define X first
#define Y second
#define maxn 100002
#define eps 0.0000001
#define inf 1e9
#define pb push_back
#define maxD 15
#define ll long long
using namespace std;
ll n,k;
ll a[maxn];
ll gcd(ll x, ll y){
	if(x==0) return y;
	return (gcd(y%x,x));
}
main(){
	cin >> n >> k;
	ll g;
	ll ma = -2e9;
	For(i,1,n) {
		scanf("%d",a+i);
		if(i==1) g = a[1];
		else g = gcd(g,a[i]);
		ma=  max(ma,a[i]);
	}
//	cout << g;
	string ans = "IMPOSSIBLE";
	For(i,1,ma/g){		
		if(k==i*g){
			ans = "POSSIBLE";
			break;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 1;
int n , m, k , q;
int a[N];
void upd(int l , int r){
	if(l > r)return;
	a[l]--; a[r + 1]++;
}
main(){
	cin >> n >> m;
	multiset < int > st;
	for(int i = 1 ; i <= n; i++){
		int x;
		cin >> x;
		st.insert(x);
	}
	while(m--){
		int u = *st.rbegin();
		st.erase(st.find(u));
		st.insert(u / 2);
	}
	int ans = 0;
	for(auto to : st)
		ans += to;
	cout << ans;	
}

Measured memory_bytes: 4992
#include <stdio.h>

int f[45];

int fibonacci(int n)
{ 
  if (n == 0 || n == 1)
    return f[n] = 1;
  if (f[n] != 0)
    return f[n];
  return f[n] = fibonacci(n-2)+fibonacci(n-1);
}

int main()
{
  int n, i;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    f[i] = 0;
  printf("%d\n",fibonacci(n));

  return 0;
}



Measured memory_bytes: 2108
use std::thread;

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_s = input.next().unwrap();

    let ans = in_s
        .chars()
        .zip("CODEFESTIVAL2016".chars())
        .filter(|&(c, a)| c != a)
        .count();
    println!("{:?}", ans);
}


Measured memory_bytes: 8572
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007
 
using namespace std;
 
//union-find
 
int par[100005]; //parents
int hukasa[100005]; //depth
 
// search root
int find (int x){
    if (par[x]<0) return x;
    else return par[x]=find(par[x]);
}
//xとyの集合を併合
 
int setsize(int n){
    return -par[n];
}
 
void unit(int x,int y){
    x=find(x);
    y=find(y);
    if (x==y) return;
    
    if (hukasa[x]<hukasa[y]){
        par[y]+=par[x];
        par[x]=y;
    }
    else {
        par[x]+=par[y];
        par[y]=x;
        if (hukasa[x]==hukasa[y]) hukasa[x]++;
    }
    
}
 
//xとyは同じ集合に入るか？
 
bool same(int x,int y){
    return find(x) == find(y);
}
 
 
 
int main(){
    int n,m;
    cin >> n >> m;
    
    for (int i=1;i<=n;i++){
        par[i]=-1;
        hukasa[i]=1;
    }
    
    int p[n+10];
    for (int i=1;i<=n;i++) cin >> p[i];
    vector<pair<int,int>> pairs(m+10);
    for (int i=1;i<=m;i++) {
        cin >> pairs[i].first >> pairs[i].second;
        unit(p[pairs[i].first],p[pairs[i].second]);
    }
    int ans=0;
    for (int i=1;i<=n;i++) if(same(i,p[i])==1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 2176
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
 
import qualified Data.Array as A
import qualified Data.Map as M
import qualified Data.List as L
 
main = print . solve . map read . lines =<< getContents
 
f b n
    | n < b     = n
    | otherwise = let (dv, md) = divMod n b in md + f b dv
 
solve [n, s]
    | n == s    = n + 1
    | s >  n    = -1
    | otherwise = ans where
        en = maximum . takeWhile (\i -> i * i <= n) $ [1 .. ]
        ans = case L.find ((==) s . snd) . map (\i -> (i, f i n)) $ [2 .. en] of
            Just (i, _) -> i
            Nothing -> if en > 0 then ans' else -1 where
                ans' = case L.find ((==) s . snd) . map (\i -> (i, f i n)) $ bs of
                    Just (j, _) -> j
                    Nothing -> -1
                bs = map ((+) 1 . fst) . filter ((==) 0 . snd) . map (divMod (n - s)) $ reverse [1 .. en]
 

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

// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H;
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
template<typename T> void minself(T &a, T b){
	a=min(a,b);
}
template<typename T> void maxself(T &a, T b){
	a=max(a,b);
}
// End Template IO/Utility

int main(){
	int N;
	long long res=0L;
	cin>>N;
	for(int i=1;i<=N;i++)
		if(i%3 && i%5)
			res+=i;
	cout<<res;
}


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  int Ans = 0;
  rep(i, N) {
    int H;
    cin >> H;
    if (K <= H) Ans++;
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using product = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;

int main()
{
    ll N,M;
    cin>>N>>M;
    vll P(M);
    vll Y(M);
    for(ll i=0;i<M;i++)
    {
        cin>>P[i]>>Y[i];
        --P[i];
    }
    vvll vals(N);
    for(ll i=0;i<M;i++)vals[P[i]].emplace_back(Y[i]);
    for(ll i=0;i<N;i++)sort(vals[i].begin(),vals[i].end());

    for(ll i=0;i<M;i++)
    {
        ll v=P[i];
        printf("%06d",v+1);

        ll id=lower_bound(vals[v].begin(),vals[v].end(),Y[i])-vals[v].begin();
        printf("%06d\n",id+1);
    }
}

Measured memory_bytes: 10256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long pow(long long n,long long k,long long q){
	long long res=1;
	while(k){
		if(k%2)res=res*n%q,k--;
		k/=2;
		n=n*n%q;
	}return res;
}
int main(){
	int n,k;cin>>n>>k;
	printf("%lld\n",pow(k,n,1e9+7));
	return 0;
}



Measured memory_bytes: 3192
today_weather = input()

if today_weather == 'Sunny':
    tomorrow_weather = 'Cloudy'
    print(tomorrow_weather)

elif today_weather == 'Cloudy':
    tomorrow_weather = 'Rainy'
    print(tomorrow_weather)

elif today_weather == 'Rainy':
    tomorrow_weather = 'Sunny'
    print(tomorrow_weather)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  ll n, k;

  cin >> n >> k;

  ll a, b, c;

  for (ll i = 1; i <= k; i++){
    if (i == 1){
      a = (n - k - 1 >= 0 ? 0 : 1);
      b = (n - k - 1 >= 0 ? 1 : 0);
      c = max((ll)0, n - k - 1);
    }
    else if (i == 2){
      a = (n - k - 1 >= 0 ? k - 1 : 0);
      b = (b * (k - i + 1) % MOD) * inv(i - 1) % MOD;
      c = (c * (k - i + 1) % MOD) * inv(i - 1) % MOD;

      b = (b * max((ll)0, n - k - i + 1) % MOD) * inv(i - 1) % MOD;
      c = (c * max((ll)0, n - k - i) % MOD) * inv(i) % MOD;
    }
    else {
      a = (a * (k - i + 1) % MOD) * inv(i - 1) % MOD;
      b = (b * (k - i + 1) % MOD) * inv(i - 1) % MOD;
      c = (c * (k - i + 1) % MOD) * inv(i - 1) % MOD;

      a = (a * max((ll)0, n - k - i + 2) % MOD) * inv(i - 2) % MOD;
      b = (b * max((ll)0, n - k - i + 1) % MOD) * inv(i - 1) % MOD;
      c = (c * max((ll)0, n - k - i) % MOD) * inv(i) % MOD;
    }
    cout << (a + 2 * b + c) % MOD << endl;
  }


  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}   


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

string s;

int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(i==s.size()-1){
			if(s[i] == '?') s[i] = 'D';
		} else if(s[i] == '?'){
			if(s[i+1] == 'D' && (i-1 < 0 || s[i-1] == 'D')){
				s[i] = 'P';
			} else {
				s[i] = 'D';
			}
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3764
for i in range(1,301):
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    else:
        a='#'
        b='.'
        print(f'{a*w}')
        for j in range(2,h):
            print(f'{a}{b*(w-2)}{a}')
        print(f'{a*w}')
    print()


Measured memory_bytes: 5624
import sys
input=sys.stdin.buffer.readline
n=int(input())+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return sum(map(int,bin(s)[2:]))
for i,c in enumerate(input()[:-1],n):data[i]=2**(c-97)
for i in range(n-1,0,-1):data[i]=data[i*2]|data[i-~i]
for _ in range(int(input())):
  q,a,b=input().split()
  if q[0]>49:print(query(int(a)-1,int(b)))
  else:update(int(a)-1,2**(b[0]-97))

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

static ll Gcd(ll a, ll b)
{
    return (a < b) ? Gcd(b, a)
         : (b > 0) ? Gcd(b, a % b)
                   : a;
}

static ll Lcm(ll m, ll n)
{
    return (m / Gcd(m,n)) * n;
}

void solve(long long A, long long B, long long C, long long D)
{
    ll a = 0, b = 0, c = 0;
    ll l = Lcm(C, D);
    if (B / C > 0) {
        a = (B / C) - (A / C);
        if (A % C == 0) a++;
    }
    if (B / D > 0) {
        b = (B / D) - (A / D);
        if (A % D == 0) b++;
    }
    if (B / l > 0) {
        c = (B / l) - (A / l);
        if (A % l == 0) c++;
    }
    printf("%lld\n", (B - A + 1) - (a + b - c));
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())

def Eratosthenes(n):
    Primes = [2]
    All = [x for x in range(3, n+1)]
    check = True
    max_check = int((n**(1/2)//1))
    while check:
        if All[0] > max_check:
            return Primes + All[1:]
        All = [x for x in All if x % Primes[-1] != 0]
        Primes.append(All[0])


Primes = Eratosthenes(55555)

Primes_select = [x for x in Primes if x % 5 == 1]
Ans = Primes_select[:n]
ans = [str(x) for x in Ans]
print(' '.join(ans))

Measured memory_bytes: 5528
using System;
using System.Linq;

namespace Program
{
    class D
    {
        static void Main(string[] args)
        {
            int ret = 1;
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0];
            int K = NK[1];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int low = 0, high = 1;
            for(int i = 0; i < N; i++)
            {
                if (A[i] > high)
                {
                    high = A[i];
                }
            }
            while (true)
            {
                if (high - low <= 1)
                {
                    ret = high;
                    break;
                }
                int mid = Floor2(high, low);
                int mintime = 0;
                for (int i = 0; i < N; i++)
                {
                    mintime += (int)Math.Ceiling((double)A[i] / mid)-1;
                }
                if(mintime <= K)
                {
                    high = mid;
                }
                else
                {
                    low = mid;
                }
                
            }


            Console.WriteLine(ret);
        }

        public static int Floor2(int a, int b)
        {

            if ((a + b) % 2 == 0)
            {
                return (a + b) / 2;
            }
            else
            {
                return (a + b - 1) / 2;
            }

        }

    }
}


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

using namespace std;

double recurse(int i, int j, vector<vector<double>> &dp,vector<double> &arr)
{
    //i denotes the number of heads, j denotes the number of items remaining.
    if(i == 0 && j == 0) return 1;
    else if( i > 0 && j == 0) return 0;
    else if(i == 0 && j > 0)
    {
        if(dp[i][j] >= 0) return dp[i][j];
        else
            dp[i][j] = recurse(i,j-1,dp,arr) * (1-arr[j-1]);
        
        return dp[i][j];
    }
    else
    {
        if(dp[i][j] >= 0) return dp[i][j];
        else
            dp[i][j] = recurse(i-1,j-1,dp,arr) * arr[j-1] + recurse(i,j-1,dp,arr) * (1-arr[j-1]);
        
        return dp[i][j];
    }
    
}

int main(int argc, char const *argv[])
{
    int n;
    double temp;
    cin >> n;
    vector<double> arr(n,-1.0);
    //denotes the number of heads remaining on one axis and ith item on second.
    vector<vector<double>> dp(n+1,vector<double>(n+1,-1.0));
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        arr[i] = temp;
    }
    double result = 0.0;
    for(int i = n/2 +1;i <= n ; i++)
    {
        dp[i][n] = recurse(i,n,dp,arr); 
        result += dp[i][n];
    }
    cout <<setprecision(11)<< result;
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define debug(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
#define endl "\n"
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> ii;

void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define maxn 100006

int n, h[maxn];
int dp[maxn];

int solve(){
  for(int i=1;i<n;i++){
      dp[i] = dp[i-1] +abs(h[i]-h[i-1]);
      if(i-2>=0){
          dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
      }
  }
  return dp[n-1];
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  cout << solve() << '\n';
  return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int L,R,D; cin >> L >> R >> D;
	int res = 0;
	forn(i,L,R+1){
		if(i%D == 0){
			res++;
		}
		
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int x = sc.nextInt();
      	int[] a =  new int[x];
		int ans = 0; 
		for(int i=0;i<x;i++){
          a[i] = sc.nextInt();
          if( i%2==0 && a[i]%2==1 )
            ans++;
		}
		System.out.println(ans);    	
	}
}

Measured memory_bytes: 27076
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n,x;
  cin>>n>>x;
  vector<ll> a(n);
  r(i,n)cin>>a.at(i);

  ll dif;
  ll cnt=0;
  if(a.at(0)>x){
    cnt+=(a.at(0)-x);
    a.at(0)=x;
  }
  //cout<<cnt<<endl;

  for(int i=1;i<n;i++){
    if(a.at(i)+a.at(i-1)>x){
      dif=a.at(i)+a.at(i-1)-x;
      a.at(i)-=dif;
      cnt+=dif;
    }
  }
  cout<<cnt<<endl;


  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int x=scan.nextInt();
		int y=scan.nextInt();
		int gg=Math.min(x, y);
		int cost=0;
		    //
		cost=Math.min((a*gg+b*gg),gg*c*2);
		
		
		 int xneed=x-gg;	
		 cost+=Math.min(a*xneed,2*c*xneed);
		
		int need=y-gg;
		cost+=Math.min(b*need,2*c*need);
		
		System.out.println(cost);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	vector<int>v(105);
	int sum=0;
	for(int i=0;i<3;i++){
		cin>>v.at(i);
	}
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<2;i++){
		sum+=v.at(i)-v.at(i+1);
	}
	cout<<sum<<endl;

	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	int mul=accumulate(a.begin(),a.end(),a.front(),[](auto a,auto b){return lcm(a,b);});
	int b=accumulate(a.begin(),a.end(),0,[mul](auto a,auto b){return a+mul/b;});
	cout<<fixed<<setprecision(8)<<1.0L*mul/b<<"\n"s;
}



Measured memory_bytes: 3672
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()

    command = [''] * N
    ans = 0
    for i, t in enumerate(T):
        if t == 'r':
            point = P
            command_candidate = 'p'
        elif t == 's':
            point = R
            command_candidate = 'r'
        else:
            point = S
            command_candidate = 's'

        if i >= K and command[i - K] == command_candidate:
            point = 0
            command_candidate = ''
        ans += point
        command[i] = command_candidate
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9964
# coding: utf-8
# Your code here!
N=int(input())

pre_T=0
pre_A=0

def krag(n,m):
    return -(-n//m)


for _ in range(N):
    T,A=map(int,input().split())
    
    if T<pre_T or A<pre_A:
        k=max(krag(pre_T,T),krag(pre_A,A))
        T*=k
        A*=k
    
    pre_T,pre_A=T,A    
print(T+A)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}

int main(){
    ll N; cin>>N;
    ll ans=0;
    N--;
    REP(i,1,N+1) ans+=(N/i);
    cout<<ans<<endl; 
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll c1 = 0, c2 = 0, c3 = 0;
    for(ll i = 0; i < n; i++){
        if(s[i]=='R') c1++;
        if(s[i]=='G') c2++;
        if(s[i]=='B') c3++;
    }
    ll ans = c1*c2*c3;
    ll count = 0;
    for(ll i = 1; i < n; i++){
        for(ll j = i; j < n; j++){
            if(j-i < 0 || j+i >= n) break;
            if(s[j-i]!=s[j] && s[j]!=s[j+i] && s[j-i]!=s[j+i]){
                count++;
                //cout << s[j-1] << " " << s[j] << " " << s[j+1] << endl;
            }
        }
    }
    cout << ans-count << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    bool possible = false;
    for(int i =0; i <= N; i++){
        for(int j =0; j <= N; j++){
            if(4*i + 7*j == N){
                possible = true;
            }
        }
    }
    if(possible) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
res = 0
for i in range(N):
    t = 0
    for j in range(i + 1):
        t += A[0][j]
    for j in range(i, N):
        t += A[1][j]
    res = max(res, t)
print(res)


Measured memory_bytes: 9176
#include <iostream>
//#include <math.h>
#include <set>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
const int maxn = 100000;

int main(){

  int n;
  int cnt_2=0,cnt_4 = 0,cnt_o=0;

  cin >> n;
  rep(i,n){
    int N;
    cin >> N;
    if(N%4==0)cnt_4++;
    else if(N%2==0)cnt_2++;
    else cnt_o++;
  }

  if((cnt_o<=cnt_4)||(cnt_o==0&&cnt_4==0)||(cnt_4+1==cnt_o+cnt_2))cout << "Yes"<<endl;
  else cout << "No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}
struct edge { int to, cost; };


int main() {
	int a, b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	int s = min(x, y)*c*2;
	if (x > y)s += a * (x - y);
	else s += b * (y - x);
	int ans = min({ max(x,y) * c*2,x * a + y * b,s });
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 

		signed main()
		{
			int a,b;
  cin >> a >> b;
  for(int i=0;i<=a;i++){
    int cu = i*2+(a-i)*4;
    if(cu == b){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

		}

Measured memory_bytes: 3640
N = input()
length = len(N)
n = int(N)
n1 = int(N)
S = 0
while(length!=0):
    number = n//(10**(length-1))
    S = S + number
    n = n - number*(10**(length-1))
    length = length - 1
if n1%S==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
from itertools import combinations
from sys import stdin


def main():
    N, M, X = [int(x) for x in stdin.readline().rstrip().split()]
    CAs = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]
    ans = 100100100100100
    for n in range(1, N + 1):
        for comb in combinations(range(1, N + 1), n):
            tmp = [0] * (M + 1)
            for c in comb:
                for i in range(len(tmp)):
                    tmp[i] += CAs[c - 1][i]
            if len([x for x in tmp[1:] if X <= x]) == M:
                ans = min(ans, tmp[0])
    if ans == 100100100100100:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9220
#include<iostream>
using namespace std;
int main(){
  int N,sum=1;
  char c;
  cin >> N;
  string S;
  cin >> S;
  c=S.at(0);
  for(int i=1;i<N;i++){
    if(c!=S.at(i)){
      sum++;
      c=S.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 512
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize, w: usize,
        board: [chars; h]
    }
    let mut board = board;
    for i in 0..h {
        for j in 0..w {
            if board[i][j] == '.' {
                let mut count = 0;
                if i > 0 {
                    if j > 0 && board[i - 1][j - 1] == '#' { count += 1; };
                    if board[i - 1][j] == '#' { count += 1; };
                    if j < w - 1 && board[i - 1][j + 1] == '#' { count += 1; };
                };
                if j > 0 && board[i][j - 1] == '#' { count += 1; };
                if j < w - 1 && board[i][j + 1] == '#' { count += 1; };
                if i < h - 1 {
                    if j > 0 && board[i + 1][j - 1] == '#' { count += 1; };
                    if board[i + 1][j] == '#' { count += 1; };
                    if j < w - 1 && board[i + 1][j + 1] == '#' { count += 1; };
                };
                board[i][j] = std::char::from_digit(count, 10).unwrap();
            }
        }
    }
    for row in board {
        let s = row.into_iter().collect::<String>();
        println!("{}", s);
    }
}


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

int main(void){

  int x,y,d;

  while(1){
    cin >>x >>y;
    if(x == 0 && y == 0) break;

    if(x > y){
      d = y;
      y = x;
      x = d;
    }
    cout <<x <<" " <<y <<"\n";
    
    
  }
  return 0;
}

Measured memory_bytes: 1160
/************************************************
*Author        :  lrj124
*Created Time  :  2018.11.01.19:08
*Mail          :  1584634848@qq.com
*Problem       :  a
************************************************/
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d",a+b/2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define TAM 100100

ll A[TAM];
vi G[TAM];

bool ok ( int i, int pi = -1 ) {
  if ( G[i].size() == 1 )
    return true;

  ll sum = 0, maxAj = 0;
  for ( int j : G[i] )
    if ( j != pi ) {
      if ( !ok(j, i) )
        return false;
      sum += A[j];
      maxAj = max ( maxAj, A[j] );
    }

  // x + A[i] = sum
  ll x = sum - A[i];

  if ( x < 0 || maxAj > A[i] )
    return false;

  A[i] -= x;
  return A[i] >= 0;
}

int main() {
  int n;
  scanf ( "%d", &n );
  for ( int i = 1, tmp; i <= n; ++i ) {
    scanf ( "%d", &tmp );
    A[i] = tmp;
  }
  for ( int edges = n-1, a, b; edges--; ) {
    scanf ( "%d%d", &a, &b );
    G[a].pb ( b );
    G[b].pb ( a );
  }

  if ( n == 2 ) {
    puts ( A[1] == A[2] ? "YES" : "NO" );
    return 0;
  }

  int root = 1;
  while ( G[root].size() == 1 ) root++;

  if ( ok(root) && A[root] == 0 ) puts ("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 13184
#include<iostream>
// #include<vector>
// #include<algorithm>
#include<cmath>
// #include<iomanip>
using namespace std;

// typedef long long ll;
// typedef unsigned long long ull;
// typedef pair<int,int> pii;


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

    int n;
    string s;
    cin>>n>>s;
    int i=0,j=n-1;
    int count = 0;
    while(i<j)
    {
        if(s[i] == 'W' && s[j] == 'R')
        {
            ++count;
            ++i;
            --j;
            continue;
        }
        while(s[i] == 'R') ++i;
        while(s[j] == 'W') --j;
    }
    cout<<count<<"\n";
    return 0;
}



Measured memory_bytes: 3772
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int n,a,b,c; 
int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		if(a<b+c){printf("No\n");return 0;}
		if(a%2==1 and (b+c)%2==0){printf("No\n");return 0;}
		if(a%2==0 and (b+c)%2==1){printf("No\n");return 0;}
	}
	printf("Yes\n");
	return 0;
}


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++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
int N,M,T;

int dist[111111];

struct UF{
    vint par,sz,pre,ma;
    UF(int n){
        par.resize(n);
        sz.resize(n);
        pre.resize(n);
        ma.resize(n);
        rep(i,n){
            par[i]=i;
            sz[i]=1;
            pre[i]=T;
            if(dist[i]==INF)ma[i]=-INF;
            else ma[i]=0;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y,int t){
        x=find(x);y=find(y);
        if(x==y)return;

        int a=(pre[x]-t)*sz[x]+ma[x];
        int b=(pre[y]-t)*sz[y]+ma[y];

        ma[x]=max(a,b);
        sz[x]+=sz[y];
        par[y]=x;
        pre[x]=t;
    }

    int latte(){
        int x=find(0);
        return ma[x]+pre[x]*sz[x];
    }
};

vector<pint>G[111111];

signed main(){
    scanf("%lld%lld%lld",&N,&M,&T);

    vector<tuple<int,int,int>>es;
    rep(i,M){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--;b--;
        G[a].pb({b,c});
        G[b].pb({a,c});
        es.pb(make_tuple(c,a,b));
    }
    sort(all(es));reverse(all(es));


    fill_n(dist,111111,INF);
    dist[0]=0;
    queue<int>que;
    que.push(0);
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto &e:G[v]){
            if(dist[e.fi]!=INF||dist[v]>=e.se)continue;
            dist[e.fi]=dist[v]+1;
            que.push(e.fi);
        }
    }



    UF uf(N);
    for(auto &w:es){
        int t,a,b;
        tie(t,a,b)=w;
        uf.unite(a,b,t);
    }

    printf("%lld\n",uf.latte());
}

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

using namespace std;

vector<int> ans;
bool isP(int num);

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		int count = 0;
		for(int i = n+1;i <= 2*n;i++){
			if(isP(i)) count++;
		}
		ans.push_back(count);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	
	return 0;
}

bool isP(int num){
	bool p = true;
	
	for(int i = 2; i < num;i++){
		if(num > 5 && i*i > num) break;
		if(num % i == 0){p = false;break;}
	}
	
	return p;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<int> now(3);
  for(int i = 0;i < 3;i++)cin >> now[i];
  //for(int i = 0;i < 3;i++)cout << now[i] << endl;
  vector<vector<int>> num(n,vector<int>(2));
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    if(s == "AB")num[i][0] = 0,num[i][1] = 1;
    else if(s == "BC")num[i][0] = 1,num[i][1] = 2;
    else num[i][0] = 0,num[i][1] = 2;
  }
  /*for(int i = 0;i < n;i++){
    for(int j = 0;j < 2;j++)cout << num[i][j] << " ";
    cout << endl;
  }*/
  if(now[0] + now[1] + now[2] == 0){
    cout << "No" << endl;
    return 0;
  }
  else{//if(now[0] + now[1] + now[2] == 1){
    bool can = true;
    vector<int> res;
    for(int i = 0;i < n;i++){
      //cout << "i" << i << " " << now[0] << now[1] << now[2] << " " << num[i][0] << num[i][1]<< endl;
      if(now[num[i][0]] + now[num[i][1]] == 0){
        can = false;
        //cout << i << endl;
        break;
        //cout << "!" << endl;
      }
      else if(now[num[i][0]] == 1 && now[num[i][1]] == 1 && now[0] + now[1] + now[2] == 2){
        //cout << "!" << endl;
        if(i != n - 1){
          if(num[i][0] + num[i][1] != num[i + 1][0] + num[i + 1][1]){
            //cout << "!" << endl;
            if((num[i][0] == 0 || num[i][1] == 0) && (num[i+1][0] == 0 || num[i+1][1] == 0)){
              now[num[i][0]]++,now[num[i][1]]--;
              res.push_back(num[i][0]);
              //cout << 0 << endl;
            }
            else if((num[i][0] == 1 || num[i][1] == 1) && (num[i+1][0] == 1 || num[i+1][1] == 1)){
              //cout << i << endl;
              if(num[i][0] == 1)now[num[i][0]]++,now[num[i][1]]--,res.push_back(num[i][0]);
              else now[num[i][0]]--,now[num[i][1]]++,res.push_back(num[i][1]);
              //cout << 1 << endl;
            }
            else if((num[i][0] == 2 || num[i][1] == 2) && (num[i+1][0] == 2 || num[i+1][1] == 2)){
              now[num[i][0]]--,now[num[i][1]]++;
              res.push_back(num[i][1]);
              //cout << 2 << endl;
            }
          }
          else{
            now[num[i][0]]++,now[num[i][1]]--;
            res.push_back(num[i][0]);
          }
        }
        else{
           now[num[i][0]]++,now[num[i][1]]--;
           res.push_back(num[i][0]);
        }
      }
      else{
        if(now[num[i][0]] >= now[num[i][1]]){
          now[num[i][0]]--,now[num[i][1]]++;
          res.push_back(num[i][1]);
        }
        else{
          //cout << i << " " << now[num[i][0]] << endl;
          now[num[i][0]]++,now[num[i][1]]--;
          res.push_back(num[i][0]);
          //cout << i << " " << now[num[i][0]] << endl;
        }
      }
    }
    if(can){
      cout << "Yes" << endl;
      for(auto& item:res)cout << (char)('A' + item) << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 9392
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
ll mod(ll val, ll MOD) {
    long long res = val % MOD;
    if (res < 0) res += MOD;
    return res;
}

ll modinv(ll a, ll MOD) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

ll f(ll a, ll b, ll x) {
    return floor(a * x / b) - a * floor(x / b);
}

int main() {
    ll a, b, n;
    cin >> a >> b >>n;
    cout << f(a, b, min(n, b-1)) << endl;
    return 0;
}


Measured memory_bytes: 3528