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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

void solve() {
	ll N; cin >> N;
	vll A(N); cin >> A;
	string S; cin >> S;
	int bs = 62;
	
	reverse(begin(A), end(A));
	reverse(begin(S), end(S));

	vll base;

	auto addBase = [](vll &base, ll val) {
		int n = base.size();
		for (int i = 0; i < n; i++) {
			if ((val^base[i]) < val) {
				val ^= base[i];
			}
		}
		if (!val) return;
		for (int i = 0; i < n; i++) {
			if ((val^base[i]) < base[i]) {
				base[i] ^= val;
			}
		}
		base.push_back(val);
		sort(rbegin(base), rend(base));
	};

	auto containBase = [](vll &base, ll val) {
		int n = base.size();
		for (int i = 0; i < n; i++) {
			if ((val^base[i]) < val) {
				val ^= base[i];
			}
		}
		if (val) return (false);
		return (true);
	};

	for (int i = 0; i < A.size(); i++) {
		if (S[i] == '0') {
			addBase(base, A[i]);
		} else {
			if (!containBase(base, A[i])) {
				cout << 1 << endl;
				return;
			}
		}
		/*
		for (int i = 0; i < base.size(); i++) {
			cout << (bitset<64>)base[i] << endl;
		}
		cout << endl;
		*/
	}
	cout << 0 << endl;
}

void Main() {
	ll T; cin >> T;
	while (T--) solve();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        string s1 = to_string(i);
        string s2(s1);
        reverse(s2.begin(), s2.end());
        if (s1 == s2) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int dp[2][2],n,prv,now,id,nxt;
  string s;
  std::ios::sync_with_stdio(0);
  while(cin >> s,s!="#"){
    n = s.size();
    dp[1][0] = dp[1][1] = 0; prv = s[0]-'1';
    
    for(int i=1;i<n;i++){
      id = i&1, nxt = 1-id;
      now = s[i]-'1';
      if(prv%3 == now%3){
	dp[nxt][0] = dp[id][1]; dp[nxt][1] = dp[id][0];
      }else if(prv%3 < now%3){
	dp[nxt][0] = dp[id][0] + 1;
	dp[nxt][1] = dp[id][0];
      }else{
	dp[nxt][0] = dp[id][1];
	dp[nxt][1] = dp[id][1] + 1;
      }
      prv = now;
    }
    cout << std::min(dp[n&1][0],dp[n&1][1]) << endl;
  }
}

Measured memory_bytes: 1328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
	vector<int> v(3);
	for(int i=0;i<3;i++)cin>>v[i];
	sort(v.begin(),v.end());
	int a=v[2]-v[1],ans1,ans2;
	if((v[2]-v[0]-a)%2)ans1=a+(v[2]-v[0]-a)/2+2;
	else ans1=a+(v[2]-v[0]-a)/2;
	cout<<ans1;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		int count =0;
		while (A%2==0&&B%2==0&&C%2==0 &&count<100000) {
			long tempA= B/2+C/2;
			long tempB= A/2+C/2;
			long tempC= B/2+A/2;
			A= tempA;
			B= tempB;
			C= tempC;
			count ++;
		}
		if (count ==100000) {
			System.out.println(-1);
		} else {
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 35812
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    def isPrime(n):
        if n == 2:
            return True
        if n%2 == 0:
            return False
        m = math.floor(math.sqrt(n))+1
        for p in range(3,m,2):
            if n%p == 0:
                return False
        return True

    x = int(input())
    while True:
        if isPrime(x):
            print(x)
            exit()
        x += 1

if __name__=="__main__":
    main()


Measured memory_bytes: 65416
#include<stdio.h>
inline int read()
{
    int s=0,f=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!=EOF)
	{
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        s=s*10+ch-'0';
        ch=getchar();
    }
    return s*f;
}
int a=read(),b=read(),c=read(),d=read();
int main()
{
	c-=b;
	if(c<=0)
	{
		puts("Yes");
		return 0;
	}
	a-=d;
	if(a<=0)
	{
		puts("No");
		return 0;
	}
	main();
}

Measured memory_bytes: 1488
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int n; cin >> n;
    vector<map<char, int>> counts;
    vector<vector<char>> keys;
    rep (i, 0, n) {
        string S; cin >> S;
        vector<char> tmp;
        map<char, int> mp;
        for (auto c : S) {
            tmp.push_back(c);
            mp[c] += 1;
        }
        counts.push_back(mp);
        uniq(tmp);
        sort(tmp.begin(), tmp.end());
        keys.push_back(tmp);
    }

    vector<char> fin_keys = keys[0];
    rep (i, 1, keys.size()) {
        vector<char> tmp;
        set_intersection(fin_keys.begin(), fin_keys.end(),
                         keys[i].begin(), keys[i].end(),
                         back_inserter(tmp));
        fin_keys = tmp;
    }

    map<char, int> ans;
    for (auto key : fin_keys) {
        for (auto mp : counts) {
            if (mp.find(key) != mp.end()) {
                if (ans.find(key) != ans.end())
                    ans[key] = min(ans[key], mp[key]);
                else
                    ans[key] = mp[key];
            }
        }
    }

    for (auto pair : ans) {
        rep (i, 0, pair.second)
            cout << pair.first;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	double s = n * 1.0 / 3;
	double ss = pow(s, 3);
	printf("%.12f", ss);
	return 0;
}

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

int N, T[500000], comp;

void Merge(int *A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	
	int L[n1 + 1], R[n2 + 1];
	for(int i = 0; i < n1; ++i)
	{
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; ++i)
	{
		R[i] = A[mid + i];
	}
	
	L[n1] = 1000000007, R[n2] = 1000000007;
	int i = 0, j = 0;
	for(int k = left; k < right; ++k)
	{
		++comp;
		if(L[i] < R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
		}
	}
}

void MergeSort(int *A, int left, int right)
{
	if(left + 1 < right)
	{
		int mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> T[i];
	}
	
	comp = 0;
	MergeSort(T, 0, N);
	
	for(int i = 0; i < N; ++i)
	{
		if(i != 0)
		{
			cout << " ";
		}
		
		cout << T[i];
	}
	cout << endl << comp << endl;

    return 0;
}



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

int main()
{
   int n,i,j,k,cnt=0;
   cin>>n;
   for(i=0;i<n;i++)
   {
       cin>>j;
       if(i%2==0 && j%2!=0)
       {
           cnt++;
       }
   }
   cout<<cnt<<endl;
    
     
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  string s1,s2,s3;
  cin>>s1>>s2>>s3;

  string s;

  s+=s1[0]-32;
  s+=s2[0]-32;
  s+=s3[0]-32;

  cout<<s<<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main(){
	
  int i, count0=0, count1;
  char S[100000];
  
  if(scanf("%s", S)==0) return -1;
  
  count1=strlen(S);
  
  for(i=0;S[i]!='\0';i++){
  	if(S[i]=='0') count0++;
  }

  count1-=count0;
  
  if(count1>=count0) printf("%d", count0*2);
  else printf("%d", count1*2);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
    string S;cin>>S;
    for(int i=0;i<S.size();i+=2) cout<<S[i];
    cout<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        Set<Integer> check = new HashSet<>();
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
            check.add(p[i]);
        }

        Arrays.sort(p);

        if (n == 0) {
            System.out.println(x);
        }

        for (int i = 0; i < n; i++) {
            // pにxが含まれていなかったらxが答え
            if (p[i] > x) {
                System.out.println(x);
                return;
            } else if (p[i] == x) {
                for (int j = 1;; j++) {
                    if (!check.contains(p[i]-j)) {
                        System.out.println(p[i]-j);
                        return;
                    } else if (!check.contains(p[i]+j)) {
                        System.out.println(p[i]+j);
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 35920
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

vector<vector<int>> p;
int n, m;

int ser(int now, int l, vector<bool> ch) {
    if(l == n) {
        return 1;
    }
    int ans = 0;
    for(int i = 0; i < p[now].size(); i++) {
        if(!ch[p[now][i]]) {
            vector<bool> cc = ch;
            cc[p[now][i]] = true;
            ans += ser(p[now][i], l+1, cc);
        }
    }
    return ans;
}

int main() {
    
    cin >> n >> m;
    p.resize(n);
    for(int i = 0; i < m;i++) {
        int t, f;
        cin >> t >> f;
        p[t - 1].push_back(f - 1);
        p[f - 1].push_back(t - 1);
    }
    int ans = 0;
        vector<bool> b;
        b.resize(n);
        b[0] = true;
        ans += ser(0, 1, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

function input_array() {
    return explode(' ', trim(fgets(STDIN)));
}

function gcd($x, $y) {
    if ($x < $y) {
        list($x, $y) = [$y, $x];
    }
    while ($y !== 0) {
        list($x, $y) = [$y, $x % $y];
    }
    return $x;
}

list($x, $y) = array_map(function($numeric_string) {
    return (int)$numeric_string;
}, input_array());

echo gcd($x, $y) . "\n";


Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, p;
	cin >> n >> p;
	vi as(n);
	trav(x, as) cin >> x;
	p %= 2;
	int cnt[2] = {};
	rep(i,0,n) cnt[as[i]%2]++;
	ll ans;
	if(cnt[1]){
		ans = 1;
		rep(_,1,cnt[1]) ans = ans*2;
	} else {
		ans = p ? 0 : 1;
	}
	rep(_,0,cnt[0]) ans = ans*2;
	cout << ans << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string.h>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <sstream>
#include <stack>
#include <iomanip>
#include <climits>
#include <complex>
#include <cmath>
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ii, int> iii;

const int maxN = 5e5 + 9, maxV = 5e5, MOD = 1e9 + 7 , lg = 20, LIM = 100;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    
    vector<int> arr(n + 4);
    
    for(int i = 0; i < n; i++) cin >> arr[i];
    
    int one = 0, two = 0, three = 0;
    
    for(int i = 0; i < n; i++){
        if(arr[i] <= a)one++;
        else if(arr[i] <= b) two++;
        else three++;
    }
    cout << min(min(one, two), three) << '\n';
    
    
}

/*
 4
 7 2 3 4
 1
 1 4
 */


Measured memory_bytes: 256
n = int(input())
s=input()
r = [0]*n
g = [0]*n
b = [0]*n
for i in range(n):
    if s[i] == "R":
        r[i] = r[i - 1] + 1
        g[i] = g[i - 1]
        b[i] = b[i - 1]
    elif s[i] == "G":
        r[i] = r[i - 1]
        g[i] = g[i - 1] + 1
        b[i] = b[i - 1]
    else:
        r[i] = r[i - 1]
        g[i] = g[i - 1]
        b[i] = b[i - 1] + 1
ans=0
for k in range(n-1,-1,-1):
    for j in range(k - 1, -1, -1):
        if s[k]==s[j]:continue
        i = {"R", "G", "B"} - {s[k], s[j]}
        if "R" in i:
            ans += r[j]
        elif "G" in i:
            ans += g[j]
        else:
            ans += b[j]
        if 2 * j - k >= 0 and s[2 * j - k] in i:
            ans -= 1
print(ans)

Measured memory_bytes: 69432
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    
    char[] c = str.toCharArray();
    
    if(c.length == 1) {
        if(c[0] == '?') System.out.println("D");
        else System.out.println(str);
        
        System.exit(0);
    }
    
    for(int i = 0; i < c.length; i++) {
        if(c[i] ==  '?'){
            if(i == 0) {
                if(c[i+1] == 'P') c[i] = 'D';
                else c[i] = 'P';
            } else if(i == c.length-1) {
                c[i] = 'D';
            } else {
                if(c[i-1] == 'P') c[i] = 'D';
                else {
                    if(c[i+1] == 'P') c[i] = 'D';
                    else c[i] = 'P';
                }
            }
        }
        
    }
    String str2 = new String(c);
    System.out.println(str2);
  }
}

Measured memory_bytes: 41284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin>>S;
    if(S.size()%2 == 1){
        cout<<No<<endl;
        return 0;
    }
    rep(i, (int)S.size()-1){
        if(S[i] == 'h' && S[i+1] == 'i'){
            i++;
        }
        else{
            cout<<No<<endl;
            return 0;
        }
    }
    cout<<Yes<<endl;
}

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

int main(){
  int a[N], t[N];
  int n,m;

  while( cin>>n>>m && (n||m) ){
    for( int i=0;i<n;i++ ){
      cin >> a[i];
      t[i] = m-(m%a[i]); // ÂÃÂÃ¥ÂÃÂÃ¬ÂÃÂÂÂÃ
      //      cout << i <<"\t" << t[i] << endl;
    }

    int minT = t[0];
    int minA = a[0], ms=0;
    int ans = 0;
    for( int i=1;i<n;i++ ){
      while( t[i]-a[i] > minT )
	t[i] -= a[i];

      /*
      if( t[i]>m ){  // ÂRÂÃÂ\ÂÂ¿
	cout <<"doubt"<<endl;
	ans = i; break;
      }
      */
      //      cout << " "<<i<<":"<<t[i] << endl;

      if( t[i]<minT ){
	ans=i; minT=t[i]; minA=a[i]; ms=0;
      }else if( t[i]==minT ){
	if( a[i]==minA ){
	  ms++;
	}else if( a[i]<minA ){
	  ans=i; minA=a[i]; ms=0;
	}
      }
    }

    if( ms>0 )
      ans=n-1;
    

    cout << (ans+1) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	int n,i;
	int yen = 100000;
	scanf("%d",&n);
	
	printf("%d\n",debt(n));
/*
	for(i=0;i<n;i++){
	yen=yen+yen*0.05;
	yen=yen+999;
	yen=yen/1000;
	yen=yen*1000;
	}
printf("%d\n",yen);
*/
	return 0;
}

int debt(int n)
{
	int i,k;
	int j=100000;
	float r = 0.05;
	for(i=0;i<n;i++){
		j += j*r;
		j += 999;
		j = j/1000;
		j = j*1000;
		
	}
	
	
	return j;
	}

Measured memory_bytes: 592
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

from collections import deque

x,y,a,b,c = l_in()
P = sorted(l_in(), reverse=True)
Q = sorted(l_in(), reverse=True)
R = deque(sorted(l_in(), reverse=True))


res = []
for i in range(x):
    res.append(P[i])
for j in range(y):
    res.append(Q[j])

res.sort()

for i in range(x+y):
    if len(R) > 0 and res[i] < R[0]:
        res[i] = R.popleft()

print(sum(res))


Measured memory_bytes: 108072
class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
    
### 使い方 ##
N = int(input())


A = [i for i in range(1,N+1)]
INF = 10**15
ide_ele = -1
SEG = SegTree(A,ide_ele,max)


LIST = []
XX = []
mod = 998244353

for i in range(N):
    X,D = map(int,input().split())
    XX.append(X)
    LIST.append([X,D])

XX.sort()
LIST.sort(key=lambda x: x[0])

GOTO = [i for i in range(1,N+1)]
#print(LIST)
import bisect
for i in range(N-1):
    j = N-2-i
    Xj = LIST[j][0]
    Dj = LIST[j][1]
    Nj = bisect.bisect_right(XX, Xj+Dj-1)
    #print(Xj,Dj,j+1,Nj)
    NEXT = SEG.query(j+1,Nj)
    if NEXT != -1:
        GOTO[j] = NEXT
        SEG.update(j,NEXT)
    
S = [-1]*(N+1)
S[N] = 1

#print(LIST)
#print(GOTO)
for i in range(N):
    j = N-1-i
    S[j] = S[j+1] + S[GOTO[j]]
    S[j] %= mod

print(S[0])

Measured memory_bytes: 127480
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((int)1e9)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
bool check(ll x) {
    char ans;
    cout << "? " << x << endl;
    fflush(stdout);
    cin >> ans;
    return (ans == 'Y');
}
int main() {
    ll n = 1;
    while(1) {
        if(!check(n)) break;
        n *= 10;
        if(n > (ll)1e10) {
            ll z = 1;
            while(n) {
                if(!check(n+1)) {
                    z = n*10;
                    break;
                }
                else n/= 10;
            }
            cout << "! " << z << endl;
            return 0;
        }
    }
    ll r = n*10 - 1, l = n-1;
    while(l < r) {
        ll mid = (l+r) >> 1;
        if(check(mid)) {
            n = mid; r = mid - 1;
        } else l = mid + 1;
    }
    cout << "! " << n/10 << endl;
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	multiset<ar<int,2> > v;
	ll ans = 0;
	ll cnt = 0;
	for(int i = 0,j,k2; i<n;i++)
	{
		cin>>j>>k2;
		v.insert({j,k2});
	}
	for(auto it:v)
	{
		cnt += it[1];
		if(cnt>=k)
		{
			cout<<it[0]<<endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	vector<ll> b(n);
	if(n==2){
		b[0] = a[1];
		b[1] = a[0];
	}else{
		for(int i = 0; i < n-1; i++){
			b[n-1] ^= a[i];
		}
		for(int i = n-2; i >= 0; i--){
			b[i] = a[i+1] ^ a[i] ^ b[i+1];
		}
	}
	for(int i = 0; i < n; i++){
		cout << b[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 6340
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define x first
#define y second

using namespace std;

const string FILENAME = "input";

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	cout << n * (n % 2 + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int S,h,m,s;
    cin >> S;
    h = S / 3600;
    m = (S%3600) / 60;
    s = (S%3600) % 60 ;
    cout << h;
    cout << ":";
    cout << m;
    cout << ":";
    cout << s;
    cout << endl;
    
}


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

int     main() {
        long L, R;
        cin >> L >> R;
        long l=L % 2019;
        long r=R % 2019;
        long S=2019;
        if (R-L>=2019) S=0;
        if (l>=r) S=0;
        if (S==2019) {
                for (long i=l; i<r; i++){
                        for (long j=i+1; j<=r; j++) {
                                S=min(S, i*j % 2019);
                        }
                }
        }
        cout << S << endl;
        return 0;
}

Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    N,M=pin()
    x=0
    y=N
    for i in range(M):
        a,b=pin()
        x=max(x,a)
        y=min(y,b)
        
    t=(y-x+1)
    if t<0:t=0
    print(t)
            
        
#%%submit!    
resolve()


Measured memory_bytes: 40684
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>N) {
		VI tb = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		cout<<tb[N-1]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll signed long long int
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 1000005
using namespace std;

ll a[MAXX], b[MAXX], c[MAXX], k = 0;

signed main()
{
	FAST;
	ll  m, f = 0;
	double n;
	double pi = 3.14;
	cin >> n;
	cout << 2 * pi * n;
	
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  int ans=1;
  int M=0;
  for(int i=1;i<=n;i++){
    int x=0;
    int y=i;
    while(y%2==0){
      x++;
      y/=2;
    }
    if(M<x){
      M=x;
      ans=i;
    }
  }
  cout<<ans<<endl;
}

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

int f(int a, int hp)
{
    return (hp + a - 1) / a;
}

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (f(b, c) <= f(d, a))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
    s << v[i];
  }
  s << "]";
  return s;
}

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

  int h, w;
  cin >> h >> w;
  vector<string> board(h);
  for (int y = 0; y < h; y++) {
    cin >> board[y];
  }

  auto dp = MakeVector2D<int>(h, w, 1E9);
  if (board[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (y + 1 < h) {
        int c = 0;
        if (board[y][x] == '.' && board[y + 1][x] == '#') c = 1;

        UpdateMin(dp[y + 1][x], dp[y][x] + c);
      }

      if (x + 1 < w) {
        int c = 0;
        if (board[y][x] == '.' && board[y][x + 1] == '#') c = 1;

        UpdateMin(dp[y][x + 1], dp[y][x] + c);
      }
    }
  }

  for (int y = 0; y < h; y++) {
    // cout << dp[y] << endl;
  }

  cout << dp[h - 1][w - 1] << endl;
}


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

using namespace std;

typedef long long ll;

string s;
ll r, res;
bool c[100];

int main() {
	c['A'] = 1;
	c['T'] = 1;
	c['C'] = 1;
	c['G'] = 1;

	cin >> s;
	for (char& v: s) {
		if (c[v]) ++r;
		else {
			res = max(res, r);
			r = 0;
		}
	}
	res = max(res, r);
	cout << res;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

struct mv{
    ll x, y, z, w;
};

int main(){
    ll h, w;
    cin >> h >> w;
    ll a[h][w];
    rep(i, h)rep(j, w){
        cin >> a[i][j];
    }

    vector<mv> ans;
    ll sum = 0;
    ll x, y;
    x = y = 0;
    bool direc = true;

    while(true){
        ll nxt_y, nxt_x;
        nxt_y = y;
        if(direc)nxt_x = x+1;
        else nxt_x = x-1;
        
        if(nxt_x >= w || nxt_x < 0){
            nxt_y++;
            nxt_x = x;
            direc = !direc;
        }

        sum += a[y][x];
        
        if(nxt_y >= h)break;
        if(sum & 1)ans.push_back(mv({x+1, y+1, nxt_x+1, nxt_y+1}));

        x = nxt_x, y = nxt_y;
    }

    cout << ans.size() << endl;
    rep(i, ans.size()){
        cout << ans[i].y << " " << ans[i].x << " " << ans[i].w << " " << ans[i].z << endl;
    }
}

Measured memory_bytes: 9288
void main() {
	auto ip = readAs!(int[]), H = ip[0], N = ip[1];
	auto dp = new int[](H+1);
	dp[] = 100000000;
	dp[0] = 0;
	int[] As, Bs;
	foreach(i; 0..N) {
		auto ip2 = readAs!(int[]), A = ip2[0], B = ip2[1];
		As ~= A, Bs ~= B;
	}

	foreach(i; 0..N) {
		foreach(j; 0..H+1) {
			dp[min(j + As[i], H)] = min(dp[min(j + As[i], H)], dp[j] + Bs[i]);
		}
	}
	dp[H].writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

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

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    vi v(n);
    f(n) cin>>v[i];
    if(is_sorted(all(v))){
        cout<<"YES";
        return 0;
    }
    f(n){
        for(int j=i+1;j<n;++j){
            vi vv=v;
            swap(vv[i],vv[j]);
            if(is_sorted(all(vv))){
                cout<<"YES";
                return 0;
            }
        }
    }
    cout<<"NO";
    return 0;
}


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

int main() {
    int n,m,i,count=0,sum=0;

    cin>>n>>m;
    double s,pop, a[n];
    for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
    s=1.0/(4*m);
    for(i=0;i<n;i++)
    {
        pop=a[i]/sum;
        if(pop>=s)
            count++;
    }
    if(count>=m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
s,K = open(0).read().split()
K = int(K)
ss = set()
temp = set([''])
for x in s:
    temp = set([''.join((y,x)) for y in temp if len(y) <= 4])
    ss = ss | temp
    temp.add('')
l = list(ss)
l.sort()
print(l[K-1])

Measured memory_bytes: 4832
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
using std::min;
using std::max;
using std::ceil;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll T[1010],A[1010];
int main(){
  cin>>N;
  rep(i,N) cin>>T[i]>>A[i];
  ll t=T[0],a=A[0];
  rep1(i,N-1){
    ll x=max((t-1)/T[i]+1,(a-1)/A[i]+1);
    t=T[i]*x;a=A[i]*x;
  }
  prin(t+a);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//O(NK)
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    const int64_t INF = 1e10;
    int N, K;
    cin >> N >> K;
    vector<int64_t> h(N), ans(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
        ans[i] = INF;
    }
    ans[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 1; j <= K; j++) {
            if(i + j < N) {
                ans[i + j] = min(ans[i + j], abs(h[i + j] - h[i]) + ans[i]);
            }
        }
    }
    cout << ans[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;




int a[200000];
signed main(){
  int n;
  cin >> n;
  rep(i,n)scanf("%lld", &a[i]);
  int cnt = 0;
  rep(i,n)cnt += (a[i]%2);
  cout << (cnt%2 ? "NO" : "YES") << endl;
	return 0;
}










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

using namespace std;

const int INF = 1 << 28;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  vector<int> dp(H + 1, INF);
  dp[0] = 0;

  for (int h = 0; h < H; h++) {
    for (int i = 0; i < N; i++) {
      chmin(dp[min(H, h + A[i])], dp[h] + B[i]);
    }
  }

  cout << dp[H] << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
a = 0

sortsecond = lambda x: x[1]
ab.sort(key = sortsecond)

for i in range(n):
    a += ab[i][0]
    if a > ab[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 53600
#include<iostream>
#include<sstream>
#include<bitset>
#include<map>
using namespace std;

string bin(char x){
    stringstream ss;
    ss << bitset<5>(x-'A');
    string s = ss.str();
    return s;
}

int main(){
    map<char, string> enc;
    for(char c = 'A'; c <= 'Z'; c++){
        enc[c] = bin(c);
    }
    enc[' '] = "11010";
    enc['.'] = "11011";
    enc[','] = "11100";
    enc['-'] = "11101";
    enc['\''] = "11110";
    enc['?'] = "11111";

    map<string, char> dec;
    char c[32] = {' ', '\'', ',', '-', '.', '?', 'A', 'B',
                  'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
                  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
    string s[32] = {"101",
                    "000000",
                    "000011",
                    "10010001",
                    "010001",
                    "000001",
                    "100101",
                    "10011010",

                    "0101",
                    "0001",
                    "110",
                    "01001",
                    "10011011",
                    "010000",
                    "0111",
                    "10011000",

                    "0110",
                    "00100",
                    "10011001",
                    "10011110",
                    "00101",
                    "111",
                    "10011111",
                    "1000",

                    "00110",
                    "00111",
                    "10011100",
                    "10011101",
                    "000010",
                    "10010010",
                    "10010011",
                    "10010000"};
    for(int i = 0; i < 32; i++){
        dec[s[i]] = c[i];
    }

    string in;
    while(getline(cin, in)){
        string cry = "";
        for(char x : in){
            cry += enc[x];
        }
        int cur = 0;
        while(cur < cry.length()){
            int next = cur+1;
            while(next <= cry.length() && !dec.count(cry.substr(cur, next-cur))){
                next++;
            }
            if(next > cry.length()) break;
            cout << dec[cry.substr(cur, next-cur)];
            cur = next;
        }
        cout << endl;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define mod 1000000007


main(){
  ll n, m; cin >> n >> m;

  if(n < m) swap(n,m);
  if(n - m > 1){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  FOR(i,1,n + 1){
    ans *= i;
    ans %= mod;
  }
  FOR(i,1,m + 1){
    ans *= i;
    ans %= mod;
  }
  if(n == m){
    ans *= 2;
    ans %= mod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
h, n = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    ai ,bi = map(int,input().split())
    a[i] = ai
    b[i] = bi


mh = [0 for i in range(10003)]
for i in range(1,h+1):
    mb = 10**9
    for j in range(n):
        if mb > mh[i-a[j]] + b[j]:
            mb = mh[i-a[j]] + b[j]
    mh[i] = mb

print(mh[h])


Measured memory_bytes: 73948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  using ld = long double;
  cout << fixed << setprecision(15);

  string S;
  cin >> S;
  ll N = S.size();
  if (N % 2 == 1)
    FINALANS("No");

  for (ll i = 0; i < N; i += 2)
  {
    if (S.at(i) != 'h' || S.at(i + 1) != 'i')
      FINALANS("No");
  }
  FINALANS("Yes");
}

Measured memory_bytes: 256