akhauriyash/Code-Regression huggingface dataset:
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-20 08:25:35
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=1000010,mod=998244353;
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1;
	for(;b;b>>=1,a=a*a%p) if(b&1) r=r*a%p;
	return r;
}
i64 inv(i64 a){ return power(a,mod-2,mod); }
i64 n,m,f[N],F[N],ans;
i64 C(i64 a,i64 b){ return b>=0&&a>=b?f[a]*F[b]%mod*F[a-b]%mod:0; }
int main()
{
	n=read(); m=read(); f[0]=1;
	fr(i,1,n+m) f[i]=f[i-1]*i%mod;
	F[n+m]=inv(f[n+m]);
	fd(i,n+m,1) F[i-1]=F[i]*i%mod;
	fr(i,0,std::min(n,m)) ans=(ans+(i&1?-1:1)*C(n,i)*C(m,i)%mod*f[i]%mod*power(n+1,m-i,mod)%mod*power(m+1,n-i,mod))%mod;
	printf("%d\n",int(ans<0?ans+mod:ans));
	return 0;
}

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

using namespace std;

typedef long long int lli;

int main() {
    int n, a, b;
    vector<vector<int>> tree(10000, vector<int>());

    cin >> n;
    for (int i=0; i<n-1; i++) {
        cin >> a >> b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }

    int c[10000], sum = 0;
    for (int i=0; i<n; i++) {
        cin >> c[i];
        sum += c[i];
    }
    sort(c, c+n, greater<int>());

    cout << sum-c[0] << endl;

    int count = 0;
    vector<int> ans(10000, -1);
    queue<int> qu;
    qu.push(0);
    while (!qu.empty()) {
        int idx = qu.front();
        qu.pop();

        ans[idx] = c[count++];

        for (auto e : tree[idx]) {
            if (ans[e] == -1) {
                qu.push(e);
            }
        }
    }

    for (int i=0; i<n-1; i++) {
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;

    return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    int N,K; cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int n;
   cin>>n;
   vector<int>p(n);
   for(int i=0;i<n;i++){
      cin>>p[i];
   }
   int ans=0;
   for(int i=1;i<n-1;i++){
      if((p[i-1]<p[i] and p[i]<p[i+1]) or (p[i+1]<p[i] and p[i]<p[i-1])){
         ans++;
      }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  int n;
  cin >> n;

  vector<int> p(n);
  fillInt(p, n);

  int res = 0;
  int i = 0;
  for(; i < n-1; i++) {
    if(i+1 == p[i] && i+2 == p[i+1]) {
      i++;
      res++;
    } else if(i+1 == p[i]) {
      res++;
    }
  }
  if(i == n-1 && p[n-1] == n) {
    res++;
  }

  cout << res << endl; 
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

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

    for(int i=0; i<100; i++){
        for(int j=0; j<50; j++){
            for(int k=0; k<34; k++){
                for(int l=0; l<25; l++){
                    for(int m=0; m<20; m++){
                        int a = X-(101*i+102*j+103*k+104*l+105*m);
                        if(a>=0 && (a%100==0)){
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << 0 <<endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[k];
        for (int i = 0; i < k; i++) {
            array[i] = sc.nextInt();
        }
        
        Arrays.sort(array);
        
        int ans = Math.max(0, array[k - 1] - (n - array[k - 1] + 1));
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
#include <stdio.h>
int main(){
 
  int d[6],n,i,j,blank,ue,mae;
   
  for(i = 0; i < 6; i++){
     
    scanf("%d",&d[i]);
     
  }
   
  scanf("%d",&n);
   
  for(j = 0; j < n; j++){
     
    scanf("%d %d",&ue,&mae);
     
    for(i = 0; d[1] != mae && i < 3; i++){
      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;
       
    }
     
    if(d[1] != mae){
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
       
      for(i = 0; d[1] != mae; i++){
    blank=d[0];
    d[0]=d[4];
    d[4]=d[5];
    d[5]=d[1];
    d[1]=blank;
     
      }
       
    }
     
    for(i = 0; d[0] != ue; i++){
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
       
    }
     
    printf("%d\n",d[2]);
     
  }
   
  return 0;
 
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1e9+7;
/*
【解法】
A = [1, 2, ..., n] と固定する（求める場合の数は、固定した場合の数の mPn 倍）。B を長さ n の数列とする

ある集合 S \subset {1, ..., n} の上で値が一致する（そのほかにも一致する値のある可能性がある）ような B の場合の数は g(S) = (m-|S|)P(n-|S|) 通り
（まだ決まっていない n-|S| 箇所の値を、使っていない m-|S| 個の値から重複しないように決める）

ある集合 S \subset {1, ..., n} の上でちょうど値が一致する（ S に属さない点 i ではA[i] != B[i] となる）ような
B の場合の数を f(S) 通りとすると、g(S) = \sum_{S\subset T} f(T) となる。

F(S) = f({1, ..., n} \setminus S), G(S) = g({1, ..., n} \setminus S) とおくと、
G(S) = \sum_{T\subset S} F(S) なので、包除原理から F(S) = \sum_{T\subset S} (-1)^|S\setminus T| G(T) が成り立つ。

求めるのは f(\emptyset)
= F({1, ..., n})
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| G(T)
= \sum_{T\subset {1, ..., n}} (-1)^|{1, ..., n}\setminus T| g({1, ..., n} \setminus T)
= \sum_{T\subset {1, ..., n}} (-1)^|T| g(T)
（ T -> T\setminus {1, ..., n} で置換）
ここで g は size の関数なので g(T) = g(|T|) とおくと、 k 元集合の選び方が nCk 通りなので 
= \sum_{k=0}^n (-1)^k nCk g(k)
= \sum_{k=0}^n (-1)^k n! / (n-k)! / k! * (m-k)! / (m-n)!
となる。

これを高速に計算する。 k == 0 のとき m! / (m-n)! で、

    n! (m-k)!             n! (m-(k-1))!          n-k+1
---------------- == ------------------------ * ---------
(n-k)! k! (m-n)!    (n-(k-1))! (k-1)! (m-n)!   (m-k+1) k

なので、 k がふえるたびに (n-k+1) / (m-k+1) / k 倍すればよい
*/
ll inv_table[500001] = {};
void make_inv_table(int n){
    inv_table[1] = 1;
    for (int i=2; i<=n; ++i){
        // (MOD / i) * i + MOD % i = 0 なので
        // (MOD / i) * i = - (MOD % i)
        // - (MOD / i) * (MOD % i)^(-1) = i^(-1)
        inv_table[i] = inv_table[MOD%i] * (MOD - MOD / i) % MOD;
    }
}

ll npr(ll n, ll r){
    ll ans = 1;
    for(ll i=n-r+1; i<=n; ++i)ans = (ans * i) % MOD;
    return ans;
}

int main()
{
    ll n, m;
    scanf("%lld%lld", &n, &m);

    const ll mpn = npr(m, n);
    ll tmp = mpn;
    ll sum[2] = {mpn, 0};
    make_inv_table(500000);
    for(int k=1; k<=n; ++k){
        tmp = ((tmp * inv_table[m-k+1]) % MOD * (inv_table[k] * (n-k+1) % MOD)) % MOD;
        sum[k%2] += tmp;
    }
    sum[0] = ((sum[0] - sum[1]) % MOD + MOD) % MOD;
    printf("%lld\n", (sum[0] * mpn) % MOD);
    return 0;
}


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

using namespace std;

bool contains(string s, char c) {
    for (char d : s) {
        if (d == c) {
            return true;
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string evens = "RUD";
    string odds = "LUD";
    for (int i = 0; i < (int)s.size(); ++i) {
        if ((i % 2 == 0 && !contains(evens, s[i])) || (i % 2 == 1 && !contains(odds, s[i]))) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  string s;
  if(a==b&&a!=c)s="Yes";
  else if(a==c&&a!=b)s="Yes";
  else if(b==c&&b!=a)s="Yes";
  else s="No";
  cout << s <<endl;
}

Measured memory_bytes: 256
/**
 *		author:  zvm
 *		created: 25.09.2020 13:44:02
**/

#include <bits/stdc++.h>

using namespace std ;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	

	int n ;
	cin >> n ;

	int ans = 1 ;
	for( int i = 1 ; i*i <= n ; ++i ) {
		ans = i*i ;
	}

	cout << ans << endl ;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;


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

	string s;
	cin >> s;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vec ans;

void f(ll x){
    if(x > 3234566667) return;

    ans.pb(x);
    f(x * 10 + x % 10);
    if(x % 10 >= 1) f(x * 10 + x % 10 - 1);
    if(x % 10 <= 8) f(x * 10 + x % 10 + 1);
}

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

    ll K;
    cin >> K;
    rep1(i, 9) f(i);
    sort(ALL(ans));
    print(ans[K - 1]);

    return 0;
}

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char t='a',w;
  while(1){
    if(t=='a'){
      if(s1.length()==0){
        w='A';
        break;
      }
      t=s1.at(0);
      s1.erase(s1.begin());
    }
    if(t=='b'){
      if(s2.length()==0){
        w='B';
        break;
      }
      t=s2.at(0);
      s2.erase(s2.begin());
    }
    if(t=='c'){
      if(s3.length()==0){
        w='C';
        break;
      }
      t=s3.at(0);
      s3.erase(s3.begin());
       }
  }
  cout << w << endl;
}

Measured memory_bytes: 256
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

class Radix {
private:
    const char* s;
    int a[128];
public:
    Radix(const char* s = "abcdefghijklmnopqrstuvwxyz") : s(s) {
        int i;
        for(i = 0; s[i]; ++i)
            a[(int)s[i]] = i;
    }
    std::string to(long long p, int q) {
        int i;
        if(!p)
            return "0";
        char t[64] = { };
        for(i = 62; p; --i) {
            t[i] = s[p % q];
            p /= q;
        }
        return std::string(t + i + 1);
    }
    std::string to(const std::string& t, int p, int q) {
        return to(to(t, p), q);
    }
    long long to(const std::string& t, int p) {
        int i;
        long long sm = a[(int)t[0]];
        for(i = 1; i < (int)t.length(); ++i)
            sm = sm * p + a[(int)t[i]];
        return sm;
    }
};

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

    int xo=0;
    rep(i,n){
        xo^=a[i];
    }
    rep(i,n-1){
        cout <<(xo^a[i])<<" ";
    }
    cout <<(xo^a[n-1])<<endl;
}

Measured memory_bytes: 4744
#include <iostream>

int main(){
	using namespace std;
	int build, floor, room, resident, data;
	int room_data[15][10] = {};

	cin >> data;

	while (data>0){
		cin >> build >> floor >> room >> resident;
		switch (build){
		case 1:
			room_data[floor-1][room-1] += resident;
			break;
		case 2:
			room_data[3 + floor][room-1] += resident;
			break;
		case 3:
			room_data[7 + floor][room-1] += resident;
			break;
		case 4:
			room_data[11 + floor][room-1] += resident;
			break;
		}
		data--;
	}
	for (int i = 0; i<15; i++)
	{
		if (i == 3 || i == 7 || i == 11)
			cout << "####################" << endl;
		else{
			for (int j = 0; j<10; j++)
			{
				if (room_data[i][j]<0)
					room_data[i][j] = -room_data[i][j];
				cout << ' ' << room_data[i][j];
			}
			cout << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


int n, m, dp[114514];
vector<int>vec[114514];
int dfs(int x) {
	if (dp[x])return dp[x];
	rep(i, vec[x].size()) {
		dp[x] = max(dp[x], dfs(vec[x][i]) + 1);
	}
	return dp[x];
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b;
		vec[a - 1].push_back(b - 1);
	}
	rep(i, n) {
		if (!dp[i]) {
			dfs(i);
		}
	}
	int ans = 0;
	rep(i, n) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long n = 100;
        long i = 0;
        while (true) {
            i++;
            n *= 1.01;
            if (n >= x) {
                System.out.println(i);
                return;
            }
        }
    }

}


Measured memory_bytes: 35708
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <utility>
#include <set>
#define lli long long int
#define m 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main() 
{
	fio;
	lli n;
	cin>>n;
	lli arr[n];
	for (int i=0;i<n;i++)
	cin>>arr[i];
	lli dp[2][n];
	memset(dp,0,sizeof(dp));
	for (int i=0;i<2;i++)
	{
	    for (int j=1;j<n;j++)
	    {
	        if (i==0||j==1)
	        dp[i][j]=dp[i][j-1]+abs(arr[j]-arr[j-1]);
	        if (j!=1)
	        dp[i][j]=min(dp[i][j-1]+abs(arr[j]-arr[j-1]),dp[i][j-2]+abs(arr[j]-arr[j-2]));
	    }
	}
	cout<<min(dp[0][n-1],dp[1][n-1]);
	return 0;
}	

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int main() {
    int N;
    int max = 100000;
    int count = 0;
    cin >> N;
    int d[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    sort(d, d + N, greater<int>());
    
    for (int i = 0; i < N; i++) {
        if (d[i] < max) {
            max = d[i];
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        if(n == 0) break;
        int s[n];
        double sum = 0;
        for(int i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        double ave = sum / n;
        sum = 0;
        for(int i = 0; i < n; i++) sum += (s[i] - ave) * (s[i] - ave);
        double a = sqrt(sum / n);
        printf("%.5f\n", a);
    }
}



Measured memory_bytes: 3228
N = int(input())
K = int(input())

def solve(n,k):
    if k==0: return 1
    if n < 10:
        return n if k==1 else 0
    if n < 100 and k == 3:
        return 0
    m,d = divmod(n,10)
    ret = d * solve(m,k-1)
    ret += (9-d)*solve(m-1,k-1)
    ret += solve(m,k)
    return ret

print(solve(N,K))

Measured memory_bytes: 3188
N,K = map(int,input().split(" "))
num = []

for i in range(N):
	a,b = map(int,input().split(" "))
	num.append([a,b])
num = list(sorted(num,key=lambda x:x[0]))

if num[0][1] >= K:
	print(num[0][0])
	exit(0)
for i in range(1,N):
	num[i][1] += num[i-1][1]
	if num[i][1] >= K:
		print(num[i][0])
		exit(0)


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

bool is_mon_inc(const VI& array) {
    int n = array.size();
    REP(i, n - 1) {
        if (array[i] > array[i + 1]) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI h(n);
    REP(i, n) cin >> h[i];

    FORR(i, n - 2, 0) if (h[i] > h[i + 1]) h[i]--;

    cout << (is_mon_inc(h) ? "Yes" : "No") << ln;
    return 0;
}


Measured memory_bytes: 3724
#include "atcoder/all"
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,q;
    cin >> n >> q;
    atcoder::dsu uf(n);
    while(q--){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            uf.merge(u,v);
        }else{
            if(uf.same(u,v)){
                print(1);
            }else{
                print(0);
            }
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int g;
    cin >> g;
    for (int i = 1; i < n; ++i)
    {
        int x;
        cin >> x;
        g = __gcd(g, x);
    }
    cout << g;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int A = Integer.parseInt(stdin.next());
		int B = Integer.parseInt(stdin.next());

		if(B == 1) {
			System.out.println(0);
		}
		else if(A == B) {
			System.out.println(1);
		}
		else {
			int sum=A;
			for(int i=1;i<100;i++) {
				if(i==1) {
					if(A*i >= B) {
						out.println(i);
						break;
					}
				}
				else {
					sum+=A-1;
					if(sum >= B) {
						out.println(i);
						break;
					}
				}
			}
			
		}
		out.flush();
	}

}


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

int main(void){
    char t[10];
    scanf("%s",t);
    if(t[0]=='S'){
        printf("Cloudy");
    }else if(t[0]=='C'){
        printf("Rainy");
    }else{
        printf("Sunny");
    }
    return 0;
}

Measured memory_bytes: 128
def insertion_sort(seq):
    n = len(seq)
    for i in range(n):
        v = seq[i]
        j = i-1
        while j >= 0 and seq[j] > v:
            seq[j+1] = seq[j] #vの入る候補がindexのi-1
            j -= 1
        seq[j+1] = v
        print(seq[0], end='')
        for k in range(1, n):
            print(' '+str(seq[k]), end='')
        print()

n = int(input())
seq = list(map(int, input().split()))
insertion_sort(seq)


Measured memory_bytes: 5980
// abc069_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  int size;
  cin>>s;
  size = s.size();
  cout<<s[0]<<size-2<<s[size-1]<<endl;
  return 0;
}


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

using namespace std;

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

  vector<int> v;
  for (int i=0; i < N; i++) {
    int A; cin >> A;
    v.push_back(A);
  }
  
  vector<int> c(v);
  sort(c.begin(), c.end());
  int max = c[c.size() - 1];
  int nextMax = c[c.size() - 2];
  
  for (int i=0; i<N; i++) {
    int ans = (v.at(i) == max) ? nextMax : max;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3316
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

const int INF = 1000;

P f(int x) {
  int a = x % 10;
  int b = 0;
  while (x) {
    b = x;
    x /= 10;
  }
  return P(a, b);
}

void Main() {
  int n;
  cin >> n;
  map<P, int> freq;
  REP(x, 1, n + 1) freq[f(x)]++;
  ll ans = 0;
  REP(x, 1, n + 1) {
    P p = f(x);
    ans += freq[P(p.second, p.first)];
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
n,m = map(int,input().split())

k = [list(map(int,input().split())) for i in range(n)]
s=[]
for i in range(n):
    s.extend(k[i][1:])
c=0

for i in range(m):
    if s.count(i+1)==n:
        c+=1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int s = 0;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        s += l[i];
    }

    sort(l.begin(), l.end());

    cout << (l[n - 1] < s - l[n - 1] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int max_value = 0, max_index = 0;
int min_value = MAX, min_index = 0;

typedef pair<int, int> Po;
typedef long long ll;

int dp[10001];

int main() {
	cin >> N >> M;
	int a[9] = {2,5,5,4,5,6,3,7,6}, num;
	vector<int> canuse;
	vector<int> many;
	bool flag = false;
	rep(i, M){
		cin >> num;
		canuse.push_back(num);
		if(a[num-1] == 5 && flag) continue;
		if(a[num-1] == 5) flag = true;
		many.push_back(a[num-1]);
	}
	sort(many.begin(), many.end());

	dp[0] = 0;
	rep(i, N){
		dp[i+1] = INF;
		rep(j, many.size()){
			if(i+1-many[j] > -1) dp[i+1] = max(dp[i+1], dp[i+1-many[j]]+1);
		}
	}

	sort(canuse.begin(), canuse.end(), greater<int>());

	int curr = N;
	while(curr != 0){
		rep(i, canuse.size()){
			if(curr-a[canuse[i]-1] < 0) continue;
			if(dp[curr-a[canuse[i]-1]] == dp[curr]-1){
				cout << canuse[i];
				curr -= a[canuse[i]-1];
				break;
			}
		}
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

loop{ #無限ループをするメソッド
  a, op, b = STDIN.gets.split
  a = a .to_i
  b = b .to_i
  op = op .to_s
  puts( case op
        when '+' 
          a + b
        when '-' 
          a - b
        when '*' 
          a * b
        when '/'  
          c = a/b
        when '?'
          break
        end)
      }
      
      

Measured memory_bytes: 8608
#include <bits/stdc++.h>
using namespace std;
long long n,h;
long long a[100000],b[100000];
int main(){
	cin>>n>>h;
	long long maxa=0;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		maxa=max(maxa,a[i]);
	}
	sort(b,b+n,greater<int>());
	int cnt=0;
	for(int i=0;i<n;i++){
		if(b[i]>=maxa){
			cnt++;
			h=h-b[i];
			if(h<=0){
				break;
			}
		}else{
			break;
		}
	}
	if(h>0){
		if(h%maxa!=0){
			cnt=cnt+h/maxa+1;
		}else{
			cnt=cnt+h/maxa;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
b=[int(input()) for i in range(m)]
for i in range(n):
    ans=0
    for j in range(m):
        ans+=A[i][j]*b[j]
    print(ans)
    


Measured memory_bytes: 6020
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int stk[10][10], head[10];
vector<string> s;

int dots(string a){
  int res = 0;
  for(int i = 0;i < a.size();++i)if(a[i] != '.')return i;
  return 0;
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    rep(i, 10){
      rep(j, 10)stk[i][j] = 0;
      head[i] = 0;
    }

    int(n); if(!n)break;
    s.resize(n); scn(n, s);

    for(i = n - 1;i >= 0;--i){
      int d = dots(s[i]);
      if(s[i][d] == '+'){
        int sum = 0;
        rep(j, head[d + 1])sum += stk[d + 1][j];
        head[d + 1] = 0;
        stk[d][head[d]++] = sum;
      }else if(s[i][d] == '*'){
        int pr = 1;
        rep(j, head[d + 1])pr *= stk[d + 1][j];
        head[d + 1] = 0;
        stk[d][head[d]++] = pr;
      }else{
        stk[d][head[d]++] = (int)(s[i][d] - '0');
      }
    }
    pri(stk[0][0]);


//*/
    s.clear();
//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint a, b;
  cin >> a >> b;
  lint ans = 0;
  lint current = 1;
  while (current < b) {
    current += a-1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys,random,time,bisect
input=sys.stdin.buffer.readline

start=time.time()
N=int(input())
vw=[(-1,-1)]
for i in range(N):
    vw.append(tuple(map(int,input().split())))

dp=[[] for i in range(2**9)]
def make_dp(v):
    t=[[0,0] for i in range(15)]
    V=v
    id=0
    while v>=1:
        t[id]=vw[v]
        id+=1
        v//=2
    n=id
    temp=[[0,0] for i in range(2**n)]
    for i in range(n):
        for j in range(2**i,2**(i+1)):
            temp[j][0]=temp[j-2**i][0]+t[i][0]
            temp[j][1]=temp[j-2**i][1]+t[i][1]
    temp.sort(key=lambda x:x[1])
    for i in range(1,2**n):
        temp[i][0]=max(temp[i][0],temp[i-1][0])

    dp[V]=[0]*(10**5+1)
    for i in range(2**n-1):
        L=temp[i][1]
        R=temp[i+1][1]
        if L>10**5:
            break
        elif R>10**5:
            R=10**5+1
        for j in range(L,R):
            dp[V][j]=temp[i][0]
    else:
        L=temp[-1][1]
        if L<=10**5:
            for j in range(L,10**5+1):
                dp[V][j]=temp[-1][0]

MAX=min(2**9,N+1)
for i in range(1,MAX):
    make_dp(i)

Q=int(input())
query=[[] for i in range(N+1)]
for i in range(Q):
    v,L=map(int,input().split())
    query[v].append((L,i))

ans=[0]*Q
temp=[[0,0] for i in range(2**9)]
t=[[0,0] for i in range(15)]
def solve(v):
    V=v
    id=0
    while v>=2**9:
        t[id]=vw[v]
        id+=1
        v//=2
    n=id
    for i in range(n):
        for j in range(2**i,2**(i+1)):
            temp[j][0]=temp[j-2**i][0]+t[i][0]
            temp[j][1]=temp[j-2**i][1]+t[i][1]

    for L,ID in query[V]:
        res=0
        for i in range(2**n):
            if L>=temp[i][1]:
                res=max(res,temp[i][0]+dp[v][L-temp[i][1]])
        ans[ID]=res

for i in range(1,N+1):
    if query[i]:
        solve(i)

for i in range(Q):
    print(ans[i])


Measured memory_bytes: 534280
n,m=map(int,input().split())
lista=[]
for i in range(n):
    lista.append(input())
listb=[]
for i in range(m):
    listb.append(input())
ans=0
num1=n-m+1
for i in range(num1):
    for j in range(num1):
        yn=0
        for k in range(m):
            str1=lista[i+k]
            if listb[k]!=str1[j:j+m]:
                yn=1
                break
        if yn==0:
            ans=1
            break
    if ans==1:
        break
if ans==0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
n=int(input())
s=input()
e=s.count("E")
E=W=0
a=n
for i in range(n):
    if s[i]=="W":
        b=W+e-E
        W+=1
    else:
        E+=1
        b=W+e-E
    a=min(a,b)
print(a)

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

long long a[100010][3];
long long dp[100010][3];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) cin >> a[i][j];
  }

  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;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]); 
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 3; i++) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

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

	for (int i = 1; i <= 1000; i++)
		if (i / 10 == b && i * 8 / 100 == a)
		{
			printf("%d", i);
			return 0;
		}

	printf("-1");
	return 0;
}


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

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

int main()
{
	LL cnt = 0;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == t[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,i,j,c;

        scanf("%d",&n);

        int a[n];

        for(i=0;i<n;i++)
                scanf("%d",&a[i]);

        c=0;
        for(i=0;i<n-2;i++){
                        if(a[i]>a[i+2]){
                                if(a[i]>a[i+1] && a[i+1]>a[i+2]) c++;
                        }
                        else {
                                if(a[i]<a[i+1] && a[i+1]<a[i+2]) c++;
                        }
        }

        printf("%d\n",c);
        return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    new Main().a();

  }

  private void a() {
    try (Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)))) {

      String input = in.nextLine();
      String[] words = input.split(" ");

      for (final String word:words
           ) {
        System.out.print(word.charAt(0));
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 10192
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i%2==0){
    					 if(x%2==0){
     					    sb.append("#");
     				    }else{
     				        sb.append(".");
     				    }
    				 }
    			     else{
    				    if(x%2==0){
    					    sb.append(".");
    				    }else{
    				        sb.append("#");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    }

}

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

int main() {
  long long N;
  cin >> N;
  vector<long long>vec;
  for(long long i=1; i*i<=N+1; i++){
    if(N%i == 0){
      vec.push_back( N/i + i - 2);
    }
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(0) << endl;
}


Measured memory_bytes: 3600
n=int(input())
t=list(map(int,input().split()))
a=list(map(int,input().split()))
mod=pow(10,9)+7
ans=[[0,0] for _ in range(n)]
pre=0
for i in range(n):
  if t[i]>pre:
    ans[i]=[t[i],1]
  else:
    ans[i]=[t[i],0]
  pre=t[i]
#print(ans)
pre=0
for i in range(n-1,-1,-1):
  if a[i]>pre:
    if ans[i][1]==0 and ans[i][0]<a[i]:
      print(0)
      exit()
    elif ans[i][1]==1 and ans[i][0]!=a[i]:
      print(0)
      exit()
    else:
      ans[i]=[a[i],1]
  else:
    if ans[i][1]==0:
      ans[i][0]=min(ans[i][0],a[i])
    elif ans[i][1]==1 and ans[i][0]>a[i]:
      print(0)
      exit()
  pre=a[i]
b=1
for x,y in ans:
  if y==1:continue
  b*=x
  b%=mod
print(b)

Measured memory_bytes: 27148
#include<bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()
using namespace std;


const int maxn=1e6+7;
int a[maxn],x,y,z;

int main (){
    set<char>ss;
    int vis[1000];
    for(int i=0;i<=30;i++) vis[i]=0;
    string s;cin>>s;
    sort(all(s));
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[3]) cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
int dx[4] = { 1,0/*,-1,0*/ }, dy[4] = { 0,1/*,0,-1*/ };
/**************/

typedef long double ld;
typedef unsigned long long ull;
const int MX = 3007;

ld f[MX][MX], p[MX];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> p[i];
	f[0][0] = 1.0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			f[i + 1][j + 1] += f[i][j] * p[i];
			f[i + 1][j] += f[i][j]*(1.0-p[i]);
		}
	}
	ld ans = 0.0;
	for (int i = 0; i <= n; i++) {
		if (n<= i*2 ) {
			ans += f[n][i];
		}
	}
	//ans = 3.1415162879247329242952658462;
	cout << fixed <<setprecision(20)<< ans << endl;
	printf("%20.18L", ans);
	return 0;
}


Measured memory_bytes: 141568
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(s string) string {
        // N: 0
        // W: 1
        // S: 2
        // E: 3

        var d [4]int

        for i := range s {
                switch s[i] {
                case 'N':
                        d[0]++
                case 'W':
                        d[1]++
                case 'S':
                        d[2]++
                case 'E':
                        d[3]++
                }
        }
        if d[0] > 0 && d[2] == 0 || d[0] == 0 && d[2] > 0 {
                return "No"
        }
        if d[1] > 0 && d[3] == 0 || d[1] == 0 && d[3] > 0 {
                return "No"
        }
        return "Yes"
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var s string
        fmt.Fscan(r, &s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 1856