akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
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 ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    string s;cin >> s;
    vector<int> v(s.size());
    int count = 0;
    rep(i, s.size()) {
        if(s[i]=='R') count++;
        else v[i]=count,count=0;
    }
    count=0;
    rev(i, s.size()) {
        if(s[i]=='L') count++;
        else v[i]=count,count=0;
    }
    vi ans(s.size());
    // for(auto p:v) cout << p << ' ';cout << char(10);
    rep(i, s.size()) {
        if(!v[i]) continue;
        // cout << "OK" << endl;
        if(s[i]=='L') {
            ans[i-1]+=(v[i]+1)/2;
            if(i>1) ans[i]+=v[i]/2;
        }
        else {
            ans[i+1]+=(v[i]+1)/2;
            if(i+2<s.size()) ans[i]+=v[i]/2;
        }
    }
    rep(i, s.size()) cout << ans[i] << (i==s.size()-1?"\n":" ");
    return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;


void solve()
{ 
 int n,k,i;
    cin>>n>>k;
    vector<int>a(n);
    for(int &x:a)cin>>x;
    for(i=k;i<n;i++)
    {
        if(a[i]>a[i-k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define mod 998244353
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n, 0);
  ll max = 0;
  for(ll i=0; i<n; i++){
    ll num;
    cin >> num;
    if(max < num) max = num;
    if(i == 0 && num != 0){
      cout << 0 << endl;
      return 0;
    }
    vec[num]++;
  }
  if(vec[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  ll res = 1;
  for(ll i=0; i<=max-1; i++){
    ll powRes = 1;
    for(ll j=0; j<vec[i+1]; j++){
      powRes *= vec[i];
      powRes %= mod;
    }
    res *= powRes;
    res %= mod;
  }
  cout << res << endl;
}
  
  

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    int a;
    cin >> a;

    int maxDiff = 0, minPrice = a;
    int count = 0;

    for (int i = 1; i < n; i++) {
        cin >> a;
        
        if (maxDiff == a-minPrice) {
            count++;
        } else if (maxDiff < a-minPrice) {
            count = 1;
        }

        maxDiff = max(maxDiff, a-minPrice);
        minPrice = min(minPrice, a);
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

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

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

int main() {
    int n, k; cin >> n >> k;
    vector<pint> sushi(n);
    rep(i, n) {
        int t, d; cin >> t >> d;
        sushi[i] = make_pair(d, t);
    }
    sort(sushi.rbegin(), sushi.rend());

    vector<int> residue;
    map<int, int> mp;

    ll base = 0;
    int kind = 0;
    rep(i, k) {
        int t = sushi[i].second;
        int d = sushi[i].first;
        if (!mp.count(t)) {
            mp[t]++;
            base += d;
            kind++;
        } else {
            residue.push_back(d);
            base += d;
        }
    }

    ll ans = base + ll(kind) * ll(kind);
    sort(residue.begin(), residue.end());
    int j = 0;

    for (int i = k; i < n; i++) {
        int t = sushi[i].second;
        int d = sushi[i].first;
        if (mp.count(t)) continue;
        if (j >= residue.size()) break;
        base -= residue[j];
        j++;
        base += d;
        kind++;
        mp[t]++;
        ans = max(ans, base + ll(kind) * ll(kind));
    }


    cout << ans << endl;



    return 0;
}


    


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int n,l,m,a[100003],x,y,b[100003][103],ans,l1,r1,mid;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	cin>>l>>m;
	for(int i=1; i<=n-1; i++)
	{
		l1=i+1,r1=n;
		while(l1<=r1)
		{
			mid=(l1+r1)/2;
			if(a[mid]-a[i]>l)
				r1=mid-1;
			else
				l1=mid+1;
		}
		b[i][0]=r1;
	}
	for(int j=n; j>=1; j--)
		for(int i=1; b[b[j][i-1]][i-1]!=0; i++)
			b[j][i]=b[b[j][i-1]][i-1];
	for(int i=1; i<=m; i++)
	{
		scanf("%d%d",&x,&y);
		ans=0;
		if(x>y)
			swap(x,y);
		while(x<y)
		{
			for(int i=0; i==0||b[x][i-1]!=0; i++)
				if(b[x][i]==y)
				{
					x=b[x][i],ans+=(1<<i);
					break;
				}
				else if(b[x][i]>y||b[x][i]==0)
				{
					if(i==0)
					{
						x=y,ans+=1;
						break;
					}
					x=b[x][i-1],ans+=(1<<(i-1));
					break;
				}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 41472
vec = [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]
k = int(input())
print(vec[k - 1])

Measured memory_bytes: 3060
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll w, a, b;
  scanf("%lld%lld%lld", &w, &a, &b);
  if (b >= a && b <= a + w)
  {
    printf("%d\n", 0);
    return 0;
  }
  printf("%lld\n", (MIN(llabs(b - a + w), llabs(a - b + w))));
}

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

int main(){
  int n;
   cin >> n;
   string s;
   cin >>s;
   int subsum=0;
   for(int i=0;i<n;i++)
   {
     int pos=i;
     int j=i+1;
     bool is_marge=true;
     while(is_marge)
      {
        is_marge= (s[pos]==s[j]);
        if(is_marge)
        {
         i++;
         subsum++;
         j++;
        }
      }
   }
   cout << n-subsum <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
    int x,n,t,s,a;
    cin>>n>>a;
    x=100000;
   while(n--)
   {
       cin>>s>>t;
       if(t<=a)
        x=min(x,s);
   }
   if(x==100000)
    cout<<"TLE"<<endl;
   else
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
import copy

n = int(input().strip())

a = []

for i in range(n):
    a.append(-1 * int(input().strip()))

b = copy.deepcopy(a)
heapq.heapify(b)

first = heapq.heappop(b)
second = heapq.heappop(b)

for i in range(n):
    if (a[i] == first):
        print(-second)
    else:
        print(-first)


Measured memory_bytes: 118360
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
 
min_limit = min(a, b, c, d, e)
if n % min_limit == 0:
    cnt = n // min_limit
else:
    cnt = n // min_limit + 1
print(5 + cnt - 1)

Measured memory_bytes: 9144
s_str = input()

check_list = ['a', 'b', 'c']
result_list = [[s == check for check in check_list] for s in s_str]
r1, r2, r3 = result_list
result = all([s1 or s2 or s3 for s1, s2, s3 in zip(r1, r2, r3)])

if result:
    print('Yes')
else:
    print('No')


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

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

	if (N > 100)
		return 1;
	else if (K > N)
		return 1;
	else if (N < 1 || K < 1)
		return 1;

	int different = N - K;

	if (K == 1)
		different = 0;

	cout << different;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int t = sc.nextInt();
		int x,y=0,time=0;
		
		x = sc.nextInt();
		y=x;
		time += x-m;
		for(int i=1;i<n;i++) {
			y = sc.nextInt();
			
			time += 2*m >= y-x ? 0:y-x-2*m;
			
			x=y;
		}
		
		time += y+m < t ? t-y-m : 0;
		System.out.println(time);
	sc.close();
	}

}



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

int main () {
  string S;
  cin>>S;
  
  if (S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]) {
    cout<<"Yes"<<endl;
  }
  else if (S[0]==S[2] && S[1]==S[3] && S[0]!=S[1]) {
    cout<<"Yes"<<endl;
  }
  else if (S[0]==S[3] && S[1]==S[2] && S[0]!=S[1]) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  
  
}

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

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

    rep(i, s.size()) {
        if (',' == s.at(i)) {
            s.at(i) = ' ';
        }
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k[2020],f[2000005],a[2000005],g[2000005];
long long sum;
int main() 
{
   string s;
   cin>>s;
   int n=s.size();
   for(int i=0;i<n;i++){
      a[i+1]=s[i]-'0';
   }
   int l=1; 
   for(int i=n;i>=1;i--){ 
      g[i]=l;
      l*=10;
      l%=2019;
   }
   for(int i=n;i>=1;i--){ 
      f[i]=(f[i+1]+a[i]*g[i])%2019;
      k[f[i]]++;
   }
   sum=k[0];
   sum+=(k[0]*(k[0]-1)/2);
   for(int i=1;i<=2018;i++){
      sum+=(k[i]*(k[i]-1)/2);
   }
   cout<<sum;
   return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    ll N; cin >> N;
    ll s = (ll) sqrt(N);
    while(N % s > 0) s--;
    cout << s-1 + N/s -1 << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
// abc174_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;



template <typename T>
struct RangeTree {
    int n;
    vector<vector<T>> dat;
    vector<T> val;

    explicit RangeTree(vector<T>& val_): val(val_) {
        n = 1;
        while (n < val.size()) n <<= 1;
        dat.assign(n << 1, vector<T>());

        build(0, 0, val.size());
    }

    void build(int k, int l, int r) {
        if (r-l == 1) {
            dat[k].emplace_back(val[l]);
        } else {
            int lch = 2*k+1, rch = 2*k+2;
            build(lch, l, (l+r)/2);
            build(rch, (l+r)/2, r);
            dat[k].resize(r-l);
            merge(dat[lch].begin(), dat[lch].end(), dat[rch].begin(), dat[rch].end(), dat[k].begin());
        }
    }

    int query(int i, int j, T x) {
        return query(i, j, x, 0, 0, val.size());
    }

    int query(int i, int j, T x, int k, int l, int r) {
        if (j <= l || r <= i) return 0;
        // x以下の要素の数
//        if (i <= l && r <= j) return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        // x未満の要素の数
        if (i <= l && r <= j) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        int lch = query(i, j, x, 2*k+1, l, (l+r)/2);
        int rch = query(i, j, x, 2*k+2, (l+r)/2, r);
        return lch+rch;
    }
};


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
    cin >> N >> Q;
    vector<int> C(N);
    REP(i, N) {cin >> C[i]; C[i]--;}

    vector<int> last(N, N);
    vector<int> nxt(N);
    REP_REV(i, N){
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }

    // [l,r)で、r未満の要素の数を数える
    RangeTree<int> rt(nxt);

    REP(i, Q){
        int l, r;
        cin >> l >> r; l--;
        int ans = r - l - rt.query(l, r, r);
        print(ans);
    }


    return 0;
}


Measured memory_bytes: 98800
#include<bits/stdc++.h>
using namespace std;
int main () {
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for (int i = 0; i < 10000; i ++) {
    int kj = d * i;
    if (L <= kj && kj <= R) ans ++;
  }
  cout << ans << endl;
}


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



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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> m;
  rep(i, n) m[a[i]] = i;
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i, n) {
    if ((i + m[a[i]]) % 2 == 1) ans++;
  }
  ans /= 2;
  cout << ans << '\n';




  
  return 0;
}

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

void operate(char str[]);

int main(void)
{
	char str[200000];
	int n;
	
	while (scanf("%d", &n)){
		if (n == 0){
			break;
		}
		scanf("%s", str);
	
		while (n){
			operate(str);
			n--;
		}
	
		printf("%s\n", str);
	}
	return (0);
}

void operate(char str[])
{
	char tmp[200000];
	char c;
	int i, j, l;
	int tmplen;
	int count, k;
	
	memset(tmp, 0, sizeof(tmp));
	l = tmplen = 0;
	while (str[l] != '\0'){
		c = str[l];
		i = l;
		j = 0;
		while (c == str[i]){
			j++;
			i++;
		}
		k = j;
		count = 0;
		while (j != 0){
			j /= 10;
			count++;
		}
		j = k;
		i = count;
		while (count){
			tmp[tmplen + count - 1] = k % 10 + '0';
			k /= 10;
			count--;
		}
		tmplen += i;
		tmp[tmplen] = c;
		tmplen++;
		l += j;
	}
	strcpy(str, tmp);
}

Measured memory_bytes: 832
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 8, MAX_M = 8 * 7 / 2;
bool G[MAX_N][MAX_N];
bool visited[MAX_N];
int N, M;

int dfs(int v) {
    bool all_visited = true;
    REP(i, N) if (!visited[i]) all_visited = false;
    if (all_visited) return 1;

    int ret = 0;
    REP(i, N) {
        if (!G[v][i]) continue;
        if (visited[i]) continue;
        visited[i] = true;
        ret += dfs(i);
        visited[i] = false;
    }
    return ret;
}

void solve() {
    visited[0] = true;
    int ans = dfs(0);
    cout << ans << endl;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a][b] = G[b][a] = true;
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc060/tasks/abc060_b

import itertools
import collections
import bisect

def main():
    A, B, C = map(int, input().split())
    for c in range(1, B+1):
        if (A * c) % B == C:
            print('YES')
            exit()

    print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b; 
    cin >> a >> b;
    cout << b - ( a - b );
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define lint long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;

signed main(){
  int n;cin>>n;
  vector<P> a(n);
  rep(i,n){
    cin>>a[i].first;
    a[i].second=i+1;
  }
  sort(a.begin(),a.end());
  vector<int> sum(n);
  sum[0]=a[0].first;
  rep1(i,n-1){
    sum[i]=sum[i-1]+a[i].first;
  }
  vector<bool> ans(n,false);
  ans[n-1]=true;
  int res=0;
  for(int i=n-2;i>=0;--i){
    if(sum[i]*2>=a[i+1].first){
      ans[i]=ans[i+1];
    }
  }
  rep(i,n){
    if(ans[i])++res;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
    int n,q,ans;
    ans=0;
    cin>>n;
    int S[n];
    for(int a=0;a<n;a++){
        cin>>S[a];
    }
    cin>>q;
    int T[q];
    for(int a=0;a<q;a++){
        cin>>T[a];
    }
    int key=-1;
    for(int a=0;a<q;a++){
        if(key!=T[a]){
            key=T[a];
            for(int b=0;b<n;b++){
                if(key==S[b]){
                    ans+=1;
                    break;
                }
            }
        }
    }cout<<ans<<endl;
}



Measured memory_bytes: 3124
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e15;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
vector<vector<int>>ko;
int solve(int ter,int oya){
	//どの頂点も、0or1つの方向を除いて、アンテナを置く
	int ans=0,okan=0;//okan->おかない頂点数
	for(auto it:ko[ter]){
		if(it==oya){continue;}
		int ret=solve(it,ter);
		ans+=ret;
		if(ret==0){okan++;}
	}
	if(okan>1){ans+=okan-1;}
	return ans;
}
int main(void){
	int i,n;cin>>n;
	//木多くない?多いね
	ko.res(n);
	for(i=0;i<n-1;i++){
		int x,y;cin>>x>>y;
		ko[x].pub(y);
		ko[y].pub(x);
	}
	int sai=-1;
	for(i=0;i<n;i++){if(ko[i].size()>2){sai=i;break;}}
	if(sai!=-1){cout<<solve(sai,-1)<<endl;}
	else{cout<<1<<endl;}//分岐がなければひとつで十分
	return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define int long long

bool bit[40];
int x;

void hoge(){
  int count = 1;
  
  while(x){
    bit[count++] = x%2;
    x/=2;
  }
  
}
signed main(){

  cin>>x;

  hoge();
  
  for(int i = 32; i; i--) cout<<bit[i];
  cout<<endl;
  for(int i = 32; i; i--) cout<<!bit[i];
  cout<<endl;
  for(int i = 31; i >= 0; i--) cout<<bit[i];
  cout<<endl;
  for(int i = 33; i >= 2; i--) cout<<bit[i];
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3100
#pragma GCC optimize(2)
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#define N 1000011
using namespace std;
struct point{
	int x,y;
	point(){}
	point(int xx,int yy){x=xx;y=yy;}
	bool operator<(const point &other)const{
		if(x==other.x) return y<other.y;
		return x<other.x;
	}
}que[N];
set<int> V[N];
set<int>::iterator it;
map<point,int> Map;
int father[N],head,tail,n,ans;
inline int read(){
	int ret=0;char ch=getchar();
	while(ch<'0' || ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret;
}
int find(int u){
	if(u==father[u]) return u;
	father[u]=find(father[u]);
	return father[u];
}
int main(){
	int x,y;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) father[i]=i;
	for(int i=1;i<=n*2-2;i++){
		x=read(),y=read();
		Map[point(x,y)]++;
		Map[point(y,x)]++;
		V[x].insert(y);
		V[y].insert(x);
		if(Map[point(x,y)]==2) que[++tail]=point(x,y);
	}
	while(head<tail){
		head++;
		x=que[head].x;
		y=que[head].y;
		x=find(x),y=find(y);
		V[x].erase(y);
		V[y].erase(x);
		if(V[x].size()>V[y].size()) swap(x,y);
		for(it=V[x].begin();it!=V[x].end();it++){
			int t=*it;
			Map[point(x,t)]=Map[point(t,x)]=0;
			V[y].insert(t);
			V[t].erase(x);
			V[t].insert(y);
			Map[point(y,t)]++;
			Map[point(t,y)]++;
			if(Map[point(y,t)]==2) que[++tail]=point(y,t);
		}
		father[x]=y;
		V[x].clear();
	}
	for(int i=1;i<=n;i++) ans+=(i==father[i]);
	if(ans==1) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 102400
from bisect import bisect_left

N = int(input())
L = list(map(int,input().split()))
L.sort()
 
result = 0

for aIndex,a in enumerate(L[:N-2]):
    for bIndex,b in enumerate(L[aIndex+1:N-1]):
        bIndex = aIndex + bIndex + 1
        ab = a+b
        n = bisect_left(L,ab) - bIndex - 1
        result += n
print(result)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  for (int i = 0; i < (1 << s.size() - 1); ++i) {
    st = s[0];
    int cnt = s[0] - '0';
    for (int j = 0; j < s.size() - 1; ++j) {
      if (i & (1 << j))
        st = st + "+" + s[j + 1], cnt += s[j + 1] - '0';
      else
        st = st + "-" + s[j + 1], cnt -= s[j + 1] - '0';
    }
    if (cnt == 7) {
      st = st + "=7";
      break;
    }
  }

  cout << st << endl;
  return 0;
}


Measured memory_bytes: 256
n = input()
n = int(n)

points = []
points.append(("0", "0", "0"))
for i in range(n):
  points.append(input().split())

for i in range(len(points)-1):
  dt = int(points[i+1][0]) - int(points[i][0])
  dx = int(points[i+1][1]) - int(points[i][1])
  dy = int(points[i+1][2]) - int(points[i][2])
  
  if dt < abs(dx)+abs(dy):
    print("No")
    exit()
  elif (dt - ( abs(dx)+abs(dy) ) ) % 2 == 1:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 32148
#!/usr/bin/env python3
import sys


def solve(x: "List[int]"):
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
            return
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int(next(tokens)) for _ in range(5)]  # type: "List[int]"
    solve(x)

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,a[N],mn,mx,cnt,rem;

void yes() {
  cout << "Yes\n";
  exit(0);
}

void no() {
  cout << "No\n";
  exit(0);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  mn = n + 1;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i];
    mn = min(mn,a[i]);
    mx = max(mx,a[i]);
  }
  if (mx - mn > 1)
    no();
  for (int i = 1 ; i <= n ; i++)
    if (a[i] == mx - 1)
      cnt++;
    else
      rem++;
  if (rem == 1)
    no();
  if (mx >= cnt + 1 && mx <= cnt + (n - cnt) / 2)
    yes();
  if (cnt == 0 && mx == n - 1)
    yes();
  no();
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

struct UnionFind {
   vector<int> d;
   UnionFind(int n = 0) : d(n, -1) {}
   int find(int x) {
      if (d[x] < 0) return x;
      return d[x] = find(d[x]);
   }
   bool unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x, y);
      d[x] += d[y];
      d[y] = x;
      return true;
   }
   bool same(int x, int y) { return find(x) == find(y); }
   int size(int x) { return -d[find(x)]; }
};

int main() {
   int n, m;
   cin >> n >> m;
   vector<int> a(m), b(m);
   rep(i, 0, m) {
      cin >> a[i] >> b[i];
      a[i]--, b[i]--;
   }
   int ans = 0;
   rep(i, 0, m) {
      UnionFind uf(n);
      rep(j, 0, m) {
         if (j == i) continue;
         uf.unite(a[j], b[j]);
      }
      if (uf.size(0) < n) ans++;
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3648
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		System.out.println((n-1) * (m-1));


	}

}


Measured memory_bytes: 23892
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := findMaxVolume(float64(n))
	fmt.Println(answer)
}

func findMaxVolume(limit float64) float64 {
	x := limit / 3
	y := limit / 3
	z := limit - x - y
	maxVolume := x * y * z

	return maxVolume
}


Measured memory_bytes: 512
n = int(input())
ans = 0

def divisor(N):
  div = []
  cur = N
  for i in range(1,N+1):
    if cur%i == 0:
      div.append(i)
  return len(div)

if n >= 105:
  for i in range(105, n+1, 2):
    if divisor(i)==8:
      ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 10050
#define mod 1000000007
vector<ll>v(MAX+1,0);
ll computeTotient(ll n)
{
    ll res=n;
    ll tmp=n;
    for(int i=2;i<=sqrt(tmp);i++)
    {
        if(n%i==0){
            res-=(res/i);
            while(n%i==0)
                n/=i;
        }

    }
    if(n>1)
    {
        res-=(res/n);
    }
    return res;

}
int main()
{
    for(int i=1;i<=105;i++)
    {
        for(int j=1;j<=105;j++)
        {
            for(int k=1;k<=105;k++)
            {
                int val=i*i+j*j+k*k+i*j+j*k+k*i;
                if(val<MAX)
                    v[val]++;
            }
        }
    }
    ll n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cout<<v[i]<<'\n';
} 

Measured memory_bytes: 3696
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        long h=sc.nextLong(),w=sc.nextLong();
        long total=0;
        if(w==1||h==1){
            total=1;
        }else if(w%2==0){
            total=w/2*h;
        }else{
            long f=w/2+1;
            long s=w/2;
            if(h%2==0){
                total=f*(h/2)+s*(h/2);
            }else{
                total=f*((h+1)/2)+s*(h/2);
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 25044
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		int d = (N-1)/(K-1);
		int e = (N-1)%(K-1);
		if(e == 0) {
			System.out.print(d);		
		}else {
			System.out.print(d+1);
		}
		
		in.close();
		
	}
}

Measured memory_bytes: 21972
N = int(input())
H = list(map(int, input().split()))

res = True
for i in range(N-1,0,-1):
    if H[i-1] > H[i] + 1:
        res = False
        break
    elif H[i-1] == H[i] + 1:
        H[i-1] -= 1

print('Yes' if res else 'No')


Measured memory_bytes: 14276
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
ll n;int l,r;
vector<int> Q(ll n){
    vector<int> ans;
    if (n<=2){
        for (int i=1;i<=n;i++) ans.push_back(--l);
        return ans;
    }
    ans=Q((n-1)>>1);
    ans.push_back(++r);
    if (!(n&1)) ans.push_back(--l);
    return ans;
}
vector<int> a;
int main()
{
    scanf("%lld",&n);
    l=51;r=50;
    a=Q(n);
    for (int i=l;i<=r;i++) a.push_back(i);
    printf("%d\n",(int)a.size());
    for (int i=0;i<a.size();i++) printf("%d ",a[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	optimizator;
	string a;
	cin>>a;
	for(int i=0; i<a.size(); i++){
		if(i%2==0){
			if(a[i]=='L'){
				cout<<"No";
				return 0;
			}
		}
		else{
			if(a[i]=='R'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string replace_x(string a, int b) {
  int pos = a.find("X");
  while (pos != string::npos) {
    a.replace(pos, 1, {static_cast<char>(b + '0')});
    pos = a.find("X", pos + 1);
  }
  return (a.length() > 1 && a[0] == '0') ? "NA" : a;
}

void fillzero(string &a, int n) {
  ostringstream ss;
  ss << setw(n) << setfill('0') << a;
  a = ss.str();
}

string add(string a, string b, int n) {
  string c(n, '0');
  int plus = 0;
  for (int i = n - 1; 0 <= i; --i) {
    int ai = a[i] - '0';
    int bi = b[i] - '0';
    int ci = ai + bi + plus;
    plus = ci / 10;
    c[i] = (ci % 10) + '0';
  }
  return c;
}

int main() {
  string str;
  while (cin >> str) {
    string a, b, c;
    stringstream ss(str);
    getline(ss, a, '+');
    getline(ss, b, '=');
    getline(ss, c);

    string ans = "NA";
    for (int i = 0; i < 10; ++i) {
      string a2 = replace_x(a, i);
      string b2 = replace_x(b, i);
      string c2 = replace_x(c, i);
      if (a2 == "NA" || b2 == "NA" || c2 == "NA")
        continue;

      vector<unsigned long> nvec = {a2.length(), b2.length(), c2.length()};
      int n = *max_element(nvec.begin(), nvec.end()) + 1;
      fillzero(a2, n);
      fillzero(b2, n);
      fillzero(c2, n);

      if (add(a2, b2, n) == c2)
        ans = {static_cast<char>(i + '0')};
    }
    cout << ans << endl;
  }
}


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

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int k, s;
long long ans = 0;

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

	for (int i = 0; i <= k && i <= s; i++)
		for (int j = 0; j <= k && j <= k; j++) {
			if (s - i - j <= k && s - i - j >= 0)
				ans++;
		}

	cout << ans << endl;
//	cin >> s;
	return 0;
}

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

int main() {
  char a;
  cin>>a;
   if (isupper(a))    cout<<"A"<<endl;
   else cout<<"a"<<endl;
}

Measured memory_bytes: 3588
array_data = map(int, raw_input().split())
n = array_data[0]
m = array_data[1]

A = []
for i in range(n):
	partial_A = map(int, raw_input().split())
	A.append(partial_A)

b = []
for i in range(m):
	partial_b = int(raw_input())
	b.append(partial_b)

ans = []
for i in range(n):
	partial_ans = 0
	for j in range(m):
		partial_ans += A[i][j] * b[j]
	ans.append(partial_ans)

for i in range(len(ans)):
	print ans[i]

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

int main() {
  int n, t, a, b, dp[6000] = {}, ans = 0;
  vector<pair<int, int> > p;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    p.push_back({a, -b});
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < n; i++) {
    for (int j = t - 1; j >= 0; j--) {
      dp[j + p[i].first] = max(dp[j + p[i].first], dp[j] - p[i].second);
    }
  }
  for (int i = 0; i < 6000; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n,i,j,minj,max,counter=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n-1;i++){
        minj=i;
        for(j=i+1;j<n;j++)if(a[minj]>a[j])minj=j;
        if(a[i]>a[minj]){
            max=a[i];
            a[i]=a[minj];
            a[minj]=max;
            counter++;
        }
    }
    for(i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<a[i];
    }cout<<endl<<counter<<endl;
    return 0;
}


Measured memory_bytes: 3112
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for j in range(m)]
for a,b in ab:
    abcd=[abs(a-c)+abs(b-d) for c,d in cd]
    print(abcd.index(min(abcd))+1)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#define ll long long
#define Max 1e18
using namespace std;
int main()
{
    ll a,b,c;
    ll n;
    while(cin>>a>>b>>c>>n)
    {
        ll x=a,y=b,z=c;
        ll k=n*(n-1)/2;
            if(n%2)
            {
                x=(k-1)*a+k*b+k*c;
                y=k*a+(k-1)*b+k*c;
                z=k*a+k*b+(k-1)*c;
            }
            else
            {
                x=(k+1)*a+k*b+k*c;
                y=k*a+(k+1)*b+k*c;
                z=k*a+k*b+(k+1)*c;
            }
        if(abs(x-y)-Max>0)
            cout<<"Unfair"<<endl;
            else
                cout<<x-y<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, k = map(int, input().split())
a = [0]*(n+1)
a[0] = 1
for _ in range(k):
    _ = input()
    d = list(map(int, input().split()))
    for di in d:
        a[di] += 1
cnt = Counter(a)
if 0 in cnt:
    print(cnt[0])
else:
    print(0)

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

int main()
{
    int dif1[3], dif2[3], n[3];
    rep(i,3){
        rep(j,3){
            cin >> n[j];
        }
        dif1[i] = n[0] - n[1];
        dif2[i] = n[1] - n[2];
    }
    if (dif1[0] == dif1[1] && dif1[1] == dif1[2]){
        if (dif2[0] == dif2[1] && dif2[1] == dif2[2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/* Madar Bozorg migoft : "dorost mishavad"
va hamishe badash b aseman negah mikard o mikhandid
hatm daram k chiz haii ""DARBARE KHODA"" midanest
k ma az an bi khabar budim :) */
//RTn_E
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define _file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define sp setprecision
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define pii pair < int , int >
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 100;
const ll inf = 1e18;

//Main CODE :/\

int a[maxn];
int main() {
    ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a , a + 4);
    if (a[0] != 1 || a[1] != 4 || a[2] != 7 || a[3] != 9)
        return cout << "NO\n" , 0;
    cout << "YES\n";
    return 0;
}
//The_End
//Game Over :D


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

typedef long long ll;
#define fi first
#define se second

using namespace std;

///////////////////////////////////////
//
//
///////////////////////////////////////
//

int N;
int M;
int a;
int b;
int Q[112345];
int jdg = 1;

int main(){
  
  cin>>N>>M;
  
  fill( Q, Q+N+1, 0 );
  
  int i;
  
  for( i = 0; i < M; i++ ){
    scanf("%d %d", &a, &b);
    Q[a]++;
    Q[b]++;
  }
  
  for( i = 1; i <= N; i++ ){
    if( Q[i]%2 ){
      jdg = 0;
      break;
    }
  }
  
  if( jdg ) puts("YES");
  else{     puts("NO");}
  
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner date = new Scanner(System.in);

		int [] num = new int [10];
		
		for (int i = 0; i < 10; i++) {
			num[i] = date.nextInt();
		}
		
		java.util.Arrays.sort(num);
		
		for (int i = 9; i > 6; i--) {
			System.out.println(num[i]);
		}
		
	
	}

}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

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

  int rz = 0, ro = 0;
  REP(i,s.length()) {
    if(i%2 == 0) {
      if(s[i] == '0') {
        ro++;
      } else {
        rz++;
      }
    } else {
      if(s[i] == '0') {
        rz++;
      } else {
        ro++;
      }
    }
  }

  cout << min(rz, ro) << endl;
}


Measured memory_bytes: 512
N=int(input())
S=list(map(str,input()))
for i in range(len(S)):
  if ord(S[i])+N>90:
    S[i]=chr(ord(S[i])+N-26)
  else:
    S[i]=chr(ord(S[i])+N)
print("".join(map(str,S)))

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

using namespace std;
using ll = long long;

const ll mxs = 1e18 + 10;


int N, W;
vector<int> w, v;

int main(){
    cin>>N>>W;
    w.resize(N), v.resize(N);
    for(int i = 0; i < N; i++){
        cin>>w[i]>>v[i];
    }
    int V = 0;
    for(auto x : v){
        V += x;
    }
    //dp[i] is min weight to get i value
    vector<ll> dp(V + 1);
    for(int i = 1; i < (int) dp.size(); i++) dp[i] = mxs;
    for(int i = 0; i < N; i++){
        vector<ll> ndp(V + 1);
        for(int j = 0; j <= V; j++){
            if(j >= v[i]){
                ndp[j] = min(dp[j], (ll) w[i] + dp[j - v[i]]);
            }else{
                ndp[j] = dp[j];
            }
        }
        dp = ndp;
    }
    int res = 0;
    for(int i = V; i >= 0; i--){
        if(dp[i] <= W){
            res = i;
            break;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

typedef long long ll;

#define MAX 100002

int main()
{
  ll n, c;
  ll x[MAX], v[MAX];

  cin >> n >> c;
  for(int i = 1; i <= n; i++){
    cin >> x[i] >> v[i];
  }

  ll l[MAX], r[MAX];
  ll lmax[MAX], rmax[MAX];
  for(int i = 1; i <= n; i++){
    r[i] = r[i-1] + v[i];
    rmax[i] = max(rmax[i-1], r[i] - x[i]);
  }

  for(int i = n; i > 0; i--){
    l[i] = l[i+1] + v[i];
    lmax[i] = max(lmax[i+1], l[i] - (c - x[i]));
  }

  ll ans = 0;
  for(int i = 1; i <= n; i++){
    if(i != n) ans = max(ans, r[i] - 2*x[i] + lmax[i+1]);
    if(i != 1) ans = max(ans, l[i] - 2*(c - x[i]) + rmax[i-1]);
    ans = max(ans, max(rmax[i], lmax[i]));
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int nr, N, M, leftEnd[500009], rightEnd[500009], t[500009], first[500009][26];
char s[500009];
vector < int > v[500009];

void dfs (int nod)
{
    leftEnd[nod] = ++nr;
    for (auto it : v[nod])
        dfs (it);
    rightEnd[nod] = nr;
}

bool isAncestor (int up, int down)
{
    return (leftEnd[up] <= leftEnd[down] && leftEnd[down] <= rightEnd[up]);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s", s + 1), N = strlen (s + 1);
for (int i=1; i<=N; i++)
    s[i] -= 'a';
for (int i=N; i>=1; i--)
{
    int c = s[i];
    t[i] = -1, first[i][s[i]] = i;
    for (int j=i + 1; j<=N; j++)
    {
        if (s[j] == c)
        {
            if (c == 25)
            {
                t[i] = j + 1;
                break;
            }
            c ++, first[i][c] = j;
        }
        else
        {
            j = first[j][c];
            if (j <= 0) break;
            if (c == 25)
            {
                t[i] = j + 1;
                break;
            }
            c ++, first[i][c] = j;
        }
    }
    if (t[i] != -1)
    {
        for (int j=0; j<26; j++)
            if (first[i][j] <= 0)
                first[i][j] = first[t[i]][j];
    }
}
for (int i=1; i<=N; i++)
    if (t[i] != -1)
        v[t[i]].push_back (i);
for (int i=1; i<=N + 1; i++)
    if (t[i] == -1 || i == N + 1)
        dfs (i);
scanf ("%d", &M);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    if (isAncestor (y + 1, x)) printf ("Yes\n");
    else printf ("No\n");
}
return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	vector<llong> H;

	cin >> N;
	H.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> H[i];

	bool check = true;
	H[0]--;
	for (int i = 1; i < N; ++i) {
		if (H[i] > H[i-1])
			H[i]--;
		check &= H[i-1] <= H[i];
	}

	if (check)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1024
n, k, q = map(int, input().split())
a = []
for _ in range(q):
    a.append(int(input()))
score = [k-q] * n
for i in range(q):
    score[a[i]-1] += 1
for j in range(n):
    if score[j] <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 10472
import sys
input = sys.stdin.readline

def linput(tt=int):
	return list(map(tt,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	a,b = linput(str)
	A = int(a)
	B = int((float(b) + .0001) * 100)
	
	res = A * B // 100
	print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 9192
#include <iostream>
using namespace std;
 
bool f(int p) {
    for (int i=2; i*i<=p; i++) {
        if (p % i == 0) return false;
    }
    return true;
}
 
int main() {
    int N;
    while (cin >> N) {
        int p1, p2;
        for (p1=N-1; ; p1--) if (f(p1)) break;
        for (p2=N+1; ; p2++) if (f(p2)) break;
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3080