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

int s, m = 0;
int a[1000000];

int main()
{
	cin >> s;

	a[0] = s;

	for (int i = 0; i < 1000000; i++) {
		if (a[i] % 2 == 0)
			a[i + 1] = a[i] / 2;
		else
			a[i + 1] = a[i] * 3 + 1;

		for (int j = 0; j <= i; j++)
			if (a[i + 1] == a[j]) {
				m = i + 2;
				break;
			}

		if (m > 0)
			break;
	}

	cout << m << endl;

	return 0;
}

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

int main(){
    int n;
     cin >> n;
     vector<int> a(n);
     vector<int> appear(n + 1, 0);
     vector<int> appear2(n + 1, 0);
     vector<int> prefixSumK(n + 1, 0), prefixSum(n + 1, 0);
     vector<int> f(n + 1);
    for(int i = 0; i< n;i++){
        cin >> a[i];
        appear[a[i]] ++;
    }
    for(int i = 1; i <= n;i ++){
        int ci = appear[i];
        appear2[ci] ++;
    }
    for(int i = 1; i <= n; i++){
        prefixSumK[i] = prefixSumK[i-1] + i * appear2[i];
        prefixSum[i] = prefixSum[i-1] + appear2[i];
    }
    f[0] = 0;
    for(int i = 1; i <= n; i++){
        f[i] = (prefixSumK[i] + i * (prefixSum[n] - prefixSum[i])) / i;
    }

    int ptr = n;
    for(int k = 1; k <= n; k++){
        while(ptr > 0 && f[ptr] < k){
            ptr --;
        }
        cout << ptr << "\n";
    }
}


Measured memory_bytes: 10316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

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

    ll k = 1LL;
    ll res = 0LL;
    while(H > 0) {
        res += k;
        H /= 2LL;
        k *= 2LL;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  long long N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  cout << 5 + (N-1) / min({A,B,C,D,E}) << endl;
  return 0;
}

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

const int maxn = 50;
const int INF = 0x3f3f3f3f;
int dp[4010][4010];
int a[maxn], b[maxn], c[maxn];
int n, m1, m2;
int v1, v2;


int main(){
	memset(dp, INF, sizeof(dp));
	dp[0][0] = 0;
	cin >> n >> m1 >> m2;
	for (int i = 1; i <= n; ++i){
		cin >> a[i] >> b[i] >> c[i];
		v1 += a[i];
		v2 += b[i];
	}
	for (int i = 1; i <= n;++i)
	for (int j = v1; j >= a[i];--j)
	for (int k = v2; k >= b[i]; --k)
		dp[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]]+c[i]);
	int kk = INF;
	for (int i = 1; i*m1 <= v1&&i*m2 <= v2; ++i){
		kk = kk < dp[i*m1][i*m2] ? kk : dp[i*m1][i*m2];
	}
	if (kk == INF)cout << -1 << endl;
	else cout << kk << endl;
}

Measured memory_bytes: 63104
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
  int n;
  std::cin >> n;
  int a = n%10;
  if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) std::cout << "hon\n";
  else if(a == 3) std::cout << "bon\n";
  else std::cout << "pon\n";

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main(){
	int n; cin >> n;
	if(n==25) cout << "Christmas";
	if(n==24) cout << "Christmas Eve";
	if(n==23) cout << "Christmas Eve Eve";
	if(n==22) cout << "Christmas Eve Eve Eve";
	cout << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, p: "List[float]"):
    dp = [[0] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 1.0

    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += p[i] * dp[i][j]
            dp[i+1][j] += (1.0 - p[i]) * dp[i][j]
    return sum(dp[-1][(N // 2 + 1):])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ float(next(tokens)) for _ in range(N) ]  # type: "List[float]"
    result = solve(N, p)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 259952
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
int a[maxn],n;
inline void sol(int td){
	if(td==1){
		puts("First");
		exit(0);
	}
	puts("Second");
	exit(0);
}
inline void play(int user){
	int cnt=0,tag=0;
	rep(i,1,n)tag|=a[i]==1;
	rep(i,1,n)cnt+=(a[i]&1);
	if((cnt&1)^(n&1))sol(user);
	if(cnt>1||tag)sol(user^1);
	rep(i,1,n)if(a[i]&1)a[i]--;
	int g=a[1];
	rep(i,1,n)g=__gcd(g,a[i]);
	rep(i,1,n)a[i]/=g;
	play(user^1);
}
int main(){
	// judge();
	read(n);
	rep(i,1,n)read(a[i]);
	if(n>=3)play(1);
	if(n==1){
		sol(a[1]%2==0);
	}
	if(n==2){
		sol(a[1]%2==0||a[2]%2==0);
	}
	return 0;
}


Measured memory_bytes: 640
/*
Code Author: ADITYA SHETH (^_^)
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long // remove when constraints are tight.
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;

bool odd_cycle=false;
const int N=205;
int color[N];
int ar[N][N];
int n;
void dfs(int node,int col)
{
	if(color[node]!=0)
	{
		if(color[node]==col)
		{	
			return;
		}
		else
		{
			odd_cycle=true;
			return;
		}		
	}
	color[node]=col;
	for(int i=0;i<n;i++)
	{
		if(ar[node][i])
		{
			dfs(i,-col);
		}
	}
}
const int INF=1e9;
int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	
	cin>>n;	
	
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			char c;
			cin>>c;
			ar[i][j]=c-'0';
			
		}
	}
	dfs(0,1);
	
	
	if(odd_cycle)
	{
		cout<<-1<<endl;
		return 0;
	}
	int dis[n][n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{

			dis[i][j]=ar[i][j];
			if(dis[i][j]==0)
			{
				dis[i][j]=INF;
			}
		}
	}
	for(int k=0;k<n;k++)
	{
		for(int j=0;j<n;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(i==j)
				{
					continue;
				}
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	// for(int i=0;i<n;i++)
	// {
	// 	for(int j=0;j<n;j++)
	// 	{
	// 		cout<<dis[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	// for(int i=0;i<n;i++)
	// {
	// 	t(i,"=");
	// 	for(auto x: v[i])
	// 	{
	// 		cerr<<x<<" ";
	// 	}
	// }
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==j)
			{
				continue;
			}
			ans=max(ans,dis[i][j]+1);
		}
	}
	cout<<ans<<endl;
}


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

int main(){
	int A,B,T;
	cin >> A >> B >> T;
	
	cout << (T/A)*B << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;

    if (k <= a) {
        ans = k;
        cout << ans << endl;
        return 0;
    } else {
        ans = a;
        k = k - a;
    }

    if (k <= b) {
        cout << ans << endl;
        return 0;
    } else {
        k = k - b;
        ans = ans - k;
        cout << ans << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){

  int P,Q,R,max;
  scanf("%d", &P);
  scanf("%d", &Q);
  scanf("%d", &R);

  if(P>Q){
    max=P;
  }else{
    max=Q;
  }

  if(R>max){
    max=R;
  }

  printf("%d",P+Q+R-max);
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int c[26]={0},i;
    char s[100001];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        c[s[i]-'a']++;
    }
    for(i=0;i<26;i++){
        if(c[i]==0){
            printf("%c\n",i+'a');
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<double, double > pi; 
typedef pair<pair<double, double >, double > pii; 
int main(){

    ll N, C;
    cin >> N >> C;

    priority_queue<pii, vector<pii>, greater<pii> >  que;
    
    //重複は削除
    map<ll, map<pair<ll, ll>, ll > > mp;
    for(ll i = 0; i < N; i++){
        ll S, T, C; cin >> S >> T >> C;
        que.push(make_pair(make_pair(S, T), C));
    }

    
    priority_queue<pii, vector<pii>, greater<pii> > t_que;
    ll n = 0;
    ll ans = 0;
    //切り替えフラグ
    bool f = false;
    while(n < N){
        //cout << n << endl;
        pair<pair<double, double >, double >  tmp;
        
        if(f == false){
            tmp = que.top();
            que.pop();
            n++;
            while(!que.empty()){
                //同じチャンネル同士で録画できるのも含める
                ll t_t = tmp.first.second;
                ll t_s = que.top().first.first;
                if(t_t < t_s || (t_t == t_s && tmp.second == que.top().second) ){
                    //cout << "*";
                    tmp = que.top();
                    que.pop();
                    n++;
                }else{
                    t_que.push(que.top());
                    que.pop();
                }
            }
            f = true;
        }else{
            tmp = t_que.top();
            t_que.pop();
            n++;
            while(!t_que.empty()){
                ll t_t = tmp.first.second;
                ll t_s = t_que.top().first.first;
                if(t_t < t_s || (t_t == t_s && tmp.second == t_que.top().second)){
                    tmp = t_que.top();
                    t_que.pop();
                    n++;
                }else{
                    que.push(t_que.top());
                    t_que.pop();
                }
            }
            f = false;
        }
        //cout << endl;
        ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 8560
while True:
    [a,b,c]=[x for x in input().split()]
    [a,c]=[int(a),int(c)]
    op=b
    if op=="?":
        break
    elif op=="+":
        print(a+c)
    elif op=="-":
        print(a-c)
    elif op=="*":
        print(a*c)
    else:
        print(a//c)

Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<int>DP(N,1000000000);
  DP[0]=0;
  for(int i=0;i<N-1;i++){
    for(int j=1;j<=K;j++){
      if(i+j>=N)break;
      DP[i+j]=min(DP[i+j],DP[i]+abs(A[i+j]-A[i]));
    }
  }
  cout<<DP[N-1]<<endl;
}

Measured memory_bytes: 4028
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int x[3];
	REP(i, 3)cin >> x[i];
	sort(x, x + 3);
	if (x[0] + x[1] == x[2])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int m, f, b;
    int sub; 
    
    while(cin >> m){
        cin >> f >> b;
        if(m >= b) cout << 0 << endl;
        if(m < b){
            sub = b - m;
            if(sub <= f) cout << sub << endl;
            else cout << "NA" << endl;
        }
    }
}



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

 
int main()
{   
    string S, out;
    cin >> S;
    
    if(S=="ABC"){
        out = "ARC";
    }else{
        out = "ABC";
    }
    cout << out << endl;
  
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(){
  long biscuits=1,yen=0;
  long K,A,B;
  scanf("%ld%ld%ld",&K,&A,&B);

  if (A>=B-1)
  {
    biscuits=K+1;
  }else{
    while (0<K)
    {
      if (K<2){ biscuits++; break;}

      if (biscuits>=A)
      {
        yen=biscuits/A;
        biscuits-=yen*A;
        K-=yen;
      }else{
        K-=A-biscuits;
        biscuits+=A-biscuits;
      }

      if (yen<=K)
      {
        biscuits+=yen*B;
        K-=yen;
      }else{
        while (yen>0)
        {
          if (K>0)
          {
            biscuits+=K*B;
            yen-=K;
            K=0;
          }else{
            yen--;
            biscuits+=A;
            K++;
          }
        }
      }
    }
  }

  printf("%ld",biscuits);

  return 0;
}

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

using namespace std;

int main(void){
    long long K, N;
    cin >> K >> N;
    vector<long long> A(N + 1);
    for(int i = 0; i < N; i++) cin >> A[i];
    A[N] = A[0] + K;
    long long ans = K;
    for(int i = 0; i < N; i++) ans = min(ans, K - (A[i + 1] - A[i]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#![allow(unused_imports, unused_macros, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

#[derive(Eq, PartialEq)]
enum Status {
    Vacant,
    Male,
    Female,
}

fn query(n: usize) -> Status {
    println!("{}", n);
    let _ = std::io::stdout().flush();
    let res: String = readln();
    match res.as_str() {
        "Male" => Status::Male,
        "Female" => Status::Female,
        _ => ::std::process::exit(0),
    }
}

fn main() {
    let n: usize = readln();

    let mut fl = query(0);
    let mut low = 0;
    let mut high = 2 * n - 1;
    while high - low > 1 {
        let mid = low + ((high - low) >> 1);
        let fm = query(mid % n);
        if (mid - low) % 2 == 0 && fl == fm || (mid - low) % 2 == 1 && fl != fm {
            low = mid;
            fl = fm;
        } else {
            high = mid;
        }
    }
}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}


Measured memory_bytes: 4948
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;


int main(){
	int N;
	cin>>N;
	int H[N];
	int ma=0;
	for(int i = 0; i < N; i++){
		cin>>H[i];
		ma = max(H[i],ma);
		if(ma - H[i] >= 2){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
		
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
 
#define int long long

#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define mp(a, b) make_pair((a), (b))
 
using namespace std;

int N;
string S;

map<pair<string, string>, int> m, m2;
 
void dfs(int idx, string red, string blue) {
    if (idx == N) {
        m[mp(red, blue)]++;
        return;
    }
    dfs(idx + 1, red + S[idx], blue);
    dfs(idx + 1, red, S[idx] + blue);
}
 
void dfs2(int idx, string blue, string red) {
    if (idx == N) {
        m2[mp(blue, red)]++;
        return;
    }
    dfs2(idx + 1, blue + S[2 * N - idx - 1], red);
    dfs2(idx + 1, blue, S[2 * N - idx - 1] + red);
}
 
signed main() {
    cin >> N >> S;
 
    dfs(0, "", "");
    dfs2(0, "", "");
 
    int ret = 0;
    itrep(it, m) {
        ret += it->second * m2[it->first];
    }
 
    cout << ret << endl;
 
    return 0;
}

Measured memory_bytes: 101376
//
//  main.cpp
//  JOI
//
//  Created by Kate Tada on 2016/06/08.
//  Copyright ?? 2016??´ aaa. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1156
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N, M;
int[] A, B;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      M = readInt();
      A = new int[M];
      B = new int[M];
      foreach (i; 0 .. M) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }
      
      if (M % 2 == 0) {
        auto deg = new int[N];
        auto cnt = new int[N];
        auto sets = new RedBlackTree!int[N];
        foreach (u; 0 .. N) {
          sets[u] = new RedBlackTree!int;
        }
        foreach (i; 0 .. M) {
          ++deg[A[i]];
          ++deg[B[i]];
          sets[A[i]].insert(B[i]);
          sets[B[i]].insert(A[i]);
        }
        alias Entry = Tuple!(int, int);
        BinaryHeap!(Array!Entry, "a > b") q;
        auto vis = new bool[N];
        foreach (u; 0 .. N) {
          if (deg[u] > 0) {
            q.insert(Entry(deg[u], u));
          }
        }
        for (; !q.empty; ) {
          int u = q.front[1];
          q.removeFront;
          if (deg[u] > 0) {
            int v = sets[u].front;
            // if (deg[u] == 1) {
              if (cnt[u] % 2 == 0) {
                swap(u, v);
              }
            // }
            writeln(u + 1, " ", v + 1);
            --deg[u];
            --deg[v];
            ++cnt[u];
            sets[u].removeKey(v);
            sets[v].removeKey(u);
            if (deg[u] > 0) {
              q.insert(Entry(deg[u], u));
            }
            if (deg[v] > 0) {
              q.insert(Entry(deg[v], v));
            }
          }
        }
      } else {
        writeln(-1);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 23024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name=br.readLine();
		int num;
		int compare;

		while(true){

			try{
				StringTokenizer st=new StringTokenizer(name," ");
				compare=Integer.parseInt(st.nextToken())+Integer.parseInt(st.nextToken());
				System.out.println(compare);
				name=br.readLine();
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 24160
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll white, black;
// vector<vector<char>> c(h, vector<char>(w));
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
    

//     if(A.size() == h+w){
//       // rep(i, A.size()) cout << A[i];
//       // cout << " ";
//       vector<vector<char>> tmp(h, vector<char>(w));
//       rep(i, h){
//         rep(j, w) tmp[i][j] = c[i][j];
//       }
//       ll cnt = black;
//       for(ll i = 0; i < h; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, w){
//             if(tmp[i][j] == '#'){
//               tmp[i][j] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }
//       for(ll i = h; i < h+w; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, h){
//             if(tmp[j][i-h] == '#'){
//               tmp[j][i-h] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }

//       // cout << cnt << endl;
//       if(cnt == k) ans++;
      
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

int main(){
  
  string n; cin >> n;
  ll tmp = 0;
  // cout << n[0] << endl;
  rep(i, n.length()){
    // cout << tmp << endl;
    tmp += n[i] - '0';
  }
  if(tmp%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  // cout << tmp << endl;
  // cout << tmp%9 << endl;



  return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int N, M;
vector<pair<int, int>> cities,sorted;

int main() {

	scanf("%d %d", &N, &M);

	int prefecture, year;
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &prefecture, &year);
		cities.push_back(make_pair(prefecture, year));
		sorted.push_back(make_pair(prefecture, year));
	}
	for (int i = 0; i <= N; i++)
		sorted.push_back(make_pair(i, -1));

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

	for (int i = 0; i < M; i++) {
		auto lower = lower_bound(sorted.begin(), sorted.end(), make_pair(cities[i].first, -1));
		auto upper = lower_bound(sorted.begin(), sorted.end(), cities[i]);
		
		printf("%06d%06d\n", cities[i].first, upper - lower);
	}

	return 0;
}

Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 200100

ll X,Y,N;
ll A[MAXN], B[MAXN];
ll p[MAXN];
vpi V[MAXN];
vi merged[MAXN];
const ll MOD = 1e9+7;

ll par(ll x){return (x == p[x])?x:p[x] = par(p[x]);}

void merge (ll a, ll b){
	p[par(a)] = par(b);
	// cout<<"Merge "<<a<<' '<<b<<'\n';
}

map<ll,ll> M;
ll fact[MAXN];
ll inv[MAXN];

ll exp(ll a, ll b){
	if (b==0)return 1;
	ll h=exp(a,b/2);
	h=(h*h)%MOD;
	if (b%2)h=h*a%MOD;
	return h;
}

ll ans=1;

int main(){
	cin>>N>>X>>Y;
	fact[0] = 1;
	inv[0] = 1;
	for (ll i=1;i<=N;++i){
		fact[i] = fact[i-1]*i%MOD;
		inv[i] = exp(fact[i], 1e9+5);
		cin>>A[i]>>B[i];
		p[i] = i;
		V[A[i]].pb(B[i], i);
	}
	for (ll i=1;i<=N;++i){
		sort(ALL(V[i]));
		if (SZ(V[i]) <= 1)continue;
		for (ll j=1;j<SZ(V[i]);++j){
			ll w = V[i][j].f + V[i][0].f;
			if (w > X)break;
			merge(V[i][j].s, V[i][0].s);
		}
	}
	ll lowest = 1e9;
	ll ind = -1;
	for (ll i=1;i<=N;++i)if (B[i] <= lowest){lowest=B[i]; ind = i;}
	for (ll i=1;i<=N;++i)if (A[i] != A[ind]){
		if (B[i] + B[ind] > Y)continue;
		merge(i,ind);
	}
	ll lowest2 = 1e9;
	ll ind2 = -1;
	for (ll i=1;i<=N;++i)if (B[i] <= lowest2 && A[i] != A[ind]){lowest2=B[i]; ind2 = i;}
	for (ll i=1;i<=N;++i)if (A[i] != A[ind2]){
		if (B[i] + B[ind2] > Y)continue;
		merge(i,ind2);
	}

	for (ll i=1;i<=N;++i){
		merged[par(i)].pb(A[i]);
	}

	for (ll i=1;i<=N;++i)if (SZ(merged[i])){
		M.clear();
		ll e = 0;
		for (auto j : merged[i]){M[j]++;e++;}
		ans = (ans*fact[e])%MOD;
		for (auto j : M){
			ans = (ans*inv[j.s])%MOD;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 32884
#include <stdio.h>

typedef struct _tree_t {
	int id;
	struct _tree_t *p, *l, *r;
} tree_t;






tree_t* tree_insert(tree_t* root, int id){
	tree_t *y = NULL;
	tree_t *x = root;
	tree_t *z = (tree_t*)malloc(sizeof(tree_t));
	z->id = id;
	z->l = z->r = z->p = NULL;

	while(x != NULL) {
	    y = x;
	    if(z->id < x->id) {
	        x = x->l;
	    } else { 
	        x = x->r;
	    }
	}
	z->p = y;
	if(y == NULL) {
    	root = z;
	} else if(z->id < y->id) {
	    y->l = z;
	} else { 
	    y->r = z;
	}
	
	return root;
}

void preorder(tree_t *tree) {
    printf(" %d", tree->id);
    if(tree->l != NULL) preorder(tree->l);
    if(tree->r != NULL) preorder(tree->r);
}

void inorder(tree_t *tree) {
    if(tree->r == NULL && tree->l == NULL) {
        printf(" %d", tree->id);
    } else if(tree->r == NULL) {
        inorder(tree->l);
        printf(" %d", tree->id);
    } else if(tree->l == NULL) {
        printf(" %d", tree->id);
        inorder(tree->r);
    } else {
        inorder(tree->l);
        printf(" %d", tree->id);
        inorder(tree->r);
    }
}

int main(void) {
	int i, n, id;
	char buff[100];
	tree_t *root = NULL;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%s %d\n", buff, &id);
		if(buff[0] == 'i') {
			root =tree_insert(root, id);
		} else if(buff[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}




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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(4);
	
	int n, x, l = 0, k, ans = 0;

	cin >> n >> x;

	n++;

	while (n--) {
		cin >> k;
		if (l <= x) ans++;
		l += k;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        check = [a[i + k][j:j + m] for k in range(m)]

        flag = True
        for x in range(m):
            if check[x] != b[x]:
                flag = False
                break

        if flag:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int w = in.nextInt();
        int h = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();

        System.out.print(new BigDecimal(Integer.valueOf(w))
                .multiply(new BigDecimal(Integer.valueOf(h))
                        .divide(new BigDecimal("2"), 6, RoundingMode.CEILING)));
        System.out.print(" ");
        if (x * 2 == w && y * 2 == h) {
            System.out.print(1);
        } else {
            System.out.print(0);
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3
#define max_n 122000
#define max_v 1e12+10
typedef long long ll;   
typedef unsigned long long ull;
inline long long read(){
	long long x=0;char c=getchar();
    int nag=1;if(c=='-'){
        nag=-1;c=getchar();
    }
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*nag;
}
vector<ll> n;
ll res[int(1e7)],k;
int l=1,r=0;
void init() {
	for(int i=1;i<10;i++)
		res[++r]=i;
	while(r>l){
		ll c=res[l++];
		if(c>ll(1e11)) return;
		n.push_back(c);
		int check=c%10;
		res[++r]=c*10ll+check;
		if(check!=0) res[++r]=c*10ll+check-1;
		if(check!=9) res[++r]=c*10ll+check+1;
	}
}
int main(){
    init();cin>>k;
    sort(n.begin(),n.end());
    /*if(k==1){
        cout<<1<<endl;
        return 0;
    }*/
    cout<<n[k-1];
}


Measured memory_bytes: 22764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	int N=s.size();
	rep(i,N-1) if(s[i]==s[i+1]){
		cout<<i+1<<" "<<i+2<<endl;
		return 0;
	}
	rep(i,N-2) if(s[i]==s[i+2]){
		cout<<i+1<<" "<<i+3<<endl;
		return 0;
	}
	puts("-1 -1");
}


Measured memory_bytes: 512
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import core.bitop;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);
    auto BS = readln.split.to!(int[]);

    auto DP = new int[][](51, 2^^N);
    foreach (ref dp; DP) dp[] = -1;

    int solve(uint s, int p) {
        auto i = popcnt(s);
        if (i == N) return 0;
        if (DP[p][s] == -1) {
            int r = int.max/2;
            foreach (j; 0..N) if (!(s & (1<<j))) {
                auto x = (i+j)%2 == 0 ? AS[j] : BS[j];
                if (x < p) continue;
                int d;
                foreach (k; j+1..N) if (s & (1<<k)) ++d;
                r = min(r, solve(s | (1<<j), x) + d);
            }
            DP[p][s] = r;
        }
        return DP[p][s];
    }
    auto r = solve(0, 0);
    writeln(r >= int.max/2 ? -1 : r);
}

Measured memory_bytes: 56700
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np
import queue

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]

for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [[mod,mod,mod] for i in range(N)]

from collections import deque

# q = queue.Queue()
q = deque()
q.append((S,0))
# Deep First Serch
while q:
    now, cost = q.popleft()
    state = cost % 3
    if used[now][state] == mod:
        used[now][state] = cost
        for route in routes[now]:
            q.append((route,cost+1))

# print(used)
try:
    ans = used[T][0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))


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

int main() {
	int a, b;
	
	cin >> a >> b;

	if ((a*b) % 2 == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<stdio.h>
#include<map>
using namespace std;
struct wolf{
	int t[9];
	wolf(){}
};
int v[9];
int D[36][9]={
{2,0,0,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0,0},
{3,0,0,0,0,0,1,0,0},
{1,0,1,0,0,1,0,0,0},
{0,2,0,0,0,1,0,0,0},
{2,1,0,0,0,1,0,0,0},
{4,0,0,0,0,1,0,0,0},
{1,0,0,1,1,0,0,0,0},
{0,1,1,0,1,0,0,0,0},
{2,0,1,0,1,0,0,0,0},
{1,2,0,0,1,0,0,0,0},
{3,1,0,0,1,0,0,0,0},
{5,0,0,0,1,0,0,0,0},
{0,1,0,2,0,0,0,0,0},
{0,0,2,1,0,0,0,0,0},
{2,0,0,2,0,0,0,0,0},
{1,1,1,1,0,0,0,0,0},
{0,3,0,1,0,0,0,0,0},
{3,0,1,1,0,0,0,0,0},
{2,2,0,1,0,0,0,0,0},
{4,1,0,1,0,0,0,0,0},
{6,0,0,1,0,0,0,0,0},
{1,0,3,0,0,0,0,0,0},
{0,2,2,0,0,0,0,0,0},
{2,1,2,0,0,0,0,0,0},
{4,0,2,0,0,0,0,0,0},
{1,3,1,0,0,0,0,0,0},
{3,2,1,0,0,0,0,0,0},
{5,1,1,0,0,0,0,0,0},
{7,0,1,0,0,0,0,0,0},
{0,5,0,0,0,0,0,0,0},
{2,4,0,0,0,0,0,0,0},
{4,3,0,0,0,0,0,0,0},
{6,2,0,0,0,0,0,0,0},
{8,1,0,0,0,0,0,0,0},
{10,0,0,0,0,0,0,0,0}
};
long long conv(wolf a){
	long long ret=0;
	for(int i=0;i<9;i++){
		ret*=128;
		ret+=a.t[i];
	}
	return ret;
}
map<long long,int> dp;
int solve(wolf a,int b){
	if((int)(dp.count(conv(a))))return dp[conv(a)];
	int ret=0;
	for(int i=b;i<36;i++){
		bool ok=true;
		for(int j=0;j<9;j++){
			if(a.t[j]<D[i][j]){
				ok=false;
				break;
			}
		}
		if(ok){
			for(int j=0;j<9;j++)a.t[j]-=D[i][j];
			ret=max(ret,solve(a,i)+1);
			for(int j=0;j<9;j++)a.t[j]+=D[i][j];
		}
	}
	return dp[conv(a)]=ret;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		dp.clear();
		for(int i=0;i<10;i++)v[i]=0;
		for(int i=0;i<a;i++){
			int b;
			scanf("%d",&b);
			b--;
			v[b]++;
		}
		int ret=0;
		for(int i=5;i<9;i++){
			int V=min(v[i],v[8-i]);
			ret+=V;
			v[i]-=V;
			v[8-i]-=V;
		}
		ret+=v[4]/2;
		v[4]%=2;
		wolf S;
		for(int i=0;i<9;i++)S.t[i]=v[i];
		printf("%d\n",ret+solve(S,0));
	}
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
#define mod 1000000007
#define N 1000000
int main()
{
    int n; cin >> n;

    ll ans = 0;
    for(ll i=1; i<=N; i++){
        for(ll j=1; j<=N; j++){
            if(i*j >= n) break;
            if(n - i*j >= 1) ans++;
        }
    }

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

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
int power(long long x, long long y, long long p) {
    long long res = 1;  // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1) res = (res * x) % p;

        // y must be even now
        y = y >> 1;  // y = y/2
        x = (x * x) % p;
    }
    return res;
}

long long modInverse(long long n, long long p) { return power(n, p - 2, p); }

long long nCrModPFermat(long long n, long long r, long long p) {
    if (r == 0) return 1;
    long long fac[n + 1];
    fac[0] = 1;
    for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long a, b, ans = 0;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int ans=0,cnt,a[N],b[N],d[N],s[N],c[N],n,k,q;
bool ck(int x,int mid){
	s[0]=0; int tot=0;
	for (int i=1;i<=n;i++){
	if (a[i]<x) b[i]=0,d[++tot]=i;
	if (a[i]>=x&&a[i]<=mid) b[i]=1;
	if (a[i]>mid) b[i]=2;
	if (b[i]==1) s[i]=s[i-1]+1; else s[i]=s[i-1];
	}
	int cnt=0; d[0]=0;
	d[++tot]=n+1;
	for (int i=1;i<=tot;i++){
		int l=d[i-1]+1,r=d[i]-1;
		if (l>r) continue;
		if (r-l+1<k) continue;
		cnt+=min(s[r]-s[l-1],r-l+2-k);
	}
	return (cnt>=q);
}
int main(){
	n=read(),k=read(),q=read();
	for (int i=1;i<=n;i++) a[i]=read(),c[i]=a[i];
	ans=1e9;
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++){
		cnt=1e9;
		int l=i,r=n;
		while (l<=r){
			int mid=(l+r)>>1;
			if (ck(c[i],c[mid])) cnt=min(cnt,c[mid]-c[i]),r=mid-1; else l=mid+1;
		}
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
}

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

int main() {
 int a, b;
  cin >> a >> b;
  for (int i = 0; i <= 1000000; i++) {
    if ((i*8)/100 == a && (i*10)/100 == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1, tt;
const ll N = 1000005;
void solve(){
	ll n, a, b;
	cin>>n>>a>>b;
	cout<<(n/(a+b))*a + min(n%(a+b),a);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


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

int main()
{
	string s;

	char t[100];

	int ans = 0;

	cin >> s;

	for (int i = 0; i < s.size(); i += 2)
	{
		if ((s.at(i) == 'R') || (s.at(i) == 'U') || (s.at(i) == 'D'))++ans;
	}
	
	for (int i = 1; i < s.size(); i += 2)
	{
		if ((s.at(i) == 'L') || (s.at(i) == 'U') || (s.at(i) == 'D'))++ans;
	}

	if (ans == s.size())
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << b << endl
#define COUT3(a, b, c) cout << a << b << c << endl
#define VINT(v, n) vector<int> v(n)
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m))
#define VCHAR(v, n) vector<char> v(n)
#define MAX(a, b) a > b ? a : b;
#define MIN(a, b) a < b ? a : b;

using namespace std;

int main() {
    long long N, T = 0, A = 0;
    CIN(N);
    REP(i, N) {
        int t, a;
        CIN2(t, a);
        if(i == 0) {
            T = t;
            A = a;
        } else {
            long long n1, n2;
            if(T % t == 0) n1 = T / t;
            else n1 = T / t + 1;
            if(A % a == 0) n2 = A / a;
            else n2 = A / a + 1;
            long long n = max(n1, n2);
            T = n * t;
            A = n * a;
        }
    }
    cout << T + A << endl;
}


Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 04.18.2020 00:49:08
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

int main() {
  int N, M;
  cin >> N >> M;
  unordered_map<int, int> cnt;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  for (int i = 0; i < M; i++) {
    int b, c;
    cin >> b >> c;
    cnt[c] += b;
  }

  vector<P> v;
  for (auto& p : cnt) {
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  ll sum = 0;
  int c = N;
  for (int i = v.size() - 1; i >= 0; i--) {
    auto& p = v[i];
    sum += (ll)p.first * min(c, p.second);
    c -= p.second;
    if (c <= 0) break;
  }
  cout << sum << endl;
}


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

int K, dp[309][309][309]; string S;

int solve(int l, int r, int c) {
	if (c > K) return -(1 << 30);
	if (l > r) return 0;
	if (l == r) return 1;
	if (dp[l][r][c] >= 0) return dp[l][r][c];
	int ret = 0;
	ret = max(ret, solve(l + 1, r, c));
	ret = max(ret, solve(l, r - 1, c));
	if (S[l] == S[r]) ret = max(ret, solve(l + 1, r - 1, c) + 2);
	else ret = max(ret, solve(l + 1, r - 1, c + 1) + 2);
	dp[l][r][c] = ret;
	return ret;
}

int main() {
	cin >> S >> K;
	for (int i = 0; i < 309; i++) { for (int j = 0; j < 309; j++) { for (int k = 0; k < 309; k++) dp[i][j][k] = -1; } }
	cout << solve(0, S.size() - 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 115584
import java.util.Scanner;


public class Main{

     public static void main(String []args){
        Scanner scan = new Scanner(System.in);
        int str1 = scan.nextInt();
        int str2 = scan.nextInt();
 
        if(str1 == str2){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        scan.close();
     }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  s[3] = '8';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256