akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    string s;
    cin >> n >> s;

    map<pair<string, string>, int> mp, mp2;
    for(int bit = 0; bit < (1 << n); ++bit){
        string str = "", str2 = "";
        for(int i = 0; i < n; ++i){
            if((bit >> i) & 1)  str += s[i];
            else    str2 += s[i];
        }
        reverse(str2.begin(), str2.end());
        ++mp[make_pair(str, str2)];
    }
    for(int bit = 0; bit < (1 << n); ++bit){
        string str = "", str2 = "";
        for(int i = 0; i < n; ++i){
            if((bit >> i) & 1)  str += s[n + i];
            else    str2 += s[n + i];
        }
        reverse(str.begin(), str.end());
        ++mp2[make_pair(str, str2)];
    }

    ll ans = 0;
    for(auto it : mp){
        ans += (ll)it.second * mp2[it.first];
    }
    cout << ans << endl;
}

Measured memory_bytes: 89624
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll n;
    cin>>n;
    vector<vector<ll>> es(n);
    vector<LP> ps(n - 1);
    rep(i, n - 1) {
        ll e1, e2;
        cin>>e1>>e2; e1--; e2--;
        es[e1].push_back(e2);
        es[e2].push_back(e1);
        ps[i] = LP(e1, e2);
    }
    vector<ll> cs(n);
    rep(i, n) cin>>cs[i];
    sort(cs.begin(), cs.end());

    vector<ll> vs(n);
    vector<ll> visited(n);
    vector<ll> selected(n);
    priority_queue<LP, vector<LP>, greater<LP>> q;
    rep(i, n) q.emplace(es[i].size(), i);
    int i = 0;
    while (!q.empty()) {
        LP p = q.top(); q.pop();
        ll f = p.first;
        ll s = p.second;
        if (visited[s]) continue;
        visited[s] = cs[i];
        i++;

        for (auto e : es[s]) {
            selected[e]++;
            q.emplace(es[e].size() - selected[e], e);
        }
    }

    ll ans = 0;
    rep(i, n - 1) {
        ans += min(visited[ps[i].first], visited[ps[i].second]);
    }
    cout<<ans<<endl;
    rep(i, n) cout<<visited[i]<<endl;
}

Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int n,m;
    cin >> n >> m;
    vector<i64> x(n);
    vector<i64> y(n);
    vector<i64> z(n);
    rep(i,n) cin >> x[i] >> y[i] >> z[i];

    if(m==0)
    {
        cout << 0 << endl;
        return 0;
    }

    i64 dp[n+1][m+1][8];
    i64 inf = 1;
    inf <<= 53;
    rep(i,n+1) rep(j,m+1) rep(k,8) dp[i][j][k] = -inf;
    rep(i,n+1) rep(k,8) dp[i][0][k] = 0;

    i64 p[8][3] = { {1,1,1},    {1,1,-1},   {1,-1,1},   {-1,1,1},
                    {1,-1,-1},  {-1,1,-1},  {-1,-1,1},  {-1,-1,-1} };

    rep(i,n)
        rep(j,m)
            rep(k,8)
            {
                i64 tmp = dp[i][j][k] + p[k][0]*x[i] + p[k][1]*y[i] + p[k][2]*z[i];
                dp[i+1][j+1][k] = max(dp[i][j+1][k], tmp);                    
            }
    
    i64 max_sum = -inf;
    rep(k,8)
    {
        max_sum = max(max_sum, dp[n][m][k]);
    }
        
    
    cout << max_sum << endl;    
    return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
ll inv[2000000+7],fac_inv[2000000+7],fac[2000000+7];
void initialize()
{
	ll i;
	inv[1]=1;
	for(i=2;i<=2000005;i++)
		inv[i]=(M-M/i)*inv[M%i]%M; 
	fac[0]=fac[1]=1;
	for(i=2;i<=2000005;i++)
		fac[i]=i*fac[i-1]%M;
	fac_inv[0]=fac_inv[1]=1;
	for(i=2;i<=2000005;i++)
		fac_inv[i]=inv[i]*fac_inv[i-1]%M;
}
ll ncr(ll n,ll r,ll m)
{
	return (fac[n]*fac_inv[r]%M)*fac_inv[n-r]%M;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll r1,r2,c1,c2,i,j;
	initialize();
	cin>>r1>>c1>>r2>>c2;
	ll ans=0;
	for(i=c1;i<=c2;++i)
	{
		ans=((ans+ncr(i+r2+1,i+1,M))%M+M-ncr(i+r1,i+1,M))%M;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 47104
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
        t: String,
    }
    let n_s = s.len();
    let n_t = t.len();
    let mut s = s.into_bytes();
    let t = t.into_bytes();

    let mut ok = 0;
    for i in (0..n_s - n_t + 1).rev() {
        ok = 1;
        for j in 0..n_t {
            if s[i + j] == t[j] {
                continue;
            } else if s[i + j] == '?' as u8 {
                continue;
            } else {
                ok = 0;
                break;
            }
        }

        if ok == 1 {
            for j in 0..n_t {
                s[i + j] = t[j];
            }
            break;
        }
    }
    let ans: String = s
        .into_iter()
        .map(|c| if c == '?' as u8 { 'a' } else { c as char })
        .collect();
    if ok == 1 {
        println!("{}", ans);
    } else {
        println!("UNRESTORABLE");
    }
}


Measured memory_bytes: 4352
using System;

	public class Dice
	{
		public static void Main(String[] args)
		{
			//????????¶?????????????????¨?????\???????????????
			int top=0;
			int bottom=5;
			int north=4;
			int south=1;
			int east=2;
			int west=3;
			int temp=0;
			
			string dataset=Console.ReadLine();
			string news=Console.ReadLine();
			string[] data=dataset.Split();
			
			for	(int i=0;i<news.Length;i++){
				
				switch (news[i]){
				case 'N':
					temp=top;
					top=south;
					south=bottom;
					bottom=north;
					north=temp;
					
					break;
				case 'S':
					temp=top;
					top=north;
					north=bottom;
					bottom=south;
					south=temp;
					
					break;
				case 'W':
					temp=top;
					top=east;
					east=bottom;
					bottom=west;
					west=temp;
					
					break;
				case 'E':
					temp=top;
					top=west;
					west=bottom;
					bottom=east;
					east=temp;
					break;
			  }
			}
			Console.WriteLine(data[top]);
					
			
		}
	}

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

int main() {
	int x;
	cin >> x;
	vector<int> ans = { 1 };
	for (int i = 2; i <= sqrt(x); i++) {
		int y = i * i;
		while (y <= x) {
			ans.push_back(y);
			y *= i;
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	cout << ans.at(0) << endl;
		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int i;
    vector<int> h;
    for(i=0; i<n; i++){
        int x;
        cin >> x;
        h.push_back(x);
    }
    int tmp = 0, count = 0;
    for(i=1; i<n; i++){
        if(h[i]<=h[i-1]) tmp++;
        else{
            count = max(count, tmp);
            tmp = 0;
        }
    }
    cout << max(tmp, count) << endl;
    return 0;
}

Measured memory_bytes: 3932
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		String[] distance = str.split(" ");
		
		double a = Double.parseDouble(distance[0]);
		double b = Double.parseDouble(distance[1]);
		double C = Double.parseDouble(distance[2]);
		
		double S = a * b * Math.sin(Math.toRadians(C)) / 2;
		double L = a + b + Math.sqrt(a*a + b*b - 2 * a * b* Math.cos(Math.toRadians(C)));
		//double L = Math.pow(((Math.pow(a, 2) + (Math.pow(b, 2) - 2 * a * b * Math.cos(C)))), 0.5) + a + b;
		double h = (2 * S) / a;
		/*
		double S = a * b / 2;
		double L = Math.pow(((Math.pow(a, 2) + (Math.pow(b, 2)))), 0.5) + a + b;
		double h = (2 * S) / a;
		*/
		
		System.out.printf("%.8f\n",S);
		System.out.printf("%.8f\n",L);
		System.out.printf("%.8f\n",h);
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b) cout<<"a < b"<<endl;
    if(a>b) cout<<"a > b"<<endl;
    if(a==b) cout<<"a == b"<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[101][101010];


int main(){
    int k,n;
    cin>>k>>n;
    vector<int> a;
    REP(i,1,100000){
        if(i*i>k)break;
        a.push_back(i);
        a.push_back(k/i);
    }
    a.push_back(0);
    sort(a.begin(),a.end());
    int m = a.size();
    dp[0][0]=1;
    rep(i,n){
        rep(j,m)(dp[i][j+1]+=dp[i][j])%=mod;
        rep(j,m-1){
            int idx = m-j-2;
            dp[i+1][j]=dp[i][idx]*(a[j+1]-a[j])%mod;
        }
    }
    ll ans = 0;

    rep(i,m)ans += dp[n][i];
    cout<<ans%mod<<endl;
    return 0;
}


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

typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef vector<mat> space;

const int INF = 1 << 28;

void solve(int N) {
    vector<int> p(N+1), t(N+1);
    p[0] = t[0] = 0;
    for (int i = 1; i <= N; i++) cin >> p[i] >> t[i];

    mat dp(N+1, vec(4, INF));
    dp[0][0] = 0;

    for (int i = 1; i <= N; i++) {
        bool flag = false;
        if (dp[i-1][0] != INF && t[i-1] + p[i] <= t[i]) {
            dp[i][1] = dp[i-1][0] + p[i];
            flag = true;
        }

        if (dp[i-1][1] != INF) {
            if (t[i-1] + 2 * p[i-1] + p[i] <= t[i]) dp[i][1] = min(dp[i][1], dp[i-1][1] + p[i-1] + p[i]), flag = true;
            if (t[i-1] + 2 * abs(p[i] - p[i-1]) <= t[i]) dp[i][2] = min(dp[i][2], dp[i-1][1] + abs(p[i] - p[i-1])), flag = true;
        }

        if (dp[i-1][2] != INF) {
            if (t[i-1] + 3 * p[i-1] + p[i] <= t[i]) dp[i][1] = min(dp[i][1], dp[i-1][2] + p[i-1] + p[i]), flag = true;
            if (t[i-1] + 3 * abs(p[i-1] - p[i]) <= t[i]) dp[i][3] = min(dp[i][3], dp[i-1][2] + abs(p[i] - p[i-1])), flag = true;
        }

        if (dp[i-1][3] != INF) {
            if (t[i-1] + 4 * p[i-1] + p[i] <= t[i]) dp[i][1] = min(dp[i][1], dp[i-1][3] + p[i-1] + p[i]), flag = true;
        }

        if (!flag) {
            cout << "NG " << i << endl;
            return ;
        }
    }

    int ans = INF;
    for (int i = 0; i < 4; i++) {
        ans = min(ans, dp[N][i] + p[N]);
    }

    cout << "OK " << ans << endl;
}

int main() {
    int N;
    while (cin >> N, N) solve(N);

    return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
#include<string.h>
int main()
{
    char s[55];
    scanf("%s", s);
    if (strcmp(s, "AKIHABARA") == 0)printf("YES\n");
    else if (strcmp(s, "KIHABARA") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHBARA") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHABRA") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHABAR") == 0)printf("YES\n");
    else if (strcmp(s, "KIHABAR") == 0)printf("YES\n");
    else if (strcmp(s, "KIHBARA") == 0)printf("YES\n");
    else if (strcmp(s, "KIHABRA") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHBRA") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHBAR") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHABR") == 0)printf("YES\n");
    else if (strcmp(s, "KIHBRA") == 0)printf("YES\n");
    else if (strcmp(s, "KIHBAR") == 0)printf("YES\n");
    else if (strcmp(s, "KIHABR") == 0)printf("YES\n");
    else if (strcmp(s, "AKIHBR") == 0)printf("YES\n");
    else if (strcmp(s, "KIHBR") == 0)printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
	ll a,b;
	cin>>a>>b;
	//ll count=1;
	//ll i=2;
	//while(a<b)
	//{
	//	a=a*i;
	//	i++; count++;
	//}
	cout<<int(ceil(double(b - 1) / double(a - 1)));
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int x, y, z, K;
    cin >> x >> y >> z >> K;

    ll A[x], B[y], C[z];
    for (int i = 0; i < x; i++) cin >> A[i];
    for (int i = 0; i < y; i++) cin >> B[i];
    for (int i = 0; i < z; i++) cin >> C[i];

    sort(A, A+x, greater<ll>());
    sort(B, B+y, greater<ll>());
    sort(C, C+z, greater<ll>());

    priority_queue <ll, vector <ll>, greater<ll> > q;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            for (int k = 0; k < z; k++) {
                ll sm = A[i] + B[j] + C[k];
                if (q.size() < K) {
                    q.push(sm);
                } else {
                    ll top = q.top();
                    if (sm <= top) {
                        break;
                    } else {
                        q.pop();
                        q.push(sm);
                    }
                }
            }
        }
    }

    int i = K-1;
    vector <ll> ans(K);
    while (q.size()) {
        ans[i--] = q.top();
        q.pop();
    }

    for (ll ret : ans) cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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



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

	ll f[n][10];
	ll p[n][11];

	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, n) {
		rep(j , 11) {
			cin >> p[i][j];
		}
	}
	ll ans = -100000000000LL;
	for (int i = 1; i < (1 << 10); i++) {
		int cur = i;
		vector<int> open(n,0);
		int count = 0;
		while(cur > 0) {
			if ((cur & 1) == 1) {
				rep(j, n) {
					if (f[j][count] == 1) {
						open[j]++;
					}
				}
			} 
			count++;
			cur = cur >> 1;
		}
		ll point = 0;
		rep(j, n) {
			point += (ll) p[j][open[j]];
		}
		if (ans < point) {
			ans = point;
		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5", "24 11 8 3 16" ].parse.expand.solve == 3 );
	assert( [ "4", "5 5 5 5" ].parse.expand.solve == 0 );
	assert( [ "10", "33 18 45 28 8 19 89 86 2 4" ].parse.expand.solve == 5 );
	
	assert( [ "4", "5 5 6 6" ].parse.expand.solve == 0 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort();
	
	auto ans = 0L;
	auto ds = new bool[ 10L ^^ 6 + 1 ];
	LOOP: foreach( i, a; as )
	{
		if( i + 1 < as.length && as[ i ] == as[ i + 1 ] )
		{
			ds[ a ] = true;
			continue;
		}
		
		auto s = cast( long ) a ^^ 0.5L;
		for( auto d = 1L; d <= s; d++ )
		{
			if( a % d == 0 && ( ds[ d ] || ds[ a / d ] ) ) continue LOOP;
		}
		ds[ a ] = true;
		ans++;
	}
	return ans;
}


Measured memory_bytes: 12724
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())[::-1]
t = list(input())[::-1]
n = len(s)
m = len(t)
res = []
for i in range(n-m+1):
    for j in range(m):
        if s[i+j] != '?' and s[i+j] != t[j]:
            break
    else:
        for k in range(n):
            if i <= k < i+m:
                res.append(t[k-i])
            else:
                if s[k] == '?':
                    res.append('a')
                else:
                    res.append(s[k])
        print(''.join(res[::-1]))
        break
else:
    print('UNRESTORABLE')

Measured memory_bytes: 63980
N = gets.to_i
a = gets.split.map(&:to_i)

h = 0
k = 0
s = 0

a.each{|t|
  if t%4==0 then
    h += 1
  elsif t%2==0 then
    k += 1
  else
    s -= 1
  end
}

#p h,s

if N > 3 then 
  if k >= 1 then
    puts (h+s) >= 0 ? "Yes" : "No"
  else
    puts (h+s) >= -1 ? "Yes" : "No"
  end
else
  puts (h >= 1)||(s >= 0) ? "Yes" : "No"
end

Measured memory_bytes: 8452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define space printf(" ")
#define endl printf("\n")
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{

	}
	void assign_value_()
	{

	}
	void merge_nodes_()
	{

	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;

ll fact[N];

void pre_fact()
{
	int i;
	fact[0] = 1LL;
	fo(i,1,N)
		fact[i] = (fact[i-1]*((ll)i))%mod;
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	pre_fact();
	int n, m;
	ll ans = 1LL;
	cin >> n >> m;
	if(abs(n-m) > 1)
		ans = 0LL;
	else
	{
		ans = (fact[n]*fact[m])%mod;
		if(n == m)
			ans = (ans+ans)%mod;
	}
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{ 
int n,m,s;
cin>>n;
int time[n];
for (int i=0;i<n;i++)
	cin>>time[i];
cin>>m;
int drink[m][2];
for(int j=0;j<m;j++)
{
	
	for(int i=0;i<2;i++)
		cin>>drink[j][i];
}
for(int j=0;j<m;j++)
{
	s=0;
	for(int i=0;i<n;i++)
	{
		s+=time[i];
		if(drink[j][0]-1==i)
		{
			s=s-time[i];
			s=s+drink[j][1];
		}
	}
	cout<<s<<endl;
}			
return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := readI()
	cnt := 0
	for i := 0; i < n; i++ {
		if readI() == readI() {
			cnt++
		} else {
			cnt = 0
		}
		if cnt == 3 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	ll x,k,d; cin >> x >> k >> d;
	ll n = -(x/d);
	ll ans;
	if(abs(n) > k){
		if(x < 0) ans = x + k*d;
		else ans = x - k*d;
	} else{
		if(x < 0){
			x = x + n*d;
			k -= n;
			if(k&1){
				ans = x + d;
			} else{
				ans = x;
			}
		} else{
			x = x + n*d;
			k -= n;
			if(k&1){
				ans = x - d;
			} else{
				ans = x;
			}
		}
	}
	cout << abs(ans);
	
	//x + nd = 0 find lowerbound of n
	// goal is as close to 0 as possible
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  char c;
  cin >> c;
  c++;
  cout << c << endl;
}

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

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

    int k;
    int a,b;
    cin>>k>>a>>b;
    if(b-a>=k)
        cout<<"OK";
    else{
        bool reshenie=false;
        for(int i=a;i<=b;i++){
            if(i%k==0)
            reshenie=true;
        }
    if(reshenie==true)
        cout<<"OK";
    else
        cout<<"NG";
    }
}


Measured memory_bytes: 3692
def func(a, b):
	return max(map(len, map(str, [a, b])))

N = int(input())

min_dig = 10 ** 18
for i in range(1, int(N ** 0.5) + 1):
	if not N % i:
		j = N // i
		min_dig = min(min_dig, func(i, j))

print(min_dig)


Measured memory_bytes: 3188
#include<stdio.h>
#define MAX 100000
int n,k;
long long T[MAX];

int calculate(long long P) {
  int i = 0,j;
  for(j = 0;j < k;j++) {
    long long s = 0;
    while(s + T[i] <=P) {
      s += T[i];
      i++;
      if(i==n)return n;
    }
  }
  return i;
}

int binary(void) {
long long left = 0,mid;
long long right = (long long)MAX*MAX;
while(right - left > 1) {
  mid = (left + right) / 2;
  int hantei = calculate(mid);
  if(hantei >= n) right = mid;
  else left = mid;
}
return right;
}

int main()  {
  int i;
  scanf("%d%d",&n,&k);
  for(i = 0;i<n;i++) scanf("%lld", &T[i]);
 long long ans = binary();
  printf("%lld\n",ans);
  return 0;

}



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

// sort(arr, arr+n);
// (binary_search(key, key + total element, sizeof))

int main()
{
  double D, T, S;
  scanf("%lf %lf %lf", &D, &T, &S);

  double timeTaken = D / S;
  (timeTaken <= T) ? puts("Yes") : puts("No");

  // int arr[] = {1, 5, 8, 2, 4};
  // int n = 5;
  // sort(arr, arr + n);
  // for (int i = 0; i < 5; i++)
  // {
  //   printf("%d ", arr[i]);
  // }

  // binary_search(arr, arr + n, 7) ? puts("FOUND") : puts("NOT FOUND");

  return 0;
}

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

int max(int x, int y){
    if (x>=y) return x;
    else return y;
}

int main(){
    int n;
    cin >> n;
    int a[n] = {};
    for (int i=0;i<n;i++)
    cin >> a[i];
    int mina = a[0];
    int maxa = a[1]-a[0];
    for (int j=1;j<n;j++){
        maxa = max(maxa, a[j] -mina);
        mina = -max(-mina,-a[j]);
        
    }
    cout << maxa << endl;
    return 0;
}


Measured memory_bytes: 3892
package main

import (
	"bufio"
	"fmt"
	"os"
)

type Node struct {
	val      int
	children []*Node
}

func main() {
	var n int
	fmt.Scan(&n)

	linesMap := make(map[int][]int)

	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n-1; i++ {
		var a, b int
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)
		linesMap[a] = append(linesMap[a], b)
		linesMap[b] = append(linesMap[b], a)
	}

	_, s := farthest(1, linesMap)
	depth, _ := farthest(s, linesMap)

	dp := make([]bool, depth+1)
	dp[0] = true
	if depth > 0 {
		dp[1] = false
	}
	for i := 2; i <= depth; i++ {
		if dp[i-1] && dp[i-2] {
			dp[i] = false
		} else {
			dp[i] = true
		}
	}

	if dp[depth] {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}

func farthest(i int, linesMap map[int][]int) (depth int, node int) {
	ancestors := make(map[int]bool)
	ancestors[i] = true
	current := linesMap[i]
	node = i
	for current != nil {
		var next []int
		for _, j := range current {
			node = j
			for _, k := range linesMap[j] {
				if !ancestors[k] {
					next = append(next, k)
				}
			}
			ancestors[j] = true
		}
		depth++
		current = next
	}

	return depth, node
}


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

using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin >> n >> m;
    ll sum = 0;
    for(int i = 0; i < m ; i++)
    {
        ll x;
        cin >> x;
        sum+=x;
    }
    cout << max(-1 *1LL, n - sum);
    
}

Measured memory_bytes: 3668
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL i,j,k,n,s=1,a[200040],b[200040],c[200040],d[200040];
LL P(LL x,LL y)
{
	for(LL i=1000000005;i;i>>=1)
	{
		if(i&1)
		{
			x=x*y%1000000007;
		}
		y=y*y%1000000007;
	}
	return x;
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	k=min(k,n-1);
	if(k<2)cout<<n*(n-1)%1000000007;
	else
	{
		for(*a=*b=*c=*d=1;i++<n;)
		{
			a[i]=a[i-1]*i%1000000007;
			b[i]=b[i-1]*(n-i+1)%1000000007;
			c[i]=c[i-1]*i%1000000007;
			d[i]=d[i-1]*(n-i)%1000000007;
		}
		for(i=0;i++<k;)
		{
			s=(s+P(b[i],a[i])*P(d[i],c[i]))%1000000007;
		}
		cout<<s;
	}
}

Measured memory_bytes: 6528
n = int(input())
ans = 0

for i in range(1,n+1):
    right = n//i
    s = ((right+1)*right)//2
    ans += (s*i)
print(ans)


# for i in range(2,n+1):
#     base = i
#     while True:
#         buf[base] += 1
#         base += base
#         if base > n:
#             break
#
# print(buf)
#
# ans = 0
# for i in range(1,n+1):
#     ans += i*buf[i]
#
# print(ans)

Measured memory_bytes: 63168
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // String line = sc.nextLine();
        int N = sc.nextInt();
        String unit;
        switch (N % 10) {
            case 3:
                unit = "bon";
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                unit = "pon";
                break;
            default:
                unit = "hon";
                break;
        }
        System.out.println(unit);
    }
}

Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 1e5+10;

int N, M;
int P[MAX_N], Y[MAX_N];
string ans[MAX_N];

void solve(){
	map<int,vector<int>> v;
	for(int i=0; i<M; ++i) v[P[i]].push_back(Y[i]);
	for(auto& p:v) sort(p.second.begin(), p.second.end());
	for(int i=0; i<M; ++i){
		int j=lower_bound(v[P[i]].begin(), v[P[i]].end(), Y[i])-v[P[i]].begin();
		printf("%06d%06d\n", P[i], j+1);
	}
}

int main(){
	cin>>N>>M;
	for(int i=0; i<M; ++i) cin>>P[i]>>Y[i];
	solve();
}

Measured memory_bytes: 18428
import java.util.*;

public class Main {
	private static long solve(long H) 
	{if(H==1) return 1;
	else return(2*solve(H/2)+1);
	}


	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		System.out.println(solve(sc.nextLong()));
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S, std::string T){
  if(S.size()+1 == T.size() && S == T.substr(0,S.size())) {
    cout << YES << endl;
  }
  else {
    cout << NO << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3592
#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;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
  ll a, b , c, d;
  cin >> a >> b >> c >> d;
  ll x[4];
  x[0] = a * c, x[1] = a * d, x[2] = b * c, x[3] = b * d;
  ll mx = -INF;
  rep(i,4) {
    chmax(mx,x[i]);
  }
  cout << mx << endl;
}

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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<long long> A(N, 0LL);
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }
    long long ans = 0;
    for (long long i = 1; i < N; ++i) {
        if (A[i] < A[i - 1]) {
            long long diff = A[i - 1] - A[i];
            A[i] += diff;
            ans += diff;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
int ans,h,e,w,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int bfs(int s[10][10]){
	int cnp=1;
	bool visit[10][10];
	memset(visit,0,sizeof(visit));
	queue<P> que;
	que.push(P(0,0));
	visit[0][0]=1;
	while(!que.empty()){
		P p=que.front();
		que.pop();
		rep(i,4){
			int nx=p.second+dx[i];
			int ny=p.first+dy[i];
			if(!(nx>=0&&nx<w&&ny>=0&&ny<h)||!(s[ny][nx]==s[0][0])||visit[ny][nx])
			continue;
			que.push(P(ny,nx));
			cnp++;
			visit[ny][nx]=1;
		}
	}
	return cnp;
}
void func(int s[10][10],int now){
	if(now==5){
		if(s[0][0]==e){
			ans=max(ans,bfs(s));
		}
		return;
	}
	int c[10][10];
	bool visit[10][10];

	for(int i=1;i<=6;i++){
		if(i!=s[0][0]){
			rep(k,h)
				rep(j,w)
					c[k][j]=s[k][j];
			queue<P> que;
			que.push(P(0,0));
			visit[0][0]=1;
	memset(visit,0,sizeof(visit));
			while(!que.empty()){
				P p=que.front();
				que.pop();
				c[p.first][p.second]=i;
				rep(z,4){
					int nx=p.second+dx[z];
					int ny=p.first+dy[z];
					if(!(nx>=0&&nx<w&&ny>=0&&ny<h)||!(c[ny][nx]==s[0][0])||visit[ny][nx])
						continue;
					que.push(P(ny,nx));
					visit[ny][nx]=1;
					c[ny][nx]=i;
				}
			}
			func(c,now+1);
		}
	}
}
int main(){
	while(cin>>h>>w>>e,w||h||e){
		int s[10][10];
		ans=0;
		rep(i,h)
			rep(j,w)
				cin>>s[i][j];
		
		func(s,0);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
using namespace std;
int n,a,b;
char c;
int d=0,e=0;
signed main() {
	cin>>n>>a>>b;
	rep(i,n) {
		cin>>c;
		if(c=='a') {
			if(d<a+b) {
				cout<<"Yes"<<endl;
				d++;
			}
			else {
				cout<<"No"<<endl;
			}
		}
		else if(c=='b') {
			if(d<a+b&&e<b) {
				cout<<"Yes"<<endl;
				d++;
				e++;
			}
			else {
				cout<<"No"<<endl;
			}
		}
		else {
			cout<<"No"<<endl;
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(15)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int A, B; cin >> A >> B;
  cout << max({A+B, A-B, A*B}) << endl;
}


Measured memory_bytes: 256
let q = read_int ()

let rec f i =
  if i < q then (
    Scanf.scanf "%d %d\n" (fun a b ->
      let pro = a * b in
      let root = int_of_float (sqrt (float_of_int pro)) in
      let b = pro = root * root && a <> b in
      let ans = root + (pro - 1) / (root + 1) - 1 in
      let ans = ans + if b then -1 else 0 in
      Printf.printf "%d\n" ans;
      f (i + 1)
    )
  )

let () = f 0


Measured memory_bytes: 3836
N=int(input())
W=[]
flag=0
for i in range(N):
    W.append(input())
    if not i==0:
        if W[i][0]!=W[i-1][len(W[i-1])-1]:
            flag+=1
if len(W) != len(set(W)):
    flag+=1
if flag==0:
    print("Yes")
else:
    print("No")

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

int main() {
  int N;
  std::cin >> N;
  long power = 1;
  int divider = 1;
  for (int i = 0; i < 9; i++) divider *= 10;
  divider += 7;
  for (int i = 1; i < N + 1; i++) {
    power *= i;
    power %= divider;
  }
  std::cout << power << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ( )
{
int x,y;
    scanf("%d %d",&x,&y);
if(x>=-1000 && y<=1000 && y>=-1000 && y<=1000)
    {
    if(x<y)
    {
    printf("a < b\n");
    }
    if(x>y)
    {
    printf("a > b\n");
    }
    if(x==y)
    {
    printf("a == b\n");
    }
    }
return 0;
}









Measured memory_bytes: 2584
data = [list(map(int, input().split())) for _ in range(3)]

if data[0][1]-data[0][0] != data[1][1]-data[1][0]:
    print('No')
    exit()
if data[0][2]-data[0][0] != data[1][2]-data[1][0]:
    print('No')
    exit()
if data[0][1]-data[0][0] != data[2][1]-data[2][0]:
    print('No')
    exit()
if data[0][2]-data[0][0] != data[2][2]-data[2][0]:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int alpha[30];
int main(void){
  string s;
  cin>>s;
  bool f=true;
  int l,r,ans=0;
  l=0;r=s.size()-1;
  while(l<r){
    if(s[l]==s[r]){
      l++;r--;
    }
    else if(s[l]=='x'||s[r]=='x'){
      ans++;
      if(s[l]=='x') l++;
      else r--;
    }
    else{
      f=false;
      break;
    }
  }
  if(!f) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	int a, b,c,i,t;
	t = 0;
	cin >> a; cin >> b;
	if (1 <= b&&b <= 9) {
		c = 10 * a + b;
	}
	else if(b==100){
		c = 1000 * a + b;
	}
	else {
		c = 100 * a + b;
	}
	for (i = 1; i <= sqrt(c); i++) {
		if (i*i == c)t = 1;
	}
	while (true) {
		if (t == 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
		break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;

const long long MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(b, a);
    }

    sort(v.begin(), v.end());

    int ts = 0;
    for(int i = 0; i < n; i++){
        ts += v[i].second;
        if(ts > v[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
	public static void main(String[] args){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int k=s.nextInt();
		int m=s.nextInt();

		StringJoiner sj=new StringJoiner(" ");
		for(int i=0;i<k;++i)
			sj.add(String.valueOf(m));

		int o=k==1000000000?1:999999999;
		for(int i=k;i<n;++i)
			sj.add(String.valueOf(o));
		System.out.println(sj);
	}
}


Measured memory_bytes: 36832
N,start = map(int,input().split())
D = list(map(int,input().split()))
input()
Q = list(map(int,input().split()))

Q = [(k-1,i) for i,k in enumerate(Q)]
Q.sort()

P = [start]
for d in D:
  a = P[-1]
  b = abs(a-d)
  P.append(min(a,b))

result = [None]*len(Q)

x = 1

for i,d in zip(reversed(range(len(D))), reversed(D)):
  if Q[-1][0] == i:
    result[Q[-1][1]] = P[i] >= x
    Q.pop()
    if not Q:
      break

  if abs(x-d) < x:
    x += d

for r in result:
  print('YES' if r else 'NO')

Measured memory_bytes: 113988
N,A,B,C,D=(int(x) for x in input().split())
S=input()
def Solve():
    if '##' in S[B-1:D] or '##' in S[A-1:C]:#道中に石が2つ並んでたらその時点でアウト
        return 'No'
    if C<D:
        return 'Yes'
    if '...' in S[B-1:D]:
        return 'Yes'
    if (D!=N and S[D]=='.' and S[D-2]=="." and S[D-1]==".") or (S[B-2]=='.' and S[B-1]=="." and S[B]=="."):
        return 'Yes'
    else:
        return 'No'
    

print(Solve())


Measured memory_bytes: 3572
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    a, b, c = input().split()
    ans = 'A' + b[0] + 'C'
    print(ans)


if __name__ == '__main__':
    solve()

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

using namespace std;


int main()
{
  int n,k;

  cin >> n >> k;
  int num = 1;
  double pro = 0;

  for(int i = 1;
      i <= n;
      ++i)
    {
      double part_pro = 1.0/n;
      int num = 1;
      for(;
          (num * i) < k;
          num = (num << 1))
        {
          part_pro *= 0.5;
        }
      pro += part_pro;
    }
  cout << setprecision(20) << pro << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100005;
struct point
{
	int t,x,y;
}p[MAXN];
bool cmp(point a,point b)
{
	return a.t<b.t;
}
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d",&p[i].t,&p[i].x,&p[i].y);
	}
	sort(p+1,p+n+1,cmp);
	int x=0,y=0,t=0;
	for(int i=1;i<=n;i++)
	{
		int a=abs(p[i].x-x)+abs(p[i].y-y);
		int tt=p[i].t-t;
		if(tt<a||((tt-a)%2==1))
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

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

int main()
{
    int n, h;
    vector<int> a;
    vector<int> b;
    cin >> n >> h;
    int amax = 0;
    for(int i = 0; i < n; i++){
        int in1, in2;
        cin >> in1 >> in2;
        a.push_back(in1);
        b.push_back(in2);
        if(a[amax] < a[i]){
            amax = i;
        }
        if(a[amax] == a[i] && b[amax] > b[i]){
            amax = i;
        }
    }
    int last = b[amax];
    b[amax] = 0;
    int answer = 0;
    sort(b.begin(), b.end());
    while(b[b.size() - 1] > a[amax]){
        h -= b[b.size() - 1];
        answer++;
        b.pop_back();
        if(h <= 0){
            cout << answer << endl;
            return 0;
        }
    }
    if(h <= last){
        answer++;
        cout << answer << endl;
        return 0;
    }
    if(last > a[amax]){
        answer += (h - last) / a[amax];
        if((h - last) % a[amax] != 0){
            answer++;
        }
        answer++;
    } else {
        answer += h / a[amax];
        if(h % a[amax] != 0){
            answer ++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1276
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = (0, ) + tuple(map(int, readline().split()))
m = map(int, read().split())
G = [[] for _ in range(N + 1)]
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)

def dfs_order(G, root=1):
    parent = [0] * (N + 1)
    order = []
    stack = [root]
    while stack:
        x = stack.pop()
        order.append(x)
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            stack.append(y)
    return parent, order

def main(N, A, G):
    if N == 2:
        return A[1] == A[2]
    degree = [len(x) for x in G]
    root = degree.index(max(degree))
    parent, order = dfs_order(G, root)
    # 上に伸ばすパスの個数
    dp = [0] * (N + 1)
    for v in order[::-1]:
        if degree[v] == 1:
            dp[v] = A[v]
            continue
        p = parent[v]
        nums = [dp[w] for w in G[v] if v != p]
        x = sum(nums)
        y = max(nums)
        pair = x - A[v]
        if pair < 0 or pair > x - y or pair > x // 2:
            return False
        dp[v] = x - 2 * pair
    return dp[root] == 0

print('YES' if main(N, A, G) else 'NO')

Measured memory_bytes: 41376
#include <iostream>
#include <vector>
#include <algorithm>
#define N 200
using namespace std;

int main()
{
	int n, p, d;
	while (cin >> n, n) {
		vector<int> x(n, 0), y(n, 0);
		for (int i = 1; i < n; i++) {
			cin >> p >> d;
			x[i] = x[p] + (d!=0?d==2?1:0:-1);
			y[i] = y[p] + (d!=1?d==3?1:0:-1);
		}
		sort(x.begin(), x.end());
		sort(y.begin(), y.end());
		cout << x[n-1] - x[0] + 1 << " " << y[n-1] - y[0] + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
using namespace std;
int main(void){
	string S;
		cin >> S;
	int a=0,b=0;
	for(int i=0,j=1;i<S.size();i++,j*=(-1)){
		if((j==-1&&S[i]=='0')||(j==1&&S[i]=='1'))
			a++;
		else
			b++;
	}
	cout << min(a,b) << endl;
	return 0;
}

Measured memory_bytes: 512
package main 

import "fmt"

func main(){
	var A, B, C, X int 
	var coinArray[3]int
	var coin, tmp int

	fmt.Scan(&A, &B, &C, &X)
	
	coinArray[0] = A 
	coinArray[1] = B	
	coinArray[2] = C	
	tmp = 0
	for i := 0 ; i <= A ; i++ {
		for j := 0 ; j <= B ; j++ {
			for k := 0 ; k <= C ; k++ {
				tmp = 500 * i + 100 * j + 50 * k
				if tmp == X {coin++}
			}
		}
	}

	fmt.Println(coin)
}

Measured memory_bytes: 512