akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int r, g, b;
	scanf("%d%d%d", &r, &g, &b);
	if ((100 * r + 10 * g + b) % 4 == 0) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;

}

Measured memory_bytes: 128
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

optimize();
float n,x,t;
cin>>n>>x>>t;
float y=ceil(n/x);
cout<<int(y*t)<<endl;




over
}


Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long big=0,n,count=0;
	cin >> n;
	vector<long long>h(n);
	for (long long i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (long long i = 0; i < n-1; i++) {
		if (h[i + 1] - h[i] > 0) {
			if (big < count) {
				big = count;
			}
			count = 0;
		}
		else {
			count++;
		}
	}
	cout << max(count,big) << endl;
}

Measured memory_bytes: 1024
let rec seq a b = if a > b then [] else a :: seq (a+1) b
let () =
  Scanf.scanf "%d" @@ fun n ->
  let p = Array.init n (fun _ -> Scanf.scanf " %f" ((+.) 0.)) in
  let dp = Array.init (n+1) (fun _ -> Array.make (n+1) 0.) in
  dp.(0).(0) <- 1.0;
  for x = 1 to n do
    for y = 0 to x do
      dp.(x).(y) <- dp.(x).(y) +. dp.(x-1).(y) *. (1. -. p.(x-1));
      if y > 0 then dp.(x).(y) <- dp.(x).(y) +. dp.(x-1).(y-1) *. p.(x-1);
    done;
  done;
  seq (n/2+1) n |> List.fold_left (fun s i -> s +. dp.(n).(i)) 0.0
  |> Printf.printf "%.15f\n"

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

int main(){
  int N;
  cin >> N;
  vector<int64_t> L(N+1);
  
  if(N==1){
    L.at(N) = 1;
  } else {
    L.at(0) = 2;
    L.at(1) = 1;
    for(int i=2;i<=N;i++){
      L.at(i) = L.at(i-1) + L.at(i-2);
    }
  }
  
  cout << L.at(N) << endl;
}
  

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        long k = sc.nextLong();
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'a' || 'z' - s[i] + 1 > k) {
                continue;
            }
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
        char c = s[s.length - 1];
        if (k > 0) {
            k %= 26;
            s[s.length - 1] = (char) (s[s.length - 1] + k);
        }
        System.out.println(new String(s));
    }

}


Measured memory_bytes: 27192
#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>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int X, N;
  cin >> X >> N;
  vector<bool> Pset(101,1);
  rep(i, N){
    int p;
    cin >> p;
    Pset[p] = 0;
  }

  int ans;
  int i=0;
  bool h=1;
  while(h){
    if (Pset[X+i] == 1){
      ans = X+i;
      h = 0;
    }
    if (Pset[X-i] == 1){
      ans = X-i;
      h = 0;
    }
    i++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i,n) cin >> a.at(i) >> b.at(i);
	ll x=1,y=1;
	rep(i,n){
		ll k=max((x+a.at(i)-1)/a.at(i),(y+b.at(i)-1)/b.at(i));
		x=k*a.at(i);
		y=k*b.at(i);
	}
	cout << x+y << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const int inf = 0x3f3f3f3f;
int mindist[100005];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	rep(i, 0, 100005) mindist[i] = inf;
	
	int k; read(k);
	pq.push({0, 0});

	while (!pq.empty()) {
		int md, node;
		tie(md, node) = pq.top(); pq.pop();
		if (md > mindist[node]) continue;
		rep(i, 0, 10) if (i != 0 || node != 0) {
			int newnode = (node * 10 + i) % k;
			if (chmin(mindist[newnode], md + i)) {
				pq.push({mindist[newnode], newnode});
			}
		}
	}

	die(mindist[0]);


}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    
    
   char pp;
   cin>>pp;
   
   if(pp=='A')
   cout<<"T";
   
   if(pp=='T')
   cout<<"A";
   
   if(pp=='C')
   cout<<"G";
   if(pp=='G')
   cout<<"C";
 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn=1e5+100;
int n,vis[maxn],par[maxn];
vector<int>g[maxn];
vector<pair<int,int>>Vec;
map<pair<int,int>,int>mp;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].emplace_back(y);
        g[y].emplace_back(x);
        Vec.emplace_back(x,y);
    }
    int K=0;
    queue<int>que;
    que.push(1);
    vis[1]=1;
    while(!que.empty()){
        int u=que.front(); que.pop();
        if(K<g[u].size()) K=g[u].size();
        int cur=1;
        for(auto v:g[u]){
            if(vis[v]) continue;
            if(cur==par[u]) cur++;
            par[v]=mp[make_pair(u,v)]=mp[make_pair(v,u)]=cur++;
            vis[v]=1;
            que.push(v);
        }
    }
    printf("%d\n",K);
    for(auto p:Vec) printf("%d\n",mp[p]);
    return 0;
}

Measured memory_bytes: 20084
L, R = gets.split.map(&:to_i)
 
ans = 2019
 
L.upto(R-1) do |i|
  (i+1).upto(R) do |j|
    mod = (i * j) % 2019
    if mod == 0
      puts 0
      exit
    end
 
    ans = mod if mod < ans
  end
end
 
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
bool ss(int n){
	if(n<=1) return false;
	if(n==2||n==3) return true;
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main(){
	int i,n,j=0,k,o;
	scanf("%d",&o);
	while(o--){
		scanf("%d",&n);
		if(ss(n)){
			j++;
		}
	}
	printf("%d\n",j);
} 


Measured memory_bytes: 2616
#!/usr/bin/env ruby

n, a, b = gets.strip.split(' ').map(&:to_i)

sum = 0
(1..n).each do |i|
  t_sum = i.to_s.chars.reduce(0) { |s, c| s += c.to_i }
  sum += i if t_sum.between?(a, b)
end
puts sum


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


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

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

    int sn = 0;
    int tmp = n;

    while(tmp > 0){
        sn += tmp%10;
        tmp /= 10;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std ;
int a[50] ,flag , l , r  ;
void dfs(int x , int l , int r)
{
    if(x==11) return ;
    if(a[x]>l) dfs(x+1,a[x],r);
    else if(a[x]>r) dfs(x+1,l,a[x]);
    else
    {
        flag = 1 ;
        return;
    }
}
int main()
{
    int t ;
    cin>>t;
    while(t--)
    {
        flag = 0 ;
        for(int i = 1 ; i<=10;i++)
        {
            cin>>a[i];
        }
        dfs(1,0,0);
        if(flag) printf("NO\n");
        else printf("YES\n");
    }
    return 0 ;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int a, b;
void solve() {
    cin >> a >> b;

    cout << max(0, a - 2 * b) << endn;
}

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


Measured memory_bytes: 256
N,M,S,T = map(int,input().split())
S,T = S-1,T-1
UVAB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for u,v,a,b in UVAB:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))

import heapq
INF = float('inf')
ycost = [INF] * N
ycost[S] = 0
q = [(0,S)]
heapq.heapify(q)
while q:
    c,v = heapq.heappop(q)
    for to,a,b in es[v]:
        if c+a >= ycost[to]: continue
        ycost[to] = c+a
        heapq.heappush(q, (c+a,to))

scost = [INF] * N
scost[T] = 0
q = [(0,T)]
heapq.heapify(q)
while q:
    c,v = heapq.heappop(q)
    for to,a,b in es[v]:
        if c+b >= scost[to]: continue
        scost[to] = c+b
        heapq.heappush(q, (c+b,to))

a = 0
ans = []
for y,s in zip(ycost[::-1],scost[::-1]):
    tmp = 10**15 -y -s
    a = max(a, tmp)
    ans.append(a)
print(*ans[::-1], sep='\n')

Measured memory_bytes: 74352
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

int main()
{
    std::string s;

    std::cin >> s;

    std::vector<long> children_num(s.length(), 0);
    for (int direction = 0; direction < 2; direction++) {
        long count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == 'R') {
                count++;
            } else {
                children_num[i - 1] += (count + 1) / 2;
                children_num[i] += count / 2;
                count = 0;
            }
        }
        std::reverse(children_num.begin(), children_num.end());
        std::reverse(s.begin(), s.end());

        for (int i = 0; i < s.length(); i++) {
            s[i] = (s[i] == 'R') ? 'L' : 'R';
        }
    }

    for (auto i : children_num) {
        std::cout << i << " ";
    }
    putchar('\n');
}


Measured memory_bytes: 1408
N = int(input())

c = list(input())

cnt = 0
headcnt = 0
tailcnt = -1

Noflag = 0

while True:
    if c[tailcnt] == 'R' and Noflag == 0:
        while True:
            if c[headcnt] == 'W':
                c[headcnt], c[tailcnt] = c[tailcnt], c[headcnt]
                cnt += 1
                # headcnt += 1
                # tailcnt -= 1
                break
            else:
                headcnt += 1
                if headcnt + abs(tailcnt) >= len(c):
                    Noflag += 1
                    break
    elif c[tailcnt] == 'W' or Noflag == 1:
        tailcnt -= 1
        if headcnt + abs(tailcnt) >= len(c):
            print(cnt)
            break


Measured memory_bytes: 10732
#include <bits/stdc++.h>
using namespace std;
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> pii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<pii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
ll mod = 1e9 + 7;
ll t=1;

vvi adj;
ll n,m,x,y,h,w;
// vi dp,vis;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cin>>t;
    while(t--){
        cin>>h>>w;
        char s[h][w];
        int dp[h][w]={0};
        dp[0][0]=1;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>s[i][j];
            }
        }
        
        // for(int i=0;i<h;i++){
        //     for(int j=0;j<w;j++){
        //         cout<<s[i][j];
        //     }
        //     cout<<"\n";
        // }
        
    for(int i=1;i<w;i++){
        if(s[0][i]=='#')dp[0][i]=0;
        else dp[0][i] = dp[0][i-1];
    }
    for(int i=1;i<h;i++){
        if(s[i][0]=='#')dp[i][0]=0; 
        else dp[i][0] = dp[i-1][0];
    }

    for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
        if(s[i][j]=='#'){dp[i][j]=0;continue;}
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
        // for(int i=0;i<h;i++){
        //     for(int j=0;j<w;j++){
        //         cout<<dp[i][j]<<" ";
        //     }
        //     cout<<"\n";
        // }
        
        cout<<dp[h-1][w-1];
}

    return 0;
}    

Measured memory_bytes: 5120
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=0,b=0;
	while(1){
		if(s.substr(0,6)=="eraser"){
			s.erase(0,6);
			a++;
			}
		
		else if(s.substr(0,5)=="erase"){
			s.erase(0,5);
			a++;
			}
		
		else if(s.substr(0,7)=="dreamer"){
			if(s.substr(5,6)=="eraser"){
				s.erase(5,6);
				continue;
				}
				else if(s.substr(5,5)=="erase"){
				s.erase(5,5);
				continue;
				}
			s.erase(0,7);
			a++;
		}
		else if(s.substr(0,5)=="dream"){
			s.erase(0,5);
			a++;
			}
		if(a==b){
			cout<<"NO"<<endl;
			return 0;
			}
			b=a;
		if(s.size()==0){
			cout<<"YES"<<endl;
			return 0;
			}
		}
}
 

Measured memory_bytes: 512
/*
*
*  アルゴリズム bit全検索
*  https://atcoder.jp/contests/abc079/tasks/abc079_c
*  この問題を使ってbit全検索を練習します。
*
*/

#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;

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

    vector<int> c(4);

    for(int i = 0;i < s.length();i++) c[i] = s[i] - '0';

    int res; // 計算結果
    string res_sentence; //出力用

    for (int i = 0; i < (1 << 3) ;i++){
        res = c[0];
        res_sentence = to_string(c[0]); 

        for(int j = 0;j < 3;j++){
            // 右からj番目の値が1であれば+ 0であれば-
            if(i & (1 << j)){
                res = res + c[j+1];
                res_sentence = res_sentence + '+' + to_string(c[j+1]);
            }else{
                res = res - c[j+1];
                res_sentence = res_sentence + '-' + to_string(c[j+1]);
            }
        }

        if(res == 7){
            cout << res_sentence << "=7" << endl;
            return 0;
        }

    }
    // 問題の仕様上ここにはたどり着かないはず
    return -1;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(){
    int i,j,l[100];
    char m[100],s[101];
    ll k,sum=0;

    scanf("%s",s);
    scanf("%lld",&k);

    m[0] = s[0]; l[0] = 1;
    for(i=1,j=0;s[i] != '\0';i++){
        if(s[i] == s[i-1]){
            l[j]++;
        }else{
            j++;
            m[j] = s[i];
            l[j] = 1;
        }
    }

    if(j == 0){
        sum = l[0]*k /2;
    }else{
        for(i=1;i<j;i++)
            sum += l[i]/2;
        sum *= k;

        if(m[j] == m[0]){
            sum += l[0]/2;
            sum += l[j]/2;
            sum += (l[0]+l[j])/2 * (k-1);
        }else{
            sum += l[0]/2 * k;
            sum += l[j]/2 * k;
        }
    }
    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll h,w;

int main(){
	cin>>h>>w;
	ll ans=(h<w)?h:w;
	if(h%3==0||w%3==0)
		ans=0;
	for(ll i=1;i<h;i++){
		ll a=i*w;
		ll b=(h-i)*(w/2);
		ll c=(h-i)*(w-w/2);
		
		ll aa=abs(a-b);
		ll bb=abs(b-c);
		ll cc=abs(c-a);
		ll min=max(max(aa,bb),cc);
		ans=min(ans,min);
	}
	
	for(ll i=1;i<w;i++){
		ll a=i*h;
		ll b=(w-i)*(h/2);
		ll c=(w-i)*(h-h/2);
		
		ll aa=abs(a-b);
		ll bb=abs(b-c);
		ll cc=abs(c-a);
		ll min=max(max(aa,bb),cc);
		ans=min(ans,min);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String s = in.next();
        String t = in.next();
        int [][]arr = new int[s.length()+1][t.length()+1];
        for(int i=0;i<s.length();i++){
            for(int j=0;j<t.length();j++){
                if(s.charAt(i)==t.charAt(j)) arr[i+1][j+1] =arr[i][j]+1;
                else arr[i+1][j+1]= Math.max(arr[i][j+1],arr[i+1][j]);
            }
        }
        int i = s.length();int j = t.length();
        String text = "";
        int cur = arr[s.length()][t.length()];
        while (cur>0){
            if (arr[i-1][j]==cur){
                i--;
            }
            else if(arr[i][j-1]==cur){
                j--;
            }
            else {
                text= t.charAt(j-1)+text;
                i--;
                j--;
                cur--;
            }
        }
        System.out.println(text);
    }
}


Measured memory_bytes: 83356
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

struct UnionFind{
    vector<int> par,rank;
    
    //初期化
    UnionFind(int n){
        for(int i=0;i<=n;++i){
            par.push_back(i);
            rank.push_back(0);
        }
    }

    //根をFind
    int find(int i){
        if(par[i]==i)return i;

        return par[i]=find(par[i]);
    }

    //Union
    void unite(int x,int y){
        int rx=find(x);
        int ry=find(y);

        if(rx==ry)return;

        if(rank[rx]>rank[ry])par[ry]=rx;
        else{
            par[rx]=ry;
            if(rank[rx]==rank[ry])
                rank[ry]++;
        }
    }

    //同じ木に属するか判定
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int N,K,L;cin>>N>>K>>L;
    UnionFind UF1(N),UF2(N);
    for(int k=0;k<K;k++){
        int p,q;cin>>p>>q;
        UF1.unite(p,q);
    }
    for(int l=0;l<L;l++){
        int r,s;cin>>r>>s;
        UF2.unite(r,s);
    }
    pair<int,int> P[200010];
    map<pair<int,int>,int> mp;
    for(int i=1;i<=N;i++){
        P[i]={UF1.find(i),UF2.find(i)};
        mp[P[i]]++;
    }
    for(int i=1;i<=N;i++)
        cout<<mp[P[i]]<<endl;

    return 0;
}

Measured memory_bytes: 17428
#include<cstdio>

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if(a + b == 15) {
		printf("+\n");
	} else if(a * b == 15) {
		printf("*\n");
	} else {
		printf("x\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) P(0);
  else P(1);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
long long n,a[100][100],F[25][3000005];
long long DP(long long i,long long used)
{
    if (i==n) return 1;
    if (F[i][used]>-1) return F[i][used];

    long long &res=F[i][used];
    res=0;
    for (int j=0;j<=n-1;j++) {
        if (a[i][j]==0 || ((used>>j) & 1)) continue;
        res=(res+DP(i+1,used | (1<<j)))%1000000007;
    }
    return res;
}

int main()
{
    //freopen("MATCHING.INP","r",stdin);
    //freopen("MATCHING.OUT","w",stdout);
    cin>>n;
    for (int i=0;i<=n-1;i++)
        for (int j=0;j<=n-1;j++)
            cin>>a[i][j];

    for (int i=0;i<=n-1;i++)
        for (int j=0;j<=3000000;j++)
            F[i][j]=-1;
    cout<<DP(0,0);
    return 0;
}


Measured memory_bytes: 495772
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll a[N];


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    ll n;
    map<ll,ll> f;
    cin>>n;
    foo(i,2,n)cin>>a[i];
    foo(i,2,n){
        f[a[i]]++;
    }

    foo(i,1,n)cout<<f[i]<<"\n";
    
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 22384
#include<bits/stdc++.h>
using namespace std;
long long d,f;
int main() {
	long long n,i;
	cin>>n;
	i=sqrt(n)+1;
	while(i>=1) {
		i-=1;
		if((double)n/i==floor((double)(n/i)) && (double)n/i==ceil((double)(n/i))) {
			long long x=i,y=n/i;
			while(x!=0) {
				d++;
				x/=10;
			}
			while(y!=0) {
				f++;
				y/=10;
			}
			cout<<max(d,f);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int ans = INF;
  REP(i, s.length()-2) {
    string temp = "";
    FOR(j, i, i+3) temp += s[j];
    int aa = stoi(temp);
    if (abs(aa-753) < abs(ans-753)) ans = aa;
  }
  cout << abs(ans-753) << "\n";
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
arr = input()

# ランレングス圧縮
compressed = []
curr = ""
for x in arr:
    if curr != x:
        compressed.append(x)
        curr = x

# 境界の個数はランレングス圧縮後の文字数 - 1
boundary = len(compressed) - 1

# 2個ずつ圧縮可能
x = max(0, boundary - 2 * k)

print(n - 1 - x)

Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	int N, Q; cin >> N >> Q;
	vector<int>a(N); rep(i, 0, N)cin >> a[i];
	rep(i, 0, Q) {
		int x; cin >> x;
		int ans(0), l(0), sum(0);
		rep(j, 0, N) {
			sum += a[j];
			while (sum > x)sum -= a[l++];
			ans += j - l + 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
const int N=500,mod=998244353;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
int dp[N][N],n,ans,jc[N],jc2[N],f[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	jc[0]=jc2[0]=1;
	for(int i=1;i<N;++i){
		jc[i]=(ll)jc[i-1]*i%mod;
		jc2[i]=ksm(jc[i],mod-2);
	}
	dp[0][0]=1;
	int sum1=0,sum2=0;
	for(int i=0;i<n;++i){
		int x,y;cin>>x>>y;--y;
		int pw=mod-1;
		for(int j=0;j<=y;++j,pw=(ll)pw*x%mod)f[j]=(ll)pw*jc2[j]%mod;
		for(int j=sum1;j>=0;--j)
			for(int k=0;k<=sum2;++k)if(dp[j][k])
				for(int l=0;l<=y;++l)dp[j+x][k+l]=(dp[j+x][k+l]+(ll)dp[j][k]*f[l])%mod;
		sum1+=x;sum2+=y;
	}
	for(int i=0;i<=sum1;++i){
		int invi=ksm(i,mod-2),pw=invi;
		for(int j=0;j<=sum2;++j,pw=(ll)pw*invi%mod)ans=(ans+(ll)pw*dp[i][j]%mod*jc[j])%mod;
	}
	ans=(ll)ans*sum1%mod;ans=(mod-ans)%mod;
	cout<<ans<<'\n';
	return 0;
}


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

int main() {
	string S; cin >> S;
	char al[26];
	for(int i=0; i<26; ++i) al[i] = 'a' + i;
	bool ac=true, sm;
	int C=0;
	if(S[0]!='A') ac=false;
	else{
	    for(int i=1; i<S.size(); ++i){
	        if(S[i]=='C'){
	            if(C==0 && i>1 && i+1!=S.size()) C=i;
	            else{
	                ac=false;
	                break;
	            }
	        }
	        else{
	            sm=true;
	            for(int j=0; j<26; ++j) if(S[i]==al[j]) sm=false;
	            if(sm){
	                ac=false;
	                break;
	            }
	        }
	    }
	}
	if(C==0) ac=false;
	if(ac) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int mp[35][35],smp[35][35],n,SUM,W,H;
P mem[35][35][35][35];
int used[35][35][35][35];

int cal(int x1,int y1,int x2,int y2){
  return smp[y2][x2]-(smp[y1-1][x2]+smp[y2][x1-1])+smp[y1-1][x1-1];
}

P dfs(int x,int y,int w,int h){
  
  if(used[x][y][w][h]++) return mem[x][y][w][h];

  P res=P(1,n-(SUM-cal(x,y,w,h)));
  for(int i=x;i!=w;i++){
    int m=max(SUM-cal(x,y,i,h),SUM-cal(i+1,y,w,h));
    if(m<=n){
      P a=dfs(x,y,i,h);
      P b=dfs(i+1,y,w,h);
      res=max(res,P((a.f+b.f),min(a.s,b.s)));
    }
  }

  for(int i=y;i!=h;i++){
    int m=max(SUM-cal(x,y,w,i),SUM-cal(x,i+1,w,h));
    if(m<=n){
      P a=dfs(x,y,w,i);
      P b=dfs(x,i+1,w,h);
      res=max(res,P((a.f+b.f),min(a.s,b.s)));
    }
  }
  return mem[x][y][w][h]=res;
}

int main(){
  while(1){
  cin>>H>>W>>n;
  if(!H&&!W&&!n)break;

  memset(mp,0,sizeof(mp));
  memset(smp,0,sizeof(smp));
  memset(used,0,sizeof(used));
  memset(mem,0,sizeof(mem));

  for(int i=1;i<=H;i++)
    for(int j=1;j<=W;j++)cin>>mp[i][j],smp[i][j]=mp[i][j];

  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++) smp[i][j+1]+=smp[i][j];
  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++) smp[i+1][j]+=smp[i][j];
  SUM=smp[H][W];
  P ans=dfs(1,1,W,H);
  cout <<ans.first<<" "<<ans.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 18780
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
 
import itertools
 
#import bisect
 
import copy
 
 
def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
 
def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta
 
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
 
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
 
 
 
def main():
    h,n=map(int,input().split()) #n yen, m types
    a=[]
    b=[]
    for i in range(n):
        x,y=map(int,input().split())
        a.append(x)
        b.append(y)
 
    dp=[INFI for i in range(h+1)]
    dp[0]=0
    for i in range(n):
        for j in range(len(dp)):
            if j-a[i]<0:
                dp[j] = min(dp[j], dp[0] + b[i])
            else:
                dp[j]=min(dp[j],dp[j-a[i]]+b[i])
 
    print(dp[h])
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 40944
# coding: utf-8
# Your code here!
def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization
    
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n,a = [int(i) for i in readline().split()]
#n,x = [int(i) for i in readline().split()]
n = int(input())

from collections import defaultdict
d = defaultdict(int)

for i in range(1,n+1):
    l = prime_factorize(i)
    for p,e in l:
        d[p] += e


l = sorted([i for i in d.values() if i > 1])

#print(l)
ans = 0

def f(x): return len([i for i in l if i >= x-1])

ans += f(75)
ans += f(25)*(f(3)-1)
ans += f(15)*(f(5)-1)
ans += f(5)*(f(5)-1)//2*(f(3)-2)

print(ans)




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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void solver() {
    i64 n = input();
    auto cnt = prime_factor(n);

    int max_m = 0;
    for (auto p: cnt) {
        chmax(max_m, p.second);
    }

    vector< int > dp(max_m + 1, -1);
    dp[0] = 0;

    range(d, 1, max_m + 1) {
        rrange(i, d, max_m + 1) {
            if (dp[i - d] == -1) continue;
            chmax(dp[i], dp[i - d] + 1);
        }
    }

    int ans = 0;
    for (auto p: cnt) {
        ans += dp[p.second];
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int n;
ll ans;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	ans=1ll*n*(n+1)/2;
	int t=n/3;
	ans-=3ll*t*(t+1)/2;
	t=n/5;
	ans-=5ll*t*(t+1)/2;
	t=n/15;
	ans+=15ll*t*(t+1)/2;
	print(ans);
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
struct dice{
    int val[6];
    void in(){
        for(int i=0;i<6;i++)scanf("%d",&val[i]);
        return ;
    }
    void spin(){
        int temp=val[1];
        val[1]=val[2];
        val[2]=val[4];
        val[4]=val[3];
        val[3]=temp;
        return ;
    }
    void change(){
        int temp=val[0];
        val[0]=val[1];
        val[1]=val[5];
        val[5]=val[4];
        val[4]=temp;
        return ;
    }
    bool operator ==(const dice &a){
        for(int i=0;i<6;i++)if(a.val[i]!=val[i])return false;
        return true;
    }
};
int main(){
    dice a,b;
    a.in();
    b.in();
    for(int k=0;k<4;k++){
        a.spin();
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++)if(a==b){
            printf("Yes\n");
            return 0;
        }
        else a.spin();
        a.change();
    }
    }
    printf("No\n");
}



Measured memory_bytes: 2700
#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 n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p.at(i);
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,k){
        ans+=p.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
n = gets.to_i
a = gets.split.map(&:to_i)

ans_even = 0
sum = 0
a.each_with_index do |ai, i|
    sum += ai
    if (i.even? && sum <= 0)
        ans_even += 1 - sum
        sum = 1
    elsif (i.odd? && sum >= 0)
        ans_even += 1 + sum
        sum = -1
    end
end

ans_odd = 0
sum = 0
a.each_with_index do |ai, i|
    sum += ai
    if (i.odd? && sum <= 0)
        ans_odd += 1 - sum
        sum = 1
    elsif (i.even? && sum >= 0)
        ans_odd += 1 + sum
        sum = -1
    end
end
puts [ans_even, ans_odd].min

Measured memory_bytes: 8580
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define ps push_back 
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	string s;
	set<string>a;
	rep0(i, n - 1) {
		cin >> s;
		a.insert(s);
	}
	if (a.size() == 4)
		cout << "Four" << endl;
	else
		cout << "Three" << endl;
	return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    bool ok = true;
    if(N%2) ok = false;
    for(int i=0; i<N/2; i++) if(S[i] != S[i+N/2]) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll n, d;
    cin >> d >> n;
    ll a = 1;
    for (ll i = 0; i < d; i++)
    {
        a *= 100;
    }

    if(n==100)
        n++;

    ll temp = a;
    for (ll i = 0; i < n - 1; i++)
    {
        a += temp;
    }

    cout << a << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	var n int
	n = nextInt()

	a, b := make([]string, n), make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = nextStr()
		b[i] = a[i]
	}

	ansB, ansS := bubbleSort(a, n), selectionSort(b, n)
	msgB, msgS := "Stable", "Stable"
	for j := 0; j < n; j++ {
		if ansB[j] != ansS[j] {
			msgS = "Not stable"
			break
		}
	}

	printSlice(ansB)
	fmt.Println(msgB)
	printSlice(ansS)
	fmt.Println(msgS)
}

func printSlice(s []string) {
	length := len(s)
	for i, v := range s {
		if i == length-1 {
			fmt.Printf("%s\n", v)
		} else {
			fmt.Printf("%s ", v)
		}
	}

}

func bubbleSort(a []string, n int) []string {
	left := 0
	ans := 0
	for left < n-1 {
		for i := n - 1; i >= left+1; i-- {
			v := a[i]
			if v[1] < a[i-1][1] {
				a[i] = a[i-1]
				a[i-1] = v
				ans++
			}
		}
		left++
	}
	return a
}

func selectionSort(a []string, n int) []string {
	for i := 0; i < n-1; i++ {
		mini := i

		for j := i; j < n; j++ {
			if a[mini][1] > a[j][1] {
				mini = j
			}
		}
		minv := a[mini]
		a[mini] = a[i]
		a[i] = minv

	}
	return a
}



Measured memory_bytes: 1124
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 
#define pll pair<ll,ll>

const ll M = (ll)(1e9+7);

void solve()
{
   string k;
   int d;
   cin>>k>>d;
   vector<vl> dp(d,vl(2,0));
   int in = k[0]-'0';
   f(i,0,in+1)
   {
      int state = (i<in);
      dp[i%d][state]++;
   }
   f(i,1,k.length())
   {
      vector<vl> dp2(d,vl(2,0));
      f(sum,0,d)
      {
         f(state,0,2)
         {
            f(j,0,10)
            {
               if(j>k[i]-'0' && state==0)break;

               dp2[(sum+j)%d][state|| (j<k[i]-'0')]+=(dp[sum][state]);
               dp2[(sum+j)%d][state|| (j<k[i]-'0')]%=M;
            }
         }
      }
      dp = dp2;
   }
   cout<<(dp[0][0] + dp[0][1]-1+M)%M;
}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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















int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> ok(n + 2, true);
    REP(i, m){
        ll a;
        cin >> a;
        ok[a] = false;
    }
    vector<ll> dp(n + 2);
    dp[0] = 1;
    REP(i, n){
        if(ok[i + 1]){
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if(ok[i + 2]){
            dp[i + 2] += dp[i]; 
            dp[i + 2] %= MOD;
        }
    }
    cout << dp[n] << endl;
}

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

int main()
{
  int a,b,ab;

  while(scanf("%d%d",&a,&b)!=EOF){
    ab=a+b;
    int count=0;
    while(1){
      ab/=10;
      if(ab==0)break;
      count++;
    }
    printf("%d\n",count+1);
  }
  return 0;
}

Measured memory_bytes: 1028
from collections import deque
from copy import deepcopy


def solve():
    H, W = map(int, input().split())
    maze = [[-2 for _ in range(W)] for _ in range(H)]
    s_point = []
    for i in range(H):
        line = input()
        for j in range(W):
            if line[j] == '#':
                maze[i][j] = -1
            else:
                s_point.append((i, j))

    dyx = [[-1, 0], [0, 1], [1, 0], [0, -1]]
    N = len(s_point)
    ans = 0
    for i in range(N):
        ans_tmp = 0
        maze_tmp = deepcopy(maze)
        sy, sx = s_point[i]
        maze_tmp[sy][sx] = 0
        que = deque([[sy, sx]])
        while que:
            cy, cx = que.popleft()
            for j in range(4):
                ny, nx = cy + dyx[j][0], cx + dyx[j][1]
                if 0 <= ny <= H - 1 and 0 <= nx <= W - 1:
                    if maze_tmp[ny][nx] == -2:
                        maze_tmp[ny][nx] = maze_tmp[cy][cx] + 1
                        ans_tmp = max(ans_tmp, maze_tmp[ny][nx])
                        que.append([ny, nx])
        ans = max(ans, ans_tmp)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 50268
def spritarr(arr):
  ret=[]
  for i in range(arr.count(0)):
    pos=arr.index(0)
    ret.append(arr[:pos])
    arr=arr[pos+1:]
  if len(arr)!=0:
    ret.append(arr)
  return ret

n=int(input())
arr=list(map(int,input().split()))
tmp=spritarr(arr)
ans=0
while len(tmp)!=0:
  tmp2=[]
  for i in range(len(tmp)):
    if len(tmp[i])!=0:
      tm=min(tmp[i])
      ans+=tm
      for j in range(len(tmp[i])):
        tmp[i][j]-=tm
    tmp2.extend(spritarr(tmp[i]))
  tmp=tmp2
print(ans)

Measured memory_bytes: 3064