akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;

int expr(string &s, int &p);
int term(string &s, int &p);
int factor(string &s, int &p);
int number(string &s, int &p);

bool ng;
// Q ::= E=E
bool is_eq(string &s) {
    if (count(s.begin(), s.end(), '=') != 1) return false;
    int k = s.find('=');
    string a = s.substr(0, k), b = s.substr(k + 1);
    auto check = [](string &s) {
        if (s.size() == 0) return false;
        int br = 0;
        for (char c: s) {
            br += (c == '(') - (c == ')');
            if (br < 0) return false;
        }
        return br == 0;
    };
    if (!check(a) || !check(b)) return false;
    ng = false;
    int p = 0, x = expr(a, p);
    if (ng || p != a.size()) return false;
    int q = 0, y = expr(b, q);
    if (ng || q != b.size()) return false;
    return x == y;
}
// E ::= T | E+T | E−T
int expr(string &s, int &p) {
    int res = term(s, p);
    while (p < s.size()) {
        if (s[p] == '+') { res += term(s, ++p); continue; }
        if (s[p] == '-') { res -= term(s, ++p); continue; }
        break;
    }
    return res;
}
// T ::= F | T*F
int term(string &s, int &p) {
    int res = factor(s, p);
    while (p < s.size()) {
        if (s[p] == '*') { res *= factor(s, ++p); continue; }
        break;
    }
    return res;
}
// F ::= N | −F | (E)
int factor(string &s, int &p) {
    int res;
    if (s[p] == '-') {
        res = -factor(s, ++p);
    } else if (s[p] == '(') {
        ++p;
        res = expr(s, p);
        ++p;
    } else if (isdigit(s[p])) {
        res = number(s, p);
    } else {
        return ng = true;
    }
    return res;
}
// N ::= 0 | 1B
// B ::= ϵ | 0B | 1B
int number(string &s, int &p) {
    if (s[p] == '0') {
        if (p + 1 < s.size() && isdigit(s[p + 1])) return ng = true;
        return p++, 0;
    }
    int res = 0;
    while (p < s.size() && isdigit(s[p])) res = res * 2 + s[p++] - '0';
    return res;
}

int main() {
    string s; cin >> s;
    vector<char> cs;
    for (auto c: s) if (isalpha(c)) cs.emplace_back(c);
    sort(cs.begin(), cs.end());
    cs.erase(unique(cs.begin(), cs.end()), cs.end());
    if (cs.size() > 8) return !(cout << 0 << endl);
    int cnt = 0;
    string p = "=+-*()01";
    sort(p.begin(), p.end());
    do {
        string t = s;
        for (auto &c: t) if (isalpha(c)) {
            int k = lower_bound(begin(cs), end(cs), c) - begin(cs);
            c = p[k];
        }
        cnt += is_eq(t);
    } while (next_permutation(p.begin(), p.end()));
    for (int i = 0; i < p.size() - cs.size(); i++) cnt /= i + 1;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

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

    cout << ((K % 2) ? (K / 2) + 1 : K / 2)*(K / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	string s,t; cin>>s>>t;
	bool flg=true;
	if(s.size()==t.size()-1){
		rep(i,s.size()){
			if(s[i]!=t[i]) flg=false;
		}
		if(flg) return cout<<"Yes"<<endl,0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<string>

#define MAX_STACKS 102

class Stack{
  int* addrs[MAX_STACKS];
  unsigned int top = 0;
public:
  int pop(){
    if( top <= 0 ){
      std::cerr << "No stacks" << std::endl;
      exit(0);
    }

    int n = *(addrs[top]);
    delete addrs[top];
    top--;
    return n;
  }
  void push( int num ){
    if( top >= MAX_STACKS - 1 ){
      std::cerr << "Stacks max" << std::endl;
      exit( 0 );
    }
    top++;
    addrs[top] = new int;
    *(addrs[top]) = num;
    return;
  }
};

int main(){
  Stack s;

  std::string str;
  while( std::cin>>str  ){
    if( str[0] == '+'){
      int a = s.pop();
      int b = s.pop();
      s.push( b + a );
    }
    else if( str[0] == '-' ){
      int a = s.pop();
      int b = s.pop();
      s.push( b - a );
    }
    else if( str[0] == '*' ){
      int a = s.pop();
      int b = s.pop();
      s.push( b * a );
    }
    else{
      s.push( atoi( str.c_str() ) );
    }
  }
  std::cout << s.pop() << std::endl;
}



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

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n+1,1e9);
  for(ll i=0;i<n;i++) {
    cin >> a[i+1];
  }
  sort(a.rbegin(),a.rend());
  ll l=-1,r=1e11;
  ll temp=(l+r)/2;
  while(l+1<r) {
    ll count=0;
    for(ll i=1;i<n+1;i++) {
      ll tl=0,tr=n+1;
      ll ttemp=(tl+tr)/2;
      while(tl+1<tr) {
        if(a[i]+a[ttemp]>temp) {
          tl=ttemp;
        }
        else {
          tr=ttemp;
        }
        ttemp=(tl+tr)/2;
      }
      count+=tl;
    }
    if(count<m) {
      r=temp;
    }
    else {
      l=temp;
    }
    temp=(l+r)/2;
  }
  vector<ll> s(n+1);
  for(ll i=1;i<n+1;i++) {
    s[i]=s[i-1]+a[i];
  }
  ll ans=0;
  ll count=0;
  for(ll i=1;i<n+1;i++) {
    ll tl=0,tr=n+1;
    ll ttemp=(tl+tr)/2;
    while(tl+1<tr) {
      if(a[i]+a[ttemp]>temp) {
        tl=ttemp;
      }
      else {
        tr=ttemp;
      }
      ttemp=(tl+tr)/2;
    }
    count+=tl;
    ans+=a[i]*tl+s[tl];
  }
  ans+=(m-count)*r;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
	while(true){
		int n,m;
		scanf("%d",&n);
		if(n==0) break;
		bool v[21][21]={},j[21][21]={};
		rep(i,n){
			int x,y;
			scanf("%d%d",&x,&y);
			j[x][y]=1;
		}
		scanf("%d",&m);
		v[10][10]=1;
		int nx=10,ny=10;
		rep(i,m){
			char c;
			int d,h;
			cin >> c >> d;
			if(c=='E') h=0;
			if(c=='N') h=1;
			if(c=='W') h=2;
			if(c=='S') h=3;
			rep(k,d) nx+=dx[h],ny+=dy[h],v[nx][ny]=1;
		}
		bool ok=true;
		rep(i,21) rep(k,21) if(j[i][k] && !v[i][k]) ok=false;
		cout << (ok ? "Yes\n" : "No\n");
	}
}

Measured memory_bytes: 1192
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

ll calc(vector<int> &a, int b){
	ll res = 0;
	rep(i, a.size()) res += (a[i]-b)*(a[i]-b);
	return res;
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i, n) cin>>a[i];
	ll res = 1e10;
	for(int i = -100; i <= 100; i++){
		chmin(res, calc(a, i));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (a != c) << endl;
}


Measured memory_bytes: 888
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll a, b, c;
  while (cin >> a >> b >> c) {
    ll d = c - a - b;
    if (d <= 0) {
      cout << "No" << endl;
      continue;
    }
    bool res = 4 * a * b < d * d;
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
use std::fmt;

use::std::collections::VecDeque;
use std::vec::Vec;
use std::cmp::Ordering;
use std::cmp::Ordering::Greater;
use std::cmp::Ordering::Less;
use std::usize;
use std::ops::Add;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (h, w) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };
  let mut s: Vec<Vec<char>> = Vec::new();
  for _ in 0..h {
    let v: Vec<char> = read::<String>().chars().collect();
    s.push(v);
  }
  let d = match dfs(&s, h, w) {
    Dist::Inf => -1,
    Dist::Fin(x) => x as i64,
  };

  let mut count = 0;
  for line in &s {
    for &e in line {
      if e == '#' {
        count += 1;
      }
    }
  }
  if d == -1 {
    println!("-1");
  } else {
    println!("{}", h as i64 * w as i64 - d - count - 1);
  }
}

fn dfs(s: &Vec<Vec<char>>, h: usize, w: usize) -> Dist {
  let mut check = vec![vec![false; w]; h];
  let mut queue = VecDeque::new();
  let start = (0, 0);
  let mut dist = vec![vec![Dist::Inf; w]; h];

  // init
  queue.push_back(start);
  dist[0][0] = Dist::Fin(0);
  check[0][0] = true;

  while let Some(node) = queue.pop_front() {
    for (x, y) in connect_node(node, s, h, w) {
      if !check[x][y] {
        check[x][y] = true;
        queue.push_back((x, y));
        dist[x][y] = min(dist[node.0][node.1] + Dist::Fin(1), dist[x][y]);
      }
    }
  }

  dist[h-1][w-1]
}

fn connect_node(node: (usize, usize), s: &Vec<Vec<char>>, h: usize, w: usize) -> Vec<(usize, usize)> {
  let (x, y) = node;
  let (x, y) = (x as i64, y as i64);
  let h = h as i64;
  let w = w as i64;
  let mut res = Vec::new();

  let diff = vec![(x + 1, y), (x, y+1), (x-1, y), (x, y-1)];
  for (pst_x, pst_y) in diff {
    if 0 <= pst_x && pst_x <= h-1 && 0 <= pst_y && pst_y <= w-1 && s[pst_x as usize][pst_y as usize] == '.' {
      res.push((pst_x as usize, pst_y as usize));
    }
  }

  res
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum Dist {
  Inf,
  Fin(usize)
}

impl Ord for Dist {
  fn cmp(&self, other: &Dist) -> Ordering {
    match (self, other) {
      (&Dist::Inf, _) => Greater,
      (_, &Dist::Inf) => Less,
      (&Dist::Fin(x), &Dist::Fin(y)) => x.cmp(&y),
    }
  }
}

impl PartialOrd for Dist {
    fn partial_cmp(&self, other: &Dist) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Add for Dist {
  type Output = Self;
  fn add(self, other: Self) -> Self {
    match (self, other) {
      (Dist::Inf, Dist::Inf) | (Dist::Inf, _) | (_, Dist::Inf) => Dist::Inf,
      (Dist::Fin(x), Dist::Fin(y)) => Dist::Fin(x + y),
    }
  }
}

impl fmt::Display for Dist {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    match self {
      &Dist::Inf    => write!(f, "Inf"),
      &Dist::Fin(x) => write!(f, "Fin({})", x),
    }
  }
}


Measured memory_bytes: 4352
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

string s;
cin >> s;
//fr(i,0,s.size())
k = 0,i=0;
ll ans = 0;
while(i<s.size())
{
	k =0;
	if(s[i]=='R')
	while(s[i]=='R'){
		i++;
		k++;
	}
	else
		i++;
	ans = max(k,ans);
}
cout << ans;

 eNd();
  return 0;
 
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    s64 N, K;
    cin >> N >> K;

    s64 ans = 0;
    for (int i = 1; i <= N; ++ i)
    {
        if ((2 * i) % K != 0) continue;
        s64 x = MAX((N + i) / K - CEIL((i + 1), K) + 1, 0);
        ans += x * x;
    }

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



Measured memory_bytes: 256
import sys
N = 999999
lis = []
if N >= 2:
	lis.append(2)
if  N >= 3:
	lis.append(3)
if N >= 5:
	for i in xrange(5,N+1,2):
		for item in lis:
			if item > (i**0.5):
				lis.append(i)
				break
			if i % item == 0:
				break
		else:
			lis.append(i)
dp = [0]*999999
for item in lis:
	dp[item-1] += 1
for i in xrange(1,999999):
	dp[i] += dp[i-1]

for line in sys.stdin:
	num = int(line)
	print dp[num-1]

Measured memory_bytes: 38908
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 29 20:26:17 2020

@author: wiste
"""

S = list(input())
T = list(input())


cm = 0
for i in range(len(S) - len(T) + 1):
    c =0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            c += 1
    cm = max(cm, c)

ans = len(T) - cm


print(ans)

Measured memory_bytes: 9112
#include <stdio.h>
int n, k, c;
char s[200001];
int a[200000];
int b[200000];
int x, y;
int main() {
	scanf("%d%d%d", &n, &k, &c);
	scanf(" %s", s);
	x = -n - 1;
	for (int i = 0; i < n; i++) {
		if (x + c < i && s[i] == 'o') {
			x = i;
			a[i] = 1;
			y++;
		}
	}
	if (y > k)return 0;
	x = 2 * n;
	for (int i = n - 1; i >= 0; i--) {
		if (x - c > i && s[i] == 'o') {
			x = i;
			b[i] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] && b[i])printf("%d\n", i + 1);
	}
}

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

int dfs(int N, long long now, int b){
    int cnt = 0;
    if(now > N){
        return 0;
    }
    if(b == 7) cnt++;

    cnt += dfs(N,now*10+3, b | 1);
    cnt += dfs(N,now*10+5, b | 2);
    cnt += dfs(N,now*10+7, b | 4);

    return cnt;
}

int main(){
    int N;
    cin >> N;
    cout << dfs(N,0,0) << endl;

}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
def dfs(g,v,z):
    if vis[v]!=0: return
    else:
        vis[v]=z
        for p in g[v]:
            dfs(g,p,z)
n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    g[x].append(y)
    g[y].append(x)
z=0 ; vis=[0]*n
for i in range(n):
    if vis[i]==0:
        z+=1
        dfs(g,i,z)
q=int(input())
for i in range(q):
    x,y=map(int,input().split())
    if vis[x]==vis[y]: print('yes')
    else: print('no')

    


Measured memory_bytes: 126960
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    int V[100];
    int C[100];
    scanf("%d",&N);
    int i;
    int rieki=0;
    for(i=0;i<N;i++)
    {
        scanf("%d",&V[i]);
    }
    for(i=0;i<N;i++)
    {
        scanf("%d",&C[i]);
    }
    
    for(i=0;i<N;i++)
    {
        if(V[i]>C[i])
        {
            rieki=rieki+(V[i]-C[i]);
        }
    }
    
    printf("%d",rieki);
    return 0;
}

Measured memory_bytes: 128
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	if(n%10==9||n/10==9){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}


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

ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0
for i in range(N):
    S = input()
    if S=="AC":
        ans1 += 1
    elif S =="WA":
        ans2 += 1
    elif S == "TLE":
        ans3 += 1
    elif S == "RE":
        ans4 += 1
print("AC x " + str(ans1))
print("WA x " + str(ans2))
print("TLE x " + str(ans3))
print("RE x " + str(ans4))


Measured memory_bytes: 9200
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 200009;

int a[maxn];
ll ans;
int n;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	if(a[1]) puts("-1");
	else
	{
		int last=0;
		for(int i=1;i<=n;i++)
		{
			int x=a[i];
			if(x==last) ans+=last;
			else if(x==last+1) ans++,last=x;
			else if(x<last) last=x,ans+=x;
			else{puts("-1");return 0;}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
(defun main ()
  (let* ((k (read))
	 (n (read))
	 (a (make-array (1+ n)))
         (l 0)
         (buff))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (setf (aref a n) (+ k (aref a 0)))
    (dotimes (i n)
      (setf buff (- (aref a (1+ i)) (aref a i)))
      (if (< l buff) (setf l buff)))
    (format t "~d~%" (- k l))))

(main)


Measured memory_bytes: 70376
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
ll a[200010], b[200010];

/*==================================================*/
/*function*/

//最終的なxorにおいて, 下からd桁目が 1 かどうか判定
bool check(int d){
    ll t = (1LL << d);

    //下d桁目までのみが必要
    ll aa[200010], bb[200010];
    REP(i,0,N){
        aa[i]  = a[i] % (2LL*t);
        bb[i]  = b[i] % (2LL*t);
    }

    //繰り上がりの条件分岐のために分類
    vector<ll> sb[2];
    REP(i,0,N){
        if(bb[i] & t) sb[1].push_back(bb[i] - t);
        else sb[0].push_back(bb[i]);
    }

    sort(sb[0].begin(), sb[0].end());
    sort(sb[1].begin(), sb[1].end());

    ll cnt = 0;

    REP(i,0,N){
        ll ta = aa[i];

        //a'=a[i]%2^(d+1),b'=b[i]%2^(d+1)

        //a',b'それぞれ(2^d)引いてのしきい値t(2^d)との大小比較
        //=> d桁目のビットの1/0をチェック (d桁目について, 繰り上がって1になるか or もとの1が残るか)

        if(ta & t){
            ta -= t;
            //(d-1)桁目からの繰り上がりがなくa'のd桁目の1が残る (逆に繰り上がりがあるとd桁目が0になる)
            //((a'-(2^d))+(b'-(2^d))) < (2^d)
            cnt += lower_bound(sb[0].begin(), sb[0].end(), t - ta) - sb[0].begin(); //しきい値を超えない値(=未満)が欲しいのでこのまま

            //a'とb'の各d桁目の1で繰り上がるため,(d-1)桁目からの繰り上がりが必要
            //((a'-(2^d))+(b'-(2^d))) >= (2^d)
            cnt +=  sb[1].size() - (lower_bound(sb[1].begin(), sb[1].end(), t - ta) - sb[1].begin()); //しきい値以上がほしいので"未満"のサイズとの差分
        }else{
            //a'とb'のどちらのd桁目にも0がないため,(d-1)桁目からの繰り上がりが必要
            //((a'-(2^d))+(b'-(2^d))) >= (2^d)
            cnt += sb[0].size() -  (lower_bound(sb[0].begin(), sb[0].end(), t - ta) - sb[0].begin());

            //(d-1)桁目からの繰り上がりがなくb'のd桁目の1が残る (逆に繰り上がりがあるとd桁目が0になる)
            //((a'-(2^d))+(b'-(2^d))) < (2^d)
            cnt += lower_bound(sb[1].begin(), sb[1].end(), t - ta) - sb[1].begin();
        }
    }

    return cnt % 2 == 1;
}

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N) cin>>a[i];
    REP(i,0,N) cin>>b[i];

    ll ans = 0;
    REP(d,0,29){
        if(check(d)) ans += (1 << d);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 10068
from collections import deque
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

N, Q = map(int, input().split())

G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

count = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    count[p-1] += x

def dfs(v, p):
    if p != -1:
        count[v] += count[p]
    for next_v in G[v]:
        if next_v == p: continue
        dfs(next_v, v)

dfs(0, -1)
print(" ".join(map(str, count)))

Measured memory_bytes: 232604
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
#include <limits>

using namespace std;
#define iter(b) for(int i = 0;i < (b);i++)
#define VVI vector<vector<int>>
typedef vector<int> VI;

int main()
{
    int N;
    cin >> N;
    long long a;
    long long prod = 1;
    long long p = pow(10, 18);
    bool flag = true, z = false;
    iter(N){
        cin >> a;
        if(log10(prod) + log10(a) > 18 || a * prod > p){
            flag = false;
        }
        prod *= a;
        if(a == 0) z = true;
    }
    if(z) cout << '0';
    else{
        cout << (flag ? prod : -1);
    }


}


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


int main(void){
    
    int A,B;
    cin >> A >> B;
    
    if(A >= 13){
        cout << B << endl;
    }
    else if(A >= 6){
        cout << B / 2 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3620
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int A[200000];
vpii v;
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);

    int l = 1,r = N;
    while (l < r) {
        int m = (l+r) / 2;

        int f = 0;
        v.pb(mp(0,A[0]));
        for (i = 1; i < N; i++) {
            if (A[i] > A[i-1]) v.pb(mp(0,A[i]-A[i-1]));
            else {
                int l = A[i-1];
                while (l > A[i]) {
                    int z = min(l-A[i],v.back().second);
                    v.back().second -= z,l -= z;
                    if (v.back().second == 0) v.pop_back();
                }
                int z = 0;
                while (!v.empty() && (v.back().first >= m-1)) z += v.back().second,v.pop_back();
                if (v.empty()) {
                    f = 1;
                    break;
                }
                else {
                    int t = v.back().first;
                    v.back().second--;
                    if (v.back().second == 0) v.pop_back();
                    v.pb(mp(t+1,1));
                    if (z > 0) v.pb(mp(0,z));
                }
            }
        }
        if (f) l = m+1;
        else r = m;
        v.clear();
    }
    printf("%d\n",l);

    return 0;
}



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

int main(){
  int n,q; string s; cin>>n>>q>>s;
  vector<int> ac(n+1);

  ac[0]=0; ac[1]=0;
  char a=s[0];
  int acnum=0;
  for(int i=1; i<n; ++i){
    char b=s[i];
    if(a=='A' && b=='C')++acnum;
    ac[i+1]=acnum;
    a=b;
  }

  for(int i=0; i<q; ++i){
    int l,r; cin>>l>>r;
    cout<<ac[r]-ac[l]<<endl;
  }
}


Measured memory_bytes: 1408
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;

void solve(){
    double d,t,s; cin>>d>>t>>s;
    if((double)(d/s)<=t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}
int main(){
    fastio();
    //write code
    int t; t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    for (int j = 0; j <= n; j++){
      if (4 * i + 7 * j == n){
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
  return 0;
}

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


int k, q;
vector<int> d, n, x, m;


void input() {
    cin >> k >> q;
    d = vector<int>(k);
    n = x = m = vector<int>(q);
    rep(i, k) cin >> d[i];
    rep(i, q) cin >> n[i] >> x[i] >> m[i];
}


ll query(int i) {
    vector<ll> sd(k + 1, 0);
    vector<int> zn(k + 1, 0);
    rep(j, k) {
        sd[j+1] = sd[j] + d[j] % m[i];
        if (d[j] % m[i] == 0) {
            zn[j+1] = zn[j] + 1;
        } else {
            zn[j+1] = zn[j];
        }
    }
    int nn = (n[i] - 1) / k;
    ll a = x[i] % m[i];
    ll b = a + sd.back() * nn;
    b += sd[(n[i] - 1) % k] ;
    ll ans = n[i] - 1;
    ans -= b / m[i];
    ans -= zn.back() * nn + zn[(n[i] - 1) % k];
    return ans;
}


int main() {
    input();
    rep(i, q) cout << query(i) << endl;
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
    int s[n], a[n];
    for (int i = 0; i < n; ++i) {
        int ai; cin >> ai;
        s[i] = ai; a[i] = ai;
    }
    sort(s, s + n);
    int m = s[n - 1];
    for (int i = 0; i < n; ++i) {
        if (a[i] != m) cout << m << "\n";
        else cout << s[n - 2] << "\n";
    }
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 3200
n,m,q=gets.split.map &:to_i
a=(n+1).times.map{[0]*(n+1)}
m.times{
	l,r=gets.split.map &:to_i
	a[l][r]+=1
}
n.times{|y|(n+1).times{|x|a[y+1][x]+=a[y][x]}}
(n+1).times{|y|n.times{|x|a[y][x+1]+=a[y][x]}}
q.times{
	l,r=gets.split.map &:to_i
	p a[l-1][l-1]-a[l-1][r]-a[r][l-1]+a[r][r]
}

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

// price, day
priority_queue<int> pq;

// day, price
map<int, vector<int> > mp;

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

  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    mp[a].push_back(b);
  }

  ll res=0;
  for(int i=1;i<=m;i++){
    for(auto t : mp[i]) {
      pq.push(t);
    }
    if(pq.empty())continue;
    res+=pq.top();
    pq.pop();
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 10880
import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        char chr=input.scanString().charAt(0);
        if(chr>='a' && chr<='z') {
            System.out.println("a");
        }
        else {
            System.out.println("A");
        }
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if(a >= 13){
		cout << b << endl;
	}else if(a >= 6 && a <= 12){
		cout << b/2 << endl;
	}else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  int west[S.size()+1] = {0};
  int east[S.size()+1] = {0};
  for(int i = 0; i < S.size(); i++){
      if(S[i] == 'W') {
        west[i+1] = west[i] + 1;
        east[i+1] = east[i];
      }
      if(S[i] == 'E'){
        west[i+1] = west[i];
        east[i+1] = east[i] + 1;
      }
  }
  int ans = INF;
  for(int i = 0; i < S.size(); i++){
    int a = west[i] + east[S.size()] - east[i+1];
    ans = min(ans, a);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<long double>p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]=1-p[i];
    }
    vector<vector<long double>>a(n);
    for(int i=0;i<n;i++){
        a[i].resize(n+1);
    }
    a[0][0]=p[0];
    a[0][1]=1-p[0];
    for(int i=2;i<=n;i++){
        a[0][i]=0;
    }
    for(int i=1;i<n;i++){
        a[i][0]=a[i-1][0]*p[i];
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<n+1;j++){
            a[i][j]=p[i]*a[i-1][j]+(1-p[i])*a[i-1][j-1];
        }
    }
    long double ans=0;
    int j=0;
    while(2*j<n){
        ans+=a[n-1][j];
        ++j;
    }
    ans=1-ans;
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;

}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x;
    cin >> x;
    int rad = 0;
    int cnt = 0;
    while(true){
        rad += x;
        cnt++;
        if(rad % 360 == 0){
            cout << cnt << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
// finish date: 2018/06/17
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    int N;
    cin >> N;
    vi a(N + 1), b(N + 1);
    rep(i, N) {
        cin >> a[i];
    }
    rep(i, N) {
        cin >> b[i];
    }
    a[N] = INF;
    b[N] = INF;

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int g = 0;
    int h = 0;
    int ans = 1;
    int stock = 0;
    while (g < N || h < N) {
        if (a[g] < b[h]) {
            if (stock < 0) ans = mul(ans, -stock);
            stock++;
            g++;
        } else {
            if (stock > 0) ans = mul(ans, stock);
            stock--;
            h++;
        }
    }
    cout << ans << endl;

    return 0;
}






Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes";	//YAKI
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int H, W;
    cin >> H >> W;
    vector<string> ss(H);
    REP(i,H) cin >> ss[i];

    vector<string> s2(H,string(W,'.'));
    s2[0][0] = '#';
    vector<int> dx{0,1};
    vector<int> dy{1,0};
    queue<pii> que;
    que.push({0,0});
    while(!que.empty()) {
        //cerr << que.front().first << " " << que.front().second << endl;
        pii xy = que.front(); que.pop();
        REP(i,2) {
            int nx = xy.first + dx[i];
            int ny = xy.second + dy[i];
            if (nx >= W) continue;
            if (ny >= H) continue;
            if(ss[ny][nx] == '#') {
                que.push({nx,ny});
                s2[ny][nx] = '#';
                break;
            }
        }
    }

    bool ans = true;
    REP(i,H) {
        if (ss[i] != s2[i]) {
            ans = false;
            break;
        }
    }
    
    if (ans) OUT("Possible")
    else OUT("Impossible")

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX
#define NUM

#define numerator first
#define denominator second

int con;

inline pair<int,int> add(pair<int,int> a, pair<int,int> b){
	int nume = a.numerator*b.denominator + b.numerator*a.denominator;
	int deno = a.denominator*b.denominator;
	int gcd = __gcd(abs(nume), abs(deno));
	nume /= gcd;
	deno /= gcd;
	
	return make_pair(nume,deno);
}


inline int solve(pair<int,int> fra, int b, int a, int n){
	int res = 0, temp = 1, hoge;
	// cout<<fra.numerator<<"/"<<fra.denominator<<" "<<b<<" "<<a<<" "<<n<<endl;
	if(n == 0) return 0;
	if(n == 1){
		if(fra.numerator == 1 && b <= fra.denominator && fra.denominator <= a) return 1;
		else return 0;
	}
	if(fra.numerator*b > fra.denominator*n) return 0;
	
	// cout<<"temp "<<temp<<endl;
	for(int i = 1;fra.numerator*b > fra.denominator*i; i++){
		 temp *= b;
		if(temp > a){
			// con++;
			return -1;
		}
	}
	// cout<<"temp "<<temp<<endl;
	for(int i = max(b, fra.denominator/fra.numerator); i <= a; i++){
		if(fra.numerator*i == fra.denominator) res++;
		else if(fra.numerator*i > fra.denominator){
			hoge = solve(add(fra,make_pair(-1,i)),i,a/i,n-1);
			if(hoge == -1)break;
			res += hoge;
		}
	}
	return res;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int p, q, a, n;
	
	while(true){
		cin>>p>>q>>a>>n;
		
		if(!p && !q && !a && !n) break;
		
		int gcd = __gcd(p, q);
		p /= gcd;
		q /= gcd;
		// cout<<con<<endl;
		cout<<solve(make_pair(p,q),1, a, n)<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include <string.h>
using namespace std;

int main(){
	long long int i,j,m,n;//1 2 3 4 5  12
	char a,b;
	while(cin>>n){
		long long int sum=0;
		int count=0;
		for(i=1;i<=n;i++){
			sum=sum+i;
			count++;
			if(sum>=n){
				break;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
Count = 0
while(1):
    count = 0
    for i in range(n):
        if a[i] % 2 == 0:
            count += 1
    if count != n:
        break
    for i in range(n):
        a[i] /= 2
    Count += 1
print(Count)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
 int i,j,k,b,c;
  char a;
  int x[2]={0};
  for(i=0;i<3;i++)
  {
    scanf("%c",&a);
    if(a=='A'){
    x[0]+=1;
    }
    else if(a=='B'){
    x[1]+=1;
    }

  }
  if(x[0]==2 || x[1]==2)
    printf("Yes\n");
  else
    printf("No\n");
return 0;
}


Measured memory_bytes: 128
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L,R,d = LI()
    ans = 0
    for i in range(L,R+1):
        ans += (i % d == 0)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68868
#include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include<queue>
#include<stack>
using namespace std;
stack<int> st;
int main(){
	int a;
	while(cin>>a){
		if(a!=0){
			st.push(a);
		}
		else{
			cout<<st.top()<<endl;
			st.pop();
		}
	}
	return 0;

}

Measured memory_bytes: 1200