akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int n,min=1000000,max=-1000000,i=0;
    int x[9999];
    long long sum=0;
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        if(x[i]<min){
            min=x[i];
        }
        if(x[i]>max){
            max=x[i];
        }
        sum=sum+x[i];
    }
    printf("%d %d %lld\n",min,max,sum);
  return 0;
}



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

#pragma region Macro
#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(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	string s,t;
	cin >> s >> t;

	int ans = t.size() + 1;

	rep(i,s.size() - t.size() + 1){
		int count = 0;
		rep(j, t.size()){
			if(s[i+j] != t[j]) count++;
		}
		chmin(ans, count);
	}
	
	cout << ans << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  int x; cin>>x;
  cout<<(!x)<<'\n';
  
  return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

signed main() {
  uint64_t a, b;
  cin >> a >> b;
  cout << a*b << " " << 2*(a+b) << endl;
  return 0;
}


Measured memory_bytes: 3008
s = str(input())

left = int(s[:2])
right = int(s[-2:])
# print(left, right)

if left > 12 or left == 0:
  if right >= 1 and right <= 12:
    print('YYMM')
  else: # right == 0 or right > 12:
    print('NA')
else: # left 1~12
  if right >= 1 and right <= 12:
    print('AMBIGUOUS')
  else: # right == 0 or right > 12
    print('MMYY')
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct SeqSearchTable {
	string v;
	vector<UL> t;
	SeqSearchTable(string seq) { init(move(seq)); }
	void init(string seq) {
		v = move(seq);
		t.resize(v.size());
		t[0] = (UL)-1;
		UL p = 1, q = -1;
		while (p < v.size()) {
			if (q == (UL)-1) { t[p] = 0; p++; q = 0; }
			else if (v[q] == v[p - 1]) { t[p] = q + 1; p++; q++; }
			else { q = t[q]; }
		}
	}
};

vector<UL> SeqSearch(const string &seq, const SeqSearchTable &tg) {
	vector<UL> f(seq.size());
	UL p = 0, q = 0;
	while (p < seq.size()) {
		if (seq[p] == tg.v[q]) {
			f[p] = q + 1;
			p++; q++;
			if (q == tg.v.size()) {
				q = tg.t[q - 1] + 1;
			}
		}
		else {
			q = tg.t[q];
			if (q == (UL)-1) { p++; q = 0; }
		}
	}
	return move(f);
}

UL gcd(UL a, UL b) { return b ? gcd(b, a % b) : a; }

struct Problem {

	void Solve() {
		string s, t; cin >> s >> t;
		string S; while (S.size() < t.size() + s.size()) S += s;
		auto F = SeqSearch(S, SeqSearchTable(t));
		//cout << "S = " << S << endl;
		//cout << "T = " << t << endl;
		//rep(i, F.size()) cout << F[i] << " "; cout << endl;
		UL G = gcd(s.size(), t.size());
		UL ans = 0;
		rep(m, G) {
			UL n = 0;
			rep(i, s.size() / G * 2) {
				UL p = (t.size() * i + m) % s.size();
				if (F[p + t.size() - 1] >= t.size()) n++;
				else n = 0;
				ans = max(ans, n);
				//cout << p << " ";
			} //cout << endl;
		}
		if (ans >= s.size() / G) { cout << -1 << endl; return; }
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'

const int maxn = 3e3 + 20;
string s, t;

int dp[maxn][maxn], dad[maxn][maxn][2], mx1, mx2, mx3;

void chap(int i, int j){
	if (i == 0 || j == 0)
		return;
	chap(dad[i][j][0], dad[i][j][1]);
	if(t[i] == s[j])
		cout << t[i];
	//if (t[i] == s[j])
		//cout << i << " " << j  << " : " << dp[i][j] << " " << t[i] << " / " << s[j] << endl;
	return;
}

int main(){
	IoFast;
	cin >> s >> t;
	s = '1' + s;
	t = '0' + t;
	for(int i = 1; i < sz(t); i ++){
		for (int j = 1; j < sz(s); j ++){
			dp[i][j] = dp[i - 1][j];
			dad[i][j][0] = i - 1;
			dad[i][j][1] = j;
			if (dp[i][j] < dp[i][j - 1]){
				dp[i][j] = dp[i][j - 1];
				dad[i][j][0] = i;
				dad[i][j][1] = j - 1;
			}
			if (t[i] == s[j] && dp[i - 1][j - 1] + 1 >= dp[i][j]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
				dad[i][j][0] = i - 1;
				dad[i][j][1] = j - 1;
			}
			if (mx1 < dp[i][j]){
				mx1 = dp[i][j];
				mx2 = i;
				mx3 = j;
			}
		}
	}
	if (mx1 == 0){
		cout << " " << endl;
		return 0;
	}
	chap(mx2, mx3);
	cout << endl;
	//cout << mx1 << "   : " << mx2 << "  : " << mx3 << endl;
}



Measured memory_bytes: 107008
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    map<ll,ll> mp;
    REP(i,N){
        cin>>A[i];
        mp[A[i]]++;

    }
    sort(ALL(A),greater<ll>());
    ll ans=0;
    vector<ll> num(33,0);
    REP(i,33) num[i]=pow(2,i);
    REP(i,N){
        if(mp[A[i]]<=0) continue;
        REPD2(j,32,-1){
            if(num[j]<=A[i]) break;
            if(mp[num[j]-A[i]]>0){
                if(!(mp[num[j]-A[i]]==1&&num[j]-A[i]==A[i])){
                    mp[num[j]-A[i]]--;
                    mp[A[i]]--;
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 68676
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

A, B = 1, N
for lr in LR:
    L, R = lr
    if R < A or B < L:
        print(0)
        exit()

    if A <= L <= R <= B:
        A, B = L, R
    elif L <= A <= R <= B:
        B = R
    elif A <= L <= B <= R:
        A = L
print(B - A + 1)


Measured memory_bytes: 60376
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NM = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var (N, M) = (NM[0], NM[1]);
            var answer = 0L;
            if (M / 2 <= N)
            {
                answer = M / 2;
            }
            else
            {
                answer = N;
                M -= N * 2;
                answer += M / 4;
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28064
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

//0-indexed BIT
class BinaryIndexedTree
{
    using T = int;
private:
    void _add(int i, T x) {
        if (i > N) return;
        data[i] += x;
        _add(i + (i & -i), x);
    }

public:
    vector<T> data;
    int N;

    BinaryIndexedTree(int N): data(vector<T>(N + 1, 0)), N(N) {}
    BinaryIndexedTree(){}

    //sum of [0,i) (0<=i<=N)
    T sum(int i) {
        if (!i) return 0;
        return data[i] + sum(i - (i & -i));
    }

    //0<=i<N
    void add(int i, T x) { _add(i + 1, x); };
    void update(int i, T x){
        T now = sum(i + 1) - sum(i);
        add(i, x - now);
    }

};

signed main(){

    int N, Q; cin >> N >> Q;
    vec a(N); cin >> a;
    BinaryIndexedTree ST(N);
    REP(i, N) ST.add(i, a[i]);

    REP(_, Q){
        int t, a, b; cin >> t >> a >> b;
        if(t == 0) ST.add(a, b);
        else Out(ST.sum(b) - ST.sum(a));
    }

    return 0;
}


Measured memory_bytes: 12148
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> B = A;
  for (int i = 1; i < N; i++){
    B[i] = max(B[i], B[i - 1]);
  }
  long long sum = 0;
  for (int i = 0; i < N; i++){
    sum += B[i] - A[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 4816
N = int(input())
S = input()
count = 0
r=0
g=0
b=0
#i,j,k-->i,j,2j-i
for i in range(N):
    if S[i]=="R":
        r+=1
    elif S[i]=="G":
        g+=1
    else:
        b+=1
    for j in range(i+1,N):
        if 2*j-i <= N-1:
            if S[i] != S[j] and S[j]!=S[2*j-i] and S[2*j-i]!=S[i]:
                count -= 1
count += r*g*b
print(count)



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

int main(void) {
	char judge[10];
	int a[3]={0},s,i,j,o,k,l;
	scanf("%d",&j);
		for(i = 1;i <= j ;i++){
			s = 0;
			o = 0;
			for (l = 0; l <= 2;l++){
				a[l] = 0;
			}
			while(o <= 2){
				scanf("%s" , judge);
				if (strcmp( judge , "HOMERUN") == 0 ){
					for(k = 0; k <= 2;k++){
						if(a[k] == 1){
							s = s + 1;
							a[k] = 0;
						}
					}
				s = s + 1;
				}
				else if(strcmp( judge , "HIT") == 0){
					if (a[2] == 1){
						s = s + 1;
						a[2] = 0; 
					}
					a[2] = a[1];
					a[1] = a[0];
					a[0] = 1;
				}
				else{
					o = o + 1;
				}
			}
			printf("%d\n", s);
		}
return 0;
}

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

#define ran 202202

int n;

int main() {
	scanf("%d", &n);
	
	int ans = 0, mi = n+1;
	for(int i=0;i<n;i++) {
		int x;
		scanf("%d", &x);
		
		if(x<mi) ans++;
		mi = min(mi, x);
	}
	printf("%d\n", ans);
	
	return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

namespace io {
	#define isdigit(c)  (c >= '0' && c <= '9')
	#define getchar()   (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufsz, stdin), p1 == p2) ? EOF : *p1++)
	#define flush()     (fwrite(puf, 1, pp - puf, stdout), pp = puf)
	#define putchar(c)  (*pp++ = c, pp - puf == bufsz && flush())
	
	const int bufsz = 1 << 20;
	static char buf[bufsz], puf[bufsz], *p1, *p2, *pp = puf;
	struct flusher { ~flusher() { flush(); } } flusher;
	
	template<class type>
	void inline read(type &a) {
		int f = 1, c = getchar();
		for (; !isdigit(c); c == 45 && (f = -1), c = getchar());
		for (a = 0; isdigit(c); a *= 10, a += c & 15, c = getchar());
		a *= f;
	}
	
	template<class type>
	void inline write(type a, char c = ln) {
		static char d[20];
		int s = d[0] = 0;
		for (a < 0 && (putchar(45), a = -a); a; d[s++] = a % 10, a /= 10);
		for (s || (s = 1); s; putchar(d[--s] + 48));
		putchar(c);
	}
}
using namespace io;

const int nsz = 2e5;
int n, a[nsz + 5], rt, lst, ans;
int ql, qr, q[2 * nsz + 5];

struct treap {
	int sz, ls[nsz + 5], rs[nsz + 5], pri[nsz + 5];
	int key[nsz + 5], mn[nsz + 5], mx[nsz + 5];
	
	int inline node(int w) {
		int u = ++sz;
		key[u] = mn[u] = mx[u] = w, pri[u] = rand();
		return u;
	}
	
	void inline up(int u) {
		mn[u] = ls[u] ? mn[ls[u]] : key[u];
		mx[u] = rs[u] ? mx[rs[u]] : key[u];
	}
	
	int merge(int v1, int v2) {
		if (!v1 || !v2)  return v1 | v2;
		return pri[v1] < pri[v2] ? (rs[v1] = merge(rs[v1], v2), up(v1), v1) : (ls[v2] = merge(v1, ls[v2]), up(v2), v2);
	}
	
	void split(int u, int w, int &v1, int &v2) {
		if (!u) { v1 = v2 = 0; return; }
		key[u] <= w ? (v1 = u, split(rs[u], w, rs[u], v2), up(u)) : (v2 = u, split(ls[u], w, v1, ls[u]), up(u));
	}
	
	void inline push_back(int &rt, int w) { rt = merge(rt, node(w)); }
	
	void inline pop_back(int &rt, int w) { int v; split(rt, w - 1, rt, v); }
};
treap tr;

void inline init() {
	cont (i, n) {
		tr.push_back(q[qr], a[i]);
		if (i != n && a[i] > a[i + 1])  ++qr;
	}
	for (lst = n; tr.mx[q[qr]] == lst && lst; tr.pop_back(q[qr], lst--));
	++qr;
}

void inline deal() {
	for (++ans; !q[ql] && ql != qr; ++ql);
	int u = q[ql++], mx = tr.mx[u], v1, v2;
	for (int k = ql; k != qr && mx != lst; ++k) {
		if (!q[k])  continue;
		if (tr.mx[q[k]] > mx) {
			tr.split(q[k], mx, v1, v2);
			q[k] = v1, u = tr.merge(u, v2);
			mx = tr.mx[u];
		}
		int &r1 = q[k - 1], &r2 = q[k];
		if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	}
	int &r1 = q[qr - 1], &r2 = u;
	if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	for (; tr.mx[u] == lst && lst; tr.pop_back(u, lst--));
	q[qr++] = u;
}

int main() {
	read(n);
	cont (i, n) {
		read(a[i]);
	}
	for (init(); lst; deal());
	write(ans);
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    rep(i, 1, n){
        if((n - i) % 2 == 1) continue;
        ll len = (n - i);
        if(s.substr(0, len/2) == s.substr(len/2, len/2)) ans = max(ans, len); 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split())) #0..n-1
B = list(map(int, input().split())) #0..n-1
C = list(map(int, input().split())) #0..n-2
man = sum(B)
for i in range(N-1):
    if A[i+1] == A[i] + 1:
        man += C[A[i]-1]

print(man)

Measured memory_bytes: 3064
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if(n<=k){cout<<n*x<<endl;}
  if(n>k){cout<<k*x+(n-k)*y<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a, b, N;
  cin >> a >> b;
  N = a * b;
  if (N % 2 == 1){
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

vector<long long> enum_divisors(long long N)
{
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main()
{
    ll n, ans = 10000000000000;
    cin >> n;

    const auto &res = enum_divisors(n);

    rep(i, res.size())
    {
        if (ans > res[i] + n / res[i])
            ans = res[i] + n / res[i];
    }
    // for (ll i = 0; i < n / 2; i++)
    // {
    //     if (n % i == 0)
    //     {
    //         if (ans > i + n / i)
    //             ans = i + n / i;
    //         else
    //             break;
    //     }
    // }

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

Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
const long long maxn=111111;
long long n,m;
char ch1[maxn],ch2[maxn];
long long gcd(long long x,long long y){
	if(y==0)return x;
	return gcd(y,x%y);
}
map<long long,char> mmm;
int main(){
	scanf("%lld%lld",&n,&m);
	scanf("%s%s",ch1+1,ch2+1);
	long long lcm=n*m/gcd(n,m);
	for(long long i=1;i<=m;i++){
		mmm[lcm/m*(i-1)+1]=ch2[i];
	}
	for(long long i=1;i<=n;i++){
		if(mmm[lcm/n*(i-1)+1]&&mmm[lcm/n*(i-1)+1]!=ch1[i]){
			printf("-1");
			return 0;
		}
	}
	printf("%lld",lcm);
	return 0;
}

Measured memory_bytes: 10880
n=int(input())
monsters=[int(i) for i in input().split()]
powers=[[int(i),0] for i in input().split()]
monsters.append(0)
powers.extend([[0,0],[0,0]])

breaks=[]
for i in range(n+1):
  if monsters[i]>powers[i][1]:
    attack=sum(powers[i])
    if monsters[i]>=attack:
      breaks.append(attack)
    else:
      breaks.append(monsters[i])
      powers[i+1][1]=attack-monsters[i]
                    
  else:
    powers[i+1][1]=powers[i][0]
    breaks.append(monsters[i])
    
print(sum(breaks))
    
    

Measured memory_bytes: 27968
import numpy as np
from numba import njit


@njit
def solve(n, k, a):
    for _ in range(min(k, 41)):
        diff = np.zeros(3 * n + 1, dtype=np.int64)
        for pos in range(n):
            diff[n + pos - a[pos]] += 1
            diff[n + pos + a[pos] + 1] -= 1
        diff = diff.cumsum()
        a = diff[n:2 * n]
    return a


n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.int64)
a = solve(n, k, a)
print(" ".join(map(str, a)))


Measured memory_bytes: 140268
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> h(n);
	cin >> h[0];
	int ans = 0, cnt = 0;
	rep(i,n-1){
		cin >> h[i+1];
		if(h[i+1] <= h[i]) ++cnt;
		else cnt = 0;
		chmax(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long l = 7;
        int ans = -1;

        for(int i=1; i<=k; i++) {
            if(l % k == 0) {
                ans = i;
                break;
            }
            l = (l * 10 + 7) % k;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35680
n = int(input())
a = []
a = input().split()
Sum = 0

for i in range(n):
  Sum = Sum + int(a[i])

average = int(Sum / n)

answer_1 = 0
answer_2 = 0
for i in range(n):
  answer_1 = answer_1 + (int(a[i]) - average) * (int(a[i]) - average)
  answer_2 = answer_2 + (int(a[i]) - average - 1) * (int(a[i]) - average - 1)

  answer = min(answer_1, answer_2)
print(answer)

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

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int s;
  s = S.size();
  if(s%2==1) cout<<"No"<<endl;
  else{
    bool ans=true;
    for(int i=0; i<N/2; i++){
      if(S.at(i)!=S.at(N/2+i)){
        ans=false;
        break;
      }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3580
#include<cstdio>
#define ll long long
#define mod 1000000007
#define N 110000
inline char gc(){
	static char now[1<<16],*S,*T;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0;char ch=gc();
	while (ch<'0'||ch>'9') ch=gc();
	while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x;
}
int a[N],in[N],color[N],mark[N],cnt[N],n,foot[N];bool circle[N];
ll dp[N];
int main(){
	//freopen("agc.in","r",stdin);
	n=read();ll ans=1;
	for (int i=1;i<=n;++i) a[i]=read(),++in[a[i]];
	for (int i=1;i<=n;++i){
		if (color[i]) continue;int x=i;
		for(;!color[x];x=a[x]) color[x]=i;
		if (color[x]!=i) continue;
		for (;!circle[x];x=a[x]) circle[x]=1; 
	}
	for (int i=1;i<=n;++i) if ((circle[i]&&in[i]>2)||(!circle[i]&&in[i]>1)) {printf("0");return 0;}
	//处理痞老板(基环内向树） 
	for (int i=1;i<=n;++i){
		if (in[i]) continue;int x=i,tmp=0;
		while(!circle[x]) x=a[x],tmp++;foot[x]=tmp;
	} 
	for (int i=1;i<=n;++i){
		if (!circle[i]) continue;int x=i,st=0,first=0,id=0,len=0;
		while (circle[x]){
			++id;circle[x]=0;
			if (foot[x]){
				if (!first){
					st=first=id;len=foot[x];x=a[x];continue;
				}else{
					int numm=(foot[x]<(id-st))+(foot[x]<=(id-st));
					(ans*=numm)%=mod;if (!ans) {printf("0");return 0;}st=id;x=a[x];continue;
				}
			}x=a[x];
		}if (first){
			int numm=(len<(id+first-st))+(len<=(id+first-st));
			(ans*=numm)%=mod;if (!ans) {printf("0");return 0;}
		}else cnt[id]++;
	}
	//for (int i=1;i<=n;++i) if (cnt[i]) printf("%d %d\n",i,cnt[i]);
	for (int i=1;i<=n;++i){
		dp[0]=1;if (!cnt[i]) continue;
		if (i>1&&(i%2)){
			for (int j=1;j<=cnt[i];++j) {
				dp[j]=dp[j-1]*2%mod;if (j>1) (dp[j]+=dp[j-2]*(j-1)*i%mod)%=mod;
			}
		}else{
			for (int j=1;j<=cnt[i];++j){
				dp[j]=dp[j-1];if (j>1) (dp[j]+=dp[j-2]*(j-1)*i%mod)%=mod;
			}	
		}
		(ans*=dp[cnt[i]])%=mod;if (!ans){printf("0");return 0;}
	}printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2304
from bisect import bisect_left as bs
#ソート順序を保ったまま値を挿入する
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

while M > 0:
  i = A.pop(-1) // 2
  A.insert(bs(A, i), i)
  M -= 1

print(sum(A))

Measured memory_bytes: 85684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		
		int Christmas = 25;
		int N = sc.nextInt();
		if(N ==25) {
			System.out.println("Christmas ");
			System.exit(0);
		}
		System.out.print("Christmas ");
		for(int i =0; i<Christmas-N; i++) {
			System.out.print("Eve ");
		}
	}

}


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

long long f(int X,int Y,int Z)
{
  long long af=X*(X+Y)+Y*(Y+Z)+Z*(Z+X);
  return af;
}

int main()
{
int N;cin>>N;vector<long long> ans(N+1,0);
for(int x=1;x<N;x++)for(int y=x;y<N;y++)for(int z=y;z<N;z++)
{
  long long ff=f(x,y,z);
  if(ff>N)break;
  if(x==y&&y==z)ans[ff]++;
  else if(x==y)ans[ff]+=3;
  else if(y==z)ans[ff]+=3;
  else ans[ff]+=6;
}
for(int i=1;i<N+1;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    map<ll, ll> mp;
    rep(i, n){
        ll num;
        cin >> num;
        sum += num;
        mp[num]++;
    }
    int q;
    cin >> q;
    rep(i, q){
        ll b, c;
        cin >> b >> c;
        mp[c] += mp[b];
        sum -= mp[b] * b;
        sum += mp[b] * c;
        mp.erase(b);
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 7452
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        try {
            Scanner data = new Scanner(System.in);
            int n = Integer.parseInt(data.next());
            double money = 0;
            double sum = 0;
            for (int i=0; i<n; i++) {
                money = data.nextDouble();
                String type = data.next();
                if (type.equals("JPY")){
                    sum = sum + money;
                } else {
                    sum = sum + (money * 380000.0);
                }
            }
            System.out.println(sum);
            data.close();
        } catch (NumberFormatException nfe) {
          System.out.println("NumberFormatException: " + nfe.getMessage());
        }
    }

    Main() {

    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define lli long long int

using namespace std;
lli dp[20010][4];
lli x;
lli sk[5];

lli coin(lli now,int in)
{

    if(now ==x)
        return 1;
    if(now >x)
        return 0;
    if(in>3)
        return 0;
    lli m;
    if(in==1)
        m=500;
    else if(in==2)
        m=100;
    else
        m=50;
        if(dp[now][in]!=-1)
            return dp[now][in];
        lli ans=0;
        for(int i=1;i<=sk[in];i++)
        {
            ans+=coin(now+m*i,in+1);

        }
        ans+=coin(now,in+1);
        return dp[now][in]=ans;



}


int main()
{

    memset(dp,-1,sizeof(dp));
	cin >>sk[1]>>sk[2]>>sk[3]>>x;

    cout <<coin(0,1);

}



Measured memory_bytes: 896
#include<stdio.h>

int main(void)
{
	int A, B;
	
	scanf("%d%d", &A, &B);

	if (A == 1)
		A = 14;
	if (B == 1)
		B = 14;

	if (A > B)
		printf("Alice\n");
	else if (A == B)
		printf("Draw\n");
	else
		printf("Bob\n");

	return 0;
}

Measured memory_bytes: 128
N,X,Y = map(int,input().split())

dist = [i*0 for i in range(N)]


for i in range(1,N+1):
  for j in range(i,N+1):
    if(i==j):
      continue
    a = abs(i-j)
    b = abs(X-i)+1+abs(Y-j)
    #c = abs(X-j)+1+abs(Y-i)
    
    #print(str(min(a,b,c))+' when ('+str(i)+','+str(j)+')')
    dist[min(a,b)]+=1
    #if(j>X):
    #  if(j<X+((Y-X)/2)):
    #    dist[N-(Y-X)+(int((Y-X)/2) - 1) - j] += 1
    #  else:
    #    dist[N-1-j]+=1
    #else:
    #  dist[N-(Y-X)-j]+=1
#print(Pi)
#dist=[]
#dist.append(abs(Ai[N-1]-Ai[0]))
#for i in range(N-1):
#  dist.append(abs((K+Ai[i])-Ai[i+1]))

#print(min(dist))
#print(dist)
  
#Pi.sort(reverse=True)
#Qi.sort()
#Ri.sort()

for i in range(1,N):
  print(dist[i])




Measured memory_bytes: 46556
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


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

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n); rep(i, n)cin >> a[i];
	vector<int>b(n); rep(i, n)cin >> b[i];
	vector<int>c(n - 1); rep(i, n-1)cin >> c[i];
	int ans = 0;
	rep(i, n) {
		ans += b[a[i] - 1];
	}
	rep(i, n - 1) {
		if (a[i] + 1 == a[i + 1]) {
			ans += c[a[i]-1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap());
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    let c = it.next().unwrap();
    if c >= a && c <= b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import numpy as np
N, T = map(int, raw_input().split())
A_list = map(int, raw_input().split())

dif_dict = dict()

A_min = np.minimum.accumulate(A_list)
A_max = np.maximum.accumulate(A_list[::-1])[::-1]

max_d = (A_max - A_min).max()
print len(set(A_min[max_d ==A_max - A_min]))


Measured memory_bytes: 19456
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    int f = max(a, c);
    int e = min(b, d);

    if(e - f < 0) cout << 0 << endl;
    else cout << e - f << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  string s, p;
  cin >> s >> p;
  string ss = s + s;
  bool flag = false;
  for (int i = 0; i < ss.length(); i++) {
    if (ss[i] == p[0]) {
      flag = true;
      for (int j = 1; j < p.length(); j++) {
        if (ss[i+j] != p[j]) {
          flag = false;
          break;
        }
      }
      if (flag) break;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   vector<ll> div;
   for(ll i=1;i<=sqrt(n);i++)
   {
       if(n%i == 0)
       {
           div.pb(i);
           if(i!=n/i)
                div.pb(n/i);
       }
   }
   
   ll cnt = 0;
   rep(div.size())
   {
       if(div[i] == 1)
            continue;
       ll temp = n;
       while(temp%div[i] == 0)
           temp/=div[i];
       temp%=div[i];
       if(temp == 1)
            cnt++;
   }
   
   div.clear();
   n--;
   for(ll i=1;i<=sqrt(n);i++)
   {
       if(n%i == 0)
       {
           if(i>1)
                div.pb(i);
           if(i!=n/i && n/i>1)
                div.pb(n/i);
       }
   }
   
   cnt+=(ll)div.size();
   cout<<cnt;
   
   
   
   return 0;        
}  
   

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define W first
#define U second.first
#define V second.second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int n, m, p;
viii e;
vi d;

bool check() {
    d[1] = 0;
    fort(i, 0, 2 * n)
        for (iii &x : e)
            if (d[x.U] != INF && d[x.V] > d[x.U] + x.W) {
                d[x.V] = d[x.U] + x.W;
                if (i >= n && x.V == n) return 0;
            }
    return 1;
}

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> p;
    while (m--) {
        int u, v, w; cin >> u >> v >> w;
        e.pb(iii(-(w - p), ii(u, v)));
    }
    d = vi(n + 1, INF);
    if (!check()) cout << "-1\n";
    else cout << max(0, -d[n]) << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main(void){
    int N, M;

    cin >> N >> M;

    long long x[N+5], y[N+5], z[N+5];

    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    
    int count =0;
    long long ans=-(1LL << 60);
    
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                vector<long long> re;
                for(int ii=0;ii<N;ii++){
                    re.push_back(pow(-1, i) * x[ii] + pow(-1, j) * y[ii] + pow(-1, k) * z[ii]);
                }
                sort(re.begin(), re.end());
                reverse(re.begin(), re.end());
                long long maxn=0LL;
                for(int ii=0;ii<M;ii++){
                    maxn = maxn + re[ii];
                }
                ans = max(maxn, ans);
                
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,M;
    cin >> N >> M;
    ll gcm = 0;
    if(N <= 10){
        for(ll i = N;;i++){
            if(M < i)break;
            if(M % i == 0){
                chmax(gcm,M/i);
                break;
            }
        }
    }else{
        for(ll i = 1;;i++){
            ll test = M - i*(N-1);
            if(test <= 0)break;
            if(test < i)break;
            if(test % i == 0){
                chmax(gcm,i);
            }
        }
    }
    cout << gcm << "\n";
}

Measured memory_bytes: 3496
import math

N = int(input())
W = list(map(int, input().split()))

saishou = 100000000
for i in range(N-1):
    s1 = sum(W[:i+1])
    s2 = sum(W[i+1:])
    sa = max(s1-s2, s2-s1)
    saishou = min(saishou, sa)

print(saishou)


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    char X, Y;
    std::cin >> X >> Y;

    if(X == Y) {
        std::cout << '=' << std::endl;
    }
    else {
        std::cout << ((X < Y) ? '<' : '>') << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int _500, _100, _50, sum;
  int count = 0;
  cin >> _500;
  cin >> _100;
  cin >> _50;
  cin >> sum;

  for(auto i = 0; _500 >= i; ++i){
    for(auto j = 0; _100 >= j; ++j){
      for(auto k = 0; _50 >= k; ++k){
        if(i * 500 + j * 100 + k * 50 == sum){
          count++;
        }
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int>parent,sizes;
  UnionFind(int n):parent(n),sizes(n,1){
    for(int i=0;i<n;++i)parent[i]=i;
  }
  int find(int x){
    if(x==parent[x])return x;
    return parent[x]=find(parent[x]);
  }
  void unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y)return;
    if(sizes[x]>sizes[y])swap(x,y);
    parent[y]=x;
    sizes[x]+=sizes[y];
    sizes[y]=0;
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  int size(int x){
    return sizes[find(x)];
  }
};
main(){
  int n,m,a,b,x=0,y=0;
  cin>>n>>m;
  UnionFind UF(n);
  for(int i=0;i++<m;UF.unite(--a,--b))cin>>a>>b;
  for(int i=0;i<n;++i)UF.sizes[i]>1?x++:UF.sizes[i]-1?:y++;
  cout<<abs(x-y)<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int r;
    cin >> r;
    if (r < 1200)
    {
        OP("ABC");
    }
    else if (r < 2800)
    {
        OP("ARC");
    }
    else
    {
        OP("AGC");
    }
    return 0;
}

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

#define l first
#define r second
#define p first
#define q second

int main() {

#ifdef LOCAL_DEFINE
	freopen("input.txt", "rt", stdin);
#endif

	int n, m, q;
	cin >> n >> m >> q;

	vector< pair<int, int> > train(m);

	for (int i = 0; i < m; i++) cin >> train[i].l >> train[i].r;

	vector< pair<int, int> > query(q);

	for (int i = 0; i < q; i++) cin >> query[i].p >> query[i].q;

	int sum[n + 1][n + 1] = {};

	for (int i = 0; i < m; i++) sum[train[i].l][train[i].r]++;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n + 1; j++) {
			if (j > 1) sum[i][j] += sum[i][j - 1];
		}
	}

	for (int i = 0; i < q; i++) {
		int ans = 0;
		for (int j = query[i].p; j < n + 1; j++) {
			ans += sum[j][query[i].q] - sum[j][query[i].p - 1];
		}
		cout << ans << endl;
	}

#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s. \n";
#endif

	return 0;
}

Measured memory_bytes: 4224
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# 


s = input()
t = input()
if s == t[:-1]:

    print("Yes")
else:
    print("No")


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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	int n, m, sum = 0;
	cin >> n >> m;
	while (m--) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum <= n) cout << n - sum << "\n";
	else cout << "-1" << "\n";
	return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();

        int ans = Integer.MAX_VALUE;
        int[] whiteCumulativeSum = new int[s.length];

        if (s[0] == '.') {
            whiteCumulativeSum[0]++;
        }

        for (int i = 1; i < s.length; i++) {
            whiteCumulativeSum[i] = whiteCumulativeSum[i - 1];
            if (s[i] == '.') {
                whiteCumulativeSum[i]++;
            }
        }

        if (whiteCumulativeSum[s.length - 1] == 0) {
            System.out.println(0);
            return;
        }

        for (int i = 0; i < s.length; i++) {
            // iまでを白にするコスト
            int whiteCost = i + 1 - whiteCumulativeSum[i];
            // iより奥を黒にするコスト
            int blackCost = whiteCumulativeSum[n - 1] - whiteCumulativeSum[i];
            ans = Math.min(ans, whiteCost + blackCost);
        }

        System.out.println(Math.min(ans, whiteCumulativeSum[n - 1]));
    }
}

Measured memory_bytes: 42044
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int w = in.nextInt();
		int h = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int r = in.nextInt();
		
		if((x+r<=w)&&(x-r>=0)&&(y+r<=h)&&(y-r>=0)) System.out.println("Yes");
		else System.out.println("No");
	}

}

Measured memory_bytes: 26280
package main

import "fmt"

func main() {
	var (
		num  int
		str1 string
		str2 string
		ans string
	)

	fmt.Scanf("%d", &num)
	fmt.Scanf("%s %s", &str1, &str2)

	for i := 0; i < num; i++ {
		ans += string(str1[i]) + string(str2[i]);
	}

	fmt.Printf("%s", ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;
ll powMod(ll a, ll k)
{
	ll ret = 1;
	while(k)
	{
		if(k & 1) ret = ret * a % mod;
		a = a * a % mod; k >>= 1;
	}
	return ret;
}
ll inv(ll a) { return powMod(a, mod - 2);}
ll C(int n, int m) 
{
	ll a = 1, b = 1;
	for(int i = 1; i <= m; ++i) 
	{
		a = a * i % mod;
		b = b * (n - i + 1) % mod;
	}
	return b * inv(a) % mod;
}
int main()
{
	ll n, m, k;
	cin >> n >> m >> k;
	ll ans = C(n * m - 2, k - 2);
	ll A = n * n % mod * C(m + 1, 3) % mod;
	ll B = m * m % mod * C(n + 1, 3) % mod;
	ans = ans * (A + B) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

vector<ll> A;
vector<ll> B;
vector<ll> C;

vector<ll> ans;
set<tuple<int, int, int>> exists;

void solve(const ll K) {
    int num = 0;

    priority_queue<tuple<ll, int, int, int>> q; // {value, ind_a, ind_b, ind_c}
    q.push(make_tuple(A[0] + B[0] + C[0], 0, 0, 0));
    exists.insert(make_tuple(0, 0, 0));

    while (num < K) {
        assert(!q.empty());
        ll v;
        int a, b, c;

        tie(v, a, b, c) = q.top();
        // printf("%lld, %d, %d, %d\n", v, a, b, c);
        q.pop();
        ans.push_back(v);
        num++;

        if (a < (int) A.size() - 1) {
            a++;
            if (exists.find(make_tuple(a, b, c)) == exists.end()) {
                v = A[a] + B[b] + C[c];
                tuple<ll, int, int, int> tup(v, a, b, c);
                q.push(tup);
                exists.insert(make_tuple(a, b, c));
            }
            a--;
        }
        if (b < (int) B.size() - 1) {
            b++;
            if (exists.find(make_tuple(a, b, c)) == exists.end()) {
                v = A[a] + B[b] + C[c];
                tuple<ll, int, int, int> tup(v, a, b, c);
                q.push(tup);
                exists.insert(make_tuple(a, b, c));
            }
            b--;
        }
        if (c < (int) C.size() - 1) {
            c++;
            if (exists.find(make_tuple(a, b, c)) == exists.end()) {
                v = A[a] + B[b] + C[c];
                tuple<ll, int, int, int> tup(v, a, b, c);
                q.push(tup);
                exists.insert(make_tuple(a, b, c));
            }
            c--;
        }
    }
}

int main(void) {
    int X, Y, Z;
    ll K;
    cin >> X >> Y >> Z >> K;

    A.resize(X);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    B.resize(Y);
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());

    C.resize(Z);
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());

    solve(K);

    for (int i = 0; i < K; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 924
import java.util.Scanner;

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

            StringBuilder screen = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (c == 'B') {
                    if (screen.length() > 0) {
                        screen.setLength(screen.length() - 1);
                    }
                } else {
                    screen.append(c);
                }
            }

            System.out.println(screen.toString());
        }
    }
}


Measured memory_bytes: 26560