akhauriyash/Code-Regression huggingface dataset:
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
ll a[N],b[N];
signed main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n,m,k;cin>>n>>m>>k;
    _for(i,0,n){
        int x;cin>>x;
        a[i+1]=a[i]+x;
    }
    _for(i,0,m){
        int x;cin>>x;
        b[i+1]=b[i]+x;
    }
    int ans = 0;
    ll res;
    _for(i,0,n+1){
        res = k-a[i];
        if(res<0){
            if(i==1){
                int y = lower_bound(b,b+m+1,k)-b;
                if(y==m+1)y=m;
                else if(b[y]>k)--y;
                ans = max(ans,y);
                break;
            }
            else break;
        }else if(res==0)ans = max(i,ans);
        else{
            int y = lower_bound(b,b+m+1,res)-b;
            if(y==m+1)y=m;
            else if(b[y]>res)--y;
            ans = max(ans,y+i);
        }
    }
    cout<<ans;
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}


Measured memory_bytes: 6712
N = int(input())
a = list(map(int,input().split()))
x = a[0]
y = sum(a[1:])
ans = abs(x-y)
for i in range(1,N-1):
    x += a[i]
    y -= a[i]
    ans = min(abs(x-y),ans)

print(ans)


Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
    ll n,k;
    cin>>n>>k;
    vector<ll>h(n);
    for(int i=0;i<n;++i){
        cin>>h[i];
    }
    ll dp[n];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    for(ll i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for(ll j=2;j<=min(i,k);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
    }
    cout<<dp[n-1];
}
int main(){
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
s=0
t=0
u=0
for i in range(n):
  if a[i]%4==0:
    s=s+1
  elif a[i]%2==0:
    t=t+1
  else:
    u=u+1
if t>=1:
  if s>=u:
    print("Yes")
  else:
    print("No")
else:
  if s-u>=-1:
    print("Yes")
  else:
    print("No")
    
  

Measured memory_bytes: 19892
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb emplace_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int mod = (int)1e9 + 7;
//const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/
const int  N = 1e6+1;
vector<int> sieve(N+7,1);
void fun()
{
    sieve[0] =0;
    sieve[1] = 0;
    for(int i=2;i*i<=N;++i)
    {
        if(sieve[i])
        {
            for(int j=i*i;j<=N;j+=i)
            {
                sieve[j] = 0;
            }
        }
    }
}
int modExpo(int x,int y){
  int res = 1;
  while(y > 0){
    if(y&1)
      res = (res*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
  }
  return res;
}
int32_t main() 
{
    fastio
    int n;
    cin>>n;
    cout<<(n*n)<<el;
    return 0;
}



Measured memory_bytes: 8064
def read():
    N, M = list(map(int, input().strip().split()))
    A = list(map(int, input().strip().split()))
    B = []
    C = []
    for m in range(M):
        b, c = list(map(int, input().strip().split()))
        B.append(b)
        C.append(c)
    return N, M, A, B, C


def solve(N, M, A, B, C):
    cindex_desc = sorted(range(M), key=lambda k: C[k])
    A = sorted(A)
    left_index = 0
    for i in reversed(cindex_desc):
        for j in range(B[i]):
            if left_index >= N:
                break
            if A[left_index] < C[i]:
                A[left_index] = C[i]
                left_index += 1
            else:
                break
    return sum(A)


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 21044
N,M = map(int, input().split())

AB = []
for _  in range(N):
    AB.append(list(map(int, input().split())))

AB.sort()

num = 0
val = 0
for ab in AB:
    if num+ab[1] >= M:
        val += (M-num)*ab[0]
        break
    else:
        val += ab[1]*ab[0]
        num += ab[1]
print(val)

Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;

int main()
{
    boost;
    int x; cin >> x;
    if (x < 30) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 3636
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
n,m = map(int,input().split())
ans = ((m+n) * (m+n-1))//2
kisu = (n *(n-1))//2
gusu = (m*(m-1))//2
kigu = ans - kisu - gusu

print(kisu+gusu)

Measured memory_bytes: 21888
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N;
    vi a(N), b(N);
    REP(i, N) {
        cin >> X >> Y;
        a[i] = (X + Y);
        b[i] = (X - Y);
    }
    sort(ALL(a));
    sort(ALL(b));
    cout << max(abs(a.back() - a.front()), abs(b.back() - b.front())) << endl;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
   string a;
cin >> a ;
  int n = a.size();
REP(i,n){
if(a[i]=='1'){
  a[i]='9';
}
else if(a[i]=='9'){
  a[i]='1';
}
}
cout <<a;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    int N;
    scanf("%d", &N);
    char S[605][605], T[605][605];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            char c;
            scanf(" %c", &c);
            S[i][j] = S[i + N][j] = S[i][j + N] = S[i + N][j + N] = c;
            T[j][i] = T[j + N][i] = T[j][i + N] = T[j + N][i + N] = c;
        }
    }

    int ans = 0;
    for (int a = 0; a < N; ++a) for (int b = 0; b < N; ++b) {
        int ok = 1;
        //for (int i = 0; i < N; ++i) for (int j = 0; j <= i; ++j) {
        //    if (S[i + a][j + b] != T[i + b][j + a]) {
        //        ok = 0;
        //        break;
        //    }
        //}
        for (int i = 0; i < N; ++i) {
            if (memcmp(S[i + a] + b, T[i + b] + a, i + 1)) {
                ok = 0;
                break;
            }
        }
        ans += ok;
    }
    printf("%d\n", ans);
}

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

long long GetGreatestCommonDivisor(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main()
{
	long long n, X; cin >> n >> X;

	vector<long long> x(n); for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	x.push_back(X);

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

	vector<long long> d(n);
	for (int i = 0; i < n; i++) {
		d[i] = x[i + 1] - x[i];
	}

	long long tmp = d[0];
	for (int i = 1; i < n; i++) {

		tmp = GetGreatestCommonDivisor(tmp, d[i]);

	}
	
	cout << tmp << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a,mark[1000005][2],tr,tc,corn;
long long ans;
bool r[1004],c[1004];
const int mod=1e9+7;
int main(){
	int n,m;
	ans=1;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		mark[a][0]=i;
	}
	for(int i=1;i<=m;++i){
		scanf("%d",&a);
		mark[a][1]=i;
	}
	for(int i=n*m;i>0;--i){
		if(mark[i][0] && mark[i][1]){
			if(r[mark[i][0]] || c[mark[i][1]]){
				ans=0;
				break;
			}
			r[mark[i][0]]=c[mark[i][1]]=1;
			tr++;tc++;
			corn+=(tc-1);
			corn+=(tr-1);
		}
		else if(mark[i][0] && !mark[i][1]){
			if(r[mark[i][0]]){
				ans=0;
				break;
			}
			r[mark[i][0]]=1;
			tr++;
			ans=(ans*tc)%mod;
			corn+=(tc-1);
		}
		else if(!mark[i][0] && mark[i][1]){
			if(c[mark[i][1]]){
				ans=0;
				break;
			}
			c[mark[i][1]]=1;
			tc++;
			ans=(ans*tr)%mod;
			corn+=(tr-1);
		}
		else{
			ans=(ans*corn)%mod;
			corn--;
		}
		//cout<<ans<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
  private static Character[] toCharacter(String str) {
    Character ary[] = new Character[str.length()];
    for (int i = 0; i < str.length(); ++i) {
      ary[i] = str.charAt(i);
    }
    return ary;
  }
  
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String _s = sc.next();
    String _t = sc.next();

    Character[] s = toCharacter(_s);
    Arrays.sort(s);

    Character[] t = toCharacter(_t);
    Arrays.sort(t, new Comparator<Character>() {
      @Override
      public int compare(Character a, Character b) {
        if (a < b) return 1;
        else if (a > b) return -1;
        else return 0;
      }
    });

    int i = 0;
    while (i < s.length && i < t.length && s[i] == t[i]) ++i;

    if ((i != s.length && i != t.length && s[i] < t[i]) || (i == s.length && i != t.length))  {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }   

    sc.close(); 
  }
}


Measured memory_bytes: 22484
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class PrimeNumber2
    {
        public static void Main()
        {
            // 素数をリストにする
            var prime = new List<int>() { 2 };
            for (int i = 3; i <= 51000; i = i + 2)
            {
                bool is_prime = true;
                foreach (var p in prime)
                {
                    if (i % p == 0)
                    {
                        is_prime = false;
                        break;
                    }
                    else if (p >= Math.Sqrt(i)) { break; }
                }
                if (is_prime) { prime.Add(i); }
            }

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                int a = prime.Where(x => x < int.Parse(input)).Max();
                int b = prime.Where(x => x > int.Parse(input)).Min();
                Console.WriteLine(a + " " + b);
            }
        }
    }
}

Measured memory_bytes: 5908
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

int main() {
	Int n;
	cin >> n;
	vector<Int> d(n);
	for (Int i = 0; i < n; i++)cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if((a * 100 + b * 10 + c) % 4 == 0){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 3600
import bisect

N = int(input())
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]
C = [int(i) for i in input().split(' ')]

A.sort()
B.sort()
C.sort()

count = 0
for b in B:
    i = bisect.bisect_left(A,b)
    j = bisect.bisect_right(C,b)
    count += i * (N - j)

print(count)

Measured memory_bytes: 23232
#include <iostream>
#include <cstring>
using namespace std;
int vis[105];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int a,d;
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			cin>>a;
			vis[a]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!vis[i]) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M := nextInt(), nextInt()
	if N == 1 && M == 1 {
		fmt.Println(1)
	} else if N == 1 || M == 1 {
		fmt.Println(N*M - 2)
	} else if N == 2 || M == 2 {
		fmt.Println(0)
	} else {
		fmt.Println(N*M - (N+M)*2 + 4)
	}
}

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

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
foodtime = []
for i in range(5):
    foodtime.append(int(input()))
thinkfood = []
for j in range(5):
    thinkfood.append((foodtime[j]-1)%10)
thinkfood = sorted(thinkfood)
u = 10-(thinkfood[0]+1)
ans = 0
for k in range(5):
    if foodtime[k]%10==0:
        ans += foodtime[k]
    else:
        ans += foodtime[k] - (foodtime[k]%10) + 10
print(ans - u)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

/////////////////////////////////////////////////////////////////
// https://github.com/atcoder-live/library/blob/master/mint.cpp
/////////////////////////////////////////////////////////////////
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    mpi a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    mpi d = v - w;
    if (d <= 0) {
        cout << "NO" << endl;
        return 0;
    }
    if (abs(a - b) <= d * t) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    // cout << setprecision(10);
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
const int sz=110;
int g[sz][sz];
main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(!a)
    {
        printf("1 1\n#\n");
        return 0;
    }
    if(!b)
    {
        printf("1 1\n.\n");
        return 0;
    }
    printf("100 100\n");
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)if(i<=50) g[i][j]=0;else g[i][j]=1;
    }
    a--,b--;
    for(int i=1;i<=50&&b;i+=2)for(int j=1;j<=100&&b;j+=2)g[i][j]=1,b--;
    for(int i=1;i<=50&&a;i+=2)for(int j=1;j<=100&&a;j+=2)g[101-i][j]=0,a--;
    for(int i=1;i<=100;i++,putchar('\n'))for(int j=1;j<=100;j++)printf("%c",g[i][j]?'#':'.');
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int N = 100;

int main()
{
    int n,p[N+1],m[N+1][N+1],i,l,j,k;

    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
      scanf("%d%d",&p[i-1],&p[i]);
    }

    for(i=1;i<=n;i++) m[i][i]=0;
    for(l=2;l<=n;l++)
    {
        for(i=1;i<=n-l+1;i++)
        {
        j = i+l-1;
        m[i][j] = (i << 21);
        for(k=i;k<=j-1;k++)
        {
	  if(m[i][j] > m[i][k] + m[k+1][j] + p[i -1] * p[k] * p[j])
	    {
	      m[i][j] = m[i][k] + m[k+1][j] + p[i -1] * p[k] * p[j];
	    }
        }
        }
    }


    printf("%d\n",m[1][n]);

    return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(S.at(i)==S.at(j))cnt++;
    }
    if(cnt!=2){
      cout<<"No"<<endl;
      return 0;
    }  
    cnt=0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,a,b;
    cin>>x>>a>>b;
    
    a=abs(a-x);
    b=abs(b-x);
    if(a>b) cout1("B")
    else cout1("A")
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int a[1000];
signed main(){
    int n,d,x;
    cin >> n >> d >> x;
    rep(i,n){
        cin >> a[i];
    }   
    int q,cnt = 0;
    rep(j,n){
        q = 1;
        while(d >= q){ 
            cnt++;
            q = q + a[j];
        }
    }   
    cout << x + cnt << '\n';
    return 0;   
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        aa: [usize; n]
    }

    let mut map = HashMap::new();

    for a in aa {
        *map.entry(a).or_insert(0) += 1;
    }

    let mut ans = 0;

    for (key, val) in map {
        if key <= val {
            ans += val - key;
        } else {
            ans += val;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
 
int main() {
  ll x;
  cin >> x;
  ll a = 100;
  ll ans = 0;
  while (a < x) {
    a += a/100;
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/dp/tasks/dp_i>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<double> p(N); for(auto& in:p) cin >> in;
    vector<vector<double>> dp(N+1,vector<double>(N+1));
    dp[0][0] = 1.0;
    for(int n = 0; n < N;n++){
        for(int i = 0; i <= n;i++){
            int j = n-i;
            dp[i+1][j] += dp[i][j]*p[n];
            dp[i][j+1] += dp[i][j]*(1-p[n]);
        }
    }
    
    for(int i = 0; i <= N;i++){
        int j = N-i;
        if(i <= j) continue;
        res += dp[i][j];
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl
//宣言
ll ans = 0,N,K;
ll MOD = 1e9+7;

void solve(){
    for(ll i =K; i<=N+1; i++){
        ans += (N-i+1)*i +1;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 3636
n=int(input())
a={0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N",14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T",20:"U",21:"V",22:"W",23:"X",24:"Y",25:"Z"}
s=input()
def inverse_lookup(a, x):
    for k,v in a.items():
        if x == v:
            return k
for x,i in enumerate(s):
    ind=inverse_lookup(a,i)
    ind+=n
    if ind>=26:
        ind-=26
    print(a[ind],end="")

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

int main(){
	int N;
	cin >> N;
	vector<int> x(N);
	vector<int> y(N);
	for(int i=0;i<N;i++)cin >> x[i] >> y[i];
	
	double dist[N][N];
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)dist[i][j]=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
	
	double ans=0.0;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)ans+=dist[i][j];
	ans/=N;
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi 2*acos(0.0)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int a, b;
		cin >> a >> b;
		if(min(a,b)>=1 && max(a,b)<=9){
			cout << a*b << endl;
		}
		else
			cout <<"-1\n";

	
	}
	
	return 0;
}


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

using namespace std;

int main(void){
  int a,b,c,n;
  double tmp, limit;
  
  while(cin >> a >> b >> c){
	if((a|b|c) == 0) break;
	vector<int> v;
	v.push_back(a);	v.push_back(b);	v.push_back(c);
	sort(v.begin(),v.end());
	limit = sqrt(v[0]*v[0]+v[1]*v[1])/2;
	cin >> n;
	for(int i=0;i<n;i++){
	  cin >> tmp;
	  if(tmp > limit){
		cout << "OK" << endl;
	  }else{
		cout << "NA" << endl;
	  }
	}
  }
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        ll X, Y; cin >> X >> Y;
        cout << (abs(X - Y) <= 1  ? "Brown" : "Alice") << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;

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

//--------------------



int main() {

  int n, l;
  cin >> n >> l;
  int a[n];
  int sum = 0;
  rep(i, n) {
    a[i] = l+(i+1)-1;
    sum += a[i];
  }

  int ans = 100000;
  int ans2 = 0;
  rep(i, n) {
    int res = abs(a[i]);
    if(ans>res) {
      ans = res;
      ans2 = a[i];
    }
  }

  cout << sum-ans2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll X = 0;
    rep(i, n) X ^= a[i];

    rep(i, n) {
        ll res = X ^ a[i];
        cout << res << (i == n - 1 ? "" : " "); 
    }

    cout << endl;

}
signed main(){ Main();return 0;}

Measured memory_bytes: 4736
#include<stdio.h>
#include<string.h>
 int main()
 {
    int i,j,k,l;
    char s[102],p,m;
    
    gets(s);
        l=strlen(s);


    for(i=0;i<=l;i++)
        {
            if(i==0)
            {


            p=s[i];
            l--;
            }
            else if(i==l)

            {
                m=s[i];
                l--;
            }

        }

    printf("%c%d%c",p,l,m);
    return 0;
 }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4,vecx,vecy;
    vecx = x2-x1;
    vecy = y2-y1;
    x3 = x2 - vecy;
    y3 = y2 + vecx;
    x4 = x3 - vecx;
    y4 = y3 - vecy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl; 
    return 0;
}
 

Measured memory_bytes: 256
# https://tenka1-2019-beginner.contest.atcoder.jp/tasks/tenka1_2019_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    A, B, C = map(int, input().split())
    if A < C < B or B < C <A:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(u==s)a--;
    else if(t==u) b--;
    cout<< a<<" "<<b<<endl;
}

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

const int MAX = 105;

int main() {

	int X, N;
	cin >> X >> N;
	if (N == 0) {
		cout << X << endl;
		return 0;
	}

	vector<int> cnt(MAX);
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}

	int ans;
	int y = 200;
	for (int i = 0; i < MAX; i++) {
		if (cnt[i] == 0) {
			if (abs(X - i) < y) {
				y = abs(X - i);
				ans = i;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

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

  ll a, b;
  for (ll i = 1; i*i <= n; i++){
    if (n % i == 0)
        a = i;
  }

  b = n / a;
  cout << a + b - 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define MOD 10007
string tmp = "JOI", s;
int dp[1001][1 << 3], n;
int rec(int now,int bit){
  if(now == n) return 1;
  if(dp[now][bit]) return dp[now][bit];
  int ret = 0;
  for(int i = 0 ; i < 1 << 3 ; i++ ){
    if(bit & i && (i >> tmp.find(s[now])) & 1){
      ret += rec( now + 1, i);
    }
  }
  return dp[now][bit] = ret % MOD;
}
int main(){
  cin >> n >> s;
  cout << rec(0,1) << endl;
}

Measured memory_bytes: 1304
#include <iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    cin>>a>>op>>b;
    while(op!='?'){
        if(op=='+'){
            cout<<a+b<<endl;
        }else if(op=='-'){
            cout<<a-b<<endl;
        }else if(op=='*'){
            cout<<a*b<<endl;
        }else if(op=='/'){
            cout<<a/b<<endl;
        }
        cin>>a>>op>>b;
    }
}

Measured memory_bytes: 3076
#include <cstdio>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	while(1){
		int f=1;
		int k=n;
		int s=k%10;
		while(k>0){
			if(k%10!=s)f=0;
			k/=10;
		}
		if(f)break;
		n++;
	}
	printf("%d",n);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <unordered_map>
#include <utility>
#include <vector>
#include <queue>

namespace std
{
    template <>
    class hash<std::pair<int, int>>
    {
    public:
        size_t operator()(const std::pair<int, int> &x) const
        {
            // 10^9
            constexpr int k = 1000000000;
            // hash<int>::operator()がとても遅い
            return static_cast<int64_t>(x.first) * k + x.second;
        }
    };
} // namespace std

struct Edge
{
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using Node = std::pair<int, int>;
using Graph = std::vector<std::vector<Edge>>;

constexpr int32_t INF = 1000000000;

std::vector<int> RunDijkstra(const Graph &graph, const int start)
{
    std::priority_queue<Node, std::vector<Node>, std::greater<Node>> queue;
    std::vector<int> d(graph.size(), INF);
    d[start] = 0;
    queue.emplace(0, start);

    while (!queue.empty())
    {
        const Node node = queue.top();
        queue.pop();
        const int node_index = node.second;
        if (d[node_index] < node.first)
        {
            continue;
        }

        for (const auto &edge : graph[node_index])
        {
            if (d[edge.to] > d[node_index] + edge.cost)
            {
                d[edge.to] = d[node_index] + edge.cost;
                queue.emplace(d[edge.to], edge.to);
            }
        }
    }

    return d;
}

int main()
{
    int n, m;
    std::cin >> n >> m;

    Graph graph(n);

    // エッジが使用されているかを記録
    std::unordered_map<std::pair<int, int>, bool> edge_list;
    for (int i = 0; i < m; ++i)
    {
        int a, b, c;
        std::cin >> a >> b >> c;
        --a;
        --b;
        graph[a].emplace_back(Edge{b, c});
        graph[b].emplace_back(Edge{a, c});

        if (a < b)
        {
            edge_list[std::make_pair(a, b)] = false;
        }
        else
        {
            edge_list[std::make_pair(b, a)] = false;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        const auto distance = RunDijkstra(graph, i);
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
            {
                continue;
            }

            for (const auto &edge : graph[j])
            {
                if (distance[j] == distance[edge.to] + edge.cost)
                {
                    // このエッジは最短経路の一部
                    if (j < edge.to)
                    {
                        edge_list[std::make_pair(j, edge.to)] = true;
                    }
                    else
                    {
                        edge_list[std::make_pair(edge.to, j)] = true;
                    }
                }
            }
        }
    }

    int count = 0;
    for (const auto &e : edge_list)
    {
        if (!e.second)
        {
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a==b)cout<<"a"<<" == "<<"b"<<endl;
    else if(a>b)cout<<"a"<<" > "<<"b"<<endl;
    else if(a<b)cout<<"a"<<" < "<<"b"<<endl;


    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#define MN 101000

int n, s, x[MN], q[MN], p[MN];

int Abs(int x) {return x > 0 ? x : -x;}

int main()
{
	scanf("%d%d", &n, &s);
	for(int i = 1; i <= n; i++) scanf("%d%d", &x[i], &p[i]);
	if(x[1] > s) return 0 * printf("%d\n", x[n] - s);
	int lst = 1, h = 2, t = n, i; 
	long long sum = 0, ans = 0;
	for(i = 1; i <= n; i++)
	{
		int now; 
		if(x[lst] < s)
		{
			if(x[t] < s) break;
			now = t--;
		}
		else
		{
			if(x[h] > s) break;
			now = h++;
		}
		if(p[now] > sum + p[lst] || p[now] == sum + p[lst] && x[now] < s) q[i] = x[lst], sum += p[lst], lst = now;
		else q[i] = x[now], sum += p[now];
	}
	q[i] = x[lst]; q[i + 1] = s;
	for(int j = i; j >= 1; j--) ans += Abs(q[j + 1] - q[j]);
	printf("%lld\n", ans);
}

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

int main() {
   string S;
   cin >> S;
   queue<char> q;
   for (int i=0; i<S.size(); i++) {
       q.push(S[i]);
   }
   bool aa;
   bool bb=false;
   while(!q.empty()) {
       char a[6];
       bool b,c;
       aa=false;
       b=true;c=true;
       for (int i=0; i<5; i++) {
           a[i]=q.front();
           if (bb && i==2) {
               if (a[0]=='e' && a[1]=='r' && a[2]!='a') {
                   aa=true;bb=false;break;
               }
           }
           q.pop();
           if (i==1 && q.empty() && bb) {
               if (a[0]=='e' && a[1]=='r') {
                   cout << "YES" << endl;
                   aa=true;break;
               }
           }
           if (i!=4 && q.empty()) {
               cout << "NO" << endl;aa=true;break;
           }
       }
       if (aa) continue;
       if (a[0]!='d') b=false;
       if (a[1]!='r') b=false;
       if (a[2]!='e') b=false;
       if (a[3]!='a') b=false;
       if (a[4]!='m') b=false;
       if (a[0]!='e') c=false;
       if (a[1]!='r') c=false;
       if (a[2]!='a') c=false;
       if (a[3]!='s') c=false;
       if (a[4]!='e') c=false;
       bb=b;
       if ((!b) && (!c)) {
           cout << "NO" << endl;break;
       }
       if (c && q.front()=='r' && (!q.empty())) {
           q.pop();
       }
       if (q.empty()) cout << "YES" << endl;
   }
}

Measured memory_bytes: 3780
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int a,b;cin >>a >> b;
    cout << (a-1)*(b-1) << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
ll a[200010],b[200010],ten1[200010],ten2[200010],sum1[200010],sum2[200010];
map<pair<ll,ll>,int> mp;
int main(){
	long long i,n,p,q,ans = 0;
	string s; cin >> s;
    n = s.size(); p = 3,q = 673;
	ten1[0] = 1; ten2[0] = 1;
	for(i=1;i<=n;i++){
		ten1[i] = (ten1[i - 1]*10)%p;
        ten2[i] = (ten2[i - 1]*10)%q;
	}
	for(i=0;i<n;i++){
		long long x = s[i] - '0';
		a[i] = (ten1[n - 1 - i]*x)%p;
        b[i] = (ten2[n - 1 - i]*x)%q;
	}
	sum1[0] = 0,sum2[0] = 0;
	mp[{0,0}]++;
	for(i=0;i<n;i++){
		sum1[i + 1] = (sum1[i] + a[i])%p;
        sum2[i + 1] = (sum2[i] + b[i])%q;
		ans += mp[{sum1[i + 1],sum2[i + 1]}];
		mp[{sum1[i + 1],sum2[i + 1]}]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 13088
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define MX 2010
#define EPS 0.00000000001
#define MOD 1000000007
#define PI acos(-1)
#define INF 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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

    int r[n],g[n],b[n];
    r[n-1] = g[n-1] = b[n-1] = 0;
    if(s[n-1] == 'R') r[n-1] = 1;
    else if(s[n-1] == 'G') g[n-1] = 1;
    else if(s[n-1] == 'B') b[n-1] = 1;

    rev_loop(i,n-2,0)
    {
        r[i] = r[i+1]; g[i] = g[i+1]; b[i] = b[i+1];
        if(s[i] == 'R') ++r[i];
        else if(s[i] == 'G') ++g[i];
        else if(s[i] == 'B') ++b[i];
    }

    //loop(i,0,n) cout<<i+1<<' '<<r[i]<<' '<<g[i]<<' '<<b[i]<<'\n';

    LL ans = 0, c1, l;
    loop(i,0,n)
    {
        loop(j,i+1,n)
        {
            if(s[j] != s[i])
            {
                //cout<<i+1<<' '<<j+1<<'\n';
                if((s[i] == 'R' && s[j] == 'G') || (s[j] == 'R' && s[i] == 'G'))
                {
                    c1 = b[j];
                    l = j - i;
                    //cout<<c1<<' '<<l<<' '<<j+l<<'\n';
                    if(j+l < n && s[j+l] == 'B') --c1;
                    //cout<<c1<<'\n';
                    ans += c1;
                }
                else if((s[i] == 'R' && s[j] == 'B') || (s[j] == 'R' && s[i] == 'B'))
                {
                    c1 = g[j];
                    l = j - i;
                    //cout<<c1<<' '<<l<<' '<<j+l<<'\n';
                    if(j+l < n && s[j+l] == 'G') --c1;
                    //cout<<c1<<'\n';
                    ans += c1;
                }
                else if((s[i] == 'G' && s[j] == 'B') || (s[j] == 'G' && s[i] == 'B'))
                {
                    c1 = r[j];
                    l = j - i;
                    //cout<<c1<<' '<<l<<' '<<j+l<<'\n';
                    if(j+l < n && s[j+l] == 'R') --c1;
                    //cout<<c1<<'\n';
                    ans += c1;
                }
                //cout<<r[j]<<' '<<g[j]<<' '<<b[j]<<' '<<c1<<' '<<ans<<'\n';
            }
        }
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 3672
import sys

input = sys.stdin.readline

a, b, c, d= map(int, input().split())
ac = a*c
ad = a*d
bc = b*c
bd = b*d
max_1 = max(ac,ad)
max_2 = max(bc,bd)
ans = max(max_1,max_2)
print(ans)

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


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


int main(){
  vector<char> N(4);
  rep(i, 4) cin >> N.at(i);
  string res = "No";
  
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2)) res = "Yes";
  if(N.at(1) == N.at(2) && N.at(2) == N.at(3)) res = "Yes";
  
  cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long long int a,b,res;
    char c;
    scanf("%lld %c %lld",&a,&c,&b);
    if(c=='+') res= a+b;
    else if(c=='-') res= a-b;
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 128