akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

/*

int main(){
    string S;
    cin >> S;
    int N = (int)S.size();

    //右側からチェックしていく
    for(int i = N-1; i >= 0; i--){
        string t;

        //dreamer check
        if(i-7+1 >= 0){
            t = S.substr(i-7+1 ,7);
            if(t == "dreamer"){
                i -= 6;
                continue;
            }
        }

        //eraser check
        if(i-6+1 >= 0){
            t = S.substr(i - 6 + 1, 6);
            if (t == "eraser"){
                i -= 5;
                continue;
            }
        }

        //dream and erase check
        if(i-5+1 >= 0){
            t = S.substr(i - 5 + 1, 5);
            if (t == "dream" || t == "erase"){
                i -= 4;
                continue;
            }
        }

        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

*/

int main(){
    string S;
    cin >> S;

    int N = (int)S.size();

    reverse(S.begin(), S.end());

    const string dreamer = "remaerd";
    const string dream = "maerd";
    const string eraser = "resare";
    const string erase = "esare";

    rep(i, N){
        //dreamer check
        if(i < N){
            string t = S.substr(i, 7);
            if(t == dreamer){
                i+=6;
                continue;
            }
        }
        //eraser check
        if(i < N){
            string t = S.substr(i, 6);
            if(t == eraser){
                i+=5;
                continue;
            }
        }
        //dream and erase check
        if(i < N){
            string t = S.substr(i, 5);
            if(t == erase || t == dream){
                i+=4;
                continue;
            }
        }

        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
int main()
{
	int a1,a2,max,b1,b2,b3;
	scanf("%d%d",&a1,&a2);
	b1=a1-a2;
	b2=a1+a2;
	b3=a1*a2;
	max=b1;
	if(max<b2)
	{
		max=b2;
	}
	if(max<b3)
	{
		max=b3;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )

using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;

inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

int main(void) {


	int N;
	vector<int> A;
	INPUT(N);
	REPEAT(i,N){
		int a;
		INPUT(a);		
		A.push_back(a);
	}


	double ans = 0.0;
	REPEAT(i,N) ans += 1.0 / A[i];


	OUTPUT(1.0/ans);
		
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

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

    let mut ones = vec![vec![0; n+1]; 20];
    for i in 0..n {
        for bit in 0..20 {
            ones[bit][i+1] = ones[bit][i] + ((a[i]>>bit) & 1);
        }
    }

    let mut ans = 0;
    for head in 0..n {
        let mut tail = n+1;
        for bit in 0..20 {
            let pivot = ones[bit][head] + 1;
            tail = min(tail, ones[bit].upper_bound(&pivot) - 1);
        }
        ans += tail - head;
    }
    println!("{}", ans);
}


Measured memory_bytes: 19824
#include<iostream>
#include<vector>
#include<utility>
#include<map>
using namespace std;
using ll = long long int;
int n;
vector<ll> x, y;
map<pair<ll, ll>, int> memo;

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int xi, yi;
		cin >> xi >> yi;
		x.push_back(xi);
		y.push_back(yi);
	}

	int num = 0;
	for (int i = 0; i < n; i++) {
		ll xi = x[i];
		ll yi = y[i];
		for (int j = i + 1; j < n; j++) {
			ll xj = x[j];
			ll yj = y[j];
			pair<ll, ll> pqp(xi - xj, yi - yj);
			pair<ll, ll> pqm(xj - xi, yj - yi);
			memo[pqp]++;
			memo[pqm]++;
			if (memo[pqp] > num) {
				num = memo[pqp];
			}
		}
	}
	cout << n - num << endl;
	return 0;
}


Measured memory_bytes: 384
x,y=map(int,input().split())
if(y%2):
  print("No")
  exit(0)
re=(y//2)-x
re1=x-re
if(re+re1==x and re*4+re1*2==y and re>=0 and re1>=0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61916
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <cstdio>
using namespace std;
int main(void){
	int a,b,i,f=1;
	string s;
	cin>>a>>b>>s;
	for(i=0;i<a;i++){
		if(s[i]<'0'||s[i]>'9') f=0;
	}
	if(s[a]!='-') f=0;
	for(i=a+1;i<a+b+1;i++){
		if(s[i]<'0'||s[i]>'9') f=0;
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int h, w;cin>>h>>w;
  int a, b;cin>>a>>b;
  cout<<h*w-a*w-b*(h-a)<<endl;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    string s;
    cin >> s;

    int cc=0;

    FOR(i,1,(int)s.sz()){
        if(s[i-1]==s[i]){
            cc++;
            if(s[i]=='1' && s[i-1]=='1')
                s[i]='0';
            else
                s[i]='1';
        }
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 512
N,M=(int(x) for x in input().split())

H=list(map(int, input().split()))

l=[]
k=[]

j=list(range(1,N+1))

for i in range(M):
    A=list(map(int, input().split()))
    l.extend(A)
    if H[A[0]-1]>H[A[1]-1]:
        c=int(A[1])
        k.append(c)
    elif H[A[0]-1]<H[A[1]-1]:
        c=int(A[0])
        k.append(c)
    else:
        c=int(A[0])
        d=int(A[1])
        k.append(c)
        k.append(d)


        
    
a=N-len(set(l))

b=N-len(set(k))-a

print(a+b)

Measured memory_bytes: 32728
// ABC153D.cpp
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric> //accumulateに必要
#include <iomanip> //setprecision(桁数指定)に必要
using namespace std;

int main(){
	long long H,ruijo,sum = 0;
	cin>>H;
	int i = 0;
	ruijo = 1;
	while(H >= ruijo){
		sum += ruijo;
		i += 1;
		ruijo *= 2;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	int a, b;
	cin >> a >> b;
	int x = (a + b + 1) / 2;

	printf("%d\n", x);

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    x1, y1, x2, y2 = list(map(int, input().split()))
    a = [x2 - x1, y2 - y1]
    lal2 = a[0]**2 + a[1]**2
    q = int(input())
    for i in range(q):
        x, y = map(int, input().split())
        b = [x - x1, y - y1]
        t = (a[0]*b[0] + a[1]*b[1]) / lal2
        print(x1 + a[0] * t, y1 + a[1] * t)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5720
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    S = [input().split() for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if S[h][w] == "snuke":
                ans = chr(ord("A") + w) + str(h + 1)
                print(ans)
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <cstdio>

typedef long long int lli;

int main()
{
	lli mod[50], a[50];
	lli sum = 0, modSum;
	lli ans = 6 * 1e17;
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
		mod[i] = a[i] % (N + 1);
		sum += a[i];
	}
	for (int i = 0; i < N + 1; i++) {
		modSum = 0;
		bool notCount = false;
		for (int j = 0; j < N; j++) {
			modSum += (mod[j] + i) % (N + 1);
			if ((mod[j] + i) % (N + 1) == N)
				notCount = true;
		}
		if (!notCount && ans > sum - modSum && sum - modSum >= 0)
			ans = sum - modSum;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
A, B, C, D = map(int, input().split())

MOD = 998244353

# A = 1, B = 1, C = 2, D = 2
# |0|0|0|
# |0|0|0|
# |0|0|0|
dp = [[0 for _ in range(D + 1)] for _ in range(C + 1)]  # (C + 1, D + 1)

# |0|0|0|
# |0|1|0|
# |0|0|0|
dp[A][B] = 1

# |0|1|0|
# |0|1|0|
# |0|0|0|
for i in range(A + 1, C + 1):
    dp[i][B] = (B * dp[i - 1][B]) % MOD

# |0|1|0|
# |0|1|1|
# |0|0|0|
for i in range(B + 1, D + 1):
    dp[A][i] = (A * dp[A][i - 1]) % MOD

# |0|1|2|    |0|1|4|    |0|1|3|
# |0|1|1| -> |0|1|1| -> |0|1|1|
# |0|0|0|    |0|0|0|    |0|0|0|
for i in range(A + 1, C + 1):
    for j in range(B + 1, D + 1):
        dp[i][j] = (i * dp[i][j - 1]) % MOD
        dp[i][j] = (dp[i][j] + (j * dp[i - 1][j]) % MOD) % MOD
        dp[i][j] = (dp[i][j] - ((i - 1) * (j - 1) * dp[i - 1][j - 1]) % MOD) % MOD

print(dp[C][D])


Measured memory_bytes: 153292
#include<stdio.h>
#include<cmath>
#include<iostream>
 
#define PI 3.14159265358979323846
using namespace std;
 
int length, angle, currentAngle;
double px, py;
  
void walk(){
    double dx = length * cos(currentAngle * PI / 180.0);
    double dy = length * sin(currentAngle * PI / 180.0);
    currentAngle -= angle;
    px += dx;
    py += dy;
}
 
main(){
    px = 0;
    py = 0;
    currentAngle = 90;
    while(1){
    scanf("%d,%d", &length, &angle);
    if ( length == 0 && angle == 0 ) break;
    walk();
    }
    int x = (int)px;
    int y = (int)py;
    printf("%d\n", x);
    printf("%d\n", y);
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

void bfs( bool visit[], int dist[], int s );

vector< int > graph[SIZE];

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

    int n;
    int w_dist[SIZE];
    int b_dist[SIZE];
    bool b_visit[SIZE];
    bool w_visit[SIZE];
    cin >> n;

    for( int i = 1; i <= n; ++i ) {
        w_dist[i] = b_dist[i] = 0;
        b_visit[i] = w_visit[i] = false;

    }

    for( int i = 0; i < n - 1; ++i ) {
        int a, b;
        cin >> a >> b;
        graph[a].pb( b );
        graph[b].pb( a );

    }

    bfs( w_visit, w_dist, 1 );
    bfs( b_visit, b_dist, n );
    int w_res = 0, b_res = 0;
    for( int i = 1; i <= n; ++i ) {
        if( w_dist[i] <= b_dist[i] ) ++w_res;
        else if( w_dist[i] > b_dist[i] ) ++b_res;

    }

    if( w_res > b_res ) cout << "Fennec";
    else cout << "Snuke";
    cout << endl;

    return 0;
}

void bfs( bool visit[], int dist[], int s ) {
    queue< P > q;
    q.push( MP( s, 0 ) );

    while( !q.empty() ) {
        P p = q.front();
        visit[p.F] = true;
        dist[p.F] = p.S;
        q.pop();

        for( int i = 0; i < graph[p.F].size(); ++i ) {
            if( !visit[graph[p.F][i]] ) {
                q.push( MP( graph[p.F][i], p.S + 1 ) );

            }
        }
    }

    return;
}



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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

const int Z=3e5+5;
int n;
int a[Z];
int ans;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    rep(i,1,n+1) cin >> a[i];
    for(int i=0; i<62; i++){
        int p=0,q=0;
        for(ll j=1; j<=n; j++){
            if(a[j]&(1LL<<i)) p++;
            else q++;
        }
        //trace(p,q);
        int z=(p*q)%mod;
        add(ans,(z*power(2,i))%mod);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
 
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
 
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
 
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
ll md = 1e9+7;
ll n;

int main(){
 
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
  	cin>>n;
  	ll ans = 1;
  	for(int i=2;i<=n;i++) ans = (ans*i)%md;
  	cout<<ans<<newl;
}

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

int main() {
  int k, x;
  cin >> k >> x;
  
  if (k*500 >= x) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

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

const int maxn = 110;
const int maxv = 1010;
int n, w;
int W[maxn], V[maxn];
ll f[2][maxv * maxn];

void work() {
  n = read(), w = read();
  rep(i, 1, n) W[i] = read(), V[i] = read();
  int o = 1;
  rep(v, 1, 100000) f[0][v] = 1e18;
  rep(i, 1, n) {
    rep(v, 1, 100000) {
      f[o][v] = f[o ^ 1][v];
      if (v >= V[i]) f[o][v] = min(f[o][v], f[o ^ 1][v - V[i]] + W[i]);
    }
    o ^= 1;
  }
  o ^= 1;
  int mx = 0;
  rep(v, 1, 100000) if (f[o][v] <= w) mx = v;
  printf("%d\n", mx);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void) {
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i, t) {
    cin >> a[i];
  }
  int ans = 0;
  int yes = -1;
  rep(i, k) {
    vector<int>::iterator maxIt = max_element(a.begin(), a.end());
    size_t maxIndex = distance(a.begin(), maxIt);
    if (maxIndex == yes) {
      int tmp = a[maxIndex];
      a[maxIndex] = 0;
      vector<int>::iterator secondIt = max_element(a.begin(), a.end());
      size_t secondIndex = distance(a.begin(), secondIt);
      if (a[secondIndex] == 0) {
        ans = tmp;
        break;
      } else {
        a[secondIndex]--;
        yes = secondIndex;
        a[maxIndex] = tmp;
      }
    } else {
      a[maxIndex]--;
      yes = maxIndex;
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);

    int ans=0;
    while(true){
        rep(i,n){
            if(a.at(i) % 2 == 1){
                cout << ans << endl;
                return 0;
            }
        }
        rep(i,n){
            a.at(i) /= 2;
        }
        ans ++;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll a, b, n;
    cin >> a >> b >> n;

    ll x = n;
    if (n >= b-1)
        x = b-1; 

    ll ans = a*x/b-a*(x/b);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
import math


class SegmentTree:
    __slots__ = ["elem_size", "tree_size", "tree"]

    def __init__(self, a: list, default: int):
        real_size = len(a)
        self.elem_size = 1 << math.ceil(math.log2(real_size))
        self.tree_size = 2 * self.elem_size
        self.tree = [default]*self.elem_size + a + [default]*(self.elem_size - real_size)
        self.init_tree()

    def init_tree(self):
        tree = self.tree
        for i in range(self.elem_size-1, 0, -1):
            left, right = tree[i << 1], tree[(i << 1)+1]
            # ===== ??????????????´???????????? =====
            tree[i] = left if left < right else right

    def get_range_index(self, x: int, y: int, k: int = 1, l_end: int = 0, r_end: int = None):
        '''[x, y), tree[k], [l_end, r_end)'''
        if r_end is None:
            r_end = self.elem_size

        if l_end == x and y == r_end:
            return [k]

        mid = (l_end + r_end) // 2
        left_y = y if y < mid else mid
        right_x = x if x > mid else mid

        left = self.get_range_index(x, left_y, k << 1, l_end, mid) if x < left_y else []
        right = self.get_range_index(right_x, y, (k << 1)+1, mid, r_end) if right_x < y else []
        return left + right

    def get_value(self, x: int, y: int):
        tree = self.tree
        index_list = self.get_range_index(x, y)

        # ===== ??????????????´???????????? =====
        return min(tree[n] for n in index_list)

    def update_tree(self, k: int):
        tree = self.tree

        while k > 1:
            k >>= 1
            left, right = tree[k << 1], tree[(k << 1)+1]
            # ===== ??????????????´???????????? =====
            tree[k] = left if left < right else right

    def set_value(self, i: int, value: int, op: str):
        k = self.elem_size + i
        if op == "=":
            self.tree[k] = value
        elif op == "+":
            self.tree[k] += value
        self.update_tree(k)


n, q = map(int, input().split())
rmq = SegmentTree([2**31-1]*n, 2**31-1)
ans = []
for _ in [0]*q:
    c, x, y = map(int, input().split())
    if c == 0:
        rmq.set_value(x, y, "=")
    else:
        ans.append(rmq.get_value(x, y+1))
print("\n".join([str(n) for n in ans]))

Measured memory_bytes: 15132
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> DP;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
string a,b,c;
bool x,y,z;
ll N;
ll ans = 0LL;

int main()
{
  cin>>N;
  cin>>a>>b>>c;
  rep(i,N){
    x = (a[i] == b[i]);
    y = (a[i] == c[i]);
    z = (c[i] == b[i]);
    ans+=2;
    if(x && y && z) ans -=2;
    else if(x || y || z) ans -=1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	ll n,k;
	cin>>n>>k;
	if(k==1)
	{
		cout<<"0";
		exit(0);
	}
	cout<<(n-k);
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        Set<Integer> set = new HashSet<Integer>();

        for (int i = a; i <= b; i++) {
            if (i < a + k || i > b - k) {
                System.out.println(i);
            }
        }
        //
        //        for (Integer num : set) {
        //            System.out.println(num);
        //        }
    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int main()
{
    int A, B, C, K;
    scanf("%d %d %d %d", &A, &B, &C, &K);
    if ((A >= B && A > C) || (A > B && A >= C) || (A >= B && A >= C))
    {
        for (int aux = 0; aux < K; aux++)
        {
            A *= 2;
        }
        printf("%d", (A + B + C));
    }
    else if ((B >= A && B > C) || (B > A && B >= C) || (B >= A && B >= C))
    {
        for (int aux = 0; aux < K; aux++)
        {
            B *= 2;
        }
        printf("%d", (A + B + C));
    }
    else if ((C >= A && C > B) || (C > A && C >= B) || (C >= A && C >= B))
    {
        for (int aux = 0; aux < K; aux++)
        {
            C *= 2;
        }
        printf("%d", (A + B + C));
    }

    return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();

        double[] p = new double[n];
        for (int i = 0; i < n; i++) {
            p[i] = scanner.nextDouble();
        }

        double[] dp = new double[n + 1];
        dp[0] = 1;

        for (int coin = 1; coin <= n; coin++) {
            dp[coin] = dp[coin - 1] * p[coin - 1];
            for (int j = coin - 1; j >= 0; j--) {
                dp[j] = (j - 1 < 0 ? 0 : dp[j - 1] * p[coin - 1]) + dp[j] * (1 - p[coin - 1]);
            }
        }

        //writer.println(Arrays.toString(dp));

        double ans = 0;
        for (int i = n / 2 + 1; i <= n; i++) {
            ans += dp[i];
        }

        writer.println(ans);
    }
}


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

#define LARGE 1000000007

int main() {
    ll n;
    cin >> n;
    ll k[61];
    rep (i, 61) k[i] = 0;
    rep (i, n) {
        ll a;
        cin >> a;
        rep (j, 61) if ((a>>j)&1) k[j]++;
    }

    ll sum = 0;
    rep (i, 61) {
        ll dat = k[i] * (n-k[i]);
        rep (j, i) dat = dat * 2 % LARGE;
        sum += dat;
        sum %= LARGE;
    }

    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, ll> P; 
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

P v[3333];
ll dp[3333][3333];

bool comp(P a, P b){
	return ((a.first == b.first)?(a.second > b.second):(a.first < b.first));
}

int main(void){
	int n,t,i,j;
	ll ans = 0ll, tmp = 0ll;
	cin >> n >> t;
	for(i=0; i<n; ++i){
		cin >> v[i].first >> v[i].second;
	}
	sort(v,v+n,comp);
	for(i=0; i<n; ++i){
		for(j=0; j<t; ++j){
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if(j+v[i].first<t){
				dp[i+1][j+v[i].first] = max(dp[i+1][j+v[i].first],dp[i][j]+v[i].second);
			}
		}
	}
	for(i=n; i>=0; --i){
		tmp = max(tmp,v[i].second);
		for(j=0; j<t; ++j){
			ans = max(ans,dp[i][j]+tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	string s, t;
	cin >> s;
	cin >> t;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != t[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int a, b, c;

int sameThreeDigits(int n)
{
    return n * 100 + n * 10 + n;
}

int getDebutN()
{
    int debutN;
    
    if (a < b) {
        debutN = sameThreeDigits(a + 1);
    } else if (a == b) {
        if (a < c) {
            debutN = sameThreeDigits(a + 1);
        } else {
            debutN = sameThreeDigits(a);
        }
        
    } else {
        debutN = sameThreeDigits(a);
    }

    return debutN;
}

int main()
{
    int n;
    cin >> n;
    
    c = n % 10;
    n /= 10;

    b = n % 10;
    n /= 10;

    a = n;

    cout << getDebutN() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, t;
    cin >> n >> t;

    vector<pair<int64_t, int64_t>> p(n);
    for (auto&& pp : p) {
        cin >> pp.first >> pp.second;
    }

    sort(p.rbegin(), p.rend());

    vector<int64_t> dp(t);
    for (auto pp : p) {
        for (auto i : irange(1L, t) | reversed) {
            if (i - pp.first >= 0) {
                dp[i] = max(dp[i - pp.first] + pp.second, dp[i]);
            }
        }
        dp[0] = max(pp.second, dp[0]);
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int N;cin>>N;vi P(N),Q(N);
  rep(i,N)cin>>P[i];
  rep(i,N)cin>>Q[i];
  vi R(N);
  R=P;
  sort(all(R));
  int a=0,b=0;
  int cnt=1;
  do {
    // 1行で今の並び方を出力
    bool op=true,oq =true;
    for(int x=0;x<N;x++){
      if(R[x]!=P[x])op=false;
    }
    for(int x=0;x<N;x++){
      if(R[x]!=Q[x])oq=false;
    }
    if(op)a=cnt;
    if(oq)b=cnt;
    cnt++;
  } while (next_permutation(R.begin(), R.end()));
  cout<<abs(a-b)<<endl;
}


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

int main(){
   int n,k;
   cin>>n>>k;
   vector<int> v(n);
   vector<bool> dp(k+1);
   for(int i=0;i<n;i++){
       cin>>v[i];
   }
   for(int stone=0;stone<=k;stone++){
       for(int a:v){
           if(stone>=a && !dp[stone-a]){
               dp[stone]=true;
           }
       }
   }
   if(dp[k]) cout<<"First"<<endl;
   else cout<<"Second"<<endl;
}

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




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

    long long N;
    cin>>N;
    long long res = 0;
    for(long long A=1;A<=N;A++) {
        for(long long B=1;B*A<N;B++) {
            res++;
        }
    }
    cout<<res;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
template <class T>
istream& operator>>(istream& input, vector<T>& v) {
    for (T& i : v) input >> i;
    return input;
}
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    cin >> A >> B;
    ll f1 = min(A[0], B[0]);
    ll f2 = min(A[1], B[0] - f1);
    ll ans = f1 + f2;
    for (int i = 1; i < N; i++) {
        f1 = min(A[i] - f2, B[i]);
        f2 = min(A[i+1], B[i] - f1);
        ans += f1 + f2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
S = input()
N = int(input())
l = len(S)

sub = {}
for i in range(1,6):
    for j in range(0,l+1-i):
        temp = S[j:j+i]
        if temp not in sub:
            sub [temp]  = True

sub = list(sub.keys())
sub.sort()
print(sub[N-1])





Measured memory_bytes: 41072
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string x;
	cin >> x;
	
	int n = (int)x.size();
	vector<char> cargo;
	
	for(int i = 0; i < n; ++i) {
		if( cargo.empty() ) cargo.push_back(x[i]);
		
		else {
			if( x[i] == 'S' ) cargo.push_back(x[i]);
			if( x[i] == 'T' ) {
				if( cargo.back() == 'S' ) cargo.pop_back();
				else cargo.push_back(x[i]);
			}
		}
	}
	
	cout << (int)cargo.size() << endl;
	
	return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>
int main(void)
{
	int n,i;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if(x1==x2||x3==x4)
		{
			if(x1==x2&&x3==x4)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		else
		{
			if((y1-y2)/(x1-x2) == (y3-y4)/(x3-x4))
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 620
#include <stdio.h>
#define N 300001
#define ll long long int
char zfc[N];
int main(void)
{
	ll n;
	scanf("%lld",&n);
	scanf("%s",zfc);
	ll k;
	ll zh[N]={0,};
	ll fa[N]={0,};
	ll w=0,e=0;
	for(k=0;k<n;k++)
	{
		zh[k]=w;
		if(zfc[k]=='W')
		{
			w++;
		}
	}
	while(k>=0)
	{
		--k;
		fa[k]=e;
		if(zfc[k]=='E')
		{
			e++;
		}
	}
	ll min=N;
	for(k=0;k<n;k++)
	{
		if(min>zh[k]+fa[k])
		{
			min=zh[k]+fa[k];
		}
	}
	printf("%lld",min);
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int mod = 1e9 + 7;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    rep(i,n) cin >> a[i];
    ll sum = 0;
    for(int i = n-1; i >= 1; i--){
        sum += a[i];
        sum %= mod;
        ans += (a[i-1] * sum) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9 + 7;
constexpr int INF = 2e9;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      vector<int> res;
      res.emplace_back(i);
      res.emplace_back(j);
      for (int k = 0; k < n; k++) {
        if (s[k] == 'o') res.emplace_back(res[k] ^ res[k + 1]);
        else res.emplace_back(res[k] ^ res[k + 1] ^ 1);
      }
      if (res[n] == i && res[n + 1] == j) {
        for (int l = 1; l <= n; l++) cout << (res[l] ? 'W' : 'S');
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
} 

Measured memory_bytes: 4244
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		long test = sc.nextLong();
		long result = Long.MAX_VALUE;
		for(int i = 1; i <= Math.sqrt(test); i++) {
			if(test % i == 0) {
				long digit = Math.max(i, test/i);
				result = Math.min(result, digit);
			}
		}
		String str = result+"";
		System.out.println(str.length());
	}
	
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Endl endl
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(a, b);
    Int(c);
    cout << min(a+b, min(b+c, a+c)) << endl;

    return 0;
}



Measured memory_bytes: 256
import math
X = int(input())


def get_yakusu(P):
    yakusu = []
    for i in range(1, int(math.sqrt(P))+1):
        if P % i == 0:
            yakusu.append(i)
            if i != int(P / i):
                yakusu.append(int(P / i))
    return yakusu


X_yakusu = get_yakusu(X)

flag = False
K = max(int(10 ** 1.4), int((10 ** 9 / 5) ** 0.25)) + 2
for A in range(0, K):
    if flag:
        break
    for x in X_yakusu:
        B = A - x
        if A ** 5 - B ** 5 == X:
            print(A, B)
            flag = True
            break


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

int main() {
    int n;
    cin >> n;
    vector<int> R(n);
    for (int i = 0; i < n; i++) {
        cin >> R.at(i);
    }
    
    int maxv = -2000000000; // 十分小さい値を初期値に設定
    int minv = R.at(0);

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R.at(i) - minv); // 最大値を更新
        minv = min(minv, R.at(i)); // ここまでの最小値を保持しておく
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 1e5 + 5;
int flag[maxn];
int a[maxn];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 0;i < n; ++i)
	{
		scanf("%d",&a[i]);
	}
	bool allpos = 1,allneg = 1;
	for(int i = 0;i < n; ++i)
	{
		if(a[i] >= 0)
		{
			flag[i] = 1;
			allneg = 0;
		}
		else
		{
			flag[i] = -1;
			allpos = 0;
		}
	}
	if(allpos || allneg)
	{
		int maxpos = 0;
		for(int i = 0;i < n; ++i)
		{
			if(abs(a[i]) < abs(a[maxpos]))
			{
				maxpos = i;
			}
		}
		flag[maxpos] *= -1;
	}
	int sum = 0;
	for(int i = 0;i < n; ++i)
	{
		sum += a[i] * flag[i];
	}
	printf("%d\n",sum);
	int p = -1,q = -1;
	for(int i = 0;i < n; ++i)
	{
		if(flag[i] == 1)
		{
			if(p == -1)
			{
				p = i;
			}
		}
		else
		{
			if(q == -1)
			{
				q = i;
			}
		}
	}
	for(int i = 0;i < n; ++i)
	{
		if(i == p || i == q)
		{
			continue;
		}
		if(flag[i] == 1)
		{
			printf("%d %d\n",a[q],a[i]);
			a[q] -= a[i];
		}
		else
		{
			printf("%d %d\n",a[p],a[i]);
			a[p] -= a[i];
		}
	}
	printf("%d %d\n",a[p],a[q]);
	return 0;
}

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

int main(){
    int n,b,f,r,v;
    cin >> n;
    
    int A[5][4][11];
    for (int i=1; i<=4; i++)
        for (int j=1; j<=3; j++)
            for (int k=1; k<=10; k++)
                A[i][j][k]=0;
                
    for (int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        A[b][f][r]+=v;
    }
    
    for (int i=1; i<=4; i++){
        for (int j=1; j<=3; j++){
            for (int k=1; k<=10; k++){
                cout << " " << A[i][j][k];
            }cout << endl;
        }
    if (i!=4) cout << "####################" << endl;
    }
    

    return 0;
}
    
        



Measured memory_bytes: 3104
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int ans = 0;
        for(int i = 0; i < 3;i++){
            if(s[i] == t[i])ans++;
        }
        
        System.out.println(ans);
        
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
            return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 21076
#include <iterator>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
int main(int argc, char **argv) {
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    double x;
    cin >> x;
    string cur;
    cin >> cur;

    if (cur == "BTC") {
      x *= 380000.0;
    }
    ans += x;
  }

  cout << fixed << setprecision(5) << ans << endl;
  return 0;
}

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

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
int main() {
	int K;
	cin >> K;
	int sum = 0;
	for (int i = 1; i < K + 1; i++) {
		for (int j = 1; j < K + 1; j++) {
			int temp = gcd(i, j);
			for (int r = 1; r < K + 1; r++) {
				sum = sum + gcd(temp, r);
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string n = sc.Next();

        var mod = 0;
        foreach (var c in n)
        {
            mod += (c - '0');
            mod %= 9;
        }

        Console.WriteLine(mod == 0 ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 26440