akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
const int MAXN = 234567;
int lead[MAXN], sz[MAXN], par[MAXN];

int find(int x) {
    return x == par[x] ? x : par[x] = find(par[x]);
}

void merge(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    par[x] = y;
    sz[y] += sz[x];
    lead[y] = min(lead[y], lead[x]);
}

int main() {
    int N;
    scanf("%d", &N);
    vector<pair<pii, int>> V1;
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        V1.push_back(make_pair(make_pair(x, y), i));
    }
    sort(V1.begin(), V1.end());
    set<pii> st;
    for (int i = 0; i < N; i++) {
        int y = V1[i].first.second;
        int idx = V1[i].second;
        par[idx] = idx;
        sz[idx] = 1;
        lead[idx] = y;
    }
    for (int i = 0; i < N; i++) {
        int y = V1[i].first.second;
        auto it = st.upper_bound(make_pair(y, 0));
        int idx = V1[i].second;
        if (it != st.begin()) {
            it = prev(it);
            while (1) {
                auto nit = it;
                bool OK = false;
                if (it != st.begin()) {
                    nit = prev(it);
                    OK = true;
                }
                merge(idx, it->second);
                st.erase(it);
                if (!OK) break;
                it = nit;
            }
        }
        idx = find(idx);
        st.insert(make_pair(lead[idx], idx));
    }
    for (int i = 0; i < N; i++) {
        printf("%d\n", sz[find(i)]);
    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
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; }
//ミョ(-ω- ?)
int main() {
    ll n,k;
    cin >> n >> k;
    if(k%2){
        ll x = n/k;
        cout << x * x * x << "\n";
    }else{
        ll x = n/k;
        ll y = 0;
        repp(i,1,n+1)if(i%k == k/2 )y++;
        cout << x * x * x + y * y * y << "\n";
    }
    return 0;
}

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

bool chkai(string s){
    int size=s.size();
    string t=s;
    for(int i=0;i<size;i++){
        t[i]=s[size-1-i];
    }
    //cout <<t << endl;
    if(s==t){return true;}else{return false;}
}

int main(){
    string s;
    cin >>s;
    int n=s.size();
    //cout <<s + " " + s.substr(0,(n-1)/2) + " " +  s.substr((n+1)/2,(n-1)/2) << endl;
    if(chkai(s) && chkai(s.substr(0,(n-1)/2)) && chkai(s.substr((n+1)/2,(n-1)/2))){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <tuple>
#include <climits>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <numeric>
#include <fstream>
#include <map>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <array>
#include <chrono>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    uint32_t count = K;
    for(int i=0; i<N-1; i++) {
        count *= (K-1);
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



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

  int n;
  cin>>n;
  vector<vector<P>> a(n);
  rep(i,n){
    int c;
    cin>>c;
    while(c--){
      int x,y;
      cin>>x>>y;
      x--;
      a[i].PB(P(x,y));
    }
  }

  int ans=0;
  rep(bit,1<<n){
    bool flag=true;
    int s=0;
    rep(i,n){
      if(bit&(1<<i)){
        s++;
        for(P p:a[i]){
          if(!(((bit>>p.F)&1)==p.S)) flag=false;
        }
      }
    }
    if(flag){
      ans=max(ans,s);
    }
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int before = 0;
  ll ans = 0;
  rep(i, n){
    int a;
    cin >> a;
    if(i){
      if(before > x){
        ans += before - x;
        before = x;
      }
      if(a + before > x){
        ans += a + before - x;
        a -= a + before - x;
      }
    }
    before = a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
M=[]
Y=[]
for i in range(N):
  n,a=input().split()
  M.append(float(n))
  Y.append(a)
m=0
r=380000
for i in range(N):
  if Y[i]=='JPY':
    m+=float(M[i])
  else:
    m+=float(M[i])*r
print(m)

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

int main(void)
{
	vector<int>A;
	vector<int>B;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		A.push_back(temp);
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		int temp;
		cin >> temp;
		B.push_back(temp);
	}
	cout<<lexicographical_compare(A.begin(), A.end(), B.begin(), B.end())<< endl;
	return 0;
}


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

main(int argc, char const *argv[])
{
	int n,m,p;
	while(cin>>n>>m>>p,n)
	{
		int x,s=0,w;
		for (int i = 0; i < n; ++i)
		{
			cin>>x;
			s+=x;
			if(i==m-1) w=x;
		}
		s*=100;
		if(w>0)	cout<<s*(100-p)/100/w<<endl;
		else cout<<"0\n";
	}
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i, a , b) for (ll i =a ; i < b ; i++)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e5+5;
            const ll mod = 1e9+7;
            const ll inf = 1e18;
            ll   n  , k  , m  , l , r , u , z , d   , p[N],  c[N] , ans = -inf, res , vis[N];

    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2) ;
        pt *= pt  , pt %= mod;
        if(n&1)
            pt *= a , pt %= mod;
        return pt;
    }

    ll solve(const vector <ll> v ,ll lim  , bool can_empty)
    {
        ll sz = (ll)v.size();
        vector <ll> sums(2*sz+1);
        for(int i =0 ; i < 2*sz; i++)
        {
            sums[i+1] = sums[i] + v[(i)%sz];
        }
        multiset <ll> seen;
        ll ans = can_empty ? 0 : -inf;
        for(int i = 0; i <= 2*sz ; i++)
        {
            if(!seen.empty())
            {
                ans = max(ans , sums[i] - *seen.begin());
            }
            seen.insert(sums[i]);
            ll l =  i- lim;
            if(l >=0 )
            {
                seen.erase(seen.find(sums[l]));
            }
        }
        return ans;
    }


    int main()
    {
         IOS;
         int ts =1;
         ///cin >> ts ;
         while(ts--)
         {
            cin >> n >> k;
            rep(i,1,n+1) cin >> p[i];
            rep(i,1,n+1) cin >> c[i];
            rep(i,1,n+1)
            {
                if(!vis[i])
                {
                    ll x =  i;
                    vector <ll> v;
                    do
                    {
                        v.pb(c[x]);
                        x=  p[x];
                        vis[x] = 1;
                    }while(x != i);

                    ll sum = 0 , length_of_cycle = (ll)v.size() ;
                    for(auto x : v) sum += x;
                    ll full = k / length_of_cycle , rest = k % length_of_cycle;
                    ans=  max(ans , solve( v , min(k ,length_of_cycle-1) , false )  );
                    ans  = max(ans , solve( v , rest , full >=1 ) + 1ll*sum*full );
                    if(full >= 1)
                    ans = max( ans ,  solve(v , length_of_cycle-1 , full > 1) + 1ll*sum*(full-1));
                }
            }
            cout << ans << endl;
         }
    }


Measured memory_bytes: 4120
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

int main(){
  int input(n);
  rep(x, n){
    int input(y);
    int input(m);
    int input(d);
    int day = -1;

    RFOR(i, y - 1, 1){
      if(i%3 == 0) day += 20 * 10;
      else day += 20*5 + 19*5;
    }

    if(y%3 == 0){
      day += (m - 1) * 20;
    }else{
      RFOR(i, m - 1, 1){
        if(i%2 == 1) day += 20;
        else day += 19;
      }
    }

    day += d;

    p("%d", 196470 - day);
  }
}

Measured memory_bytes: 3168
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define It it=se.begin();it!=se.end();it++
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define unmap unordered_map
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define sh short int
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
string s,t;
int main(){
    cin>>s>>t;
    string ss = "";
    for(int i=0;i<s.size();i++){
        ss += t[i];
    }
    if(s != ss) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

import bisect
from collections import deque


def main():
	n=int(input())
	A=[int(input()) for _ in range(n)]
	
	Q=deque([A[0]])
	
	for i in range(1,n):
		if A[i]<=Q[0]:
			Q.appendleft(A[i])

		else:
			ix=bisect.bisect_left(Q,A[i])
			Q[ix-1]=A[i]
	
	print(len(Q))
	
	
	
	
	



if __name__ == "__main__":
	main()


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

sum1=0
ans=0
for i in range(n):
    for j in range(m):
        sum1+=a[i][j]*b[j]
    sum1+=c
    if sum1>0:
        ans+=1
    sum1=0
print(ans)

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

H, W = map(int, input().split())
s = []

for i in range(H):
    s.append(list(input()))

for i in range(H):
    for j in range(W):
        OK_cnt = 0
        if s[i][j] == '#':
            #上
            if j > 0 and s[i][j-1] == '#':
                OK_cnt += 1
            #右
            if i+1 < H and s[i+1][j] == '#':
                OK_cnt += 1
            #下
            if j+1 < W and s[i][j+1] == '#':
                OK_cnt += 1
            #左
            if i > 0 and s[i-1][j] == '#':
                OK_cnt += 1
            if OK_cnt == 0:
                print('No')
                exit()

print('Yes')


Measured memory_bytes: 3064
/*author : Yashvardhan
Friday, May 31, 2019
9:52 AM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int getpow(double x){
	for(int i = 0; i <= 17 ; i++){
		int val = pow(2,i,mod);
		if(val >= x){
			debug(x,val);
			return val;
		}
	}
	return -1;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,k;
	cin>>n>>k;
	double tmp = 0;
	for(int i = 1; i <= n; i++){
		double q = (double) k/i;
		tmp += (1/(double) getpow(q));
	}

	tmp *= (1/(double) n);

	cout<<setprecision(20)<<fixed;
	cout<<tmp<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,a[300000];
    long long s=0;
    cin>>n;
    for(int i=0;i<n*3;i++){
        cin>>a[i];
    }
    sort(a,a+n*3,greater<int>());
    for(int i=1;i<2*n;i+=2){
        s+=a[i];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> GRA;

int i,j,N,K,x,a,ans;

int main() {
	cin >> N >> K;
	
	vector<int> A(200000,200001);

	REPI(0,N) {
		cin >> x;
		if ( A[x] == 200001 ) {
			a++;
			A[x] = 1;
		} else A[x]++;
	}
	
	sort(A.begin(), A.end());
	
	while(a > K) {
		ans += A[i];
		a--;
		i++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n),r(110000);
  rep(i,n){
    cin >> a[i];
    r[a[i]]++;
  }
  int q;
  cin >> q;
  ll ans = 0;
  rep(i,110000){
    ans+= i*r[i];
  }

  while(q--){
    ll b,c;
    cin >> b >> c;
    ll cnt = r[b];
    r[b] = 0;
    r[c]+=cnt;
    ans-=b*cnt;
    ans+=c*cnt;
    cout<<ans<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 4840
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] aaa = scanner.nextLine().split(" ", 3);

        int[] arr = new int[3];
        for (int i = 0; i < 3; i++) {
            arr[i] = Integer.parseInt(aaa[i]);
        }
        Arrays.sort(arr);

        System.out.println(arr[2] - arr[0]);
    }
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  vector<int> A(N + 1);
  vector<bool> ans(N + 1,false);
  int num = 0;
  bool all_zero = true;
  for(int i = 1;i <= N;i++) {
      cin >> A.at(i);
      if(A.at(i) == 1) all_zero = false;
  }

    
  for(int i = N;i >= 1;i--) {
      if(i >= N / 2 + 1) {
          if(A.at(i) == 1) {
              ans.at(i) = true;
              num++;
          }
        }else {
            int m = (N / i) * i,sum = 0;
            while(m > i) {
                sum += A.at(m);
                m -= i;
            }
            if(sum % 2 != A.at(i)) {
                num++;
                ans.at(i) = true;
                A.at(i) = 1;
            }else {
                A.at(i) = 0;
            }
        }
  }

    if(all_zero) {
        cout << 0 << endl;
    }else {
        if(num == 0) {
            cout << -1 << endl;
        }else {
            cout << num << endl;
        }
    }

    for(int i = 1;i <= N;i++) {
      if(ans.at(i)) cout << i << " ";
    }

  

 
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;

struct P {
    int a;
    int b;

    bool operator<(const P &another) const {
        if (b == another.b)
            return a < another.a;
        else
            return b < another.b;
    };
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<P> p(M);
    rep(i, M) cin >> p[i].a >> p[i].b;

    sort(all(p));

    int b_before = 0;
    int ans = 0;

    rep(i,M){
      if(p[i].b > b_before && p[i].a >= b_before){
        ans += 1;
        b_before = p[i].b;
      }
    }
    cout << ans << endl;
}

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

class Main {

    public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        Solver s = new Solver();
        int test = 1;
        for (int i = 1; i <= test; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

    static class Solver {
        void solve(int test_case, InputReader in, PrintWriter out) {
            String s = in.next();
            String r = in.next();
            out.println((r.charAt(1) == s.charAt(1) && r.charAt(2) == s.charAt(0) && r.charAt(0) == s.charAt(2)) ? "YES" : "NO");
        }
    }

    static class InputReader {

        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 22484
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let gcd: usize = gcd(a, b);

    let pf = prime_factorization(gcd);

    let ans = pf.len() + 1;
    return ans.to_string();
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y > 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    return x;
}

fn prime_factorization(n: usize) -> HashMap<usize, usize> {
    let mut result: HashMap<_, _> = HashMap::new();

    let mut numerator = n;
    for denominator in 2.. {
        if denominator * denominator > n {
            break;
        }
        while numerator % denominator == 0 {
            *result.entry(denominator).or_insert(0) += 1;
            numerator /= denominator;
        }
    }

    if numerator != 1 {
        result.insert(numerator, 1);
    }

    return result;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
// #define for(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9

int main() {
    int A, B, ans;

    cin >> A;
    cin >> B;

    if (A <= 9 and B <= 9) {
        ans = A * B;
        cout << ans << endl;
    } else {
        cout << "-1" << endl;
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
  	cin >> n;
  	vvi a(2, vi(n));
  	rep(i,2){
    	rep(j,n){
        	cin >> a[i][j];
        }
    }
	
  	vvi dp(3, vi(n+1,0));		// dp[i+1][j+1] が a[i][j] のマスに対応
	rep(j,n) dp[0][j] = 0;
  	rep(i,3) dp[i][0] = 0;
  	dp[1][1] = a[0][0];
  	
	rep(j,n){
  		rep(i,2){
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]) + a[i][j];
        }
    }  
  
 	cout << dp[2][n] << endl;
	return;
}

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

Measured memory_bytes: 256
// Compiled with: g++ -Wall -std=c++14 -pthread

#include <bits/stdc++.h>

using namespace std;

string s;
int main(){
    cin >> s;
    for(int i=0; i<4; i++){
        int cnt = 0;
        for(int j=0; j<4; j++){
            if (s[j] == s[i]) cnt++;
        }
        if (cnt != 2) return 0*puts("No");
    }
    cout << "Yes\n";
    return 0;
}


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


int main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<w+2;i++){
        cout<<"#";
    }
    cout<<endl;
    string a;
    for(int n=0;n<h;n++){
        cin>>a;
        cout<<"#"<<a<<"#"<<endl;
    }
    for(int m=0;m<w+2;m++){
        cout<<"#";
    }
    cout<<endl;
    return 0;
}


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

void
solver(int k, int x)
{
    if (500*k>=x)
        printf("Yes\n");
    else
    {
        printf("No\n");
    }
    return;
}

int
main(int argc, char *argv[])
{
    int K, X;

    scanf("%d%d", &K, &X);
    solver(K, X);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String s = br.readLine();
        String alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC";
        String out = "";
        for (int i=0; i<s.length(); i++) {
            int temp = alph.indexOf(s.charAt(i));
            temp += N;
            out += alph.charAt(temp);
        }
        System.out.println(out);
    }
}


Measured memory_bytes: 145108
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int 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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i < 10; i++)
  {
    for (int j = 0; j < 10; j++)
    {
      cin >> c.at(i).at(j);
    }
  }

  for (int k = 0; k < 10; k++)
  {
    for (int i = 0; i < 10; i++)
    {
      for (int j = 0; j < 10; j++)
      {
        chmin(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int A;
      cin >> A;
      if (A != -1) ans += c.at(A).at(1);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func rcvInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func gcd(a, b int) int {
	for b != 0 {
		c := a % b
		a, b = b, c
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := rcvInt()

	var x int
	y := rcvInt()
	for i := 1; i < n; i++ {
		x = rcvInt()
		y = gcd(x, y)
	}

	fmt.Println(y)
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
long long INF = 100000000000000000;
string rev(string S){
  reverse(S.begin(), S.end());
  return S;
}
bool is_palindrome(string S){
  return S == rev(S);
}
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  vector<long long> C(N);
  for (int i = 0; i < N; i++){
    cin >> S[i] >> C[i];
  }
  vector<vector<pair<long long, int>>> E(N * 41);
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 41; j++){
      int d = j - 20;
      if (d <= 0){
        if (S[i].size() < abs(d)){
          continue;
        }
        string L = S[i].substr(S[i].size() - abs(d));
        for (int k = 0; k < N; k++){
          if (S[k].size() < abs(d)){
            if (rev(S[k]) == L.substr(0, S[k].size())){
              //cout << "i = " << i << ", d = " << d << ", k = " << k << endl;
              E[i * 41 + j].push_back(make_pair(C[k], i * 41 + j + S[k].size()));
            }
          } else {
            if (S[k].substr(S[k].size() - L.size()) == rev(L)){
              //cout << "i = " << i << ", d = " << d << ", k = " << k << endl;
              E[i * 41 + j].push_back(make_pair(C[k], k * 41 + j + S[k].size()));
            }
          }
        }
      }
      if (d >= 0){
        if (S[i].size() < d){
          continue;
        }
        string R = S[i].substr(0, d);
        for (int k = 0; k < N; k++){
          if (S[k].size() < d){
            if (rev(S[k]) == R.substr(R.size() - S[k].size())){
              //cout << "i = " << i << ", d = " << d << ", k = " << k << endl;
              E[i * 41 + j].push_back(make_pair(C[k], i * 41 + j - S[k].size()));
            }
          } else {
            if (S[k].substr(0, R.size()) == rev(R)){
              //cout << "i = " << i << ", d = " << d << ", k = " << k << endl;
              E[i * 41 + j].push_back(make_pair(C[k], k * 41 + j - S[k].size()));
            }
          }
        }
      }
    }
  }
  vector<long long> dist(N * 41, INF);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
  for (int i = 0; i < N; i++){
    pq.push(make_pair(0, i * 41 + 20));
  }
  while (!pq.empty()){
    long long c = pq.top().first;
    int v = pq.top().second;
    pq.pop();
    if (dist[v] == INF){
      if (c > 0){
        dist[v] = c;
      }
      for (auto P : E[v]){
        int w = P.second;
        if (dist[w] == INF){
          pq.push(make_pair(c + P.first, w));
        }
      }
    }
  }
  long long ans = INF;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 41; j++){
      if (j <= 20){
        int d = j - 20;
        if (S[i].size() < abs(d)){
          continue;
        }
        string L = S[i].substr(S[i].size() - abs(d));
        if (is_palindrome(L)){
          ans = min(ans, dist[i * 41 + j]);
        }
      }
      if (j >= 20){
        int d = j - 20;
        if (S[i].size() < d){
          continue;
        }
        string R = S[i].substr(0, d);
        if (is_palindrome(R)){
          ans = min(ans, dist[i * 41 + j]);
        }
      }
    }
  }
  if (ans == INF){
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3964
N=int(input())
A=[]
r=[]
for i in input().split():
  A.append(int(i))
#入力した配列をソート
A.sort()

#Queue操作
t=A.pop(-1) #最大値をとりだす
#print('t=',t)
b=A.pop(0)  #最小値をとりだす
#print('b=',b)

#残りの配列において
for i in A:
  #print(i)
  #非負の場合
  if i>=0:
    r.append([b,i]) #最小値と現在の値のペア
    b=b-i  #bを更新
  #負の場合
  else:
    r.append([t,i]) #最大値と現在の値のペア
    t=t-i #tを更新
print(t-b)
r.append([t,b])
for i in r:
  #print(i)
  print(i[0],i[1])

Measured memory_bytes: 22496
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n;
int main()
{
	cin>>n;
	for(int i=0;i<=25;i++)
	{
		for(int j=0;j<=14;j++)
		{
			if(i*4+j*7==n)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}


Measured memory_bytes: 256
import itertools
N = int(input())
L = list(map(int,input().split()))
C = []
ans = 0

for c in itertools.combinations(L,3):
  C.append(c)
  
for a in C:
  a = sorted(a)
  if a[0]+a[1]>a[2] and a[0]!=a[1] and a[1]!=a[2]:
    ans+=1
    
print(ans)

Measured memory_bytes: 20628
# -*- coding: utf-8 -*-
s = input().split()
n = list(map(int,input().split()))
s2 = input()

if s[0] == s2:
  n[0] = n[0] - 1
else:
  n[1] = n[1] - 1

print(str(n[0]) +' '+str(n[1]))


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 1 << 16 | 7;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int Fac[MN], iFac[MN];
void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}
inline int Binom(int N, int M) {
	if (N < 0 || M < 0 || M > N) return 0;
	return (LL)Fac[N] * iFac[M] % Mod * iFac[N - M] % Mod;
}

int N, M, U, A[17];
int f[MN], g[MN], Ans;

int main() {
	scanf("%d%d", &N, &M);
	U = (1 << N) - 1, Init(1 << N);
	for (int i = 1; i <= M; ++i) scanf("%d", &A[i]);
	f[0] = 1;
	for (int i = M; i >= 1; --i) {
		for (int S = 0; S <= U; ++S) g[S] = f[S];
		for (int S = 0; S <= U; ++S)
			for (int j = 0; j < N; ++j) if (~S >> j & 1)
				g[S ^ 1 << j] = (g[S ^ 1 << j] - (LL)f[S] * Binom((1 << N) - A[i] - S, (1 << j) - 1)) % Mod;
		std::swap(f, g);
	}
	for (int S = 0; S <= U; ++S) {
		int num = (LL)f[S] * Fac[S ^ U] % Mod;
		for (int j = 0; j < N; ++j) if (~S >> j & 1)
			num = (LL)num * iFac[1 << j] % Mod;
		Ans = (Ans + num) % Mod;
	}
	for (int j = 0; j < N; ++j) Ans = 2ll * Ans * Fac[1 << j] % Mod;
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll n, a,b;
	cin>>n>>a>>b;
	if( (n*a)<=b)
		cout<<(n*a);
	else cout<<b;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//fixed<<setprecision(15);

signed main(){
    int n; cin >> n;
    vector<P> r(n);
    rep(i,n){
        int x,l; cin >> x >> l;
        r[i].first=x+l;
        r[i].second=x-l;
    }
    sort(all(r));
    int res=0; int pos=-1*INF;
    rep(i,n){
        if(pos<=r[i].second){ 
            res++;
            pos=r[i].first;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
 int n; cin >> n;
 string s; cin >> s;
 int ans=0;
 int flg=0;
 rep(i,n){
	if(s[i]=='A') flg = 1;
	else if(s[i]=='B' && flg==1) flg = 2; 
	else if(s[i]=='C' && flg==2){
		ans++;
		flg = 0;
	}
	else flg = 0;
 }
	out(ans);
}




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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, K;

int main(int argc, char **argv)
{
	cin >> N >> K;
	ll ma = (N-2) * (N-1) / 2;
	if (ma < K)
	{
		std::cout << -1 << std::endl;
		return 0;
	}

	vector<pair<ll, ll>> add;

	std::cout << N-1 + ma - K << std::endl;
	for (ll v = 0; v < N-1; ++v)
	{
		for (ll vv = v + 1; vv < N; ++vv)
		{
			if (vv == N-1)
				std::cout << v+1 << " " << vv+1 << std::endl;
			else
				add.push_back(P(v, vv));
		}
	}

	REP(i, ma-K)
		std::cout << add[i].first+1 << " " << add[i].second+1 << std::endl;
	
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<int> A(N),B(N),C(N-1);
	for(int i=0;i<N;i++)	cin >> A.at(i);
	for(int i=0;i<N;i++)	cin >> B.at(i);
	for(int i=0;i<N-1;i++)	cin >> C.at(i);

	int ans=0;
	for(int i=0;i<N;i++){
		ans+=B.at(A.at(i)-1);
	}
	for(int i=0;i<N-1;i++){
		if(A.at(i)+1==A.at(i+1))	ans+=C.at(A.at(i)-1);
	}
	cout << ans << endl;
	
	return 0;
}


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

int main() {
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    
    long long F = min({A, B, C, D, E});
    if (N % F == 0) cout << N / F + 4;
    else cout << N / F + 5;
    cout << endl;
}

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

int main() {
ll n,res=0,i,a=0,b=0,c=0,d=0;
cin>>n;
string s;
cin>>s;
for(i=0;i<n;i++)
{
	if(s[i]=='W')
	a++;
	else
	b++;
	
}
for(i=0;i<b;i++)
{
	if(s[i]=='R')
	c++;
}
for(;i<n;i++)
{
	if(s[i]=='W')
	d++;
}

cout<<min(n-a,min(n-b,min(b-c,a-d)))<<endl;

}

Measured memory_bytes: 3752
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

char S[5];

int main() {

	cin >> S;

	if (S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;

	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

s_pos = 0
s_neg = 0

# start neg val
cum = 0
for i in range(n):
    cum += a[i]
    if i % 2 == 0 and cum >= 0:
        s_neg += abs(cum) + 1
        cum = -1
    if i % 2 != 0 and cum <= 0:
        s_neg += abs(cum) + 1
        cum = 1

# start pos val
cum = 0
for i in range(n):
    cum += a[i]
    if i % 2 == 0 and cum <= 0:
        s_pos += abs(cum) + 1
        cum = 1
    if i % 2 != 0 and cum >= 0:
        s_pos += abs(cum) + 1
        cum = -1

ans = min(s_pos, s_neg)
print(ans)

Measured memory_bytes: 63216
s = str(input())
l = len(s)
a = 0

for i in range(l):
    if i != 0:
        if s[0] == '0':
            if i % 2 == 1:
                if s[i] != '1':
                    a += 1
            else:
                if s[i] != '0':
                    a += 1
        else:
            if i % 2 == 1:
                if s[i] != '0':
                    a += 1
            else:
                if s[i] != '1':
                    a += 1

print(a)

Measured memory_bytes: 3188
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int ar [ 7 ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for ( int i = 0 ; i < 7 ; ++ i )
		cin >> ar [ i ] ;
	int res = 0 , ans = 0 ;
	res += ( ar [ 0 ] / 2 ) * 2 ;
	res += ar [ 1 ] ;
	res += ( ar [ 3 ] / 2 ) * 2 ;
	res += ( ar [ 4 ] / 2 ) * 2 ;
	smax ( ans , res ) ;
	if ( ar [ 0 ] && ar [ 3 ] && ar [ 4 ] ) {
		res = 0 ; 
		ar [ 0 ] -- ;
		ar [ 3 ] -- ;
		ar [ 4 ] -- ;
		res += 3 ;
		res += ( ar [ 0 ] / 2 ) * 2 ;
		res += ar [ 1 ] ;
		res += ( ar [ 3 ] / 2 ) * 2 ;
		res += ( ar [ 4 ] / 2 ) * 2 ;
		smax ( ans , res ) ; 
	}
	cout << ans << '\n' ; 
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	ll n;
	cin >> n;
	vector<pair<int, int>> info(n);
	FOR(i, 0, n - 1) {
		cin >> info[i].second;
		cin >> info[i].first;
	}
	sort(ALL(info));
	ll time = 0;
	FOR(i, 0, n - 1) {
		time += info[i].second;
		if (time > info[i].first) {
			ps(No);
			return(0);
		}
	}
	ps(Yes);
	return(0);
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;
    vector<ll> array(N, 0);

    REP(i, N-1){ 
        ll t;
        cin >> t;
        array[t-1]++;
    }

    REP(i, N){ 
        cout << array[i] << endl;
    }

}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
const int maxm = 4010;
const int INF = 0x3f3f3f3f;
struct Edge{
    int to,next,cap,flow,cost;
}edge[maxm];
int head[maxn],tol;
int pre[maxn],dis[maxn];
bool vis[maxm];
int n,m,p;
void init(){
    tol=0;
    for(int i=1;i<=n;++i) head[i]=-1;
}
void addedge(int u,int v,int cap,int cost){
    edge[tol].to=v;
    edge[tol].cap=cap;
    edge[tol].cost=cost;
    edge[tol].flow=0;
    edge[tol].next=head[u];
    head[u]=tol++;
    edge[tol].to=u;
    edge[tol].cap=0;
    edge[tol].cost=-cost;
    edge[tol].flow=0;
    edge[tol].next=head[v];
    head[v]=tol++;
}
bool spfa(int s,int t){
    queue<int> q;
    for(int i=1;i<=n;++i){
        dis[i]=INF; vis[i]=false; pre[i]=-1;
    }
    dis[s]=0; vis[s]=true;
    q.push(s);
    while (!q.empty()){
        int u = q.front(); q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=edge[i].next){
            int v=edge[i].to;
            if(edge[i].cap>edge[i].flow&&dis[v]>dis[u]+edge[i].cost){
                dis[v]=dis[u]+edge[i].cost;
                pre[v]=i;
                if(!vis[v]){
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
    if(pre[t]==-1) return false;
    else return true;
}
double minCostMaxflow(int s,int t){
    int flow=0,cost=0; double ans=INF;
    while (spfa(s,t)){
        int Min = INF;
        for(int i=pre[t];i!=-1;i=pre[edge[i^1].to]){
            if(Min>edge[i].cap-edge[i].flow)
                Min=edge[i].cap-edge[i].flow;
        }
        for(int i=pre[t];i!=-1;i=pre[edge[i^1].to]){
            edge[i].flow+=Min;
            edge[i^1].flow-=Min;
            cost+=edge[i].cost*Min;
        }
        flow+=Min;
        ans=min(ans,(1.0*cost+p)/flow);
    }
    return ans;
}

int s,t,u,v,d,c;
int main(){
    scanf("%d %d %d %d %d",&n,&m,&p,&s,&t); init();
    while(m--){
        scanf("%d %d %d %d",&u,&v,&d,&c);
        addedge(u,v,c,d);
    }
    printf("%lf\n",minCostMaxflow(s,t));
}


Measured memory_bytes: 3372
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
# define ft first
# define sec second

int main()
{
   int x;
   cin>>x;
   if(x>=30 ) cout<<"Yes\n";
   else cout<<"No\n";

}


Measured memory_bytes: 3128
import sys
from collections import defaultdict
K = int(input())
n = len(str(K))

r = 7 % K
dict = defaultdict(bool)  # int/bool/list....
dict[r] = True
orgr = r
d = 1
for _ in range(K + 1):
    if r == 0:
        print(d)
        break
    d += 1
    r = (10 * r + 7) % K
    if dict[r]:
        print(-1)
        sys.exit()
    dict[r] = True

Measured memory_bytes: 160468
import numpy as np

N,M=map(int,input().split())
ac=np.array([0]*N)
wa=np.array([0]*N)

for i in range(M):
    a,b=input().split()
    A=int(a)
    if ac[A-1]==0 and b=="WA":
        wa[A-1]+=1
    else :
        ac[A-1]=1

cal=sum(ac)
ans=sum(ac*wa)
print(cal, ans)


Measured memory_bytes: 16584