akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

const int mod=1e9+7;
//lint dp[100010][2][110]={};

int main()
{
	string K;
	lint D;
	
	cin >> K >> D;
	
	const lint N=K.length();
	lint dp[100010][2][110]={};
	dp[0][0][0]=1;
	
	for(lint i=0;i<N;i++)
	{
		for(lint j=0;j<2;j++)
		{
			for(lint k=0;k<D;k++)
			{
				lint dmax;
				if(j==1)dmax=9;
				else dmax=K[i]-'0';
				for(lint d=0;d<=dmax;d++)
				{
					lint nj,nk;
					if(j==1 || d<dmax)nj=1;
					else nj=0;
					nk=(k+d)%D;
					
					dp[i+1][nj][nk]+=dp[i][j][k];
					dp[i+1][nj][nk]%=mod;
				}
			}
		}
	}
	
	cout << (dp[N][0][0]+dp[N][1][0]-1+mod)%mod << endl;
	return 0;
}

Measured memory_bytes: 172160
#include <iostream>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define w(x) int x; cin >> x; while (x--)
#define pb push_back
 
ll dp[100001];

int solve(int i, int* h, int n, int k) {

	if (i == n) {
		dp[n] = 0;
		return dp[n];
	}

	ll ans = 1000000009;
	for (int j = 1; j <= k and i + j <= n; ++j) {
		if (dp[i+j] == -1) {
			dp[i+j] = solve(i+j, h, n, k);
		}
		ans = min(ans, abs(h[i] - h[i+j]) + dp[i+j]);
	}
	dp[i] = ans;
	return ans;
}

int main() {

	int n, k;
	cin >> n >> k;
	int h[n];
	for (int i = 1; i < n+1; ++i)
		cin >> h[i];

	for (int i = 0; i < 100001; ++i) 
		dp[i] = -1;
	
	cout << solve(1, h, n, k);

	return 0;
}

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

int main(){
    int K;
    cin >> K;
    long long *A=new long long[100000];

    for(int i=0;i<K;i++){
        cin >> A[i];
    }

    long long min=2,max=2;
    for(int i=K-1;i>=0;i--){
        bool flg=false;
        long long tmin,tmax;
        tmin=min-(min%A[i])+(min%A[i]==0?0:A[i]);
        tmax=max-(max%A[i])+A[i]-1;
        if(tmin>tmax){
            cout << "-1" << endl;
            delete[] A;
            return 0;
        }
        min=tmin;
        max=tmax;
    }

    cout << min << ' ' << max << endl;

    delete[] A;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	numA := x
	numB := y
	numC := 0

	if a+b > c*2 {
		m := min(numA, numB)
		numA -= m
		numB -= m
		numC += m * 2
		switch {
		case numA > 0 && a > c*2:
			numC += numA * 2
			numA = 0
		case numB > 0 && b > c*2:
			numC += numB * 2
			numB = 0
		}
	}

	fmt.Println(numA*a + numB*b + numC*c)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct gauss {

    vector<unsigned long long> v;

    void init() {
      v.resize(64);
    }

    void add(unsigned long long a) {
      for(int i=63; i>=0; i--) {
        if (a&(1uLL<<i)) {
          if (v[i] != 0) {
            a ^= v[i];
          } else {
            v[i] = a;
            break;
          }
        }
      }
    }

    bool canCreate(ll b) {
      for(int i=63; i>=0; i--) {
        if (b&(1uLL<<i)) {
          if (v[i] != 0) {
            b ^= v[i];
          } else {
            return false;
          }
        }
      }
      return true;
    }
};


class AXorBattle {
public:

    void calc(istream& cin, ostream& cout) {
      int n; cin >> n;
      vector<ll> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      string s; cin >> s;
      reverse(all(s));
      reverse(all(a));
      gauss g;
      g.init();
      rep(i, n) {
        if (s[i] == '0') {
          g.add(a[i]);
        } else {
          if (!g.canCreate(a[i])) {
            cout << 1 << '\n';
            return;
          }
        }
      }
      cout << 0 << '\n';
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int t; cin >> t;
      while(t--) {
        calc(cin, cout);
      }
    }
};

signed main() {
  AXorBattle solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int a;
	cin >> a;
	int ans = a + a * a + a * a * a;
	cout << ans << endl;
	return 0;
}

//!

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

ll K;
string s("19");

int main(void){
    
    cin >> K;
    
    int i = 1;
    for(; i <= K && i <= 9; ++i) cout << i << endl;
    int j = 1;
    for(; i <= K && j <= 9; ++i) cout << j++ << "9" << endl;
    j = 1;
    for(; i <= K && j <= 19; ++i) cout << j++ << "99" << endl;
    j = 2;
    for(; i <= K && j <= 29; ++i) cout << j++ << "999" << endl;
    j = 3;
    for(; i <= K && j <= 39; ++i) cout << j++ << "9999" << endl;
    j = 4;
    for(; i <= K && j <= 49; ++i) cout << j++ << "99999" << endl;
    j = 5;
    for(; i <= K && j <= 59; ++i) cout << j++ << "999999" << endl;
    j = 6;
    for(; i <= K && j <= 69; ++i) cout << j++ << "9999999" << endl;
    j = 7;
    for(; i <= K && j <= 79; ++i) cout << j++ << "99999999" << endl;
    j = 8;
    for(; i <= K && j <= 89; ++i) cout << j++ << "999999999" << endl;
    j = 9;
    for(; i <= K && j <= 99; ++i) cout << j++ << "9999999999" << endl;
	j = 10;
	for (; i <= K and j <= 99; i++) cout << j++ << "99999999999" << endl;
	j = 10;
	for (; i <= K and j <= 109; i++) cout << j++ << "999999999999" << endl;
	j = 11;
	for (; i <= K and j <= 109; i++) cout << j++ << "9999999999999" << endl;
	j = 11;
	for (; i <= K and j <= 99; i++) printf("%d99999999999999a\n", j++);
    j = 10;
    for(; i <= K && j <= 109; ++i) cout << j++ << "99999999999" << endl;
    j = 11;
    for(; i <= K && j <= 119; ++i) cout << j++ << "999999999999" << endl;
    j = 12;
    for(; i <= K && j <= 129; ++i) cout << j++ << "9999999999999" << endl;
    j = 13;
    for(; i <= K && j <= 139; ++i) cout << j++ << "99999999999999" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
	#define MOD 1000000007
	#define ll long long
	#define mp make_pair
	#define pb push_back 
	using namespace std;
	int main(){
		ios::sync_with_stdio(false);
		cin.tie(NULL);
		string a, b;
		cin >> a >> b;
		string d1 = "", d2 = "";
		for(int i = 0; i < stoll(b); i++)
			d1 += a;
		for(int i = 0; i < stoll(a); i++)
			d2 += b;
		if(d1 <= d2)
			cout << d1 << '\n';
		else cout << d2 << '\n';
	
	}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main() {
	while (cin >> n, n) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];
		vector<vector<int> > dp(n, vector<int>(n + 1));
		for (int i = 2; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				int r = j + i;
				for (int k = j + 1; k < r; k++) {
					dp[j][r] = max(dp[j][r], dp[j][k] + dp[k][r]);
				}
				if (abs(a[j] - a[r - 1]) <= 1 && dp[j + 1][r - 1] == i - 2) {
					dp[j][r] = max(dp[j][r], dp[j + 1][r - 1] + 2);
				}
			}
		}
		cout << dp[0][n] << endl;
	}
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

#define     _test int _TC; cin >> _TC; while(_TC--)
#define     CS(x) cout << "Case " << x << ": ";
#define     precision(n) cout << fixed << setprecision(n);
#define     Clear(a, b) memset(a, b, sizeof(a))
#define     sq(x) ((x) * 1LL * (x))
#define     eb emplace_back
#define     all(_n) _n.begin(), _n.end()
#define     rall(_n) _n.rbegin(), _n.rend()
#define     endl "\n"
#define     show(x) cout << x << endl
#define     nl cout << endl
#define     sz(x) int(x.size())
#define     gcd(a, b) __gcd(a, b)
#define     lcm(a, b) (abs((a) * (b)) / gcd(a, b))
#define     parity(a, b) ((a&1) ^ (b&1))
#define     make_unique(x) sort(all((x))); (x).erase(unique(all((x))), (x).end())
#define     IN(a) for(auto &it : a) cin >> it

template <typename T> void print (T t){ for(const auto &it : t) cout << it << ' '; nl; }
template <typename T> using OS = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // order_of_key find_by_order

const    double Pi = acos(-1.0);
const    int Mod = 1e9 + 7;
const    int Inf = 1 << 30; // INT_MAX = (1LL << 31) -1 // Inf -> 1e9
const    int Maxx = 1e6 + 10;

/************************************[Code Starts Here]************************************/


void _case()
{
	int n, m; cin >> n >> m;
	vector<int> v(m); IN(v);
	ll x = accumulate(all(v), 0LL);
	show((x > n ? -1 : n-x));
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    _case();
    return 0;
}




Measured memory_bytes: 3652
#include<stdio.h>
int main()

{
    int T, N[200001];
    int i,j,min=10000000, count=0;

    scanf("%d", &T);

    for(i=0; i<T; i++)
    {
       scanf("%d", &N[i]);
    }
     for(j=0;j<T;j++)
       {

           if(N[j]<=min)
             {
              count++;
              min=N[j];
            }
       }


    printf("%d", count);
}


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

#define REP(i, t) for(int i = 0, i##E = (t); i < i##E; ++i)
#define fst first
#define snd second

typedef long long LL;
typedef std::pair<int, int> Pii;

#ifdef __linux__
#define getchar getchar_unlocked
#endif
template <typename T> inline bool maximum(T &a, T b) { return a < b? a = b, 1 : 0; }
template <typename T> inline bool minimum(T &a, T b) { return a > b? a = b, 1 : 0; }
template <typename T>
T read(T &x, T f = 0)
{
	char c = getchar(); x = 0;
	for(; !isdigit(c); c = getchar())
		f |= c == '-';
	for(;  isdigit(c); c = getchar())
		x = x*10 + c-'0';
	return x = f? -x : x;
}

const int N = 4e5 + 10;
const int mod = 924844033;
const int G0 = 5;

int n;

//GRAPH
int e, Begin[N];

struct Edge
{
	int to, next;
	Edge(int _to = 0, int _next = 0) : to(_to), next(_next) {}
}E[N << 1];

void add_edge(int u, int v)
{
	E[++e] = Edge(v, Begin[u]), Begin[u] = e;
	E[++e] = Edge(u, Begin[v]), Begin[v] = e;
}

//NTT
int rev[N << 1], Len, bit_cnt;

int fpm(int x, int e)
{
	int res = 1;
	for(; e; e >>= 1){
		if(e & 1) res = (LL)res * x % mod;
		x = (LL)x * x % mod;
	}
	return res;
}

void NTT(int *p, int n, int f)
{
	REP(i, n) if(i < rev[i]){
		std::swap(p[i], p[rev[i]]);
	}

	for(int step = 1; step < n; step <<= 1){
		int w = fpm(G0, (mod-1)/(step<<1));
		if(f) w = fpm(w, mod - 2);

		for(int i = 0; i < n; i += step << 1){
			int e = 1;

			for(int j = i; j < i + step; ++j){
				int u = (LL)p[j + step] * e % mod;
				p[j + step] = (p[j] - u + mod) % mod;
				p[j] = (p[j] + u) % mod;
				e = (LL)e * w % mod;
			}
		}
	}

	if(f){
		REP(i, n)
			p[i] = (LL)p[i] * fpm(n, mod - 2) % mod;
	}

	return ;
}

int size[N], A[N << 1], B[N << 1];

void Addcon(int o, int f)
{
	A[o] += f;
	if(A[o] < 0) A[o] += mod;
	if(A[o] >= mod) A[o] -= mod;
}

void dfs_Modulus(int u, int fa)
{
	Addcon(n, +1);
	size[u] = 1;

	for(int i = Begin[u]; i; i = E[i].next){
		int v = E[i].to;
		if(v == fa) continue;
		dfs_Modulus(v, u);
		size[u] += size[v];

		Addcon(size[v], -1);
	}

	Addcon(n-size[u], -1);
}

void Init()
{
	read(n);
	for(int i = 1; i < n; ++i){
		int u, v; 
		read(u), read(v);
		add_edge(u, v);
	}

	bit_cnt = 0;
	Len = 1; 
	for(; Len <= n + n; Len <<= 1, ++bit_cnt) {}

	REP(i, Len){
		rev[i] = (rev[i>>1] >> 1) | ((i&1) << (bit_cnt-1));
	}

	return ;
}

void Work()
{
	dfs_Modulus(1, 0);

	int fac = 1;
	for(int i = 1; i <= n; ++i){
		fac = (LL)fac * i % mod;
		A[i] = (LL)A[i] * fac % mod;
	}
	fac = 1;
	for(int i = 0; i < n; ++i){
		if(i) fac = (LL)fac * i % mod;
		B[n - i] = fpm(fac, mod - 2);
	}

	NTT(A, Len, 0), NTT(B, Len, 0);
	REP(i, Len) A[i] = (LL)A[i] * B[i] % mod;
	NTT(A, Len, 1);

	fac = 1;
	for(int i = 1; i <= n; ++i){
		fac = (LL)fac * i % mod;
		printf("%lld\n", (LL)A[n + i] * fpm(fac, mod-2) % mod);
	}

	return ;
}

int main()
{
	Init();
	Work();

	return 0;
}

Measured memory_bytes: 28544
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> l(n);
    rep(i,n) {
        cin>>l[i];
    }
    sort(begin(l), end(l));
    ll res = 0;
    repr(i, 2, n) {
        ll mx = l[i];
        repr(j, 1, i) {
            ll m2 = l[j];
            auto it = upper_bound(begin(l), end(l), mx - m2);
            res += max(0LL, ll(j) - ll(it - l.begin()));
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
    s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  vector<int> cs(60);
  for (int i = 0; i < n; i++) {
    int64 x;
    cin >> x;
    for (int j = 0; j < 60; j++) {
      if (x & (1LL << j)) {
        cs[j]++;
      }
    }
  }
  // cout << cs << endl;

  FiniteField ans = 0;
  for (int i = 0; i < 60; i++) {
    ans += FiniteField(1LL << i) * cs[i] * (n - cs[i]);
  }
  cout << ans << endl;
}

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

int n, cnt[4], a;
double bd[301][301][301];

double eat(int a, int b, int c) {
	double ans = 1; 
	if (!bd[a][b][c]) {
		if (a>0) {
			if (!bd[a-1][b][c])
				eat(a-1, b, c);
			ans += a*bd[a-1][b][c]/n;
		}
		if (b>0) {
			if (!bd[a+1][b-1][c])
				eat(a+1, b-1, c);
			ans += b*bd[a+1][b-1][c]/n;
		}
		if (c>0) {
			if (!bd[a][b+1][c-1])
				eat(a, b+1, c-1);
			ans += c*bd[a][b+1][c-1]/n;
		}
		bd[a][b][c] = n*ans/(a+b+c);
	}
	return bd[a][b][c];
}

int main() {
	cin >> n;
	cnt[1] = 0;
	cnt[2] = 0;
	cnt[3] = 0;
	for (int i=0; i<n; i++) {
		cin >> a;
		cnt[a]++;	
	}
	bd[0][0][0] = 0;
	bd[1][0][0] = n;
	cout.precision(17);
	cout << eat(cnt[1], cnt[2], cnt[3]) << "\n";
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    string S; cin >> S;
    vector<int> c(26, 0);
    rep(i, S.size()) c[S[i] - 'a']++;
    rep(i, 26) {
        if (c[i] > 1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

int main() {
  int a, b;
  std::cin >> a >> b;
  if (std::abs(a - b) > 1) {
    std::cout << ":(" << std::endl;
  } else {
    std::cout << "Yay!" << std::endl;
  }
}


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

#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

vec<vec<int>> gen(vec<int> &x, int a) {
    int n = $(x);
    vec<short> h_bit((1ll << n));
    for (int mask = 2; mask < (1ll << n); ++mask) {
        h_bit[mask] = h_bit[mask / 2] + 1;
    }
    vec<short> s((1ll << n));
    s[1] = x[0];
    for (int mask = 2; mask < (1ll << n); ++mask) {
        s[mask] = (x[h_bit[mask]] + s[mask ^ (1ll << h_bit[mask])]);
    }
    vec<vec<int>> ans($(x) + 1, vec<int>(1250 + 1, 0));
    for (int mask = 0; mask < (1ll << n); ++mask) {
        int cnt = __builtin_popcount(mask);
        ans[cnt][s[mask]]++;
    }
    return ans;
}

void solve() {
    int n, a;
    cin >> n >> a;
    vec<int> x(n);
    cin >> x;
    if (n == 1) {
        if (x[0] == a) {
            cout << 1 << endl;
        }
        else {
            cout << 0 << endl;
        }
        return;
    }

    vec<int> v1, v2;
    for (int i = 0; i < n / 2; ++i) {
        v1.pb(x[i]);
    }
    for (int i = n / 2; i < n; ++i) {
        v2.pb(x[i]);
    }

    int ans = 0;
    vec<vec<int>> V1 = gen(v1, a), V2 = gen(v2, a);
    for (int k1 = 0; k1 < $(V1); ++k1) {
        for (int k2 = 0; k2 < $(V2); ++k2) {
            if (k1 + k2 == 0) continue;
            for (int i = 0; i < $(V1[k1]); ++i) {
                if (a * (k1 + k2) - i >= $(V2[k2]) || a * (k1 + k2) - i < 0) continue;
                ans += V1[k1][i] * V2[k2][a * (k1 + k2) - i];
            }
        }
    }

    cout << ans << endl;
}

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

int const N = 100*1000 + 16;
int const M = 1000*1000*1000 + 7;

int n, m;

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

  cin >> n >> m;
  set<int> one;
  vector<pair<int,int>> e(m);
  for(int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    e[i] = {u,v};
    if(u == 1) one.insert(v);
    if(v == 1) one.insert(u);
  }

  bool can = false;

  for(int i = 0; not can && i < m; ++i) {
    int u, v;
    tie(u, v) = e[i];
    if(u == n) can |= one.find(v) != one.end();
    if(v == n) can |= one.find(u) != one.end();
  }

  cout << (can ? "POSSIBLE" : "IMPOSSIBLE");
}

Measured memory_bytes: 6528
n= int(input())
h= list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
#print(dp)
print(dp[n-1])


Measured memory_bytes: 13928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int n,k;
	ll h[200000];
	
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> h[i];

	sort(h,h+n);
	reverse(h,h+n);

	for(int i=0;i<k;i++) h[i] = 0;

	ll sum = 0;
	for(int i=0;i<n;i++) sum += h[i];

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<set>
#include<unordered_map>
#include<vector>
typedef long long ll;
using namespace std;
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 1010
#define M 200010
vector<int>G[N];
int a[M],b[M],vis[2][N][N];
void dfs(int mod,int a,int b,int col){
	if(vis[mod][a][b])return;
	vis[mod][a][b]=col;
	for(auto q:G[b])dfs(mod,a,q,col);
}
int main(){
	int i,j,n,m;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&a[i],&b[i]);
		G[a[i]].pb(b[i]);
	}
	for(i=1;i<=n;i++){
		vis[0][i][i]=vis[1][i][i]=1;
		for(j=0;j<G[i].size();j++)dfs(0,i,G[i][j],j+1);
		for(j=G[i].size()-1;j>=0;j--)dfs(1,i,G[i][j],j+1);
	}
	for(i=1;i<=m;i++){
		int x=(vis[0][a[i]][b[i]]!=vis[1][a[i]][b[i]]);
		int y=vis[0][b[i]][a[i]]!=0;
		if(x^y)printf("diff\n");
		else printf("same\n");
	}
	return 0;
}

Measured memory_bytes: 12288
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())

move_i = 0
move_j = 0

result = []

for i in range(1, int(math.sqrt(N))+1):
    if N % i == 0:
        cnt = i - 1 + (N//i - 1)
        result.append(cnt)

ans = min(result) 

print(ans)


Measured memory_bytes: 66280
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int a[200000];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &a[i]);
		a[i] -= i + 1;
	}
	sort(a, a + n);
	LL ret = 0;
	REP(i, n)ret += abs(a[i] - a[n / 2]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
int main(){
    string str;
    int sum = 0;
    string ans = "0";
    while(cin >> str){
        bool flg = true;
        for(int i = 0; i < str.size(); i++){
            if(isdigit(str[i])){
                if(flg){
                    ans += str[i];
                }
                else{
                    ans = str[i];
                    flg = true;
                }
            }
            else{
                sum += atoi(ans.c_str());
                flg = false;
                ans= "0";
            }
        }
        sum += atoi(ans.c_str());
        ans = "0";
    }
    printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
} 
int main(){
   fast_io
   ll a,b,c;
   cin>>a>>b>>c;
   ll sum = a+b+c;
   if(sum >= 22){
      cout<<"bust"<<endl;
   }
   else{
      cout<<"win"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>

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

typedef long long ll;

int main()
{
    
    int n;
    cin >> n;
    double ans = double(n - (n / 2)) / n;
    //((n % 2) + (2 / n)) / n);
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 256
def c_time3_or_div2(N, A):
    ans = 0  # Aの各要素の因数2の個数の和
    for a in A:
        while a % 2 == 0:
            ans += 1
            a //= 2
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(c_time3_or_div2(N, A))

Measured memory_bytes: 4404
import java.util.Scanner;

public class Main {

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

		int ans = (a-1)*(b-1);

		System.out.println(ans);
		sc.close();

	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b>c*d)cout<<a*b<<endl;
	else cout<<c*d<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int main(){

    int N;cin >> N;

    auto a = make_vec<int>(N,3);;
    REP(i,N) cin >> a[i][0] >> a[i][1] >> a[i][2];
  
    auto dp = make_vec<int>(N+1,3);
    fill_v(dp,0);

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    REP(i,N-1){
        dp[i+1][0]=max(dp[i][1],dp[i][2])+a[i+1][0];
        dp[i+1][1]=max(dp[i][2],dp[i][0])+a[i+1][1];
        dp[i+1][2]=max(dp[i][0],dp[i][1])+a[i+1][2];
    }
    
    pl(max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])))

    return 0;
}

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

int main () {
	string s;
  	cin >> s;
  	if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
    }
  	else {
    cout << "No" << endl;
    }
}

Measured memory_bytes: 256
while True:
    data = input()
    if data == "#": break
    data = data.split()
    y = int(data[1])
    m = int(data[2])
    d = int(data[3])

    if 31 > y or (y == 31 and 4 >= m):
        print("HEISEI {} {} {}".format(y,m,d))
    else:
        new_y = y - 31 + 1
        print("? {} {} {}".format(new_y,m,d))



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

main () {
  ll w, h, x, y;
  scanf("%lld %lld %lld %lld", &w, &h, &x, &y);

  bool b1 = w%2==0 && x==w/2;
  bool b2 = h%2==0 && y==h/2;
  printf("%lf %d\n", w*h/2.0, b1 && b2 ? 1 : 0);
  return 0;
}


Measured memory_bytes: 256
#C - Candies
N = int(input())
A = [input().split(),input().split()]
award = [[],[]]
for i in range(2):
    for j in range(N):
        A[i][j] = int(A[i][j])
        award[i] += [0]


for i in range(2):
    for j in range(N):
        if i == 0 and j == 0:
            award[i][j] = A[i][j]
        elif i == 0:
            award[i][j] = award[i][j-1] + A[i][j]
        elif j == 0:
            award[i][j] = award[i-1][j] + A[i][j]
        else:
            award_right = award[i][j-1] + A[i][j]
            award_down  = award[i-1][j] + A[i][j]
            award[i][j] = max(award_right,award_down)
print(award[1][N-1])

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

int main()
{
  
  vector<int> v(32);
  v[0]=1;v[1]=1;v[2]=1;v[3]=2;v[4]=1;v[5]=2;v[6]=1;v[7]=5;
  v[8]=2;v[9]=2;v[10]=1;v[11]=5;v[12]=1;v[13]=2;v[14]=1;v[15]=14;
  v[16]=1;v[17]=5;v[18]=1;v[19]=5;v[20]=2;v[21]=2; v[22]=1;v[23]=15;
  v[24]=2;v[25]=2;v[26]=5;v[27]=4;v[28]=1;v[29]=4;v[30]=1;v[31]=51;
 long k;
  cin>>k;
  cout<<v[k-1]<<endl;
}


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

using namespace std;

string dat[6] = 
{"..rr....", "..rr....", "ggyybbww", "ggyybbww", "..oo....", "..oo...."};

void funcU(){
	string tmp[6];
	for(int i=0;i<6;i++) tmp[i] = dat[i];
	dat[2][0] = tmp[2][2];
	dat[2][1] = tmp[2][3];
	dat[2][2] = tmp[2][4];
	dat[2][3] = tmp[2][5];
	dat[2][4] = tmp[2][6];
	dat[2][5] = tmp[2][7];
	dat[2][6] = tmp[2][0];
	dat[2][7] = tmp[2][1];
	dat[0][2] = tmp[1][2];
	dat[1][2] = tmp[1][3];
	dat[1][3] = tmp[0][3];
	dat[0][3] = tmp[0][2];
}

void funcF(){
	string tmp[6];
	for(int i=0;i<6;i++) tmp[i] = dat[i];
	dat[1][2] = tmp[3][1];
	dat[1][3] = tmp[2][1];
	dat[2][1] = tmp[4][2];
	dat[3][1] = tmp[4][3];
	dat[4][2] = tmp[3][4];
	dat[4][3] = tmp[2][4];
	dat[2][4] = tmp[1][2];
	dat[3][4] = tmp[1][3];
	dat[2][2] = tmp[3][2];
	dat[3][2] = tmp[3][3];
	dat[3][3] = tmp[2][3];
	dat[2][3] = tmp[2][2];
}

void funcR(){
	string tmp[6];
	for(int i=0;i<6;i++) tmp[i] = dat[i];
	dat[0][3] = tmp[2][3];
	dat[1][3] = tmp[3][3];
	dat[2][3] = tmp[4][3];
	dat[3][3] = tmp[5][3];
	dat[4][3] = tmp[3][6];
	dat[5][3] = tmp[2][6];
	dat[2][6] = tmp[1][3];
	dat[3][6] = tmp[0][3];
	dat[2][4] = tmp[3][4];
	dat[3][4] = tmp[3][5];
	dat[3][5] = tmp[2][5];
	dat[2][5] = tmp[2][4];
}

void funcD(){
	string tmp[6];
	for(int i=0;i<6;i++) tmp[i] = dat[i];
	dat[3][0] = tmp[3][6];
	dat[3][1] = tmp[3][7];
	dat[3][2] = tmp[3][0];
	dat[3][3] = tmp[3][1];
	dat[3][4] = tmp[3][2];
	dat[3][5] = tmp[3][3];
	dat[3][6] = tmp[3][4];
	dat[3][7] = tmp[3][5];
	dat[4][2] = tmp[5][2];
	dat[5][2] = tmp[5][3];
	dat[5][3] = tmp[4][3];
	dat[4][3] = tmp[4][2];
}

void funcB(){
	string tmp[6];
	for(int i=0;i<6;i++) tmp[i] = dat[i];
	dat[0][2] = tmp[2][5];
	dat[0][3] = tmp[3][5];
	dat[2][5] = tmp[5][3];
	dat[3][5] = tmp[5][2];
	dat[5][2] = tmp[2][0];
	dat[5][3] = tmp[3][0];
	dat[2][0] = tmp[0][3];
	dat[3][0] = tmp[0][2];
	dat[2][6] = tmp[3][6];
	dat[3][6] = tmp[3][7];
	dat[3][7] = tmp[2][7];
	dat[2][7] = tmp[2][6];
}

void funcL(){
	string tmp[6];
	for(int i=0;i<6;i++) tmp[i] = dat[i];
	dat[0][2] = tmp[3][7];
	dat[1][2] = tmp[2][7];
	dat[2][7] = tmp[5][2];
	dat[3][7] = tmp[4][2];
	dat[4][2] = tmp[2][2];
	dat[5][2] = tmp[3][2];
	dat[2][2] = tmp[0][2];
	dat[3][2] = tmp[1][2];
	dat[2][0] = tmp[3][0];
	dat[3][0] = tmp[3][1];
	dat[3][1] = tmp[2][1];
	dat[2][1] = tmp[2][0];
}

int main(){
	string in;
	cin >> in;
	for(int i=0;i<in.size();i++){
		//for(int j=0;j<6;j++) cout << dat[j] << endl; cout << endl;
		if(in[i] == 'U') funcU();
		else if(in[i] == 'F') funcF();
		else if(in[i] == 'R') funcR();
		else if(in[i] == 'D') funcD();
		else if(in[i] == 'B') funcB();
		else if(in[i] == 'L') funcL();
	}
	for(int i=0;i<6;i++) cout << dat[i] << endl;
	return 0;
}

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

int main () {
	int n;
	cin >> n;
	int F[50];
	F[0] = F[1] = 1;
	for (int i=2; i<=n; ++i) F[i] = F[i-1] + F[i-2];
	cout << F[n] << endl;
	return 0;
}




Measured memory_bytes: 3084
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def main():
    n,q=MI()
    s=SI()
    cs=[0]*(n+1)
    for i in range(n-1):
        if s[i:i+2]=="AC":cs[i+2]+=1
    for i in range(n):cs[i+1]+=cs[i]
    for _ in range(q):
        l,r=MI()
        l,r=l-1,r-1
        ans=cs[r+1]-cs[l]
        if s[l-1:l+1]=="AC":ans-=1
        print(ans)

main()


Measured memory_bytes: 8212
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << char(toupper(s1.at(0))) << char(toupper(s2.at(0))) << char(toupper(s3.at(0))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;

int main(){
    string s;
    std::cin >> s;
    int n=s.size();
    std::set<char> a,b;
    rep(i,n){
        if(s[i]=='N'||s[i]=='S')a.insert(s[i]);
        else b.insert(s[i]);
    }
    if(a.size()%2==0&&b.size()%2==0)std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	vector<int> g[n+1];
	vector<int> indegree(n+1, 0);
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		indegree[v]++;
	}    
	int dp[n+1];
	memset(dp, 0, sizeof(dp));
	// dp[i] is the longest directed path ending at vertex i
	vector<int> sources;
	for(int i = 1; i <= n; i++){
		if(indegree[i] == 0){
			sources.push_back(i);
		}
	}
	while(sources.size() > 0){
		vector<int> new_sources;
		for(int i = 0; i < sources.size(); i++){
			for(int ch: g[sources[i]]){
				dp[ch] = max(dp[ch], dp[sources[i]] + 1);
				indegree[ch]--;
				if(indegree[ch] == 0){
					new_sources.push_back(ch);
				}
			}
		}
		sources = new_sources;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, dp[i]);
	}
	cout << ans;
}

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

int main(void) {
    int N;
    long long W;
    cin >> N >> W;
    vector<long long> w(N);
    vector<long long> v(N);
    vector<vector<long long>> dp(N + 1, vector<long long>(100100, 1e18 + 1));
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 100100; j++) {
            if (j - v[i - 1] >= 0) {
                dp[i][j] =
                    min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 100100; i++) {
        if (dp[N][i] <= W) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>

int a,b,c,x,count;

int main() {
  count = 0;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  for (size_t i = 0; i <= a; i++) {
    for (size_t j = 0; j <= b; j++) {
      for (size_t k = 0; k <= c; k++) {
        if(500 * i + 100 * j + 50 * k == x) count++;
      }
    }
  }
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
from collections import deque

H, W = map(int, input().split(' '))

maze = []
white_count = 0
for _ in range(H):
    line = list(input())
    white_count += line.count('.')
    maze.append(line)

queue = deque()
queue.append((0, 0, 1))

min_step = -1
while len(queue) > 0:
    y, x, step = queue.popleft()
    if maze[y][x] != '.':
        continue
    else:
        maze[y][x] = '#'

    if y == H - 1 and x == W - 1:
        min_step = step
        break

    for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        ny = y + dy
        nx = x + dx

        if 0 <= ny < H and 0 <= nx < W:
            queue.append((ny, nx, step + 1))

if min_step == -1:
    print(min_step)
else:
    print(white_count - min_step)


Measured memory_bytes: 3316
#include<stdio.h>

int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;

	printf("%d %d %7.5f",d,r,f);
	return 0;
}

Measured memory_bytes: 640
n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
lst=[0]
now=0
memo=0
town=[0]*n
town[0]=1
b=0
for i in range(k):
	now=a[now]
	if town[now]==1:
		memo=now
		b=1
		break
	lst.append(now)
	town[now]=1
if b==1:
	i=lst.index(memo)
	l=len(lst)
	if memo!=0:
		lst=lst[i:]
		l-=len(lst)
		print(lst[(k-l)%len(lst)]+1)
	else:
		print(lst[k%l]+1)
else:
	print(now+1)

Measured memory_bytes: 32392
def cut_and_count():
    n = int(input())
    s = input()

    ans = 0
    for i in range(1, n):
        count = 0
        left = s[:i]
        right = s[-(n - i):]
        left_set = list(set(left))
        right_set = list(set(right))

        if left_set >= right_set:
            for j in range(len(right_set)):
                if right_set[j] in left_set:
                    count += 1
        else:
            for k in range(len(left_set)):
                if left_set[k] in right_set:
                    count += 1

        ans = max(count, ans)

    print(ans)


if __name__ == '__main__':
    cut_and_count()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long n,i;
	cin>>n;
	long long a[n];
	for (i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	i=0;
	long long ans=0;
	while(i<n-1){
		//cout<<i<<n<<endl;
		///Sleep(500);
		if (a[i]==a[i+1]){
			int j=i+2;
			i++;
			if (j>=n)continue;
			while(j<n-1&&a[j]!=a[j+1])j++;
			if (j<n-1)ans=max(ans,a[j]*a[i]);
		}
		else i++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;


int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i!=N;++i){
        cin>>A[i];
    }
    bool jud=false;
    for(int i=0;i!=N;++i){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                jud=true;
                break;
            }
        }
    }
    
    if(jud==false){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
}


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

struct union_find{
    union_find(int n){
        parent = vector<int>(n, -1);
        weight = vector<int>(n, 0);
    }
    int find(int x){
        if(parent[x] < 0) return x;
        else return parent[x] = find(parent[x]);
    }
    bool isSame(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){
            weight[x]++;
            return;
        }
        if(parent[x] < parent[y]) swap(x,y);
        parent[x] += parent[y];
        parent[y] = x;
        weight[x] += weight[y] + 1;
    }
    int getSize(int x){
        return -parent[find(x)];
    }
    int getWeight(int x){
        return weight[find(x)];
    }

    private:
        vector<int> parent;
        vector<int> weight;
};

int main(){
    int N, M;  cin >> N >> M;
    vector<ll> a(N);
    for(ll &v : a) cin >> v;

    union_find uf(N);
    for(int i=0; i<M; i++){
        int x, y;  cin >> x >> y;
        uf.unite(x, y);
    }

    map<int, int> roots;
    for(int i=0; i<N; i++){
        int root = uf.find(i);
        if(roots.find(root) == roots.end()){
            roots[root] = i;
        }else{
            int idx = roots[root];
            if(a[idx] > a[i]){
                roots[root] = i;
            }
        }
    }

    int X = roots.size();
    if(2*(N-1-M) > N){
        cout << "Impossible" << endl;
        return 0;
    }else if(M == N-1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    vector<bool> used(N, false);
    for(auto p : roots){
        used[p.second] = true;
        ans += a[p.second];
    }

    priority_queue<int, vector<int>, greater<int>> que;
    for(int i=0; i<N; i++){
        if(!used[i]){
            que.push(a[i]);
        }
    }
    for(int i=0; i<2*(N-1-M) - X; i++){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z, r;
  i = 1;
  r = 7 % n;
  while (i <= n && r != 0) {
    r = (r * 10 + 7) % n;
    i++;
  }
  if (r == 0) cout << i;
  else cout << -1;
  return 0;
}


Measured memory_bytes: 3656