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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> csum(n + 1, 0);
  vector<int> cxor(n + 1, 0);
  for (int i = 0; i < n; i++) {
    csum[i + 1] = csum[i] + a[i];
    cxor[i + 1] = cxor[i] ^ a[i];
  }
  int t = 1;
  long long res = 0;
  for (int s = 0; s < n; s++) {
    while (csum[t] - csum[s] == (cxor[t] ^ cxor[s]) and t <= n) t++;
    res += t - s - 1;
  }
  cout << res << '\n';
  return 0;
}

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

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

const double PI = 3.14159265358979323846;

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

int main()
{	
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << 60*h2 + m2 - (60*h1 + m1) - k << endl;
}


Measured memory_bytes: 3592
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [h, w] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    encode :: (Int, Int) -> Int
    encode (i, j) = i * w + j
    decode :: Int -> (Int, Int)
    decode = (`divMod` w)
    inside :: (Int, Int) -> Bool
    inside (i, j) = 0 <= i && i < h && 0 <= j && j < w
    neighbors :: VU.Vector Bool -> Int -> [Int]
    neighbors v k | v VU.! k  = filter (v VU.!) . map encode . filter inside $ [(i, j - 1), (i, j + 1), (i - 1, j), (i + 1, j)]
                  | otherwise = []
      where
        (i, j) = decode k
    search :: VU.Vector Bool -> Int -> Int
    search v k0 = snd . last $ queue
      where
        queue = (k0, 0) : walk 1 (IS.singleton k0) queue
        walk :: Int -> IntSet -> [(Int, Int)] -> [(Int, Int)]
        walk 0 _ _ = []
        walk l u ((k, d) : q) = map (flip (,) (d + 1)) ns ++ walk (l - 1 + length ns) u' q
          where
            ns = filter (`IS.notMember` u) $ neighbors v k
            u' = foldl (flip IS.insert) u ns
  bs <- VU.fromList . map ('.' ==) . concat . lines <$> getContents :: IO (VU.Vector Bool)
  print . VU.maximum . VU.map (search bs) $ VU.enumFromN 0 (h * w)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

//エラトステネスのふるい
struct Sieve {
    int n;
    //fはその数を割り切れる最小の素数
    vector<int> f, primes;

    //エラトステネスのふるい
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            //範囲内でiの倍数になる整数全てのfをiにする
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
   
    //f[x]==x、つまりxを割り切れる最小の素数がxそのものなら素数
    bool isPrime(int x) { return f[x] == x;}

    //xを入力するとxが1になるまで素数で割り続ける
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }

    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }

    //返り値resは(素因数、その次数)のpair
    vector<pair<ll,int>> factor(ll x){
        vector<pair<ll, int>> res;
        for(int p:primes){
            int y=0;
            while(x%p==0) x/=p, ++y;
            //res(pair)のfirstにはp、secondにはyを追加する
            if(y!=0) res.emplace_back(p,y);
        }
        if(x!=1) res.emplace_back(x,1);
        return res;
    }
};


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

    //nは1〜10の12乗なのでその平方根の100000以上のふるいを作る
    Sieve s(1000005);
    auto fs = s.factor(n);

    int ans=0;
    for(auto p:fs){
        int x = p.second;
        int b=1;
        while(b<=x){
            x -=b;
            b++;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;

}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int sx, sy, tx, ty;
  std::cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx, dy = ty - sy;
  // s -> t
  REP(i, dx) std::cout << "R";
  REP(i, dy) std::cout << "U";
  // t -> s
  REP(i, dx) std::cout << "L";
  REP(i, dy) std::cout << "D";
  // s -> t
  std::cout << "D";
  REP(i, dx + 1) std::cout << "R";
  REP(i, dy + 1) std::cout << "U";
  std::cout << "L";
  // t -> s
  std::cout << "U";
  REP(i, dx + 1) std::cout << "L";
  REP(i, dy + 1) std::cout << "D";
  std::cout << "R";
}


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

#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()


int main() {
    int n, t;
    cin >> n >> t;
    int mini = 1145141919;
    vector<int> d;
    rep(i, n) {
        int a;
        scanf("%d", &a);
        d.push_back(a - mini);
        mini = min(mini, a);
    }

    sort(ALL(d));
    cout << upper_bound(ALL(d), d[n - 1]) - lower_bound(ALL(d), d[n - 1]) << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
	
  
	int n;cin>>n;
	if(n%2==0) cout<<n/2<<endl;
	else cout<<(n/2)+1<<endl;

	return 0;
}	

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

int count_zeros(int input) {
  int cnt = 0;
  while(input) {
    if (input & 1) {
      break;
    }
    ++cnt;
    input >>= 1;
  }
  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  int min_zeros = 0;
  for (int i = 0; i < n; i++) {
    int input_value;
    std::cin >> input_value;
    int number_of_zeros = count_zeros(input_value);
    min_zeros = (i == 0 || number_of_zeros < min_zeros) ? number_of_zeros : min_zeros;
  }
  std::cout << min_zeros;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS
set<LL> st;
int N,M = 0;
int a[1000];
int main() {
	cin >> N >> M;
	for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i++){
        LL sum=0;
        for(int j=i;j<N;j++){
            sum+=a[j];
            st.insert(sum);
        }
    }
    LL nowBit=1;
    while(1){//実現可能な最大（最も左の）bitを探す
        nowBit*=2;
        auto temp=st.end();
        temp--;
        if(nowBit > *temp ){
            nowBit/=2;
            break;
        }
    }
    LL ans=0;
    LL lastUpdateBit=nowBit;//100...的なやつで初期化

    while(lastUpdateBit>=1){
        int count=0;
        auto temp=st.end();
        temp--;
        for(auto it=temp;it!=st.begin();it--){
            if( (*it & nowBit) == nowBit){
                count++;
                if(count>=M){
                    ans=nowBit;//答えを更新
                    break;
                }
            }
        }
        if(count<M){
            nowBit-= lastUpdateBit;//数が確保できなかったbitを0に
        }
        //次のbitを立てる//
        lastUpdateBit/=2;
        nowBit|=lastUpdateBit;
        /////////////////
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23680
N, M = list(map(int, input().split()))
target = [list(input().split()) for i in range(N)]

result =[]
for i,t in enumerate(target):
     if i == 0:
         result = t[1:]
     else:
         result = list(set(t[1:]) & set(result))
         
print(len(result))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int gcd_(int a,int b){
	if(a == b)	return a;
	int temp = a - b;
	if(temp < b)	swap(temp,b);
	return gcd_(temp,b);
}

int main(int argc, char const *argv[]){
	int a,b,gcd,lcm;
	while(cin >> a >> b){
		if(a < b)	swap(a,b);
		gcd = gcd_(a,b);
		lcm = a / gcd * b;
		printf("%d %d\n",gcd,lcm);
	}
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,d,x;
  cin>>n>>d>>x;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++){
    for(Int j=0;j<d;j++)
      if(a[i]*j<d) x++;
  }
  cout<<x<<endl;
  return 0;
}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

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


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int h,w;
  cin>>h>>w;
  int sy,sx,gy,gx;
  cin>>sy>>sx>>gy>>gx;
  sy--;sx--;gy--;gx--;
  vector<string> maze(h);
  for (auto &&x : maze)
  {
    cin>>x;
  }
  vector<vector<int> > dist (h,vector<int>(w,INF));
  deque<pair<int,int> > q;
  q.push_back({sx,sy});
  dist[sy][sx] = 0;
  int dir[] = {1,0,-1,0,1};
  //ZERO PATHS
  while(!q.empty())
  {
    int cx,cy;
    tie(cx,cy) = q.front();
    q.pop_front();
    // DEBUG(dist);
    for (int i = 0; i < 4; i++)
    {
      int nx = cx + dir[i];
      int ny = cy + dir[i+1];
      if(ny < 0 | nx < 0 || ny >= h || nx >= w)continue;
      if(maze[ny][nx] == '#')continue;
      if(dist[ny][nx] > dist[cy][cx])
      {
        dist[ny][nx] = dist[cy][cx];
        q.push_front({nx,ny});
      }
    }
    //ONE PATHS
    for (int i = -2; i <= 2; i++)
    {
      for (int j = -2; j <= 2; j++)
      {
        int ny = cy + i;
        int nx = cx + j; 
      if(ny < 0 || nx < 0 || ny >= h || nx >= w)continue;
      if(maze[ny][nx] == '#')continue;
      if(dist[ny][nx] > dist[cy][cx] +1)
      {
        dist[ny][nx] = dist[cy][cx] + 1;
        q.push_back({nx,ny});
      }
      }
      
    }
    

        
  }

  if(dist[gy][gx] == INF)cout<<-1<<endl;
  else cout<<dist[gy][gx]<<endl;

}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 12588
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty()) {
    int u = S.top();
    S.pop();
    for(int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if(color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for(int i = 0; i < n; i++) color[i] = NIL;
  for(int u = 0; u < n; u++) {
    if(color[u] == NIL) dfs(u, id++);
  }
}

int main (void) {
  int s, t, m, q;

  cin >> n >> m;

  for(int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for(int i = 0; i < q; i++) {
    cin >> s >> t;
    if(color[s] == color[t]) {
      cout << "yes" << endl;
    }
    else {
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 7064
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int a[25]={0};


int main()
{
 int  n,ans=0;
 scanf("%d",&n);
 for(int i=0;i<n;i++)
 scanf("%d",&a[i]);
for(int i=1;i<n-1;i++)
{
   if(a[i]>a[i-1]&&a[i]<a[i+1])
   ans++;
   else if(a[i]<a[i-1]&&a[i]>a[i+1])
   ans++;
}
printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int count_switch(string S){
    int cnt = 0;
    for(int i=0;i<S.length()-1;i++){
        if(S[i]!=S[i+1]){
            cnt++;
        }
    }
    return cnt;
}

int count_sat(string S){
    int sat = 0;
    for(int i=0;i<S.length()-1;i++){
        if(S[i]==S[i+1]){
            sat++;
        }
    }
    return sat;
}

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    int cnt,ans;
    cnt = count_switch(S);
    ans = count_sat(S);
    for(int i=1;i<=K;i++){
        if(cnt>=2){
            ans+=2;
            cnt-=2;
        }else if(cnt==1){
            ans+=1;
            cnt-=1;
        }else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <string>
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  int n,X;
  cin >> n >> X;
  int x[n+1];
  rep(i,n){
    cin >> x[i];
  }
  x[n] = X;
  sort(x,x+n+1);

  int diff[n];
  rep(i,n){
    diff[i] = x[i+1] - x[i];
  }
  int gcdNum = 0;
  rep(i,n){
    if(i != 0) gcdNum = gcd(gcdNum,diff[i]);
    else       gcdNum = diff[i];
  }
  cout << gcdNum << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
      x = (int) (1LL * x * p.x % mod);
      return *this;
  }

  ModInt &operator/=(const ModInt &p) {
      *this *= p.inverse();
      return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
      int a = x, b = mod, u = 1, v = 0, t;
      while(b > 0) {
          t = a / b;
          swap(a -= t * b, b);
          swap(u -= t * v, v);
      }
      return ModInt(u);
  }

  ModInt pow(int64_t n) const {
      ModInt ret(1), mul(x);
      while(n > 0) {
          if(n & 1) ret *= mul;
          mul *= mul;
          n >>= 1;
      }
      return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
      return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
      int64_t t;
      is >> t;
      a = ModInt< mod >(t);
      return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;

ll N, K;

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

    cin >> N >> K;

    // gcd が i になるパターン数
    vector<modint> pat(K + 1);

    modint ans(0);
    for(int i = K; i >= 1; --i) {
        modint cnt(K / i);
        pat[i] = cnt.pow(N);
        if(cnt.x > 1) {
            // i の倍数がいるならそれしか出ないパターンぶん引く
            for(int j = 2; i * j <= K; ++j) {
                pat[i] -= pat[i * j];
            }
        }
        ans += modint(i) * pat[i];
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3956
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int n,i,j;
	int p,q,r,cc;
	int flg;
	vector<int> No,a,b,c;
	while(1) {
		cin >> n;
		if(n==0) break;
		No.resize(n);
		a.resize(n);
		b.resize(n);
		c.resize(n);
		for(i=0;i<n;i++) cin >> No[i] >> a[i] >> b[i] >> c[i];
		cin >> p >> q >> r >> cc;
		flg=0;
		for(i=0;i<n;i++) {
			if(p>=a[i] && q>=b[i] && r>=c[i]) {
				if(cc>=(a[i]*4)+(b[i]*9)+(c[i]*4)) {
					cout << No[i] << endl;
					flg=1;
				}
			}
		}
		if(flg==0) cout << "NA" << endl;
	}
	exit(0);
}

Measured memory_bytes: 1244
using System;
using System.Collections.Generic;

//https://beta.atcoder.jp/contests/agc028/tasks/agc028_a

public class Program_AGC028_A // ←Class名変更！！
{
    public static void Main(string[] args)
    {
        var st = Console.ReadLine();
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var l = Lcm(s.Length, t.Length);
        var x = new Dictionary<long, char>();

        for (int i = 0; i < s.Length; i++)
        {
            var pos = i * (l / s.Length) + 1;
            x[pos] = s[i];
        }


        for (int i = 0; i < t.Length; i++)
        {
            var pos = i * (l / t.Length) + 1;
            if (x.ContainsKey(pos))
            {
                if (x[pos] != t[i])
                {
                    Console.WriteLine(-1);
                    return;

                }
            }
        }

        Console.WriteLine(l);
    } // Main



    //最小公倍数 least common multiple
    public static long Lcm(int a, int b)
    {
        //return a * b / Gcd(a, b) ;
        return a  / Gcd(a, b) * b;
    }

    //ユークリッドの互除法
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a); // 引数を入替えて自分を呼び出す

        while (b != 0)
        {
            var temp = a % b;
            a = b;
            b = temp;
        }

        return a;
    }





    //static long Gcd(long a, long b)
    //{
    //    var small = Math.Min(a, b);
    //    var big = Math.Max(a, b);

    //    if (small > 0)
    //    {
    //        return Gcd(small, big % small);
    //    }
    //    else
    //    {
    //        return big;
    //    }


    //    //if (a < b)
    //    //{
    //    //    return Gcd(b, a);
    //    //}
    //    //else
    //    //{
    //    //    if (b > 0)
    //    //    {
    //    //        return Gcd(b, a % b);
    //    //    }
    //    //    else
    //    //    {
    //    //        return a;
    //    //    }
    //    //}

    //    //return (a < b) ? Gcd(b, a)
    //    //     : (b > 0) ? Gcd(b, a % b)
    //    //               : a;
    //}

    ////static long Lcm(long a, long b)
    ////{
    ////    return a / Gcd(a, b) * b;
    ////}


    //static long gcd(long a, long b)
    //{
    //    long c = Math.Max(a, b) % Math.Min(a, b);
    //    b = Math.Min(a, b);
    //    while (c != 0)
    //    {
    //        a = b % c;
    //        b = c;
    //        c = a;
    //    }
    //    return b;
    //}

}     // Class




Measured memory_bytes: 18784
#include <stdio.h>
int main(void)
{
	int n, m,i,j;
	int gyo1[100][100];
	int gyo2[1000];
	scanf("%d %d",&n,&m);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d ", &gyo1[i][j]);
		}
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d",&gyo2[i]);
	}
	
	for (i = 0; i < n; i++)
	{
		int c = 0;
		for (j = 0; j < m; j++)
		{
			c = c + gyo1[i][j] * gyo2[j];
		}
		printf("%d\n", c);
	}
	return 0;
}

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

int main() {
  int L,R,d;
  cin >> L >> R >> d;
  int s;
  s = 0;
  
  for(int i = L; i < R + 1; i++) {
  	if(i % d == 0) {
    	s++;
    }
  }
  
  cout << s << endl;
 
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }


const int Max = 100000;
long long  h[Max][3];
long long  dp[Max][3]; // dp[i+1][j] i日目までの活動履歴のうち最終日i日目に活動jを選んだ場合の幸福度の最大値


int main() {
	int N;
	cin >> N;
	
	for(int i=0; i<N; i++) {
		cin >> h[i][0] >> h[i][1] >> h[i][2];
	}

	for(int i=0; i<N; i++) {
		for(int j=0; j<3; j++) {
			for(int k=0; k<3; k++) {
				if (j==k) continue;
				chmax(dp[i+1][k], dp[i][j] + h[i][k] );
			}
		}
	}

	// your code goes here
	long long res=0;
	for(int j=0; j<3; j++) chmax(res, dp[N][j]);
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



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

Measured memory_bytes: 256
n = int(input())


arr = []
arr.append(0) 
arr.extend(map(int,raw_input().split()))
arr.append(0)

distance = 0
for i in range(n+1):
	distance += abs(arr[i + 1] - arr[i])

for i in range(0,n):
	print distance - (abs(arr[i + 1] - arr[i]) + abs(arr[i + 2] - arr[i + 1])) + abs(arr[i + 2] - arr[i])

Measured memory_bytes: 11132
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;


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

	vector<ll> lxor(n+5, 0), rxor(n+5, 0);

	lxor[1] = a[1];
	for (int i = 2; i <= n; ++i) {
		lxor[i] = lxor[i-1] ^ a[i];
	}

	rxor[n] = a[n];
	for (int i = n-1; i >= 1; --i) {
		rxor[i] = rxor[i+1] ^ a[i];
	}

	for (int i = 1; i <= n; ++i) {
		if (i == 1) cout << rxor[2] << endl;
		else if (i == n) cout << lxor[n-1] << endl;
		else cout << (rxor[i+1] ^ lxor[i-1]) << endl;
	}

	return 0;
}


Measured memory_bytes: 7916
#include <bits/stdc++.h>
using namespace std;
#define N 110
int i,j,k,m,n,x,y,l[N],r[N];
char s[N][N];
inline void check(int*a,int n,int m,int f) {
    for (int i = 1, k, j; i <= n; ++i) {
        for (k = 0, j = 1; j <= m; ++j)if (f ? (s[i][j] == '.') : (s[j][i] == '.'))++k;
        if (k == m)a[i] = 1;
    }
}
int main() {
    for (scanf("%d%d", &n, &m), i = 1; i <= n; ++i)scanf("%s", s[i] + 1);
    check(l, n, m, 1), check(r, m, n, 0);
    for (i = 1; i <= n; ++i) {
        x = 0;
        for (j = 1; j <= m; ++j) {
            if (l[i] || r[j])continue;
            x = 1, putchar(s[i][j]);
        }
        if (x)puts("");
    }
}

Measured memory_bytes: 256
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc145/tasks/abc145_e
#E - All-you-can-eat
"""

"""

N = gi()
M = gi()
S = gw()

lis = [0] * (N + 5)

li = 0

all_good = 1

for i in range(1, N + 1):
    while (i - li > M or (li < i and S[li] == "1")):
        li += 1
    if li == i:
        all_good = 0
        break
    lis[i] = li

if all_good:
    ans = []
    ci = N
    while ci > 0:
        step = ci - lis[ci]
        ans.append(step)
        ci -= step
    ans.reverse()
    for a in ans:
        print(a, end=" ")
else:
    print(-1)


Measured memory_bytes: 18184
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int k,x;
    cin>>k>>x;
    if(500*k>=x){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double db;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    #define de(x) cout << #x << "=" << x << endl
    #define rep(i,a,b) for(int i=a;i<(b);++i)
    #define all(x) (x).begin(),(x).end()
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define lb(x) (x&-(x))
    const int N = 101010;
    int dp[2][17000]; 
    int main(){

        string s;
        cin>>s;
        int x,y;
        cin>>x>>y;

        vector<int> list[2];
        int isrow=1,sum=0;
        for(int i=0;i<s.length();i++)
        {
            char c=s[i];
            if(c=='F')
            sum++;
            else if(c=='T')
            {
                list[isrow].pb(sum);
                sum=0;
                isrow=(isrow+1)%2;
            }
        }
        list[isrow].pb(sum);
    //  for(int i=0;i<list[0].size();i++)cout<<list[0][i]<<" ";cout<<endl;
    //  for(int i=0;i<list[1].size();i++)cout<<list[1][i]<<" ";cout<<endl;  
        dp[0][8500]=1;//0点 
        dp[1][8500]=1;//0点 
        for(int ff=0;ff<2;ff++)
        {
            for(int i=0;i<list[ff].size();i++)
            {
                int x=list[ff][i];
                int temp[17000];
                memset(temp,0,sizeof(temp));
                for(int j=0;j<17000;j++)//+-8000
                {
                    if(dp[ff][j]==1)
                    {
                        if(i==0&&ff==1)
                        temp[j+x]=1;
                        else
                        {
                            temp[j+x]=1;
                            temp[j-x]=1;
                        }
                    } 
                }
                memcpy(dp[ff],temp,sizeof(temp)); 
            }
        }
        if(dp[0][y+8500]&&dp[1][x+8500])
        cout<<"Yes"<<endl;
        else 
        cout<<"No"<<endl;
        return 0;
    }

Measured memory_bytes: 3848
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
const int P=998244353;
int n;
struct pos{
	int x,y;
}ps[1007];
int ep=0,f[1007],sz[1007];
int gf(int x){while(x!=f[x])x=f[x]=x[f][f];return x;}
struct edge{
	int a,b;
	int v;
	bool operator<(const edge&e)const{return v<e.v;}
	void cal(){
		int x=gf(a),y=gf(b);
		if(x!=y)f[x]=y,sz[y]+=sz[x];
	}
}es[207*207];
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int pw[1007],ans;
int main(){
	scanf("%d",&n);
	pw[0]=1;
	for(int i=1;i<=n;++i)pw[i]=pw[i-1]*2%P;
	ans=(pw[n]-n-1)%P;
	for(int i=0;i<n;++i)scanf("%d%d",&ps[i].x,&ps[i].y);
	for(int i=0;i<n;++i){
		for(int j=0;j<i;++j){
			int x=ps[i].x-ps[j].x,y=ps[i].y-ps[j].y;
			int g=gcd(x,y);
			x/=g,y/=g;
			if(!x)y=1;
			if(!y)x=1;
			if(x<0)x=-x,y=-y;
			es[ep++]=(edge){i,j,x*30000+y};
		}
	}
	std::sort(es,es+ep);
	for(int i=0,j=0;i<ep;i=j){
		for(int a=0;a<n;++a)sz[f[a]=a]=1;
		for(;j<ep&&es[i].v==es[j].v;es[j++].cal());
		for(int a=0;a<n;++a)if(f[a]==a&&sz[a]>1)ans=(ans-pw[sz[a]]+sz[a]+1)%P;
	}
	printf("%d\n",(ans%P+P)%P);
	return 0;
}


Measured memory_bytes: 512
s = list(input())
K = int(input())
character = '0abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
limit = len(s) - 1

here = 0
while K:
    tmp = character.find(s[here])
    if tmp == 1 and here != limit:
        here += 1
        continue

    if tmp + K > 26 and here != limit:
        K -= 26 - tmp + 1
        s[here] = 'a'
        here += 1
    elif here == limit:
        K %= 26
        s[-1] = character[tmp + K]
        break
    else:
        here += 1
print(''.join(s))

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

using namespace std;
int main(void){
    // Here your code !
  int m,h;

  
 while(true){ 
  string W="";
cin>>W;
cin>>m;
if(W=="-") break;

for(int i=0; i<m;i++){
    cin>>h;

    string left=W.substr(0,h);

    string right=W.substr(h,W.length() - h + 1);
    
    W=right+left;
}
cout<<W<<endl;
}

}

Measured memory_bytes: 1216
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n;
	char min[26];
	memset(min, CHAR_MAX, 26);
	scanf("%d\n", &n);
	for(int i=0; i<n; i++){
		char now[26];
		memset(now, 0, 26);
		char c;
		while((c=getchar())!=10) now[c-'a']++;
		for(char j=0; j<26; j++){
			if(now[j]<min[j]) min[j]=now[j];
		}
	}
	for(char j=0; j<26; j++){
		for(char i=0; i<min[j]; i++){
			putchar(j+'a');
		}
	}
	putchar(10);
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(br.readLine());
		String line = br.readLine();
	    while(n!=0){
    	    String cline = calc(line);
    	    int ans = 0;
    	    while(!line.equals(cline)){
    	        line = cline;
    	        cline = calc(line);
    	        ans++;
    	    }
    	    System.out.println(ans);
    	    System.out.println(line);
	        n = Integer.parseInt(br.readLine());
	        line = br.readLine();
	    }
    }
    public static String calc(String line){
        HashMap<String,Integer> numMap = new HashMap<String,Integer>();
        String[] lines = line.split(" ");
        for(String st:lines){
            if(numMap.containsKey(st)){
                numMap.put(st,numMap.get(st)+1);
            }else{
                numMap.put(st,1);
            }
        }
        StringBuilder ans = new StringBuilder();
        boolean fst = true;
        for(String st:lines){
            if(!fst){
                ans.append(" ");
            }
            fst = false;
            ans.append(numMap.get(st));
        }
        return ans.toString();
    }
}

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

int main(){
    int ans = 0;
    int n, a, b; cin >> n >> a >> b;
    
    for(int i = 1; i <= n; i++){
        int tmp = 0;
        
        for(int j = i; j > 0; j /= 10){
            tmp += j % 10;
        }
        
        if(tmp >= a && tmp <= b){
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int RSIDE[7][4]={{},
  {2, 3, 5, 4},
  {1, 4, 6, 3},
  {1, 2, 6, 5},
  {1, 5, 6, 2},
  {1, 3, 6, 4},
  {2, 4, 5, 3}};
  
  int DICE[7], q, i, j, t, f, top;
	for(i=1; i<7; i++) {
    scanf("%d", &DICE[i]);
  }

	scanf("%d", &q);
	for(i=0; i<q; i++) {
		scanf("%d %d", &t, &f);

		for (j=0; j<7; j++) {
      if (DICE[j]==t) top=j;
    }

    for (j=0; j<4; j++) {
      if (DICE[RSIDE[top][j]]==f) {
        printf("%d\n", DICE[RSIDE[top][(j+5)%4]]);
      }
    }
	}
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 1000
#define M_MAX 1000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int d[M_MAX];
int n, m;

int i, j, k;

char s[N_MAX + 1];

int e[M_MAX][2];

void deb(){
	return;
}

void solve(){
	char* t;
	int ns = 0, ew = 0;
	for (t = s; *t; t++) {
		switch (*t) {
		case 'N':
			ns |= 1;
			break;
		case 'S':
			ns |= 2;
			break;
		case 'W':
			ew |= 1;
			break;
		case 'E':
			ew |= 2;
			break;
		}
	}
	if (((ns + 1) & 2) || ((ew + 1) & 2)) {
		puts("No");
	} else {
		puts("Yes");
	}
	return;
}

int main (void) {
	scanf("%s", s);

	solve();
	return 0;
}




Measured memory_bytes: 128
#include <algorithm>
  #include <iostream>
  using namespace std;
  int main()
  {
    int c[9];
    for(int i = 0; i < 9; i++) {
      int d;
      cin>>d;
      c[i] = d;
    }
    if(c[0] - c[3] == c[1] - c[4] && c[1] - c[4] == c[2] - c[5] && c[3] - c[6] == c[4] - c[7] && c[4] - c[7] == c[5] - c[8] && c[0] - c[6] == c[1] - c[7] && c[2] - c[8] == c[1] - c[7] && c[0] - c[1] == c[3] - c[4] && c[3] - c[4] == c[6] - c[7] && c[1] - c[2] == c[4] - c[5] && c[4] - c[5] == c[7] - c[8] && c[0] - c[2] == c[3] - c[5] && c[3] - c[5] == c[6] - c[8]){
      puts("Yes");
    }
    else {
      puts("No");
    }
    
    return 0;
  }


Measured memory_bytes: 256
def main():
    S = input()
    if len(S) == 0: return 0

    ref = S[0]
    count = 0
    for i in range(1, len(S)):
        if S[i] != ref:
            ref = S[i]
            count += 1
    return count 

if __name__ == '__main__':

    print(main())


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

const int MAX = 510000;
const int MOD = INF;

long long fac[MAX], finv[MAX], inv[MAX];

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

// テーブルを作る前処理
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;
}

signed main(){
    int N,K;
    cin>>N>>K;
    vin A(N);
    rep(0,N){
        cin>>A.at(i);
    }
    sort(A.begin(),A.end());
    int sum=0;
    COMinit();
    // for(int i=N;i>=K;i--){
    //     sum+=(A.at(i-1)-A.at(N-i))*COM(i-1,K-1)%INF;
    //     sum%=INF;
    // }
    rep(0,N-K+1){
        sum+=((((A.at(N-1-i)+INF)%INF-(A.at(i)+INF)%INF)+INF)%INF)*COM(N-1-i,K-1)%INF;
        sum%=INF;
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s,t;
cin>>s>>t;
map<char,char> st,ts;
int n=s.size();
bool possible=true;
rep(i,n){
    if(st.count(s[i])){
        if(st[s[i]]!=t[i]){
            possible=false;
            break;
        }
    }
    else if(ts.count(t[i])){
        if(ts[t[i]]!=s[i]){
            possible=false;
            break;
        }
    }
    else{
        st[s[i]]=t[i];
        ts[t[i]]=s[i];
    }
}
if(possible){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
//system("pause");
return 0;
}

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

#define ALL(container) (container).begin(), (container).end()
#define INF 1000000007
typedef long long ll;

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

using namespace std;

int main()
{
    int N; cin >> N;
    vector<ll> v(N);
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
        if (i == 0) {
            ans = v[i];
        } else {
            ans = GCD(ans, v[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
# import fractions
# import sys
import math
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
ans = 0
for i in range(1, n + 1):
    if k / i <= 1:
        ans += (1 / n)
    else:
        ans += (1 / n) / 2 ** (math.ceil(math.log2(k / i)))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  int l,r;
  int ans=0;
  cin>>n;
  REP(i,n){
    cin>>l>>r;
    ans += r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int a, b, t, sum = 0;
  scanf("%d %d %d", &a, &b, &t);
  
  for(int i = 1; i <= t; i++) {
    if(i % a == 0) {
      sum += b;
    }
  }
  printf("%d\n", sum);
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a, b;

int main() {
    scanf("%d", &n);
    a = b = 0;
    forn(i, n) {
        int x;
        scanf("%d", &x);
        if (x % 2 == 0) {
            ++a;
        } else {
            ++b;
        }
    }
    if (b % 2 == 0 || n == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<iomanip>
#include<set>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,ll> pii;
const int max_N=1e5+10;
int N,K;
vector <pii> G[max_N],rg[max_N];
vector<int>p(105,0);
bool dp[100005];
int a[105];
int main()
{
  memset(dp,false,sizeof(dp));
  cin >> N >> K;
  for(int i=0;i<N;i++)
    {
      cin >> a[i];
    }
  for(int i=0;i<=K;i++)
    {
      dp[i]=false;
      for(int j=0;j<N;j++)
	{
	  if(i-a[j]>=0)
	    {
	      if(!dp[i-a[j]])
		{
		  dp[i]=true;
		}
	    }
	}
    }
  if(dp[K])
    {
      cout << "First" << endl;
    }
  else
    {
      cout << "Second" << endl;
    }
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int N,K;
    cin >> N >> K;
    int tmp;
    int sum = 0;
    rep(i,N)
    {
        cin >> tmp;
        sum += min(tmp,K - tmp);
    }
    cout << sum * 2<< '\n';
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := readInt(), readInt()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = readInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(h)))

	if k >= n {
		fmt.Println("0")
		return
	} else {
		h = h[k:]
	}

	sum := 0
	for _, v := range h {
		sum += v
	}
	fmt.Println(sum)
}


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

int main(){
    int a,b;cin>>a>>b;
    int d=a/b,r=a%b;double aa=a,bb=b,f=aa/bb;
    cout<<d<<" "<<r<<" "<<fixed<<setprecision(5)<<f<<endl;
}


Measured memory_bytes: 3280
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,overlap
    character(:),allocatable:: s,t

    read*, n
    allocate(character(n):: s,t)
    read*, s
    read*, t

    overlap=0
    do i=n-1,0,-1
        if (s(n-i:n) == t(1:1+i)) then
            print'(i0)', 2*n-(i+1)
            stop
        end if
    end do
    print'(i0)', 2*n
end program name

Measured memory_bytes: 256