akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;


long long dp[100][21];

int main(){
  int N, c;
  
  cin >> N;
  cin >> c;
  dp[0][c] = 1;
  
  for(int i = 1; i < N-1; i++){
    cin >> c;
    for(int j = 0; j < 21; j++){
      if(dp[i-1][j]){
	int plus  = j + c;
	int minus = j - c;
	if(0 <= plus && plus <= 20){
	  //cout << "plus" << endl;
	  dp[i][plus] += dp[i-1][j];
	}
	if(0 <= minus && minus <= 20){
	  //cout << "minus" << endl;
	  dp[i][minus] += dp[i-1][j];
	}
      }
    }
  }

  /*for(int j = 0; j < N; j++){
  for(int i = 0; i < 21; i++){
    cout << dp[j][i] << " ";
  }
  cout << endl;
  }*/
  cin >> c;
  cout << dp[N-2][c] << endl;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint dp[55][55][60*60];

int main(){
    fastcin();

    int n, K;
    cin >> n >> K;
    dp[0][0][0] = 1;
    rep(i, n)rep(j, n)rep(k, n*n){
        // 保留がj個あるなら、i -> i+1するたびに奇妙さは2*j増える
        // そのままペア
        dp[i+1][j][k+2*j] += dp[i][j][k];
        // L, Rどちらかを保留から選択、片方を保留
        dp[i+1][j][k+2*j] += dp[i][j][k]*2*j;
        // L, Rどちらも保留から選択
        if(j>0) dp[i+1][j-1][k+2*j] += dp[i][j][k]*j*j;
        // L, Rどちらも保留
        dp[i+1][j+1][k+2*j] += dp[i][j][k];
    }
    cout << dp[n][0][K] << endl;
}

Measured memory_bytes: 42752
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if (A * B % 2 == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<string> vecA(N);
  vector<string> vecB(M);
  for(int i=0;i<N;i++)
    cin>>vecA.at(i);
  for(int i=0;i<M;i++)
    cin>>vecB.at(i);
  int count=0;
  bool finished=false;
  for(int i=0;i<N-M+1;i++){
  	for(int j=0;j<N-M+1;j++){
      if(vecA.at(i).at(j)==vecB.at(0).at(0)){
      	for(int k=0;k<M;k++){
          for(int l=0;l<M;l++){
            if(vecA.at(i+k).at(j+l)==vecB.at(k).at(l)){
              count++;
              if(count==M*M){
                finished=true;
                break;
              }
            }
            else{
              count=0;
              break;
            }
          }
          if(count==0||finished==true)
            break;
        }
      }
    }
    if(finished==true)
      break;
  }
  if(finished==true)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res=(a*res)%10;
        }
        a=(a*a);
        b/=2;
    }
    return res;
}  
int n,m,k;
vector<string> s(1e6+7); 
bool valid(int x,int y){ 
    if(x<1||x>n||y<1||y>m) return false;
    if(s[x-1][y-1]=='@') return false; 
    return true;
}
int dfs(int x1,int y1,int x2,int y2){
    vector<vector<int>> dis(n+1,vector<int> (m+1,1e7));
    queue<pp > q;
    dis[x1][y1]=0;
    q.push({x1,y1});
    while(!q.empty()){
        x1=q.front().ff;
        y1=q.front().ss;
        q.pop(); 
        //cout<<x1<<" "<<y1<<endl;
        for(int i=1;i<=k&&x1+i<=n;i++){
            //cout<<x1+i<<" "<<y1<<endl;
            if(!valid(x1+i,y1)) break; 
            if(dis[x1+i][y1]<dis[x1][y1]+1) break;
            if(dis[x1+i][y1]==1e7){
                dis[x1+i][y1]=dis[x1][y1]+1;
                q.push({x1+i,y1});
            }
        }
        for(int i=1;i<=k&&x1-i>0;i++){
            if(!valid(x1-i,y1)) break; 
            if(dis[x1-i][y1]<dis[x1][y1]+1) break;
            if(dis[x1-i][y1]==1e7){
                dis[x1-i][y1]=dis[x1][y1]+1;
                q.push({x1-i,y1});
            }
        }
        for(int i=1;i<=k&&y1+i<=m;i++){
            if(!valid(x1,y1+i)) break; 
            if(dis[x1][y1+i]<dis[x1][y1]+1) break;
            if(dis[x1][y1+i]==1e7){
                dis[x1][y1+i]=dis[x1][y1]+1;
                q.push({x1,y1+i});
            }
        }
        for(int i=1;i<=k&&y1-i>0;i++){
            if(!valid(x1,y1-i)) break; 
            if(dis[x1][y1-i]<dis[x1][y1]+1) break;
            if(dis[x1][y1-i]==1e7){
                dis[x1][y1-i]=dis[x1][y1]+1;
                q.push({x1,y1-i});
            }
        }
    }
    if(dis[x2][y2]==1e7) return -1;
    return dis[x2][y2];
}
void solve(){
    cin>>n>>m>>k; 
    int x1,x2,y1,y2;
    //vector<vector<int>> vis(n+1,vector<int> (m+1,0));
    cin>>x1>>y1>>x2>>y2;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cout<<dfs(x1,y1,x2,y2);
}
int main() {
	// your code goes here
	//isprime();
	//prime(); 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//int t;
	//cin>>t;
	//while(t--) 
	    solve();
	return 0; 
	
}



Measured memory_bytes: 47348
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
ll modInverse(ll a, ll m)
{
    ll g = gcd(a, m);
    return(power(a,m-2,m));
}
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/
vector<ll> v(1000000,1);

void solve()
{
    ll h,n;
    cin>>h>>n;
    ll arr[n];
    rep(i,n)
    cin>>arr[i];
    ll s=0;
    rep(i,n)
    s+=arr[i];
    if(h>s)
        puts("No");
    else
        puts("Yes");
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 8832
#include<stdio.h>
int main()
{
    int w,h,n;
    scanf("%d %d %d",&w,&h,&n);
    int l=0,r=w,u=h,d=0;
    int l_min=0,r_max=100,d_min=0,u_max=100;
    for(int i=0;i<n;i++){
        int x,y,a;
        scanf("%d %d %d",&x,&y,&a);
        if(a==1&&(x>l_min)){
            l=x;
            l_min=x;
        }
        else if(a==2&&(x<r_max)){
            r=x;
            r_max=x;
        }
        else if(a==3&&(y>d_min)){
            d=y;
            d_min=y;
        }
        else if(a==4&&(y<u_max)){
            u=y;
            u_max=y;
        }
    }
    int p=r-l,q=u-d;
    if(p<0){
        p=0;
    }
    if(q<0){
        q=0;
    }
    int ans=p*q;
    if(ans<0){
        ans=0;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        H: i64,
        W: i64,
        h: i64,
        w: i64,
    }
    println!("{}",(H-h)*(W-w));
}

Measured memory_bytes: 4352
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}
int n;
int arr[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    sort(arr, arr + n);

    map<int, int> mp;
    for (int i = 0; i < n; ++i)
    {
        //cout << arr[i] << endl;
        mp[arr[i]]++;
    }

    int sum = 0;
    for (auto e : mp)
    {
        sum += e.second - 1;
    }

    if (sum % 2 == 0)
    {
        cout << mp.size() << endl;
    }
    else
    {
        cout << mp.size() - 1 << endl;
    }

    return 0;
}

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

int main(){
    int a, num[101]={}, sum=0;
    
    for(int i=0; i<3; i++){
        cin >> a;
        num[a]++;
    }
    for(int i=0; i<101; i++){
        if(num[i] != 0) ++sum;
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
ll a[100010], num[45];
int main() {
	int n; ll k;
	cin >> n >> k;
	rep(i,n) {
		cin >> a[i];
		rep(j,40) {
			if ((a[i]>>j) & 1) num[j]++;
		}
	}

	ll x = 0;
	for (int i = 39; i >= 0; i--)	{
		if (num[i] * 2 <= n) x += (1LL << i);
		if (x > k) x -= (1LL << i);
	}
	ll ans = 0;
	rep(i,n) {
		ans += x ^ a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long b,mini = 1000000000000000;
  vector<long long> a(n + 1,0);
  for(int i = 1;i <=n;i++){
    cin >> b;
    a[i] = b + a[i - 1];
  }
  for(int i = 1;i < n;i++){
    mini = min(mini,llabs(a[i] - (a[n] - a[i])));
  }
  cout << mini << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    vector<int> nums;
    int sum = 0;
    int maxn = -1;
    for(int i = 0; i < n; ++i){
    	int x; cin >> x;
    	sum += x;
    	if(x > maxn) maxn = x;
    }
    sum = sum - maxn / 2;
    cout << sum << endl;
	return 0;
} 

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

N, A, B = list(map(int, input().split()))
ans = 0
abset = N // (A+B)

ans += A * abset

if N % (A+B) != 0:
    if A > N - (A+B)*abset:
        ans += N - (A+B)*abset
    else:
        ans += A

print(ans)


Measured memory_bytes: 3064
st = gets.chomp.split
s = st[0]
t = st[1]

ab = gets.chomp.split
a = ab[0].to_i
b = ab[1].to_i

u = gets.chomp

case u
when s
  a -= 1
when t
  b -= 1
end

puts a.to_s + " " + b.to_s

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define N 1000000007;
using namespace std;
int main()
{
   long long x;
   cin>>x;
   int nb=0;
   nb+=(x/500)*1000;
   x=x%500;
   nb+=(x/5)*5;
   cout<<nb;
    return(0);
}


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

int main(){
  char s[1003];
  scanf("%s", s);
  int n = strlen(s);
  if(s[n-1] == 's'){
    s[n+2] = s[n];
    s[n+1] = 's';
    s[n] = 'e';
  }
  else{
    s[n+1] = s[n];
    s[n] = 's';
  }
  printf("%s", s);
  return 0;
}

Measured memory_bytes: 1728
n = int(input())
for i in range(n):
    balls = list(map(int, input().split()))
    b, c = 0, 0 
    flag = 0
    for ball in balls:
        if b == 0:
            b = ball
        elif b < ball:
            b = ball
        elif c > ball:
            flag = 1
            break
        else:
            c = ball
    if flag == 0:
        print('YES')
    else:
        print("NO")



Measured memory_bytes: 5596
while(True):
    h, w = (int(x) for x in input().split())
    if (h == 0) and (w == 0):
        break;
        
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print('#', end = '')
            else:
                print('.', end = '')
        print('')
    print('')


Measured memory_bytes: 7020
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll N; int X, M; cin>>N>>X>>M;

	int mn = min(N, (ll)M);
	set<int> S;
	vector<int> A;
	ll sum_9 = 0; // sum of pre + cycle

	rp(_i, 0, mn){
		if(S.find(X) != S.end()) break;
		S.insert(X);
		A.push_back(X);
		sum_9 += X;
		X = (ll)X*X % M;
	}

	if((int)A.size() >= mn){ cout<< sum_9 <<endl; return 0; }

	int pre_len = find(A.begin(), A.end(), X) - A.begin();
	int cyc_len = A.size() - pre_len;
	int nxt_len = (N - pre_len) % cyc_len;

	ll cyc_num = (N - pre_len) / cyc_len;

	ll pre = 0; rp(i, 0, pre_len) pre += A[i];
	ll cyc = sum_9 - pre;
	ll nxt = 0; rp(i, pre_len, pre_len + nxt_len) nxt += A[i];

	cout<< pre + cyc * cyc_num + nxt <<endl;
}


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

int main(){
    int q; cin >> q;
    map<string,int> m;
    rep(i ,q){
        int man; cin >> man;
        string key;
        int x;
        switch (man)
        {
            case 0:
                cin >> key >> x;
                m[key] = x;
                break;
            case 1:
                cin >> key;
                map<string,int>::iterator itr = m.find(key);
                cout << itr->second << endl;
                break;
        }
    }
}


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

int main(){
    long a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    long dx;

    if(a-b<0){
        dx = b-a;
        if(v-w<=0) cout << "NO";
        else{
            if(dx<=(v-w)*t) cout << "YES";
            else cout << "NO";
        }
    }
    if(a-b>0){
        dx = a-b;
        if(v-w<=0) cout << "NO";
        else{
            if(dx<=(v-w)*t) cout << "YES";
            else cout << "NO";
        }
    }
    else if(a==b) cout << "YES";
}

Measured memory_bytes: 3644
// dp[i][j] means j heads using i coins;;


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define rev(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>

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

    vector<long double>p(n);
    rep(i,n) cin>>p[i];

    double dp[n+1][n+1]={0.0};

    dp[0][0]=1.0;

    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0){
                dp[i][j]=dp[i-1][j]*(1.0-p[i-1]);
            }
            else{
                dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1.0-p[i-1]);
            }
        }
    }
    long double ans=0.0;
    for(int i=(n+1)/2;i<=n;i++){
        ans+=dp[n][i];
    }
    printf("%.12Lf\n",ans);

}

Measured memory_bytes: 70528
#include <iostream>
#include <string>
#include <set>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  set<char> l;
  for (int i = 0; i < s.size(); ++i) {
    l.insert(s[i]);
  }

  int ret = 1000000;
  for (set<char>::iterator i = l.begin(); i != l.end(); ++i) {
    int tmp = 0;
    int n = s.size();
    char target = *i;
    string t = s;
    while (true) {
      bool changed = false;
      for (int j = 0; j < n - 1; ++j) {
        if (t[j] == target && t[j + 1] == target)
          continue;
        if (t[j] == target || t[j + 1] == target) {
          t[j] = target;
          changed = true;
        }
      }
      if (!changed)
        break;
      ++tmp;
      --n;
    }
    ret = min(ret, tmp);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    int L = (int)s.size();

    int m2019[200200]; // m2019[t] := 1桁目からt桁までのmod.2019を記録する (tは1-indexed)
    m2019[0] = 0;
    int t = 1;
    for(int i=0;i<L;i++){
        m2019[i+1] = (m2019[i] + (int)(s[L-i-1]-'0') * t) % 2019;
        t = t * 10 % 2019;
    }

    int cntm2019[2020];
    Fill(cntm2019,0);
    for(int i=0;i<=L;i++){
        cntm2019[m2019[i]]++;
    }

    ll ans = 0;
    for(int i=0;i<2019;i++){
        ans += cntm2019[i]*(cntm2019[i] - 1) / 2;
    }

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

Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int n = sz(s);
  reverse(all(s));
  int beki = 1, tot = 0;
  int m = 2019,ans = 0;
  vector<int> cnt(m,0);// 累積和がtotであるものが何個あるか数え上げ
  rep(i, n) {
    cnt[tot]++;
    tot +=(s[i] - '0') * beki;
    tot %= m;
    ans += cnt[tot];
    beki = (beki * 10) % m;// 次の桁が何桁目か(10の何乗か)
  }
  cout << ans << endl;
  return 0;
}


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

int main(int argc, char** argv) {
	int n;
	unsigned int sum = 0;
	vector<int> a, b;
	cin >> n;
	a.resize(n);
	b.resize(n - 1);
	for (auto &i : b) {
		cin >> i;
	}


	if (n == 2) {
		cout << b.at(0) * 2 << endl;
	}
	else {
		a.at(n - 1) = b.at(n - 2);
		a.at(0) = b.at(0);
		a.at(1) = b.at(0);

		for (int i = 1; i < n - 1; i++) {
			// cout << "Process" << endl;
			a.at(i) = min(b.at(i), b.at(i - 1));
		}

		for (auto &i : a) {
			sum += i;
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 764
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	wins := strings.Count(s, "o")
	if 15-len(s)+wins >= 8 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = sum(b) - sum(a)
s, t = 0, 0
for i in range(n):
    if a[i] < b[i]:
        if (b[i] - a[i]) % 2:
            s += 1
            t += 1
        s += (b[i] - a[i]) // 2
    else:
        t += (a[i] - b[i])
if s < max(s, t):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,x;
    cin >> n >> x;
    int d = 0;
    int cnt = 1;
    rep(i,n){
        int l;
        cin >> l;
        d += l;
        if(d<=x) cnt++;
    }
    cout << cnt <<endl;

    
    
    return 0;
}

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

#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double

int s;
int mod(int n,int m){
    n%=m;
    n=(n < 0) ? n + m : n;
    return n;
}
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    cin >> s;
    int m = (int)pow(10,9)+7;
    VI dp(s+10,0);
    dp[3]=1,dp[4]=1,dp[5]=1;
    FOR(i,5,s){
        dp[i+1] = mod(dp[i]+dp[i-2],m);
    }
    cout << dp[s] << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int64_t INF(1e15);
int main()
  {int N, W; cin >> N >> W;
  vector<vector<int64_t>> dp(N + 1, vector<int64_t>(100001, INF)); dp[0][0] = 0;
  for (int i = 0; i < N; ++i)
    {int w, v; cin >> w >> v;
    for (int j = 0; j < 100001; ++j) dp[i + 1][j] = min(dp[i][j], j >= v ? dp[i][j - v] + w : INF);}
  for (int j = 100000; j >= 0; --j) if (dp[N][j] <= W) {cout << j << endl; break;}}

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

int main(void){
    int N;
    int check = 0;
    char S[100];
    scanf("%s",S);
    N = strlen(S);
    for(int i=0; i<N; i++){
        if(S[i]!=S[N-i-1]){
            check++;
        }
    }
    for(int i=0; i<(N-1)/2; i++){
        if(S[i]!=S[(N-1)/2-i-1]){
            check++;
        }
    }
    for(int i=0; i<(N-1)/2; i++){
        if(S[N-1-i]!=S[(N+3)/2+i-1]){
            check++;
        }
    }
    if(check==0){
        printf("Yes");
    }else{
        printf("No");
    }
}

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

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

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

    int N; cin >> N;
    int W[100];

    int ans = INT_MAX;

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

    for (int i = 0;i < N;i++){
        int a = 0;
        for (int j = 0;j <= i;j++){
            a += W[j];
        }
        int b = 0;
        for (int j = N-1;j > i;j--){
            b += W[j];
        }
        ans = min(ans,abs(a-b));
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.*;
// cin=sc.nextInt();
// List<Integer> a = new ArrayList<Integer>(n);
 
public class Main {
    public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);	
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a%2==0 || b%2==0){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));

  ll ans = 0;
  if(N%2) {
    {
      int l=0, r=N-1;
      vector<int> v;
      v.push_back(A[N/2]);
      rep(i, N/2) {
        v.push_back(A[l++]);
        v.push_back(A[r--]);
      }
      ll cur = 0;
      rep(i, N-1) cur += abs(v[i+1]-v[i]);
      ans = max(cur, ans);
    }
    {
      int l=0, r=N-1;
      vector<int> v;
      v.push_back(A[N/2]);
      rep(i, N/2) {
        v.push_back(A[r--]);
        v.push_back(A[l++]);
      }
      ll cur = 0;
      rep(i, N-1) cur += abs(v[i+1]-v[i]);
      ans = max(cur, ans);
    }
  } else {
    {
      int l=0, r=N-1;
      vector<int> v;
      v.push_back(A[N/2]);
      rep(i, N/2-1) {
        v.push_back(A[l++]);
        v.push_back(A[r--]);
      }
      v.push_back(A[N/2-1]);
      ll cur = 0;
      rep(i, N-1) cur += abs(v[i+1]-v[i]);
      ans = max(cur, ans);
    }
    {
      int l=0, r=N-1;
      vector<int> v;
      v.push_back(A[N/2-1]);
      rep(i, N/2-1) {
        v.push_back(A[r--]);
        v.push_back(A[l++]);
      }
      v.push_back(A[N/2]);
      ll cur = 0;
      rep(i, N-1) cur += abs(v[i+1]-v[i]);
      ans = max(cur, ans);
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4800
import Data.Array
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

main = do
  n <- readLn
  input <- B.getContents
  let tab = listArray ((0,0),(n-1,n-1)) $ B.unpack $ B.concat $ B.lines $ input
  print (solve n tab)

type Table = Array (Int,Int) Char

isGood :: Int -> Int -> Table -> Bool
isGood n dx tab =
  and [tab!(f x,y) == tab!(f y,x) | x<-[0..n-1], y<-[x..n-1]]
  where
    f i = (i+dx)`mod`n

solve :: Int -> Table -> Int
solve n tab =
  n * length [1 | i<-[0..n-1], isGood n i tab]

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

vi v;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N; cin >> N;
    FOR(i,1,MOD) if (i*(i+1)/2 >= N) {
        FOR(j,1,i+1) if (j != i*(i+1)/2-N) cout << j << "\n";
        exit(0);
    }
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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


int main() {

    int n,m; cin >> n;
    ll tmp,tmpD,tmpT;
    string ans = "NO";
    priority_queue<ll> d,t;
    rep(i,n){
        cin >> tmp;
        d.push(tmp);
    }
    cin >> m;
    rep(i,m){
        cin >> tmp;
        t.push(tmp);
    }

    while(1) {
        tmpD = d.top();
        tmpT = t.top();
        if(tmpD == tmpT){
            d.pop();t.pop();
        }else if(tmpD > tmpT){
            d.pop();
        }else{
            break;
        }
        if(t.empty()) {
            ans = "YES";
            break;
        }
        if(d.empty()){
            break;
        }
    }
    cout << ans;

    return 0;
}











Measured memory_bytes: 7908
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,s,t;
vvi g;
vi a,b;

void dfs(int v,int p,int d){
	a[v]=b[v]=d;
	for(auto u:g[v]) if(u!=p){
		dfs(u,v,d+1);
		b[v]=max(b[v],b[u]);
	}
}

int main(){
	cin>>n>>s>>t;
	s--;t--;
	g=vvi(n);
	a=b=vi(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(t,-1,0);
	int res=0,tmp=a[s];
	while(s!=t){
		if(a[s]>=(tmp+2)/2) res=max(res,b[s]-1);
		for(auto v:g[s]) if(a[v]+1==a[s]){
			s=v;
			break;
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 12928
n = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
m = 0
mae = -1
for i in A:
    m += int(B[int(i)-1])
    if int(i) - mae  == 1:
        m += int(C[int(i)-2])
    mae = int(i)
print(m)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    scanf("%d%d",&x,&y);
    int X=0,Y=0;
    
    if(x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12){X=1;}
    else if(x==2){X=2;}
    else if(x==4 || x==6 || x==9 || x==11){X=3;}
    
    if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12){Y=1;}
    else if(y==2){Y=2;}
    else if(y==4 || y==6 || y==9 || y==11){Y=3;}
    
    if(X==Y){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    bool flag = false;
    cin >> N;
    vector<char>S(N);
    for(int i = 0;i < N;i++){
        cin >> S[i];
    }
    while(1){
        for(int i = 0;i < N - 1;i++){
            if(S[i] == S[i + 1]){
                S.erase(S.begin() + i + 1);
                N--;
                flag = true;
            }
        }
        if(flag == true){
            flag = false;
        }else{
            break;
        }
    }
    cout << N << endl;
}


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
int main()
{
    FAST
string a,b;
cin>>a>>b;
for(int i=0;i<a.length();i++)
{
    if(a==b)
        return cout<<"Yes",0;
    rotate(a.begin(),a.begin()+1,a.end());
}
cout<<"No"<<endl;
    return 0;
}


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

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

	long long ans = 0;
	if( K % 2 ) {
		long long n = N / K;
		ans += n * n * n;
	}
	else {
		long long n1 = N / K;
		long long n2 = N / (K / 2) - n1;
		ans += n1 * n1 * n1;
		ans += n2 * n2 * n2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    rep(i,n){
        int a;
        cin >> a;
        a--;
        sum += a;
    }
    cout << sum << endl; 
}

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


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

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main(){
    string S;
    cin >> S;
    string days[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    for (int i = 0; i < 7; i++){
        if (days[i] == S){
            cout << 7 - i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf LLONG_MAX
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//int mod=1e9+7;
//int mod=998244353;
int dp[N][3];

signed main()
{
    SPEED

    memset(dp,0,sizeof dp);
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1],i,j;
    for(i=1;i<=n;++i)
        cin>>a[i]>>b[i]>>c[i];

    dp[1][0]=a[1],dp[1][1]=b[1],dp[1][2]=c[1];
    for(i=2;i<=n;++i)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});


    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String S =sc.next();
    char[]ss = S.toCharArray();
    
    int cou = 0;
    for(int i=0; i<a; i++) {
    	if(ss[i] == '-') {
    		cou++;
    	}
    }
    	if(ss[a] != '-') {
    		cou++;
    	}
    for(int i=a+1; i<=a+b; i++) {
    	if(ss[i] == '-') {
        		cou++;
        	}
    	}
    if(cou==0) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
    }
}

Measured memory_bytes: 35768
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(k);
	string s; cin >> s;
	VLL cnts;
	cnts.push_back(0);
	rep(i, 0, s.length()) {
		LL last = (i == 0 ? 1 : (s[i-1]-'0'));
		LL curr = s[i]-'0';
		if(curr != last)	cnts.push_back(0);
		cnts[cnts.size()-1]++;
	}
	if(cnts.size()%2 == 0)	cnts.push_back(0);
	rep(i, 1, cnts.size())	cnts[i] += cnts[i-1];
	LL ans = 0;
	rep(i, 0, (LL)cnts.size()) {
		if(i%2 == 1)	continue;
		LL j = min(i + 2*k, (LL)cnts.size()-1);
		LL len = cnts[j] - (i > 0 ? cnts[i-1] : 0);
		ans = max(ans, len);
	}
	pll(ans); nl;
}


Measured memory_bytes: 1528
#include<iostream>
using namespace std;
#include <string>
int main()
{
    // 整数の入力
    int a;
    cin >> a;
  if(a<30)
  {
      
    // 出力
    cout <<  "No" << endl;
  }
  else
  {
      
    // 出力
    cout << "Yes" << endl;
  }
 
    return 0;
}

Measured memory_bytes: 3584
N=int(input())
d=[int(input()) for i in range(N)]
A=[]
d.sort(reverse=True)
for j, n in enumerate(d):
    if j==0:
        A.append(n)
    else:
        if A[-1]>n:
            A.append(n)
        else:
            pass
print(len(A))

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

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

int dp[1000][1000];

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char> > a(H,vector<char>(W));
    rep(i,H){
        rep(j,W){
            cin >> a[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 0 ; i < H; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j] == '#')continue;
            for(int k = 0; k < 2 ; k++){
                int nx = j+dx[k], ny = i+dy[k];
                if(nx>=0 && ny>=0 && a[ny][nx] == '.'){
                    dp[i][j] += dp[ny][nx];
                    dp[i][j] %=  MOD;
                }
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 5120
// Devarshi

/*
We will not return to the countless mistakes of the past
I will not relive the failures of the man I once was

Only through dedication will I destroy all preconception

No longer will I let myself be truly satisfied with the standard
We will not return to the countless mistakes of the past

Only through dedication will I destroy all preconception

Let this be
Be the day
Day of my
My declaration
Let this be the day of my declaration

Join me,
Walk with me

Shatter the bonds that tie us
To what we strive to never be

Join me,
Walk with me
*/
#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001;


int main(){

ll n,m;
cin>>n>>m;
map<ll,ll> naksha;
ll pre[n+1];
pre[0]=0;
ll x;
fore(i,1,n){
cin>>x;
pre[i]=pre[i-1]+x;
pre[i]%=m;
}
ll ans=0;
naksha[0]=1;
fore(i,1,n){
ans+=naksha[pre[i]];
naksha[pre[i]]++;
}
cout<<ans;

return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>

int main(void){
    // Your code here!
    int N, W[100], S1 = 0, S2 = 0, Dmin;
    
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
        scanf("%d", &W[i]);
    
    S1 = W[0];
    for(int i = 1; i < N; i++)
        S2 += W[i];
        
    Dmin = abs(S1-S2);
    
    for(int j = 1; j <= 98; j++)
    {
        S1 += W[j];
        S2 -= W[j];
        if(Dmin > abs(S1-S2))
            Dmin = abs(S1-S2);
    }
    
    printf("%d\n", Dmin);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
using namespace std;
long long gcd(long long a,long long b){
	if(a<b){
		swap(a,b);
	}
	if(a%b==0){
		return b;
	}else{
		return gcd(b,a%b);
	}
}
int main(){
	int K;
	cin>>K;
	long long ans=0;
	for(int i=1;i<=K;i++){
		for(int j=i+1;j<=K;j++){
			for(int k=j+1;k<=K;k++){
				ans+=gcd(gcd(i,j),k)*6;
			}
		}
	}
	for(int i=1;i<=K;i++){
		for(int j=i+1;j<=K;j++){
			ans+=gcd(i,j)*3*2;
		}
	}
	for(int i=1;i<=K;i++){
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

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

def count(a, b, c):
    return (a+b+c)**2-a*b-b*c-c*a

table = [0] * (N+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = count(x, y, z)
            if tmp <= N:
                table[tmp] += 1
print(*table[1:], sep="\n")

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string s, t, r;
	cin >> s >> t >> r;
	if (s.back() == t[0] && t.back() == r[0]) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

}

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


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

void trace(int A[], int N){
    int i;
    for(i = 0; i < N; i++){
        if(i > 0) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N){
    int j, i, v;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
    while(j >= 0 && A[j] > v){
        A[j+1] = A[j];
        j--;
    }
    A[j+1] = v;
    trace(A, N);
    }
}


int main(){
    int N;
    cin >> N;
    int Z[100];
    for(int i = 0; i < N; i++){
        cin >> Z[i];
    }
    trace(Z, N);
    insertionSort(Z, N);
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int here = 1;
  
  for (int i = 0; i < N + 10; i++){
    if (here == 2){
      cout << i << endl;
      break;
    }
    else{
      here = A.at(here - 1);
    }
    
    if (i > N){
      cout << -1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3788
n = int(input())
a = input().split()
b = input().split()

a_sum = 0
b_sum = 0
diff = list()
for i in range(n):
  a_sum += int(a[i])
  b_sum += int(b[i])
  diff.append(int(a[i])-int(b[i]))

if a_sum < b_sum:
  print(-1)
else:
  diff.sort()

  minus = 0
  for i in range(n):
    if diff[i] < 0:
      minus += diff[i]
    else:
      change1 = i
      break

  plus = 0
  for i in range(n-1, -1, -1):
    plus += diff[i]
    if plus >= -minus:
      change2 = n-i
      break
  
  if minus == 0:
    change2 = 0
  
  print(change1 + change2)

Measured memory_bytes: 22268