akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a) for(ll i=a;i>=0;i--)
ll mod=1e9+7;
/*ll power(ll x,ll n)
{
    ll ans=1;
    while(n)
    {
       if(n&1)
       ans=(ans*x)%mod;
       n>>=1;
       x=(x*x)%mod;
    }
   // ans%=mod;
    return ans;
}
/*
struct comp {
    bool operator()(const pair& x, const pair& y) const {
        if (x.second != y.second)
            return x.second < y.second;

        return x.first < y.first;
    }
};
void dfs(int source,vector<int> graph[],vector<int> &path,bool status[])
{
 path.push_back(source);
 status[source]=0;
 //int j=graph[source].size();
 for(int i=0;i<graph[source].size();i++)
 {
     if(status[graph[source][i]]==1)
     dfs(graph[source][i],graph,path,status);
 }
 return;
}*
bool solve(int i,int j,string s)
{
    while(i<j)
    {
      if(s[i]<s[j])
      return 0;
      if(s[i]>s[j])
      return 1;
      i++;
      j--;
    }
    return 1;
}
bool isprime(ll x)
{
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
        return 0;
    }
    return 1;
    
}
ll lg(ll x,ll n)
{
    ll ans=0;
    while(x/n!=0)
    {
        ans++;
        x/=n;
    }
    return ans;
}*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,q,t,y,x,k1,i1,j1,z,x1,y1,m,d,p;
     cin>>n;
     ll a[n];
     rep(i,0,n)cin>>a[i];
     ll ans=0;
     for(i=0;i<=n-3;i++)
     {
         for(j=i+1;j<n-1;j++)
         {
             if(a[i]!=a[j])
             {
             for(k=j+1;k<n;k++)
             {
                if(a[i]!=a[k] && a[k]!=a[j])
                {
                    x=a[i]+a[j]+a[k]-max(a[i],max(a[j],a[k]));
                    if(x>max(a[i],max(a[j],a[k])))
                    ans++;
                }
             }
             }
         }
     }
     cout<<ans;
    
}



Measured memory_bytes: 3648
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;long D[1<<20],Z[1<<20],A[1<<18],x,z;long f(a,k,l,r){D[k]+=z=Z[k];Z[2*k]+=z;Z[2*k+1]+=z;Z[k]=0;return a<=l&r<i+2?D[k]+(Z[k]=x):l<=i&a<r?D[k]=fmax(f(a,2*k,l,(l+r)/2),f(a,2*k+1,(l+r)/2,r)):D[k];}main(j){for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];for(;p?:(p=F[++i],f(i,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],1,0,n);printf("%ld",x);}

Measured memory_bytes: 19200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n, a, ans=-1;
	cin >> n;
	for (int i = 1;i <= n;i++) {
		int a = i * 1.08;
		if (a == n)ans = i;
	}
	if (ans == -1)cout << ":(" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
a_inputs = [int(input())-1 for i in range(n)]

visited = [0]*n
x = 0

ans=1
while True:
    if visited[x]==1:
        ans=-1
        break
    if a_inputs[x]==1:
        break
    visited[x] = 1
    x = a_inputs[x]
    ans+=1
print(ans)

Measured memory_bytes: 7852
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;


int main()
{
    string color;
    cin >> color;
    
    size_t len = color.length();
    int count1 = 0,count2 = 0;

    for(int i=0; i<len; i+=2){
        if(color[i] != '0') count1++;
    }
    for(int i=1; i<len; i+=2){
        if(color[i] != '1') count1++;
    }

    for(int i=0; i<len; i+=2){
        if(color[i] != '1') count2++;
    }
   for(int i=1; i<len; i+=2){
        if(color[i] != '0') count2++;
    }

    cout << min(count1,count2);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
    cout << b - a + 1 - div(a, b, c) - div(a, b, d) + div(a, b, ((c * d) / __gcd(c, d)))<< endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	int SIZE = 80;
	int[] ans;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int l = 0; l < n; l++) {
			// 80ケタの数字は扱えないので文字列に
			char[] a = sc.next().toCharArray();
			char[] b = sc.next().toCharArray();

			// 入力が80ケタを超える
			if (a.length > SIZE || b.length > SIZE) {
				System.out.println("overflow");
				continue;
			}

			// 文字列⇒配列に
			int[] x = new int[a.length];
			int[] y = new int[b.length];
			for (int i = 0; i < a.length; i++) {
				x[i] = a[i] - '0';
			}
			for (int i = 0; i < b.length; i++) {
				y[i] = b[i] - '0';
			}

			// 大きい桁数+1だけ答えの配列をとる
			if (x.length >= y.length) {
				ans = new int[x.length + 1];
			} else {
				ans = new int[y.length + 1];
			}

			int i = x.length - 1;
			int j = y.length - 1;
			int k = ans.length - 1;
			int count = 0;
			boolean flag = false;

			// 同じ桁数の計算
			while (i >= 0 && j >= 0) {
				count++;
				ans[k] += (x[i] + y[j]);
				// 繰り上がり処理
				if (ans[k] >= 10) {
					if (count < SIZE) {
						ans[k - 1] = 1;
						ans[k] -= 10;
					} else {
						flag = true;
					}
				}
				i--;
				j--;
				k--;
			}

			// x>y（桁数）
			if (i > j) {
				while (i >= 0) {
					count++;
					ans[k] += x[i];
					// 繰り上がり処理
					if (ans[k] >= 10) {
						if (count < SIZE) {
							ans[k - 1] = 1;
							ans[k] -= 10;
						} else {
							flag = true;
						}
					}
					k--;
					i--;
				}
			} else {
				while (j >= 0) {
					count++;
					ans[k] += y[j];
					// 繰り上がり処理
					if (ans[k] >= 10) {
						if (count < SIZE) {
							ans[k - 1] = 1;
							ans[k] -= 10;
						} else {
							flag = true;
						}
					}
					k--;
					j--;
				}
			}

			if (flag) {
				System.out.println("overflow");
				continue;
			}

			for (int m = 0; m < ans.length; m++) {
				if (m == 0 && ans[m] == 0) {
					continue;
				}
				System.out.print(ans[m]);
			}
			System.out.println();
		}

		sc.close();
	}

	void run1() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();

		while (t != 0) {
			BigInteger bi = sc.nextBigInteger().add(sc.nextBigInteger());
			if (bi.toString().length() > 80) {
				System.out.println("overflow");
			} else {
				System.out.println(bi);
			}
			t--;
		}
	}

	public static void main(String[] args) {
		new Main().run1();
	}

}

Measured memory_bytes: 18420
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;
using P = pair< int , int >;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

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

	vector<int> ds;

	for (int i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			ds.pb(i);
			if (i != m) {
				ds.pb(m / i);
			}
		}
	}

	sort(ds.begin(),ds.end());
	int divided = 0;
	for (auto d : ds) {
		if (d >= n) {
			divided = d;
			break;
		}
	}

	cout <<  m / divided << endl;
	return 0;
}

Measured memory_bytes: 256
import kotlin.math.abs
import kotlin.math.max

fun main() {
    val n = readLine()!!.toInt()
    val list = List(n) {
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        Pair(x, y)
    }
    fun dis(x: Pair<Int, Int>, y: Pair<Int, Int>): Int {
        return abs(x.first - y.first) + abs(x.second - y.second)
    }
    val maxPlus = list.maxBy { it.first + it.second }!!
    val minPlus = list.minBy { it.first + it.second }!!
    val maxMinus = list.maxBy { it.first - it.second }!!
    val minMinus = list.minBy { it.first - it.second }!!
    println(max(dis(maxPlus, minPlus), dis(maxMinus, minMinus)))
}

Measured memory_bytes: 74096
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro rep (i n &body body)
  `(dotimes (,i ,n) ,@body))

(defmacro rep1 (i s g &body body)
  `(loop for ,i from ,s below ,g
      do ,@body))

;;vector
(defmacro vec (type &optional (num 0) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num)
            (dim (if (> ,g 100) (+ ,g 100) 100)))
       (make-array dim :element-type ',type :initial-element ,val
                   :adjustable t :fill-pointer ,g))))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defun chmax (var comp &optional (predicate #'>))
  (if (or (null var) (not (funcall predicate var comp)))
        (setf var comp)))
(defun chmin (var comp &optional (predicate #'<))
  (if (or (null var) (not (funcall predicate var comp)))
        (setf var comp)))



(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))
(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

;;本体


(defun main ()
  (let* ((n (read))
         ma mi)
    (dotimes (i n)
      (let ((temp (read)))
        (chmax ma temp)
        (chmin mi temp)))
    (princ (- ma mi))
    (terpri)))
 
#-swank(main)


Measured memory_bytes: 9696
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    if(x == 1 || x == n * 2 - 1){
        cout << "No" << endl;
        return 0;
    }

    vector<int> v(2*n-1, -1);
    v[n-2] = x - 1;
    v[n-1] = x;
    v[n]   = x + 1;

    int a = 1;
    for(int i=0; i<2*n-1; ++i){
        if(v[i] == -1){
            if(a == x - 1)
                a = x + 2;
            v[i] = a;
            ++ a;
        }
    }

    cout << "Yes" << endl;
    for(int i=0; i<2*n-1; ++i)
        cout << v[i] << endl;

    return 0;
}

Measured memory_bytes: 2304
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define allr(v) v.rbegin(),v.rend()
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
int main()
{
	Mohammed_Atef_Hassan
		int x, y;
	cin >> x >> y;
	ll res = 0;
	if (x <= 3)
		res += (4 - x) * 100000;
	if (y <= 3)
		res += (4 - y) * 100000;
	if (x == y && x == 1)res += 400000;
	cout << res << finl;
}

Measured memory_bytes: 256
from functools import lru_cache

N=int(input())
K=int(input())
 
@lru_cache(None)
def F(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
#     assert N >= 0
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q,r = divmod(N,10)
    ret = 0
    if K >= 1:
        # 1の位が nonzero
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    # 1の位が zero
    ret += F(q, K)
    return ret
 
# F(100, 1), F(25, 2), F(314159, 2)
 
print(F(N, K))


Measured memory_bytes: 3940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll N, K, X;
	cin >> N >> K >> X;
  if(N + K == X || N + X == K || K + X == N)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(void)
{
    int r,D,x;
    scanf("%d %d %d", &r, &D, &x);
    for(int i=0;i<10;i++){
        x = r*x-D;
        printf("%d\n", x);
    }
}

Measured memory_bytes: 256
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = nums()
AC = set()
WA = {}
for _ in range(M):
    pi,si = input().split()
    if si == "AC":
        AC.add(pi)
    else:
        if not (pi in WA.keys()) and not pi in AC:
            WA[pi] = 1
        else:
            if not (pi in AC):
                WA[pi] += 1

for problem in WA.keys():
    if not (problem in AC):
        WA[problem] = 0
ACnum = len(AC)
WAnum = sum(WA.values())
print(ACnum,WAnum)



Measured memory_bytes: 16192
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define MOD 1000000007 
int n,m,ans,fc[N],invF[N];
int qPow(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%MOD) if(y&1) res=1ll*res*x%MOD;return res; 
}
int C(int x,int y) {return 1ll*fc[x]*invF[y]%MOD*invF[x-y]%MOD;}
int main()
{
	scanf("%d %d",&n,&m);
	fc[0]=invF[0]=1;for(int i=1;i<=n;++i) fc[i]=1ll*fc[i-1]*i%MOD;
	invF[n]=qPow(fc[n],MOD-2);
	for(int i=n-1;i>=1;--i) invF[i]=1ll*invF[i+1]*(i+1)%MOD; 
	for(int i=0;i<=min(n-1,m);++i) ans=(ans+1ll*C(n,i)*C(n-1,n-i-1)%MOD)%MOD;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define ll long long
#define rep(i,l,r,d) for(ll i=(l);i<(r);i+=(d))
ll A[2001], lowp[2001], lowa[2001];
int main(void){
    ll N, K, MOD=1000000007, k;
    scanf("%lld %lld", &N, &K);
    rep(i, 0, N, 1) scanf("%lld", A+i);
    //A[i]より後ろにいくつ小さいのがあるか
    rep(i, 0, N, 1) rep(j, i+1, N, 1) if(A[i]>A[j])lowp[i]++;
    //全体として小さいのがいくつあるか
    rep(i, 0, N, 1) rep(j, 0, N, 1) if(A[i]>A[j]) lowa[i]++;
    //for(i=K-1, i>0, i--) k += i の公式
    if(K%2==0)k=((K+1)*(K/2) - K)%MOD;
    else k=(K*(K/2))%MOD;
    rep(i, 0, N, 1){
        A[2000] += (lowp[i]*K)%MOD + (lowa[i]*k)%MOD;
        A[2000] = A[2000]%MOD;
    }
    printf("%lld\n", A[2000]);
    return 0;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int r;
signed main()
{
    cin >> r;

    cout << fixed << setprecision(10) << 3.141592653589793238 * 2 * r << endl;
    return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


string s;
int K;

int main(){

    cin >> s;
    cin >> K;
    set<string> st;
    for(int i = 0; i < (int)s.size(); i++){
        for(int j = 0; j < 5 && i + j < (int)s.size(); j++){
            string t = s.substr(i, j + 1);
            st.insert(t);
        }
    }
    auto it = st.begin();
    for(int i = 1; i < K; i++) it++;
    cout << *it << endl;

}


Measured memory_bytes: 1664
using System;


namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int S = int.Parse(Console.ReadLine());
            //????????????????§??????????????????????
            int h = S / (60 * 60);
            //??¨???-??????/60??§????????????
            int m = (S - (h*(60 * 60))) / 60;
            //??¨???-(??????+???)??§?§??????????
            int s = (S - (h*(60*60))-(m*60));
            Console.WriteLine(h + ":" + m + ":" + s);


        }
    }
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  long long sum = 0;
  
  for(int i = 1; i <= N; i++){
    if(i % 3 && i % 5) sum += i;
  }
  
  cout << sum << endl;
  
  return 0;
}


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


ll gcd(ll x,ll y){return y ? gcd(y,x % y) : x;}

int main(){
    ll a,b;
    cin >> a >> b;
    ll g = gcd(a,b);
    set<ll> s;
    s.insert(1);
    for(ll i = 2;i * i <= g;i++){
        if(g == 1) break;
        while(g % i == 0){
            g /= i;
            s.insert(i);
        }
    }
    if(g!=1)s.insert(g);
    cout << s.size() << endl;
    
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#define N 200

int main(void){
	char mo[N],st[N],en[N];
	int m,h,i,j,maen=0;
	char last[]="-";
	
	while(1){
		scanf("%s",mo);
		if(strcmp(mo,last)==0)break;
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%d",&h);
			for(j=0;j<h;j++){
				st[j]=mo[j];
				st[j+1]='\0';
			}
			maen=strlen(mo)-h;
			for(j=0;j<maen;j++){
				en[j]=mo[j+h];
				en[j+1]='\0';
			}
			strcpy(mo,en);
			strcat(mo,st);
		}
		printf("%s\n",mo);
	}
	
	return 0;
}


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

int main(){
    ll n, a;
    cin >> n;
    map<ll, ll> b;
//    rep(i, 1000200001) b.at(i) = 0;
    ll sum = 0;
    rep(i, n){
        cin >> a;
        ll k = i+1;
        sum += b[max(k-a, 0LL)];
        if(b[k + a] == 0){
            b[k + a] = 1;
        }else{
            b[k + a]++;
        }
    }
    cout << sum << endl;
    return 0;
}

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

#define  int  long long
#define  ld   long double
#define  endl  '\n'
const int mod = 1e9 + 7;

const int N = 3000;
ld dp[N][N], p[N], ip[N];
//dp[i][k] = probabilty of getting k heads out of coins[1....i]
int n;
bool vis[N][N];

ld solve(int i, int k)
{
  //base cases
   if(i < 1)
     return k == 0;
   if(k == 0)
     return ip[i];

   if(vis[i][k])
      return dp[i][k];

   vis[i][k] = true;
   dp[i][k] = p[i] * solve(i - 1, k - 1) + (1.0 - p[i]) * solve(i - 1, k);

   return dp[i][k];
}

int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> n;
  
  for(int i = 1; i <= n; i++)
  {
    cin >> p[i];
    ip[i] = 1.0 - p[i];
    if(i > 1)
      ip[i] *= ip[i - 1];
  }

  ld ans = 0.0;

  for(int k = (n + 1) / 2; k <= n; k++)
    ans += solve(n, k);

  cout << fixed << setprecision(12) << ans << endl;

  return 0;
}

Measured memory_bytes: 150016
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

ll dp[101][10001];

int main()
{
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];

    rep(i, N) {
        rep(j, W + 1) {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j - w[i] >= 0) {
                chmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }

    ll ans = 0;
    rep(i, W + 1) {
        chmax(ans, dp[N][i]);
    }

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


Measured memory_bytes: 10880
#include<stdio.h>

int main(void){
	int a,b,c;
	int i,num;
	
	scanf("%d",&num);
	for(i=0;i<num;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a>b && a>c){
			if(a*a==b*b+c*c){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else if(b>a && b>c){
			if(b*b==a*a+c*c){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else{
			if(c*c==a*a+b*b){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 580
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(L: str):
    n = len(L)
    memo = [0] * (n + 1)
    memo[0] = 1
    for i in range(1, n + 1):
        memo[i] = memo[i - 1] * 3 % MOD
    cum = [0] * (n + 1)
    cum[0] = 1
    for i in range(1, n + 1):
        cum[i] = (cum[i - 1] * 2) % MOD

    ret = 0
    cnt = 0
    for i in range(n):
        c = L[i]
        if c == '1':
            rest = n - i - 1
            ret = (ret + memo[rest] * cum[cnt]) % MOD
            cnt += 1
            #print(ret)
    ret = (ret + cum[cnt]) % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = str(next(tokens))
    solve(L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    vector<int> times(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> times.at(i);
    }

    if (times.at(1) <= times.at(2) || times.at(3) <= times.at(0))
        cout << 0 << endl;
    else
    {
        sort(times.begin(), times.end());
        cout << times.at(2) - times.at(1) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 500000
#define INFTY 1000000000

void merge(int *, int, int, int);
void mergeSort(int *, int, int);

int count=0;

int main(){
  int A[N], i, n;

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

  mergeSort(A, 0, n);

  for(i = 0; i < n; i++){
    if(i == n - 1) printf("%d\n", A[i]);
    else printf("%d ", A[i]);
  }

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

  return 0;
}

void merge(int *A, int left, int mid, int right){
  int n1, n2, L[N], R[N], i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }

  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  i = 0;
  j = 0;

  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

void mergeSort(int *A, int left, int right){
  int mid;

  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()

#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;

ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}

void solve()
{
	ll n,m;
	cin>>m>>n;

	ll arr[2*n];
	For(i,0,n)
		cin>>arr[i];
	ll ans=arr[n-1]-arr[0];
	ans=min(ans,arr[0]+m-arr[1]);
	For(i,1,n)
	{
		ans=min(ans,m-arr[i]+arr[i-1]);
		if(i<n-1)
			ans=min(ans,arr[i]+m-arr[i+1]);
		else
			ans=min(ans,arr[i]-arr[0]);
	}
	cout<<ans<<endl;


}

signed main() 
{
    fast_cin();
    // #ifndef ONLINE_JUDGE
    // freopen("C:/IO/in.txt", "r", stdin);
    // freopen("C:/IO/out.txt", "w", stdout);
    // #endif
    
    int t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 3328
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Add_Sub_Mul.Run();
        }
    }
      public class Add_Sub_Mul
    {
        public Add_Sub_Mul()
        {
        }
        public static void Run(){
            int A, B;
            string s = Console.ReadLine();
            A = int.Parse(s.Split(' ')[0]);
            B = int.Parse(s.Split(' ')[1]);
            Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
        }
    }
}



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

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

    int res;
    vector<int> vec(N);
    
    for (int i = 1; i <= N; i++)
    {
        res = pow(i,2);
        if (res <= N){
            for (int j = 1; j <= N; j++)
            {
                res = pow(i,2) + pow(j,2) + i*j;
                if (res <= N){
                    for (int k = 1; k < N; k++)
                    {
                        res = pow(i,2) + pow(j,2) + pow(k,2) + i*j + j*k + k*i;
                        if (res <= N){
                            vec.at(res-1) += 1;
                        }
                        else if (res > N)
                        {
                            break;
                        }
                        
                    }
                }
                
                
            }
        }
        
    }


    rep(i, N){
        cout << vec.at(i) << endl;
    }
}

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

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

    int n;
    cin >> n;
    int sum = 0;
    int a[n+2];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int ans = INT_MAX;
    int preffix_sum = 0;
    for(int i = 0; i < n; i++){
            preffix_sum += a[i];
        ans = min(ans, abs(preffix_sum - (sum - preffix_sum)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool RGB(char x, char y, char z){
int a=0;
if(x=='R'||y=='R'||z=='R'){ a++; }
if(x=='G'||y=='G'||z=='G'){ a++; }
if(x=='B'||y=='B'||z=='B'){ a++; }
if(a==3){ return true; }else{ return false; }
}
int main(){
long N, i, j, k, r, g, b; string S; cin >> N >> S; r=g=b=0;
for(i=0; i<N; i++){ if(S[i]=='R'){ r++; }else if(S[i]=='G'){ g++; }else{ b++; } }
long h=(N-1)/2, ans=r*g*b;
for(i=1; i<=h; i++){ for(j=0; j+2*i<=N-1; j++){
 if(RGB(S[j], S[j+i], S[j+2*i])){ ans--; }
} }
cout << ans << "\n";
}

Measured memory_bytes: 3572
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
struct edge {int to; int cost;};
const int dx1[] = {1, 0, -1, 0}, dy1[] = {0, 1, 0, -1};

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    --ch; --cw; --dh; --dw;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];
    
    auto f = [&](int x, int y) -> int {return x * w + y;};
    
    vector<vector<edge>> g(h * w);
    rep(i, h) rep(j, w) {
        if (s[i][j] == '#') continue;
        rep(dx, -2, 3) rep(dy, -2, 3) {
            if (i + dx < 0 || i + dx >= h || j + dy < 0 || j + dy >= w) continue;
            if (s[i + dx][j + dy] == '#') continue;
            g[f(i, j)].push_back(edge{f(i + dx, j + dy), 1});
        }
        rep(k, 4) {
            if (i + dx1[k] < 0 || i + dx1[k] >= h || j + dy1[k] < 0 || j + dy1[k] >= w) continue;
            if (s[i + dx1[k]][j + dy1[k]] == '#') continue;
            g[f(i, j)].push_back(edge{f(i + dx1[k], j + dy1[k]), 0});
        }
    }
    
    deque<int> dq;
    dq.push_back(f(ch, cw));
    vector<int> dist(h * w, inf);
    dist[f(ch, cw)] = 0;
    while (!dq.empty()) {
        int v = dq.front(); dq.pop_front();
        for (edge& e: g[v]) {
            if (e.cost == 0) {
                if (chmin(dist[e.to], dist[v])) dq.push_front(e.to);
            } else {
                if (chmin(dist[e.to], dist[v] + 1)) dq.push_back(e.to);
            }
        }
    }
    if (dist[f(dh, dw)] != inf) cout << dist[f(dh, dw)] << "\n";
    else cout << "-1\n";
    return 0;
}


Measured memory_bytes: 120512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t r,g,b,n,cnt=0;
  cin >> r >> g >> b >> n;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      int k=(n-r*i-g*j)/b;
      if(0<=k && k<=n && r*i+g*j+k*b==n)cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //コンソールから入れる際に高速に入れる方法
		String x = br.readLine();
      	if(x.contains("A") && x.contains("B")) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
n,m,x = gets.split.map(&:to_i)
aa = gets.split.map(&:to_i)

ans = 10**10

# to n
costs = 0
(x+1).upto(n) do |i|
  if aa.include?(i)
    costs += 1
  end
end
ans = [ans, costs].min

# to 0
costs = 0
(x-1).downto(0) do |i|
  if aa.include?(i)
    costs += 1
  end
end

ans = [ans, costs].min

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int N,M,L,X,a[10005],res=0;
bool dp[1005]={};
int main() {
	cout << fixed << setprecision(18);
    
    cin>>N>>X;
    while(N!=0){
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            for(int k=j+1;k<=N;k++){
                if(i+j+k==X){res++;}
            }
        }
    }
    cout<<res<<endl;
    res=0;
    cin>>N>>X;
    }
} 



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <string>
#include <complex>

using namespace std;

int n, m;
string A[500], B[500];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < m; i++) cin >> B[i];
    for (int i1 = 0; i1 + m <= n; i1++)
    {
        for (int j1 = 0; j1 + m <= n; j1++)
        {
            int t = 0;
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (A[i1 + i][j1 + j] != B[i][j])
                    {
                        t = 1;
                    }
                }
            }
            if (!t) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int mp[400005];

signed main(){
    FASTER;
    int n;cin>>n;
    string s;cin>>s;
    
    for(int i=0;i<400005;i++){
        int tmp=i;
        int ans=0;
        while(tmp){
            tmp=tmp%__builtin_popcountll(tmp);
            ans++;
        }
        mp[i]=ans;
    }
    
    int cnt=0;
    for(char c:s)cnt+=(c=='1');
    
    int Pp1=0,Pm1=0,cur1 = 1,cur2 = 1;
    for(int i=n-1,id=0;i>=0;i--,id++){
        if(s[i]=='1'){
            Pp1=(Pp1+cur2 % (cnt + 1))%(cnt+1);
            if(cnt>=2)Pm1=(Pm1+cur1 % (cnt - 1))%(cnt-1);
        }
        if(cnt > 1){
            cur1 *= 2;
            cur1 %= (cnt - 1); 
        } 
        cur2 *= 2;
        cur2 %= (cnt + 1);
    }
    
    vi cp1mod(n+n,1);
    for(int i=n - 2;i>=0;i--){
        cp1mod[i]=cp1mod[i+1]*(2%(cnt+1));
        cp1mod[i] %= (cnt + 1);
    }
    vi cm1mod(n+n,1);
    for(int i=n - 2;i>=0 && cnt>1;i--){
        cm1mod[i]=cm1mod[i+1]*(2%(cnt-1));
        cm1mod[i] %= (cnt - 1);
    }
    
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            int rem=(Pp1+cp1mod[i])%(cnt+1);
            int cntt=1+mp[rem];
            cout<<cntt<<"\n";
        }else{
            if(cnt==1){
                cout<<0<<"\n";
            }else{
                int rem=(Pm1-cm1mod[i]+cnt-1)%(cnt-1);
                int cntt=1+mp[rem];
                cout<<cntt<<"\n";
            }
        }
    }
    
}


Measured memory_bytes: 12804
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));

  cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n,memo[N],c[N];

int dp(int curr) {
    if (curr == n) return 0;
    if (curr > n) return 1e9;
    int &sol = memo[curr];
    if (sol != -1) return sol;
    sol = min(
        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,
        dp(curr + 2) + abs(c[curr] - c[curr + 2])
    );
    return sol;
}

int main() {
    scanf("%d" , &n);
    for (int i = 1 ; i <= n ; i++)
        scanf("%d" , &c[i]);
    memset (memo , -1 , sizeof memo);
    printf("%d\n" , dp(1));
}


Measured memory_bytes: 8108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll calc(ll b,ll n){
  ll res = 0;
  while(n>=b){
    res+=n%b;
    n=n/b;
  }
  return res+n;
}
int main(){
  ll n,s,i,j,k,ans=-1;
  cin>>n>>s;
  
  if(n>s){
    for(i=2;i*i<=n;i++){
      if(calc(i,n)==s){
	ans=i;
	break;
      }
    }
    if(!~ans){
      for(i=1;i*i<=n;i++){
	if(i>s) break;
	if((n-s)%i==0)
	  if(calc((n-s)/i+1,n)==s)
	    ans=(n-s)/i+1;
      }
    }
    if(!~ans&&s==1) ans=n;
  }
  if(n==s) ans=n+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Atcoder0629
{
    class Program
    {
        static void Main(string[] args)
        {
            int n =Int32.Parse(Console.ReadLine());
            int[] p = new int[n];
            int ans = 0;
            string[] str=Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)p[i] = Int32.Parse(str[i]);
            for (int i = 1; i < n - 1; i++)
            {
                if ((p[i] < p[i - 1] || p[i] < p[i + 1]) && (p[i] > p[i - 1] || p[i] > p[i + 1])) ans += 1;
            }
            Console.WriteLine(ans);
            return;
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
      cout << 6-x-y << endl;
}

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

const int INF = 1 << 20;

// ティツ。ツ古・ツ按療」ツδゥテ」ツつ、テ」ツδ姪」ツδゥテ」ツδェ
// Verified: TopCoder SRM 704 Div.2 (ModEquationEasy)
// ティツ。ツ古・ツ按療」ツ?ョテァツゥツ?テ」ツ?ィ テァツエツッテ、ツケツ?テァツケツーテ」ツつ甘ィツソツ氾」ツ?療、ツコツ古、ツケツ療ヲツウツ?

// Matrix Library Begin (C++11)

template <typename T>
using Matrix = vector< vector<T> >;

template <typename T>
void init_mat(Matrix<T> &A, int h, int w) {
    A.resize(h, vector<T>(w, 0));
}

template <typename T>
Matrix<T> calc_mat(Matrix<T> A, Matrix<T> B) {
    Matrix<T> C(A.size(), vector<T>(B[0].size()));
    for(int i=0; i<A.size(); i++) {
        for(int k=0; k<B.size(); k++) {
            for(int j=0; j<B[0].size(); j++) {
                C[i][j] |= A[i][k] & B[k][j]; // modテ」ツ?ェテ」ツ??
                // C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; // modテ」ツ?づ」ツつ?
            }
        }
    }
    return C;
}

template <typename T>
Matrix<T> mat_pow(Matrix<T> A, int n) {
    Matrix<T> B(A.size(), vector<T>(A.size()));
    for(int i=0; i<A.size(); i++) B[i][i] = 1;
    while(n > 0) {
        if(n & 1) B = calc_mat(B, A);
        A = calc_mat(A, A);
        n >>= 1;
    }
    return B;
}

// Matrix Library End

Matrix<int> trans(Matrix<int> A) {
    int N = A.size();
    Matrix<int> ret;
    init_mat(ret, N, N);
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            ret[i][j] = A[j][i];
        }
    }
    return ret;
}

int main() {
    int N, M, A, B, C;
    scanf("%d%d%d%d%d", &N, &M, &A, &B, &C);

    Matrix<int> adj;
    init_mat(adj, N, N);
    for(int i=0; i<M; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        adj[u][v]++;
    }

    Matrix<int> gs[3], gg;
    gs[0] = mat_pow(adj, A), gs[1] = mat_pow(adj, B), gs[2] = mat_pow(adj, C);
    for(int i=0; i<3; i++) gs[i] = trans(gs[i]);

    int cnt = 0;
    bool checked[55] = {};
    queue<int> que;
    que.push(N-1);
    checked[N-1] = true;
    while(1) {
        queue<int> tmp;
        cnt++;
        bool cont = false;

        Matrix<int> mat;
        init_mat(mat, 3, N);
        while(!que.empty()) {
            int cur = que.front();
            // printf("cnt = %d, cur = %d\n", cnt, cur);
            tmp.push(cur); que.pop();
            for(int to=0; to<N; to++) {
                for(int k=0; k<3; k++) {
                    mat[k][to] |= gs[k][cur][to];
                }
            }
        }

        vector<int> res(N, 1);
        for(int j=0; j<N; j++) {
            for(int k=0; k<3; k++) {
                res[j] &= mat[k][j];
            }
            if(res[j]) {
                if(checked[j]) continue;
                if(j == 0) {
                    printf("%d\n", cnt);
                    return 0;
                }
                checked[j] = true;
                cont = true;
                tmp.push(j);
            }
        }

        if(!cont) break;
        que = tmp;
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    string s;
	cin >> s;
	ll p = 0;
	REP(i, 0, s.size()) {
		if (s[i] == '7') {
			p = 1;
			break;
		}
	}
	if (p)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3656
import numpy as np

nm = input().split()
n = int(nm[0])
m = int(nm[1])

min = 0
max = np.inf

for i in range(m):
    a = input().split()
    if int(a[0])>=min:
        min = int(a[0])

    if int(a[1])<=max:
        max = int(a[1])

if max>=min:
    print(max-min+1)
else:
    print(0)

Measured memory_bytes: 12424
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	double n;
	cin >> n;
	rep(i, 50001) {
		double be = (double)i;
		double af = i * 1.08;
		int ans = floor(af);
		if (ans == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;

	return 0;
}


Measured memory_bytes: 256