akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = list(map(int,input().split()))

if(N%2 == 0):
  N = int(N/2)
else:
  N = int(N/2)+1
count = 0
for i in range(1,N+1):
  if(a[(2*i-1)-1]%2 == 1):
    count += 1
print(count)

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

int main(){
    long int N,M;
    cin >> N >> M;

    vector<long int> H(N);
    rep(i,N) {
        cin >> H.at(i);
    }
    
    vector<long int> G(N,2);

    rep(i,M) {
        long int tA = 0;
        long int tB = 0;
        cin >> tA >> tB;
        tA -= 1;
        tB -= 1;

        
        if(H.at(tA)>H.at(tB)) {
            if(G.at(tA)!=0){
                G.at(tA) = 1;
            }

            G.at(tB) = 0;
        }

        if(H.at(tB)>H.at(tA)) {
            if(G.at(tB)!=0){
                G.at(tB) = 1;
            }

            G.at(tA) = 0;
        }

        if(H.at(tA)==H.at(tB)) {
            G.at(tA) = 0;
            G.at(tB) = 0;
        }

    }

    long int sum = 0;

    rep(i,N) {
        if(G.at(i)==1 || G.at(i)==2){
            sum += 1;
        }
    }

    cout << sum << endl;



}

Measured memory_bytes: 4820
#include <iostream>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

constexpr auto NMAX = (int)2e5 + 20;
constexpr auto INF = 2000000000;
using namespace std;

typedef unsigned long long ull;

int r;
double const pi = 3.14159;

int main()
{
	cin >> r;
	cout << 2 * pi * r << '\n';
	return 0;
}

Measured memory_bytes: 3788
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
const int N=1e3+10;
int n,maxx=32;
ll pw[35]={1},d[35],x[N],y[N];
inline ll read(){
	char ch=getchar(); ll x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline ll abss(ll a){return a>0 ? a : -a;}
int main()
{
//	freopen("Robot Arms.in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)
	{
		x[i]=read(); y[i]=read();
		if((abss(x[i]+y[i])%2)!=(abss(x[1]+y[1])%2))
		{
			printf("-1\n");
			return 0;
		}
	}
	for(int i=1;i<=maxx;i++) pw[i]=pw[i-1]*2;
	for(int i=1;i<=maxx;i++)
	{
		d[i]=pw[maxx-i+1];
	}
	d[++maxx]=1;
	if((abss(x[1]+y[1]))%2==0)
	{
		d[++maxx]=1;
	}
	printf("%d\n",maxx);
	for(int i=1;i<=maxx;i++) printf("%lld ",d[i]); printf("\n");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=maxx;j++)
		{
			if(abss(x[i])>abss(y[i]))
			{
				if(x[i]>=0)
				{
					printf("R"), x[i]-=d[j];
				}
				else printf("L"), x[i]+=d[j];
			}
			else
			{
				if(y[i]>=0)
				{
					printf("U"), y[i]-=d[j];
				}
				else printf("D"), y[i]+=d[j];
			}
		}
		printf("\n");
	}
//	for(int i=1;i<=n;i++) printf("%lld %lld\n",x[i],y[i]);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	sort(all(a)); sort(all(b));
	if (n % 2 == 0) cout << b[n / 2 - 1] + b[n / 2] - a[n / 2 - 1] - a[n / 2] + 1 << '\n';
	else cout << b[n / 2] - a[n / 2] + 1 << '\n';
}

Measured memory_bytes: 6368
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 55;
const double g = 9.8;   //重力加速度
const double EPS = 1e-10;
int N;
double V, X, Y;
double L[maxn], B[maxn], R[maxn], T[maxn];

//&#35745;算以vy的速度&#31446;直向上射出t秒后的位置
double calc(double vy, double t)
{
    return vy * t - g * t * t / 2;
}

//a相&#23545;lb和ub的位置
int cmp(double lb, double ub, double a)
{
    return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}

//判断当射出路径&#32463;&#36807;点(qx, qy)&#26102;，卵是否能&#20987;中猪
bool check(double qx, double qy)
{
    //&#35774;初速度在x方向和y方向的分量分&#21035;&#20026;vx和vy，&#35774;通&#36807;(qx, qy)的&#26102;&#38388;&#20026;t
    //&#35774;解&#32852;立方程式vx^2 + vy ^2 = V^2, vx * t = 1x, vy * t - 1/2 g t^2 = qy
    double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if (D < 0 && D > -EPS)
        D = 0;
    if (D < 0)
        return false;
    for (int d = -1; d <= 1; d += 2){       //&#39564;&#35777;&#32852;立方程式上的&#20004;个解的循&#29615;
        double t2 = (-b + d * sqrt(D)) / (2 * a);
        if (t2 <= 0)
            continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g * t * t / 2) / t;

        //判断是否通&#36807;猪的正上方
        double yt = calc(vy, X / vx);
        if (yt < Y - EPS)
            continue;

        bool ok = true;
        for (int i = 0; i < N; i++){
            if (L[i] >= X)
                continue;
            //判断在猪正上方的&#40479;和猪之&#38388;是否有障碍物
            if (R[i] == X && Y <= T[i] && B[i] <= yt)
                ok = false;
            //判断在&#39134;到猪的正上方之前是否会撞到障碍物
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));   //左&#20391;的相&#23545;位置
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));   //右&#20391;的相&#23545;位置
            int xH = cmp(L[i], R[i], vx * (vy / g));      //最高点的相&#23545;位置
            int yH = cmp(B[i], T[i], calc(vy, vy / g));
            if (xH == 0 && yH >= 0 && yL < 0)
                ok = false;
            if (yL * yR <= 0)
                ok = false;
        }
        if (ok)
            return true;
    }
    return false;
}

void solve()
{
    //截掉猪以右的障碍物
    for (int i = 0; i < N; i++){
        R[i] = min(R[i], X);
    }
    bool ok = check(X, Y);      //直接撞上猪的情况
    for (int i = 0; i < N; i++){
        ok |= check(L[i], T[i]);     //&#32463;&#36807;左上角的情况
        ok |= check(R[i], T[i]);     //&#32463;&#36807;右上角的情况
    }
    puts(ok ? "Yes" : "No");
}

int main()
{
    while (scanf("%d%lf%lf%lf", &N, &V, &X, &Y) != EOF){
        for (int i = 0; i < N; i++){
            scanf("%lf%lf%lf%lf", &L[i], &B[i], &R[i], &T[i]);
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 1044
def Quadrillion():

    Num = int(input())

    moji = num2alpha(Num)

    print(moji)

def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)

if __name__ == '__main__':
    Quadrillion()

Measured memory_bytes: 9120
n = int(input())
dd = {}
for i in range(n):
	s = input()
	if s in dd.keys():
		dd[s] += 1
	else:
		dd[s] = 1
ma = max(dd.values())
lst = []
for k, v in dd.items():
	if v == ma:
		lst.append(k)
for l in sorted(lst):
	print(l)

Measured memory_bytes: 35740
#include <iostream>
#include <set>

using namespace std;

int main() {
  int n, in;
  set<int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> in;
    set<int>::iterator result = a.find(in);
    if (result == a.end()) a.insert(in);
    else a.erase(in);
  }
  cout << a.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')cout << "vowel" << endl;
  else cout <<"consonant" << endl;
  return 0;
}


Measured memory_bytes: 3620
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
K,N = inputlist()
A = inputlist()
lia = [0]*N
for i in range(1,N):
    k = A[i] - A[i-1]
    lia[i] = k
lia[0] = (K+A[0]-A[-1])
lia.sort()
ans = 0
for i in range(N-1):
    ans += lia[i]
print(ans)

Measured memory_bytes: 26444
from collections import deque

S = input()
Q = int(input())
Queries = [input().split() for i in range(Q)]
dq = deque(S)

f = 0

for a in Queries:
    if a[0] == '1':
        f ^= 1
    else:
        if f == (int(a[1])-1):
            dq.appendleft(a[2])
        else:
            dq.append(a[2])

if f:
    dq.reverse()

print(''.join(dq))


Measured memory_bytes: 119556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    ll n;
    cin>>n;
    ll a[n],i,j,k,ans=0;
    scan(a,n);

    ll x,y,z;
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        for(k=j+1;k<n;k++){
             x=max(a[i],max(a[j],a[k]));
             y=min(a[i],min(a[j],a[k]));
             z=a[i]+a[j]+a[k]-x-y;
             if(z+y>x && x!=y && y!=z && x!=z) {ans++;
              //cout<<i<<" "<<j<<" "<<k<<endl;
            }
        }
      }
    }

      cout<<ans;

 

      
return 0;    
 }  

Measured memory_bytes: 3636
#include<stdio.h>
#define MAX_NUMBER_OF_NODE 250

/*struct Node
{
  int id;
  int index_of_node;
}
*/

//struct Node node[MAX_NUMBER_OF_NODE];
int insert(int);
int main()
{
  int node[MAX_NUMBER_OF_NODE];
  int number_of_node;//it is represented as H in AOJ
  int i,id;

  //for(i = 0 ; i < MAX_NUMBER_OF_NODE ;i++ )node[i].index_of_node = NULL;
   

  scanf("%d",&number_of_node);
  for(i = 1 ; i <= number_of_node ; i++)
    {
      scanf("%d",&id);
      node[i] = id;
    }


  for(i = 1 ; i <= number_of_node ; i++)
    {
      printf("node %d: key = %d, ",i,node[i]);
      if(i != 1)printf("parent key = %d, ",node[i/2]);
      if(number_of_node >= 2*i)printf("left key = %d, ",node[2*i]);
      if(number_of_node >= 2*i+1)printf("right key = %d, ",node[2*i+1]);
      printf("\n");
    }
}

/*
void insert(int id);
{



}
*/



Measured memory_bytes: 2044
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();

    if (K % 2 == 0) {
      System.out.println((K / 2) * (K / 2));
    } else {
      System.out.println((K / 2) * (K / 2 + 1));
    }

  }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    vector<int> a(n+1);
    map<ll, int> freq;
    rep(i, n)  cin >> a[i+1];

    for(int i = 1; i <= n; ++i) {
        ll tmp = i - a[i];
        if(tmp > 0) {
            freq[tmp]++;
        }
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        ll tmp = i + a[i];
        if(tmp < n) {
            ans += freq[tmp];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 14880
#include <bits/stdc++.h>
#define fo(i, a, b) for (ll i = a; i < ll(b); i++)
#define fr(i, a, b) for (ll i = b - 1; i >= ll(a); i--)
#define al(x) begin(x), end(x)
#define ral(x) rbegin(x), rend(x)
#define I(x) ll x; cin >> x;
#define this (*this)
#define ar array
#define vc vector
#define pb push_back
#define rs resize
#define is insert
#define vl vc<ll>
#define popcnt __builtin_popcountll
#define sp <<" "<<
using namespace std;
using namespace std::placeholders;
using ll = long long;
using ld = long double;
using pa = array<ll, 2>;
using ve = ar<ll,3000>;
using mt = ar<ve,3000>;
using pr = pair<ll, ll>;
using bt = bitset<64>;
#ifdef DEBUG
#include "../debug.h"
#else
#define dbg(x)
#define cerr if(false) cerr
#endif
const ll M = 998244353, inf = 1e18;
istream& operator>>(auto& is, auto &v) {
  for (auto &x : v) {
    cin >> x;
  }
}
int main() {
	ios::sync_with_stdio(false);
	cin.exceptions(ios::badbit | ios::failbit);
	I(h);I(w);
	vc<vc<char>> a(h, vc<char>(w));
	vc<vl> d(h, vl(w, inf));
	deque<pr> q;
	fo(i,0,h){
		fo(j,0,w){
			cin>>a[i][j];
			if(a[i][j]=='#'){q.pb({i,j});d[i][j] = 0;}
		}
	}
	ll ans = 0;
	for(;q.size(); q.pop_front()){
		auto p = q.front();
		ll i = p.first, j = p.second;
		#define ad(x,y) if(0<=x && x<h && 0<=y && y<w && d[x][y]==inf){d[x][y] = d[i][j]+1; ans = max(ans, d[x][y]); q.pb({x,y});}
		ad(i-1, j);
		ad(i+1,j);
		ad(i, j-1);
		ad(i,j+1);
	}
	cout<<ans<<endl;
}

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

int main(){
	int n; cin>>n;
	n*=2;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	sort(rall(v));
	int cnt=0;
	for(int i=0; i<n; i+=2){
		cnt+=v[i+1];
	}
	cout<<cnt<<endl;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	
	sort(l.begin(), l.end());
	
	ll ans = 0;
	for(int i = 0; i < n - 2; i++){
		for(int j = i + 1; j < n - 1; j++){
			for(int k = j + 1; k < n; k++){
				if(l[i] + l[j] > l[k]) ans++;
				else break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Coloring Colorfully
	var S string
	fmt.Scanf("%s", &S)

	var A string
	for i := 0; i < len(S); i++ {
		if i%2 == 0 {
			A += string('0')
		} else {
			A += string('1')
		}
	}

	var countA, countB int
	for i := 0; i < len(S); i++ {
		if A[i] != S[i] {
			countB++
		} else {
			countA++
		}
	}

	fmt.Println(math.Min(float64(countA), float64(countB)))
}


Measured memory_bytes: 8008
#include <iostream>
#include <thread>
#include <chrono>
#include <random>
#include <fstream>
#include <time.h>


int main()
{
    int n;
    std::cin >> n;

    if(n%2==0){
        std::cout << n << std::endl;
    }
    else{
        std::cout << n*2 << std::endl;
    }

    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;

    map<char, i64> cnt;
    for (auto& e : s) cnt[e]++;

    if (((cnt['N'] == 0) ^ (cnt['S'] == 0)) || ((cnt['W'] == 0) ^ (cnt['E'] == 0))) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

vector<vector<ll>> b(210000,vector<ll>(2,0));

bool isOK(ll index, ll key){ 
    if (b.at(index).at(0) > key) return true; 
    else return false;
}

ll binse(ll key, ll sizem){ //sizem番目まで二分探索
	ll left = -1;
	ll right = sizem;
	while (right-left>1){
		ll mid = left+(right-left)/2;
		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	ll n, d, a, x, h; cin >> n >> d >> a;
	REP(i,n){
		cin >> x >> h;
		b[i][0] = x;
		b[i][1] = (h+a-1)/a;
	}
	sort(b.begin(), b.begin()+n);
	vector<ll> cnter(n+1,0);
	ll ans = b[0][1];
	cnter[0] = b[0][1];
	cnter[binse(b[0][0]+2*d,n)] -= b[0][1];
	FOR(i,1,n-1){
		cnter[i] += cnter[i-1];
		ll ky = b[i][0]+2*d;
		ll diff = b[i][1]-cnter[i];
		if (diff>0){
			ans += diff;
			cnter[i] += diff;
			cnter[binse(ky,n)] -= diff;
		}
		//cout << i << " " << diff << " " << cnter[i] << " " << binse(ky,n) << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 200500;
long long a[maxn];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; ++i)
        cin >> a[i];
    
    for(int i = 1 ; i < n ; ++i)
        a[i] += a[i - 1];
    
    long long best = 1e18;
    for(int i = 0 ; i < n - 1 ; ++i)
        best = min(best, abs(2LL * a[i] - a[n - 1]));
    cout << best << '\n';
    return 0;
}


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

#define N_MAX 2000000
#define V_MAX 10000

void countingSort(short A[], short B[], long n) {
    long C[V_MAX + 1];
    for (long i = 0; i < V_MAX + 1; i++) {
        C[i]  = 0;
    }
    
    for (long i = 0; i < n; i++) {
        C[A[i]]++;
    }
    
    for (long i = 1; i < V_MAX + 1; i++) {
        C[i] += C[i - 1];
    }
    
    for (long i = n - 1; i >= 0; i--) {
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }
}

int main() {
    long n;
    cin >> n;
    short A[N_MAX];
    for (long i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    short B[N_MAX];
    countingSort(A, B, n);
    
    for (long i = 0; i < n; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << B[i];
        if (i == n - 1) {
            cout << endl;
        }
    }
}


Measured memory_bytes: 10900
// -*- coding:utf-8-unix -*-

use proconio::input;

// based on the pdf explanation

fn main() {
    input! {
        n: usize,
        a_vec: [usize; n],
    }

    let a1 = a_vec[0];
    let a2 = a_vec[1];
    let mut x = 0;
    for i in 2..n {
        x ^= a_vec[i];
    }
    let x = x;
    let s = a1 + a2;

    if s < x || (s - x) % 2 != 0 {
        println!("-1");
        return;
    }
    let d = (s - x) / 2;
    if d & x != 0 {
        println!("-1");
        return;
    }

    if d > a1 {
        println!("-1");
        return;
    }

    let mut y = 0;
    let mut bit = 2usize.pow(40);
    while bit != 0 {
        if bit & x == 0 {
            bit /= 2;
            continue;
        }
        if d ^ y ^ bit <= a1 {
            y ^= bit;
        }
        bit /= 2;
    }

    if d ^ y == 0 {
        println!("-1");
        return;
    }

    println!("{}", a1 - (d ^ y));
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int m_sum = 0;
  rep(i,N) {
    cin >> m.at(i);
    m_sum += m.at(i);
  }
  int plus = 0;
  if ( X > m_sum ) {
    sort(m.begin(), m.end());
    int rest = (X - m_sum) % m.at(0);
    plus = (X - m_sum - rest)/m.at(0);
  }
  int answer = N + plus;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    VL x(5);
    cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4];
    int index = -1;
    LL min_1x = 11;
    REP(i,5){
        if(x[i] % 10 == 0)continue;
        if(x[i] % 10 < min_1x){
            min_1x = x[i] % 10;
            index = i;
        }
    }
    LL ans = 0;
    REP(i,5)if(i != index){
        if(x[i] % 10 == 0){
            ans += x[i];
        }
        else{
            ans += x[i] - (x[i] % 10) + 10;
        }
    }
    if(index != -1)ans += x[index];

    PUTS(ans);
}

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

int main()
{
    int n;
    scanf("%d", &n);
    long long *a = new long long[n];
    for (int i = 0; i < n; i++)
        scanf("%lld", a + i);
    
    std::sort(a, a + n);
    int edge[2]{-1, -1};
    for (int i = n - 1; i > 0; i--)
    {
        if (a[i] != a[i - 1]) continue;
        if (edge[0] == -1)
        {
            edge[0] = i;
            i--;
        }
        else
        {
            edge[1] = i;
            break;
        }
    }
    if (edge[1] == -1) printf("0\n");
    else printf("%lld\n", a[edge[0]] * a[edge[1]]);

    delete[] a;
    return 0;
}

Measured memory_bytes: 1024
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X-(a+b)
            if c > b and c <= N:
                ans += 1
    print(ans)


Measured memory_bytes: 5592
import java.util.Scanner;

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        if(A <= C && C <= B){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

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

int main() {
  LL n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  int sum = 0;
  for (int i = 1; i < n; i ++) {
    if (s[i - 1] == 'R' && s[i] == 'L') sum += 2;
  }
  if (s[0] == 'L') sum ++;
  if (s[n - 1] == 'R') sum ++;

  rep(i, k) {
    if (sum > 1) sum -= 2;
    else break;
  }
  if (sum == 0) sum ++;

  cout << n - sum << endl;
}

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

using namespace std;

#define ll long long 
#define Coming ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n";

int main()
{
	int n, last = 0, a, coun = 0;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> a ;
		
		if(a >= last)
		{
			coun++;
			last = a;
		}
	}
	
	cout << coun << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int C = sc.nextInt();
        int[][] D = new int[C][C];
        for(int i = 0; i < C; i++) {
            for(int j = 0; j < C; j++) {
                D[i][j] = sc.nextInt();
            }
        }
        int[][] c = new int[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                c[i][j] = sc.nextInt();
            }
        }

        int[][] c_sum = new int[3][C];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                c_sum[(i + j) % 3][c[i][j] - 1]++;
            }
        }
        int min = 2 << 28;
        for(int c1 = 0; c1 < C; c1++) {
            for(int c2 = 0; c2 < C; c2++) {
                for(int c3 = 0; c3 < C; c3++) {
                    int cou = 0;
                    if(c1 == c2 || c2 == c3 || c1 == c3) continue;
                    for(int i = 0; i < C; i++) {
                        cou += c_sum[0][i] * D[i][c1];
                    }
                    for(int i = 0; i < C; i++) {
                        cou += c_sum[1][i] * D[i][c2];
                    }
                    for(int i = 0; i < C; i++) {
                        cou += c_sum[2][i] * D[i][c3];
                    }
                    min = Math.min(min,cou);
                }
            }
        }

        System.out.println(min);






    }
}

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

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

Measured memory_bytes: 3640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(){
	int x,a,b;
  cin>>x>>a>>b;
  cout<<(x-a)%b<<endl;
	

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define lson rt<<1
#define rson rt<<1|1
#define PII pair<int,int>
#define test freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
const int maxn=1e5+5;
int n;
PII a[maxn],b[maxn];
int fa[maxn];
int main()
{
    //test
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",&a[i].first),a[i].second=i;
    for(int i=1;i<=n;++i) scanf("%d",&b[i].first),b[i].second=i;
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;++i) 
    {
        if(a[i].first>b[i].first) {cout<<"No";return 0;}
        fa[a[i].second]=b[i].second;
    }
    for(int i=1;i<n;++i) if(i!=n&&a[i+1].first<=b[i].first) {cout<<"Yes";return 0;}
    int x=1,ct=0;
    do 
    {
        x=fa[x];
        ++ct;
    }while(x!=1);
    if(ct==n) cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

void solve(){
	int n;
	cin>>n;
  bool flag = false;
	FOR(i, 1, 10){
      FOR(j, 1, 10){
        if(i*j==n) flag = true;
      }
    }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 256
nums = sorted(list(map(int,input().split())))
x = min(nums)
y = nums[1]
z = max(nums)
gap1 = z - y
gap2 = z - x - gap1
answer = 0
if gap2 % 2 == 0:
  answer = gap1 + gap2//2
else:
  answer = gap1 + gap2//2 + 2
print(answer)

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int mx = 0, mn = inf;
	vi x(n);
	rep(i, n) {
		cin >> x[i];
		
		mx = max(mx, x[i]);
		mn = min(mn, x[i]);
	}

	int mid = (mx + mn) / 2;

	cout << max(abs(mx - mid), abs(mn - mid)) << endl;
}


Measured memory_bytes: 3104
n = int(input())
a = input()
b = input()
c = input()


ans = 0
for i in range(n):
    s = set([a[i], b[i], c[i]])
    # print(len(s))
    if len(s) == 1:
        ans+=0
    elif len(s) == 2:
        ans += 1
    elif len(s) == 3:
        ans += 2

print(ans)

Measured memory_bytes: 3064
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

tmp = [0 for i in range(n + 1)]
cnt = 0
res = 1

while cnt < k:
    cnt += 1
    if tmp[res] == 0:
        tmp[res] = cnt
    else:
        cnt += (k - cnt) // (cnt - tmp[res]) * (cnt - tmp[res])
        tmp[res] = cnt
    res = A[res - 1]

print(res)


Measured memory_bytes: 54752
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
int A[110];
int dp[110];

int solve(int j) {
    REP(i, 110) dp[i] = 1LL << 30;
    dp[1] = 0;
    FOR(i, 1, N + 2) {
        FOR(k, 1, j + 1) {
            int nxt = min(N + 2, i + k);
            if (!A[nxt]) dp[nxt] = min(dp[nxt], dp[i] + 1);
        }
    }
    return dp[N + 2];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;
    REP(i, N) cin >> A[i + 2];
    FOR(j, 1, N + 2) {
        if (solve(j) == 1LL << 30) continue;
        cout << j << endl;
        return 0;
    }
}


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

int sum[200005];

signed main(){
    int n,k;
    cin >> n >>k;

    double a[n+1];
    for(int i =1;i<=n;i++){
        cin >> a[i];
        sum[i] = sum[i-1] + a[i];
    }

    int pos;
    double mx = 0;

    for(int i = 1;i+k-1<=n;i++){
        double cur = sum[i+k-1]-sum[i-1];
        if(mx<cur){
            mx  = max(cur,mx);
            pos = i;
        }
    }
    double ans = 0.0;
    for(int i = pos; i<=pos+k-1;i++){
        ans+=(a[i]+1)/2.0;
    }

    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define push_back pb
#define make_pair mp
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 10;
ll n, sum;
char a[N][10];
map<string, int> mp;
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		scanf("%s", a[i]);
		sort(a[i], a[i] + 10);
		mp[a[i]]++;
		sum += mp[a[i]] - 1;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 12160
def calculate(people_num, limit, height_array):
    permission = [height for height in height_array if height >= limit]
    return len(permission)
 
if __name__ == "__main__":
    people_num, limit = map(int, input().split())
    height_array = map(int, input().split())
    result_num = calculate(people_num, limit, height_array)
    print(result_num)

Measured memory_bytes: 11648
#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 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 snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<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 getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
typedef v(string) vs;
#include <atcoder/all>
using namespace atcoder;
const int di[] = {1,0}, dj[] = {0,1}; //v>



int main() {
  int h,w;
  scanf("%d%d",&h,&w);
  vs s(h);
  cin>>s;

  int n = h*w;
  int sv = n, tv = n+1;
  mcf_graph<int,int> g(n+2);
  int pre = 0;
  rep(i,h)rep(j,w) {
    if (s[i][j] == '#') continue;
    int a = i*w+j;
    if (s[i][j] == 'o') g.add_edge(sv,a,1,0), pre += h-i+w-j;
    g.add_edge(a,tv,1,h-i+w-j);
    rep(v,2) {
      int ni = i+di[v], nj = j+dj[v];
      if (ni<0||nj<0||ni>=h||nj>=w) continue;
      if (s[ni][nj] == '#') continue;
      int b = ni*w+nj;
      g.add_edge(a,b,INF,0);
    }
  }

  int ans = pre-g.flow(sv,tv).se;
  cout<<ans<<endl;
  return 0;
}






















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

void solve(){
    int n;
    cin>>n;
    vector<long long>v(n);
    for(int i=0; i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(v[i] == v[j])continue;
            for(int k=j+1;k<n;k++){
                if(v[j] == v[k])continue;                
                if(v[i]+v[j] > v[k]){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    
}

int main() {
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

ll maxm;
ll dp[101][100001];
ll fn(ll c[],ll w[],ll n,ll W)
{
    if(n==0 || W==0)
    {
        return 0;
    }
    if(dp[n][W] != -1)
    {
        return dp[n][W];
    }
    if(w[n-1] <= W)
    {
        return dp[n][W] = max(c[n-1]+fn(c,w,n-1,W-w[n-1]),fn(c,w,n-1,W));
    }
    else
    {
        return dp[n][W] = fn(c,w,n-1,W);
    }
}
int main()
{
    ll i,j,n,k;
    cin>>n>>k;
    ll c[n];
    ll w[n];
    for(i=0; i<=n; i++)
    {
        cin>>w[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    fn(c,w,n,k);
    cout<<dp[n][k]<<"\n";
    return 0;
}

Measured memory_bytes: 82492
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
//const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll MOD = 1000003;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


bool mp[30][30];
void solve(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) return;
    rep(i, 30)rep(j, 30) mp[i][j] = 0;
    rep(i, n){
      int x, y;
      cin >> x >> y;
      mp[x][y] = 1;
    }
    mp[10][10] = 0;
    int m;
    cin >> m;
    int x = 10, y = 10;
    rep(_, m){
      char s;
      int d;
      cin >> s >> d;
      rep(__, d){
        if(s == 'N') y++;
        if(s == 'E') x++;
        if(s == 'S') y--;
        if(s == 'W') x--;
        mp[x][y] = 0;
      }
    }
    bool ok = 1;
    rep(i, 30)rep(j, 30){
      if(mp[i][j]) ok = 0;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}



Measured memory_bytes: 3192
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	int w=0,h=0,x=0,y=0;
	cin>>w>>h>>x>>y;
	printf("%f ",(double)w*h/2);
	if(x*2==w && y*2==h){
		cout<<1;
	}else{
		cout<<0;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
X = []
Y = []
for i in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
Sum = 0.0
for i in range(N):
    for j in range(N-i-1):
        Sum += ((X[i]-X[j+i+1])**2+(Y[i]-Y[j+i+1])**2)**0.5

print(Sum*2/N)

Measured memory_bytes: 3064
#include <stdio.h>
int main() {
	while(1){
		int h,m,i,j;
		scanf("%d %d",&h,&m);
		if(h == 0 && m == 0) break;
		for(i=0;i<h;i++){
			for(j=0;j<m;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2128
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    ll a = 0;
    for (ll e : s)
        a += e - '0';
    cout << (a % 9 ? "No" : "Yes");
}

Measured memory_bytes: 3684
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
     int x, y;
     cin >> x >> y;
     if (x % y  == 0) cout << -1;
     else cout << x ;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


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

char A[10][10];
int book[10],k,r,c,a[20],d[20],e[10];

void putQueen(int x){
  int i,j;
  
  if(e[x]==1)putQueen(x+1);
  
  if(x==8){
    for(i=0;i<8;i++){
      for(j=0;j<8;j++)printf("%c",A[i][j]);
    printf("\n");
    }
    return;
  }

  for(i=0;i<8;i++){
    if(book[i]==0 && a[x+i]==0 && d[x-i+8]==0){
      book[i]=1;
      a[x+i]=1;
      d[x-i+8]=1;
      A[x][i]='Q';
      putQueen(x+1);
      book[i]=0;
      a[x+i]=0;
      d[x-i+8]=0;
      A[x][i]='.';
    }
  }  
}

int main(){
  int i;
  
  scanf("%d",&k);
  for(i=0;i<8;i++){
    for(int j=0;j<8;j++)A[i][j] = '.';
  }
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    A[r][c] = 'Q';
    book[c] = 1;
    a[r+c]=1;
    d[r-c+8]=1;
    e[r]=1;
  }
  putQueen(0);
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
lol i[200100];
lol f(lol x,lol y){
  if(i[x]!=-1) return i[x];
  if(y==0) return 0;
  return i[x]=1+f(x+1,y/2)*2;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>a;
  memset(i,-1,sizeof(i));
  cout <<f(0,a)<<'\n';
  return (0);
}


Measured memory_bytes: 1792
#include<stdio.h>
#define LINE_MAX 30

int main(){
  int w,n;
  int line[LINE_MAX],ai,bi;
  int i,tmp;

  scanf("%d %d",&w,&n);

  for(i=0;i<w;i++){
    line[i]=i+1;
  }

  for(i=1;i<=n;i++){
    scanf("%d,%d\n",&ai,&bi);
    tmp=line[ai-1];
    line[ai-1]=line[bi-1];
    line[bi-1]=tmp;
  }

  for(i=0;i<w;i++)
    printf("%d\n",line[i]);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 1005;
const int MAXM = 2005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	const int MOD = 1e9 + 7;
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
	inline int Ksm(int x, int y) {
		int ret = 1;
		for (; y; y >>= 1) {
			if (y & 1) ret = Mul(ret, x);
			x = Mul(x, x);
		}
		return ret;
	}
	inline int Inv(int x) {
		return Ksm(x, MOD - 2);
	}
}
using namespace ModCalculator;

int n, m, f[MAXN], ans, inT[MAXM];
int fa[MAXN], dep[MAXN], fe[MAXN], tot;
LL W, X, d[MAXM];

struct Edge {
	int u, v, w;
	bool operator < (const Edge &rhs) const {
		return w < rhs.w;
	}
} e[MAXM];

struct TEdge {
	int v, w, nxt;
} g[MAXN << 1];
int first[MAXN], eCnt;

inline void AddEdge(int u, int v, int w) {
	g[++eCnt].v = v;
	g[eCnt].w = w;
	g[eCnt].nxt = first[u];
	first[u] = eCnt;
}

int getf(int x) {
	return (f[x] == x)? x : f[x] = getf(f[x]);
}

void DFS(int u) {
	for (int i = first[u]; i; i = g[i].nxt) {
		int v = g[i].v;
		if (v == fa[u]) continue;
		fa[v] = u;
		fe[v] = g[i].w;
		dep[v] = dep[u] + 1;
		DFS(v);
	}
}

int GetMax(int u, int v) {
	int ret = 0;
	while (u ^ v) {
		if (dep[u] < dep[v]) swap(u, v);
		ret = max(ret, fe[u]);
		u = fa[u];
	}
	return ret;
}

void init() {
	read(n); read(m); read(X);
	for (int i = 1; i <= m; ++i) {
		read(e[i].u); read(e[i].v); read(e[i].w);
	}
}

void solve() {
	sort(e + 1, e + m + 1);
	for (int i = 1; i <= n; ++i) {
		f[i] = i;
	}
	for (int i = 1; i <= m; ++i) {
		int u = getf(e[i].u), v = getf(e[i].v);
		if (u == v) continue;
		W += e[i].w;
		inT[i] = 1;
		f[u] = v;
		AddEdge(e[i].u, e[i].v, e[i].w);
		AddEdge(e[i].v, e[i].u, e[i].w);
	}
	if (W > X) {
		printf("%d\n", 0);
		return;
	}
	if (W == X) {
		Inc(ans, Mul(Sub(Ksm(2, n - 1), 2), Ksm(2, m - n + 1)));
	}
	DFS(1);
	for (int i = 1; i <= m; ++i) {
		if (inT[i]) continue;
		d[++tot] = e[i].w - GetMax(e[i].u, e[i].v);
	}
	sort(d + 1, d + tot + 1);
	for (int i = 1; i <= tot; ++i) {
		if (W + d[i] == X) {
			Inc(ans, Ksm(2, tot - i + 1));
		}
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();	
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;

  if (a > b) {
    cout << a + a - 1 << endl;
  }
  else if (a < b) {
    cout << b + b - 1 << endl;
  }
  else {
    cout << a + b << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll n, ans=0;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
	}
	loop(i, 1, n){
		if(a[i-1] > a[i]){
			ans+=(a[i-1]-a[i]);
			a[i]+=(a[i-1]-a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4836