akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define eps 1e-8
using namespace std;

double func(string s,int n){
	if(s=="north")return 0;
	if(s=="west")return 90;
	if(s.substr(0,5)=="north")return func(s.substr(5),n-1)-(double)90/pow(2,n-1);
	if(s.substr(0,4)=="west")return func(s.substr(4),n-1)+(double)90/pow(2,n-1);
}

int main(){
	string s;
	while(cin>>s,s!="#"){
		int n=0;
		if(s.size()>4)rep(i,s.size()-4)if(s.substr(i,5)=="north")n++;
		rep(i,s.size()-3)if(s.substr(i,4)=="west")n++;
		double ans=func(s,n);
		int a=0;
		while(abs((double)(ans-(int)ans))>eps){
			ans*=2;
			a++;
		}
		if(a==0)cout<<(long long)ans<<endl;
		else cout<<(long long)ans<<"/"<<pow(2,a)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

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

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    
  int main(){
    lint N;
    cin>>N;
    string s[N];
    map<string,lint>x;
    rep(i,N){
        cin>>s[i];
        x[s[i]]++;
    }
    lint mx=0;
    rep(i,N){
        mx=max(mx,x[s[i]]);
    }
   for(auto l:x){
        if(l.second==mx)cout<<l.first<<endl;
   }
    }
     
  


Measured memory_bytes: 26752
#include <stdio.h>

int main(void){
    double a,b,c,tmp,n;
    scanf("%lf",&n);
    while(scanf("%lf%lf%lf",&a,&b,&c)!=EOF){
        if(a>b){
            tmp=a;
            a=b;
            b=tmp;
        }
        if(b>c){
            tmp=b;
            b=c;
            c=tmp;
        }
        if(a*a+b*b==c*c){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 608
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define N '\n'
#define S ' '
#define Z '0'
#define RT return
#define elif else if
#define W(a) while(a)
#define RP(a,b,c) for(ll a=(b);a<(c);++a)
#define R(a,b) for(ll a=0;a<(b);++a)
#define RD(a,b) for(ll a=(b);a>=0;++a)
#define LI(a) for(auto &x:a)I(x)
#define P(a) cout<<"a"<<N
#define F(a) cout<<fixed<<setprecision(10)<<a
#define D(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define C cin.tie(0);ios::sync_with_stdio(false)
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y,z;
const int P[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
inline void I(){}
template<class T,class...A>inline void I(T&&t,A&&...a){cin>>t;I(move(a)...);}
template<class T>inline void O(T t){cout<<t<<N;}
template<class T,class...A>inline void O(T t,A...a){cout<<t<<S;O(move(a)...);}
inline ll dig(ll a){ll d=1;W(a/=10)++d;RT d;}
inline ll GCD(ll a,ll b){ll c;W(a){c=a;a=b%a;b=c;}RT b;}
inline bool isp(ll a){if(a<48){RP(i,0,15)if(P[i]==a)RT 1;}
    elif(a<2809)RT GCD(614889782588491410,a)==1;
    else {O("Error:Argument is Over-2808!");exit(1);}RT 0;}

int main(){
    C;
    ll A[3];
    cin>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    cout<<abs(A[1]-A[0])+abs(A[2]-A[1]);
















}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
int mod;
const int A = 1e5 + 2;

int add(int x, int y) {
    return ((x + y) % mod + mod) % mod;
}
int mul(int x, int y) {
    return (1LL * x * y) % mod;
}
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n >> mod;
    int a[n];
    for (int i = 0; i < n; i++) {
        char x;
        cin >> x;
        a[i] = x - '0';
    }
    ll ans = 0;
    if (mod == 2 || mod == 5) {
        int acc = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (a[i] % mod == 0)
                acc++;
            ans += acc;
        }
        cout << ans;
        return 0;
    }
    int suf = 0, x = 1, acc[10001] = {};
    acc[0] = 1;
    for (int i = n - 1; i >= 0; i--) {
        suf = add(suf, mul(a[i], x));
        x = mul(x, 10);
        ans += acc[suf]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 3003
int dp[MX][MX];
int main() {
	string s, t;
	cin >> s >> t;
	for(int i = 1; i <= s.size(); ++i) {
		for (int j = 1; j <= t.size(); ++j) {
			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], dp[i][j - 1]);
		}
	}
	stack <int> st;
	int i = s.size();
	int j = t.size();
	while(dp[i][j] != 0) {
          if(dp[i][j] == dp[i - 1][j])
          	i = i - 1;
          else if(dp[i][j] == dp[i][j - 1])
          	j = j - 1;
          else {
          	st.push(i);
          	i = i - 1;
          	j = j - 1;
          }
	}
	while(!st.empty())
		cout << s[st.top() - 1], st.pop();
	cout << endl;
}


Measured memory_bytes: 35456
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    ll n,x,m;
    cin>>n>>x>>m;
    map<long,int> map;
    long tmp=x;
    long sum=0;
    long sum1=0;
    long sum2=0;
    int flag=0;
    long tmp2;
    long i;
    for(i=1;i<=n;i++){
        map[tmp]++;
        if(map[tmp]==2){
            flag=1;
            tmp2=tmp;
            break;
        }
        sum1+=tmp;
        tmp=(long)pow(tmp,2)%m;
    }
    if(flag==0){
        cout<<sum1;
        exit(0);
    }
    long l;
    tmp=x;
    for(l=1;l<=i;l++){
        map[tmp]++;
        if(map[tmp]==3){
            break;
        }
        sum2+=tmp;
        tmp=(long)pow(tmp,2)%m;
    }
    long sum3=sum1-sum2;
    long tw = (n-l+1)/(i-l);
    long tp = (n-l+1)%(i-l);
    sum=sum2+sum3*tw;
    for(int i=0;i<tp;i++){
        sum+=tmp2;
        tmp2=(long)pow(tmp2,2)%m;
    }
    cout<<sum;
}


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N,L;
    string S;
    cin >> N;
    cin >> S;
    L = S.size();
    REP(int,j,0,L){
        REP(int,i,0,N){
            if ( S.at(j) == 'Z' ){
                S.at(j) = 'A';
            }
            else{
                S.at(j)++;
            }
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main(){
    int n;
    double p=0;
    cin >>n;
    if (n%2 ==0){
        p=0.5;
    }else{
        double a = n+1;
          double b =2*n;
      p =a/b;
    }
    cout << p <<endl;
}

Measured memory_bytes: 256
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])

hantei = False

for i in range(N-M+1):
  for j in range(N-M+1):
    C=np.array(A[i:i+M,j:j+M])
    if (C==B).all():
      hantei = True
print('Yes' if hantei else 'No')

Measured memory_bytes: 12432
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s;
    while (cin>>s) {
        vector<vector<char>>v(3,vc());
        int hoge=0;
        rep(i,3)rep(j,3){v[i].push_back(s[hoge++]);}
        bool flag=false;
        char win = '\0';
        rep(i,3)if((v[i][0]==v[i][1])&&v[i][0]==v[i][2]){if(v[i][1]=='s')continue;flag=true;win=v[i][1];}
        rep(i,3)if((v[0][i]==v[1][i])&&v[1][i]==v[2][i]){if(v[1][i]=='s')continue;flag=true;win=v[1][i];}
        if((v[0][0]==v[1][1])&&(v[1][1]==v[2][2])){if(v[1][1]=='s')continue;flag=true;win=v[1][1];}
        if(v[0][2]==v[1][1]&&v[1][1]==v[2][0]){if(v[1][1]=='s')continue;flag=true; win=v[1][1];}
        if(flag)cout<<win<<endl;
        else cout<<"d"<<endl;
    }
}

Measured memory_bytes: 3068
a,b = map(int,input().split())

strength_list = [2,3,4,5,6,7,8,9,10,11,12,13,1]

a_idx = strength_list.index(a)
b_idx = strength_list.index(b)

if a_idx > b_idx:
    print('Alice')
elif a_idx == b_idx:
    print('Draw')
else:
    print('Bob') 

Measured memory_bytes: 3064
#![allow(non_snake_case)]

use proconio::input;
use proconio::fastout;

#[fastout]

fn main() {
    const MOD: i32 = 998244353;
    input! {
        N: usize,
        S: usize,
    }
    let mut dp = vec![0; S + 1];
    dp[0] = 1;
    for _ in 0..N {
        input! {
            A: usize,
        }
        for i in (0..=S).rev() {
            dp[i] = (dp[i] * 2) % MOD;
            if i >= A {
                dp[i] = (dp[i] + dp[i - A]) % MOD;
            }
        }
    }
    println!("{}", dp[S]);
}


Measured memory_bytes: 2176
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n, k;
char tmp[maxn];
int a[maxn];

int read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  scanf("%s", tmp);
  for (int i = 0; i < n; i++) {
    a[i] = tmp[i] - 'A';
  }
  return true;
}

void solve() {
  int pos = 0;
  int toxor = 0;
  while (k && pos != n) {
    if (a[pos] ^ toxor) {
      pos++;
      toxor ^= 1;
    } else {
      a[pos] ^= 1;
    }
    k--;
  }
  if (!k) {
    for (int i = 0; i < n; i++) {
      tmp[i] = 'A' + (a[i] ^ toxor);
    }
    rotate(tmp, tmp + pos, tmp + n);
    printf("%s\n", tmp);
    return;
  }
  pos = 0;
  if (!(n & 1)) {
    if (!(a[pos] ^ toxor)) {
      while (k && pos != n) {
        if (a[pos] ^ toxor) {
          pos++;
          toxor ^= 1;
        } else {
          a[pos] ^= 1;
        }
        k--;
      }
      if (!k) {
        for (int i = 0; i < n; i++) {
          tmp[i] = 'A' + (a[i] ^ toxor);
        }
        rotate(tmp, tmp + pos, tmp + n);
        printf("%s\n", tmp);
        return;
      }
      pos = 0;
    }
    assert(a[pos] ^ toxor);
  } else {
    if (a[pos] ^ toxor) {
      while (k && pos != n) {
        if (a[pos] ^ toxor) {
          pos++;
          toxor ^= 1;
        } else {
          a[pos] ^= 1;
        }
        k--;
      }
      if (!k) {
        for (int i = 0; i < n; i++) {
          tmp[i] = 'A' + (a[i] ^ toxor);
        }
        rotate(tmp, tmp + pos, tmp + n);
        printf("%s\n", tmp);
        return;
      }
      pos = 0;
    }
    assert(!(a[pos] ^ toxor));
  }
  if (n & 1) {
    k %= 2;
  } else {
    k %= 1;
  }
  while (k) {
    if (a[pos] ^ toxor) {
      pos++;
      if (pos == n) {
        pos = 0;
      }
      toxor ^= 1;
    } else {
      a[pos] ^= 1;
    }
    k--;
  }
  for (int i = 0; i < n; i++) {
    tmp[i] = 'A' + (a[i] ^ toxor);
  }
  rotate(tmp, tmp + pos, tmp + n);
  printf("%s\n", tmp);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1408
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

	vvi cost(n, vi(n, INF));
	int a, b, d, e;
	char c;
	REP(i, m) {
		cin >> a >> c >> b >> c >> d >> c >> e;
		cost[a-1][b-1] = d;
		cost[b-1][a-1] = e;
	}
	cin >> a >> c >> b >> c >> d >> c >> e;

	REP(k, n) {
		REP(i, n) {
			REP(j, n) {
				cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
			}
		}
	}

	cout << d-e-cost[a-1][b-1]-cost[b-1][a-1] << endl;
    return 0;
}

Measured memory_bytes: 1212
def main():
    n, a, b = map(int, input().split())
    if (bin(a).count("1")+bin(b).count("1")) % 2 == 0:
        print("NO")
        return
    print("YES")

    def calc(a, b, k):
        if k == 1:
            return [a, b]
        for i in range(k):
            if ((a >> i) & 1) ^ ((b >> i) & 1):
                break
        a2 = (a & (2**i-1))+((a >> (i+1)) << i)
        b2 = (b & (2**i-1))+((b >> (i+1)) << i)
        a3 = ((a >> i) & 1)
        b3 = ((b >> i) & 1)
        c = a2 ^ 1
        q = calc(a2, c, k-1)
        r = calc(c, b2, k-1)
        q = [((t >> i) << i+1)+(a3 << i)+(t & (2**i-1)) for t in q]
        r = [((t >> i) << i+1)+(b3 << i)+(t & (2**i-1)) for t in r]
        return q+r
    print(*calc(a, b, n))


main()


Measured memory_bytes: 12196
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  int a[3];
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a, a+3);
  cout << a[0] + a[1] << endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 1000000007
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>>task(n,vector<int>(3));
	rep(i, 0, n)rep(j, 0, 3)cin >> task[i][j];

	vector<vector<long long int>>dp(n,vector<long long int>(3));
	rep(j, 0, 3)dp[0][j] = task[0][j];
	rep(i, 1, n) {
		rep(j, 0, 3) {
			if (j == 0)dp[i][j] = max(dp[i - 1][1], dp[i - 1][2]) + task[i][j];
			if (j == 1)dp[i][j] = max(dp[i - 1][0], dp[i - 1][2]) + task[i][j];
			if (j == 2)dp[i][j] = max(dp[i - 1][0], dp[i - 1][1]) + task[i][j];
		}
	}
	long long int ans = 0;
	rep(i, 0, 3)ans = max(ans, dp[n - 1][i]);
	cout << ans << endl;

	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector <ll> a(1000002,0),aa(n);
    rep(i,n){
        cin >> aa[i]; 
    }
    sort(aa.begin(),aa.end());
    ll ans=0,k4=0,kk;
    if(aa[0]==1){
        ans=1;
        if(n>=2){
        if(aa[1]==1){
            ans=0;
        }
        }
            }
        else{
            rep(i,n){
                if(i!=0){
                if(k4==1 and aa[i]==aa[i-1]){
                    --ans;
                }
                }
                
            kk=1;
            if(a[aa[i]]==0){
                ++ans;
                k4=1;
            
            while(kk*aa[i]<1000001){
                a[aa[i]*kk]=-1;
                //cout << kk << endl;
                ++kk;
            }
            }
            else{
                k4=0;
            }
            }
        }

        cout << ans << endl;

    

    return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(x, t);
  
  cout << max(x - t, 0) << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n,m;
  cin >> n >> m;
  vector<pair<long long int,int> > v;
  for(int i = 0;i < n;i++)
  {
    long long int a;
    int b;
    cin >> a >> b;
    v.push_back(make_pair(a,b));
  }
  sort(v.begin(),v.end());
  long long int price_sum = 0;
  int need = m;
  for(int i = 0;i < n;i++)
  {
    if(need >= v[i].second)
    {
      price_sum = price_sum + v[i].first * v[i].second;
      need = need - v[i].second;
    }
    else
    {
      price_sum = price_sum + v[i].first * need;
      break;
    }
  }
  cout << price_sum << "\n";

  return 0;
}

Measured memory_bytes: 2420
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ocnt = 0;
  int ccnt = 0;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '(') ocnt++;
    else ccnt++;
    if (ocnt < ccnt) {
      cnt++;
      ocnt++;
    }
  }

  for (int i = 0; i < cnt; ++i) {
    s = "(" + s;
  }

  ocnt = 0;
  ccnt = 0;
  cnt = 0;
  for (int i = s.size() - 1; i >= 0; --i) {
    if (s[i] == ')') ccnt++;
    else ocnt++;
    if (ccnt < ocnt) {
      cnt++;
      ccnt++;
    }
  }
  for (int i = 0; i < cnt; ++i) {
    s += ")";
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int A, B, C, K, count = 0, ans = 0 ;
  cin >> A >> B >> C >> K ;
  while(A >= B){
    count++ ;
    B *= 2 ;
  }
  while(B >= C){
    count++ ;
    C *= 2 ;
  }
  if(K >= count){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  } 
  return 0 ;
}  

Measured memory_bytes: 3628
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

struct UnionFind {
	vector<long> par;//親を返す

	UnionFind(long N) : par(N){
		for (int i = 0; i < N; i++) par[i] = i;//全て根である状態
	}

	long root(long i) {//根を返す
		if (par[i] == i) return i;
	    return par[i] = root(par[i]); //根に直接繋ぎなおす
	}

	void unite(long x, long y) {//二つの木の統合(rxをryに繋ぐ)
		long rx = root(x);
		long ry = root(y);

		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(long x, long y) { return root(x) == root(y); }//根が等しいか
};

int main() {

	long N, M; cin >> N >> M;
	long res = 1;
	UnionFind tree(N);

	for (int i = 0; i < M; i++) {
		long x, y, z; cin >> x >> y >> z;
		x--; y--;
		tree.unite(x, y);
	}

	long roots[100009];//それぞれの根を記録
	for (int i = 0; i < N; i++) roots[i] = tree.root(i);

	sort(roots, roots + N);//O(log N)

	for (int i = 1; i < N; i++) if (roots[i - 1] != roots[i]) res++; //根の種数の走査

	cout << res << endl;
}

Measured memory_bytes: 2048
n, m = map(int, input().split())
edge = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

visited = [0] * n
def dfs(v, p):
    if sum(visited) == n:
        return 1
    res = 0
    for u in edge[v]:
        if u != p and visited[u] == 0:
            visited[u] = 1
            res += dfs(u, v)
            visited[u] = 0
    return res

visited[0] = 1
ans = dfs(0, -1)

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int number[3], i;

	scanf("%d%d%d", &number[0], &number[1], &number[2]);

	if (number[0] >= number[1])
	{
		i = number[0];
		number[0] = number[1];
		number[1] = i;
	}

	if (number[1] >= number[2])
	{
		i = number[1];
		number[1] = number[2];
		number[2] = i;
	}

	if (number[0] >= number[1])
	{
		i = number[0];
		number[0] = number[1];
		number[1] = i;
	}

	printf("%d %d %d\n", number[0], number[1], number[2]);

	return 0;
}



Measured memory_bytes: 2128
lis=[]

while True:
	m,f,r=[int(x) for x in input().split()]
	if m==-1 and f==-1 and r==-1:
		break
	lis.append([m,f,r])

for i in lis:
	m,f,r=i[0],i[1],i[2]
	res=""
	if m==-1 or f==-1:
		res="F"
	elif 30<=m+f and m+f < 50:
		if 50<=r:
			res="C"
		else:
			res="D"
	elif 50<=m+f and m+f<65:
		res="C"
	elif 65 <= m+f < 80:
		res="B"
	elif 80<= m+f:
		res="A"
	elif m+f < 30:
		res="F"

	print(res)


Measured memory_bytes: 5604
n = int(input())
a = list(map(int, input().split()))
#4で割れる数、2で割れるかず、そうでない数をそれぞれ数えるためのカウント
count_4 = 0
count_2 = 0
count = 0
for i in range(n):
    if a[i] % 4 == 0:
        count_4 += 1
    elif a[i] % 2 == 0:
        count_2 += 1
    else:
        count += 1
if count_2 == 0:
    count_4 += 1
if count_4 >= count :
    print("Yes")
else:
    print("No")


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

using namespace std;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    /*
        容器2から容器1へmin(c,a-b)リットル水を移すので、
            c - min(c,a-b)
        が答え.
     */
     cout << c - min(c,a-b) << endl;
     return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
abc = [tuple(map(int,input().split())) for i in range(n)]

dp_a = [0]*n
dp_b = [0]*n
dp_c = [0]*n

a,b,c = abc[0]
dp_a[0] = a
dp_b[0] = b
dp_c[0] = c

for i in range(1,n):
    a, b, c = abc[i]
    dp_a[i] = max(dp_b[i-1]+a, dp_c[i-1]+a)
    dp_b[i] = max(dp_c[i-1]+b, dp_a[i-1]+b)
    dp_c[i] = max(dp_a[i-1]+c, dp_b[i-1]+c)

print(max(dp_a[-1], dp_b[-1], dp_c[-1]))


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int n;
string s;

void dfs(char Max){
	if(s.size()==n){
		cout<<s<<endl;
		return;
	}
	for(char c='a';c<=Max+1;c++){
		s+=c;
		dfs(max(c,Max));
		s.pop_back();
	}
}
int main(){
	cin>>n;
	s="a";
	dfs('a');
}

Measured memory_bytes: 1536
fun main(args: Array<String>) {
    /**
     * 解説を見てみると，回答方針はあっていた模様，どこの処理が遅い書き方になっていて TLEになっていたのか分析する
     */


    val (h, w) = readLine()!!.split(" ").map { it.toInt() }

    val inputs = mutableListOf<String>()

    // bufferedReader を使えば早くなりそう？？ と思ったが RE が発生してしまい使えなかった

    // map を使うと処理に時間がかかって間に合わなくなる??
    for (i in 0 until h) {
        val line = readLine()!!
        inputs.add(line)
    }

    val fieldHorizontal = Array(h) { IntArray(w) { 1 } }
    val fieldVertical = Array(h) { IntArray(w) { 1 } }

    // 横方向へ塗っていく
    for (i in 0 until h) {
        for (j in 1 until w) {
            // 岩はスキップ

            if (inputs[i][j] == '#') {
                fieldHorizontal[i][j] = 0
                continue
            }

            fieldHorizontal[i][j] = fieldHorizontal[i][j - 1] + 1
        }
    }

    // 塗った結果を逆方向から反映させていく
    for (i in 0 until h) {
        var maxTmp = fieldHorizontal[i][w - 1]
        for (j in w - 2 downTo 0) {
            // 岩はスキップ
            if (inputs[i][j] == '#') {
                maxTmp = 0
                continue
            }
            maxTmp = Math.max(maxTmp, fieldHorizontal[i][j])
            fieldHorizontal[i][j] = maxTmp
        }
    }


    // 縦方向へ塗っていく
    for (j in 0 until w) {
        for (i in 1 until h) {
            // 岩はスキップ
            if (inputs[i][j] == '#') {
                fieldVertical[i][j] = 0
                continue
            }
            fieldVertical[i][j] = fieldVertical[i - 1][j] + 1
        }
    }

    // 塗った結果を逆方向から反映させていく
    for (j in 0 until w) {
        var maxTmp = fieldVertical[h - 1][j]
        for (i in h - 2 downTo 0) {
            // 岩はスキップ
            if (inputs[i][j] == '#') {
                maxTmp = 0
                continue
            }
            maxTmp = Math.max(maxTmp, fieldVertical[i][j])
            fieldVertical[i][j] = maxTmp
        }
    }


    var ans = 0
    for (i in 0 until h) {
        for (j in 0 until w) {
            ans = Math.max(ans, fieldHorizontal[i][j] + fieldVertical[i][j])
        }
    }

    println(ans - 1)
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

ll gcd(ll m, ll n) {
    ll tmp;
    while (m % n != 0) {
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

ll lcm(ll m, ll n) {
    return max(m, n)/gcd(m,n) * min(m,n);
}

using Graph = vector<vector<int>>;

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

ll modnum = 1e9+7;

int main() {
    string s; cin >> s;
    int n = s.size()-1;
    ll ans = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<string> nums;
        string tmp = "";
        tmp += s[0];
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                nums.push_back(tmp);
                tmp = s[i+1];
            } else {
                tmp += s[i+1];
            }
        }
        if(tmp.size() > 0) nums.push_back(tmp);
        rep(i, nums.size()) {
            ans += atoll(nums[i].c_str());
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,m=MI()
sws=[]
for i in range(m):
    sws.append(list(map(int,input().split())))
#print(sws)
ps=LI()
ans=0
for i in range(2**n):
    count=0
    for j in range(m):
        sm=0
        for k in range(1,len(sws[j])):
            sm+= (i>>(sws[j][k]-1)) %2
        #print(sm)
        if sm%2==ps[j]:
            count+=1
    if count==m:
        ans+=1
print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
 
using namespace std;
  
int main() {
  long long n;
  cin >> n;
  
  vector<char> s;
  char current;
  
  vector<char> sd;
  
  for(long long i; i < n; i++){
    char b;
    cin >> b;
    s.push_back(b);
  }
  
  for(long long i; i < n; i++){
    if(current != s.at(i)){
      sd.push_back(s.at(i));
      current = s.at(i);
    }
  }  
  cout << sd.size();
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
#define ALL(a)  (a).begin(),(a).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

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

	int ans = 0;
	int N; cin >> N;
	int K; cin >> K;
	REP(i, N) {
		int h; cin >> h;
		if (h >= K)ans++;
	}
	print(ans);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, x, t := io.NextInt(), io.NextInt(), io.NextInt()
	q := n / x
	r := n % x
	times := q
	if r != 0 {
		times++
	}
	io.Println(t * times)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1772
import Data.List (nub, sort)

main :: IO ()
main = do
    n <- readLn
    as <- (map read . words) <$> getLine
    putStrLn $ solve n as

-- |
--
-- >>> solve 4 [2100,2500,2700,2700]
-- "2 2"
--
-- >>> solve 5 [1100,1900,2800,3200,3200]
-- "3 5"
--
-- >>> solve 20 [800,810,820,830,840,850,860,870,880,890,900,910,920,930,940,950,960,970,980,990]
-- "1 1"
solve :: Int -> [Int] -> String
solve n as = show k_min ++ " " ++  show k_max
  where
    as_lower = takeWhile (< 3200) $ sort as
    n_lower = length as_lower
    n_upper = n - n_lower
    k_min' = length . nub . map (`div` 400) $ as_lower
    k_min = if k_min' == 0 then 1 else k_min'
    k_max = if k_min' == 0 then n_upper else k_min' + n_upper



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

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

    int r = 1;
    for (int i = 0; i < n; i++) {
        r = min(r + k, r * 2);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int a = sc.nextInt();
    int ans = 0;
    if (h % a == 0) {
    	ans = h/a;
    } else {
    	ans = h/a + 1;
    }
    System.out.println(ans);
  }
}



Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const 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.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define dbg(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define dbg(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

int main() {
  string s; cin>>s;
  int q; cin>>q;

  vector<string> t(2);

  int flg = 0;
  while(q--) {
    int a; cin>>a;
    if (a == 1) {
      flg ^= 1;
    } else {
      int f; cin>>f; f--;
      char c; cin>>c;
      t[flg^f].push_back(c);
    }
  }

  if (flg) {
    reverse(s.begin(), s.end());
    reverse(t[1].begin(), t[1].end());
    cout << t[1] << s << t[0] << endl;
  } else {
    reverse(t[0].begin(), t[0].end());
    cout << t[0] << s << t[1] << endl;
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int r, g;
  cin >> r >> g;

  int ans = 2 * g - r;
  cout << ans << endl;
  return 0;
}


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

int N;

int main(){
	cin >> N;
	bool pairwise = true, setwise = true;
	int gcd = 0;
	set < int > ct;

	while (N --){
		int A;
		cin >> A;
		gcd = __gcd(gcd, A);
		for (int j = 1; j*j <= A; j ++){
			if (A % j == 0){
				if ((j != 1) && ct.find(j) != ct.end()){
					pairwise = false;
					break;
				}else{
					ct.insert(j);
				}
				if (j != (A / j)){
					if((A/j != 1) && ct.find(A/j) != ct.end()){
						pairwise = false;
						break;
					}else{
						ct.insert(A/j);
					}
				}
			}
		}
	}
	setwise = (gcd == 1);

	if (pairwise){
		cout << "pairwise coprime\n";
	}else if (setwise){
		cout << "setwise coprime\n";
	}else{
		cout << "not coprime\n";
	}

}

Measured memory_bytes: 50348
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1000000000
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll t;
    cin>>t;
    vector<double>dp(t+1, 0);
    dp[0]=1;
    REP(i, 0, t){
        double x;
        cin>>x;
        for(ll j = t+1; j>=0; j--){
            dp[j] = dp[j]*(1-x);
            if(j > 0){
                dp[j]+=dp[j-1]*x;
            }
        }
    }
    double ans=0;
    REP(i, t/2+1, t+1){
        ans+=dp[i];
    }
    cout<<fixed<<setprecision(10)<<ans;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
const int N=200005,M=20,L=266666;
 
int n,m,x[N],U,dp1[L],dp2[L];
int nex[M][N],pre[M][N],sz[M],k;
int mx[N];
 
void make(int V,int*nx,int*pr){
	nx[n]=n;
	for(int i=n-1;i>=1;i--)if(x[i+1]-x[i]>V)nx[i]=i;else nx[i]=nx[i+1];
	pr[1]=1;
	for(int i=2;i<=n;i++)if(x[i]-x[i-1]>V)pr[i]=i;else pr[i]=pr[i-1];
}
 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&x[i]);
	for(int i=m>>1;i>=1;i>>=1)sz[k++]=i;sz[k++]=0;
	sz[k]=m;
	for(int i=0;i<=k;i++)make(sz[i],nex[i],pre[i]);
	U=1<<k;
	for(int i=0;i<U;i++)dp1[i]=0,dp2[i]=n+1;
	for(int i=0;i<U;i++)for(int j=0;j<k;j++)
		if(~i>>j&1){
			if(dp1[i]==n)dp1[i|1<<j]=n;
			else dp1[i|1<<j]=max(dp1[i|1<<j],nex[j][dp1[i]+1]);
			if(dp2[i]==1)dp2[i|1<<j]=1;
			else dp2[i|1<<j]=min(dp2[i|1<<j],pre[j][dp2[i]-1]);
		}
	memset(mx,-1,sizeof(mx));
	for(int i=0;i<U;i++){
		mx[dp2[i]]=max(mx[dp2[i]],dp1[(U-1)^i]);
	}
	for(int i=1;i<=n+1;i++)
		mx[i]=max(mx[i],mx[i-1]);
	for(int i=1;i<=n;i++){
		if(mx[nex[k][i]+1]>=pre[k][i]-1)
			puts("Possible");
		else
			puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 37248
N=int(input())
S=[]
T=[]
for i in range(N):
  s=int(input())
  S+=[s]
  if not s%10==0:
    T+=[s]
answer=sum(S)
if answer%10==0:
  if not T==[]:
    answer -=min(T)
  else:
    answer=0
print(answer)
 

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

def judge(n):
    n *= 2
    for d in range(1,n):
        if n == d*(d+1):
            return True, d
    return False, -1

# k : 部分集合の大きさ
# k+1 : 部分集合の数
flag, k = judge(N)
if not flag:
    print("No")
    exit()

print("Yes")
print(k+1)

l = [[] for _ in range(k+1)]
c = 1
for i in range(k+1):
    for j in range(i+1, k+1):
        l[i].append(c)
        l[j].append(c)
        c += 1

for line in l:
    print(k, end = " ")
    print(*line)

Measured memory_bytes: 9424
#include <stdio.h>
/*
ABC132 B
twitter　@oct0pus_G
気軽にフォローしてくださいね
*/

int main(void)
{
  int N;
  int count = 0;
  int array[50] = {0};

  scanf("%d", &N);
  for (size_t i = 1; i <= N; i++) {
    scanf("%d", &array[i]);
  }

  for (size_t i = 1; i <= N-2; i++) {
    if ((array[i] < array[i+1] && array[i+1] < array[i+2]) || (array[i+2] < array[i+1] && array[i+1] < array[i])) {
      count++;
    }
  }

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


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int m, n1, n2; cin >> m >> n1 >> n2;
    if (m == 0 and n1 == 0 and n2 == 0) break;
    vector<int> P(m); REP(i, m) cin >> P[i];
    sort(ALL(P));
    int max_gap = -1, max_idx = m - n2 + 1;
    FOR(i, m - n2, m - n1 + 1) {
      if (max_gap < P[i] - P[i-1]) max_gap = P[i] - P[i-1], max_idx = i;
    }
    cout << m - max_idx << endl;
  }

  return 0;
}

Measured memory_bytes: 3040
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

string str;
int pos;

typedef struct _panel{
  string name;
  set<_panel> child;
  int x1,y1,x2,y2;
  bool operator<(const _panel&r)const{
    if(x1!=r.x1)return x1<r.x1;
    if(y1!=r.y1)return y1<r.y1;
    if(x2!=r.x2)return x2<r.x2;
    if(y2!=r.y2)return y2<r.y2;
    if(name!=r.name)return name<r.name;
    return child<r.child;
  }
}panel;


string gettagname(){
  string ret;
  ++pos;
  if(str[pos]=='/')++pos;
  while(str[pos]!='>'){
    //cout<<ret<<endl;
    ret+=str[pos];
    ++pos;
  }
  ++pos;
  return ret;
}

int getnum(){
  while(!isdigit(str[pos]))++pos;
  int ret=0;
  while(isdigit(str[pos])){
    ret=ret*10+str[pos]-'0';
    ++pos;
  }
  return ret;
}

panel gettagstr(){
  panel ret;
  string tagname=gettagname();
  //cout<<tagname<<endl;
  int x1=getnum(),
    y1=getnum(),
    x2=getnum(),
    y2=getnum();
  ret.x1=x1;
  ret.y1=y1;
  ret.x2=x2;
  ret.y2=y2;
  ret.name=tagname;

  while(str[pos+1]!='/'){
    panel add=gettagstr();
    ret.child.insert(add);
  }
  gettagname();
  return ret;
}

panel pare;

int dfs(int x,int y,const panel& se){
  FOR(siter,se.child){
    const panel& tp=*siter;
    if(tp.x1<=x && x<=tp.x2 && tp.y1<=y && y<=tp.y2){
      return dfs(x,y,tp);
    }
  }
  cout<<se.name<<" ";
  return se.child.size();
}

main(){
  int n;
  while(cin>>n,n){
    cin>>str;
    pos=0;
    pare=gettagstr();
    //puts("parse con");
    //cout<<pare.x1<<" "<<pare.y1<<" "<<pare.x2<<" "<<pare.y2<<endl;
    
    while(n--){
      int x,y;
      cin>>x>>y;
      if(pare.x1>x || x>pare.x2 || pare.y1>y || y>pare.y2){
	cout<<"OUT OF MAIN PANEL 1"<<endl;
      }else cout<<dfs(x,y,pare)<<endl;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        string t;
        cin>>t;
        int n=t.size();
        fr(i,0,n)
        {
            if(t[i]=='?') cout<<'D';
            else cout<<t[i];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3780