akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }


int main(){
  int n;
  cin>>n;
  ll a[300000],ans=0;
  rep(i,3*n) cin>>a[i];

  sort(a,a+(3*n));

  for(int i=n;i<(3*n);i+=2){
    ans+=a[i];
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(){
    
    int b; //?£?
    int f; //???
    int r; //??¨?±?
    int v; //??\?±??????°
    int p[4][3][10]={};
    int n, i, j, k;
    
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        p[b-1][f-1][r-1]+=v;
    }
    
    for(i=0;i<4;i++){
        if(i!=0)printf("####################\n");
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",p[i][j][k]);
            }
        printf("\n");
        }
    }
    
return 0;
}

Measured memory_bytes: 612
from collections import Counter
n = int(input())
nums = list(map(int, input().split()))
nums_count_dict = Counter(nums)
nums_count_combi = {key: value*(value-1)/2 for key, value in nums_count_dict.items()}
total = sum(nums_count_combi.values())
for number in nums:
    print(int(total-nums_count_dict[number]+1))

Measured memory_bytes: 33948
import java.util.Scanner;

public class Main {

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

		if(s.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
	}

}


Measured memory_bytes: 35628
# Problem C - Train Ticket

# input
ABCD = input()
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]

# initialization
pattern_list = []
for i in range(2**3):
    p = ['-']*3
    for j in range(3):
        if (i>>j)&1:
            p[j] = '+'
    pattern_list.append(p)

# check loop
for p in pattern_list:
    calc_str = A + p[0] + B + p[1] + C + p[2] + D
    if eval(calc_str)==7:
        calc_str += '=7'
        print(calc_str)
        break


Measured memory_bytes: 38384
import std.stdio, std.string, std.algorithm, std.conv, std.array, std.math;

void main(){
  auto hw=readln.split.to!(long[]);
  auto h=hw[0], w=hw[1];
  if(h % 3 == 0 || w % 3 == 0){
    writeln(0);
    return;
  }
  writeln(min(VtHr(h, w), HrVt(h, w), h, w));
}

long VtHr(long h, long w){
  return HrVt(w, h);

}

auto HrVt(long h, long w){
  return min(TCut(h, w, h/3), TCut(h, w, h/3+1));
}

long TCut(long h, long w, long cutAt)
{
  auto top=cutAt*w;
  if(w%2==0)
  {
    return abs(top-(w/2)*(h-cutAt));
  }else{
    return max(abs(top-(w/2)*(h-cutAt)), abs(top-(w/2+1)*(h-cutAt)));
  }
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int A[N]; rep(i, N) cin >> A[i];
    sort(A, A+N);
    int ans = 0;
    rep(i, K) ans += A[i];
    cout << ans << endl;
    return 0;
}

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

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

  vector<vector<ll>> G(N);
  vector<vector<ll>> next(1, vector<ll>(N));
  next.at(0).at(0) = -1;
  for (ll i = 0; i < N; i++)
  {
    ll K;
    cin >> K;
    for (ll j = 0; j < K; j++)
    {
      ll c;
      cin >> c;
      G.at(i).push_back(c);
      next.at(0).at(c) = i;
    }
  }

  vector<ll> depth(N, -1);
  depth.at(0) = 0;
  queue<ll> que;
  que.push(0);
  while (!que.empty())
  {
    ll v = que.front();
    que.pop();

    for (auto nv : G.at(v))
    {
      if (depth.at(nv) != -1)
        continue;

      depth.at(nv) = depth.at(v) + 1;
      que.push(nv);
    }
  }

  for (ll i = 0;; i++)
  {
    next.push_back(vector<ll>(N));
    bool fin = true;
    for (ll j = 0; j < N; j++)
    {
      ll tmp = next.at(i).at(j);
      if (tmp == -1)
        next.back().at(j) = -1;
      else
        next.back().at(j) = next.at(i).at(tmp);
      
      if (next.back().at(j) != -1)
        fin = false;
    }

    if (fin)
      break;
  }
  ll M = next.size();

  ll Q;
  cin >> Q;
  for (ll q = 0; q < Q; q++)
  {
    ll u, v;
    cin >> u >> v;

    if (depth.at(u) > depth.at(v))
      swap(u, v);

    ll x = depth.at(v) - depth.at(u);
    for (ll k = 0; k < M; k++)
    {
      if (x % 2 == 1)
        v = next.at(k).at(v);

      x /= 2;
    }
    if (u == v)
    {
      cout << u << endl;
      continue;
    }

    for (ll k = M - 1; k >= 0; k--)
    {
      if (next.at(k).at(u) != next.at(k).at(v))
      {
        u = next.at(k).at(u);
        v = next.at(k).at(v);
      }
    }
    ll ans = next.at(0).at(u);
    cout << ans << endl;
  }
}


Measured memory_bytes: 23216
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    int N;
    cin >> N;
    stack<int> st;
    int res = 0;
    
    st.push(0);
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a > st.top()) st.push(a);
        else if (a == st.top()) {}
        else {
            while (st.top() > a) {
                st.pop();
                ++res;
            }
            if (a > st.top()) st.push(a);
        }
    }
    cout << res + st.size() - 1 << endl;
    
    return 0;
}


Measured memory_bytes: 1800
#include <iostream>

using namespace std;

int main()
{
  int a, b , c ;
  cin >> a >> b >> c;
  if(a == 5 && b == 5 && c == 7)
    cout << "YES";

  else if (a == 5 && b == 7 && c == 5)
    cout << "YES";

  else if( a == 7 && b == 5 && c ==5)
    cout << "YES";
  else
    cout << "NO";

  return 0;
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_s)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

str = inputs[0][0]

# body
if $debugFlag
  p str
end

ans = "Yes"
for i in 1..str.length
  if i % 2 == 0
    unless str[i-1] == "L" or str[i-1] == "U" or str[i-1] == "D" 
      ans = "No"
      break
    end
  else
    unless str[i-1] == "R" or str[i-1] == "U" or str[i-1] == "D" 
      ans = "No"
      break
    end
  end
end

puts ans


Measured memory_bytes: 1788
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
x=int(input())
from collections import Counter
retl=[]
for i in range(1,x+1):
    tmp=prime_factorize(i)
    retl+=tmp
    
f=(Counter(retl))
ret=1
mod=10**9+7
for j in f.values():
    ret*=(j+1)
    ret%=mod
    
print(ret)
    
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll mod = 1000000007;
    vector<vector<ll>> dp(n, vector<ll>(3, 0));
    if(s[0] == '?' || s[0] == 'A')dp[0][0] = 1;
    ll pow = 1;
    if(s[0] == '?')pow = 3;

    for(int i = 1; i < n; i++){
        if(s[i] == 'A'){
            dp[i][0] = (dp[i-1][0] + pow) % mod;
            dp[i][1] = dp[i-1][1];
            dp[i][2] = dp[i-1][2];
        }else if(s[i] == 'B'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = (dp[i-1][1] + dp[i-1][0]) % mod;
            dp[i][2] = dp[i-1][2];
        }else if(s[i] == 'C'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = (dp[i-1][2] + dp[i-1][1]) % mod;
        }else{
            dp[i][0] = (3 * dp[i-1][0] + pow) % mod;
            dp[i][1] = (3 * dp[i-1][1] + dp[i-1][0]) % mod;
            dp[i][2] = (3 * dp[i-1][2] + dp[i-1][1]) % mod;
            pow = pow * 3 % mod;
        }
    }
    cout << dp[n-1][2] << endl;
}

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

int main()
{
    int N;
    scanf("%d",&N);

    char w[101][13];
    char s[13],s2;
    // scanf("%s",w[0]);
    for( int i=0;i<N;i++){
        scanf("%s",w[i]);
    }

    for( int i=1;i<N;i++){
        if( w[i-1][strlen(w[i-1])-1] != w[i][0] ){
            printf("No\n");
            return 0;
        }
        for( int j=0;j<i;j++ ){
            if( strcmp(w[j],w[i]) == 0 ){
                printf("No\n");
                return 0;
            }
        }

    }
    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    rep2(i, s.size()) {
        char temp = s[i];
        if (temp == '?') {
            printf("D");
        } else {
            printf("%c", temp);
        }
    }
    print("");
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;

int main()
{
	IOS
	ll a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	return 0;

}             

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

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

int main(void) {
    int a, b, ans = -1;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    REP(i, 1000 + 1) {
        int price_a = i * 0.08, price_b = i * 0.10;
        if (price_a == a && price_b == b) {
            ans = i;
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main() {
	int n,a=0,b=0,c=0,d=0;
	std::string s;
	std::cin>>n;
	rep(i,n){
		std::cin>>s;
		if(s=="AC")a++;
		else if(s=="WA")b++;
		else if(s=="TLE")c++;
		else d++;
	}
	std::cout<<"AC x "<<a<<std::endl;
	std::cout<<"WA x "<<b<<std::endl;
	std::cout<<"TLE x "<<c<<std::endl;
	std::cout<<"RE x "<<d<<std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main()
{
    long long N;
    cin >> N;
    vector<long long> A(N, 0);
    vector<long long> results(N, 0);
    for (long long i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    while(true) {
        bool foundDiff = false;
        
        for (long long i = 0; i < N; i++) {
            long long nextIndex = (i + 1) % N;
            long long nextMountain = (i + 2) % N;
            long long previousMountain = (N + i - 1) % N;
            if (A[nextIndex] > A[i]) {
                long long diff = A[nextIndex] - A[i];
                results[nextMountain] += 2 * diff;
                A[nextMountain] -= diff;
                A[nextIndex] -= diff;

                foundDiff = true;
            } else if (A[nextIndex] < A[i]) {
                long long diff = A[i] - A[nextIndex];
                results[i] += 2 * diff;
                A[i] -= diff;
                A[previousMountain] -= diff;
                foundDiff = true;
            }
        }
        
        if (foundDiff == false) {
            break;
        }
    }
    for (long long i = 0; i < N; i++) {
        cout << results[i] + A[i];
        if (i != (N - 1)) {
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  cout<<b/x-a/x+(a%x?0:1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        int ans = 0;
        while(n){
            ans += n/5;
            n /= 5;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 2980
n = int(input())
a = input()
b = input()
c = input()
res = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        pass
    elif a[i] == b[i]  and b[i] != c[i]:
        res += 1
    elif a[i] != b[i] and b[i] == c[i]:
        res += 1
    elif a[i] == c[i] and b[i] != c[i]:
        res += 1
    else:
        res += 2
print(res)

Measured memory_bytes: 38256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        int happy = 0;

        for (int j = 0; j < n; j++) {
            x = x - a[j];
            if (x < 0) {
                break;
            } else {
                happy++;
            }
        }
        if (x > 0) {
            happy--;
        }

        System.out.println(happy);
    }

}










Measured memory_bytes: 23764
#!/usr/bin/env python3
import sys, math, itertools
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0



a, b, c = map(int, input().split())
for i in itertools.permutations([a, b, c], 3):
    if i[0] == sum(i[1:]) or sum(i[:2]) == i[2]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> B[i];

    ll sum = 0;
    int n = 0;
    vector<int> plus;
    for (int i = 0; i < N; i++) {
        int diff = A[i] - B[i];
        if (diff < 0) { sum -= diff; n++; }
        else plus.push_back(diff);
    }

    if (sum == 0) cout << 0 << endl;
    else {
        int ans = n;
        sort(plus.begin(), plus.end(), greater<int>());
        ll p = 0;
        for (int i = 0; i < plus.size(); i++) {
            p += plus[i];
            ans++;
            if (p >= sum) break;
        }
        if (p >= sum) cout << ans << endl;
        else cout << -1 << endl;
    }

}

Measured memory_bytes: 4536
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("avx,avx2,fma,sse,sse2")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define N 200007

typedef tree<int, null_type, less<int>,rb_tree_tag,
tree_order_statistics_node_update> new_data;
int main()
{
    map<int,int>mp;
    int n,m,WA=0,AC=0;
    cin>>n>>m;
    int dp[n+5]={};
    set<int>ss;
    for(int i=0;i<m;i++)
    {
        string s;
        int x;
        cin>>x>>s;
        if(s=="WA")
        {
            if(mp[x]==0)dp[x]++;
        }
        else if(s=="AC")
        {
            if(mp[x]==0)AC++,mp[x]=1,ss.insert(x);
        }
    }
    for(auto i:ss)if(mp[i])WA+=dp[i];
        cout<<AC<<" "<<WA<<endl;

}


Measured memory_bytes: 13324
#include<stdio.h>
#include<map>
#define maxn 100010
#define ll long long
#define INF 1000000007
using namespace std; 
ll pow_mod(ll x,ll y,ll mod)
{
	ll ans=1;
	x=x%mod;
	while(y)
	{
		if(y&1)
		{
			ans=ans*x%mod;
		}
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}
int main()
{
	int n;
	ll a[maxn];
	while(scanf("%d",&n)!=EOF)
	{
		int i;
		map<ll,ll> m;
		for(i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			m[a[i]]++;
		}
		map<ll,ll>::iterator it;
		int ans=0,flag=0;
		if(n%2==0)
		{
			for(it=m.begin();it!=m.end();it++)
			{
				if(it->first%2!=0&&it->second==2)
					ans++;
				else
				{
					flag=1;
						break;
				}
			}
		}
		else
		{
			for(it=m.begin();it!=m.end();it++)
			{
				if(it->first==0&&it->second==1)
					continue;
				else if(it->first%2==0&&it->second==2)
					ans++;
				else
				{
					//printf("%lld %lld\n",it->first,it->second);
					flag=1;
					break;
				}
			}
		}
		if(flag)
			printf("0\n");
		else
			printf("%lld\n",pow_mod(2,ans,INF));
	}
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  for(int i=0;i<3;i++){
    cin>>s;
    if(s[0]=='a')s[0]='A';
    else if(s[0]=='b')s[0]='B';
    else if(s[0]=='c')s[0]='C';
    else if(s[0]=='d')s[0]='D';
    else if(s[0]=='e')s[0]='E';
    else if(s[0]=='f')s[0]='F';
    else if(s[0]=='g')s[0]='G';
    else if(s[0]=='h')s[0]='H';
    else if(s[0]=='i')s[0]='I';
    else if(s[0]=='j')s[0]='J';
    else if(s[0]=='k')s[0]='K';
    else if(s[0]=='l')s[0]='L';
    else if(s[0]=='m')s[0]='M';
    else if(s[0]=='n')s[0]='N';
    else if(s[0]=='o')s[0]='O';
    else if(s[0]=='p')s[0]='P';
    else if(s[0]=='q')s[0]='Q';
    else if(s[0]=='r')s[0]='R';
    else if(s[0]=='s')s[0]='S';
    else if(s[0]=='t')s[0]='T';
    else if(s[0]=='u')s[0]='U';
    else if(s[0]=='v')s[0]='V';
    else if(s[0]=='w')s[0]='W';
    else if(s[0]=='x')s[0]='X';
    else if(s[0]=='y')s[0]='Y';
    else s[0]='Z';
    cout<<s[0];
  }
  cout<<endl;
}
  


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, d);
  cout << "Christmas";
  rep(i, 25 - d) cout << " Eve";
  cout << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;



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

    int n,k;
    cin>>n>>k;
     ll ans=k;
    for(int i=1;i<n;i++){

            ans*=(k-1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,d,x;
  cin>>n>>d>>x;
  double f=(2*d+(2*n-1)*x)/2.0;
  double v=0;
  double vl=1;
  for(in c=n;c>=1;--c){
    v+=f*vl;
    vl*=(3*1+1*(2*c-1))/double(2*c);
  }
  cout<<setprecision(15);
  cout<<v<<endl;
  return 0;
}


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


flag=True
if len(s)!=a+b+1:
  flag=False
  
for i in range(len(s)):
  if i==a:
    if s[i]!='-':
      flag=False
  else:
    if s[i]=='-':
      flag=False
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    long MOD = (long) 1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        ArrayList<Integer> units = new ArrayList<>();
        ArrayList<Integer> count = new ArrayList<>();

        for (int i = 1; i * i <= n; i++) {
            units.add(i);
        }

        ArrayList<Integer> unitsRev = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n / i != i) {
                unitsRev.add(n / i);
            }
        }

        Collections.reverse(unitsRev);
        units.addAll(unitsRev);

        int size = units.size();
        count.add(1);
        for (int i = 1; i < size; i++) {
            count.add(units.get(i) - units.get(i - 1));
        }

        long[][] dp = new long[2][size];
        int x = 0;
        dp[0][0] = 1;

//        debug(count);
//        debug(units);
//        debug(dp[x]);

        for (int i = 0; i < k; i++) {
            x = 1 - x;

            dp[x][size - 1] = dp[1 - x][0];
            for (int j = size - 2; j >= 0; j--) {
                dp[x][j] = (dp[x][j + 1] + dp[1 - x][size - j - 1]) % MOD;
            }
            for (int j = 0; j < size; j++) dp[x][j] = (dp[x][j] * count.get(j)) % MOD;
//            debug(dp[x]);
        }
        long ans = 0;
        for (int i = 0; i < size; i++) ans = (ans + dp[x][i]) % MOD;
        System.out.println(ans);
    }

    static void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 27384
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int t,a;
    cin>>t>>a;
    vector<double> arr(n);
    for(auto &x:arr)
    {
        cin>>x;
        x=t-x*0.006;
    }

    double mdiff=1e9;
    int ans;
    for(int i=0;i<n;++i)
    {
        if(mdiff>abs(arr[i]-a))
        {
            mdiff=abs(arr[i]-a);
            ans=i+1;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static int count = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        dfs(0, n);
        System.out.println(count);
    }

    private static void dfs (long l, int n){
        if (l > n){
            return;
        }

        String str = String.valueOf(l);
        if (str.contains("3") && str.contains("5") && str.contains("7")){
            count++;
        }

        dfs(10 * l + 3, n);
        dfs(10 * l + 5, n);
        dfs(10 * l + 7, n);
    }


}

Measured memory_bytes: 23892
import collections
N = int(input())
S = []
for _ in range(N):
    S.append(list(input()))
def taikaku(A):
    n = len(A)
    b = True
    for i in range(n):
        for j in range(i+1):
            if A[j][i] != A[i][j]:
                b = False
                break
        if not b:
            break
    return(b)
ans = 0
for i in range(N):
    if taikaku(S[i:]+S[:i]):
        ans += N
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vi b(a);
    sort(b.begin(),b.end());
    vi ind;
    for(ll i=0;i<n;i++)
    {
        if(b[i]!=a[i])
        {
            ind.pb(i);
        }
    }
    if(ind.size()==2 || ind.size()==0)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


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

int main()
{
int s,count=1;scanf("%d",&s);
set<int> S;S.insert(s);
while(true)
{
if(s%2==0)s/=2;
else s=3*s+1;
count++;
if(S.count(s))break;
else S.insert(s);
}
printf("%d\n",count);
}

Measured memory_bytes: 256
O=list(str(input()))
E=list(str(input()))

resuidal=[]
if len(O)!=len(E):
    resuidal.append(O[-1])
    O.pop()

    
Ans=[]
for index in range(len(O)):
    Ans.append(O[index])
    Ans.append(E[index])
    
if resuidal!=[]:
    Ans.append(resuidal[0])
    
print(("").join(Ans))

Measured memory_bytes: 3064
#include<stdio.h> 

int main()
{   
    int a,h,m,s;
    scanf("%d",&a);
        h=a/3600;
        m=(a-3600*h)/60;
        s=(a-3600*h)%60;
            printf("%d:%d:%d\n",h,m,s); 
     return 0;
}


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

int main(){


int X,N;
cin >> X >> N;

vector < int > v;
int a;

for(int i =0 ; i<N; i++)
{
    cin >> a;
    v.push_back(a - X);
}

//sort(v.begin(), v.end());

vector<int>::iterator itr;
itr = find(v.begin(), v.end(), 0);
if (itr == v.end()) 
{
    cout << X;
    return 0;
}

for(int i =1 ; i<100; i++)
{
    vector<int>::iterator itr1,itr2;
    itr1= find(v.begin(), v.end(), -i);
    if(itr1== v.end())
    {
        cout << X - i;
        return 0;
    }

    itr2= find(v.begin(), v.end(), i);
    if(itr2== v.end())
    {
        cout << X + i;
        return 0;
    }


}




    return 0;
}




Measured memory_bytes: 3608
#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 h, a;
  cin >> h >> a;
  if(h <= a){
    cout << 1 << endl;
    return 0;
  }
  if(h % a == 0) {
    cout << h / a << endl;
    return 0;
  }
  else {
    cout << (h / a) + 1 << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int A, B;
  cin >> A >> B;
  print(max({A + B, A - B, A * B}));
  return 0;
}
#include <algorithm>


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

int		main(void)
{
	int n, d, x;

	cin >> n >> d >> x;
	int a[n];

	for (int i = 0; i < n; i++)
		cin >> a[i];
	int sum = 0;

	for (int i = 0; i < n; i++)
		for (int j = 1; j <= d; j += a[i])
			sum++;
	cout << sum + x << endl;
}


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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

int main() {
    int n, k;

    cin >> n >> k;

    int i = 1;
    int x = k;
    for (;;) {
        if (x > n) {
            break;
        }
        x *= k;
        i++;
    }

    cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

vector<ll> num[200010];

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N + 1, 0);
	for (int i = 1;i <= N;i++) {
		cin >> A[i];
		A[i]--;
		A[i] %= K;
	}

	for (int i = 1;i <= N;i++)A[i] += A[i - 1], A[i] %= K;

	map<ll, ll> Z;
	for (int i = 0;i <= N;i++) {
		if (Z.count(A[i])) {
			num[Z[A[i]]].push_back(i);
		}
		else {
			Z.insert({ A[i],i });
			num[i].push_back(i);
		}
	}

	ll ans = 0;
	for (int i = 0;i <= N;i++) {
		int js = num[i].size();
		for (ll j = 0;j < js;j++) {
			auto it = upper_bound(all(num[i]), num[i][j] - K);
			ll dis = it - num[i].begin();
			ans += j - dis;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int mn=max(a,c);
    int mx=min(b,d);
    if((mx-mn)<0) cout<<0<<endl;
    else cout<<mx-mn<<endl;
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int main(){
  int n; cin >> n;
  int a[100001] = {};
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    a[x]++;
  }
  ll sum = 0;
  for(int i = 0; i < 100001; ++i){
    sum += i * a[i];
  }
  int q; cin >> q;
  for(int turn = 0; turn < q; ++turn){
    ll b,c; cin >> b >> c;
    sum -= b * a[b];
    sum += c * a[b];
    a[c] += a[b];
    a[b] = 0;
    cout << sum << endl;
  }
  
  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e9+7;
int M[100001], D[100001];

int mul(int a, int b)
{
	return 1LL*a*b%MOD;
}

int fast_pow(int a, int b)
{
	int ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=mul(ret,a);
		a=mul(a,a);
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K, ans=0;
	cin>>N>>K; memset(M,-1,sizeof(M));
	for(int i=K;i>0;i--) {
		if(M[K/i]==-1) M[K/i]=fast_pow(K/i,N);
		D[i]=M[K/i];
		for(int j=2*i;j<=K;j+=i) {
			D[i]-=D[j];
			if(D[i]<0) D[i]+=MOD;
		}
		ans+=mul(i,D[i]);
		if(ans>=MOD) ans-=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 4364
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

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

int main(){
	int N;
	while(cin>>N,N){
		int X,Y;
		bool fld[21][21]={};
		for(int i=0;i<N;i++){
			cin>>X>>Y;
			fld[Y][X] = true;
		}
		int M,L,direct,y=10,x=10,cnt=0;
		char D;
		cin>>M;
		for(int i=0;i<M;i++){
			cin>>D; cin>>L;
			if(D=='N') direct = 0;
			else if(D=='E') direct = 1;
			else if(D=='S') direct = 2;
			else if(D=='W') direct = 3;
			for(int j=0;j<L;j++){
				y += dy[direct]; x += dx[direct];
				if(fld[y][x]==true){
					fld[y][x] = false;
					cnt++;
				}
			}
		}
		if(cnt==N) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i)-1 = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{	
    ll h, w;
    cin >> h >> w;
    string s[50];
    REP(i, h) cin >> s[i];

    REP(i, h){
        REP(j, w){
            ll ans = 0;
            if(s[i][j] == '#') continue;
            if(j != 0 && s[i][j-1] == '#') ans++;
            if(j != w-1 && s[i][j+1] == '#') ans++;
            if(i != 0 && j != 0 && s[i-1][j-1] == '#') ans++;
            if(i != 0 && s[i-1][j] == '#') ans++;
            if(i != 0 && j != w-1 && s[i-1][j+1] == '#') ans++;
            if(i != h-1 && j != 0 && s[i+1][j-1] == '#') ans++;
            if(i != h-1 && s[i+1][j] == '#') ans++;
            if(i != h-1 && j != w-1 && s[i+1][j+1] == '#') ans++;
            s[i][j] = ans + '0';
        }
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define lol long long
#define mp(x,y) make_pair(x,y)
using namespace std;

//const lol mod=1e9+7;

/*  author: H3XoRuSH  */

int main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol n,h,w;
    cin >> n >> h >> w;
    lol ans=(n-h+1)*(n-w+1);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
   int a[3][3];
   rep(i,3)rep(j,3){
       a[i][j]=0;
   }
   rep(i,3)rep(j,3){
       cin>>a[i][j];
       //cout<<a[i][j];
   }
   int n;cin>>n;
    rep(k,n){
        int b;cin>>b;
        rep(i,3)rep(j,3){
            if(a[i][j]==b) a[i][j]=-1;
        }
    }
    int ans=1;
    rep(i,3){
        if(a[i][0]==a[i][1] and a[i][0]==a[i][2]) ans=-1;
    }
    rep(i,3){
        if(a[0][i]==a[1][i] and a[0][i]==a[2][i]) ans=-1;
    }
    if((a[0][0]==a[1][1] and a[2][2]==-1) or (a[1][1]==a[0][2] and a[2][0]==-1)) ans=-1;
    //rep(i,3)rep(j,3) cout<<a[i][j];
    if(ans<0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int , null_type,less<int , rb_tree_tag,tree_order_statistics_node_update>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 100000000
// order_of_key and *find_by_order
#define N 10000001
int32_t main() {
	fast;
	int x, y;
	cin >> x >> y;
	if (y - 2 * x >= 0 and (y - 2 * x) & 1 ^ 1) {
		if (x - (y - (2 * x)) / 2 >= 0) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else {
		cout << "No";
	}









}

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

int main(){
    int n;
    cin >> n;
    cout.precision(10);
    cout << (double)(n - n/2) / (double)n << endl; 
    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

string x,y;
    ll dp[3005][3005]={0};
    ll dir[3005][3005];
/*
        1->up
        2->right
        3->print
    */
void print(ll dir[3005][3005],ll r,ll c)
{
    if(r==0 || c==0)
        return;

    if(dir[r][c]==1)
        print(dir,r-1,c);
    else if(dir[r][c]==2)
        print(dir,r,c-1);
    else
    {
        print(dir,r-1,c-1);
        cout<<x[r-1];
    }
}

int main()
{
    fast();
    cin>>x>>y;

    ll n=x.length();
    ll m=y.length();

    for(ll i=0;i<=n;i++)
        for(ll j=0;j<=m;j++)
            dp[i][j]=dir[i][j]=0;

    /*
        1->up
        2->right
        3->print
    */
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            if(x[i-1]==y[j-1]){
                dp[i][j]= dp[i-1][j-1]+1;
                dir[i][j]=3;
            }

            else if(dp[i-1][j]>=dp[i][j-1])
            {
                dp[i][j]= dp[i-1][j];
                dir[i][j]=1;
            }

            else
            {
                dp[i][j]= dp[i][j-1];
                dir[i][j]=2;
            }
        }
    }

    print(dir,n,m);

}



Measured memory_bytes: 141312
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        x[b-1]=0
    if h[a-1]<=h[b-1]:
        x[a-1]=0
print(sum(x))



Measured memory_bytes: 20116
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
  long N,p=0;
  cin>>N;
  vector<int> a(3*N);
  	for(int i=0;i<3*N;i++){
      cin>>a.at(i);
    }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
      for(int i=1;i<2*N;i+=2){
      	p+=a.at(i);
      }
  cout<<p<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n;
	string s,t,u="";
	cin>>n;
	cin>>s>>t;
	for(int i=0;i<n;i++)
	{
		u+=s[i];
		u+=t[i];
	}
	cout<<u<<endl;
	return 0;
}

Measured memory_bytes: 256