akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()

ans = 0

for i in range(1,N-1):
    if S[i] == 'R':
        leftG = S[:i].count('G')
        rightG = S[i+1:].count('G')
        leftB = S[:i].count('B')
        rightB = S[i+1:].count('B')

        ans += leftB*rightG+leftG*rightB
        for j in range(1,min(i,N-i-1)+1):
            if (S[i-j] == 'G' and S[i+j] == 'B') or (S[i-j] == 'B' and S[i+j] == 'G'):
                ans -= 1

for i in range(1,N-1):
    if S[i] == 'G':
        leftG = S[:i].count('R')
        rightG = S[i+1:].count('R')
        leftB = S[:i].count('B')
        rightB = S[i+1:].count('B')
            
        ans += leftB*rightG+leftG*rightB
        for j in range(1,min(i,N-i-1)+1):
            if (S[i-j] == 'R' and S[i+j] == 'B') or (S[i-j] == 'B' and S[i+j] == 'R'):
                ans -= 1

                
for i in range(1,N-1):
    if S[i] == 'B':
        leftG = S[:i].count('R')
        rightG = S[i+1:].count('R')
        leftB = S[:i].count('G')
        rightB = S[i+1:].count('G')
            
        ans += leftB*rightG+leftG*rightB
        for j in range(1,min(i,N-i-1)+1):
            if (S[i-j] == 'R' and S[i+j] == 'G') or (S[i-j] == 'G' and S[i+j] == 'R'):
                ans -= 1
            
print(ans)     

Measured memory_bytes: 9356
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    i64 a, b, c, k;

    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

    if (k % 2 == 0)
        printf("%lld\n", a - b);
    else
        printf("%lld\n", b - a);

    return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0

for i in range(N - 1):
    if A[i] + A[i + 1] > x:
        d = A[i] + A[i + 1] - x
        ans += d
        if A[i + 1] - d < 0:
            A[i] -= d - A[i + 1]
            A[i + 1] = 0
        else:
            A[i + 1] -= d

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vp xy(M);
  vvi from(N),to(N);
  rep(i,M) {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    xy[i] = P(x,y);
    from[x].push_back(y);
    to[y].push_back(x);
  }
  queue<int> que;
  rep(i,N) {
    if(sz(from[i]) == 0) {
      que.push(i);
    }
  }
  vi dp(N,0);
  vi dep(N,0);
  while(!que.empty()) {
    int k = que.front();
    que.pop();
    int len = 0;
    rep(i,sz(from[k])) {
      len = max(len,dp[from[k][i]]+1);
    }
    dp[k] = len;
    rep(i,sz(to[k])) {
      dep[to[k][i]]++;
      if(dep[to[k][i]] == sz(from[to[k][i]])) {
        que.push(to[k][i]);
      }
    }
  }
  int ans = 0;
  rep(i,N) {
    ans = max(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>

typedef long long ll;
using namespace std;



bool isPrime(int n){
    if(n < 2){
        return 0;
    }
    if(n%2 == 0){
        return n==2;
    }
    for(int i=3;i*i<=n;i++){
        if(n%i == 0) return 0;
    }
    return 1;
}


int main() {
   /*
    ll n,m,k;
   cin>>n>>m>>k;
   vector<ll> a(n);
   vector<ll> b(m);
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=0;i<m;i++)cin>>b[i];
   ll t = 0;
   ll no = 0;
   int i = a.size()-1;
   int j = b.size()-1;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
   while(t <= k){
       if(i >=0 && j >= 0){
           if(a[i] < b[j]){
               if( t+a[i] > k)break;
               t += a[i];
               i--;
               no++;
           }else{
               if( t+b[j] > k)break;
               t += b[j];
               j--;
               no++;
           }
       }else if( i >= 0 ){
           if( t+a[i] > k)break;
           t += a[i];
           i--;
           no++;
       }else if(j >= 0 ){
           if( t+b[j] > k)break;
           t += b[j];
           j--;
           no++;
       }else if(i < 0 && j < 0){
           break;
       }
   }
   cout<<no<<endl;
   */
  vector<int> ans(100000,0);
  int n;
  cin>>n;
  for(int i=1;i<110;i++){
      for(int j=1;j<110;j++){
          for(int k=1;k<110;k++){
                int z = i*i+j*j+k*k+i*j+i*k+j*k;
                if(z < 10e5)ans[z]++;
          }
      }
  }
  for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int P, W, G, Y = 0;

for (int i = 0; i < N; i++) {
  string iro;
  cin >> iro;
  if(iro == "P"){
    P = 1;
  }
  else if(iro == "W"){
    W = 1;
  }
  else if(iro == "G"){
    G = 1;
  }
  else if(iro == "Y"){
    Y = 1;
  }
}
  if(P + W + G + Y == 3){
    cout << "Three" << endl;
  }
  if(P + W + G + Y == 4){
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    for(int i = 0; i <= n; i++){
        if( (int)((double)i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;
using vi=vector<int>;


double dist(double dx, double dy)
{
	return sqrt(dx*dx+dy*dy);
}


double frac(int n)
{
	double ret=1.0;

	for(int i=1;i<=n;i++) ret*=i;
	return ret;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi x(n), y(n);

		for(int i=0;i<n;i++) scanf("%d%d", &x[i], &y[i]);

		double d_sum=0.0;

		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				double d=dist(x[i]-x[j], y[i]-y[j]);
				d_sum+=d;
			}
		}
		printf("%.8f\n", d_sum*2/n);
	}

	return 0;
}


Measured memory_bytes: 384
/*
 * Contents   : AOJ DPL 1 E
 * Author     : KitauraHiromi
 * LastUpdate : 20180614
 * Since      : 20180614
 */
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string S, T;
int INF = 1e9+1;
int dp[1010][1010];
int main(void){
    cin >> S >> T;
    Fill(dp, INF);
    dp[0][0] = 0;
    for(int i=-1; i<=(int)S.size(); ++i){
        for(int j=-1; j<=(int)T.size(); ++j){
            if(i == -1 && j == -1) continue;
            // 変更
            if(i >= 0 && j >= 0){
                if(S[i] == T[j]) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]);
                else dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+1);
            }
            // 削除
            if(i >= 0) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j+1]+1);
            // 追加
            if(j >= 0) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i+1][j]+1);
        }
    }
    cout << dp[S.size()][T.size()] << endl;
    return 0;
}


Measured memory_bytes: 7188
using System;

namespace Watch
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int input = int.Parse(Console.ReadLine());
			int h = input / 3600;
			int amari = input % 3600;
			int m = amari / 60;
			int s = amari % 60;
			Console.WriteLine (h + ":" + m + ":" + s);
		}
	}
}

Measured memory_bytes: 19940
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++)
        F[i]=F[i-1]+F[i-2];
    cout<<F[n]<<"\n";
    return 0;
}



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

using namespace std;

typedef long long ll;

int main() {
	ll A, B;
	scanf("%lld%lld", &A, &B);
	if(A == B) {
		puts("1");
		return 0;
	}
	for(int i = 60; i >= 0; i--) if(((A >> i) & 1) ^ ((B >> i) & 1)) {
		ll v = -1, s;
		for(int j = i - 1; j >= 0; j--)
			if(((B >> j) & 1)) {
				v = j;
				break;
			}
		s = ((1ll << i) >> (v + 1)) - ((A & ((1ll << i) - 1)) >> (v + 1));
		ll ans = (1ll << i) - ((A & ((1ll << i) - 1))) + s * (1ll << (v + 1));
		if(((A & ((1ll << i) - 1)) >> (v + 1)) != 0) {
			ans += 1 + ((~A) & ((1ll << (v + 1)) - 1));
		}// else ans += (1 << (v + 1));
		printf("%lld\n", ans);
		return 0;
	}
}

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

typedef long long ll;

ll N, M;
vector<vector<ll>> Adj;
vector<ll> Res;
queue<pair<ll, ll>> Q;

int main() {
  cin >> N >> M;
  Adj.resize(N);
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    Adj[a].push_back(b);
    Adj[b].push_back(a);
  }
  cout << "Yes" << endl;
  Res.resize(N, -1);
  Q.push({0, 0});
  while (!Q.empty()) {
    ll from, now;
    tie(from, now) = Q.front();
    Q.pop();
    if (Res[now] != -1) continue;
    Res[now] = from;
    for (ll to : Adj[now]) {
      Q.push({now, to});
    }
  }
  for (ll v = 1; v < N; ++v) {
    cout << Res[v] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 16908
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		String[] name = new String[N];
		String[] test = new String[N];
		for(int i = 0;i<N;i++) {
			name[i]= scn.next();
			name[i]+= String.format("%03d", (100-scn.nextInt()));
		}
		System.arraycopy(name,0,test,0,N);
		Arrays.sort(name);
		List<String> ans =  Arrays.asList(test);
		for(String x:name) {
			System.out.println(ans.indexOf(x)+1);
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
int main(void)
{
    int a,b,c,n,tmp,i,s;
    
    scanf("%d%d%d%d",&a,&b,&c,&n);
    if(a<b) {tmp=a; a=b; b=tmp;}
    if(a<c) {tmp=a; a=c; c=tmp;}
    for(i=0;i<n;i++)
        a=a*2;
    s=a+b+c;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int cnt = 0;
    for(char c:S)if(c == '1')cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[50];
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=2;i<n;i++){
		int a=A[i],b=A[i+1],c=A[i-1];
		if(a>b)swap(a,b);
		if(a>c)swap(a,c);
		if(b>c)swap(b,c);
		if(A[i]==b)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
//作者:中国江苏南京丁天行
using namespace std;
int n,f[105][105],g[105],pa[105],d[105],l,x[105],y[105];
ll ans=1e18;
vector<int> v[105];
void ope(int x,int y){
    d[x]=d[y]+1,pa[x]=y;
    for(int i=0;i<v[x].size();++i)if(v[x][i]!=y)ope(v[x][i],x);
}
void dfs(int x,int y){
    d[x]=d[y]+1;
    int cnt=0;
    for(int i=0;i<v[x].size();++i)if(v[x][i]!=y)dfs(v[x][i],x),++cnt;
    g[d[x]]=max(g[d[x]],cnt);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;++i){
        scanf("%d%d",x+i,y+i);
        v[x[i]].pb(y[i]),v[y[i]].pb(x[i]);
    }
    ope(1,0);
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            int x=i,y=j,z=0;
            while(x!=y){
                if(d[x]>=d[y])x=pa[x];
                else y=pa[y];
                ++z;
            }
            f[j][i]=f[i][j]=(z+2)/2;
            l=max(l,f[i][j]);
        }
    }
    for(int i=1;i<=n;++i){
        memset(d,0,sizeof(d));
        memset(g,0,sizeof(g));
        dfs(i,0);
        bool ok=1;
        for(int j=1;j<=n;++j)if(d[j]>l)ok=0,j=n;
        if(!ok) continue;
        ll res=1;
        for(int j=1;j<=l&&g[j];++j)res=res*g[j];
        ans=min(ans,res);
    }
    for(int i=1;i<n;++i){
        memset(d,0,sizeof(d));
        memset(g,0,sizeof(g));
        dfs(x[i],y[i]);
        d[x[i]]=0;
        dfs(y[i],x[i]);
        d[x[i]]=1;
        bool ok=1;
        for(int j=1;j<=n;++j)if(d[j]>l)ok=0,j=n;
        if(!ok) continue;
        ll res=2;
        for(int j=1;j<=l&&g[j];++j)res=res*g[j];
        ans=min(ans,res);
    }
    printf("%d %lld\n",l,ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

vector<ll> loc[1 << 17];
void solve() {
	int n, m; cin >> n >> m;
	vector<int> a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	rep(i, n) {
		if (m - a[i] < 0)continue;
		loc[m - a[i]].push_back(b[i]);
	}
	ll ans = 0;
	priority_queue<ll> q;
	for (int i = m; i >= 0; i--) {
		rep(j, loc[i].size())q.push(loc[i][j]);
		if (!q.empty()) {
			ans += q.top(); q.pop();
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 7168
def greatest_common_divisor(a, b):
    while b > 0:
        a, b = b, a % b
    return a


n = int(input())
lcm = 1
for i in range(n):
    t = int(input())
    lcm = lcm*t // greatest_common_divisor(lcm, t)
print(lcm)


Measured memory_bytes: 2940
n,k =map(int,input().split())
result=list(range(1,n+1))
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        if a[j] in result:
            b=result.pop(result.index(a[j]))
print(len(result))

Measured memory_bytes: 9224
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

#define MOD 1000000007

int H,W;
bool grid[1000][1000];

int dp[1000][1000];
int solve(int y, int x){
	if(y >= H || x >= W) return 0;
	if(y == H-1 && x == W-1) return 1;
	if(grid[y][x] == false) return 0;
	if(dp[y][x] != -1) return dp[y][x];
	return dp[y][x] = (solve(y+1,x) + solve(y,x+1)) % MOD;
}

int main(){
	
	cin >> H >> W;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			char c;
			cin >> c;
			if(c == '.') grid[i][j] = true;
			else grid[i][j] = false;
			dp[i][j] = -1;
		}
	}
	cout << solve(0,0) << endl;

	return 0;
}

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

template <typename T>
using indexed_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template <class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x)                                                                 \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(   \
              c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mem(a, s) memset(a, s, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; --i)

typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};

const int mod = 1e6 + 7;

void solve();
void pre();

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    // cin >> t;
    rep(i, 1, t) {
        // cout << "Case # " << i << ": ";
        solve();
    }
    return 0;
}

void pre() {}

const int mxn = 1e6 + 10;
int v[mxn], ans, n;

void go(int x) {
    int cnt = 0;
    rep(i, 0, n - 1) {
        if (v[i] % x == 0)
            cnt++;
    }
    if (cnt >= n - 1)
        ans = max(ans, x);
}

void solve() {
    cin >> n;
    rep(i, 0, n - 1) cin >> v[i];
    rep(i, 0, 1) {
        for (int j = 1; j * j <= v[i]; j++) {
            if (v[i] % j == 0) {
                go(j);
                go(v[i] / j);
            }
        }
    }
    cout << ans << "\n";
}


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

int main(){
	int n,i,j,kei;
	kei = 0;

	cin >> n;
	int a[n], b[n];

	for (i = 0; i < n ; i++){
		cin >> a[i];
	}
	for (i = 0; i < n ; i++){
		cin >> b[i];
	}

	for (i = 0; i < n ; i++){
		if (a[i] > b[i]){
			j = a[i] - b[i];
			kei += j;
		}
	}

	cout << kei << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d) cout<<"Yes";
    else cout<<"No";
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define N_MAX 100005
#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int N;
Int input[3];
Int dp[3],temp[3];

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        cin>>input[0]>>input[1]>>input[2];
        memset(temp,0,sizeof(temp));
        for(int j = 0;j < 3;j++) {
            for(int m = 0;m < 3;m++) {
                if(m == j)
                    continue;
                temp[m] = max(temp[m],dp[j]+input[m]);
            }
        }

        for(int k = 0;k < 3;k++)
            dp[k] = temp[k];
    }

    cout<<max({dp[0],dp[1],dp[2]})<<endl;

    return 0;
}




Measured memory_bytes: 256
n = int(input())
l = [[]for i in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    l[u].append([v, w])
    l[v].append([u, w])
c = [-1] * (n-1)
color = [0] + c
x = [0]
while x:
    current = x.pop(0)
    for y, d in l[current]:
        if color[y] > -1:
            continue
        color[y] = (color[current] + d)%2
        x.append(y)
for col in color:
    print(col)

Measured memory_bytes: 45772
def cumsum(lst):
    sum_list = [0]
    for i in range(len(lst)):
        sum_list.append(sum_list[i] + lst[i])
    return sum_list

N = int(input())
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row2.reverse()

candy_cand1 = cumsum(row1)[1:]
candy_cand2 = cumsum(row2)[1:]
candy_cand2.reverse()

cand = [0]*N
for i in range(N):
    cand[i] = candy_cand1[i] + candy_cand2[i]

print(max(cand))

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

using namespace std;
typedef long long ll;
typedef long double ld;
int H, W, A, B;
int ans[1000][1000];

void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {

    cin >> H >> W >> A >> B;
    REP(i, H) {
        REP(j, W) {
            ans[i][j]=((i<B&&j<A)||(i>=B&&j>=A))?1:0;
        }
    }
    REP(i, H) {
        REP(j, W) {
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    string s;cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<"3";
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R')) cout<<"2";
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout<<"1";
    else cout<<0;
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
        int N,R;
        cin >> N >> R;
        if (N >= 10) 
                cout << R << endl;
        else
                cout << (R + 100 * (10 - N)) << endl;
        return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.Arrays;

public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      int c = Integer.parseInt(sc.next());
      int d = Integer.parseInt(sc.next());

      double x = (double)a/d;
      double y = (double)c/b;
      x = Math.ceil(x);
      y = Math.ceil(y);

      if(x>=y){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}


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

void solve(){
	long long a,b;
	cin>>a>>b;
	cout<<(a*b);
	
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}

Measured memory_bytes: 3652
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(0, min(a, x//500)+1):
    for j in range(0, min(b, (x-i*500)//100)+1):
        if (x - i * 500 - j * 100) // 50 <= c:
            ans += 1

print(ans)

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
changes = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)
optimal = []
for b, c in changes:
	optimal += [c]*b
	if len(optimal) >= n:
		break
for i in range(min(n, len(optimal))):
	a[i] = max(a[i], optimal[i])
print(sum(a))

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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll ans = 0;
    for(auto x : mp){
        int k = x.second;
        ans += (ll)k*(k-1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

class Dice {
  int U, D, N, E, S, W;

  void goN() {
    int tmp = U;
    U = S;
    S = D;
    D = N;
    N = tmp;
  }

  void goE() {
    int tmp = U;
    U = W;
    W = D;
    D = E;
    E = tmp;
  }

  void goS() {
    int tmp = U;
    U = N;
    N = D;
    D = S;
    S = tmp;
  }

  void goW() {
    int tmp = U;
    U = E;
    E = D;
    D = W;
    W = tmp;
  }

  public:
  Dice(vector<int> label) {
    U = label.at(0);
    S = label.at(1);
    E = label.at(2);
    W = label.at(3);
    N = label.at(4);
    D = label.at(5);
  }

  void go(char way) {
    switch(way) {
      case 'N':
        goN();
        break;
      case 'E':
        goE();
        break;
      case 'S':
        goS();
        break;
      case 'W':
        goW();
        break;
    }
  }

  char getPos(int label) {
    if (U == label) return 'U';
    else if (D == label) return 'D';
    else if (N == label) return 'N';
    else if (E == label) return 'E';
    else if (S == label) return 'S';
    else if (W == label) return 'W';
    return 'Z';
  }

  int getLabel(char pos) {
    if (pos == 'U') return U;
    else if (pos == 'D') return D;
    else if (pos == 'N') return N;
    else if (pos == 'E') return E;
    else if (pos == 'S') return S;
    else if (pos == 'W') return W;
    return -1;
  }
};

int main() {
  vector<int> label(6);
  for (int i = 0; i < 6; ++i) cin >> label.at(i);
  Dice d1(label);
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int up, front;
    cin >> up >> front;
    char now_front, now_up;
    while (true) {
      now_front = d1.getPos(front);
      if (now_front == 'S') break;
      else if (now_front == 'E' || now_front == 'W') d1.go('E');
      else d1.go('N');
    }
    while (true) {
      now_up = d1.getPos(up);
      if (now_up == 'U') break;
      else d1.go('E');
    }
    cout << d1.getLabel('E') << endl;
  }

  return 0;
}


Measured memory_bytes: 3096
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll n;
    in >> n;
    ll a, count = 0;
    vector<ll> ans(100002, 0);
    REP(i, n){
        in >> a;
        ans[a] += 1;
        ans[a+1] += 1;
        ans[a+2] += 1;
    }
    REP(i, 100002){
        count = max(count, ans[i]);
    }
    out << count << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int a[15];
int b[60][4];
int ma;
int n,m,q;
void fun(int t){
	if(t==n){
		int sum=0;
		for(int i=0;i<q;i++){
			if(a[b[i][1]-1]-a[b[i][0]-1]==b[i][2]) sum+=b[i][3];
		}
		if(sum>ma) ma=sum;
		return;
	}
	int i;
	if(t==0) i=0;
	else i=a[t-1]; 
	for(;i<m;i++){
		a[t]=i;
		fun(t+1);
	}
}
int main(){

	cin>>n>>m>>q;
	for(int i=0;i<q;i++){
		for(int j=0;j<4;j++){
			cin>>b[i][j];
		}
	}

	ma=0;
	fun(0);
	cout<<ma<<endl;
}

Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main() {
    long n, ans = 0;
    cin >> n;

    for (long i = 1; i < n; i++) {
        if (((n - 1) / i) > 0) {
            ans += ((n - 1) / i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
//const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll x, y;
  cin >> x >> y;
  if (x % y == 0) cout << -1 << endl;
  else cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
#define ll long long
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,d;
	int ans = 0;
	cin >> n >> d;
	for(int i = 0;i<n;++i) {
		int x,y;
		cin >> x >> y;
		if(sqrt((pow(x,2)+pow(y,2))) <= d)
			ans++;
	}	
	cout << ans << '\n';
}	


Measured memory_bytes: 3696
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LS()
    if a == b:
        print("H")
    else:
        print("D")
    return

#B
def B():
    w, a, b = LI()
    a, b = min(a, b), max(a, b)
    if w + a >= b:
        print(0)
        return
    print(b-a-w)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38512
package main

import "fmt"

func main() {
	var d, n int
	_, _ = fmt.Scan(&d, &n)
	x := 1
	for i := 0; i < d; i++ {
		x *= 100
	}
	if n == 100 {
		fmt.Println(x * n + x * 1)
	} else {
		fmt.Println(x * n)
	}
}

Measured memory_bytes: 512
def main():
    from math import gcd
    _ = int(input())
    A = [int(i) for i in input().split()]

    class osa_k:
        def __init__(self, sup):
            if sup > 2 * 10**8:
                raise RuntimeError("too big")
            self.MINFact = [-1] * (sup + 1)
            self.MINFact[0] = 0
            self.MINFact[1] = 1
            primes = [True for i in range(sup+1)]
            primes[0] = False
            primes[1] = False
            for i in range(2, sup+1):
                if primes[i]:
                    self.MINFact[i] = i
                    mul = 2
                    while i*mul <= sup:
                        primes[i*mul] = False
                        if self.MINFact[i*mul] == -1:
                            self.MINFact[i*mul] = i
                        mul += 1

        def prime_factor(self, n, B):
            while n > 1:
                prime = self.MINFact[n]
                while self.MINFact[n] == prime:
                    n //= prime
                B[prime] += 1

    maxA = max(A)
    p = osa_k(maxA)
    B = [0] * (maxA + 1)
    for a in A:
        p.prime_factor(a, B)

    g = A[0]
    for a in A:
        g = gcd(g, a)

    if g != 1:
        print("not coprime")
    elif max(B) <= 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")


if __name__ == '__main__':
    main()


Measured memory_bytes: 209376
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<vector>
#include<functional>
using namespace std;

int main()
{
  int dp[2001];
  int n,k,a,b;
  vector<int> c[11],g[11];
  memset(dp,0,sizeof(dp));
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a>>b;b--;
	g[b].push_back(a);
  }

  for(int i=0;i<10;i++){
	  sort(g[i].begin(),g[i].end(),greater<int>());
  }
  
  for(int i=0;i<10;i++){
	  if(!g[i].empty()){
		  c[i].push_back(g[i].front());
	  }
      for(int i2=1;i2<g[i].size();i2++){
		  c[i].push_back(c[i][i2-1]+g[i][i2]+((i2+1)-1)*2);
	  }
  }  
  for(int i=0;i<=10;i++){
	  if(c[i].empty())
	  c[i].push_back(0);
  }
  /*for(int i=0;i<10;i++){
      for(int i2=0;i2<g[i].size();i2++){
          cout<<" "<<c[i][i2]<<" ";
	  }cout<<endl;
  }*/
  for(int j=0;j<10;j++){
  for(int i=k;i>=0;i--){
	  for(int i2=0;(i2<c[j].size())&&(i-i2-1>=0);i2++){
		  dp[i]=max(dp[i],dp[i-i2-1]+c[j][i2]);
	  }
  }
  }
  cout<<dp[k]<<endl;
	
}

Measured memory_bytes: 1256
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64, 
    }
    let l: i64 = if k >= a {
        a
    } else {
        k
    };
    let current_cards = k - l;
    if current_cards == 0 { println!("{}", l); } else {
        let n: i64 = if current_cards >= b {
            b
        } else { current_cards };
        let current_cards = current_cards - n;
        let answer = l - current_cards;
        println!("{}", answer);
    }
}


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

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

  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  int cnt = 0;
  for (int i = 0; i < N; i++){
    if (K <= vec.at(i)) cnt += 1;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int A, B, C;
	cin >> A >> B >> C;

	vector<int> value_list({ A, B, C });

	sort(value_list.begin(), value_list.end());

	int result = 0;
	for (int i = 1; i < 3; i++)
	{
		result += (value_list[i] - value_list[i - 1]);
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
#include <unordered_set>
using namespace std;
typedef unsigned long long uLL;
#define N 5000 + 5
#define Base 233

int n;
char s[N];
uLL Hash[N], Pow[N];
unordered_set<uLL> Set;

inline uLL GetHash(int l, int r)
{
	return Hash[r] - Hash[l - 1] * Pow[r - l + 1];
}

bool Check(int l)
{
	Set.clear();
	for (int i = l + 1; i + l - 1 <= n; i ++)
	{
		Set.insert(GetHash(i - l, i - 1));
		if (Set.count(GetHash(i, i + l - 1)))
			return true;
	}
	return false;
}

int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	Hash[0] = 0, Pow[0] = 1;
	for (int i = 1; i <= n; i ++)
	{
		Hash[i] = Hash[i - 1] * Base + s[i];
		Pow[i] = Pow[i - 1] * Base;
	}
	int l = 0, r = n >> 1;
	while (l < r)
	{
		int mid = l + r + 1 >> 1;
		if (Check(mid))
			l = mid;
		else r = mid - 1;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define __m  int mid=(l+r)>>1;

const int maxn=1000;
const int inf =2e9+7;
const int mod =1e9+7;

char num[maxn][maxn];
int main()
{
#ifdef LOCAL
    freopen("1.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    LL a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<endl;

}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int K = cin.nextInt();

        var index = new List<int>();
        int tmp = Console.Read();
        index.Add(0);
        if (tmp == '0')
        {
            index.Add(0);
        }

        for (int i = 1; i < N; i++)
        {
            int c = Console.Read();
            if (c != tmp)
            {
                index.Add(i);
                tmp = c;
            }
        }

        int max = 0;
        for (int i = 0; i < index.Count(); i++)
        {
            if (i % 2 == 0)
            {
                if (i + 2 * K + 1 < index.Count())
                {
                    max = Math.Max(index[i + 2 * K + 1] - index[i], max);
                }
                else
                {
                    max = Math.Max(N - index[i], max);
                }
            }
            else
            {
                if (i + 2 * K < index.Count())
                {
                    max = Math.Max(index[i + 2 * K] - index[i], max);
                }
                else
                {
                    max = Math.Max(N - index[i], max);
                }
            }
        }

        Console.WriteLine(max);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13232
import math
k=int(input())
ans=0
er=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(j,k+1):
            if j==l:
                er = er + math.gcd(i,math.gcd(j,l))
            ans=ans+2*(math.gcd(i,math.gcd(j,l)))

print(ans-er)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define MAX 101
#define INF 1000000

int main(void){
  int n, m, s, g1, g2;
  vector< vector<int> > g(MAX, vector<int>(MAX));

  while(cin >> n >> m >> s >> g1 >> g2, n | m | s | g1 | g2){
    for(int i=0; i < MAX; i++){
      for(int j=0; j < MAX; j++){
	g[i][j] = INF;
	if(i == j) g[i][j] = 0;
      }
    }
    for(int p=0; p < m; p++){
      int x, y, c;
      cin >> x >> y >> c;
      g[x][y] = c;
    }

    for(int i=1; i < n+1; i++)
      for(int j=1; j < n+1; j++)
	for(int k=1; k < n+1; k++)
	  g[j][k] = min(g[j][k], g[j][i] + g[i][k]);

    int ans = INF;
    for(int p = 1; p < n+1; p++){
      ans = min(g[s][p]+g[p][g1]+g[p][g2], ans);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
#define N 1000009
using namespace std;

int n,q[N]; char s1[N],s2[N];
int main(){
	scanf("%d%s%s",&n,s1+1,s2+1);
	if (!strcmp(s1+1,s2+1)){
		puts("0"); return 0;
	}
	int i,j,head=1,tail=0,ans=0;
	for (i=j=n; i; i--) if (s2[i]!=s2[i-1]){
		j=min(i,j);
		for (; j && s1[j]!=s2[i]; j--);
		if (!j){
			puts("-1"); return 0;
		}
		while (head<=tail && i<q[head]-(tail-head)) head++;
		if (i!=j) q[++tail]=j;
		ans=max(ans,tail-head+1);
	}
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll Max_N = 4000;
ll N;
string S;
int R[Max_N], G[Max_N], B[Max_N];

int main(){
    cin >> N;
    cin >> S;
    ll r = 0,g = 0, b = 0;
    REP(i,N){
        if(S[i]== 'R'){
            R[r] = i;
            r++;
        }
        else if(S[i] == 'G'){
            G[g] = i;
            g++;
        }
        else if(S[i] == 'B'){
            B[b] = i;
            b++;
        }
    }
    ll count = 0;
    if(!(r == 0 || g == 0 || b == 0)){
        /*REP(i,r){
            REP(k,g){
                REP(j,b){
                    int rg = abs(R[i] - G[k]);
                    int gb = abs(G[k] - B[j]);
                    int br = abs(B[j] - R[i]);
                    if(rg == gb || gb == br || br == rg){
                        count++;
                        if(rg == gb)
                }
            }
        }*/
        REP(i,N-2){
            FOR(k,1,(N + 1 -i)/2){
                if(S[i] != S[i+k] && S[i+k] != S[i+2*k] && S[i] != S[i+2*k]){
                    count++;
                }
            }
        }

        ll sum = r * g * b;
        cout << sum - count << endl;
    }
    else{cout << 0 <<endl;}

}

Measured memory_bytes: 3676
#include <stdio.h>
int main(void){
  int i,j=0;
  char s[10],t[10];
  scanf("%s",s);
  for(i=0;s[i]!=0;i++){
    if(s[i]=='0'||s[i]=='1'){
      t[j]=s[i];
      j++;
    }
    else{
      if(j!=0){
	t[j-1]=0;
	j--;
      }
    }
  }
  t[j+1]=0;
  if(t[j]!='0'||t[j]!='1') t[j]=0;
  printf("%s\n",t);
  return(0);
}

Measured memory_bytes: 128