akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

// coordinate compression
struct X {
  typedef int T;
  vector<T> d;
  inline void add(T x) { d.pb(x);}
  void init() {
    sort(rng(d));
    d.erase(unique(rng(d)), d.end());
  }
  inline int size() { return sz(d);}
  inline T operator[](T x) { return lower_bound(rng(d),x)-d.begin();}
};
//

int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  rep(i,n) scanf("%d",&a[i]);
  X xs;
  rep(i,n) xs.add(a[i]);
  xs.init();
  rep(i,n) a[i] = xs[a[i]];
  int cnt = 0;
  rep(i,n) {
    if (i&1) {
      if (a[i]%2 == 0) cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}










Measured memory_bytes: 1276
def main():
    N, a, b = (int(i) for i in input().split())
    ans = 0
    for i in range(1, N+1):
        S = str(i)
        cur = 0
        for s in S:
            cur += int(s)
        if a <= cur <= b:
            ans += i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	bool flag=false;
	int cnt=0;
	while(A>0&&C>0){
		cnt++;
		if(cnt&1){
			C-=B;
		}else{
			A-=D;
		}
	}
	if(A>0) flag=true;
	cout<<(flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3652
a,b,c = gets.split(" ").map!{|p| p.to_i}
#d 食べられるｃの最大値
if c > a + b 
  d = a + b + 1
elsif c == a + b
  d = a + b
else 
  d = c
end
# e 食べるおいしいクッキーの最大値
e = b + d
puts e


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool comp(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first > b.first;
    }else{
        return a.second > b.second;
    }
}

int main()
{
ll n ;
cin >> n ;
pair<ll,ll> f[n];
pair<ll,ll> b[n];
map<pair<ll,ll>,ll> s;
map<pair<ll,ll>,ll> ss;
ll ans = 0;
ll anss = 0;
rep(i,n){
  cin >> f[i].first >> f[i].second ;
  b[i]=f[i];
  s[f[i]]++;
  ss[f[i]]++;
}
sort(f,f+n,comp);
sort(b,b+n,compare_by_b);
bool te=1;
ll ff=0,bb=0;
ll now=0;
ll cnt=0;
while(cnt!=n){
  if(te){
      if(s.find(b[bb])!=s.end()&&s[b[bb]]>0){
      if(now>b[bb].second){ans+=now-b[bb].second;
      now=b[bb].second;}
      s[b[bb]]--;
      te=!te;
      cnt++;
    }
    bb++;
  }
  else{
    if(s.find(f[ff])!=s.end()&&s[f[ff]]>0){
      if(now<f[ff].first){ans+=f[ff].first-now;
      now=f[ff].first;}
      s[f[ff]]--;
      te=!te;
      cnt++;
    }
    ff++;
  }
}
ans+=abs(now);

te=0;
ff=0,bb=0;
now=0;
cnt=0;
while(cnt!=n){
  if(te){
      if(ss.find(b[bb])!=ss.end()&&ss[b[bb]]>0){
      if(now>b[bb].second){anss+=now-b[bb].second;
      now=b[bb].second;}
      ss[b[bb]]--;
      te=!te;
      cnt++;
    }
    bb++;
  }
  else{
    if(ss.find(f[ff])!=ss.end()&&ss[f[ff]]>0){
      if(now<f[ff].first){anss+=f[ff].first-now;
      now=f[ff].first;}
      ss[f[ff]]--;
      te=!te;
      cnt++;
    }
    ff++;
  }
}
anss+=abs(now);
cout << max(ans,anss) << endl;
return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(k, a);
  k -= min(k, a);
  if (k > 0) {
    k -= min(k, b);
    if (k > 0) {
      ans -= min(k, c);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
def gcd(a, b):
    while b != 0:
        t = b
        b = a % b
        a = t
    return a

def tgcd(a, b, c):
    return  gcd(a, gcd(b, c))

K = int(input())
total = 0

# 3 scenarios
# X-X-X
# X-X-Y
# X-Y-Z

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            total += tgcd(a, b, c)

        
print(total)
#total += sum(range(1, 201))
#print(total + sum(range(1,201)))
#print("diff", 10813692-total)

Measured memory_bytes: 68720
import Control.Applicative
import Data.List

type Dice = [Int]

rot :: Dice -> Char -> Dice
rot d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]
rot d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
rot d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
rot d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
rot _ _ = undefined

solve :: [String] -> String
solve [labels,cmds] =
    let dice = [read s | s<-words labels] :: Dice in
    show . head $ foldl' rot dice cmds

main =
    putStrLn =<< solve . take 2 . lines <$> getContents

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

#define int long long
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; }

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

	int num[310];

	int Y = 0;
	for(int i = 0;i < n;i++){
		cin >> num[i];
		if(i > 1) Y ^= num[i];
	}

	int c = 0;

	int X = num[0] + num[1];

	int A = num[0];
	int B = num[1];

	int a = 0, b = 0;

	if(X < Y || ((X-Y) & 1)){
		 cout << -1 << endl;
		 return 0;
	}

	int ze = ((X-Y) >> 1);

	a = ze;
	b = ze;
	if((b & Y) || a > A || (b|Y) < B){
		cout << -1 << endl;
		return 0;
	}

	b |= Y;

	for(int i = 60ll;i >= 0;i--){
		if(Y & (1ll << i)){
			if((a + (1ll << i)) <= A && (b - (1ll << i)) >= B){
				a += (1ll << i);
				b -= (1ll << i);
			} 
		}
	}
	if(a == 0){
		cout << -1 << endl;
		return 0;
	}
	cout << A-a << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int n = s.size();
  for (int i = 0; i < n-1; i++) {
    if (s[i] == 'C') {
      for (int j = i+1; j < n; j++) {
        if (s[j] == 'F') {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
int main()
{
	string s,t;
	cin >> s >> t;
	int m = s.length(),n=t.length();
	//output the longest sstring subsequence
	vector<vector<ll>>dp(m+1,vector<ll>(n+1,0));
	int l=0,row=0,col=0;
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(i==0||j==0)
			{
				dp[i][j]=0;
			}
			else if(s[i-1]==t[j-1])
			{
				dp[i][j]= dp[i-1][j-1]+1;
			}
			else
				dp[i][j]=max({dp[i-1][j-1],dp[i][j-1],dp[i-1][j]});
		}
	}
/*	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			ans = max(ans,dp[i][j]);
		}
	}*/
	ll i=m,j=n;
	string x="";
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			x+=t[j-1];
			i--;
			j--;
		}
		else if(dp[i][j-1]<dp[i-1][j])
		{
			i--;
		}
		else
		{
			j--;
		}
	}
	reverse(x.begin(),x.end());
	cout << x << endl;
}

Measured memory_bytes: 35584
#include <stdio.h>

int main(void)
{
  int k,s,x,y,z,i,j;
  int ans = 0;
  
  scanf("%d %d", &k, &s);
  
  for (i = 0; i <= k; i++){
    for (j = 0; j <= k; j++){
      if ((k >= (s-(i+j)))&&((s-(i+j)) >= 0)){
        ans++;
      }
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int n,x,count,timer=0;
    cin >>n>>x;
    while(n!=0 || x!=0){
        count = 0;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                for(int k=1;k<=n;k++)
                    if(i+j+k==x && i!=j && j!=k && i!=k)
                        count += 1;
        cout <<count/6<<endl;
        cin >>n>>x;
    }
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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


  int i;
  //--------------------------
  // 入力データ
  //--------------------------
  // 入力総数の取得
  scanf("%d", &num);
  //--------------
  // 改行コードの削除
  while(getchar()!='\n'){
  	;
  }
  //---------------
  // 数値データの取得
  char *str = NULL;  
  str = malloc(sizeof(char) * 10 * num + num); 
  fgets(str, sizeof(char) * 10 * num + num, stdin);
  //--------------------------
  // 数値変換
  //--------------------------  
  int *data = NULL;
  data = malloc(sizeof(int) * num);
  data[0] = atoi(strtok(str, " "));
  for(i=1; i<num; i++){
  	data[i] = atoi(strtok(NULL, " "));
  }  


  //--------------------------  
  // 操作判定
  //--------------------------
  int mod;
  int cnt = 0;
  int flg = 1;
  while(flg) {
    for(i=0; i<num; i++){
      mod = data[i] % 2;
      if(mod == 1) {
		flg = 0;
        break;
      } 
    }
    if(!flg) break;
    cnt++;
    for(i=0; i<num; i++){
      data[i] = data[i] / 2;
    }  
  } 
  printf("%d\n", cnt);

  return 0;
}  


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  int ans = 0;
  int acnt = 0;
  int bcnt = 0;
  int dcnt = 0;
  rep(i,n){
    string s;
    cin >> s;
    if(s[0]=='B') bcnt++;
    if(s.back()=='A') acnt++;
    if(s[0]=='B' && s.back()=='A') dcnt++;
    string find_word = "AB";
    auto pos = s.find(find_word);
    while(pos != std::string::npos){
      ans++;
      pos = s.find(find_word, pos + find_word.length());
    }
  }
  ans += min(acnt, bcnt);
  if(acnt==bcnt && acnt==dcnt && acnt!=0) ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	
	string s; cin>>s;
	cout<<(s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3652
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s, w = IL()

if s <= w:
  print("unsafe")
else:
  print("safe")

Measured memory_bytes: 65220
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int k, q;
	cin >> k >> q;
	vector<int> d(k);
	rep(i, 0, k) cin >> d[i];
	while(q--){
		int n, x, m;
		cin >> n >> x >> m;
		vector<int> r(k);
		rep(i, 0, k) r[i] = d[i] % m;
		int ans = n - 1;
		int sum = x % m;
		rep(i, 0, k){
			int cnt = (n - 1) / k;
			int tmp = (n - 1) % k;
			if(i < tmp) cnt++;
			if(r[i] == 0) ans = ans - cnt;
			else sum = sum + r[i] * cnt;
		}
		ans = ans - sum / m;
		cout << ans << endl;
	}
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 101010
using namespace std;

vi g[MAXN];

void dfs(int cur , int pr , vi & used , vi & prev){
	used[cur] = 1;
	prev[cur] = pr;
	
	for(int v : g[cur]){
		if(!used[v]){
			dfs(v , cur , used , prev);
		}
	}
}

int dfs2(int cur , vi & used){
	used[cur] = 1;
	int res = 1;
	for(int v : g[cur]){
		if(!used[v]){
			res += dfs2(v , used);
		}
	}
	return res;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	
	int n;
	cin >> n;
	
	rep(i , n - 1){
		int u , v;
		cin >> u >> v;
		--u;
		--v;
		g[v].pb(u);
		g[u].pb(v);
	}
	
	vi used(n);
	vi prev(n);

	dfs(0 , -1 , used , prev);
	
	
	vi used2(n);
	int len = 1;
	


	int cur = n - 1;
	vi d;
	while(prev[cur] != -1){
		used2[cur] = 1;
		d.pb(cur);
		cur = prev[cur];
		++len;
	}
	used2[0] = 1;
	d.pb(0);
	
	reverse(all(d));
	
	int cnt1 = 0 , cnt2 = 0;
	rep(i , len){
		if(i - (len & 1) < len / 2){
//			cout << d[i] << " :1\n";
			cnt1 += dfs2(d[i] , used2);
		}else{
			cnt2 += dfs2(d[i] , used2);
		}
	}
	
	cout << (cnt1 > cnt2 ? "Fennec" : "Snuke");
//	cout << cnt1 << " " << cnt2 << nl;
	
	

	return 0;
}

Measured memory_bytes: 12284
#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>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
  int N;
  string S;
  int K;
  cin >>N>>S>>K;
  char l=S[K-1];
  REP(i,N){
    if(S[i]!=l){
      S[i]='*';
    }
  }
  cout <<S<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int n,A[107]; 
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&A[i]);
	int ans=0;
	For(i,1,n)
		For(j,i+1,n)
		ans+=A[i]*A[j];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int MAXN = 500;
const int MAXM = 10000;
bool vis[MAXM + 5];
int prm[MAXM + 5], pcnt = 0;
ll GCD(ll x, ll y) {
	return y == 0 ? x : GCD(y, x%y);
}
ll LCM(ll x, ll y) {
	return x / GCD(x, y) * y;
}
void sieve() {
	for(int i=2;i<=MAXM;i++) {
		if( !vis[i] ) prm[++pcnt] = i;
		for(int j=1;i*prm[j]<=MAXM;j++) {
			vis[i*prm[j]] = true;
			if( i % prm[j] == 0 ) break;
		}
	}
}
ll Mat[MAXN + 5][MAXN + 5];
int main() {
	sieve(); int N;
	scanf("%d", &N);
	if( N == 2 ) {
		printf("4 7\n23 10\n");
		return 0;
	}
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			Mat[i][j] = 1;
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			if( (i & 1) == (j & 1) ) {
				Mat[i][j] = prm[(i + j) / 2] * prm[(i+N+1-j)/2 + N];
				Mat[i+1][j] = LCM(Mat[i+1][j], Mat[i][j]);
				Mat[i-1][j] = LCM(Mat[i-1][j], Mat[i][j]);
				Mat[i][j+1] = LCM(Mat[i][j+1], Mat[i][j]);
				Mat[i][j-1] = LCM(Mat[i][j-1], Mat[i][j]);
			}
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++)
			if( (i & 1) != (j & 1) )
				Mat[i][j]++;
	for(int i=1;i<=N;i++) {
		for(int j=1;j<N;j++)
			printf("%lld ", Mat[i][j]);
		printf("%lld\n", Mat[i][N]);
	}
}

Measured memory_bytes: 5120
#include <stdio.h>
#define MAX 1000001
#define MIN -1000001
int main()
{
	//input
	int N,a_i,max=MIN,min=MAX;
	long long sum=0;
	scanf("%d",&N);
	//algorithm
	while(N--)
	{
		scanf("%d",&a_i);
		if(max<a_i) max=a_i;
		if(min>a_i) min=a_i;
		sum+=a_i;
	}
	//output
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2752
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int num=0,left,right;
  string s;
  cin>>s;
  left=s.size()/2-1;
  right=s.size()/2;
  if(s.size()&1){
    if(s[right]!='i' && s[right]!='w')num++;
    right++;
  }
  while(left>=0){
    if( s[left]=='i' || s[left]=='w' ){
      if(s[left]!=s[right])num++;
    }else if(s[left]=='('){
      if(s[right]!=')')num++;
    }else if(s[left]==')'){
      if(s[right]!='(')num++;
    }
    left--;
    right++;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 0
n = input()
n_list = list(n)
for i in range(3):
    
    if n_list[i] == '1':
        n_list[i] = '9'
    elif n_list[i] == '9':
        n_list[i] = '1'
n_c = "".join(n_list)
print(n_c)

Measured memory_bytes: 9068
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

// typedef std::numeric_limits< double > dbl;

int main(void){
	int n;
	cin >> n;
	vector<double> p(n);
	vector<vector<double> > dp(n, (vector<double>(n+1,1)));
	for(int i = 0;i < n;i++)
		cin >> p[i];
	dp[0][0] = 1 - p[0];
	dp[0][1] = p[0];
	for(int i = 1;i < n;i++){
		dp[i][0] = (1-p[i])*dp[i-1][0];
		for(int j = 1;j <= i;j++){
			dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
		}
		dp[i][i+1] = dp[i-1][i] * p[i];
	}
	int minn = n/2 + 1;
	double ans = 0.0;
	for(int i = minn;i <= n;i++){
		if(dp[n-1][i] != 1)
			ans += dp[n-1][i];
	}
	cout.precision(10);
	cout << ans << endl;
}

Measured memory_bytes: 70656
from itertools import product
n = int(input())
li = list(product([1,0], repeat=n))
A = [[]] * n
for i in range(n):
  a = int(input())
  A[i] = [list(map(int, input().split())) for _ in range(a)]
  
cnt = 0
for i in li:
  flg = False
  for itr, val in enumerate(i):
    if val == 1:
      if not all([i[x[0]-1] == x[1] for x in A[itr]]):
        flg = True
        break
  if flg == False:
    cnt = max(cnt, sum(i))
print(cnt)
  

Measured memory_bytes: 8820
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>

using namespace std;


int main(int argc, char **argv) {
    int n;
    cin >> n;

    std::vector<int> p(n);
    for (int i=0; i<n; ++i) {
        cin >> p[i];
    }
    std::sort(p.begin(), p.end());
    int l_half = n / 2 - 1;
    int l_halfp1 = l_half + 1;

    cout << p[l_halfp1] - p[l_half] << endl;

    return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

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

    int N;
    cin >> N;

    vector<int> Adiv(N);
    LL A, cnt;
    REP(N) {
        cnt = 0;
        cin >> A;
        while(A % 2 != 1) {
            A /= 2;
            cnt++;
        }
        Adiv[i] = cnt;
    }

    sort(ALL(Adiv));
    cout << Adiv[0] << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
n,k=map(int, input().split())
a=np.array(list(map(int, input().split())))
b=np.maximum(a,0)
sm=sum(a[:k])
at=sum(b[k:])
ans=max(sm,0)+at
for i in range(k,n):
    sm+=a[i]-a[i-k]
    at+=b[i-k]-b[i]
    ans=max(max(0,sm)+at,ans)
print(ans)

Measured memory_bytes: 23172
import java.util.Scanner;

public class Main {

    private static int[] finalCount;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();

        char[] chars = line.toCharArray();
        finalCount = new int[chars.length];
        for (int i=0; i<chars.length; i++) {
            finalCount[i] = 0;
        }

        int initialPosition = 0;
        while (initialPosition < chars.length) {
            initialPosition = process(initialPosition, chars);
        }

        for (int i=0; i<chars.length; i++) {
            System.out.print(finalCount[i]);
            if (i != chars.length-1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }

    private static int process(int initialPosition, char[] chars) {
        int currentSectionCount = 0;
        int nextStopLeftPosition = 0;
        int nextStopRightPosition = 0;
        int nextSectionStartPosition = chars.length;

        for (int i=initialPosition; i<chars.length; i++) {
            // chars[initialPosition] must be 'R'.
            if (chars[i] == 'L') {
                nextStopLeftPosition = i-1;
                nextStopRightPosition = i;
                break;
            }
        }

        for (int i=nextStopRightPosition; i<chars.length; i++) {
            if (chars[i] == 'R') {
                nextSectionStartPosition = i;
                break;
            }
        }

        for (int i=initialPosition; i<nextSectionStartPosition; i++) {
            if ((nextStopLeftPosition - i) % 2 == 0) {
                finalCount[nextStopLeftPosition]++;
            } else {
                finalCount[nextStopRightPosition]++;
            }
        }

        return nextSectionStartPosition;
    }

}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<vector<ll>> cnt(10, vector<ll>(10, 0));
    rep2(i, 1, N + 1) {
        ll start = 0;
        ll j = i;
        while (j >= 10) {
            j /= 10;
        }
        cnt[j][i % 10]++;
    }
    ll ans = 0;
    rep2(i, 1, 10) {
        rep2(j, 1, 10) {
           ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n; cin >> n;
  if (n > 999) cout << "ABD" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }

    let target: Vec<char> = "ACGT".chars().collect();
    let mut maximum = 0;
    let mut current = 0;
    for c in s {
        if target.contains(&c) {
            current += 1;
        } else {
            maximum = std::cmp::max(maximum, current);
            current = 0;
        }
    }
    maximum = std::cmp::max(maximum, current);

    println!("{}", maximum);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);//一つ目のデータをＡに入れる
            int B = int.Parse(input[1]);//二つ目のデータをＢに入れる

            //13歳以上なら観覧車の代金はＢ円
            //６歳以上１２歳以下なら半額（Ｂ／２）円
            //５歳以下は無料
            if (A >= 13)
            {
                Console.WriteLine(B);
            }
            else if (A>=6)
            {
                Console.WriteLine(B/2);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll l=a[0];
  rep(i,n){
    l=gcd(a[i],l);
  }
  if(l!=1){
    if(k%l!=0){
      COUT("IMPOSSIBLE");
    }
    else if(k>a[n-1]){
      COUT("IMPOSSIBLE");
    }
    else COUT("POSSIBLE");
  }
  else{
    if(k>a[n-1]){
      COUT("IMPOSSIBLE");
    }
    else{
      COUT("POSSIBLE");
    }
  }
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		int answer = 1;
		int deltaN = n;
		int deletableNum = k-1;
		
		while(deltaN > k) {
			deltaN -= deletableNum;
			answer++;
		}
		
		System.out.println(answer);
	}
}


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

int main(void){
    int n, m; cin >> n >> m;
    int a = (n-m)*100 + m*1900;
    int r = 1;
    for(int i  = 0; i < m; i++) r = r*2;
    cout << (int)a*r << endl;
    return 0;
}


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

typedef long long ll;
ll MOD = 998244353;

typedef long long LL;

template<int p> struct FF {
	LL val;

	FF(const LL x=0) { val = (x % p + p) % p; }

	bool operator==(const FF<p>& other) const { return val == other.val; }
	bool operator!=(const FF<p>& other) const { return val != other.val; }

	FF operator+() const { return val; }
	FF operator-() const { return -val; }

	FF& operator+=(const FF<p>& other) { val = (val + other.val) % p; return *this; }
	FF& operator-=(const FF<p>& other) { *this += -other; return *this; }
	FF& operator*=(const FF<p>& other) { val = (val * other.val) % p; return *this; }
	FF& operator/=(const FF<p>& other) { *this *= other.inv(); return *this; }

	FF operator+(const FF<p>& other) const { return FF(*this) += other; }
	FF operator-(const FF<p>& other) const { return FF(*this) -= other; }
	FF operator*(const FF<p>& other) const { return FF(*this) *= other; }
	FF operator/(const FF<p>& other) const { return FF(*this) /= other; }

	static FF<p> pow(const FF<p>& a, LL b) {
		if (!b) return 1;
		return pow(a * a, b >> 1) * (b & 1 ? a : 1);
	}

	FF<p> pow(const LL b) const { return pow(*this, b); }
	FF<p> inv() const { return pow(p - 2); }
};

template<int p> FF<p> operator+(const LL lhs, const FF<p>& rhs) { return FF<p>(lhs) += rhs; }
template<int p> FF<p> operator-(const LL lhs, const FF<p>& rhs) { return FF<p>(lhs) -= rhs; }
template<int p> FF<p> operator*(const LL lhs, const FF<p>& rhs) { return FF<p>(lhs) *= rhs; }
template<int p> FF<p> operator/(const LL lhs, const FF<p>& rhs) { return FF<p>(lhs) /= rhs; }

typedef FF<998244353> num;

num cnt[1000005];
num sum[1000005];

num tot;

int main(){
	int n; cin >> n;
	
	for (int i = 0; i <= 1000000; i++){
		cnt[i] = 0; sum[i] = 0;
	}

	for (int i = 0; i < n; i++){
		int x; cin >> x; cnt[x] = 1 + cnt[x];
		tot += x;
	}

	for (int i = 1; i <= 1000000; i++){
		for (int j = 1; j * i <= 1000000; j++){
			sum[i] += cnt[i * j] * i * j;
		}
		sum[i] *= sum[i];
	}

	for (int i = 1000000; i >= 1; i--){
		for (int j = 2; j * i <= 1000000; j++){
			sum[i] -= sum[i * j];
		}
	}	

	num res = 0;

	for (int i = 1; i <= 1000000; i++){
		res += (sum[i] / i);
	}
	res -= tot;
	res /= 2;
	cout << res.val << endl;
}


Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main(){
  char str[1201];
  int num[26]={0};
  while(cin >> str){
    for(int i = 0;str[i]!='\0';i++){
      if('a'<=str[i] && str[i]<='z')
        num[str[i]-'a']++;
      if('A'<=str[i] && str[i]<='Z')
        num[str[i]-'A']++;
    }
  }
  for(int i = 0;i < 26;i++)
    cout << (char)('a'+i) << " : " << num[i] << endl;
  return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
#define re register
#define ui unsigned int
#define ull unsigned long long
int c[200100],f[200100],fc[200100],n;
struct eg{int to;eg*nx;}e[400100],*la[200100],*cnt=e;
inline void addE(re int a,re int b)
{
	*++cnt=(eg){b,la[a]};la[a]=cnt;
	*++cnt=(eg){a,la[b]};la[b]=cnt;
}
struct nd
{
	int x;nd*l,*r;
}pl[5000100],*cct=pl;
nd*no[200100];
nd*meg(re nd*a,re nd*b)
{
	if(!a)return b;
	if(!b)return a;
	a->x+=b->x;
	a->l=meg(a->l,b->l);
	a->r=meg(a->r,b->r);
	return a;
}
int qus(re nd*a,re int l,re int r,re int l1)
{
	if(!a)return 0;
	if(l==r)return a->x;
	re int mid=(l+r)/2;
	if(l1<=mid)return qus(a->l,l,mid,l1);
	else return (a->l?a->l->x:0)+qus(a->r,mid+1,r,l1);
}
void add(re nd*&a,re int l,re int r,re int l1,re int x1)
{
	if(!a)a=++cct;
	a->x+=x1;
	if(l==r)return;
	re int mid=(l+r)/2;
	if(l1<=mid)add(a->l,l,mid,l1,x1);
	else x1+=(a->l?a->l->x:0),a->l=0,add(a->r,mid+1,r,l1,x1);
}
void dfs(re int a,re int fa)
{
	for(re eg*i=la[a];i;i=i->nx)if(i->to!=fa)
	{
		f[i->to]=std::max(a,f[a]);
		dfs(i->to,a);
		fc[i->to]=qus(no[i->to],1,n,f[a]);
		no[a]=meg(no[a],no[i->to]);
	}
	add(no[a],1,n,a,1);
}
void dfs1(re int a,re int fa,re int x1)
{
	for(re eg*i=la[a];i;i=i->nx)if(i->to!=fa)x1+=fc[i->to];
	c[a]=x1;
	x1++;
	for(re eg*i=la[a];i;i=i->nx)if(i->to!=fa)dfs1(i->to,a,x1-fc[i->to]);
}
int main()
{
	re int x,y;
	scanf("%d",&n);
	for(re int i=1;i<n;i++)scanf("%d%d",&x,&y),addE(x,y);
	dfs(1,0);
	dfs1(1,0,0);
	for(re int i=2;i<=n;i++)printf("%d ",c[i]);
}

Measured memory_bytes: 102912
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

bool comp(P p, P q) {
    if (p.second < q.second)
        return true;
    else if (p.second == q.second && p.first < q.first)
        return true;
    
    return false;
}

int main() {
    int n;  cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; i++) {
        ll l, x;    cin >> l >> x;
        v[i].first = l - x;
        v[i].second = l + x;
    }
    sort(v.begin(), v.end(), comp);

    ll ans = 0, sup = -1e18;
    for (int i = 0; i < n; i++) {
        if (sup <= v[i].first) {
            sup = v[i].second;
            ans++;
        }
    }

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

Measured memory_bytes: 4844
#include <cstdio>
#include <algorithm>

#define rep(i, a, b) for(register int i = a; i <= b; i++)

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	printf("%d", std::max(a + b, (std::max(a - b, a * b))));

	return 0;
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        h: usize, n: usize,
        abv: [(usize, usize); n]
    };

    let inf = 1_usize << 30;
    let mut dp = vec![inf; h + 10];
    dp[0] = 0;
    for i in 0..n {
        let (a, b) = abv[i];
        for j in 0..h {
            let to_j = std::cmp::min(j + a, h);
            dp[to_j] = std::cmp::min(dp[to_j], dp[j] + b);
        }
    }
    println!("{}", dp[h]);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2328
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000  //int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

   string s;
   bool a = false, b = false, c = false, d = false;
   cin >> s;
   REP(i, s.length()){
      if(s[i] == 'N') a = true;
      if(s[i] == 'W') b = true;
      if(s[i] == 'S') c = true;
      if(s[i] == 'E') d = true;
   }
   if(a && b && c && d) cout << "Yes" << endl;
   elif(a && !b && c && !d) cout << "Yes" << endl;
   elif(!a && b && !c && d) cout << "Yes" << endl;
   else cout << "No" << endl;
   rtn 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define ull unsigned long long
#define maxn 505
int s[maxn],t[maxn],br[maxn],bc[maxn],cnt[maxn],a[maxn][maxn];//s[0]:row,and;s[1]:row:or.t[0]:col,and;t[1]:col,or;
ull u[maxn],v[maxn],ans[maxn][maxn];
int main(){
	int i,j,n,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&s[i]);
	for(i=1;i<=n;i++)scanf("%d",&t[i]);
	for(i=1;i<=n;i++)scanf("%llu",&u[i]);
	for(i=1;i<=n;i++)scanf("%llu",&v[i]);
	for(k=0;k<64;k++){//逐位判定，状压
		for(i=1;i<=n;i++)br[i]=((u[i]>>k)&1),bc[i]=((v[i]>>k)&1);//获得第k位上的值
		int hr[4]={0,0,0,0},hc[4]={0,0,0,0};//hr{(row,and,0),(row,and,1),(row,or,0),(row,or,1)}统计数量
		for(i=1;i<=n;i++)//行列计算
			hr[s[i]*2+br[i]]++,hc[2*t[i]+bc[i]]++;//hc{(col,and,0),(col,and,1),(col,or,0),(col,or,1)}
		if(hr[2]&&hc[1])return 0*printf("-1\n");//粗筛(row,or,0),(col,and,1),两者不能同时有取值
		if(hc[2]&&hr[1])return 0*printf("-1\n");//粗筛(col,or,0),(row,and,1),两者不能同时有取值
		for(i=1;i<=n;i++){//用行操作后的值，来设定初值
			cnt[i]=n;//i行上，雷同的数据有n个
			for(j=1;j<=n;j++)
				a[i][j]=br[i];//可以这样设置的理由:1&1=1,0&0=0;1|1=1,0|0=0;
		}
		for(j=1;j<=n;j++)//修改数据，符合列要求
			if(t[j]!=bc[j])//t[j]表示第j列操作数(0,and;1,or),bc[j]记录第j列操作结果的第k位置值.全1,全0情况
				for(i=1;i<=n;i++)
					if(a[i][j]!=bc[j])cnt[i]--,a[i][j]=bc[j];//列上操作，同一行雷同元素需减少。
		for(j=1;j<=n;j++){//用列操作后的值，来进行修补
			int flag=0;//判定是否找到
			if(t[j]==bc[j]){//(col,and,0,0)或者(col,or,1,1)
				for(i=1;i<=n;i++)
					if(a[i][j]==bc[j]){flag=1;break;}//找到这个为0，或为1的位置，找到一个即可。
				if(flag)continue;//若找到，继续找下一行
				for(i=1;i<=n;i++)//继续找
					if(s[i]==br[i]&&cnt[i]>=2){//s[i]表示第i行操作数(0,and;1,or),br[i]记录第i行操作结果的第k位置值,(0,and,0)至少有一个0;(1,or,1)至少有一个1.cnt[i]>=2至少有两个雷同
						cnt[i]--,a[i][j]=bc[j];//因至少有两个雷同，故可更改
						break;
					}
			}
			//存在兜了一圈，没改成功的情况，不用担心，之后，会有检查。
		}
		for(i=1;i<=n;i++)//生成待定矩阵元素
			for(j=1;j<=n;j++)
				ans[i][j]|=((ull)a[i][j]<<k);//第k位的处理
	}
	for(i=1;i<=n;i++){//行检验
		ull c=ans[i][1];
		for(j=2;j<=n;j++)
			if(s[i]==0)c=c&ans[i][j];
			else c=c|ans[i][j];
		if(c!=u[i])return 0*printf("-1\n");
	}
	for(j=1;j<=n;j++){//列检验
		ull c=ans[1][j];
		for(i=2;i<=n;i++)
			if(t[j]==0)c=c&ans[i][j];
			else c=c|ans[i][j];
		if(c!=v[j])return 0*printf("-1\n");
	}
	for(i=1;i<=n;i++){//经历了考验
		for(j=1;j<=n;j++)
			printf("%llu ",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 8436
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "unsafe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    s=LISTS()
    if 'Y' in s:
        print('Four')
    else:
        print('Three')
if __name__ == '__main__':
    do()

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

int main()
{
	char a[110], b[110], c[110];
	
	scanf("%s %s %s", a, b, c);
	
	if(a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0]) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    std::vector<int> a(N);
    int aa(0);
    for(int i(0); i < N; ++i){
        std::cin >> a[i];
        aa ^= a[i];
    }
    for(int i(0); i < N; ++i){
        if(i) std::cout << " ";
        std::cout << (aa ^ a[i]);
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


bool ok(ll a,ll b, ll c,ll d){
    a%=3;b%=3;c%=3;d%=3;
    ll stype,ttype;
    if(a==b) stype=0;
    else if((a==0&&b==2)||(a==1&&b==0)||(a==2&&b==1)) stype=1;
    else stype=2;
    if(c==d) ttype=0;
    else if((c==0&&d==2)||(c==1&&d==0)||(c==2&&d==1)) ttype=1;
    else ttype=2;
    if(stype==ttype) return true;
    else return false;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s,t;
    cin>>s>>t;
    ll q,n=s.size(),m=t.size();
    cin>>q;
    ll An[100010]={},Bn[100010]={},Am[100010]={},Bm[100010]={};
    rep(i,n){
        if(s[i]=='A'){
            An[i+1]=An[i]+1;
            Bn[i+1]=Bn[i];
        } else{
            Bn[i+1]=Bn[i]+1;
            An[i+1]=An[i];
        }
    }
    rep(i,m){
        if(t[i]=='A'){
            Am[i+1]=Am[i]+1;
            Bm[i+1]=Bm[i];
        } else{
            Bm[i+1]=Bm[i]+1;
            Am[i+1]=Am[i];
        }
    }
    rep(Q,q){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;c--;d--;
        ll As,At,Bs,Bt;
        As=An[b+1]-An[a];
        Bs=Bn[b+1]-Bn[a];
        At=Am[d+1]-Am[c];
        Bt=Bm[d+1]-Bm[c];
        if(ok(As,Bs,At,Bt)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


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

#define INF (INT32_MAX/2)

int main() {
	int N, K;

	cin >> N >> K;

	int ma = (N - 1) * (N - 2) / 2;
	if( K > ma ) {
		cout << -1 << endl;
	}
	else {
		int num = ma - K;
		cout << N - 1 + num << endl;
		for( int i = 2; i <= N; i++ ) {
			cout << 1 << " " << i << endl;
		}
		int n = 0;
		int flag = 0;
		for( int i = 2; i <= N - 1; i++ ) {
			for( int j = i + 1; j <= N ; j++ ) {
				if( n >= num ) {
					flag = 1;
					break;
				}
				cout << i << " " << j << endl;
				n++;
			}
			if( flag ) {
				break;
			}
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] str = scn.nextLine().toCharArray();
		long K = scn.nextInt();

		int len = 0;
		int start = 0;
		boolean all = true;
		for (int i = 0; i < str.length - 1; i++) {
			if (str[i] != str[i + 1]) {
				start = i + 1;
				all = false;
			}
		}
		long ans = 0;
		if (all) {

			System.out.println((K * str.length) / 2);

			return;
		}
		len = 1;
		for (int i = start; i < start + str.length; i++) {
			if (str[i % str.length] == str[(i + 1) % str.length]) {
				len++;
			} else {
				ans += len / 2;
				len = 1;
			}
		}
		ans += len / 2;

		ans *= K - 1;

		for (int i = 0; i < start; i++) {
			if (str[i] == str[i + 1]) {
				len++;
			} else {
				ans += len / 2;
				len = 1;
			}
		}
		for (int i = start; i < str.length - 1; i++) {
			if (str[i] == str[i + 1]) {
				len++;
			} else {
				ans += len / 2;
				len = 1;
			}
		}
		ans += len / 2;

		System.out.println(ans);
	}

}


Measured memory_bytes: 21844