akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

pair<long,long> div2(long h, long w){
  if(h%2==0 || w%2==0) return mp(h*w/2, h*w/2);
  else if(h<w){
    return mp(h*(w/2), h*((w+1)/2));
  } else {
    return mp((h/2)*w, ((h+1)/2)*w);
  }
}

long div3(long h, long w){
  long hh = h - h/3; //わけるぶん
  long s = w*(h/3);
  auto p = div2(hh, w);
  vector<long> vec = {s, p.fi, p.se};
  sort(all(vec));
  long ret = vec[2] - vec[0];

  hh--;
  s += w;
  auto pp = div2(hh, w);
  vector<long> vv = {s, pp.fi, pp.se};
  sort(all(vv));
  ret = min(ret, vv[2] - vv[0]);

  return ret;
}

int main(){
  int h,w;
  cin>>h>>w;

  if(h%3==0 || w%3==0) cout << 0 << endl;
  else {
    long ans = INF;
    // tate / yoko
    ans = min(h,w);

    ans = min(ans, div3(h,w));
    ans =min(ans, div3(w,h));

    cout << ans << endl;
  }

  return 0;
}


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


int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b) cout << c << endl;
	if(b==c) cout << a << endl;
	if(c==a) cout << b << endl;
	return 0;
}

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

long long mod = 1000000000 + 7;

long long modplus(long long a, long long b){
	long long ans = a + b;
	ans %= mod;
	return ans;
}

long long modminus(long long a, long long b){
	long long ans = a - b;
	ans %= mod;
	if(ans < 0) ans += mod;
	return ans;
}

long long modmul(long long a, long long b){
	long long ans = (a % mod) * (b % mod);
	ans = ((ans % mod) + mod) % mod;
	return ans;
}

long long modpow(long long A, long long P){
	long long a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	long long adash = modmul(a,a);
	if(p % 2) return modmul(modpow(adash, p / 2), a);
	else return modpow(adash, p / 2);
}

long long moddiv(long long a, long long b){
	long long divisor = modpow(b, mod - 2);
	return modmul(a,divisor);
}

long long comb(long long n, long long m){
	if(n == 0)return 1;
	if(m == 0)return 1;
	if(n < m) return 0;
	long long ans = 1;
	for(long long i=0;i<m;i++){
		ans = modmul(ans, n-i);
	}
	for(long long i=0;i<m;i++){
		ans = moddiv(ans, i+1);
	}
	return ans;
}

int main(){
	long long S;
	cin >> S;
	long long A[S+1];
	A[0] = 1;
	for(int i=1;i<min((long long)3,S + 1);i++){
		A[i] = 0;
		// cout << A[i] << endl;
	}
	// cout << A[3] << endl;
	for(int i = 3;i<=S;i++){
		long long tmp = 0;
		for(int j=0;j<=i-3;j++){
			tmp = modplus(tmp, A[j]);
		}
		A[i] = tmp;
	}
	// for(int i=0;i<=S;i++){
	// 	cout << A[i] << endl;
	// }
	cout << A[S] << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<std::string>s(N);
	std::vector<LL>t(N);
	rep(i, N) in >> s[i] >> t[i];
	std::string X;
	in >> X;

	LL ans = 0;
	bool flag = false;
	rep(i, N)
	{
		if(flag) ans += t[i];
		if (s[i] == X) flag = true;
	}

	out << ans << std::endl;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split(" "))
book_information = []
result = 12 * 10**5 + 1
for i in range(N):
	book_information.append(input())
for i in range(1, 1 << N):
  bought_book = []
  n = 0
  cost = 0
  skill = [0 for j in range(M)]
  for j in range(N):
    if (i >> j) & 1:
      bought_book.append(book_information[j])
      n += 1
  for j in range(n):
    bought_book_information = list(bought_book[j].split(" "))
    cost += int(bought_book_information[0])
    for k in range(M):
      skill[k] += int(bought_book_information[k + 1])
  if all(x >= X for x in skill):
    result = min(result, cost)
if result == 12 * 10**5 + 1:
  print(-1)
else:
  print(result)


Measured memory_bytes: 8988
#include <iostream>
#include <string>

using namespace std;

int main() {
	while (1){
		string a;
		cin>>a;
		int c=0,joi=0,ioi=0;
		c=a.size();
		if(c==0) break;
		for(int i=0;i<c;i++){
			if(a[i]=='O'){
				if(a[i-1]=='J'){
					if(a[i+1]=='I'){
						joi++;
					}	
				} if(a[i-1]=='I'){
					if(a[i+1]=='I'){
						ioi++;
					}
				}
			}
		}
	cout<<joi<<endl<<ioi<<endl;
	}
	return 0;
}

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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),p[n],ans=0;
    forin(p,n);
    for (int i=1;i<n-1;i++) {
        if ((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1]))  ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
using namespace std;

#define INF 1000000
#define REP(i,n) for(int i=0;i<(int)n;++i)

#ifdef _MSC_VER
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#else
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#endif

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

long long sum;



void dp(string s,int n){
	if (s.size() == 0){
		return;
	}
	else if (s.size() == n+1){
		sum += stoll(s);
		return;
	}

	dp(s, n + 1);//no
	//+
//	string test = s.substr(0, n + 1);
//	int testn = pow(2 ,(s.substr(n + 1).size() - 1));
	sum += (stoll(s.substr(0, n + 1))* (pow(2, (s.substr(n + 1).size() - 1))));
	dp(s.substr(n+1), 0);
}

int main()
{
	string s;

	cin >> s;
	sum = 0;

	dp(s,0);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;


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

    int N;
    cin >> N;

    ll result = 0;

    for (int i=0; i<N; i++) {
        ll num = i+1;
        if (num % 3 != 0 && num % 5 != 0) {
            result += num;
        }
    }

    cout << result << '\n';

    return 0;
}

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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;


void solve()
{
	int n;
	cin >> n;
	int ans = 0;
	vi cnt(n + 1, 0);

	loop(i, 1, n + 1)
	{
		for (int j = i; j <= n; j += i) cnt[j]++;
	}


	loop(i, 1, n + 1)
	{
		ans += cnt[i] * i;
	}
	cout << ans;
	return;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a % 2) == 0 ) cout << "Even" << endl;
  else if ((b % 2) == 0 ) cout << "Even" << endl;
  else cout << "Odd" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


ll c[55][55];
ll C(ll n, ll k) {
    if(k==0 || n==k) return 1;
    if(c[n][k]!=-1) return c[n][k];
    return c[n][k]=C(n-1, k)+C(n-1, k-1);
}


int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    ll v[55];
    ll i;
    ll cnt=0;
    ll rem=0;
    double ave=0;
    
    memset(c, -1, sizeof(c));
    
    for(i=0; i<N; i++) cin >> v[i];
    sort(v, v+N);
    reverse(v, v+N);
    
    //①平均を求める(大きい方からA個の平均がそのまま答え)
    for(i=0; i<A; i++) ave+=v[i];
    ave/=A;
    
    //②A番目と同じ要素がいくつあるか
    for(i=0; i<N; i++)
        if(v[A-1]==v[i]) cnt++;
    
    //③A番目より大きい要素がいくつあるか
    for(i=0; i<N; i++) {
        if(v[i]>v[A-1]) rem=i+1;
    }

    ll ans=0;
    if(rem==0)  //A番目より大きい要素が一つもなければ、Aと同じ要素をいくつ選んでも平均は変わらない
        for(i=A; i<=min(B, cnt); i++)
            ans+=C(cnt, i);
    else        //A番目より大きい要素が一つでもあれば、選ぶ要素の数が増えるほど平均は小さくなる
        ans=C(cnt, A-rem);
    
    printf("%.10f\n", ave);
    pt(ans);
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }


    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

void solve(void)
{
  int N; cin >> N;
  std::string S; cin >> S;
  int Q; cin >> Q;
  vector<int> result{};

  map<char, set<int>> m{};
  for (char c = 'a'; c <= 'z'; ++c) {
    m[c];
  }

  for (int i = 0; i < S.size(); ++i) {
    m[S[i]].emplace(i);
  }

  for (int _ = 0; _ < Q; ++_) {
    int t; cin >> t;
    switch (t)
    {
      case 1: {
        int i;
        char c; cin >> i >> c;
        --i;
        for (auto& p : m) {
          if (p.first == c) {
            p.second.emplace(i);
          } else {
            p.second.erase(i);
          }
        }
      }
        break;
    
      case 2: {
        int l, r; cin >> l >> r;
        --l; --r;
        int res{};
        for (auto& p : m) {
          auto itL = p.second.lower_bound(l);
          auto itR = p.second.lower_bound(r+1);
          auto cnt = std::distance(itL, itR);
          if (cnt > 0) {
            ++res;
          }
        }
        result.push_back(res);
      }
        break;
    
    default:
      abort();
    }
  }

  for (const auto& ans : result) {
    cout << ans << CRLF;
  }

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    string n;
    cin >> n;
    ll ans = 0;
    for(ll i = 0; i < n.length(); i++) {
        ans += n[i] - '0';
    }
    if(ans % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3716
#include <stdio.h>
long long int ans[101][100001];
long long int max(long long int a,long long int b)
{
	if(a>b) return a;
	return b;
}
long long int knap(int n,int w,int weight[],int v[])
{

	if(ans[n][w]!=-1)
	{
		return ans[n][w];
	}
	else if(w==0||n==0)
	{
		ans[n][w]=0;
		return ans[n][w];
	}	
	long long int r=knap(n-1,w,weight,v);
	if(w-weight[n-1]>=0)
	{
		r=max(r,v[n-1]+knap(n-1,w-weight[n-1],weight,v));
	}
	ans[n][w]=r;
	return ans[n][w];
}
int main(void)
{
	int n,w;
	scanf("%d %d",&n,&w);
	int weight[n];
	int v[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d",&weight[i],&v[i]);
	}
	for (int i = 0; i <=n; ++i)
	{
		for (int j = 0; j <=w; ++j)
		{
			ans[i][j]=-1;
		}
	}
	printf("%lld\n", knap(n,w,weight,v));
	
}

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


int mm[500005];
int ind[500005];
int seg[2000005];
void upd(int ver,int tl,int tr,int pos,int val)
{
    if(tl>tr)
        return ;
    else if(tl==tr)
    {
        seg[ver]=val;
    }
    else
    {
        int tm=(tl+tr)/2;
        if(tm>=pos)
        upd(2*ver,tl,tm,pos,val);
        else
            upd(2*ver+1,tm+1,tr,pos,val);
        seg[ver]=seg[2*ver]+seg[2*ver+1];
    }    
}

int get(int ver,int tl,int tr,int l,int r)
{
    if(tl>tr||l>r||tr<l||r<tl)
        return 0;
    else if(tl==l&&tr==r)
        return seg[ver];
    else
    {
        int tm=(tl+tr)/2;
        return get(2*ver,tl,tm,l,min(tm,r))+get(2*ver+1,tm+1,tr,max(tm+1,l),r);
    }    
}
int ans[500005];

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,k;
    cin>>n>>k;
    int z=(n+1)/2;
    if(z>=k)
        cout<<"YES";
    else    
    cout<<"NO";

}

Measured memory_bytes: 3592
N, Q = map(int,input().split())
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int,input().split())
    E[a].append(b)
    E[b].append(a)
PX = [list(map(int,input().split())) for _ in range(Q)]

def main():
    V = [0]*(N+1)
    for p,x in PX:
        V[p] += x
    stack = [1]
    gone = [False]*(N+1)
    gone[1] = True
    while len(stack) > 0:
        node = stack.pop(-1)
        for e in E[node]:
            if not(gone[e]):
                stack.append(e)
                V[e] += V[node]
                gone[e] = True
    print(*V[1:],sep =" ")
    return 

if __name__ == "__main__":
    main()

Measured memory_bytes: 103520
#include<iostream>
#include<string>

int main()
{
	std::string s, t1, t2;
	std::getline( std::cin, s );
	t1 = t2 = s;
	
	while( t1.find( "apple" ) != std::string::npos ){
		s.replace( t1.find( "apple" ), 5, "peach" );
		t1.replace( t1.find( "apple" ), 5, "peach" );
	}
	
	while( t2.find( "peach" ) != std::string::npos ){
		s.replace( t2.find( "peach" ), 5, "apple" );
		t2.replace( t2.find( "peach" ), 5, "apple" );
	}
	
	std::cout << s << std::endl;

 	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k;
  int array[200005];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  sort(array,array+n);
  
  long long sum=0;
  for(int i=0;i<n-k;i++){
    sum+=array[i];
  }
  cout<<sum<<endl;
  return(0);
}


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

    using namespace std;

bool N,W,E,S;

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

    string T;

    cin >> T;

    for(int i=0; i<T.size(); i++){
        if(T[i] == 'N')
            N = true;
        if(T[i] == 'W')
            W = true;
        if(T[i] == 'E')
            E = true;
        if(T[i] == 'S')
            S = true;
    }

    if(N^S || W^E)
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(s);
            int ans = 0;
            for (int i = 0; i < 2 * n; i+=2)
            {
                ans += Min(s[i], s[i + 1]);
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
#include<iostream>
#define For(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
const int N = 800005;
const int P = 924844033;
int pow(int x,int y){
	int p=1;
	for(;y;y>>=1,x=(1ll*x*x)%P)
		if(y&1)p=(1ll*p*x)%P;return p;
}
int inv(int x){return pow(x,P-2);}
int n,k,L;
int w0[N],w1[N];
int head[N],nxt[N],to[N],cnt;
int fac[N],Inv[N],tmp[N];
int A[N],B[N]; 
void add(int u,int v){
	nxt[++cnt]=head[u];head[u]=cnt;to[cnt]=v;
	nxt[++cnt]=head[v];head[v]=cnt;to[cnt]=u;
}
void init_w(){
	w0[0]=w1[0]=1;
	w0[1]=pow(5,(P-1)/L);w1[1]=inv(w0[1]);
	For(i,2,L){
		w0[i]=1ll*w0[i-1]*w0[1]%P;
		w1[i]=1ll*w1[i-1]*w1[1]%P;
	}
}
void ntt(int n,int*buf,int beg,int step,int*w){
	if(n==1) return;
	int m=n>>1;
	ntt(m,buf,beg,step<<1,w);
	ntt(m,buf,beg+step,step<<1,w);
	For(i,0,m-1){
		int pos=2*i*step;
		tmp[i]=(1ll*buf[beg+pos]+(1ll*w[i*step]*buf[beg+pos+step])%P)%P;
		tmp[i+m]=(1ll*buf[beg+pos]-(1ll*w[i*step]*buf[beg+pos+step])%P+P)%P;
	}
	For(i,0,n-1) buf[beg+i*step] = tmp[i]%P;
}
int sz[N];
long long ans[N];
long long C(int n,int m){return (1ll*fac[n]*Inv[m]%P)*Inv[n-m]%P;}
void dfs(int u,int fat){
	sz[u]=1;
	for(int i=head[u];i;i=nxt[i]){
		int v=to[i];if(v==fat) continue;
		dfs(v,u);sz[u]+=sz[v];A[sz[v]]++;
	}
	A[n-sz[u]]++;
}
int main(){
//	freopen("ha.in","r",stdin);
//	freopen("ha.out","w",stdout);
	scanf("%d",&n);
	fac[0]=1;For(i,1,n)fac[i]=(1ll*fac[i-1]*i)%P;
	For(i,0,n)Inv[i]=inv(fac[i]);
	for(L=1;L<=n;L<<=1);L<<=1;
	For(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
	}
	dfs(1,1);
	For(i,1,n) A[i] = (1ll*A[i]*fac[i])%P;
	For(i,0,n) B[n-i] = Inv[i];
	init_w();
	ntt(L,A,0,1,w0);
	ntt(L,B,0,1,w0);
	For(i,0,L-1) A[i] = (1ll*A[i]*B[i])%P;
	ntt(L,A,0,1,w1);
	int Inv_L = inv(L);
	For(i,0,L-1) A[i] = (1ll*A[i]*Inv_L)%P;
	For(k,1,n){
		ans[k]=(1ll*(P-1)*Inv[k]%P*A[k+n])%P;
		ans[k]=(ans[k]+1ll*C(n,k)*k+1ll*C(n-1,k)*n)%P;
	}
	For(i,1,n){
		while(ans[i]<0)ans[i]+=P;
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 45056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
const int maxn = 300005;
ll max(ll a, ll b, ll c, ll d)
{
    return max(max(max(a, b), c), d);
}
ll min(ll a, ll b, ll c, ll d)
{
    return min(min(min(a, b), c), d);
}
ll a[maxn];
ll sum[maxn];
int n;
int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++)
    cin >> a[i];
    for(int i = 1; i <= n; i++)
    sum[i] = sum[i-1]+a[i];
    ll ans = 1e15;
    int x1 = 1, x3 = 3;
    for(int i = 2; i <= n-1; i++)
    {
         while(x1 < n-3 && abs(sum[x1]-(sum[i]-sum[x1])) > abs(sum[x1+1]-(sum[i]-sum[x1+1])))x1++;
         while(x3 < n-1 && abs(sum[x3]-sum[i]-(sum[n]-sum[x3])) > abs(sum[x3+1]-sum[i]-(sum[n]-sum[x3+1])))x3++;
         ll d1 = sum[x1];
         ll d2 = sum[i]-sum[x1];
         ll d3 = sum[x3]-sum[i];
         ll d4 = sum[n]-sum[x3];
         ans = min(ans, max(d1, d2, d3, d4)-min(d1, d2, d3, d4));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long

void solve() {
	int n;
	cin >> n;
	int a, b, c;
	int ra = 0, rb = 0, rc = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		int step = abs(rb-b) + abs(rc-c);
		int timediff = a - ra;
		if ((timediff-step)%2 == 1 || timediff < step) {
			cout << "No\n";
			return;
		}
		ra = a;
		rb = b;
		rc = c;
	}
	cout << "Yes\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3632
X = int(input())
DP = [0 for i in range(1000000)]
DP[0] = 1
a = [100, 101, 102, 103, 104, 105]
for i in a:
    for j in range(X):
        if DP[j] == 1:
            DP[j + i] = 1
print(DP[X])

Measured memory_bytes: 10904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(whole(a));
    int ans = a[0]+a[1]+10*a[2];
    
    cout << ans << endl;
    return 0;
}


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

const int N = 222222;
int n;
int a[N];
bool v[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int i = 1;
    int ans = 0;
    while(1) {
        v[i] = true;
        i = a[i];
        ans++;
        if(v[i]) {
            cout << -1 << endl;
            return 0;
        }
        if(i == 2) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 768
fn main() {
    proconio::input! {
        n: u64,
        mut x: u64,
        m: u64,
    }

    let mut dp = vec![None; m as usize];
    let mut r = 0;
    let mut i = 0;
    while i < n {
        if let Some((c, v)) = dp[x as usize] {
            let w = i - c;
            let l = n / w - 3;
            if l > 3 {
                r += (r - v) * l;
                i += w * l;
            }
            while i < n {
                r += x;
                i += 1;
                x = x * x % m;
            }
        } else {
            dp[x as usize] = Some((i, r));
            r += x;
            i += 1;
            x = x * x % m;
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 4412
N = int(input())
A = list(map(int, input().split(' ')))
B = [0]
for a in A:
    B.append(B[-1] + a)

import collections
ans = 0
b_frq_dict = collections.Counter(B)
for frq in b_frq_dict.values():
    ans += frq * (frq-1) // 2

print(ans)

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

using namespace std;

int n,m,d;
double ans;

int main(){
	scanf("%d%d%d",&n,&m,&d);
	if (d==0) ans=(m-1)*1.0/n;
	else ans=(n-d)*2.0*(m-1)/n/n;
	printf("%.8lf\n",ans);
	
	return 0;
}
			

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

int main(){
    int n;
    cin>>n;
    long long a[n];
    long long ans=0;
    const int mod = 1000000007;
    long long sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    for(int i=0;i<n;i++){
        sum-=a[i];
        if(sum<0)sum+=mod;
        ans+=a[i]*sum;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5180
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	ll a,b,k;
	ll ans=0;
	cin>>a>>b>>k;
	ll tak=max(0LL,a-k);
	ll ao=b;
	k-=a;
	if(k>0)
		ao=max(0LL,b-k);
	cout<<tak<<" "<<ao<<endl;
	return 0;
}

Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;

 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = ( int ) 1e5 + 10 ;

int n , sz [ N ] ; 
vector < int > adj [ N ] ;

bool dfs ( int v = 0 , int p = -1 ) { 
	bool ret = true ;
	sz [ v ] = 1 ;
	int odd = 0 ; 
	for ( int u : adj [ v ] ) {
		if ( u ^ p ) {
			ret &= dfs ( u , v ) ;
			sz [ v ] += sz [ u ] ;
			odd += ( sz [ u ] & 1 ) ; 
		}
	}
	odd += ( ( n - sz [ v ] ) & 1 ) ;
	ret &= ( odd <= 1 ) ;
	return ret ; 
}

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	for ( int i = 0 ; i < n - 1 ; ++ i ) {
		int u , v ;
		cin >> u >> v ;
		-- u , -- v ; 
		adj [ u ] . push_back ( v ) ;
		adj [ v ] . push_back ( u ) ;
	}
	cout << ( dfs ( ) ? "Second" : "First" ) << '\n' ;  
}


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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n;
    cin >>n;
    vector<int> vec(n+1);
    REPS(i,n){
        cin >> vec.at(i);
    }
    int m = 1;
    int count = 0;
    bool fumiya = false;
    REP(i,n){
        if(vec.at(m) == 2){
            count++;
            fumiya = true;
            break;
        }
        m = vec.at(m);
        count++;
    }


    if(fumiya) cout << count << endl;
    else cout << -1 << endl;

    

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
 int main(void){
  int x,i;
    int a[4];
  for(i=0;i<4;i++){
    scanf("%d",&a[i]);
    x =a[0]+a[1]+a[2]+a[3];
  }
  printf("%d\n%d\n", x/60,x%60);
  return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    for (Int i = 0; i < h; i++) {
        cin >> c[i];
    }
    Int res = 0;
    for (Int bit1 = 0; bit1 < (1<<h); bit1++) {
        for (Int bit2 = 0; bit2 < (1<<w); bit2++) {
            Int cnt = 0;
            for (Int i = 0; i < h; i++) {
                if (bit1 & (1<<i)) continue;
                for (Int j = 0; j < w; j++) {
                    if (bit2 & (1<<j)) continue;
                    if (c[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) res++;
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
words = [input() for i in range(n)]
mae = ''
ans = 'Yes'

for i in range(n):
    if i == 0:
        word = words[0]
        leng = len(word)
        mae = word[leng-1]
    else:
        word = words[i]
        if mae != word[0:1] or words.count(word) >= 2:
            ans = 'No'
            break
        else:
            leng = len(word)
            mae = word[leng-1]

print(ans) 

Measured memory_bytes: 9144
/* This Template is property of Pranav Khiste aka desmond_kaneki*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define vll vector<ll>
#define pb push_back
#define qll queue<ll>
#define mp make_pair
#define fst first
#define snd second
#define pll pair<ll,ll>
#define vpll vector<pll>
#define debug(x) cout<<#x<<' '<<x<<endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
#define mod 1000000007
#define SUP LLONG_MAX
#define INF LLONG_MIN
#define test() ll var;  cin>>var; while(var--)
#define fileio freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);  // use cin cout only!!
ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*power((x*x)%M,(n-1)/2,M))%M;

}
ll popcnt(ll z)
{
    ll out=0,temp=z;
    while(temp!=0)
    {
        if(temp%2==1)
            out++;
        temp=temp/2;
    }
    return out;
}
main()
{
    //fastio;
  	ll n;
  	cin>>n;
    string s,temp;
    ll count=0,tempcnt,val1=0,val2=0,val3=0;
    cin>>s;
    fi(0,n)
    {
        if(s[i]=='1')
            count++;
    }
    fi(0,n)
    {
        ll ind=n-1-i;
        if(s[i]=='1')
        {
            val1=(val1+power(2,ind,count))%count;
            val2=(val2+power(2,ind,count+1))%(count+1);
            if(count>1)
                val3=(val3+power(2,ind,count-1))%(count-1);
            else
                val3=0;
        }
    }
    fi(0,n)
    {
        ll val=0,ans;
        if(s[i]=='0')
        {
            val=(val2+power(2,n-1-i,count+1))%(count+1);
            ans=1;
        }
        else
        {
            if(count>1)
            {
                val=(val3-power(2,n-1-i,count-1)+count-1)%(count-1);
                ans=1;
            }
            else
            {
                val=0;
                ans=0;
            }
        }
        while(val!=0)
        {
            tempcnt=popcnt(val);
            val=val%tempcnt;
            ans++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#include<cstdlib>
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  vector<double> kitai(N);
  rep(i, N){
    cin >> P.at(i);
    kitai.at(i) = (1.0+double(P.at(i)))/2.0;
  }
 
  vector<double> goukei(N-K+1);
  int64_t sum = 0;
  for(int i=0; i<K; i++){
    sum += P.at(i);
  }
  goukei.at(0) = sum;
  
  for(int i=1; i<N-K+1; i++){
    sum += P.at(i+K-1);
    sum -= P.at(i-1);
    goukei.at(i) = sum;
  }
 
  sort(goukei.rbegin(), goukei.rend());
  cout << fixed << setprecision(10);
  cout << (double(goukei.at(0))+double(K))/2.0;
 
}

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

int main() {
  int N;
  cin >> N;
  int a, before=0, cnt=0;
  for (int i=0; i<N; i++) {
    cin >> a;
    if (before == a) {
      cnt++;
      before = 0;
    } else {
      before = a;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 888
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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


int n, x, arr[100005];



int main(){

    ios_base::sync_with_stdio(0);

    cin>>n>>x;
    for(int i=0;i<n;i++)
    	cin>>arr[i];

    ll ans = 0;
    for(int i=1;i<n;i++)
    	if(arr[i-1]+arr[i] > x){
    		int extra = arr[i-1]+arr[i] - x;
    		ans += extra;
    		arr[i] = max(0, arr[i]-extra);
    	}

    cout<<ans;
    return 0;
}





 



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it
const int MOD = 1e9 + 7;
int n;
ll *dp[2];
vector<int>* ch;
int solve(int i = 0, bool col = 0, int last = n)
{
	ll &ret = dp[col][i];
	if(~ret)
		return ret;
	if((ch[i].size() == 1 && ch[i][0] == last) || ch[i].empty())
		return ret = !col + 1;
	if(col)
	{
		ret = 1;
		for(unsigned int j = 0; j < ch[i].size(); j++)
			if(ch[i][j] != last)
				ret = (ret * solve(ch[i][j], 0, i)) % MOD;
	}
	else
	{
		ll first = 1, second = 1;
		for(unsigned int j = 0; j < ch[i].size(); j++)
			if(ch[i][j] != last)
			{
				first = (first * solve(ch[i][j], 0, i)) % MOD;
				second = (second * solve(ch[i][j], 1, i)) % MOD;
			}
		ret = (first + second) % MOD;
	}
	return ret;
}
int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    cin >> n;
    ch = new vector<int>[n];
	dp[0] = new ll[n];
	dp[1] = new ll[n];
	memset(dp[0], -1, n * 8);
	memset(dp[1], -1, n * 8);
	int x, y;
	while(cin >> x >> y)
	{
		ch[x - 1].push_back(y - 1);
		ch[y - 1].push_back(x - 1);
	}
	cout << solve();
}


Measured memory_bytes: 14208
N=int(input())

a=list(map(int,input().split(" ")))

r=list(zip(a,[i+1 for i in range(N)]))
x=sorted(r)

initFlag=False
for it in x:
    if initFlag==False:
        initFlag=True
    else:
        print(" ",end="")
    
    print(it[1],end="")
print()


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

using ld = long double;
using P = std::complex<ld>;
using G = std::vector<P>;
const ld pi = std::acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P &a, const P &b) { return a.real() * b.imag() - a.imag() * b.real(); }
ld dot(const P &a, const P &b) { return a.real() * b.real() + a.imag() * b.imag(); }

/*
CCW

-- BEHIND -- [a -- ON -- b] --- FRONT --

CW
*/
enum CCW_RESULT { CCW = +1, CW = -1, BEHIND = +2, FRONT = -2, ON = 0 };
int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if(cross(b, c) > eps) return CCW;    // counter clockwise
	if(cross(b, c) < -eps) return CW;    // clockwise
	if(dot(b, c) < 0) return BEHIND;     // c--a--b on line
	if(norm(b) < norm(c)) return FRONT;  // a--b--c on line
	return ON;
}

namespace std {
	bool operator<(const P &a, const P &b) {
		return std::abs(real(a) - real(b)) > eps ? real(a) < real(b) : imag(a) < imag(b);
	}
}

struct L : public std::vector<P> {
	L(const P &a = P(), const P &b = P()) : std::vector<P>(2) {
		begin()[0] = a;
		begin()[1] = b;
	}

	// Ax + By + C = 0
	L(ld A, ld B, ld C) {
		if(std::abs(A) < eps && std::abs(B) < eps) {
			abort();
		}
		else if(std::abs(A) < eps) {
			*this = L(P(0, -C / B), P(1, -C / B));
		}
		else if(std::abs(B) < eps) {
			*this = L(P(-C / A, 0), P(-C / A, 1));
		}
		else {
			*this = L(P(0, -C / B), P(-C / A, 0));
		}
	}
};

P crosspointLL(const L &l, const L &m) {
	ld A = cross(l[1] - l[0], m[1] - m[0]);
	ld B = cross(l[1] - l[0], l[1] - m[0]);
	if(std::abs(A) < eps) P(1e9, 1e9);                     // !!!PRECONDITION NOT SATISFIED!!!
	return m[0] + B / A * (m[1] - m[0]);
}

L l[100];

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

	int n;
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			l[i] = { P(x1, y1), P(x2, y2) };
		}

		int ans = 1;
		for(int i = 0; i < n; i++) {
			vector<P> p;
			for(int j = 0; j < i; j++) {
				P cp = crosspointLL(l[i], l[j]);
				if(abs(cp.real()) >= 100 - 1e-9 || abs(cp.imag()) >= 100 - 1e-9) continue;
				bool ok = true;
				for(int k = 0; k < p.size(); k++) {
					if(abs(p[k] - cp) < 1e-10) {
						ok = false;
						break;
					}
				}
				if(ok) {
					p.push_back(cp);
				}
			}
			ans += p.size() + 1;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3108
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    string ab = a + b;
    int n = stoi(ab);
    int hoge = sqrt(n);
    if(hoge * hoge == n) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
 int r,g,b,n;
 cin >> r >> b >>g >> n;
 int x=n/r;
 int y=n/b;
 
 ll ans =0;
 rep(i,x+1){
     rep(j,y+1){
         ll m=i*r+j*b;
         if((n-m)%g==0 && n>=m)ans++;
     }
 }
 cout << ans << endl;

} 
    

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


int main() {
    int N, L;
    cin >> N >> L;
    int S = 0;
    for (int i=1; i<=N; i++) S += L+i-1;
    
    int tmp = 1000;
    int tmp2;
    int rec = 0;
    for (int i=1; i<=N; i++) {
        tmp2 = min(tmp, abs(L+i-1));
        if (tmp != tmp2) {
            rec = L+i-1;
            tmp = tmp2;
        }
    }
    
    cout << S - rec << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        long total = 0;

        // bit全探索
        // 集合 (1, 2, 3) の部分集合(1, 12, 123 など) の種類で回す (2のn乗 == Math.pow(2, S))
        for (int i = 0; i < (1 << S.length() - 1); i++) {
            String first = String.valueOf(S.charAt(0));
            StringBuilder sb = new StringBuilder(first);

            for (int j = 0; j < S.length() - 1; j++) {
                if (((i >> j) & 1) == 1) {
                    // 間に+を挿入
                    sb.append("+");
                }
                sb.append(S.charAt(j + 1));
            }

            String[] ss = sb.toString().split("\\+");
            for (String s : ss) {
                total += Long.parseLong(s);
            }
        }

        System.out.println(total);
    }
}


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

int main() {
  int N;
  cin >> N;
  int num = N;
  int sum = 0;
  while(num != 0){
      sum += num % 10;
      num /= 10;
  }
  if(N % sum == 0){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

long long N,M;
vector<vector<long long> > adj;
vector<bool> vis;

void dfs(int s){
    vis[s]=true;

    for(auto v:adj[s]){
        if(!vis[v]){
            dfs(v);
        }
    }
}
int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif


    cin>>N>>M;
    adj.resize(N+1);
    vis.resize(N+1,false);
    ll u,v;
    for(ll i=0;i<M;i++){
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans=0;
    for(int i=1;i<=N;i++){
        if(!vis[i]){
            dfs(i);
            ans++;
        }
    }
    cout<<ans-1<<"\n";


}


Measured memory_bytes: 9744
#include <algorithm>
#include <iostream>
#include <climits>
#include <vector>
#include <cmath>
#include <stack>
#define int long long
using namespace std;

int32_t main()
{
    int N;

    cin >> N;

    vector<int> arr(N);

    for (int &e : arr)
        cin >> e;

    vector<vector<int>> dp(N + 1, vector<int>(N + 1));
    for (int len = 1; len <= N; len++) {
        for (int l = 0; l + len <= N; l++) {
            int r = l + len;
            dp[l][r] = -2e18;
            dp[l][r] = max(dp[l][r], arr[l] - dp[l + 1][r]);
            dp[l][r] = max(dp[l][r], arr[r - 1] - dp[l][r - 1]);
        }
    }
    cout << dp[0][N] << endl;
}

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

using namespace std;

int main(void) {
    int A, B;
    cin >> A >> B;
    int sum = A+B;
    if(sum%2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << sum/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int MAX(int a, int b){
  return a < b ? b : a;
}
 
int main(){
 
  int A, B;
  cin >> A >> B;
 
  int ans[3];
  ans[0] = 2*A -1;
  ans[1] = A + B;
  ans[2] = 2*B -1;
 
  cout << MAX(ans[0], MAX(ans[1], ans[2])) << endl;
 
  return 0;
 
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = list(input())
K = INT()
if len(Counter(S).values()) == 1:
    print(len(S)*K//2)
    exit()
S_one = S.copy()
S_two = S*2

inner = 0
outer = 0

tmp = ""
for i, s in enumerate(S_one):
    if tmp == s:
        S_one[i] = "_"
        inner += 1
        tmp = ""
    else:
        tmp = s

tmp = ""
for i, s in enumerate(S_two):
    if tmp == s:
        S_two[i] = "_"
        outer += 1
        tmp = "_"
    else:
        tmp = s
outer -= (inner*2)

print(inner*K+outer*(K-1))


Measured memory_bytes: 5200
#include <stdio.h>
int A[1000000], n;
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2084