akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> time(N);
  for(int i = 0; i  < N; i ++){
    cin >> time[i];
  }
  
  int M;
  cin >> M;
  
  vector<vector<int>> drag(2, vector<int>(M));
  for(int j = 0; j < M; j++){
    cin >> drag[0][j];
    cin >> drag[1][j];
  }
  
  for(int k = 0; k < M; k++){//使用するdrag
      int ans = 0;
    for(int l = 0; l < N; l++){//時間の総和
      if(drag[0][k]-1 == l) ans += drag[1][k];
      if(drag[0][k]-1 != l) ans += time[l];
    }  
    cout <<  ans << endl;
  }
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/02/20 20:55:48
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
template <typename T>
class binary_indexed_tree {
 private:
  vector<T> tree_;

 public:
  explicit binary_indexed_tree(size_t size) : tree_(size+1) {}

  template <typename Iter>
  explicit binary_indexed_tree(Iter begin, Iter end) : binary_indexed_tree(end-begin) {
    for (auto it = begin; it != end; ++it)
      add(it-begin, *it);
  }

  void add(size_t index, T x) {
    for (size_t i = index+1; i < tree_.size(); i += i&(-i))
      tree_[i] += x;
  }

  T sum(size_t index) const {
    T sum = 0;
    for (size_t i = index+1; i > 0; i -= i&(-i))
      sum += tree_[i];
    return sum;
  }

  T range_sum(size_t l, size_t r) const {
    return l > 0 ? sum(r-1)-sum(l-1) : sum(r-1);
  }

};

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

  int n,q; cin>>n>>q;
  vector<int> C(n); for (auto &c:C) cin>>c;

  vector<int> p(n+1, -1);
  vector<pair<int,int>> cm;
  for (int i = 0; i < n; i++) {
    cm.emplace_back(p[C[i]], i);
    p[C[i]] = i;
  }
  sort(cm.begin(), cm.end());

  struct Query {
    int i;
    int l,r;
  };
  vector<Query> Q(q);
  for (int i = 0; i < q; i++) {
    int l,r; cin>>l>>r; l--; r--;
    Q[i] = {i,l,r};
  }
  sort(Q.begin(), Q.end(), [](auto l, auto r) {return l.l<r.l;});

  vector<int> ans(q);
  binary_indexed_tree<int> bit(n);
  int l = 0;
  int k = 0;
  for (int i = 0; i < n; i++) {
    while (l < n and cm[l].first < i) {
      bit.add(cm[l].second, 1);
      l++;
    }
    while (k < q and Q[k].l == i) {
      ans[Q[k].i] = bit.range_sum(i, Q[k].r+1);
      k++;
    }
  }
  for (auto a:ans)
    cout << a << endl;

  return 0;
}


Measured memory_bytes: 21356
using System;
using System.Linq;

class Program
{
    static string str;
    static int gnd=0, sum = 0;
    static void Main()
    {
         str = Console.ReadLine();
        int a = str.Length; int  cnt = 0, k = 0;
        int[] ind = new int[10000];
        for (int i = 0; i < a; i++)
        {
            if (str[i] == '\\')
            {
                gnd = 0;
                for (int j = i; j < a; j++)
                {
                    if (str[j] == '\\')
                    { gnd++; }
                    else if (str[j] == '/')
                    {
                        gnd--;
                        if (gnd == 0)
                        {
                            cnt++;
                            ind[k] = measure(i, j);
                            k++;
                            i = j;
                            break;
                        }
                    }
                }
            }
        }
        Console.WriteLine(sum);
        Console.Write(cnt);
        for (int i = 0; i < cnt; i++)
        {
            Console.Write(" " + ind[i]);
        }
        Console.WriteLine();
    }

    private static int measure(int i, int j)
    {
        int tmp = 0; gnd = 0;
        for (; i <= j; i++)
        {
            if (str[i] == '\\')
            {
                tmp += gnd * 2 ;
                gnd++;
            }
            else if (str[i] == '/')
            {
                tmp += gnd * 2;
                gnd--;
            }
            else if(str[i] == '_')
            {                tmp += gnd * 2 ;            }
        }
        tmp /= 2;
        sum += tmp;
        return tmp;
    }

}

Measured memory_bytes: 5808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;


int main(){
  long long N;
  string S;
  cin >> N;
  if(N == 0){
    S = "0";
  } else {
    while(N != 1){
      //偶数なら
      if(N % 2 == 0){
	S = "0" + S;
	N /= (-2);
      } //偶数でないなら
      else {
	S = "1" + S;
	N = (N-1)/(-2);
      }
    }
    S = "1" + S;
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> H[h + 1], W[w + 1];
    int hmax = 0, wmax = 0;
    map<pii, bool> mp;
    while(m--) {
        int i, j;
        cin >> i >> j;
        mp[pii(i, j)] = 1;
        H[i].pb(j);
        chmax(hmax, (int) H[i].size());
        W[j].pb(i);
        chmax(wmax, (int) W[j].size());
    }
    vector<int> HM, WM;
    rep(i, h + 1) if (H[i].size() == hmax) HM.pb(i);
    rep(i, w + 1) if (W[i].size() == wmax) WM.pb(i);
    int ans = hmax + wmax - 1;
    for(auto i : HM) for(auto j : WM) {
        if (!mp[pii(i, j)]) {
            ans++;
            cout << ans << endl;
            return;
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 58872
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,x,t,ans,o;
    cin>>n>>x>>t;
    o=n/x;
    if(n%x!=0){
        ans=t*(o+1);
    }
    else{
        ans=t*(o);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
import bisect

n = int(input())
a = []

for i in range(n):
    x = int(input())
    a.append(x)
a = a[::-1]

stack = [a[0]]

for i in range(1, n):
    index = bisect.bisect_right(stack, a[i])
    if index == len(stack):
        stack.append(a[i])
    else:
        stack[index] = a[i]

print(len(stack))


Measured memory_bytes: 7840
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

N,K = map(int,input().split())
c = [[0 for _ in range(N)] for _ in range(N)]
c[0][0] = 1
for i in range(N-1):
    for j in range(N):
        if j > 0: c[i+1][j] += c[i][j-1]
        c[i+1][j] += c[i][j]
def f2(n,k):
    return c[n+k-1][k-1]%1000000007
def f(n,k):
    if n-k<0: return 0
    if n==k: return 1
    if k<1: return 0
    return f2(n-k,k)%1000000007

for i in range(1,K+1):
    blue = f(K,i)
    red = f(N-K,i-1)+2*f(N-K,i)+f(N-K,i+1)
    ans=blue*red
    print(int(ans%1000000007))


Measured memory_bytes: 481000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
  int n;
  ll t;
  cin >> n >> t;
  ll ma=-1, ma_num=0, mi;
  cin >> mi;
  for(int i=1;i<n;i++){
    ll a;
    cin >> a;
    if(mi<=a){
      if(ma==(a-mi)){
        ma_num++;
      }else if(ma<(a-mi)){
        ma=a-mi;
        ma_num=1;
      }
    }else{
      mi=a;
    }
  }
  cout<<ma_num<<endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::HashSet;

fn main() {
    input!(
        x: isize,
        n: isize,
        p: [isize; n],
    );
    let set: HashSet<isize> = p.into_iter().collect();
    for i in 0..101 {
        if !set.contains(&(x-i)) {
            println!("{}", x-i);
            break;
        } else if !set.contains(&(x+i)) {
            println!("{}", x+i);
            break;
        }
    }
}


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

long long a,b,c,d;

long long gcd(long long a, long long b) {
    if(a < b) swap(a, b);
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}
long long f(long long in) {
    long long num = in;
    num -= in / c;
    num -= in / d;
    num += in / lcm(c, d);
    return num;
}

int main() {
  cin >> a >> b >> c >> d;
  cout << f(b) - f(a - 1) << endl;
  
}
    
      


Measured memory_bytes: 256
// originally this code was very different and ended in the punchline "blimpin' ain't easy"; i
// invite you to imagine what sort of code that might have been; if your imagination is great
// enough feel free to sincerely laugh at your amazing comedic setup
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
using ll = int64_t;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T, typename U> ostream& operator<<(ostream& _s, pair<T, U> _t) {
    _s << "(" << _t.first << "," << _t.second << ")"; return _s;
}
template<typename T, typename U> istream& operator>>(istream& _s, pair<T, U> &_t) {
    _s >> _t.first >> _t.second; return _s;
}
template<typename T> ostream& operator<<(ostream& _s, vector<T> _t) {
    rep(i, 0, _t.size()) _s << (i ? " " : "") << _t[i]; return _s;
}
template<typename T> istream& operator>>(istream& _s, vector<T> &_t) {
    rep(i, 0, _t.size()) _s >> _t[i]; return _s;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    if (__builtin_popcount(n) == 1) {
        cout << "No" << endl;
        return 0;
    }

    vector<pair<int,int>> edges = {
        {1, 2},
        {2, 3},
        {3, 1+n},
        {1+n, 2+n},
        {2+n, 3+n}
    };

    rep(i,4,n) {
        edges.push_back({i, i+1});
        edges.push_back({i+1, 1});
        edges.push_back({1, i+n});
        edges.push_back({i+n, i+n+1});
        i++;
    }

    if (n%2 == 0) {
        int bad = n;
        int pw = 1;
        rep(i,0,30) {
            if (((1 << i) & bad) != 0) {
                pw = (1 << i);
            }
        }
        edges.push_back({bad, pw + 1});
        edges.push_back({bad+n, (bad ^ pw) + n});
    }

    cout << "Yes" << endl;
    assert(edges.size() == 2*n-1);
    for(auto e : edges) {
        cout << e.first << " " << e.second << endl;
    }
}


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

using namespace std;

int main(void){
  long long int N;
  vector<long long int> a(5,0); 

  cin >> N;
  for(int i=0;i < 5; i++)cin >> a[i];

  long long int min = *min_element(a.begin(),a.end());
  long long int ans = 4 + (N + min - 1 )/min;

  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << setprecision(15) << w * h / 2.0 << " " << ((w / 2.0 == x && h / 2.0 == y)? 1: 0) << endl;
}

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

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  if(c-a-b < 0) cout << "No" << endl;
  else {
    if(4 * a * b < (c-a-b) * (c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
const int N = 200000 + 5;
int a[N], n;
int stk[N], top;
 
int main () {
	cin>>n;
	for (int i = 1; i <= n; ++i) {
		cin>>a[i];
	}
	stk[1] = 1;
	top = 1;
	for (int i = 2; i <= n; ++i) {
		if (a[i] <= a[stk[top]]) {
			stk[++top] = i;
		}
		else {
			int l = 1, r = top;
			while (l < r) {
				int mid = (l + r) / 2;
				if (a[stk[mid]] < a[i]) {
					r = mid;
				}
				else {
					l = mid + 1;
				}
			}
			stk[l] = i;
		}
	}
	cout<<top<<endl;
	return 0;
}

Measured memory_bytes: 4344
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

const ll N = 1e7+10;
int p[N];

int main()
{
    rep(i,1,N)p[i]=1;
    for(ll i=2;i<N;i++){
        for(ll j=1;i*j<N;j++)
            p[i*j]++;
    }

    ll n;cin>>n;
    ll val=0;
    rep(i,1,n+1)
        val+=(i*p[i]);
    cout<<val;
}


Measured memory_bytes: 42620
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int dp[12][12];

int lg[200005];

void Main() {
  int n; cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    int t = i;
    while(t) {
      lg[i] = t % 10;
      t /= 10;
    }
    dp[lg[i]][i % 10]++;
  }
  for(int i = 1; i <= n; i++) {
    ans += dp[i % 10][lg[i]];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
  	ll n, m;
  	cin >> n >> m;
  	if (n == 1 || m == 1)
    	cout << 1 << endl;
  	else
      	cout << (n*m+1)/2 << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       int  n;
       cin>>n;
       string s;
       cin>>s;
       map<char,ll> mp;
       fri(i,0,n){
              mp[s[i]]++;
       }
       ll ans = 0;
       ans = mp['R']*mp['G']*mp['B'];
       fri(i,0,n){
              fri(dff,1,n)
              {
                     set<char> ss;
                     if(i+2*dff < n){
                            ss.insert(s[i]);
                            ss.insert(s[i+dff]);
                            ss.insert(s[i+dff+dff]);
                            if(ss.size()==3){ans--;}
                     }
              }
       }
       cout<<ans<<endl;
}


Measured memory_bytes: 3632
S = input().split()
T = input().split()
flag = True

for i in range(len(S[0])):
    if S[0][i] == T[0][i]:
        continue
    else:   
        print('No')
        flag = False
        break

if len(S[0]) == len(T[0])-1 and flag:
    print('Yes')


Measured memory_bytes: 9044
#include <iostream>
#include <vector>
//#include <math>

using namespace std;

std::vector<long> get_deviders(const int M) {
    std::vector<long> v;

    for (long i = 1; i * i < M; i++) {
        if (M % i == 0) {
            v.push_back(i);
        }
    }

    return v;
}

int main(int argc, char* argv[]) {
    int N, M;

    std::cin >> N >> M;

    //auto deviders = get_deviders(M);

    long ans = 1;
    for (long i = 1; i * i < M; i++) {
        if (M % i == 0) {
            auto d = i;
            if (M >= d * N) ans = std::max(ans, d);
            if (d >= N) ans = std::max(ans, M / d);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
ans3 = [3*(i*2+1) for i in range(5000)]
ans2 = [2*(i+1) for i in range(15000)]

if N == 3:
    print(2,5,63)
elif N == 4:
    print(2,5,20,63)
elif N == 6:
    print(3,6,9,12,2,4)
elif N == 19999:
    ans = ans2[:14999]+ans3
    print(' '.join(map(str,ans)))
else:
    for x in range(1,2501):
        if (N-x*2)%3 == 0:
            y = (N-x*2)//3
            if 1 <= y <= 5000:
                ans = ans3[:x*2]+ans2[:y*3]
                break
    print(' '.join(map(str,ans)))


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

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

  bool flag = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[0] != 'A') {
      flag = true;
    }

    int count = 0;
    for (int j = 2; j < s.size() - 1; j++) {
      if (s[j] == 'C') {
        count++;
      }
    }
    if (count != 1) {
      flag = true;
    }

    count = 0;
    for (int j = 0; j < s.size(); j++) {
      if ('a' <= s[j] && s[j] <= 'z') {
        count++;
      }
    }
    if (count != s.size() - 2) {
      flag = true;
    }
  }

  if (flag) {
    cout << "WA" << endl;
  }
  else {
    cout << "AC" << endl;
  }
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.shift();
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
    //   arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      [arr[i], arr[largest]] = [arr[largest], arr[i]];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
vpi V;
vi cur = {0};

void ad(pi x) {
    F0Rd(i,sz(cur)) if (cur[i] <= x.f) {
        if (i == sz(cur)-1) cur.pb(2*MOD);
        cur[i+1] = min(cur[i+1],cur[i]+x.s);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N; V.resize(N);
    F0R(i,N) cin >> V[i].f >> V[i].s;
    sort(all(V),[](const pi& l, const pi& r) { return l.f+l.s < r.f+r.s; });
    for (auto a: V) ad(a);
    cout << sz(cur)-1;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define nd second
#define st first
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using mii=map<int,int>;
using si=set<int,int>;
using vpi=vector<pii>;
using vpl=vector<pll>;

const int N=(int)1e5+5;

ll n,m,a,b,c,q,W;
ll dp[N];
bool czy[N];
vpi V;

int R(int l, int p){
	return rand()%(p-l+1)+l;
}

void wczytaj(){
	cin>>n>>W;
	for (int i=0; i<n; ++i){
		cin>>a>>b;
		V.pb({a,b});
	}
	sort(V.begin(),V.end());
	czy[0]=1;
}

void solve(){
	for (pii p:V){
		for (int i=(int)1e5; i>=0; --i){
			if (p.nd<=i and czy[i-p.nd]){
				czy[i]=1;
				dp[i]=min(dp[i], dp[i-p.nd]+p.st);
			}
		}
	}
	for (int i=(int)1e5; i>=0; --i){
		if (dp[i]<=W){
			cout<<i<<'\n';
			return;
		}
	}
	cout<<0<<'\n';
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ilosc_przypadkow_testowych=1;
//	cin>>ilosc_przypadkow_testowych
	for (int i=1; i<=ilosc_przypadkow_testowych; ++i){
		wczytaj();
		for (int j=1; j<=1e5; ++j)dp[j]=(ll)1e18;
		solve();
	}
}

Measured memory_bytes: 1152
S = input()

N = len(S)
ans = 0
for bit in range(2**(N-1)):
    f = S[0]
    for i in range(N-1):
        if bit>>i & 1:
            f += "+"
        f += S[i+1]
    ans += sum(map(int, f.split('+')))
print(ans)


Measured memory_bytes: 9184
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(.int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

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

int main(void) {
	int n, a;

	cin >> n >> a;

	n = n % 500;
	if (n <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <utility>

using namespace std;
typedef long long ll;

#define ALL(c) begin((c)), end((c))
#define REP(i,n) for(ll i=0;i<(ll)n;++i)

inline int getInt() { int s; scanf("%d", &s); return s; }

#define SIZE 10
typedef array<array<int, SIZE>, SIZE> Table;

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

void fillColor(Table & state, int from, int to, int x, int y){
	if (from==to) return;
	REP(i, 4){
		if(state[y+dy[i]][x+dx[i]] != from) continue;
		state[y+dy[i]][x+dx[i]] = to;
		fillColor(state, from, to, x+dx[i], y+dy[i]);
	}
}

int countColor(Table & state, int x, int y){
	int cnt = 0;
	REP(i, 4) {
		if (state[y + dy[i]][x + dx[i]] != g_c) continue;
		state[y + dy[i]][x + dx[i]] = -1;
		cnt += 1 + countColor(state, x + dx[i], y + dy[i]);
	}
	return cnt;
}

int recursion(int depth, Table state) {
	if (depth > 5) return countColor(state, 1, 1);
	
	int cnt = 1;
	REP(i, 6) {
		if(depth==5 && i != g_c) continue;
		Table ntable = state;
		ntable[1][1] = i;
		fillColor(ntable, state[1][1], i, 1, 1);
		cnt = max(recursion(depth+1, ntable),cnt);
	}
	return cnt;
}

int main() {
	while (true) {
		ll h,w;
		cin >> h >> w;
		if (h == 0) break;
	
		g_c = getInt() - 1;
		Table table;
		REP(y, SIZE) REP(x, SIZE) table[y][x] = -1;
		REP(y, h) REP(x, w) table[y + 1][x + 1] = getInt()-1;
		cout << recursion(1, table) << endl;
	}
}

Measured memory_bytes: 1248
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

w = 100
h = 50

solve :: Int -> Int -> V.Vector (VU.Vector Bool)
solve !b !a = V.concat [whiteArea, blackArea]
 where
  whiteArea =
    let
      blackH = (a - 1) `div` (w `div` 2)
      blackW = (a - 1) `mod` (w `div` 2)
      line   = VU.replicate w False
    in
      V.replicate h line
        V.// [ ( i * 2
               , if i < blackH
                 then
                   line VU.// [ (j, True) | j <- [0 .. w - 1], even j ]
                 else
                   line VU.// [ (j, True) | j <- [0 .. blackW * 2 - 1], even j ]
               )
             | i <- [0 .. blackH]
             ]
  blackArea =
    let
      whiteH = (b - 1) `div` (w `div` 2)
      whiteW = (b - 1) `mod` (w `div` 2)
      line   = VU.replicate w True
    in
      V.replicate h line
        V.// [ ( i * 2 + 1
               , if i < whiteH
                 then
                   line VU.// [ (j, False) | j <- [0 .. w - 1], even j ]
                 else
                   line
                     VU.// [ (j, False) | j <- [0 .. whiteW * 2 - 1], even j ]
               )
             | i <- [0 .. whiteH]
             ]

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (a, b) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine

  let r = solve a b
  putStrLn $ show w ++ " " ++ show (2 * h)
  V.forM_ r $ \vec -> do
    VU.forM_ vec $ \b -> do
      putStr $ if b then "#" else "."
    putStrLn ""


Measured memory_bytes: 1020
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
// using ll = long long;
// using P = pair<int,int>;
// using vi = vector<int>;
// using vvi = vector<vi>;

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

template <typename T>
bool chmax(T &a, T &b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, T &b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}


int main() {
  int n,x;
  
  while(cin >> n >> x) {
    if(n == 0 && x == 0) break;
    int ans = 0;
    for(int i = 1; i <=n; i++) {
      for(int j = i+1; j <=n; j++) {
	for(int k = j+1; k <=n; k++) {
	  if(i+j+k == x) ans++;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}








Measured memory_bytes: 3104
#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MAXN 1000005 

int d,t,s;

int main()
{
	cin>>d>>t>>s;
	if(t*s>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
} 

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    int n, m, k;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
    }

    private void solve() {
        boolean flg = false;
        for (int col = 0; col <= n; col++) {
            for (int row = 0; row <= m; row++) {
                int count = col * m + row * n;
                count -= col * row * 2;
                if (count == k) {
                    flg = true;
                }
            }
        }

        if (flg)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

ll factorial(ll n,ll m){
    ll r = 1;
    for(ll i=1;i<=n;i++) r = (i*r)%m;
    return r%m;
}

int main() {

    ll mod = 1000000007;
    ll N,M;
    cin >> N >> M;
    ll out = 0;
    if(abs(N-M)<2){
        ll n = factorial(N,mod);
        ll m = factorial(M,mod);
        out = (n*m)%mod;
        if(N==M) out = (out*2)%mod;
    }
    cout << out << endl;
    return 0;
}


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++){
    if(a[i]%2==1)cnt++;
  }
  if(cnt%2==0)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    int m = 1, k = 0;
    bool flg = false;
    while(n > k){
        m++;
        k = m * (m-1) / 2;
        if(n==k) flg = true;
    }

    if(!flg){pr("No"); return 0;}
    else pr("Yes");

    pr(m);

    vector<int> s[m];
    s[0].push_back(1);
    s[1].push_back(1);
    FOR(i, 2, m){
        int nd = s[i-1].back() + 1;
        rep(j, i){
            s[j].push_back(nd);
            s[i].push_back(nd);
            nd++;
        }
    }

    rep(i, m){
        cout << s[i].size() << " ";
        prvec(s[i]);
    }

    return 0;}

Measured memory_bytes: 4216
#include <stdio.h>
int main(void)
{
	char a[4], b, c = 0;
	
	scanf("%s", a);
	
	for(b = 0; b < 3; b++){
		if(a[b] == a[b + 1]){
			c++;
		}
	}
	
	if(c == 0){
		printf("Good");
	}else{
		printf("Bad");
	}
	
	return 0;
}

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

number = ['1','2','3','4','5','6','7','8','9','0']
hyphen = '-'

for i in range(len(s)):
    if i < a:
        if not s[i:i+1] in number:
            print('No')
            break
    elif i == a:
        if s[i:i+1] != hyphen:
            print('No')
            break
    else:
        if not s[i:i+1] in number:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 3064
import collections
n = int(input())
v = list(int(i) for i in input().split())

a = v[:n:2]
b = v[1:n:2]
c = collections.Counter(a)
d = collections.Counter(b)

if len(c) ==1 and len(d) == 1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        print(n//2)

if len(c) ==1 and len(d) !=1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[1][1])

if len(d) ==1 and len(c) !=1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        print(n-c.most_common()[1][1]-d.most_common()[0][1])

if len(c) != 1 and len(d) != 1:
    if c.most_common()[0][0] != d.most_common()[0][0]:
        print(n-c.most_common()[0][1]-d.most_common()[0][1])
    if c.most_common()[0][0] == d.most_common()[0][0]:
        if (c.most_common()[0][1]+d.most_common()[1][1]) >= (c.most_common()[1][1]+d.most_common()[0][1]):
            print(n-c.most_common()[0][1]-d.most_common()[1][1])
        else:
            print(n-c.most_common()[1][1]-d.most_common()[0][1])


Measured memory_bytes: 19040
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");
    let takahashiHP = Math.ceil(Number(tmp[0])/Number(tmp[3]))
    let aokiHP = Math.ceil(Number(tmp[2])/Number(tmp[1]))
  	if(takahashiHP >= aokiHP) return console.log('Yes')
    else return console.log('No')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29624
n, a, b, c = gets.split.map(&:to_i)
nums = [a, b, c]
alphabets = ["A", "B", "C"]
queries = []
n.times do
  first, second = gets.chomp.split("")
  queries << [alphabets.find_index(first), alphabets.find_index(second)]
end
ans = []
queries.each_with_index do |(first, second), index|
  if nums[first] > nums[second]
    nums[first] -= 1
    nums[second] += 1
    ans << second
  elsif nums[first] < nums[second]
    nums[first] += 1
    nums[second] -= 1
    ans << first
  else
    if index < n - 1 && queries[index + 1].include?(first)
      nums[first] += 1
      nums[second] -= 1
      ans << first
    else
      nums[first] -= 1
      nums[second] += 1
      ans << second
    end
  end
  if nums.any? { |num| num < 0 }
    puts "No"
    exit
  end
end
puts "Yes"
ans.each do |a|
  puts alphabets[a]
end


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

int main()
{
    string s;
    cin >> s;
    string k;
    string l;
    for( int i = 0; i < int((s.size()-1)/2); i++ )
    {
        k.push_back(s.at(i));
    }
    for( int i = int((s.size()+3)/2)-1; i < s.size(); i++ )
    {
        l.push_back(s.at(i));
    }
    if( k == l )
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint N, A, B;
    cin >> N >> A >> B;
    lint b = N / (A + B) * A + min(N % (A + B), A);
    cout << b << endl;
    return 0;
};

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */


int main(){
    lint n, h; cin>>n>>h;
    vector<lint> vec; lint max_a = 0;
    rep(i, n){
        int a, b; cin >> a >> b; vec.push_back(b);
        if(a > max_a) max_a = a;
    }
    vector<lint> ved;
    rep(i, n){
        if(vec[i] >= max_a) ved.push_back(vec[i]);
    }
    sort(all(ved), greater<lint>());
    int v_max = ved.size();    
    rep(i, v_max-1){
        ved[i+1] += ved[i];
    }

    lint s = 0, t = 1e9;
    while(t - s > 1){
        lint mid = (s + t) / 2;
        lint x = 0;
        if(mid <= v_max) x = ved[mid-1];
        else x = ved[v_max-1] + max_a * (mid - v_max);

        if(x >= h) t = mid;
        else s = mid;
    }
    out(t);
}



Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int N, M; cin >> N >> M;
    int P[100001], Y[100001];
    rep(i, M) cin >> P[i] >> Y[i];

    vector<int> x[100001];
    rep(i, M) x[P[i]].push_back(Y[i]);
    rep(i, N) sort(x[i+1].begin(), x[i+1].end());
    //rep(i, N) sort(x[i+1].begin(), x[i+1].end());
     

    rep(i, M){
      // cout << P[i]  << " ";
        printf("%06d", P[i]);
        printf("%06d\n", int(lower_bound(x[P[i]].begin(), x[P[i]].end(), Y[i]) - x[P[i]].begin()) + 1);

    }
    

    return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

long modpow(long a, long b){
    
    if(b == 0){
        return 1;
    } else if(a == 1){
        return 1;
    } else if(b == 1){
        return a;
    } else if(b % 2 > 0){
        return a * modpow(a, b - 1) % mod;
    } else {
        return modpow(a * a % mod, b / 2);
    }
}

int main(){
    
    long n, k, ans = 0;
    cin >> n >> k;
    
    vector<long> v(k+1, 0);
    
    for(long i = k; i > 0; i--){
        v[i] = modpow((k / i), n);
        
        for(long j = 2; j <= k / i; j++){
            v[i] -= v[j * i];
            if(v[i] < 0) v[i] += mod;
        }
    }
        
    for(long i = 1; i <= k; i++){
        ans += i * v[i] % mod;
        ans %= mod;
    }
    
    cout << ans << "\n";
    
    return 0;
}



Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std ;
 
int main() {
  int X ; 
  cin >> X ; 
  int ans = 0 ; 
  
  for(int i = 1 ; i <= X ;i++){
    for(int j = 2 ; j <= 100 ; j++){
      int P = pow(i , j) ; 
      if(P <= X){
        ans = max(P , ans) ; 
      }
    }
  }
  cout << ans << endl ; 
}

Measured memory_bytes: 4172
#include <string>
#include <iostream>
#include <map>
using namespace std;
int main(){
 string s; cin >> s;
  int x=0,y=0;
  map<char,bool> chk;
  for(int i=0;i<s.length();i++){
   /*if(s[i]=='N') y++; 
   if(s[i]=='S') y--;
   if(s[i]=='W') x--;
   if(s[i]=='E') x++;*/
    chk[s[i]]=true;
  }
  string ans;
  if(chk['N']^chk['S'] || chk['W']^chk['E']) ans="No";
  else ans="Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,y;
	cin >> n >> y;
	y /= 1000;
	int flag = 0;
	ll a,b,c;
	for(ll i = 0; i <= 2000; i++) {
		for(ll j = 0; j <= 2000; j++) {
			if(9 * i + 4 * j == y - n){
				flag = 1;
				a = i;
				b = j;
				break;
			}
		}
	}
	if (flag == 1){
		c = n - a - b;
		if (a + b + c == n && c >= 0){
			cout << a << " " << b << " " << c << endl;
		}
		else{
			cout <<"-1 -1 -1"<< endl;
		}
	}
	else{
		cout <<"-1 -1 -1"<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int n;
    long long sum;
    char str1[60]={};
    char str2[60]={};
    int i;
    int flage=0;
    while (cin>>n)
    {
        cin>>str1;
        cin>>str2;
        sum=1;
        flage=0;
        for (i=0;i<n;i++)
        {
            if (str1[i]==str2[i])
            {
                if (i==0)
                {
                    sum=3;
                }
                else
                {
                    if (flage==0)
                        sum*=2;
                }
                sum%=1000000007;
                flage=0;
            }
            else
            {
                if (i==0)
                {
                    sum=6;
                }
                else
                {
                    if (flage==1)
                        sum*=3;
                    else
                        sum*=2;
                }
                sum%=1000000007;
                flage=1;
                i++;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 505
using namespace std;

int n, m, q, s, a[N][N];
int main()
{
	int i, j, t1, t2;
	cin >> n >> m >> q;
	while (m--) {
		scanf("%d %d", &t1, &t2);
		a[t1][t2]++;
	}
	for (i = 1; i <= n; i++) for (j = i; j <= n; j++) a[i][j] += a[i][j - 1];
	while (q--) {
		scanf("%d %d", &t1, &t2);
		s = 0;
		for (i = t1; i <= t2; i++) s += a[i][t2];
		printf("%d\n", s);
	}
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define fi first
#define er erase
#define in insert
#define se second
#define pp pop_back
#define pb push_back
#define mp make_pair
#define ll long long
#define vec vector<int>
#define pii pair<int,int>
#define smin(a,b) (a=min(a,b))
#define smax(a,b) (a=max(a,b))
#define fl(a,x) memset(a,x,sizeof a)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define cs ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int mx=2e5+10;
int main(){
    cs;
    string s;cin>>s;
    for(int i=0;i<s.size();i++)
        if(s[i]==',') cout<<' ';
        else cout<<s[i];

}


Measured memory_bytes: 256
/*
 * 16-7-23_ABC042_D.cpp
 *
 *  Created on: 2016/07/23
 *      Author: ryoma
 */

#include <iostream>

using namespace std;

typedef long long ll;
int H,W,A,B;
ll ans;
const ll MOD = 1000000007;
ll memo[200010];

ll mod_pow(ll x, ll n,ll mod){
	if (n==0)
		return 1;
	ll res = mod_pow(x*x % mod,n/2,mod);
	if(n&1)
		res = res * x % mod;
	return res;
}

ll mod_fact(ll x,ll mod){
	if (x == 0)
		return 1;
	if (memo[x] != 0)
		return memo[x] -1;
	memo[x] = (x*mod_fact(x-1,mod) % mod) + 1;
	return memo[x]-1;
}

ll mod_comb(ll a,ll b,ll mod){
	ll res;
	res = mod_fact(a+b,mod);
	res = res * mod_pow(mod_fact(a,mod),mod-2,mod) % mod;
	res = res * mod_pow(mod_fact(b,mod),mod-2,mod) % mod;
	return res;
}

int main(){
	cin >> H >> W >> A >> B;
	int h=H-A,w=B+1;
	while(h > 0 && w <= W){
		ll a = mod_comb(h-1,w-1,MOD)*mod_comb(H-h,W-w,MOD)%MOD;
		ans = (ans+a) % MOD;
		h--;
		w++;
	}
	//cout << mod_pow(2,MOD-2,MOD)<<endl;
	//cout << mod_fact(4,MOD)<<endl;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    int n,m;
    cin >> n >> m;
    vector<ll> X[3];
    for(int i = 0;i < n;i++){
        ll x,y,z;
        cin >> x >> y >> z;
        X[0].push_back(x);
        X[1].push_back(y);
        X[2].push_back(z);
    }
    ll ans = 0;
    for(int bit = 0;bit < (1<<3);bit++){
        vector<ll> b;
        for(int i = 0;i < n;i++){
            ll tmp = 0;
            for(int j = 0;j < 3;j++){
                if(bit & (1<<j)) tmp += X[j][i];
                else tmp -= X[j][i];
            }
            b.push_back(tmp);
        }
        sort(b.rbegin(),b.rend());
        ll sum = 0;
        for(int k = 0;k < m;k++) sum += b[k];
        ans = max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
from itertools import combinations
n,d=map(int,input().split())
l= [np.array(input().split() ,dtype=np.int64) for _ in range(n)]
ans=0
dist=0
for a,b in combinations(l,2):
    dist=((a-b)**2).sum()
    for j in range(dist+1):
        if  j**2 == dist:
            ans+=1
            continue
print(ans)

Measured memory_bytes: 27236
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()

cnt = 0
for i in range(min(A, B), 0, -1):
	if A%i == 0 and B%i == 0:
		cnt += 1
		if cnt == K:
			print(i)
			exit()

Measured memory_bytes: 5200