akhauriyash/Code-Regression huggingface dataset:
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
    	ll x;
    	cin>> x;
    	ll p=100;
    	ll count=0;
    	while(p<x)
		{
			p=p+p/100;
			count++;
		}
		cout<< count<< endl;




    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int mn = min(A, B);
  int mx = max(A, B);
  if (mn < C && C < mx)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.append(0)

a_ = 0
total = 0
for a in A:
    total += abs(a_ - a)
    a_ = a

b = 0
for i, a in enumerate(A[:-1]):
    c = A[i+1]
    ans = total - abs(b - a) - abs(c - a) + abs(c - b)
    print(ans)
    b = a

Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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() {
    //cout.precision(10);
    int n; cin >> n;
    int r = 1;
    int l = 1;
    vel a(n+1,0);
    rep(i,n) cin >> a[i+1];
    ll sum = a[1];
    ll checker = a[1];
    ll ans = 1LL;
    while(l < n){
        l++;
        sum += a[l];
        checker ^= a[l];
        while(checker != sum){
            sum -= a[r];
            checker ^= a[r];
            r++;
        }
        ans += (l - r + 1);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n,temp=1,sum=0;

	cin >>n;
	int *array=new int[n];
	for(int i=0;i<n;i++)cin >>array[i];
	for(int i=0;i<n;i++){
		temp=array[temp-1];
		sum++;
		if(temp==2)break;
		else if(i==n-1)sum=-1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int main() {
	int N;
	cin >> N;
	int A[200000];
	rep(i, N) {
		cin >> A[i];
		A[i] -= i + 1 - 200000;
	}

	int l = 0;
	int r = 1010101010;

	while (l != r) {
		int mid = (l + r) / 2 + 1;
		int tasu = 0;
		rep(i, N) if (A[i] >= mid) tasu++;
		if (tasu >= N / 2 + N % 2) l = mid;
		else r = mid - 1;
	}

	long long kotae = 0;
	rep(i, N) {
		kotae += abs(A[i] - l);
	}

	cout << kotae << "\n";
	Would you please return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int a[25],b[25],c[24];
int main()
{
    int n,ans=0,d;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    for(int i=1;i<=n-1;i++)
    {
        cin>>c[i];
    }
    for(int i=1;i<=n;i++)
    {
        d=a[i];
        ans+=b[d];
        if(i>1&&d==a[i-1]+1)
        {
            ans+=c[d-1];
        }
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;


int main() {
	map<string, ll> m;
	ll n;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;


}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int M=25;
int n;
int A[M],ans;
bool mp[M];

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&A[i]);
	}
	for(int i=2; i<n; i++){
		if(A[i]>A[i-1] && A[i]<A[i+1] || A[i]<A[i-1] && A[i]>A[i+1]){
			if(!mp[i]) ans++;
			mp[i]=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 505050

using namespace std;
int dp[maxn],d[maxn],n,m;
vector <int> h[maxn];
queue <int> q;

int main(){
    cin >> n >> m;
    for (int i=1;i<=n;i++) dp[i]=1;
    for (int i=1;i<=m;i++){
        int u,v; cin >> u >> v;
        h[u].push_back(v); d[v]++;
    }
    for (int i=1;i<=n;i++) if (!d[i]) q.push(i);
    while (!q.empty()){
        int u=q.front(); q.pop();
        for (int i=0;i<h[u].size();i++){
            int v=h[u][i];
            dp[v]=max(dp[v],dp[u]+1);
            d[v]--;
            if (!d[v]) q.push(v);
        }
    }
    int ans=0;
    for (int i=1;i<=n;i++) ans=max(ans,dp[i]);
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;

int n, m, k, p;
vector<int> et[1000];
vector<int> ec[1000];
int event[1000];	//event[i] = ??????i????¨?????????¨???????????????????????????event[i]???????????????-1?????????????????????
int dp[1000][4096];	//dp[i][j] = [???????????????i, ??????????????¶???j(2k?????????)]??????????????§???????????????

int Dijkstra(){
	typedef tuple<int, int, int> T;	//dist, verb, state
	static priority_queue<T, vector<T>, greater<T> > que;
	
	que.push(T(0, p, 0));	//init
	while( !que.empty() ){
		T now = que.top();
		int d = get<0>(now);
		int v = get<1>(now);
		int s = get<2>(now);
		que.pop();
		//pick or deliver
		if( event[v] >= 0 ){
			if( event[v] % 2 == 0 )
				s |= (1 << event[v]);
			else if( (s >> (event[v] - 1)) & 1 )
				s |= (1 << event[v]);
		}
		if( dp[v][s] <= d )
			continue;
		dp[v][s] = d;
		//cout << "(" << v << ", " << s << ") = " << dp[v][s] << endl;
		
		for( int i = 0; i < et[v].size(); i++ ){
			int nv = et[v][i];
			int nd = d + ec[v][i];
			que.push(T(nd, nv, s));
		}
	}
	int ans = 1145141919;
	for( int i = 0; i < n; i++ ){
		ans = min(ans, dp[i][(1<<(2*k)) - 1]);
	}
	return ans;
}

void input(){
	for( int i = 0; i < 1000; i++ ){
		event[i] = -1;
	}
	for( int i = 0; i < 1000; i++ ){
		for( int j = 0; j < 4096; j++ ){
			dp[i][j] = 1145141919;
		}
	}
	
	cin >> n >> m >> k >> p;
	p--;
	for( int i = 0; i < m; i++ ){
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		et[u].push_back(v); ec[u].push_back(w);
		et[v].push_back(u); ec[v].push_back(w);
	}
	for( int i = 0; i < k; i++ ){
		int s, t;
		cin >> s >> t;
		s--; t--;
		event[s] = 2*i;
		event[t] = 2*i + 1;
	}
	/*for( int i = 0; i < n; i++ ){
		cout << "v = " << i << " event = " << event[i] << endl;
	}*/
}

int main(){
	input();
	int res = Dijkstra();
	if( res > 1000000000 )
		cout << "Cannot deliver" << endl;
	else
		cout << res << endl;
	return 0;
}

Measured memory_bytes: 25264
import math

A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

A_divs = make_divisors(A)
B_divs = make_divisors(B)

A_divs_len = len(B_divs)
B_divs_len = len(B_divs)
AB_divs = []

if A_divs_len >= B_divs_len:
    for v in B_divs:
        if v in A_divs:
            AB_divs.append(v)
        else:
            continue
else:
    for w in A_divs:
        if w in B_divs:
            AB_divs.append(w)

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

primes = []

for v in AB_divs:
    if is_prime(v):
        primes.append(v)

primes.insert(0, 1)
print(len(primes))


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

int main(){
    string input;
    while(getline(cin, input), input != "END OF INPUT"){

        int num = 0;
        for(int i=0; i < input.size(); i++){
            if(input[i] == ' '){
                cout << num;
                num = 0;
            }
            else {
                num++;
            }
        }
        cout << num<< endl;
    }
}

Measured memory_bytes: 1184
while True:
    H, W = map(int,input().split())
    if (H,W) == (0,0):
        break
    line1 = "#."*(W//2)+"#"*(W%2)
    line2 = ".#"*(W//2)+"."*(W%2)
    
    for j in range(0,H):
        if j%2 == 0:
            print(line1)
        else:
            print(line2)
    print()


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double eps = 1e-8;

#define INF 2147483647
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define RESET(v) memset(v,0,sizeof(v))
#define EB emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep1n(i,n)	for(int i=1;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie();cout.tie();
 
#define MXN 1000000 //10^6

int main(){
	ll n, a[70];
	unsigned long long ipt;
	bitset<62> bt;
	
	RESET(a);
	cin>>n;
	rep(i,n){
		cin>>ipt;
		bt = ipt;
		rep(j, 62)
			if(bt[j])	a[j]++;
	}
	
	long long ans = 0, sum, k;
	k = 1;
	rep(i, 62){
		sum = (((n - a[i]) * a[i]) % MOD)*(k%MOD);
		ans += sum%MOD;
		ans %= MOD;
		k <<= 1;
	}
	cout<<ans<<'\n';
	
}







Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class CBoxesAndCandies {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    rep(i, N) {
      cin >> a[i];
    }
    int ans = 0;
    if (a[0] > x) {
      ans += a[0] - x;
      a[0] = x;
    }
    rep(i, N - 1) {
      if (a[i + 1] + a[i] > x) {
        ans += a[i + 1] + a[i] - x;
        a[i + 1] = a[i + 1] - (a[i + 1] + a[i] - x);
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  CBoxesAndCandies solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int sum;
inline int read(){
    int f=1,x=0;
    char ch;
    do{
        ch=getchar();
        if(ch=='-'){
            f=-1;
        }
    }while(ch<'0'||ch>'9');
    do{
        x=x*10+ch-48;
        ch=getchar();
    }while(ch>='0'&&ch<='9');
    return f*x;
}
int main(){
    int pd1=0,pd2=0;
    string s1,s2;
    ios::sync_with_stdio(0);
    cin>>s1>>s2;
    for(int i=0;i<s1.length()+s2.length();++i){
        if(i%2==0){
            cout<<s1[pd1];
            ++pd1;
        }
        else{
            cout<<s2[pd2];
            ++pd2;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
P = [0] + inpl()
C = [0] + inpl()

ans = 1000000010 * -1
for start in range(1,n+1):
    l = [0] * (n+1)
    l[start] = 1
    now = start
    score = []
    while True:
        l[now] = 1
        score.append(C[P[now]])
        if l[P[now]] == 1:
            break
        now = P[now]
    
    ruiseki = []
    for i in range(len(score)):
        if i == 0:
            ruiseki.append(score[i])
        else:
            ruiseki.append(ruiseki[i-1] + score[i])

    a = ruiseki[-1] #1ループでのスコア
    b = max(ruiseki) #1ループ中の最大スコア
    c = k // len(ruiseki) #ループ可能回数
    d = k % len(ruiseki) #ループ抜けてからのあまり回数

    tmp = 0
    if c == 0:
        tmp = max(ruiseki[:d])
    elif c > 0:
        if a <= 0:
            tmp = b
        elif d == 0:
            tmp = a*(c-1) + b
        else:
            tmp = max(a*c + max(ruiseki[:d]),a*(c-1) + b)
    ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 110636
#入力
n=int(input())
xy=[[list(map(int,input().split())) for _ in range(int(input()))] for _ in range(n)]
#bit全探索
ans=0
for i in range(2**n):
  flag=True         
  for j in range(n):
    if (i>>j)&1:    
      for x,y in xy[j]:#j人目の証言と仮定に矛盾がないか調べる
        if (i>>(x-1))&1!=y:
          flag=False
          break
  if flag==True: 
    ans=max(ans,bin(i)[2:].count('1'))     
#出力
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<ll> S(N);
    ll sum = 0;
    for(int i=0; i<N; i++) {
        cin >> S[i];
        sum += S[i];
    }
    sort(S.begin(), S.end());

    for(int i=0; i<N; i++) {
        if(sum % 10 == 0 && S[i] % 10 != 0) {
            sum -= S[i];
        }
        else if(sum % 10 != 0) {
            break;
        }
    }
    if(sum % 10 == 0) sum = 0;
    cout << sum << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> a(N);
  for (i64 i = 0; i < N; i++)
    cin >> a[i];
  i64 ans = 0;
  for (i64 i = 0; i < N; i++)
    if (i % 2 == 0 && a[i] % 2 == 1)
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 998244353;

     signed main(){
     
int n;
cin>>n;
int ans=0,a[n];
for(int i=0;i<n;i++){
   cin>>a[i];
   ans^=a[i];
}
for(int i=0;i<n;i++)cout<<(ans^a[i])<<' ';
cout<<endl;
     }


 


 






    





      

        


Measured memory_bytes: 5124
/**
 * author: Dhakad_123
 * created: 26.04.2020
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    int s, w;
    cin >> s >> w;
    
    if(w >= s){
        cout << "unsafe" <<"\n";
    }
    else{
        cout << "safe" << "\n";
        
        
    }
    return 0;
}

Measured memory_bytes: 3652
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        mut p: [Usize1; n],
    }

    let mut count = 0;
    for i in 0..n - 1 {
        if i == p[i] {
            count += 1;
            let tmp = p[i + 1];
            p[i + 1] = p[i];
            p[i] = tmp;
        }
    }
    if p[n - 1] == n - 1 {
        count += 1;
    }

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


Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#define ll long long
#define MOD 1000000007
using namespace std;

int main() {
    ll m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1!=m2)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int aa[1010];
int main(){
	int n,m,a,b;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=0;i<n;i++)scanf("%d",aa+i);
	int pos=0;
	while(pos<n&&aa[pos]>=a)pos++;
	if(n-pos<m)while(pos-1>=0&&aa[pos-1]<=b)pos--;
	printf("%d\n",pos);
}


Measured memory_bytes: 2148
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j, k, l;
	long int h, w, n;
	long int flg_first;
	long int left, right, top, under;
	long int count = 1;
	long int masu[400][400] = {{0}};
	char str[400][400];
	
	scanf("%ld%ld%ld", &h, &w, &n);
	
	for(i = 0; i < h; i++) {
		scanf("%s", str[i]);
	}
	
	for(i = 0; i < h; i++) {
		for(j = 0; j < w; j++) {
			if(str[i][j] =='#') {
				top = under = i;
				left = right = j;
				for(k = j - 1; k >= 0; k--) {
					if( (str[i][k] == '#') || (masu[i][k] >= 1) ) {
						left = k + 1;
						break;
					}
				}
				if(k <= -1) {
					left = 0;
				}
				
				for(k = j + 1; k < w; k++) {
					if( (str[i][k] == '#') || (masu[i][k] >= 1) ) {
						right = k - 1;
						break;
					}
				}
				if(k >= w) {
					right = w - 1;
				}
				
				flg_first = 0;
				for(k = i - 1; k >= 0; k--) {
					for(l = left; l <= right; l++) {
						if( (str[k][l] == '#') || (masu[k][l] >= 1) ) {
							top = k + 1;
							flg_first = 1;
							break;
						}
					}
					if(flg_first == 1) {
						break;
					}
				}
				if(k <= -1) {
					top = 0;
				}
				
				flg_first = 0;
				for(k = i + 1; k < h; k++) {
					for(l = left; l <= right; l++) {
						if( (str[k][l] == '#') || (masu[k][l] >= 1) ) {
							under = k - 1;
							flg_first = 1;
							break;
						}
					}
					if(flg_first == 1) {
						break;
					}
				}
				if(k >= h) {
					under = h - 1;
				}
				//printf("%ld %ld %ld %ld\n", top, under, left, right);
				for(k = top; k <= under; k++) {
					for(l = left; l <= right; l++) {
						masu[k][l] = count;
					}
				}
				count++;
				//j = right;
			}
		}
	}
	
	for(i = 0; i < h; i++) {
		for(j = 0; j < w; j++) {
			printf("%ld ", masu[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	if(k==22)cout<<"Christmas Eve Eve Eve\n";
	else if(k==23)cout<<"Christmas Eve Eve\n";
	else if(k==24)cout<<"Christmas Eve\n";
	else cout<<"Christmas\n";
	return 0;
}

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

int Y, X;
int a[80][80];
int b[80][80];
#define M 80*80*80
bitset<M*2+1> bs[80][80] = {};

int delta(int y, int x){
    return abs(a[y][x]-b[y][x]);
}

int main(void){
    cin >> Y >> X;
    rep(y,Y)rep(x,X) cin >> a[y][x];
    rep(y,Y)rep(x,X) cin >> b[y][x];
    bs[0][0][M-delta(0,0)] = true;
    bs[0][0][M+delta(0,0)] = true;
    rep(y,Y)rep(x,X){
        if (y+1 < Y) {
            int d = delta(y+1,x);
            bs[y+1][x] |= (bs[y][x] << d) | (bs[y][x] >> d);
        }
        if (x+1 < X) {
            int d = delta(y,x+1);
            bs[y][x+1] |= (bs[y][x] << d) | (bs[y][x] >> d);
        }
    }
    rep(i,M+1){
        if (bs[Y-1][X-1][M-i] || bs[Y-1][X-1][M+i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 800768
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,q; cin>>n>>q;
    vector<vector<int>> g(n);
    vector<ll> ans(n);
    rep(i,n-1) {
        int a,b; cin>>a>>b;
        --a,--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    while (q--) {
        ll p,x; cin>>p>>x;
        --p;
        ans[p] += x;
    }

    vector<bool> v(n);

    auto dfs = [&] (auto &&f, int x, ll y) -> void {
        if (v[x]) return;
        v[x] = true;
        ans[x] += y;
        for (auto &&e: g[x]) {
            f(f,e,ans[x]);
        }
        return;
    };

    dfs(dfs,0,0);

    print(ans);
    return 0;
}

Measured memory_bytes: 20480
#include<bits/stdc++.h>
using namespace std;
const int N=505;

int n,m;char s[N];
char a[N][N],b[N][N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i+=2)
		for(int j=1;j<=m;j++)
			a[i][j]='#',b[i][j]='.';
	for(int i=2;i<=n;i+=2)
		for(int j=1;j<=m;j++)
			a[i][j]='.',b[i][j]='#';
	
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
		if(s[j]=='#') a[i][j]=b[i][j]='#';
	}
	for(int i=1;i<=n;i++)
	a[i][1]=b[i][m]='#',a[i][m]=b[i][1]='.';
	
	for(int i=1;i<=n;i++,printf("\n")) 
		for(int j=1;j<=m;j++) printf("%c",a[i][j]);
	printf("\n");
	for(int i=1;i<=n;i++,printf("\n"))
		for(int j=1;j<=m;j++) printf("%c",b[i][j]);
	return 0; 
	
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

void solve()	{
	int a,b,c;
	cin >> a >> b >> c;
	int cnt[8];
	memset(cnt,0,sizeof(cnt));
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	if(cnt[5]==2 && cnt[7]==1)	cout << "YES\n";
	else cout << "NO\n";
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
	int N;
  cin >>N;
  vec A(N);
  for(int i=0;i<N;i++) cin >> A[i];
 int ans =0;
  bool f  = true;
  while(f){
   for(int i=0;i<N;i++){
    if(A[i]%2==1){
     f=false;
      break;
    }
     else {
      A[i] /= 2; 
     }
   }
    ans++;
  }
  cout << ans-1 <<endl;
}
  


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

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

using namespace std;

typedef long long ll;
ll N;

int main(){
  cin >> N;
  ll sum = 0;
  map<ll,bool> used;
  REP(i,1,N+1) {
    ll v = (ll)i;
    sum += v;
    used[v] = true;
    if( sum == N ) {
      break;
    } else if( sum > N ) {
      ll diff = sum - N;
      used[diff] = false;
      break;
    }
  }
  for(map<ll,bool>::iterator it = used.begin();it!=used.end();++it) {
    if( it->second ) {
      cout << it->first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N;
	string S;
	cin >> N >> S;
	for(auto s:S){
		cout << char('A'+(s-'A'+N)%('Z'-'A'+1));
	}
	cout << endl;

	return 0;
}



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

using namespace std;

int main()
{
  int N; cin >> N;
  double x, sum = 0;
  string u;
  for (int i = 0; i < N; ++i) {
    cin >> x >> u;

    sum += (u == "JPY" ? x : x * 380000);
  }

  cout << sum;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
maze = [list(input()) for _ in range(H)]
dist = [[-1 for _ in range(W)] for _ in range(H)]

if maze[0][0] == '#':
    dist[0][0] = 1
else:
    dist[0][0] = 0

for w in range(1, W):
    if maze[0][w-1] == '.' and maze[0][w] == '#':
        dist[0][w] = dist[0][w-1] + 1
    else:
        dist[0][w] = dist[0][w-1]

for h in range(1, H):
    if maze[h-1][0] == '.' and maze[h][0] == '#':
        dist[h][0] = dist[h-1][0] + 1
    else:
        dist[h][0] = dist[h-1][0]

for h in range(1, H):
    for w in range(1, W):
        if maze[h][w-1] == '.' and maze[h][w] == '#':
            dw = dist[h][w-1] + 1
        else:
            dw = dist[h][w-1]
        if maze[h-1][w] == '.' and maze[h][w] == '#':
            dh = dist[h-1][w] + 1
        else:
            dh = dist[h-1][w]
        dist[h][w] = min(dw, dh)

print(dist[-1][-1])

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;

void print()
{
  std::cout << std::endl;
}

template<class T>
void print(T param)
{
  std::cout << param << std::endl;
  return;
}

template<class T, class... S>
void print(T param1, S... param2)
{
  std::cout << param1 << " "; print(std::forward<S>(param2)...);
}

int main()
{
  ll N;
  std::cin >> N;
  std::vector< std::pair<std::string, ll> > vp(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vp[i].first >> vp[i].second;
  }
  std::string X;
  std::cin >> X;

  bool is_on = false;
  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    if (is_on) {
      ans += vp[i].second;
    }

    if (X == vp[i].first) {
      is_on = true;
    }
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main{
    public static void main(String[] args){
   
    Scanner sc = new Scanner(System.in);
    int a,b ;
    
    while (true) {
        String str = sc.next();
        if (str.equals("-")) {
      break; 
        }
        int i = 0;
        b = sc.nextInt();
        while(i!=b){
        String str1,str2;
        a = sc.nextInt();
        int ln =str.length();
        str1 = str.substring(0,a);
        str2 = str.substring(a,ln);
        str = "";
        str = str2 + str1;
        i++;
        }
        System.out.println(str);
    }

    }
}


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

void dump(vector<int> d)
{
    rep(i, d.size())
    {
        printf("%d ", d[i]);
    }
    cout << endl;
}

const int INF = 1001001001;

int main()
{
    int M1, M2, D1, D2;

    cin >> M1 >> D1 >> M2 >> D2;

    if (M1 != M2 and D2 == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;


fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let (a, b, c) = input_tuple();
    if b / a >= c {
        println!("{}", c);
    } else {
        println!("{}", b / a);
    }
}


Measured memory_bytes: 4352
require 'numo/narray'
include Numo

h, w, k = gets.split.map(&:to_i)
rows = Array.new(h){gets.chomp.bytes}
cnt = 0
[0, 1].repeated_permutation(h).each do |x|
  m = Int32[*rows.dup]
  x.each_with_index do |y, i|
    m[i, true] = '.'.ord if y == 1
  end
  [0, 1].repeated_permutation(w) do |u|
    mc = Marshal.load(Marshal.dump(m))
    u.each_with_index do |v, l|
      mc[true, l] = '.'.ord if v == 1
    end
    cnt += 1 if mc.to_a.flatten.count('#'.ord) == k
  end
end
puts cnt

Measured memory_bytes: 16284
n,y = map(int,input().split())

import sys

for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k)
            sys.exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int a[10000];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>a[i],n-=a[i];
	if(n>=0)cout<<n<<'\n';
	else cout<<-1<<'\n';
}

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

typedef pair<int, int> P;

int A[2][101];
int main(void) {
    int N;
    cin >> N;
    REP(i, N) cin >> A[0][i];
    REP(i, N) cin >> A[1][i];
    FOR(i, 1, N) A[0][i] += A[0][i-1];
    FOR(i, 1, N) A[1][i] += A[1][i-1];
    int ans = 0;
    REP(i, N) {
        int t = 0;
        if(i>0) t = A[1][i-1];
        ans = max(ans, A[0][i]+A[1][N-1]-t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        xs: [i32; n],
    }
    let ys = {
        let mut ys = xs.clone();
        ys.sort();
        ys
    };
    for x in xs {
        if x < ys[n/2] { println!("{}", ys[n/2]); }
        else { println!("{}", ys[(n-2)/2]); }
    }
}


Measured memory_bytes: 5944
n,m=map(int,input().split())
a_list=map(int,input().split())
mod_count={0:1}
mod_sum = 0
for a in a_list:
    mod_sum = (mod_sum + a) % m
    mod_count[mod_sum] = mod_count.get(mod_sum,0) + 1
    
ans = 0
for i in mod_count.values():
    ans += i*(i-1)//2
    
print(ans)

Measured memory_bytes: 16100
#include <stdio.h>
int main(void){
    int a,b,tot=0,sum=0,cnt=0;
    double ave;
    
    while(scanf("%d,%d",&a,&b)!=EOF){
        cnt++;
        sum+=b;
        tot+=a*b;
    }
    //ave=(double)sum/cnt+0.5;
    ave=floor((double)sum/cnt+0.5);
    
    printf("%d\n%.0f\n",tot,ave);
    return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Node {
    int id;
    int score;
    unordered_set<int> nexts;
    unordered_set<int> nnexts;
};

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

    vector<int> c(N);

    vector<Node> nodes(N);

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        nodes[a].nexts.insert(b);
        nodes[b].nexts.insert(a);
        nodes[a].nnexts.insert(b);
        nodes[b].nnexts.insert(a);
    }

    inputVector(c, N);
    sort(all(c));

    queue<int> leafQ;
    rep(i, N) {
        if (nodes[i].nexts.size() == 1) {
            leafQ.push(i);
        }
    }

    int idx = 0;
    while (!leafQ.empty()) {
        int leaf = leafQ.front(); leafQ.pop();
        nodes[leaf].score = c[idx];

        for (int next : nodes[leaf].nexts) {
            nodes[next].nexts.erase(leaf);
            if (nodes[next].nexts.size() == 1) leafQ.push(next);
        }

        idx++;
    }

    int score = 0;
    rep(i, N) {
        for (int next : nodes[i].nnexts) {
            score += min(nodes[i].score, nodes[next].score);
        }
    }
    score /= 2;

    cout << score << endl;
    rep(i, N) cout << nodes[i].score << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		string s;
		cin >> s;
		int c = 0;
		rep(i,0,sz(s)) if(s[i]=='B') c ++ ;
		if(c!=sz(s) and c!=0) cout<<"Yes";
		else cout<<"No";
	}
}

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

int main(){
    int A,B,count=0;
    cin>>A>>B;
    vector<int>vec1(B-A+1);
    vector<int>vec2(5);
    for(int i=0;i<B-A+1;i++){
        vec1[i]=A+i;
        int sum=0;
        for(int j=0;j<5;j++){
            vec2[j]=vec1[i]%10;
            vec1[i]/=10;
            int C=pow(10,j);
            sum+=vec2[j]*10000/C;
        }
        if(sum==A+i){count++;}
    }
    cout<<count<<endl;
}

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

using namespace std;
string s;
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif */
    cin >> s;
    int k = 1; bool ok = 0;
    for(int i = 0; i < s.size() - 1; ++i)
        if(i < s.size() - 3 && s[i] == s[i + 1])k+=2, i+=2;
        else if(i == (s.size() - 3) && s[i] == s[i + 1])k++, i++;
        else if(s[i] != s[i + 1])++k;
    cout << k;
    return 0;
}


Measured memory_bytes: 640
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = [int(i) for i in SS()]
    N = len(S)

    ans0 = 0
    ans1 = 0
    for i in range(N):
        ans0 += abs(S[i] - i % 2)
        ans1 += abs(S[i] - (1 - i % 2))

    print(min(ans0, ans1))

if __name__ == '__main__':
    resolve()


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


 const int MAX = 1001;
const int MOD = 1000000007;


stack<int> s;
priority_queue<pair<int,int>> d;
signed main(){
    int  r,c,n;
    cin>>r>>c>>n;
    int x1,y1,x2,y2;
    
    for(int i=1;i<=n;i++){
        cin>>x1>>y1>>x2>>y2;
        if((x1%r==0 || y1%c==0)&&(x2%r==0 || y2%c==0)){
            if((x1==0&&y1!=0)||y1==c)d.push(make_pair(2*r+2*c -x1-y1,i));
            else d.push(make_pair(x1+y1,i));
            if((x2==0&&y2!=0)||y2==c)d.push(make_pair(2*r+2*c -x2-y2,i));
            else d.push(make_pair(x2+y2,i));
        }
    }
    
    while(!d.empty()){
      
        if(s.empty()||s.top()!=d.top().second)s.push(d.top().second);
        else s.pop();
        d.pop();
    }
    if(s.empty())cout<<"YES";
    else cout<<"NO";

    

   return 0;
}

Measured memory_bytes: 2420
n = int(input())
A = sorted(map(int,input().split()))

if n % 2 == 1:
    ex = [0]
    
    for i in range(n//2):
        a = 2 * (i+1)
        ex += [a,a]
        
else:
    ex = []
    a = 1
    
    for i in range(n//2):
        ex += [a,a]
        a += 2
        
ans = 0

if A == ex:
    ans = 2 ** (n//2) % (10**9 + 7)
    
print(ans)

Measured memory_bytes: 20468
#include<stdio.h>
int main(){
    int H, W;    /* 幅、高さの格納用変数*/
    int i, j;       /* カウンタ用変数*/
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){
            break;
        }
        for(i = 1;i <= H;i++){
            printf("#");
            for(j = 1;j <= W - 2;j++){
                if(i == 1 || i == H){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("#\n");
        }
        printf("\n");
    }
    return 0;
}


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

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

  int sum = 0;
  int memoN = N;

  while (N > 0) {
    sum += N % 10;
    N /= 10;
  }
  
  if (memoN % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

set<int> s;
int bias;
int n, k;

void Ins(int x){
    s.insert(x-bias);
}

bool Exist(int x){
    return s.find(x-bias) != s.end();
}

void Tog(int x){
    x-=bias;
    if(s.find(x) != s.end()) s.erase(x);
    else s.insert(x);
}

char buf[200010];
void in(){
    scanf("%d%d",&n,&k);
    scanf("%s", buf+1);
    buf[0] = 'A';
    for(int i=1; i<=n; ++i){
        if(buf[i-1] != buf[i]){
            Ins(i);
        }
    }
}

int main()
{
	in();
	for(;k--;){
        if(n%2 == 0){
            if(int(s.size()) == n) break;
        } else if(n%2 == 1){
            if(int(s.size()) == n-1 && (!Exist(1) || !Exist(2))){
                if(k%2 == 0){
                    Tog(1); Tog(2); break;
                }
            }
        }
        if(Exist(1)){
            --bias;
            if(Exist(0)) s.erase(-bias);
            if(s.size()&1) Tog(n);
        } else {
            Ins(1); Tog(2);
        }
    }
	for(int i=1; i<=n; ++i){
        if(Exist(i))  buf[i]=131-buf[i-1];
        else buf[i]=buf[i-1];
	}
	puts(buf+1);
    return 0;
}


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


int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int max_x;
    cin >> max_x;
    rep(i, N - 1){
        int x;
        cin >> x;
        max_x = max(max_x, x);
    }
    int min_y;
    cin >> min_y;
    rep(i, N - 1){
        int y;
        cin >> y;
        min_y = min(min_y, y);
    }
    for (int i = X + 1; i <= Y; i++){
        if (max_x < i && i <= min_y){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int q; cin >> q;
  vector<bool> is_prime(100005, true);
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i < 100005; ++i) {
    if(is_prime[i]) {
      for(int j = 2; i*j < 100005; ++j) is_prime[i*j] = false;
    }
  }

  vector<int> num(100005, 0);

  for(int i = 1; i < 100005; i+=2) {
    if(is_prime[i] && is_prime[(i+1)/2]) num[i] = 1;
  }

  rep(i, 100004) num[i+1] += num[i];
  vector<int> ans;
  rep(i, q) {
    int l, r; cin >> l >> r;
    ans.push_back(num[r] - num[l-1]);
  }
  for(auto x : ans) cout << x << endl;
}

Measured memory_bytes: 1532
#include <iostream>
using namespace std;
 
string s;
long long ans = 0, cnt = 0;
int main()
{
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++)
    {
        if (s[i] == 'A')
            cnt++;
        else if (s[i] == 'B' && s[i+1] == 'C')
        ans += cnt;
        else if ((s[i] == 'B' && s[i+1] != 'C') || (s[i] == 'C' && s[i-1] != 'B'))
            cnt = 0;
    }
    cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    #define REP(x,y,z) for(int x=y;x<=z;x++)
    #define MSET(x,y) memset(x,y,sizeof(x))
    #define M 35
    using namespace std;
    int n,m;
    vector<int> suko[M];
    int main()
    {
        while (~scanf("%d %d", &n, &m)) {
            REP(i,0,n) suko[i].clear();
            REP(i,1,n) {
                int x,y;
                scanf("%d",&x);
                REP(j,1,x) {
                    scanf("%d", &y);
                    suko[i].push_back(y);
                }
            }
     
            auto check = [&](int x) {
                REP(i,1,n) {
                    auto it = find(suko[i].begin(), suko[i].end(), x);
                    if (it == suko[i].end()) return false;
                }
                return true;
            };
            int ans = 0;
            REP(i,1,m) if (check(i)) ans++;
            printf("%d\n", ans);
        }
        return 0;
    }

Measured memory_bytes: 256
letter = ["a","b","c","d","e","f","g","h","i","j","k","l","m"]


class let():
    def __init__(self, a, b):
        self.s = a
        self.n = b

def add(s_list):
    ans = []
    for s in s_list:
        for i in range(s.n):
            ans.append(let(s.s + letter[i], s.n))
        ans.append(let(s.s + letter[s.n], s.n+1))
    
    return ans




N = int(input())


a_list = [let("a", 1)]

for i in range(N-1):
    a_list = add(a_list)

for i in a_list:
    print(i.s)

Measured memory_bytes: 35444