akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int main ()
{
    lli n,k;
    cin >> n >> k;
    lli a[n+2];
    lli sum=0;
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    for(int i=0;i<n-k;i++)
        sum+=a[i];
    cout << sum <<endl;

    return 0;
}



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

int n,k;
long double ans=0.0,nw;

int main()
{
	scanf("%d%d",&n,&k);int i;
	for(i=1;i<=n;++i)
	{
		int tt=i;nw=1;
		while(tt<k) nw/=2,tt*=2;
		ans+=nw/n;
	}
	printf("%.12Lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
ll n, p[100000], a[100001], ans;
set<ll> l, r;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    a[p[i]] = i + 1LL;
  }
  l.insert(-a[n]);
  r.insert(a[n]);
  for (ll i = n - 1LL; i >= 1LL; i--) {
    set<ll>::iterator left = l.upper_bound(-a[i]);
    set<ll>::iterator right = r.lower_bound(a[i]);
    if (left == l.end()) {
      set<ll>::iterator it = r.upper_bound(*right);
      if (it != r.end()) {
        ans += i * a[i] * (*it - *right);
      } else {
        ans += i * a[i] * (n + 1LL - *right);
      }
    } else if (right == r.end()) {
      set<ll>::iterator it = l.upper_bound(*left);
      if (it != l.end()) {
        ans += i * (n + 1LL - a[i]) * (*it - *left);
      } else {
        ans += i * (n + 1LL - a[i]) * (-*left);
      }
    } else {
      set<ll>::iterator it = r.upper_bound(*right);
      if (it != r.end()) {
        ans += i * (a[i] + *left) * (*it - *right);
      } else {
        ans += i * (a[i] + *left) * (n + 1LL - *right);
      }
      it = l.upper_bound(*left);
      if (it != l.end()) {
        ans += i * (*right - a[i]) * (*it - *left);
      } else {
        ans += i * (*right - a[i]) * (-*left);
      }
    }
    l.insert(-a[i]);
    r.insert(a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char a[10];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> a;
	if(a[2]==a[3]&&a[4]==a[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main(){
    int stack[200];
    
    int top=0;
    char check[15];
    
    while(scanf("%s", check) != EOF){
        if(check[0] == '+'){
            stack[top-1] = stack[top-1] + stack[top];
            top--;
            
        } else if(check[0] == '-'){
            stack[top-1] = stack[top-1] - stack[top];
            top--;

        } else if(check[0] == '*'){
            stack[top-1] = stack[top-1] * stack[top];
            top--;

        } else { 
            stack[top+1] = atoi(check);
            top++;
        }
    }
    

    cout << stack[top] << endl;
    
    return 0;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  deque<char> dq;
  for(int i=0;i<s.size();i++){
    if(s[i]!='B')dq.push_back(s[i]);
    else if(!dq.empty())dq.pop_back();
  }
  while(!dq.empty()){
    cout<<dq.front();
    dq.pop_front();
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,s,count;
 
int solve(int i,int sum,int used){
	if(i==10){
		if(s==sum&&used==n){
 
		count++;
		}
		return count;
	}
	solve(i+1,sum+i,used+1);
 
	solve(i+1,sum,used);
 
 
	return count;
}
 
int main(){
 
	while(cin>>n>>s,n||s){
	count=0;
 
	cout<<solve(0,0,0)<<endl;
	}
 
return 0;
}

Measured memory_bytes: 1160
K = int(input())
verbose = False

path = set()
a = 0
step = 0
while True:
    step += 1
    a = (a*10 + 7) % K
    if verbose: print (step, ':', a)
    if a == 0:
        print (step)
        break
    if a in path:
        print ('-1')
        break
    path.add(a)


Measured memory_bytes: 78020
#include <cstdio>
#include <vector>

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main() {
    int n, cnt;
    scanf("%d", &n);
    vector< vector<int> > a(n, vector<int>(n));
    vector<ll> dp(1 << n, 0);
    dp.at(0) = 1;
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) scanf("%d", a.at(i).begin() + j);
    for (int i = 0; i < (1 << n); ++i) {
        cnt = 0;
        for (int j = 0; j < n; ++j) if (i & (1 << j)) ++cnt;
        for (int j = 0; j < n; ++j) if ((~i & (1 << j)) && (a.at(j).at(cnt))) {
            dp.at(i | (1 << j)) += dp.at(i);
            dp.at(i | (1 << j)) %= MOD;
        }
    }
    printf("%lld\n", dp.back());
    return 0;
}

Measured memory_bytes: 16640
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, v, p;
  cin >> n >> m >> v >> p;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int ans = 0;
  ll cur = 0;
  for (int i = 0; i < n; i++) {
    if (i < p) {
      ans++;
      if (i == p - 1) cur += a[i];
    } else {
      int rem = n - 1 - i;
      int have = v - 1;
      have -= min(have, rem);
      ll my_val = a[i] + m;
      int ot = p - 1;
      have -= min(have, ot);
      if (my_val - a[p - 1] >= 0) {
        int cnt = (i - (p - 1));
        ll ok = my_val * cnt - cur;
        if (ok >= have * (ll) m) {
          ans++;
        }
      }
      cur += a[i];
    }
  }
  cout << ans << '\n';
}


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

typedef long long int lli;

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

    lli n;
    cin >> n;

    vector<lli> v(n + 1);
    lli counter = 0;

    for(int i = 1; i <= n; i++)
    {
        cin >> v[i];

        if(i%2 == 1 && v[i]%2 == 1)
        {
            counter++;
        }
    }

    cout << counter << endl;


}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<double, vector<double>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  minq pq;
  rep(i,n) {
    int v; cin >> v;
    pq.push(v);
  }
  double ans = 0;
  while (pq.size() > 1){
    double a = pq.top(); pq.pop();
    double b = pq.top(); pq.pop();
    pq.push((a+b)/(double)2);
  }
  ans = pq.top();
  printf("%.10f\n", ans);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	map<int, int>mp;
	mp[a]++; mp[b]++; mp[c]++;
	for (auto m : mp) {
		if (m.second == 1)cout << m.first << endl;
	}
	return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
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;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n;cin >> n;
    vl a(n);
    cin >> a;

    // i日目に株をj株持っているときのお金
    vl dp(n+1);
    dp[0] = 1000;
    for(int i=0;i<n;++i){
        // dp[i+1] の更新
        for(int j=0;j<=i;++j){
            dp[i+1] = max({dp[i+1], dp[j]/a[j] * a[i] + dp[j]%a[j], dp[j]});
        }
    }
    cout << dp[n] << endl;
}

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

int main() {
  long N;
  cin >> N;
  map<long, long> MA;
  long sum = 0;
  for (long i = 0; i < N; i++) {
    long A;
    cin >> A;
    MA[A]++;
    sum += A;
  }
  long Q;
  cin >> Q;
  while (Q--) {
    long B, C;
    cin >> B >> C;
    sum -= B * MA[B];
    sum += C * MA[B];
    MA[C] += MA[B];
    MA[B] = 0;
    cout << sum << "\n";
  }
}

Measured memory_bytes: 9364
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on July 2, 2018, 2:54 PM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int canMake(int index, int M, int *A, int size);

int main(int argc, char** argv) {
    int n, q;
    int *A, *M;
    scanf("%d", &n);
    A = (int *)malloc(sizeof(int) * n);
    for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
    scanf("%d", &q);
    M = (int *)malloc(sizeof(int) * q);
    for (int j = 0; j < q; ++j) scanf("%d", &M[j]);
    
    for (int ix = 0; ix < q; ++ix)
    {
    if ( canMake(0, M[ix], A, n)) printf("yes\n");
    else { printf("no\n"); }
    }
    
    return (EXIT_SUCCESS);
}

int canMake(int index, int M, int *A, int size)
{
    if (M == 0) return 1;
    if (index >= size) return 0;
    int result = canMake(index+1, M, A, size) || canMake(index+1, M - A[index], A, size);
    return result;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    int x,l;
    vector<pair<int,int>> XL;
    vector<int> G;
    cin >> N;
    REP(i,N){
        cin >> x >> l;
        XL.push_back({x+l,x-l});
        G.push_back(x+l);
    }
    sort(XL.begin(),XL.end());
    sort(G.begin(),G.end());
    int mx = -INF;
    int Ans=0;
    REP(i,N){
        if(mx<=XL[i].second){
            Ans++;
            mx=XL[i].first;
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 3568
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


n = int(input())
a, b, ans = make_divisors(n), make_divisors(n-1), 0
for i in range(1, len(a)):
    tmp = n
    while tmp % a[i] == 0:
        tmp = tmp // a[i]
    if (tmp-1) % a[i] == 0:
        ans += 1
ans += len(b)
print(ans-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

    int N, H;
    cin >> N >> H;
    int a, b;
    priority_queue<P> que;
    rep(i,N){
        cin >> a >> b;
        que.push(P(b, 1));
        que.push(P(a, 2));
    }
    int ans = 0;
    while(true){
        P p = que.top();
        que.pop();
        int x = p.first;
        if(p.second == 1){
            ans++;
            H -= x;
            if(H <= 0){
                cout << ans << endl;
                return 0;
            }
        }
        else{
            ans += (H+x-1)/x;
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 6256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>
 
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
 
using namespace std;

mt19937 rr(random_device{}());

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;
typedef complex<double> Complex;

int main() {    
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);    
    cout.tie(0);

    ll a, b, c, d;
    ll n;
    cin >> a >> b >> c >> d;
    cin >> n;
    ll x = min({4 * a, 2 * b, c});
    ll y = min(2 * x, d);

    if (y == 2 * x) {
        cout << n * x << endl;
    } else {
        cout << (n / 2) * y + (n % 2) * x << endl;
    }
 
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  if(N%1000==0){
    PRINT(0);
  }else{
    PRINT(1000-N%1000);
  }
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

int n;
void solve(){
    cin >> n;
    vector<int> c(n), s(n), f(n);
    for(int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];

    for(int i = 0; i < n; i++){
        int t = 0;
        for(int j = i; j < n-1; j++){
            if(t < s[j]) t = s[j]+c[j];
            else if(t%f[j] == 0) t += c[j];
            else t += f[j]-t%f[j] + c[j];
        }
        cout << t << '\n';
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3680
def main():
    N = int(input())

    NumList = [int(i) for i in input().split(' ')]
    diffcount = 0

    for i in range(N-1):
        
        if(i + 1 != NumList[i]):
            diffcount += 1

        if(diffcount > 2):
            print("NO")
            break    
    else:
        print("YES")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	const sum = a + b
	if (sum >= 10) console.log('error')
	else console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
use std::cmp::*;
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: &str = itr.next().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let n = s.len();

    let mut list = Vec::new();

    for i in 0..n {
        for j in 1..k + 1 {
            if i + j <= n {
                list.push(&s[i..i + j]);
            }
        }
    }
    list.sort();
    list.dedup();
    println!("{}", list[k - 1]);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main (){
  int n,h,k,x,i,total=0;
  scanf("%d",&n);
  scanf("%d",&k);
  for(i=0;i<n;i++){
  	scanf("%d",&x);
  	h=x-k;
  	if(h<0){
  			h=-h;
  			}
  	if(x<0){
  			x=-x;
  			}	
  	if(h<x){
  		total=total+h+h;
  	}
  	else{
  		total=total+x+x;
  	}
  }
  printf("%d",total);
  return 0;
}

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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for(int i=0; i<n; i++)cin >> a[i];
	vector<int> b(a);
	sort(b.begin(), b.end());
	if(b[n-1] == b[n-2])for(int i=0; i < n; i++)cout << b[n-1] << "\n";
	else{
		for(int i=0; i < n; i++){
			if(a[i] == b[n-1]){
				cout << b[n-2] << endl;
			}
			else{
				cout << b[n-1] << "\n";
				
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3200
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val n = sc.nextInt()
        val w = Array(n) { sc.next() }
        val hs = HashSet<String>()
        hs.add(w[0])
        for (i in 1 until n) {
            if(w[i-1].last() != w[i][0]){
                println("No")
                return
            }
            if(!hs.add(w[i])){
                println("No")
                return
            }
        }
        println("Yes")
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 31268
import java.io.*;

public class Main {
    
  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //String[] in1 = br.readLine().split(" ");
    //int N = Integer.parseInt(in1[0]);
    String S = br.readLine();
    
    br.close();

    int N = S.length();
    int stockedS = 0;
    int ans = N;
    for(int i = 0; i < N; i++){
      if(S.charAt(i) == 'S') stockedS++;
      else if(stockedS > 0){
        stockedS--;
        ans -= 2;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 25644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
using namespace std;
list<int> lst;
char op[15];
int dd;
int n;
struct Item
{
    Item *prev;
    Item *next;
    int v;
};
Item *head=NULL;
void init()
{
   head=new Item();
   head->next=head;
   head->prev=head;
}
Item * fnd(int d)
{
    Item *cur=head->next;
    while(cur!=head&&cur->v!=d)
    {
        cur=cur->next;
    }
    return cur;
}
void insert(int d)
{
    Item *item=new Item();
    item->v=d;
    head->next->prev=item;
    item->next=head->next;
    head->next=item;
    item->prev=head;
}
void del(Item *item)
{
    if(item==head) return;
    item->prev->next=item->next;
    item->next->prev=item->prev;
    delete item;
}
void del_first()
{
   del(head->next);
}
void del_last()
{
    del(head->prev);
}
void del_all()
{
    while(head->next!=head) del_first();

}
void print()
{
    Item *p=head->next;
    while(p!=head)
    {
        if(p!=head->next) printf(" ");
        printf("%d",p->v);
        p=p->next;
    }
    printf("\n");
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    init();
    while(n--)
    {
        getchar();
        scanf("%s",op);
        if(strlen(op)<=6)
        {
            if(op[0]=='i')
            {
                scanf("%d",&dd);
                insert(dd);

            }
            else  if(op[0]=='d')
            {
                scanf("%d",&dd);
                del(fnd(dd));

            }
        }
        else
        {
            if(op[6]=='F')
            {
                del_first();
            }
            else if(op[6]=='L')
            {
                del_last();
            }

        }

    }
    print();
    del_all();




    return 0;
}

Measured memory_bytes: 34452
#include<iostream>
using namespace std;
int main()
{
    int N,A,B,C,D;
    cin>>N;
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>D;
    if(N/A*A==N&&N/C*C==N)
    {
        if(N/A*B<=N/C*D)
        {
            cout<<N/A*B<<endl;
        }
        if(N/A*B>N/C*D)
        {
            cout<<N/C*D<<endl;
        }
    }
    if(N/A*A<N&&N/C*C==N)
    {
        if((N/A+1)*B<=N/C*D)
        {
            cout<<(N/A+1)*B<<endl;
        }
        if((N/A+1)*B>N/C*D)
        {
            cout<<N/C*D<<endl;
        }
    }
    if(N/A*A==N&&N/C*C<N)
    {
        if(N/A*B<=(N/C+1)*D)
        {
            cout<<N/A*B<<endl;
        }
        if(N/A*B>(N/C+1)*D)
        {
            cout<<(N/C+1)*D<<endl;
        }
    }
    if(N/A*A<N&&N/C*C<N)
    {
        if((N/A+1)*B<=(N/C+1)*D)
        {
            cout<<(N/A+1)*B<<endl;
        }
        if((N/A+1)*B>(N/C+1)*D)
        {
            cout<<(N/C+1)*D<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3124
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it 💗
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//x = xDegrees*3.14159265 / 180;
//ef1tn=(( (n / 2)*( (n / 2) + 1) / 2) * 2);
//of1tn=(n * (n + 1) / 2 - 2 * ((n / 2) * (n / 2 + 1) / 2));
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
long double EPS = 1e-14;
int main(){
	K_K();
	long double a, b, c;
	cin >> a >> b >> c;
	a = sqrt(a);
	b = sqrt(b);
	c = sqrt(c);
	a += b;
	if (a > c || abs(a - c) <= EPS)
		rt("No");
	rt("Yes");
}


Measured memory_bytes: 256
from itertools import accumulate
import sys

S = input()
T = input()

ns = len(S)
nt = len(T)
SA = [0] * (ns + 1)
SB = [0] * (ns + 1)
TA = [0] * (nt + 1)
TB = [0] * (nt + 1)
for i, s in enumerate(S, 1):
    if s == "A":
        SA[i] = 1
    else:
        SB[i] = 1
for i, t in enumerate(T, 1):
    if t == "A":
        TA[i] = 1
    else:
        TB[i] = 1
SA = list(accumulate(SA))
SB = list(accumulate(SB))
TA = list(accumulate(TA))
TB = list(accumulate(TB))


q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    sa = SA[b] - SA[a - 1]
    sb = SB[b] - SB[a - 1]
    ta = TA[d] - TA[c - 1]
    tb = TB[d] - TB[c - 1]
    # ぜんぶBにしちゃう
    sb += 2 * sa
    tb += 2 * ta
    if abs(sb - tb) % 3 == 0:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 25948
#include <cstdio>

int a[100000];

int main() {
	int i, j, n, m;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i < n; i++) if (a[i] + a[i - 1] >= m) {
		puts("Possible");
		for (j = 1; j < i; j++) printf("%d\n", j);
		for (j = n - 1; j > i; j--) printf("%d\n", j);
		printf("%d\n", i);
		return 0;
	}
	puts("Impossible");
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, 3, sizeof(int), cmpint);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}


int main()
{

	int n, k;
	cin >> n >> k;

	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}

	sort(l.begin(), l.end(), greater<int>());

	long long int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += l[i];
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def per(n, r, p):
    if r < 0 or n < r:
        return 0
    return fact[n] * factinv[n-r] % p

p = 10 ** 9 + 7#mod
N = 5*pow(10, 5)  # N は必要分だけ用意する。大体問題設定のオーダーに合わせる(N >= max(n, r)。上のcmb関数のリスト同士の掛け算において、fact[n], factinv[r]を参照するため)
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n, m = map(int, input().split())
ans = 0
for i in range(n+1):
    ans += pow(per(m-i, n-i, p), 2) * per(m, i, p) * cmb(n, i, p) * (-1)**i % p
ans = ans % p
print(ans)

Measured memory_bytes: 68564
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::vector<int> a(n), vec(n + 1, 0);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		
		vec[a[i]]++;
	}
	sort(begin(a), end(a));
	
	bool f = true;
	if(a.back() % 2) {
		if(a.front() * 2 != a.back() + 1) f = false;
		if(vec[a.front()] != 2) f = false;
		
		for(int i = a.front() + 1; i <= a.back(); i++) {
			if(vec[i] > 1) continue;
			f = false;
			break;
		}
	} else {
		if(a.front() * 2 != a.back()) f = false;	
		if(vec[a.front()] != 1) f = false;
		
		for(int i = a.front() + 1; i <= a.back(); i++) {
			if(vec[i] > 1) continue;
			f = false;
			break;
		}
	}
	
	if(f) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////




int main(){
    ll n;cin>>n;
    double p[n+1];rep(i,1,n)cin>>p[i];
    double dp[n+1][n+1];memset(dp,0,sizeof(dp));
    dp[0][0]=1.0;
    rep(i,1,n){
        rep(j,0,i){
            dp[i][j]=dp[i-1][j]*(1-p[i]);
            if(j-1>=0)dp[i][j]+=dp[i-1][j-1]*p[i];
        }
    }
    double ans=0;
    rep(j,n/2+1,n)ans+=dp[n][j];
    /*rep(i,0,n){
        rep(j,0,n){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    printf("%1.20lf",ans);
    
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){
  string s[3];
  s[0]="Sunny";
  s[1]="Cloudy";
  s[2]="Rainy";
  string s1;
  cin>>s1;
  for(int i=0;i<2;i++)
  {
      if(s1==s[i]){
        cout<<s[i+1];break;}
        if(i==1)
          cout<<s[0];
  }

   return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; 
  cin >> n;
  
  int a = n%10; 
  int b = (n%100 - a)/10;
  int c = (n%1000 - (a + b*10))/100;
  int d = (n-(a + 10*b + 100*c))/1000;
  
  if (a == b && b == c){
    cout << "Yes" << endl;
  }
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define int long long
#define u64 unsigned long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=G.Head[x]; i; i=G.Nxt[i])

inline int Read() {
    int res = 0, f = 1;
    char c;
    while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
    do res = (res << 3) + (res << 1) + (c ^ 48);
    while (c = getchar(), c >= 48 && c <= 57);
    return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
    return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
    return a < b ? a = b, 1 : 0;
}

const int N = 3e5 + 5, M = 9e5 + 5;

int n, m, A[N], Ans, flag;

main() {
    n = Read();
    cout<<3*n*n;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define STEP 0.0005
// sort(a.begin(), a.end(), std::greater<int>());

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int a[110] = {0};
    rep(i, m)
    {
        int temp;
        cin >> temp;
        a[temp] = 1;
    }
    int left = 0, right = 0;
    rep(i, 110)
    {
        if (i < x)
        {
            left += a[i];
        }
        else
        {
            right += a[i];
        }
    }
    cout << min(left, right)<<endl;
    return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int N = 1e5+10;
vector<int> G[N];

signed main(){

  int n; cin >> n;
  vector<int> in(n,0);
  for(int i = 0; i < n-1; i++){
    int a,b; cin >> a >> b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
    in[a]++;
    in[b]++;
  }
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  sort(c.rbegin(),c.rend());

  int start = -1,res = 0;
  for(int i = 0; i < n; i++){
    if(res <= in[i]){
      res = in[i];
      start = i;
    }
  }
  //cout << start << endl;

  int m = 0;
  int idx = 0;
  vector<bool> used(n+1,false);
  vector<int> ans(n);
  function< void(int,int) > rec =
  [&](int i,int pre){
    ans[i] = c[idx++];
    used[i] = true;
    for(int e : G[i]){
      if(e == pre) continue;
      if(used[e]) continue;
      rec(e,i);
      m += min(ans[i],ans[e]);
    }
  };
  rec(start,-1);

  cout << m << endl;
  for(int i = 0; i < n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3840
#include<algorithm>
#include<cstdio>
#define LL long long
using namespace std;
LL res,ans,f[50][50][50],g[50][50][50];
int n,sl,fh,a[50][50];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd()<<1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			scanf("%1d",&a[i][j]);
	for(int i=1;i<=n;++i)
	{
		f[i][i][i]=1;
		for(int j=i+1;j<=n;++j)
			if(a[i][j])
				g[i][i][j]+=f[i][i][i];
	}
	for(int k=3;k<=n;k+=2)
		for(int r,l=1;l+k-1<=n;++l)
		{
			r=l+k-1;
			for(int i=l;i<=r;i+=2)
				for(int j=r;j>i;j-=2)
				{
					res=0;
					for(int x=j;x<=r;++x) res+=g[l][i][x]*f[j][r][x];
					for(int x=i+1;x<j;++x) f[l][r][x]+=res*f[i+1][j-1][x];
				}
			for(int x=l;x<=r;++x)
				for(int y=r+1;y<=n;++y)
					if(a[x][y])
						g[l][r][y]+=f[l][r][x];
		}
	for(int i=2;i<=n;++i)
		if(a[1][i])
			ans+=f[2][n][i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    int N, a, b, c, d;
    cin >> N;

    a = N / 1000;
    b = (N - 1000 * a) / 100;
    c = (N / 10) % 10;
    d = N % 10;

    if (a == b && b == c)
        cout << "Yes"<<endl;
    else if (b == c && c == d)
        cout << "Yes"<<endl;
    else
        cout << "No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
map<int,int>tim;
long long n,x,t,ans,need;
int main(){
    scanf("%lld%lld%lld",&n,&x,&t);
    need=n/x;
    if(n%x)
        need++;
    ans=need*t;
    printf("%lld",ans);
}

Measured memory_bytes: 3228
class SegmentTree
  
  def initialize
    @N=2**17
    @Z=0
    @seg=Array.new(2*@N-1){@Z}
    @lazy=Array.new(2*@N-1){@Z}
  end
  
  def update(i, l, r)
    if @lazy[i].nonzero?
      @seg[i]+=@lazy[i]*(r-l)
      if r-l>1
        @lazy[2*i+1]+=@lazy[i]
        @lazy[2*i+2]+=@lazy[i]
      end
      @lazy[i]=0
    end
  end
  
  def add(a, b, x, i=0, l=0, r=@N)
    update(i, l, r)
    if b<=l or r<=a
      return
    elsif a<=l and r<=b
      @lazy[i]+=x
      update(i, l, r)
    else
      m=(r+l)/2
      add(a, b, x, 2*i+1, l, m)
      add(a, b, x, 2*i+2, m, r)
      @seg[i]=@seg[2*i+1]+@seg[2*i+2]
    end
  end
  
  def sum(a, b, i=0, l=0, r=@N)
    update(i, l, r)
    if b<=l or r<=a
      @Z
    elsif a<=l and r<=b
      @seg[i]
    else
      m=(r+l)/2
      vl=sum(a, b, 2*i+1, l, m)
      vr=sum(a, b, 2*i+2, m, r)
      vl+vr
    end
  end
  
end

st=SegmentTree.new
n, q=gets.split.map(&:to_i)
q.times do
  query=gets.chomp
  case query[0].to_i
  when 0
    c, s, t, x=query.split.map(&:to_i)
    st.add(s-1, t, x)
  when 1
    c, s, t=query.split.map(&:to_i)
    puts st.sum(s-1, t)
  end
end

Measured memory_bytes: 13136
N=int(input())
S=input()

turn_west_list=[0]
for i in range(1,N):
  if S[i-1]=="W":
    turn_west_list.append(turn_west_list[-1]+1)
  else:
    turn_west_list.append(turn_west_list[-1])

turn_east_list=[0]
for i in reversed(range(N-1)):
  if S[i+1]=="E":
    turn_east_list.append(turn_east_list[-1]+1)
  else:
    turn_east_list.append(turn_east_list[-1])
turn_east_list=list(reversed(turn_east_list))

#print(turn_west_list)
#print(turn_east_list)

answer=10**9
for i in range(N):
  answer=min(answer,turn_west_list[i]+turn_east_list[i])
  
print(answer)

Measured memory_bytes: 20380
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
	public static void main(String[] args) {  //Recursion is OVERPOWERED
		//Requirement was 10^5 upper-bound, this works for even 10^8 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long K = I.nextLong();
		long[] a = new long[15]; //This is the answer in the form of an array of digits
		Arrays.fill(a,-1);
		while (K>0) {
			UPD(a,a.length-1);
			//for (int i = 0; i < a.length; i++) O.p(a[i]+" ");
			//O.p("\n");
			K--;
		}
		boolean print = false;
		for (int i = 0; i < a.length; i++) {
			if (a[i]>0) print=true;
			if (print) O.p(a[i]);
		}
	}
	public static void UPD(long[] a, int in) {
		if (a[in]==-1) a[in]=1;
		else {
			a[in]++;
			a[in]%=10;
			if (a[in]==0) {
				UPD(a,in-1);
				a[in]=a[in-1]-1;
				a[in]=Math.max(a[in], 0); //Can't have negative digits now
			}
			if (a[in-1]!=-1&&Math.abs(a[in]-a[in-1])>1) {
				//-1 means those digit slots haven't been used yet
				UPD(a,in-1);
				a[in]=a[in-1]-1; //Reset and recurse left starting with lower-bound
				a[in]=Math.max(a[in], 0); //Can't have negative digits now
			}
		}
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 26312
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC123B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = new int[5];
            for (int i = 0; i < 5; i++)
            {
                A[i] = ReadInt;
            }

            int[] B = new int[5];
            for (int i = 0; i < 5; i++)
            {
                B[i] = A[i] - (A[i] - 1) % 10 + 9;
            }

            A = A.Select(x => x % 10).Where(x => x > 0).ToArray();
            int minus = 10;
            if (A.Length > 0) minus = A.Min();

            int ans = B.Sum() - (10 - minus);
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396