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

int main()
{
	int month[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d;
	while(cin >> m >> d){
		if(m==0&&d==0)
			break;
		int day=0;
		for(int i=1;i<m;i++){
			day+=month[i];
		}
		day+=d;
		switch(day%7){
			case 0:
				cout << "Wednesday" << endl;
				break;
			case 1:
				cout << "Thursday" << endl;
				break;
			case 2:
				cout << "Friday" << endl;
				break;
			case 3:
				cout << "Saturday" << endl;
				break;
			case 4:
				cout << "Sunday" << endl;
				break;
			case 5:
				cout << "Monday" << endl;
				break;
			case 6:
				cout << "Tuesday" << endl;
				break;
			default:
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
int32_t main()
{
    fast;
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int m = 1; m <= k; m++)
            {
                ans += __gcd(m, __gcd(i, j));
            }
        }
    }
    cout << ans;



}

Measured memory_bytes: 3648
from collections import Counter

n,k,l=map(int,input().split())
city1=[i for i in range(n)]
city2=[i for i in range(n)]

def root(c,x):
  if x==c[x]:
    return x
  else:
    return root(c,c[x])

def union(c,x,y):
  rx=root(c,x)
  ry=root(c,y)
  if rx>ry:
    c[rx]=ry
  else:
    c[ry]=rx

for i in range(k):
  a,b=map(int,input().split())
  union(city1,a-1,b-1)
for i in range(l):
  a,b=map(int,input().split())
  union(city2,a-1,b-1)
r=[]
for i in range(n):
  r.append((root(city1,i),root(city2,i)))
c=Counter(r)
for i in range(n):
  ans=c[r[i]]
  if i==n-1:
    print(ans)
  else:
    print(ans,end=' ')

Measured memory_bytes: 58452
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	reverse(ALL(a));
	reverse(ALL(b));
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if ((a[i] + ans) % b[i] == 0) continue;
		ans += b[i] - ((a[i] + ans) % b[i]);
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4048
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
     n:usize,
    mut a: [i64;n],
      }
    a.sort();

    a.reverse();
    // dbg!(&a);
    //  for i in 0..n {
    //      if i==0 {
    //          // a[0]到着

    //      }
    //      else {
    //          a[i]
    //      }
    //  }
    let mut ans = 0;
    ans += a[0];
    for i in 2..n {
        ans += a[i / 2];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>

#define MAX_N 10000

using namespace std;

struct cakes {
	int x, y, w, h, lastcut;
	cakes(int a, int b, int c, int d, int e):x(a),y(b),w(c),h(d),lastcut(e){}
};

bool operator<(const cakes& a, const cakes& b){
	if(a.lastcut == b.lastcut){
		return a.w*a.h > b.w*b.h;
	}else{
		return a.lastcut > b.lastcut;
	}
}

bool sorter(const cakes& a, const cakes& b){ return a.w*a.h < b.w*b.h; }

int N, W, D;
int p, s;

int main(){
	while(1){
		priority_queue<cakes> Q;
		cin >> N >> W >> D;
		if(N == 0 && W == 0 && D == 0) break;
		Q.push(cakes(0,0,W,D,0));
		for(int i = 0; i < N; i++){
			scanf("%d %d", &p, &s);
			p--;
			vector<cakes> c;
			for(int j = 0; j <= p; j++){
				c.push_back(Q.top()); Q.pop();
			}
			s %= (c[p].w+c[p].h)*2;
			if(0 < s && s < c[p].w){
				Q.push(cakes(c[p].x,c[p].y,s,c[p].h,i));
				Q.push(cakes(c[p].x+s,c[p].y,c[p].w-s,c[p].h,i));
			}else if(c[p].w < s && s < c[p].w + c[p].h){
				Q.push(cakes(c[p].x,c[p].y,c[p].w,s-c[p].w,i));
				Q.push(cakes(c[p].x,c[p].y+s-c[p].w,c[p].w,c[p].h+c[p].w-s,i));
			}else if(c[p].w+c[p].h < s && s < c[p].w*2+c[p].h){
				Q.push(cakes(c[p].x,c[p].y,c[p].w*2+c[p].h-s,c[p].h,i));
				Q.push(cakes(c[p].x+c[p].w*2+c[p].h-s,c[p].y,s-c[p].w-c[p].h,c[p].h,i));
			}else{
				Q.push(cakes(c[p].x,c[p].y,c[p].w,(c[p].w+c[p].h)*2-s,i));
				Q.push(cakes(c[p].x,c[p].y+(c[p].w+c[p].h)*2-s,c[p].w,s-(c[p].w*2+c[p].h),i));
			}
			for(int j = 0; j < p; j++){
				Q.push(c[j]);
			}
		}
		vector<cakes> ans;
		for(int i = 0; i <= N; i++){ ans.push_back(Q.top()); Q.pop(); }
		sort(ans.begin(), ans.end(), sorter);
		printf("%d", ans[0].w*ans[0].h);
		for(int i = 1; i <= N; i++) printf(" %d", ans[i].w*ans[i].h);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1244
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

bool comp(pi a, pi b){
    return a.second < b.second;
}

int n;
vec<pi> arr;
void in(){
    cin >> n;
    rep(i,0,n){
        int ai, bi;
        cin >> ai >> bi;
        arr.push_back(pi(ai, bi));
    }
    sort(all(arr), comp);
}

void solve(){

    int sum = 0;
    rep(i,0,n){
        sum += arr[i].first;
        if(sum > arr[i].second){
            print("No");
            return ;
        }
    }
    print("Yes");

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;

 
int N;
 
void dfs(string s) {
    if (s.length() == N) {
        cout << s << endl;
        return;
    }
    char up = 'a';
    for (char c : s) {
        up = max(up, c);
    }
    for (char c = 'a'; c <= up + 1; c++) {
        dfs(s + c);
    }
    
} 
 
int main() {
    cin >> N;
    string s = "a";
    dfs(s);
}

Measured memory_bytes: 1536
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
for i in range(1,n-1):
    lin = li[i-1:i+2]
    lin2 = sorted(lin)
    if lin[1] == lin2[1]:
       point += 1
print(point)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1; i<x+k; i++)cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int m; cin >> m;
	int n; cin >> n;
	VE s(n), t(n);
	rep(i, n) {
		cin >> s[i] >> t[i];
	}
	vector<P>itv(n);
	rep(i, n) {
		itv[i].first = t[i];
		itv[i].second = s[i];
	}
	sort(ALL(itv));
	int ans = 0;
	int lastwork = 0;
	rep(i, n) {
		if (lastwork <= itv[i].second) {
			ans++;
			lastwork = itv[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;
typedef pair<int,P> P2;

int a[10001][1300];

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    int p,q;
    cin >> p;
    memset(a,0,sizeof(a));
    rep(i,p) {
      int x,y,z,w;
      cin >> x >> y >> z >> w;
      if(w) a[z][x]++;
      else a[z][x]--;
    }
    REP(i,1,m+1) {
      REP(j,1,1300) a[i][j]+=a[i][j-1];
    }
    cin >> q;
    while(q--) {
      int ans=0,t1,t2,x;
      cin >> t1 >> t2 >> x;
      REP(i,t1,t2) ans+=(a[x][i]>0);
      pr(ans);
    }
  }
  return 0;
}


Measured memory_bytes: 51952
#include <bits/stdc++.h>
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define ll long long
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vc vector<char>
#define vpi vector < pair <ll , ll> >
#define si set<ll>
#define sc set<char>
#define msi multiset<ll>
#define msc multiset<char>
#define lb lower_bound
#define ub upper_bound
#define mll map<ll,ll>
#define gcd __gcd
#define mp(i,j) pb(make_pair(i,j))
#define all(v) v.begin(),v.end()
#define forl(i,n) for(ll i = 0;i<n;i++)
#define fore(i,n) for(ll i = 1;i<=n;i++)
#define forn(i,n) for(ll i = n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL);
#define wq ll q ; cin >> q ; while(q--)
#define pattern ll n ; cin >> n ;
#define pattern1 ll n ; cin >> n ; ll ar[n] ; forl(i,n){cin >> ar[i];}
#define pattern2 ll n,k ; cin >> n ; cin >> k ; ll ar[n] ; forl(i,n){cin >> ar[i];}
#define pattern3 ll n ; cin >> n ; char ar[n] ; forl(i,n){cin >> ar[i];}
#define pattern4 ll n,k ; cin >> n ; cin >> k ; char ar[n] ; forl(i,n){cin >> ar[i];}
using namespace std;
ll bpow(ll a,ll b,ll mod){
    a%=mod;
    ll res = 1;
    while(b>0){
        if(b & 1){
            res = res*a%mod;
        }
        a = a*a%mod;
        b >>= 1;
    }
    return res;
}
bool dio(ll a,ll b,ll c){
    ll g = gcd(a,b);
    if(g%c==0 || c%g==0){
        return true;
    }
    else{
        return false;
    }
}
bool pdrome(string s){
    ll n = s.length();
    forl(i,n/2){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll onf(ll n){
    for(ll i = 2;i<n;i++){
        if(n%i==0){
            return i;
        }
    }
    return 1;
}
ll bis(ll arr[], ll l, ll r, ll x){
    while (l <= r){
        ll m = l + (r - l) / 2;
        if(arr[m] == x){
            return m;
        }
        if(arr[m] < x){
            l = m + 1;
        }
        else{
            r = m - 1;
        }
    }
    return -1;
}
ll isprime(ll x){
    ll k;
    for(ll i = 2;i<=x;i++){
        if(x%i==0){
            k = i;
            break;
        }
    }
    if(k==x){
        return 1;
    }
    else{
        return 0;
    }
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio;
    ll a,b,c,k,ans = 0;

    cin >> a >> b >> c >> k;
    if(k<=a){
        ans+=k;
    }
    else{
        ans+=a;
        k-=a;
        if(k<=b){
            ans+=0;
        }
        else{
            ans+=0;
            k-=b;
            ans-=k;
        }

    }
    cout << ans;
}

Measured memory_bytes: 3600
import sys
import math
sys.setrecursionlimit(10**9)
MOD = 10**9+7

N = int(input())
*B, = map(int,input().split())
A = []
for i in range(N-1):
    A.append(B[i+1]-B[i])

S = []
f = math.factorial(N-1)
cur = 0
for i in range(1,N):
    cur += pow(i,MOD-2,MOD)
    S.append(cur)

sm  = 0
for a,b in zip(A,S):
    sm += (a*b)%MOD

print((sm*f)%MOD)

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> a(N, vector<ll>(N));
    rep(i, N) rep(j, N) cin >> a[i][j];

    vector<vector<ll>> f(N, vector<ll>(N));// グラフを構成するのに(i,j)の辺が必要かどうか
    rep(i, N)rep(j, N) f[i][j] = true;

    // ワーシャルフロイド法
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                if (a[i][k] + a[k][j] < a[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }

                if (a[i][k] + a[k][j] == a[i][j] && i != k && k != j) { // i -> k -> j と i -> j が同じコストであれば i -> jのルートは不要
                    f[i][j] = f[j][i] = false;
                }
            }
        }
    }

    ll ans = 0;
    rep(i, N) rep(j, N) if (i < j && f[i][j]) ans += a[i][j];
    cout << ans << endl;
}

Measured memory_bytes: 1664
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let a:Vec<usize> = (0..n).map(|_| read()).collect();
    let sm:usize = a.iter().sum();
    let cnt = a.iter().filter(|&&x| x as f64 >= sm as f64 /(4.0*m as f64)).count();
    if cnt >= m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2108
#include<stdio.h>

#define N 100 //max data number


int main(){
  int cnt, num[N], i, j, key;
  

  //input number of article
  scanf("%d",&cnt);

  
  //input data
  for(i=0;i<cnt;i++) scanf("%d",&num[i]);

  
  //sort
  for(i=1;i<cnt;i++){
    //print data
    for(key=0;key<cnt-1;key++) printf("%d ",num[key]);
    printf("%d\n",num[key]);

    
    key=num[i];
    j=i-1;

    while(j>=0 && num[j] > key){
      num[j+1]=num[j];
      j--;
    }
    num[j+1]=key;
  }
  
  //print data
  for(key=0;key<cnt-1;key++) printf("%d ",num[key]);
  printf("%d\n",num[key]);
  
  return 0;
}




Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if (a%3==0 || b%3==0 || (a+b)%3==0) {
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int H,W,N;
int sr,sc;
char s[MAXN],t[MAXN];
int suf[MAXN];
bool Process(char a,char b,int dis,int lim) {
    suf[N + 1] = 0;int sum = 0;
    for(int i = N ; i >= 1 ; --i) {
        suf[i] = suf[i + 1];
        if(s[i] == b) {
            suf[i] = min(suf[i],sum - 1);
            --sum;
        }
        if(t[i] == a) {
            if(sum < 0) ++sum;
        }
    }
    int pos = dis;
    for(int i = 1 ; i <= N ; ++i) {
        if(s[i] == a) ++pos;
        if(pos > lim) return false;
        if(t[i] == b) {
            if(pos - 1 + suf[i + 1] >= 1) --pos;
        }
    }
    return true;
}
void Solve() {
    read(H);read(W);read(N);
    read(sr);read(sc);
    scanf("%s",s + 1);scanf("%s",t + 1);
    if(!Process('D','U',sr,H) || !Process('U','D',H + 1 - sr,H) ||
    !Process('R','L',sc,W) || !Process('L','R',W + 1 - sc,W)) {
        puts("NO");
    }
    else puts("YES");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N, A, B;

    cin >> N;
    
    if (N == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    
    cin >> A >> B;
    cout << A + B << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){
  int n,m;
  cin>>n>>m;
  int cnt[111111]={};
  for(int i=0;i<m;i++){
    int l,r;
    cin>>l>>r;
    cnt[l]++;
    cnt[r+1]--;
  }
  int ans=0;
  for(int i=1;i<111111;i++){
    cnt[i]+=cnt[i-1];
    if(cnt[i]==m)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
# 高橋君はあるプログラミングコンテストが行われているサイトに参加しています。
# ここでは, コンテストに出場した時にこの順位に応じて「パフォーマンス」というものがつき、
# それによってレーティング (整数とは限らない) が次のように変化します。
#
# 現在のレーティングを a とする。
# 次のコンテストで, パフォーマンス bを取ったとする。
# そのとき, レーティングは a と b の平均まで変化する。
# 例えば, レーティングが 1 の人が
# 次のコンテストでパフォーマンス 1000を取ったら,
# レーティングは 1 と 1000 の平均である 500.5 になります。
#
# 高橋君は, 現在のレーティングが R で,
# 次のコンテストでレーティングをちょうど Gにしたいと思っています。
# そのとき, 高橋君が取るべきパフォーマンスを求めなさい。

# 制約
# 0 ≦ R, G ≦ 4500
# 入力はすべて整数

# 標準入力から R, G の値を取得する
r = int(input())
g = int(input())

# 高橋君が取りべきパフォーマンスを計算し、出力する
# (r + x) / 2 = G
result = g * 2  - r

print(result)


Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int x;
  cin >> x;
  if (x == 3 || x ==5 || x ==7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    foreach (c; s) {
        switch (c) {
            case '1': write('9'); break;
            case '9': write('1'); break;
            default: write(c); break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  ll n,m;
  cin>>n>>m;
  ll ans = 0;
  // まずはsの持ち数でsccを作る
  ll cnt1 = min(n,m/2);
  ans+=cnt1;
  m = lmax(0,m-cnt1*2);
  ans+=m/4;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IO ios::sync_with_stdio(false),cin.tie(0)
#define FIN freopen("D://code//in.txt", "r", stdin)
#define ppr(i,x,n) for(int i = x;i <= n;i++)
#define rpp(i,n,x) for(int i = n;i >= x;i--)
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
 
inline int read() {//读入挂
    int ret = 0, c, f = 1;
    for(c = getchar(); !(isdigit(c) || c == '-'); c = getchar());
    if(c == '-') f = -1, c = getchar();
    for(; isdigit(c); c = getchar()) ret = ret * 10 + c - '0';
    if(f < 0) ret = -ret;
    return ret;
}
ll a[maxn];
int main()
{
	IO;
	ll k,n;
	cin>>k>>n;
	if(k%2 == 0)
	{
		ppr(i,1,n)
		{
			if(i == 1)
			printf("%lld ",k/2);
			else
			printf("%lld%c",k,i==n?'\n':' ');
		}
	}
	else
	{
		ll number = (k+1)/2;
		ll num = n;
		ppr(i,1,n) a[i]=number;
		ppr(i,1,n/2)
		{
			if(a[num] == 1)
			{
				a[num] = k;
				num--;
			}
			else
			{
				a[num]--;
				num = n;
			}
		}
		ppr(i,1,num)
		{
			printf("%lld%c",a[i],i==num?'\n':' ');
		}
	}
	
	return 0;
}


Measured memory_bytes: 6400
import itertools
S = input()
A = [0,1]
N = len(S)
pt = [list(i) for i in itertools.product(A,repeat=N-1)]
ans = 0
for p in pt:
	stack = ""
	for i in range(2*N-1):
		if i % 2 == 1:
			"""
			"+"を足し込むかどうか
			"""
			if i == 0:
				if p[0]: stack += "+"
			else:
				index = i // 2
				if p[index]: stack += "+"
		else:
			"""
			stackに普通に文字を入れていく
			"""
			index = i // 2
			stack+= S[index]
	ans += sum([int(x) for x in stack.split("+")])
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>

int main() {
    int h, w;
    std::cin >> h >> w;
    for (int i = 0; i < h; i++) {
        std::string s;
        std::cin >> s;
        std::cout << s << std::endl << s << std::endl;
    }
}

Measured memory_bytes: 256
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

fn main() {
    let (N, M) = read!(usize, usize);
    let A = read![[usize]];
    let B = read![[usize]];

    let mut X = vec![0; N * M + 1];
    let mut Y = vec![0; N * M + 1];

    for a in A {
        X[a] += 1;
    }
    for b in B {
        Y[b] += 1;
    }

    let mut ax = 0;
    let mut bx = 0;

    let mut s = 1_i64;
    for x in (1..N * M + 1).rev() {
        if X[x] >= 2 || Y[x] >= 2 {
            s = 0;
            break;
        }

        if X[x] + Y[x] == 2 {
            ax += 1;
            bx += 1;
            continue;
        }

        if X[x] == 1 {
            s *= bx;
            s %= P;
            ax += 1;
            continue;
        }

        if Y[x] == 1 {
            s *= ax;
            s %= P;
            bx += 1;
            continue;
        }

        s *= ax * bx - (N * M - x) as i64;
        s %= P;
    }

    println!("{}", s)
}


Measured memory_bytes: 12540
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int insert[5] =  {0, 3,4,5};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string AKIBA = "KIHBR";
    vector<string> v;
    rep(i, 16) {
        int cnt = 0;
        string tmp = AKIBA;
        int bit = i;
        rep(j, 4) {
            
            if (bit % 2) {
                //cout << insert[j] + cnt << endl;
                tmp.insert(insert[j] + cnt, "A");
                cnt++;
            }
            bit /= 2;
        }
        v.push_back(tmp);
    }
    rep(i, v.size()) {
        if(v[i] == S) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	A := nextInts(N)
	ans := 1
	var pre int
	pre = ans
	flag := false
	for i := 0; i < N; i++ {
		ans *= A[i]
		if A[i] == 0 {
			fmt.Println("0")
			return
		}
		if ans/A[i] != pre {
			flag = true
		}
		if ans > 1e18 {
			flag = true
		}
		pre = ans
	}
	if flag {
		fmt.Println("-1")
	} else {
		fmt.Println(ans)
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextUint64() uint64 {
	sc.Scan()
	i, err := strconv.ParseUint(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}


Measured memory_bytes: 5856
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n, m, q;
	cin >> n >> m >> q;
	long long d[n][n];
	long long sum[n][n];
	fill(d[0], d[0]+n*n, 0);
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		d[l-1][r-1]++;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == 0) {
				if (j == 0)
					sum[0][0] = d[0][0];
				else
					sum[i][j] = sum[i][j-1] + d[i][j];
			} else if (j == 0) {
				if (i == 0)
					sum[0][0] = d[0][0];
				else
					sum[i][j] = sum[i-1][j] + d[i][j];
			} else {
				sum[i][j] = sum[i-1][j] + sum[i][j-1] + d[i][j] - (sum[i-1][j-1]);
			}
		}
	}
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		long long ans;
		if (a-2 < 0)
			ans = sum[b-1][b-1];
		else
			ans = sum[b-1][b-1] - (sum[a-2][b-1] + sum[b-1][a-2] - sum[a-2][a-2]);
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int n;
  cin>>n;
  long long int k;
  cin>>k;
  long long int h[200004];
  for(long long int j=0;j<n;j++){
    cin>>h[j];
  }
  sort(h,h+n);
  if(k>=n){
    cout<<0;
  }else{
    long long int sum=0;
    for(long long int j=0;j<n-k;j++){
      sum+=h[j];
    }
    cout<<sum;
  }

}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[A];
        int amin = 100000;
        for(int i = 0; i < A; i++) {
        	a[i] = sc.nextInt();
        	amin = Math.min(amin, a[i]);
        }
        int[] b = new int[B];
        int bmin = 100000;
        for(int i = 0; i < B; i++) {
        	b[i] = sc.nextInt();
        	bmin = Math.min(bmin, b[i]);
        }
        int ans = amin + bmin;
        for(int i = 0; i < M; i++) {
        	int x = sc.nextInt()-1;
        	int y = sc.nextInt()-1;
        	int c = sc.nextInt();
        	ans = Math.min(ans, a[x]+b[y]-c);
        }
        System.out.println(ans);
    }
}

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

int main(){
    int X,A,B;
    cin >> X >> A >> B;
    
    if (0 >= (B - A)) cout << "delicious"<< endl;
    else if(X >= (B - A)) cout << "safe"<< endl;
    else cout << "dangerous"  << endl;
}


Measured memory_bytes: 256
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define DEBUG if(false)

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;


int main(){
  string S;
  cin >> S;
  if(S[1] == 'B'){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void solve() {
        int N = in.nextInt();
        int K = in.nextInt();
        int result = 1;
        for (int i = 0; i < N; i++) {
            if (result < K) {
                result *= 2;
            } else {
                result += K;
            }
        }
        out.println(result);
    }


    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void func(int n, int m, vector<int>res){

  if(n==0){
    for(int i=0;i<res.size();i++){
      cout << res[i];
      if(i==res.size()-1)cout << endl;
      else cout << " ";
    }
    return;
  }
  
  for(int i=n;i>0;i--){
    if(i>m)continue;
    res.push_back(i);
    func(n-i,i,res);
    res.pop_back();
  }
}

int main(void){

  int n;
  vector<int>res;

  while(cin >> n,n)
    func(n,n,res);

  return 0;
}

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

const int MAX_N = 3e5+10;
ll A, B;

ll gcd(ll x, ll y)
{
	if(!y) return x;
	return gcd(y, x%y);
}

void solve()
{
	ll LIMIT = gcd(A, B);
	int ans = 1;
	for(ll i=2;i*i<=LIMIT;++i){
		if(LIMIT % i == 0){
			ans++;
			while(LIMIT%i==0) LIMIT/=i;
		}
	}
	if(LIMIT!=1) ans++;
	cout << ans ;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> A >> B;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int n,v,a[N],len,f[1<<19|3],g[1<<19|3];
struct Seg{
	int l[N],r[N];
	void init(int x){
		per(i,n,1){r[i]=i;if(i+1<=n&&a[i+1]-a[i]<=x)r[i]=r[i+1];}
		rep(i,1,n){l[i]=i;if(i-1>=1&&a[i]-a[i-1]<=x)l[i]=l[i-1];}
		l[0]=0;r[n+1]=n+1;
	}
}b[20];
int main() {//freopen("57.txt","r",stdin);freopen("1.out","w",stdout);
	read(n);read(v);rep(i,1,n)read(a[i]);
	while(1){b[++len].init(v);if(!v)break;v/=2;}
	int all=(1<<len-1)-1;//2..len(0..len-2) merge 1
	rep(i,0,all)g[i]=n+1;
	rep(i,0,all)rep(j,2,len)if(!(i>>j-2&1))umax(f[i|(1<<j-2)],f[i]+1>n?n:b[j].r[f[i]+1]);
	rep(i,0,all)rep(j,2,len)if(!(i>>j-2&1))umin(g[i|(1<<j-2)],g[i]-1<1?1:b[j].l[g[i]-1]);
	int cnt=0;
	for(int i=1;i<=n;i=b[1].r[i]+1)cnt++;
	if(cnt>len){
		rep(i,1,n)puts("Impossible");
		return 0;
	}
	for(int i=1;i<=n;i=b[1].r[i]+1){
		int l=i,r=b[1].r[i];bool ok=0;
		rep(s,0,all)ok|=f[s]>=l-1&&g[s^all]<=r+1;
	//	printf("solve %d %d\n",l,r);
		rep(j,l,r)printf("%s\n",ok?"Possible":"Impossible");
	}
//	cerr<<len<<endl;
	return 0;
}


Measured memory_bytes: 41856
<?php
fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $slimes);

$splited_slimes = str_split($slimes);
$result = 0;
$prev = '';
foreach ($splited_slimes as $key => $slime) {
  if ($prev != $slime) {
    $result++;
  }
  $prev = $slime;
}

echo $result;

Measured memory_bytes: 10872
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;

int ft_find_min(const int ary[], int size)
{
    int minimun  = ary[0];
    for (int i = 1; i < size; i++) {
        if (ary[i] < minimun)
            minimun = ary[i];
    }
    return minimun;
}

int ft_find_max(const int ary[], int size)
{
    int maximum  = ary[0];
    for (int i = 1; i < size; i++) {
        if (ary[i] > maximum)
            maximum = ary[i];
    }
    return maximum;
}


int main(void) {
    int n;
    cin >> n;
    int positions[n];
    int i = 0;
    int temp_n = n;
    while(temp_n--) {
        cin >> positions[i++];

    }
    
    int min , max;
    min = ft_find_min(positions, n);
    max = ft_find_max(positions, n);
    
    int total_cost = 0;
    int lowerst_cost;
    
    for (int current_posi = min; current_posi <= max; current_posi++) {
        total_cost = 0;
        for (int i = 0; i < n; i++) {
            total_cost += (positions[i] - current_posi) * (positions[i] - current_posi);
        }
        
        if (current_posi == min)
            lowerst_cost = total_cost;
        if (total_cost < lowerst_cost)
            lowerst_cost = total_cost;
    }
    
    printf("%d",lowerst_cost);
    
    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()
n = len(s)
ans = 0

dp1 = [999999999999999999] * (n+1)
dp2 = [999999999999999999] * (n+1)


dp1[0] = 0
dp2[0] = 1

for i,c in enumerate(s):
    a = int(c)

    dp1[i+1] = min(dp1[i]+a, dp2[i]+a+1)
    dp2[i+1] = min(dp1[i]+a+1, dp2[i]+(10-a-1), dp2[i]+a+2)

print(min(dp1[n], dp2[n]+1))


Measured memory_bytes: 69484
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

vector<ll> daikus(vector<vector<mp> > &g,int s){
        ll v = g.size();
        vector<ll> res(v,inf);
        priority_queue<mp,vector<mp>,greater<mp> > q;
        q.push(mp(0,s) );
        while(!q.empty()){
                mp now = q.top();
                q.pop();
                ll nn = now.second;
                ll cost = now.first;
                if( res[nn] < cost) continue;
                res[nn] = cost;
                for(int i=0;i<g[nn].size();i++){
                        ll next = g[nn][i].second;
                        ll nc = cost + g[nn][i].first;
                        if( res[next] < cost ) continue;
                        q.push( mp(nc,next) );
                }
        }
        return res;
}



int main(){
    ll n,u,v;
    cin>>n>>u>>v;
    u--,v--;
    vector<vector<mp> > g(n);
    for( ll   i =0;i<n-1;i++){
	ll a,b;
	cin>>a>>b;
	a--,b--;
	g[a].push_back( mp(1,b) );
	g[b].push_back( mp(1,a) );
    }

    vector<ll> uu = daikus( g , u );
    vector<ll> vv = daikus( g , v );

    /*for(ll i=0;i<n;i++){
	cout<<i<<' '<<uu[i]<<' '<<vv[i]<<endl;
    }*/
    ll cost = 0;
    for( ll i = 0; i< n;i++ ){
	if( uu[i] < vv[i] ){
	    cost = max( vv[i] -1  , cost );
	}
	if( uu[i] == vv[i] ){
	    bool flag = false;
	    for( int j = 0; j < g[i].size() ; j++ ){
		if( vv[i] > vv[ g[i][j].second ] && uu[ g[i][j].second ] == vv[ g[i][j].second ] ){
		    flag = true;
		    break;
		}
	    }
	    if( !flag ) cost = max( cost , vv[i] );
	}
    }

    cout<<cost<<endl;
    return 0;
}


Measured memory_bytes: 10268
#include<bits/stdc++.h>
using namespace std;
double n,a,b,c,ans,Min=99999999999999;
int main()
{
    cin>>n>>a>>b;
    for(int s=0;s<n;s++)
    {
        cin>>c;
        if(abs(a-c*0.006-b)<Min)Min=abs(a-c*0.006-b),ans=s+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const LL mo=1e9+7;
int n,v[3];
LL f[43][133333];
LL qpow(LL x,LL k)
{
	LL ret=1;
	while(k){
		if(k&1) ret*=x,ret%=mo;
		x*=x;x%=mo;k>>=1;
	}
	return ret;
}
int main()
{
	scanf("%d%d%d%d",&n,&v[0],&v[1],&v[2]);
	f[0][0]=1;
	int r=(1<<v[0]+v[1]+v[2])-1;
	int ban=(1<<v[2]-1)|(1<<v[1]+v[2]-1)|(1<<v[0]+v[1]+v[2]-1);
//	cout<<"  "<<r<<' '<<ban<<endl;
	LL ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=r;j++)
		{
			for(int k=1;k<=10;k++)
			{
				int nex=((j<<k)|(1<<k-1))&r;
				if((nex&ban)!=ban)
				  (f[i+1][nex]+=f[i][j])%=mo;
			}
		}
	}
	for(int i=0;i<=r;i++)
	  if((i&ban)!=ban)
	    (ans+=f[n][i])%=mo;//cout<<i<<' '<<f[n][i]<<endl;
	cout<<(qpow(10,n)-ans+mo)%mo<<endl;
	return 0;
}


Measured memory_bytes: 42240
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,x;
  cin >> n >> x;
  vector<int>vec(n);
  rep(i,n) cin >> vec[i];
  int ans = 1;
  int now=0;
  rep(i,n){
    now+=vec[i];
    if(now<=x)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int w = sc.nextInt();
    int h = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();
    String ans = "No";

    if(x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h){
      ans = "Yes";
    }

    System.out.println(ans);
  }
}



Measured memory_bytes: 26396
#include <cstdio>
int main() {
    int x;
    scanf("%d", &x);
    int a[4];
    for (int i = 0; i < 4; ++i) {
        a[i] = x % 10;
        x /= 10;
    }
    for (int i = 0; i < 3; ++i) {
        if (a[i] == a[i + 1]) {
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");
    return 0;
}

Measured memory_bytes: 128
import collections

n,k=map(int,input().split())
g=[[] for _ in range(n+1)]
e=[]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
  e.append((a,b))
ans=0
if k%2==0:
  for i in range(1,n+1):
    tmp=0
    checked=[0]*(n+1)
    checked[i]=1
    q=collections.deque()
    q.append((i,0))
    while len(q)!=0:
      v,d=q.popleft()
      if d<=k//2:
        tmp+=1
      else:
        break
      for u in g[v]:
        if checked[u]==0:
          checked[u]=1
          q.append((u,d+1))
    ans=max(ans,tmp)
  print(n-ans)
if k%2==1:
  for v1,v2 in e:
    tmp=0
    checked=[0]*(n+1)
    checked[v1]=1
    checked[v2]=1
    q=collections.deque()
    q.append((v1,0))
    while len(q)!=0:
      v,d=q.popleft()
      if d<=k//2:
        tmp+=1
      else:
        break
      for u in g[v]:
        if checked[u]==0:
          checked[u]=1
          q.append((u,d+1))
    checked=[0]*(n+1)
    checked[v1]=1
    checked[v2]=1
    q=collections.deque()
    q.append((v2,0))
    while len(q)!=0:
      v,d=q.popleft()
      if d<=(k-1)//2:
        tmp+=1
      else:
        break
      for u in g[v]:
        if checked[u]==0:
          checked[u]=1
          q.append((u,d+1))
    ans=max(ans,tmp)
  print(n-ans)    


Measured memory_bytes: 57304
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,a,b;
ll v[1000];

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

ll C(ll n,ll m) {
	if(n / 2 < m) {
		m = n - m;
	}

	ll bunsi[m];

	for(ll i = 0;i < m;i++) {
		bunsi[i] = n - i;
	}

	for(ll i = 2;i <= m;i++) {
		ll bunbo = i;
		for(ll j = 0;j < m && bunbo > 1;j++) {
			ll g = gcd(bunbo,bunsi[j]);
			bunbo /= g;bunsi[j] /= g;
		}
	}

	ll ret = 1;
	for(ll i = 0;i < m;i++) {
		ret *= bunsi[i];
	}
	return ret;
}

int main(){
	cin >> n >> a >> b;
	REP(i,n) {
		cin >> v[i];
	}

	sort(v,v+n);

	double sum = 0;
	FOR(i,n - a,n) {
		sum += v[i];
	}
	printf("%0.10f\n",sum / a);

	int c = 0;

	FOR(i,n - a,n) {
		if(v[n - a] == v[i]) {
			c++;
		}
	}

	if(c < a) {
		ll d = 0;
		REP(i,n) {
			if(v[i] == v[n - a]) {
				d++;
			}
		}
		cout << C(d,c) << endl;
	}else {
		ll d = 0;
		REP(i,n) {
			if(v[i] == v[n - a]) {
				d++;
			}
		}
		ll ans = 0;
		FOR(i,a,min(d,b) + 1) {
			ans += C(d,i);
		}
		cout  << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256