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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int cnt = 0;
    rep(i, n) if (~i & 1 && a[i] & 1) cnt++;

    cout << cnt;

    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int mod = 1000000007;

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

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
void ini_func(vector<ll>& a, vector<ll>& b,ll N) {
	ll k, c;
	for (ll i = 0; i < N; i++) {
		cin >> k >> c;
		a.push_back(k);
		b.push_back(c);
	}


}

int main() {
	ll A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1;

}

Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;
const ll limit = 1e18;

int main()
{
  int n;
  cin >> n;
  vl a(n, 0);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 <<endl;
      return 0;
    }
  }
  ll result = 1;
  rep(i, n) {
    if (result <= limit / a[i]) {
      result *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int h,w;
    cin>>h>>w;
    char maze[h][w];
    rep(i,h){
        rep(j,w){
            cin>>maze[i][j];
        }
    }

    

    int d[h][w];

    rep(i,h){
        rep(j,w){
            d[i][j]=0;
        }
    }
    


    
    rep(i,h){
        rep(j,w){
            if(i==0 && j==0){
                if(maze[0][0]=='.') d[0][0]=0;
                else d[0][0]=1;
            }
            else if(i==0){
                if(maze[i][j]=='.') d[i][j]=d[i][j-1];
                else if(maze[i][j-1]=='.') d[i][j]=d[i][j-1]+1;
                else if(maze[i][j-1]=='#') d[i][j]=d[i][j-1];
            }
            else if(j==0){
                if(maze[i][j]=='.') d[i][j]=d[i-1][j];
                else if(maze[i-1][j]=='.') d[i][j]=d[i-1][j]+1;
                else if(maze[i-1][j]=='#') d[i][j]=d[i-1][j];
            }
            else{
                if(maze[i][j]=='.') d[i][j]=min(d[i-1][j],d[i][j-1]);
                else if(maze[i-1][j]=='.' && maze[i][j-1]=='.') d[i][j]=min(d[i-1][j],d[i][j-1])+1;
                else if(maze[i-1][j]=='#' && maze[i][j-1]=='#') d[i][j]=min(d[i-1][j],d[i][j-1]);
                else if(maze[i-1][j]=='.' && maze[i][j-1]=='#') d[i][j]=min(d[i-1][j]+1,d[i][j-1]);
                else if(maze[i-1][j]=='#' && maze[i][j-1]=='.') d[i][j]=min(d[i-1][j],d[i][j-1]+1);
            }
        }
    }

    cout<<d[h-1][w-1]<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  double w,h,x,y;cin>>w>>h>>x>>y;
  cout<<h*w/2<<" ";
  if(x==w/2&&y==h/2)cout<<1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second



int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    cin >> n >> m ;
    cout << n *m ;
    return 0;
}

Measured memory_bytes: 3648
/************************************************************
	> File Name: c.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 31 May 2020 08:06:49 PM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define int unsigned long long
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
signed main(void){
	ld a, b;
	cin >> a >> b;
	int ans = a * b;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

vector<int> P = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443};

class Box
{
    public:
    int number;
    int number_of_balls;
    vector<int> divs;
};

void Div(int N, Box boxes[])
{
    for(int i=0;i<N;i++)
    {
        for(int j=i;j<N;j+=(i+1))
        {
            boxes[j].divs.push_back(i);
        }
    }
}

void BallCounter(int N, Box boxes[], vector<int>& ballCounter)
{
    for(int i=N-1;i>=0;i--)
    {
        if(boxes[i].number_of_balls==1)
        {
            ballCounter[i]=1;
            for(auto x : boxes[i].divs)
            {
                boxes[x].number_of_balls++;
                boxes[x].number_of_balls%=2;
            }
        }
    }
}

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

    Box boxes[N];
    for(int i=0;i<N;i++)
    {
        boxes[i].number = i+1;
        cin >> boxes[i].number_of_balls;
    }

    Div(N,boxes);

    vector<int> ballCounter(N,0);

    BallCounter(N,boxes,ballCounter);

    vector<int> ans;

    for(int i=0;i<N;i++)
    {
        if(ballCounter[i]==1)
        ans.push_back(i+1);
    }

    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++)
    {
        cout << ans[i];
        if(i!=ans.size()-1)
        {
            cout << ' ';
        }
    }
    if(ans.size()!=0)
    cout << endl;

    return 0;
}

Measured memory_bytes: 25084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll calc(ll t1, ll t2, ll a1, ll a2){
    if (a1 > 0 && a2 > 0) return 0;
    if (a1 < 0 && a2 < 0) return 0;
    ll d1 = t1 * a1, d2 = t2 * a2;
    if (d1 + d2 > 0 && d1 > 0) return 0;
    if (d1 + d2 < 0 && d1 < 0) return 0;
    if (d1 + d2 < 0){
        d1 *= -1;
        d2 *= -1;
    }
    ll x = (-d1) / (d1 + d2);
    ll ret = 2 * x;
    if (x * (d1 + d2) != -d1) ret++;
    return ret;
}

int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2){
        cout << "infinity" << endl;
        return 0;
    }
    a1 -= b1;
    a2 -= b2;
    ll ans = calc(t1, t2, a1, a2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean rate[] = new boolean[8];
    int istack;
    int count = 0;
    int free = 0;
    
    Arrays.fill(rate,false);
    
    for(int i = 0;i < n;i++){
    	istack = sc.nextInt();
      	istack /= 400;
      	if(istack > 7) free++;
      	else rate[istack] = true;
    }
    
    for(int i = 0;i < 8; i++){
    	if(rate[i]) count++;
    }
    
    if(count == 0){
    	count = 1;
      	free--;
    }
    
    System.out.println(count + " " + (count+free));
  }
}


Measured memory_bytes: 38580
#include <iostream>
using namespace std;
int main(){
	int n, m;
	int k[10], s[10][10], p[10];
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> k[i];
		for(int j = 0;j < k[i];j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0;i < m;i++){
		cin >> p[i];
	}
	int count;
	int count2 = 0;
	for(int i = 0;i < (1 << n);i++){
		for(int j = 0;j < m;j++){
			count = 0;
			for(int w = 0;w < k[j];w++){
				if((i >> (s[j][w] - 1)) % 2){
					count++;
				}
			}
			if((count - p[j]) % 2){
				break;
			}
			if(j == (m - 1)){
				count2++;
			}
		}
	}
	cout << count2 << endl;
}

Measured memory_bytes: 256
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end

N = gi
S = gs
NO = 'No'
YES = 'Yes'

if N.even?
  puts S[0...(N / 2)] == S[(N / 2)..-1] ? YES : NO
else
  puts NO
end


Measured memory_bytes: 1788
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

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

class P{
public:
	int b,h,cost; //rÌÇÁ¿É¢é©,rÌK,Wvñ

	P(int _b,int _h,int _cost){
		b = _b;
		h = _h;
		cost = _cost;
	}
};

int n;
int b[2][101];
bool closed[2][101];

int solve(void){
	queue<P> q;
	memset(closed,0,sizeof(closed));
	q.push(P(0,0,0));
	q.push(P(1,0,0));

	while(!q.empty()){
		P p = q.front(); q.pop();
		if(b[p.b][p.h] == 1){ //Íµ²
			while(p.h<n && b[p.b][p.h]==1) p.h++;
			p.h--;
		}
		else if(b[p.b][p.h] == 2){ //·×éÇ
			while(b[p.b][p.h]==2) p.h--;
		}

		if(closed[p.b][p.h]) continue;
		closed[p.b][p.h] = true;

		if(p.h == n-1) return p.cost;

		rep(i,3) if(n > p.h + i) {
			q.push(P(!p.b,p.h+i,p.cost+1));
		}
	}

	return -1;
}

int main(void){
	while(cin>>n,n){
		rep(i,2) rep(j,n) cin>>b[i][j];

		int cal = solve();
		if(cal == -1) cout<<"NA\n";
		else cout<<cal<<endl;
	}

	return 0;
}

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

using namespace std;

int a,b,c;

int main() {
	scanf("%d %d %d",&a,&b,&c);
	if(a==b && c!=a || a==c && b!=a || b==c && a!=b) puts("Yes");
	else puts("No");
	return 0;
} 

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

#define mx 1000000009
int main()
{


  ll n,W;
  cin>>n;
  cin>>W;
  ll v[n+1],w[n+1];
  ll sum=0;

  for(ll i=1;i<=n;i++)
    cin>>w[i]>>v[i];

  for(ll i=1;i<=n;i++)
    sum+=v[i];


  ll dp[sum+1];

  for(ll i=1;i<=sum;i++)
    dp[i]=mx;

  dp[0]=0;

//   cout<<sum<<endl;
  for(ll i=1;i<=n;i++)
  {

    
    for(ll j=sum;j>=v[i];j--)
    {
         
         dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }


  }

 for(ll j=sum;j>=0;j--)
 {
    //  cout<<dp[j]<<" ";
 if(dp[j]<=W)
  {
    cout<<j;
    break;
  }
 }
}



Measured memory_bytes: 4388
#include <stdio.h>

int main (){
  int x,y;

  for(;;){
    scanf("%d %d",&x,&y);
    if((x == 0) && (y ==0)) break;
    if(x>y) printf("%d %d\n",y,x);
    else printf("%d %d\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  YesNo(N==M);
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	int n,t;
	cin>>n>>t;
	ll *ss = new ll[n+2];
	ll s=0;
	for(int i=0;i<=n;i++){
		s+=i;
		ss[i] = s;
	}
	ll count = 0;
	for(int i=t;i<n+1;i++){
		count = (count%mod + ((ss[n] - ss[n-i]) - ss[i-1] + 1)%mod)%mod;
	}
	cout<<count+1;
	return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
ifstream f("A.in");
ofstream g("A.out");
typedef long long ll;
typedef pair<int,int> pi;
int t,T;
const ll Mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector < ll > V(n+1),pf(n+1,0);
    for(int i=1;i<=n;i++)
    {
        cin>>V[i];
        pf[i]=(pf[i-1]+V[i])%Mod;
        if(pf[i]<0) pf[i]+=Mod;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans + ( V[i]*(pf[n]-pf[i]) )%Mod )%Mod;
        if(ans<0) ans+=Mod;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}


void warshall_floyed(v(v(ll)) &C,int V) {
  rep(k,V) {
    rep(i,V) {
      rep(j,V) {
        if(C[i][j] > C[i][k] + C[k][j]) {
          C[i][j] = C[i][k] + C[k][j];
        }
      }
    }
  }
}

int main() {
  int N,M,L;
  cin >> N >> M >> L;
  v(v(ll)) C(N,v(ll)(N,LINF));
  vvi nex(N,vi(N));
  rep(i,M) {
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    if(c > L) continue;
    C[a][b] = c;
    C[b][a] = c;
    nex[a][b] = b;
    nex[b][a] = a;
  }
  rep(i,N) {
    C[i][i] = 0;
    nex[i][i] = i;
  }
  warshall_floyed(C,N);
  v(v(ll)) A(N,v(ll)(N,LINF));
  rep(i,N) {
    rep(j,N) {
      if(C[i][j] <= L && i != j) {
        A[i][j] = 1;
      }
    }
  }
  warshall_floyed(A,N);
  int q;
  cin >> q;
  vi ans(q);
  rep(i,q) {
    int s,t;
    cin >> s >> t;
    s--;
    t--;
    if(C[s][t] == LINF) {
      ans[i] = -1;
    } else {
      ans[i] = A[s][t] - 1;
    }
  }
  rep(i,q) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
/*
int main(){
  int n;
  scanf("%d",&n);
  char a,b;
  scanf("%c",&a);
  for(int i=0;i<n-1;i++){
    scanf("%c",&b);
     printf("%c\n",b);
    if(a == 'T' && b == 'F')a = 'F';
    else a = 'T';
    printf("%c\n",b);
  }
  printf("\n%c\n",a);
  return 0;
  */
int main(){
  int n;
  char a,b;
  scanf("%d\n",&n);
  scanf("%c",&a);
  for(int i=0;i<n-1;i++){
    scanf(" %c",&b);
    //  printf("%d %c\n",i,b);
    if(a == 'T' && b == 'F'){
      a = 'F';
    }else{
      a = 'T';
    }
  }
  printf("%c\n",a);
  return 0;
}



Measured memory_bytes: 3224
S = str(input())
new_S = ''.join(list(reversed(S)))
N = len(S)
def check(n,r,s):
    for _ in range(int((r-n)/2 + 1)):
        S = list(s)
        if S[n] != S[r]:
            return("No")
        else:
            n += 1
            r -= 1
    return("Yes")
ans = 0
if S == new_S:
    ans += 1
if check(0,int((N-1)/2)-1,S) == "Yes":
    ans += 1
if check(int((N+3)/2)-1,N-1,S) == "Yes":
    ans += 1
if ans == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  int n, a[100000], cnt[100001]={0}, ans=0;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]>=100001){
      ans++;
    } else {
      cnt[a[i]]++;
    }
  }

  for(int i=0; i<100000; i++){
    if(cnt[i]<i){
      ans+=cnt[i];
    } else if(cnt[i]>i){
      int s=cnt[i]-i;
      ans+=s;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#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 int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int arr[n],ans = 0,pre=0;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
		if(i > 0 and pre > arr[i])
			ans += pre-arr[i];
		pre = max(pre,arr[i]);
	}	
	cout << ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 5212
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

    ll res = 0;

    ll l0 = 2;
    ll l1 = 1;

    for (int i = 0; i < n - 1; i++)
    {
        ll tmp = l0 + l1;

        l0 = l1;
        l1 = tmp;
    }

    cout << l1 << endl;

    return 0;
}


Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::vector<i64> a(3);
    for (i64& x: a) std::cin >> x;
    i64 sum = std::accumulate(ALL(a), 0ll);

    if (sum%2) {
        std::cout << 0 << '\n';
        return 0;
    }

    i64 g = 0;
    for (i64 x: a) {
        x = 3*x - sum;
        g = std::__gcd(x, g);
    }
    i64 ans = g==0 ? -1 : __builtin_ctzll(g);
    std::cout << ans << '\n';
}



Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{

    class ProgramC
    {

        static int[] a = new int[50];
        static int[] b = new int[50];
        static int[] c = new int[50];
        static int[] d = new int[50];
        static List<int> ans = new List<int>();
        static int n;
        static int m;
        static int q;

        static void Main(string[] args)
        {
            string[] z = Console.ReadLine().Split(' ');
            n = int.Parse(z[0]);
            m = int.Parse(z[1]);
            q = int.Parse(z[2]);



            for (int i = 0; i < q; i++)
            {
                string[] y = Console.ReadLine().Split(' ');
                a[i] = int.Parse(y[0]);
                b[i] = int.Parse(y[1]);
                c[i] = int.Parse(y[2]);
                d[i] = int.Parse(y[3]);

            }

            //DFS
            dfs("", 1);

            Console.WriteLine(ans.Max());



        }

        static void dfs(string s, int f)
        {
            if (s.Length == n)
            {
                int count = 0;
                for (int i = 0; i < q; i++)
                {
                    int bi = s[b[i] - 1] - '0';
                    int ai = s[a[i] - 1] - '0';
                    if (bi == 0)
                        bi = 10;
                    if (ai == 0)
                        ai = 10;
                    if (bi - ai == c[i])
                        count += d[i];

                }

                ans.Add(count);


            }
            else
            {
                for (int c = f; c <= m; c++)
                {

                    if (c == 10)
                        dfs(s + '0',10);
                    else
                        dfs(s + c, c);
                }
            }
        }
    }



}


Measured memory_bytes: 37000
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int a, b;
    bool n = false;
    while(cin >> a >> b, b){
        bool leap = true;
        range(i,a,b + 1){
            if(i == a && n) cout << endl;
            if(i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)){
                cout << i << endl;
                leap = false;
            }
            n = true;
        }
        if(leap)
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	int ans = 0;
	for (int i = 0; i < S.length() / 2; ++i) {
		if (S[i] != S[S.length() - i - 1]) ans += 1;
	}

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


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define UB upper_bound
#define LB lower_bound;

using namespace std;

typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;

int a[500];

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	string s;
	cin >> s;
	
	for(int i = 0 ; i < s.size() ; i++)
	   a[s[i]]++;
	
	if(!((a['W'] > 0) ^ (a['E'] > 0)) && !((a['N'] > 0) ^ (a['S'] > 0)))
	   cout << "Yes" << endl;
	else
	   cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	string S;
	cin >> S;
	if (((S[0]==S[1]&&
		S[2]==S[3])&&S[0]!=S[2])||
		((S[0] == S[2] &&
		S[1] == S[3])&&S[0]!=S[1]) || 
		((S[0] == S[3] &&
		S[1] == S[2]))&&S[0]!=S[1]) {
		cout <<"Yes"<<endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N,Q; cin >> N >> Q;
    long long wei[200020];
    fill(wei,wei+200002,0);
    int a,b;
    vector<pair<int,int> > vp;
    for (int i = 1; i < N; i++){
        cin >> a >> b;
        vp.push_back({a,b});
    }
    sort(vp.begin(),vp.end());
    long long ans = 0;
    for (int i = 1; i <= Q; i++){
        int p,x; cin >> p >> x;
        wei[p] += x;
    }
    cout << wei[1] << " ";
    for (int i = 0; i < N; i++){
        int tmp = vp[i].first;
        wei[vp[i].second] += wei[tmp];
    }
    for(int i = 2; i <= N; i++){
        cout << wei[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5616
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    char ch;
    while ((ch = getchar()) != EOF) {
        if (97 <= ch && ch <= 122) {
            printf("%c", ch - 32);
        } else if (65 <= ch && ch <= 90) {
            printf("%c", ch + 32);
        } else {
            printf("%c", ch);
        }
    }
}


Measured memory_bytes: 2960
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
	string s;
	int sum=700;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='o'){
			sum+=100;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//agc029_a
//BW→ WBに変換
//Wの移動量の総数でよさそう
int main(){
  string S;
  cin >> S;

  //最初にでてきてWは0に移動
  //次は1に移動
  ll cnt = 0;
  ll res = 0;

  REP(i,S.size())
  {
    if(S[i] == 'W')
    {
      res += i - cnt;
      ++cnt;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    [[maybe_unused]] long long int n,m,i=0,j,c=0,h[200010],a[200010],ans=0,saisyo=99999999,saidai=0;
    cin >> n;
    for(i=1;i<n;i++)
    {
        h[i]=0;
    }
    for(i=1;i<n;i++)
    {
        cin >> a[i];
        h[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        cout << h[i] << endl;
    }
    
    return 0;

}


Measured memory_bytes: 6656
n,m = map(int, input().split())
py = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    data = (y, i) # year, origIndx
    py[p-1].append(data)

    
xx = [[] for _ in range(m)]
for ken in range(0, n):
    py[ken].sort(key=lambda x: x[0])
    for i in range(len(py[ken])):
        x = py[ken][i]
        xx[x[1]] = "%s%s" % (str(ken+1).zfill(6), str(i+1).zfill(6))
print("\n".join(xx), end="")



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

int main () {
  int n;
  cin >> n;
  
  int a[n], count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n-1; i++) {
    if (max(a[i],min(a[i-1],a[i+1])) == min(a[i],max(a[i-1],a[i+1]))) {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  int a,b,c;cin>>a>>b>>c;
  map<int,int>mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  if(mp[5]==2 && mp[7]==1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#import time
#t1=time.time()
s=input()
q=int(input())
trans=0
head=''
#t2=time.time()
for i in range(q):
  query = input().split()
  if query[0]=='1':
    trans += 1
  elif (int(query[1]) & 1) ^ (trans & 1):
    head += query[2]
  else:
    s += query[2]
res = ''
#t3=time.time()
if trans % 2 == 0:
  res = ''.join([head[len(head)-i-1] for i in range(len(head))]) + s
else:
  res = ''.join([s[len(s)-i-1] for i in range(len(s))]) + head
print(res)
#t4=time.time()
#print(int((t2-t1)*1000),int((t3-t2)*1000),int((t4-t3)*1000),int((t4-t1)*1000))

Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    
    vector<ll> a;
    rep(i, 9) a.push_back(i+1);
    while(true) {
        if(k <= a.size()) {
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(a,old);
        for (ll x: old) {
            for(int i = -1; i <= 1; i++) {
                int d = x%10+i;
                if(d < 0 || d > 9) continue;
                a.push_back(x*10 + d);
                if(k == a.size()) {
                    cout << a[a.size()-1] << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 1072
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
int n;
long double dp[3001][3001],ans=0;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    dp[0][0] = 1.0;
    for(int i=1; i<=n; i++){
        long double p;
        cin >> p;
        dp[i][0] = dp[i - 1][0] * (1.0 - p);
        for(int j=0; j<i; j++)
            dp[i][j + 1] += dp[i - 1][j] * p + (1.0 - p) * dp[i - 1][j + 1];
    }
    
    for(int i=n/2+1; i<=n; i++)
        ans += dp[n][i];
        cout.precision(30);
    cout << ans << '\n';
    
    
    
    
    return 0;
}


Measured memory_bytes: 139264
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
    string S;cin>>S;
    int dp[S.size()][2];
    dp[0][0] = S[0] - '0';
    dp[0][1] = S[0] - '1';
    for(int i=1;i<S.size();++i){
        dp[i][0] = dp[i-1][0] + S[i] - '0';
        dp[i][1] = max(dp[i-1][1] + 9, dp[i-1][0] + (S[i] - '1'));
    }
    cout<<max(dp[S.size()-1][0], dp[S.size()-1][1])<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_6_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();
            int i = Partition(line, 0, line.Length - 1);

            Console.WriteLine(String.Join(" ",line.Select((x,index) => (index == i) ? "[" + x.ToString() + "]" : x.ToString()).ToArray()));
        }

        /// <summary>
        /// パーティション
        /// -配列をr番目の値より小さいグループと大きいグループに分割する
        /// </summary>
        /// <param name="array">対象配列</param>
        /// <param name="p">開始インデックス</param>
        /// <param name="r">基準インデックス</param>
        /// <returns>分割後の基準インデックスの位置</returns>
        public static int Partition(int[] array,int p,int r)
        {
            int x = array[r];
            int i = p - 1;
            for (int j = p ; j < r ; j++)
            {
                if (array[j] <= x)
                {
                    i++;
                    Swap(ref array[i], ref array[j]);
                }
            }
            Swap(ref array[i+1], ref array[r]);
            return i + 1;
        }
        private static void Swap<T>(ref T v1, ref T v2) { var tmp = v1; v1 = v2; v2 = tmp; }



        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 30032
let [| N; K |] = stdin.ReadLine().Split() |> Array.map int64

let MOD = 1000000007L

let modsub (x : int64) (y : int64) = (x + MOD - y) % MOD

let modmul (x : int64) (y : int64) = ((x % MOD) * (y % MOD)) % MOD

let modpow2 (x : int64) = x * x

let rec modpow (x : int64) (y : int64) =
    if y = 0L then 1L
    elif y = 1L then x % MOD
    elif y % 2L = 0L then modpow2 (modpow x (y / 2L)) % MOD
    else modmul x (modpow2 (modpow x (y / 2L))) % MOD

let p = Array.zeroCreate<int64> (int K)

for i in [ int K..(-1)..1 ] do
    p.[i - 1] <- modpow (K / (int64 i)) N
    for j in [ 2 * i..i..int K ] do
        p.[i - 1] <- modsub p.[i - 1] p.[j - 1]

p
|> Array.mapi (fun i x -> modmul (int64 (i + 1)) x)
|> Array.sum
|> fun x -> x % MOD
|> stdout.WriteLine


Measured memory_bytes: 43012
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const int infi = 2147483647;
const ll infl = 1e17;


int main()
{
    ll h, w, K;
    cin >> h >> w >> K;
    vvll dp(h + 1, vll(w, 0));
    dp[0][0] = 1;
    vvll touri(9, vll(2,0));
    touri[0][0] = 1;
    rep(i,8){
        touri[i + 1][0] = (touri[i][0] + touri[i][1]) % mod;
        touri[i + 1][1] = (touri[i][0]);
    }
    rep(k,h){
        rep(i,w){
            if (i>0)
            {dp[k + 1][i - 1] = (dp[k + 1][i - 1]+
            (dp[k][i] * (touri[i - 1][0]*touri[w-1-i][0]%mod))
            )% mod;}
            dp[k+1][i]=(
                dp[k+1][i]+
                (dp[k][i]*(touri[i][0]*touri[w-1-i][0])%mod)%mod
            )%mod;
            if(i<w-1)
            {dp[k + 1][i + 1] = (dp[k + 1][i + 1] +
                                (dp[k][i] * (touri[i][0] * touri[w - 2 - i][0]) % mod) % mod) %
                               mod;}
        }
    }
    cout << dp[h][K - 1] << endl;
}


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

string s;

int main(void){
	cin >> s;
	unordered_map<char, bool> mp;
	rep(i, s.size()){
		mp[s[i]]=true;
	}
	if(mp['N']^mp['S'] != 0) cout << "No" << endl;
	else if(mp['W']^mp['E'] != 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    sc.next();
    Set<String> set = new HashSet<>();
    while (sc.hasNext()) {
      if (!set.add(sc.next())) {
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
  }
}

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

long N, K, R, S, P;
string T;

long point(char c) {
    if (c == 'r') {
        return P;
    }
    if (c == 's') {
        return R;
    }
    if (c == 'p') {
        return S;
    }
    return 0;
}

int main()
{
    cin >> N >> K >> R >> S >> P >> T;
    long ans = 0;

    for (long i = 0; i < K; i++) {
        ans += point(T[i]);
        int flag = true;
        for (long j = i + K; j < N; j = j + K) {
            if (flag == false) {
                flag = true;
                ans += point(T[j]);
                continue;
            }

            if (T[j - K] == T[j]) {
                flag = false;
            }
            else {
                flag = true;
                ans += point(T[j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ans=1,ans_num=a[0],sum=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]==ans_num)
            ans++;
        else
        {
            if(ans>=ans_num)
                sum+=ans-ans_num;
            else
                sum+=ans;
            ans_num=a[i];
            ans=1;
        }
    }
    if(ans>=ans_num)
        sum+=ans-ans_num;
    else
        sum+=ans;
    cout<<sum<<endl;
    return 0;
}
/*
4 8

*/


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

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

	size_t s_len = s.length();
	vector<char> s1;

	for (size_t i = 0; i < s_len; ++i) {
		s1.push_back(s[i]);
	}

	for (size_t i = 0; i < s_len / 2; ++i) {
		if (s1[i] != s1[s_len - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	size_t cond2 = (s_len - 1) / 2;
	for (size_t i = 0; i < cond2 / 2; ++i) {
		if (s1[i] != s1[cond2 - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	for (size_t i = (s_len + 3) / 2; i < s_len; ++i) {
		if (s1[i] != s1[s_len - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    int ans = 0;
    while(x <= y){
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
ans = 0
tail_a_cnt = 0
top_b_cnt = 0
top_b_tail_a = 0
for i in range(n):
    s = list(input())
    top_b = False
    tail_a = False
    
    for c in range(len(s)):
        if c == 0:
            if s[c] == 'B':
                top_b = True
        else:
            if s[c] == 'B' and s[c-1] == 'A':
                ans += 1
        
        if c == len(s)-1 and s[c]=='A':
            tail_a = True
            
    top_b_cnt += top_b
    tail_a_cnt += tail_a
    top_b_tail_a += top_b*tail_a
     
ans += min(top_b_cnt, tail_a_cnt)
if top_b_cnt == tail_a_cnt == top_b_tail_a and top_b_cnt>0:
    ans -= 1
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

vector<string> memo;

void dfs(string s, bool y){
  if(s.length()==10){
    memo.push_back(s);
  }
  else{
    if(s[s.length()-1]=='0'){
      if(!y){
        dfs(s+'0',false);
        for(char c='1';c<='9';c++) dfs(s+c,true);
      }
      else{
        dfs(s+'0',true);
        dfs(s+'1',true);
      }
    }
    else if(s[s.length()-1]=='9'){
      dfs(s+'8',true);
      dfs(s+'9',true);
    }
    else{
      dfs(s+(char)(s[s.length()-1]-1),true);
      dfs(s+s[s.length()-1],true);
      dfs(s+(char)(s[s.length()-1]+1),true);
    }
  }
  return;
}

int main() {
  int k;
  cin>>k;
  for(char i='0';i<='9';i++){
    string v="";
    v+=i;
    dfs(v,false);
  }
  sort(memo.begin(),memo.end());
  //for(int i=0;i<100;i++) cout<<memo[i]<<endl;
  bool can=false;
  for(int i=0;i<memo[k].length();i++){
    if(!can){
      if(memo[k][i]=='0') continue;
      else {
        can=true;
      }
    }
    cout<<memo[k][i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 14320
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		string s; cin >> s;
		string revs = s;
		reverse(all(revs));
		int ans = 0;
		rep (i, s.length()) {
			if (s[i] != revs[i]) ans++;
		}
		cout << ans / 2 << endl;
    return;
}

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



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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    string s;
    cin >> s;
    int ans = INT_MAX;
    for (int i = 0; i < s.length() - 2; ++i) {
        int x = stoi(s.substr(i, 3));
        ans = min(ans, abs(x - 753));
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

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

int main() {
    ll n,m;
    cin >> n >> m;

    if(n>1 && m>1){
        cout << n*m-(2*n+2*(m-2)) << endl;
    }

    else{
        if(n==1){
            if(m==1) cout << 1 << endl;
            else cout << m-2 << endl;
        }
        else{
            cout << n-2 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
n, k, s = map(int, input().split())

def sieve(n):
    prime = [True] * (n + 1)
    prime[0] = prime[1] = False
    i = 2
    while i * i <= n:
        if prime[i]:
            for j in range(i * i, n + 1, i):
                prime[j] = False
        i += 1
    return [i for i in range(i) if prime[i]]

primes = sieve(1000)

def solve(n, k, s):
    other = None
    for p in primes:
        if s % p != 0:
            other = p
            break
    return [s] * k + [other] * (n - k)

print(*solve(n, k, s))

Measured memory_bytes: 5716
N = int(input())
dp = [i for i in range(N+1+9**5)]
for i in range(N):
  dp[i+1] = min(dp[i+1], dp[i] + 1)
  for j in range(1, 7):
    dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
  for k in range(1, 6):
    dp[i+9**k] = min(dp[i+9**k], dp[i] + 1)
    
print(dp[N])

Measured memory_bytes: 9368