akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e5+10;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
ll dp[MAX][13];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int n=s.length();
    dp[0][0]=1;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<10; j++)
        {
            int cur=s[i]-'0';
            if(s[i]=='?')
                cur=j;
            for(int k=0; k<13; k++)
            {
                int rem=((k*10)+cur)%13;
                dp[i+1][rem]=MODADD(dp[i+1][rem],dp[i][k]);
            }
            if(s[i]!='?')
                break;
        }
    }
    cout<<dp[n][5]<<endl;

    return 0;
}


Measured memory_bytes: 13932
#include<iostream>

int main(){
	int a,b,i,n;
	while(std::cin>>a>>b){
		i=1;
		for(n=1;n>0;n++){
			if(i<=a+b){
				if(a+b<i*10){
					std::cout<<n<<std::endl;
					n=-1;
				}else{
					i=i*10;
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, m, x;

int main()
{
    int l = 0, r = 0;
    cin >> n >> m >> x;
    while(m--)
    {
        int s;
        cin >> s;
        if(s < x) l++;
        else r++;
    }

    cout << min(l, r) << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input, marker::Chars};
use std::cmp::min;
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        s: Chars
    }
    let one_num = s.iter().filter(|&&s| s == '1').count();
    let zero_num = s.iter().filter(|&&s| s == '0').count();
    println!("{}", min(zero_num, one_num) * 2);
}


Measured memory_bytes: 2508
// https://atcoder.jp/contests/abc082/tasks/arc087_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int gx, gy;
    cin >> gx >> gy;
    int cnt = 0;
    vector<int> vx, vy;
    s += 'T';
    bool bt = false;
    int fv = -1;
    for (auto &x : s) {
        if (x == 'T') {
            if (bt) {
                vy.push_back(cnt);
            } else {
                if (fv == -1) {
                    fv = cnt;
                } else {
                    vx.push_back(cnt);
                }
            }
            cnt = 0;
            bt = !bt;
        } else {
            cnt++;
        }
    }
    sort(ALLR(vx));
    sort(ALLR(vy));
    int cx = fv, cy = 0;
    for (auto &a : vx) {
        cx += a * (cx < gx ? 1 : -1);
    }
    for (auto &a : vy) {
        cy += a * (cy < gy ? 1 : -1);
    }
    if (cx == gx && cy == gy) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
def make_plus_index(S_list):
  s_index = [S_list[0]]
  for S in S_list[1:]:
    new_index = []
    for s in s_index:
      new_index.append(s+'+'+S)
      new_index.append(s+S)
    s_index = new_index
  return s_index

def run():
  S_list = list(input())
  s_lists = make_plus_index(S_list)
  total = 0
  for s in s_lists:
    total += sum(map(int, s.split('+')))
  print(total)
  
if __name__ == '__main__':  
  run()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int ans=0;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i==1)continue;
        else{
            if(a[i]==a[i-1]){
                a[i]=n+10;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3520
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int H, W; char s[1009][1009]; bool vis[1009][1009];
int main() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", s[i]);
	vector<pair<int, int> > v;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '.' || s[i][j] == '9') continue;
			int cnt = 0;
			for (int k = -1; k <= 1; k++) {
				for (int l = -1; l <= 1; l++) {
					int tx = j + l, ty = i + k;
					if (0 <= tx && tx < W && 0 <= ty && ty < H && s[ty][tx] == '.') cnt++;
				}
			}
			if (cnt >= s[i][j] - 48) v.push_back(make_pair(j, i));
		}
	}
	int ret = 0;
	for (; !v.empty(); ret++) {
		for (pair<int, int> i : v) s[i.second][i.first] = '.';
		vector<pair<int, int> > w;
		for (pair<int, int> i : v) {
			int sx = i.first, sy = i.second;
			for (int j = -1; j <= 1; j++) {
				for (int k = -1; k <= 1; k++) {
					int tx = sx + k, ty = sy + j;
					if (!(0 <= tx && tx < W && 0 <= ty && ty < H)) continue;
					if (s[ty][tx] == '.' || s[ty][tx] == '9' || vis[ty][tx]) continue;
					int cnt = 0;
					for (int l = -1; l <= 1; l++) {
						for (int m = -1; m <= 1; m++) {
							int ux = tx + m, uy = ty + l;
							if (0 <= ux && ux < W && 0 <= uy && uy < H && s[uy][ux] == '.') cnt++;
						}
					}
					if (cnt >= s[ty][tx] - 48) w.push_back(make_pair(tx, ty)), vis[ty][tx] = true;
				}
			}
		}
		for (pair<int, int> i : w) vis[i.second][i.first] = false;
		v = w;
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 4684
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll N = max(A, B);
    ll M = min(A, B);
    while (M > 0) {
        ll T = M;
        M = N % M;
        N = T;
    }
    cout << A * B / N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
    int n;
    int t[101];
    int m;
    int p[101];
    int x[101];

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
        cin >> p[i];
        cin >> x[i];
    }

    int sum = 0;
    for (int i = 1; i <= m; i++) {
        sum = 0;
        for (int j = 1; j <= n; j++) {
            if (j == p[i]) {
                sum += x[i];
            }
            else {
                sum += t[j];
            }
        }
        cout << sum << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,x,k=0,n;
    vector<int>v;
    vector<int>vv;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>x;
        v.push_back(x);
    }
    for(j=1; j<=100; j++)
    {
        k=0;
        for(i=0; i<v.size(); i++)
        {
            k+=((v[i]-j)*(v[i]-j));


        }
        vv.push_back(k);
    }

    sort(vv.begin(),vv.end());
    cout<<vv[0]<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		String []d=new String[K];
		for(int i=0;i<K;i++){
			d[i]=sc.next();
		}
		
		LOOP:while(true){
			String number=String.valueOf(N);
			N++;
			
			for(int i=0;i<number.length();i++){
				for(int j=0;j<K;j++){
					if(number.charAt(i)==d[j].charAt(0))continue LOOP;
				}
			}
			System.out.println(number);
			return;
		}
	}
}


Measured memory_bytes: 26580
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int time = 0;
    vector<int> arr(5);
    vector<int> m10;
    for(int i = 0; i < 5; i++)
    {
        cin >> arr[i];
    }
    for(int i = 0; i < arr.size(); i++)
    {
        if(arr[i] % 10 == 0)
        {
            m10.push_back(arr[i]);
            arr.erase(arr.begin() + i);
            i--;
        }
    }
    vector<int> mod10(arr.size());
    for(int i = 0; i < arr.size(); i++)
    {
        mod10[i] = arr[i] % 10;
    }
    if(arr.size() > 0)
    {
        int mini = *min_element(mod10.begin(), mod10.end());
        for(int i = 0; i < arr.size(); i++)
        {
            if(mod10[i] == mini)
            {
                time += arr[i];
                arr.erase(arr.begin() + i);
                break;
            }
        }
    }
    for(int i = 0; i < arr.size(); i++)
    {
        time += arr[i] / 10 * 10 + 10;
    }
    for(int i = 0; i < m10.size(); i++)
    {
        time += m10[i];
    }
    cout << time;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

lint po(lint n) {
  return n * n * n * n * n;
}

int main() {
  
  lint x; cin >> x;
  for (lint a = -3000; a <= 3000; a++) {
    for (lint b = -3000; b <= 3000; b++) {
      if (po(a) - po(b) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

        sc.close();

        int road = a + b - 1;

        System.out.println(a * b - road);
    }
}

Measured memory_bytes: 21844
from sys import stdin, stdout
import sys
INF=1e11
import bisect
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
from collections import defaultdict 
import math
d={"AC":0,"WA":0,"TLE":0,"RE":0}
for _ in range(int(stdin.readline())):
    d[get_string()]+=1
for x in d:
    print(x,"x",d[x])


Measured memory_bytes: 9316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const int mo = 1e9 + 7;
struct mint
{
    int n;
    mint(int n = 0) : n(n) {}
};
mint operator+(mint a, mint b) { return (a.n += b.n) >= mo ? a.n - mo : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mo : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n & mo; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
const int ma=1e5+10;
void solve()
{
    vector<int> isp(ma,1);
    isp[0]=isp[1]=0;
    for(int i=2;i<ma;i++)
    {
        if(isp[i])
        {
            for(int j=2*i;j<ma;j+=i)
            {
                isp[j]=0;
            }
        }
    }
    vector<int> cnt(ma,0);
    for(int i=2;i<ma;i++)
    {
        if(isp[i]&&isp[(i+1)/2])cnt[i]++;
    }
    rep(i,ma-1)cnt[i+1]+=cnt[i];
    int q;
    cin>>q;
    while(q--)
    {
        int a,b;cin>>a>>b;
        cout<<cnt[b]-cnt[a-1]<<endl;
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;



int N, M, L, L2;

struct roadinfo {
	int B, C;
};

vector<roadinfo> roads;
vector<int> conn[300];

ll dist[300][300]; // distance = L2 * 給油回数 + frac


struct dinfo {
	ll dist;
	int city;
};


class Comp {
public:
	bool operator() ( const dinfo &l, const dinfo &r ){
		return l.dist > r.dist;
	};
};

// dijkstra
void calc_reachable( int n ){
	priority_queue<dinfo,vector<dinfo>,Comp> q; // {total_distance,city}
	for ( int i = 0; i < N; i++ )
		dist[n][i] = -1;
	
	dist[n][n] = 0;
	q.push({0,n});
	
	while ( !q.empty() ){
		dinfo d = q.top();
		q.pop();
		if ( dist[n][d.city] < d.dist )
			continue;
		
		for ( auto it : conn[d.city] ){
			roadinfo &road = roads[it];
			int city = road.B;
			int dist_frac = d.dist % L2;
			ll new_dist;
			if ( dist_frac + road.C <= L ) // 給油せずに到達できるか？
				new_dist = d.dist + road.C;
			else
				new_dist = (d.dist-dist_frac+L2) + road.C; 
			
			if ( dist[n][city] == -1 || new_dist < dist[n][city] ){
				dist[n][city] = new_dist;
				q.push({new_dist,road.B});
			}
		}
	}
	//cout << "-- " << n << endl;
	//for ( int i = 0; i < N; i++ )
	//	cout << i << ":" << dist[n][i] << " = L*" << (dist[n][i]/L2) << " + " << (dist[n][i]%L2)<< endl;
}


int main(){
	cin >> N >> M >> L;
	L2 = L*2;
	
	roads.resize(M*2);
	int m = 0;
	for ( int i = 0; i < M; i++ ){
		int A, B, C;
		cin >> A >> B >> C;
		A--;
		B--;
		if ( C <= L ){
			roads[m*2]   = {B,C};
			roads[m*2+1] = {A,C};
			conn[A].push_back(m*2);
			conn[B].push_back(m*2+1);
			m++;
		}
	}
	roads.resize(m*2);
	M = m;
	
	
	// 道が短い順にソート
	for ( int i = 0; i < N; i++ ){
		sort( conn[i].begin(), conn[i].end(), [](int l, int r){
			return roads[l].C < roads[r].C;
		} );
	}
	
	//chrono::system_clock::time_point start, end;
	//start = chrono::system_clock::now();
	for ( int i = 0; i < N; i++ ){
		calc_reachable(i);
	}
	//end = chrono::system_clock::now();
	//double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0);
	//cout << "time=" << time << endl;
	
	int Q;
	cin >> Q;
	for ( int i = 0; i < Q; i++ ){
		int s, t;
		cin >> s >> t;
		s--;
		t--;
		cout << (dist[s][t] == -1 ? -1 : dist[s][t]/L2) << endl;;
	}
	
	return 0;
}



Measured memory_bytes: 3288
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <numeric>

int main() {
	usize n, m;
	i32 c;
	std::cin >> n >> m >> c;
	std::vector<i32> b(m);
	for (auto &e : b) {
		std::cin >> e;
	}
	usize ans = 0;
	while (n--) {
		std::vector<i32> a(m);
		for (auto &e : a) {
			std::cin >> e;
		}
		if (std::inner_product(a.cbegin(), a.cend(), b.cbegin(), c)> 0) {
			++ans;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
string s,t;
bool NOL[222],NOR[222];
int D[222][222],P[222][222];
bool ok[222][222];
main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]>='0'&&s[i]<='9')
		{
			t+=s[i];
			if(i>0&&s[i-1]=='(')NOR[t.size()-1]=true;
			if(i+1<s.size()&&s[i+1]==')')NOL[t.size()-1]=true;
		}
		else if(s[i]=='+'||s[i]=='-')t+=s[i];
	}
	s=t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]>='0'&&s[i]<='9')
		{
			ok[i][i+1]=true;
			D[i][i+1]=P[i][i+1]=s[i]-'0';
		}
	}
	for(int k=2;k<=s.size();k++)for(int i=0;i+k<=s.size();i++)
	{
		if(NOL[i]||NOR[i+k-1])continue;
		int d=-2e9,p=2e9;
		for(int j=i+1;j<i+k;j++)
		{
			if(!ok[i][j]||!ok[j+1][i+k])continue;
			if(s[j]=='+')
			{
				ok[i][i+k]=true;
				d=max(d,D[i][j]+D[j+1][i+k]);
				p=min(p,P[i][j]+P[j+1][i+k]);
			}
			else if(s[j]=='-')
			{
				ok[i][i+k]=true;
				d=max(d,D[i][j]-P[j+1][i+k]);
				p=min(p,P[i][j]-D[j+1][i+k]);
			}
		}
		if(ok[i][i+k])D[i][i+k]=d,P[i][i+k]=p;
	}
	cout<<D[0][s.size()]<<endl;
}



Measured memory_bytes: 3628
#include <stdio.h>

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

	int a[100];
	
	for(int i = 0; i < n; i++){
		
		scanf("%d", &a[i]);
	}
	
	for(int i = 0; i < n; i++){
		
		printf("%d", a[n - 1 - i]);
		if(i != n - 1){
			printf(" ");
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 2684
N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

sum_h = sum(h)
sum_dam = B * N + (A - B)
ng = (sum_h - 1) // sum_dam + 1 - 1
ok = (max(h) - 1) // B + 1
ans = (ng + ok + 1) // 2
while ok - ng > 1:
    cnt = ans
    flag = 0
    for h_i in h:
        rem = h_i - B * ans
        if rem > 0:
            cnt -= (rem - 1) // (A - B) + 1
            if cnt < 0:
                flag = 1
                break
    if flag == 0:
        ok = ans
    else:
        ng = ans
    ans = (ng + ok + 1) // 2

print(ans)


Measured memory_bytes: 50648
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll x, y;
    cin >> x >> y;

    auto a_a = (y - x) >= 0 ? y - x : numeric_limits<ll>::max();
    auto a_ab = (-y) - x >= 0 ? (-y) - x + 1 : numeric_limits<ll>::max();
    auto ba_a = y - (-x) >= 0 ? y - (-x) + 1 : numeric_limits<ll>::max();
    auto ba_ab = (-y) - (-x) >= 0 ? (-y) - (-x) + 2 : numeric_limits<ll>::max();

    cout << min({ a_a, a_ab, ba_a, ba_ab }) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll sum(ll n){
  return n*(n+1)/2;
}

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

  ll ans = 0;
  while(sum(ans)<X){
    ans++;
  }
  cout << ans <<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n);
    vector<pair<ll, ll>> vp;
    rep(i, n)
    {
        cin >> as[i];
    }
    rep(i, n)
    {
        int l = 0;
        int r = 0;
        rep(j, n)
        {
            if (j < i && as[j] < as[i])
            {
                l++;
            }
            else if (i < j && as[j] < as[i])
            {
                r++;
            }
        }
        vp.push_back({l, r});
    }
    // rep(i, n)
    // {
    //     cout << vp[i].first << " " << vp[i].second << endl;
    // }
    ll ans = 0;
    rep(i, n)
    {
        ll l = vp[i].first;
        ll r = vp[i].second;
        ans += (k * r % mod + k * (k - 1) / 2 % mod * (l + r) % mod) % mod;
        ans %= mod;
    }
    cout << ans % mod << endl;
    return 0;
}

Measured memory_bytes: 3680
import collections
if __name__=='__main__':
    n = int(input())
    arr = list(map(int,input().split()))
    arr.sort()
    c = 0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if arr[i]!=arr[j] and arr[j]!=arr[k] and arr[i]+arr[j]>arr[k]:
                    c+=1
    print(c)

        
        
        
        
        
                    


Measured memory_bytes: 73900
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(K: int, X: int):
    A = []
    for i in range(2*K-1):
        A.append(str(X-K+i+1))
    print(' '.join(A))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,i,k,l;

    while(cin>>s)
    {
        cin>>n;
        l = s.size();
        if(n==1)
        {
            cout<<s<<endl;
            continue;
        }

        for(i=1;i<=l;i++)
        {
            if(i%n==1)
            {
                cout<<s[i-1];
            }

        }
        cout<<endl;
        s.clear();

    }










return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string N;
int main() {
    cin >> N;
    long long Sn = 0;

    int slen = N.length();
    for(int i = 0; i < slen; ++i) {
        char n = (char)N.at(i);
        Sn += (long long)(n - '0');
    }

    long long sN = stoll(N);

    if(sN % Sn == 0) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
using System;
namespace AISing.Problems
{
    class B
    {
        static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            long res = 0;
            string[] inputs =  Console.ReadLine().Split(' ');
            for (int i = 1; i <= n; i++)
            {
                long a = long.Parse(inputs[i-1]);
                if (i % 2 == 1 & a % 2 == 1) res++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27536
#include <stdio.h>
#define SIZE 100

int search(int *donut, int n)
{
	int min = donut[0];
	for (int i = 1; i < n; i++) {
		if (min > donut[i]) {
			min = donut[i];
		}
	}
	return min;
}

int main(void)
{
	int n, ele;
	int min = 0;
	int sum = 0;
	int rst = 0;
	int donut[SIZE];

	scanf("%d %d", &n, &ele);

	for (int i = 0; i < n; i++) {
		scanf("%d", &donut[i]);
		sum += donut[i];
	}

	rst = ele - sum;
	min = search(donut, n);

	printf("%d\n", n + rst / min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    /***********************************************/
    /* Dear online judge:
     * I've read the problem, and tried to solve it.
     * Even if you don't accept my solution, you should respect my effort.
     * I hope my code compiles and gets accepted.
     *  ___  __     _______    _______      
     * |\  \|\  \  |\  ___ \  |\  ___ \     
     * \ \  \/  /|_\ \   __/| \ \   __/|    
     *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
     *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
     *    \ \__\\ \__\\ \_______\\ \_______\
     *     \|__| \|__| \|_______| \|_______|
     */
    const long long mod = 1000000007;
     
    int main() {
    	ios_base::sync_with_stdio(false);
    	cin.tie(nullptr);
     
    	int N;
    	cin>>N;
    	vector<long long> a(N);
    	vector<long long> pre(N);
    	for(int i = 0;i < N;i++) cin>>a[i], pre[i] = a[i] + (i?pre[i-1]:0);
    	long long res = LLONG_MAX;
    	for(int h = 1;h < N-2;h++) {
    		long long f = pre[h];
    		long long s = pre[N-1] - pre[h];
    		int f1 = upper_bound(pre.begin(),pre.end(),(f+1)/2) - pre.begin()-1;
    		int s1 = upper_bound(pre.begin(),pre.end(),pre[h] + (s+1)/2) - pre.begin()-1;
    		for(int f2 = f1;f2 < f1 + 2;f2++) {
    			if(f2 < 0 || f2 == h) continue;
    			for(int s2 = s1;s2 < s1 + 2;s2++) {
    				if(s2 <= h || s2 >= N-1) continue;
    				long long mn = min(pre[f2],pre[h] - pre[f2]);
    				mn = min(mn,min(pre[s2]-pre[h],pre[N-1] - pre[s2]));
     
    				long long mx = max(pre[f2],pre[h] - pre[f2]);
    				mx = max(mx,max(pre[s2]-pre[h],pre[N-1] - pre[s2]));
    				
    //				cerr<<f2<<' '<<h<<' '<<s2<<": "<<mn<<' '<<mx<<'\n';
    				res = min(res,mx-mn);
    			}
    		}
    	}
    	cout<<res<<'\n';
    	return 0;
    }

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

int main(){
    int p, q ,r;
    cin >> p >> q >> r;
    cout << min(p+q , min(q+r, r+p)) <<endl;
    return 0;
}

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

#define ll long long

struct monster {
	ll x,h;
} m[200005];

struct bomb {
	ll pos,cnt;
} b[200005];

ll i,t,j;
ll n,d,a,ans,cnt,sum,l;

bool cmp(monster a1,  monster a2) {
	return (a1.x<a2.x);
}

int main() {
	scanf("%lld%lld%lld",&n,&d,&a);

	for (i=1; i<=n; ++i) {
		scanf("%lld%lld",&m[i].x,&m[i].h);
	}

	sort(m+1,m+n+1,cmp);

	cnt=sum=0;
	b[l].pos=-9e18;
	for (i=1; i<=n; ++i) {
		while (m[i].x-b[l].pos>d && l<=cnt) {
			sum-=b[l].cnt;
			++l;
		}

		m[i].h-=sum*a;
		if (m[i].h>0) {
			b[++cnt]=(bomb) {
				m[i].x+d,(m[i].h-1)/a+1
			};
			sum+=b[cnt].cnt;
		}
	}

	for (i=1; i<=cnt; ++i) ans+=b[i].cnt;

	printf("%lld\n",ans);

	return 0;
}
/*
4 2
1121
--------
2020
==========
5 3
92325
-------
2121
*/

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n;
  double f[105],a[105],t[105],x[105],y[105];
  double a_dis=-1,a_time=-1,b_dis=-1,b_time=-1;

  cin>>n;
  rep(i,n){
    cin>>f[i]>>a[i]>>t[i]>>x[i]>>y[i];
    if(i==0)continue;
    double d=sqrt(pow(abs(x[i]-x[i-1]),2)+pow(abs(y[i]-y[i-1]),2));
    double tt=(f[i]-f[i-1])/60;
    //cout<<"debug: "<<d<<" "<<t<<endl;;
    if(t[i]==t[i-1]&&a[i]!=a[i-1]){
      if(t[i]==0&&(a_dis<d||(a_dis==d&&a_time>tt))){
	  a_dis=d;
	  a_time=tt;
      }
      
      if(t[i]==1&&(b_dis<d||(b_dis==d&&b_time>tt))){
	b_dis=d;
	b_time=tt;
      }
    } 
  }
  printf("%.6f %.6f\n",a_dis,a_time);
  printf("%.6f %.6f\n",b_dis,b_time);
  return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

void bfs(map<P,int>& mp, int &k, const int n, const Graph g) {
    vector<bool> used(n+1,false);
    vector<int> c(n+1,-1);
    queue<int> q;
    q.push(1);
    used[1] = true;

    while(!q.empty()) {
        int u = q.front(); q.pop();
        int cc = 1;
        for (auto v : g[u] ) {
            if (used[v]) continue;
            used[v] = true;
            q.push(v);
            if (cc == c[u]) cc++;
            c[v] = mp[P(u,v)] = cc++;
        }
        k = max(k, cc-1);
    }
    return ;
}

int main() {
    int n;
    int k = 0;
    cin >> n;

    Graph g(n+1);
    vector<P> edge;

    for (int i=0; i<n-1; i++) {
        int a,b;
        cin >> a >> b;
        if (a>b) swap(a,b);
        edge.push_back(P(a,b));
        g[a].push_back(b);
        g[b].push_back(a);
    }

    map<P,int> mp;
    bfs(mp, k, n, g);


    cout << k << endl;
    for (auto e : edge) {
        cout << mp[e] << endl;
    }
}

Measured memory_bytes: 17268
#include <iostream>

using namespace std;

int main(){
	char prev;
	char current;
	bool flag = false;

	cin >> current;

	for(int i = 1; i < 4; ++i){
		prev = current;
		cin >> current;

		if(prev == current){
			flag = true;
		}
	}

	if(flag){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}

}

Measured memory_bytes: 256
//A
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;

ll gcd_euclid(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

bool check(ll L,ll N,ll M, string S,string T){
	ll lmc = gcd_euclid(N,M);
	for(ll i(1);i<lmc;++i){
		if(S[i*N/lmc] != T[i*M/lmc]){
			return false;
		}
	}
	return true;
}

int main()
{
	ll N,M;
	cin >> N >> M;
	string S,T;
	cin >> S;
	cin >> T;
	if(S[0] != T[0]){
		 cout << -1 << endl;
		 return 0;
	}
	ll L(M/gcd_euclid(N,M)*N);
	if(check(L,N,M,S,T)){
		cout << L << endl;
		return 0;
	}
	cout << "-1" << endl;
	return 0;
}



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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		vector<pair<int,int>> v(n);
		int a = -inf , b = -inf , c=inf , d= inf;
		for(int i=0;i<n;++i)
		{
			cin>>v[i].first>>v[i].second;
			a = max(a,v[i].first+v[i].second);
			b = max(b,v[i].first-v[i].second);
			c = min(c,v[i].first+v[i].second);
			d  = min(d,v[i].first-v[i].second);
		}
		cout<<max(a-c,b-d);
			
    }
    return 0;
}


Measured memory_bytes: 6304
implicit none
integer :: N
integer, allocatable :: W(:)
integer :: i, ds, dsmin, s1, s2, T

read *,N
allocate(W(N))
read *, (W(i),i=1,N)

s2 = sum(W)

dsmin = s2
s1 = 0
do T = 1, N-1
   s1 = s1 + W(T)
   s2 = S2 - W(T)
   ds = abs(s1-s2)
   if (ds < dsmin) then
      dsmin = ds
   else
      exit  ! Once weight starts to increase, no longer consider.
   endif
enddo

write(6,'(i0)') dsmin
stop
end

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  int x[N][N];
  int y[N][N];

  for(int i=0; i<N; i++)
    {
      cin >> A[i];
      for(int j=0; j<A[i]; j++)
	  cin >> x[i][j] >> y[i][j];
    }
  
  int max = 0;
  vector<bool> table(1<<N, true);
  bool flag = true;
  for(int bit=0; bit<(1<<N); bit++)
    {
      flag = true;
      //cout << bit << endl;
 
      for(int i=0; i<N; i++)
	{
	  for(int j=0; j<A[i]; j++)
	    {
	      //cout << x[i][j]-1 << " " << y[i][j]<<endl;

	      if(((bit>>i) & 1) == 0)
		{
		  continue;
		}
	      else
		{
		  if(((bit >> (x[i][j]-1)) & 1)!=y[i][j])
		    {
		      //cout << "y-no" << endl;
		      flag = false;
		      table[bit]=false;
		      break;
		    }
		}
	    }
	  if(!flag)
	    break;
	}
    }
      
  int count = 0;
  int bibit=-1;
  for(int bit=0; bit<(1<<N); bit++)
    {
      count=0;
      if(table[bit])
	{
	  for(int i=0; i<N; i++)
	    {
	      if((1 & (bit>>i))==1)
		count++;
	    }
	  if(max<count)
	    {
	      max = count;
	      bibit=bit;
	    }
	}
    }
    


  cout << max << endl;
  //  cout << bibit << endl;
  
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0281
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = RInt();
            for (int i = 0; i < q; i++)
            {
                Console.WriteLine(CalcMaxCnt(RArInt()));
            }
        }

        private static int CalcMaxCnt(int[] v)
        {
            int carefulType = v.Min();
            for (int i = 0; i < v.Length; i++) v[i] -= carefulType;

            int quickType = Math.Min(v[0] / 2, v[1]);
            v[0] -= quickType * 2;
            v[1] -= quickType;

            int stableType = v[0] / 3;

            return carefulType + quickType + stableType;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18256
//C - Dubious Document 2
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

vector<string> a;

void create(string s,string t, int i){
    string tmp=s;
    //cout<<tmp<<endl;
    for(int j=0; j<t.size(); j++){
        if(s[i+j]==t[j] || s[i+j]=='?'){
            tmp[i+j]=t[j];
        }
        //cout<<j<<" : "<<tmp<<endl;
    }
    for(int j=0; j<s.size(); j++){
        if(tmp[j]=='?'){
            tmp[j]='a';
        }
    }
    a.push_back(tmp);
}

int main(){
    string s,t;
    
    cin>>s>>t;
    for(int i=0; i<s.size()-t.size()+1; i++){
        bool flag=true;
        for(int j=0; j<t.size(); j++){
            if(s[i+j]!=t[j] && s[i+j]!='?'){
                flag=false;
            }
        }
        if(flag){
            create(s,t,i);
        }
    }

    if(a.size()>0){
        sort(a.begin(),a.end());
        cout<<a[0]<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S    = input()

L = S.replace('01', '0,1')
L = L.replace('10', '1,0')
L = L.split(',')
L = [len(l) for l in L]

if S[0] == '0':
    L = [0] + L

R = []
for i in range(max(1, len(L) // 2 + 1 - K)):
    if i == 0:
        R.append(sum(L[2*i:2*(i+K)+1]))
    else:
        R.append(R[-1] - sum(L[2*(i-1):2*(i-1)+2]) + sum(L[2*(i+K)-1:2*(i+K)+1]))

print(max(R))


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
using namespace std;

int main(){
	int n;
	string bit;
	cin >> n >> bit;

	vector<int> node(2 * bit.size() - 1);
	for(int i = 0; i < bit.size(); ++i){
		node[i + bit.size() - 1] = bit[i] - '0';
	}
	
	map<int,int> tbl;
	tbl[0] = 0;
	tbl[1] = 1;
	int k = n;
	for(int i = bit.size() - 2; i >= 0; --i){
		int a = node[i * 2 + 1], b = node[i * 2 + 2];
		if(a == b){
			node[i] = a;
		}
		else{
			node[i] = tbl.insert(make_pair(a << 16 | b << 4 | k, tbl.size())).first->second;
		}

		if((i & (i + 1)) == 0){ --k; }
	}
	cout << tbl.size() - 2 << endl;
}

Measured memory_bytes: 1220
using System;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
       int[]A = new int[N];
       for (int i = 0; i < N; i++)
       {
           A[i] = sc.NextInt();
       }

       int max = -1;
       int second = -1;
       var cp = A.ToArray();
       Array.Sort(cp);
       max = cp[N - 1];
       second = cp[N - 2];

       var sb = new StringBuilder();

       foreach (int i in A)
       {
           if (i == max)
           {
               sb.AppendLine(second.ToString());
           }
           else
           {
               sb.AppendLine(max.ToString());
           }
       }
       Console.Write(sb.ToString());
    }
}


class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


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

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

int main() {
	ll n;
	cin >> n;
	vector<ll> mp(5);
	rep(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'M') mp[0]++;
		if (s[0] == 'A') mp[1]++;
		if (s[0] == 'R') mp[2]++;
		if (s[0] == 'C') mp[3]++;
		if (s[0] == 'H') mp[4]++;
	}
	ll ans = 0;
	for (int i = 0; i < 5; ++i) {
		for (int j = i + 1; j < 5; ++j) {
			for (int k = j + 1; k < 5; ++k) {
				ans += mp[i] * mp[j] * mp[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
l = input().split()
W = int(l[0])
H = int(l[1])
x = int(l[2])
y = int(l[3])
r = int(l[4])
if x-r <0 or x + r > W or y - r <0 or y + r > H :
    print("No")
else :
    print("Yes")


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) 
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,h[100005],g;ll a,b;
bool check(ll k)
{
    ll cnt=0;
    rep(i,1,n)
    cnt+=max((h[i]-k*b+a-b-1)/(a-b),0ll);
    return cnt<=k;
}
int main()
{
    scanf("%d%lld%lld",&n,&a,&b);
    rep(i,1,n) scanf("%d",h+i),g=max(g,h[i]);
    ll l=1,r=g;
    while(l<r){
        ll mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    printf("%lld\n",l);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A;
    int B;
    cin >> A >> B;
    if(A < 10 & B < 10) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	int n;
	cin >> n;

	vi T(n);
	REP(i, n) cin >> T[i];

	int m;
	cin >> m;
	REP(i, m) {
		int p, x;
		vi vec = T;
		cin >> p >> x;
		p--;

		vec[p] = x;
		int sum = 0;
		REP(i, n) sum += vec[i];
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s=input()
st=s[0]
if s[1]==st:
  if s[2]!=s[1] and s[2]==s[3]:
    print("Yes")
  else:
    print("No")
elif s[2]==st:
  if s[1]==s[3] and s[1]!=st:
    print("Yes")
  else:
    print("No")
elif s[3]==st:
  if s[1]==s[2] and s[1]!=st:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
		}

		long l = 0;
		long r = 0;

		Arrays.sort(a);

		for (int i = n - 1; i >= 1; i--) {
			if (l == 0) {
				if (a[i] == a[i - 1]) {
					l = a[i];
					i--;
				}
			} else {
				if (a[i] == a[i - 1]) {
					r = a[i];
					break;
				}
			}
		}

		System.out.println(l * r);

	}

}


Measured memory_bytes: 47668
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,A,B; cin >> N >> A >> B;
    if (A + B > N+1) {
        cout << -1 << endl;
        return 0;
    }
    if (A == 1) {
        if (B != N) {
            cout << -1 << endl;
            return 0;
        } else {
            rep(i,N) cout << N-i << " ";
            cout << endl;
            return 0;
        }
    }
    if (B == 1) {
        if (A != N) {
            cout << -1 << endl;
            return 0;
        } else {
            rep(i,N) cout << i+1 << " ";
            cout << endl;
            return 0;
        }
    }
    int K = (N+A-1) / A;
    if (K > B) {
        cout << -1 << endl;
        return 0;
    }
    int L,R;
    rep(i,N+1) {
        if (B == N-i+(i+A-2)/A) {
            R = i;
            L = N - R;
        }
    }
    vector<int> ans(R);
    int num = A;
    int val = 1;
    rep(_,R) {
        ans[--num] = val++;
        if (num%A == 0) num = min(R,num+A*2);
    }
    rep(i,L) ans.emplace_back(val++);
    reverse(all(ans));

    rep(i,N) cout << ans[i] << " ";
    cout << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> av;
	int sum = 0;
	rep(i,n) {
		int a;
		cin >> a;
		av.push_back(a);
		sum += a;
	}
	sor(av);
	rep(i,m) {
		if((double)sum/(double)(4*m) > av.at(n-i-1)){
				cout << "No" << endl;
				return 0;
		}
	}
	cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256