akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int dp[5010][5010];

int main(void){
	int n; cin >> n;
	string str; cin >> str;

	int ans = 0;
	rep(i, n){
		rep2(j, i+1, n){
			if(str[i] == str[j]){
				if(i!=0 && i >= (j - dp[i-1][j-1])) continue;
				if(i==0) dp[i][j] = 1;
				else dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
			} else{
				dp[i][j] = 0;
			}
		}
	}

	rep(i, n){
		rep(j, n){
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 96896
#include <iostream>
#include <string>

void solve() {
    std::string s;
    std::cin >> s;

    for (auto c : s) {
        if (c == '?') c = 'D';
        std::cout << c;
    }
    std::cout << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3760
S=input()
flagA = False
flagB = False
flagC = False
for i in range(3):
  if S[i] == "a":
    flagA = True
  elif S[i] == "b":
    flagB = True
  elif S[i] == "c":
    flagC = True
  else:
    pass
if flagA and flagB and flagC:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9036
#include <stdio.h>

int main(){
    long long int N,K,a;
    long long int n1,n2;
    scanf("%lld %lld",&N,&K);
    a=N;
    if(N>=K){
        a=N%K;
    }
    

        n1=a;
        n2=K-n1;
        if(n1<n2){
            printf("%lld",n1);
        }
        else{
            printf("%lld",n2);
        }
    
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 13;

ll dp[100005][15];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.length();
    reverse(S.begin(), S.end());
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    ll d = 1;
    REP(i, N) {
        REP(j, MAX) {
            REP(n, 10) {
                if (S[i] != '?' && S[i] != '0' + n)
                    continue;
                ll m = (n * d + j) % MAX;
                dp[i + 1][m] += dp[i][j];
                dp[i + 1][m] %= MOD;
            }
        }
        d = d * 10LL % MAX;
    }
    cout << dp[N][5] << endl;
    return 0;
}

Measured memory_bytes: 12240
s = input()
l = len(s)
k = int(input())


def compare(a, b):
    ll = [a, b]
    ll = sorted(ll)
    return ll[0] == a


db = []
for length in range(1, k + 1):
    for start in range(l + 1 - length):
        candidate = s[start:start+length]
        if len(db) >= 5:
            if compare(candidate, db[-1]):
                if candidate not in db:
                    db.append(candidate)
                    db = sorted(db)
                    db = db[:5]
        else:
            if candidate not in db:
                db.append(candidate)
                db = sorted(db)

print(sorted(db)[k-1])


Measured memory_bytes: 3064
N, M = map(int, input().split())
C = [0] + list(map(int, input().split()))
C.sort()

dp = [[0] * (N+1) for _ in range(M+1)]
for i in range(N+1):
	dp[1][i] = i
for i in range(2,M+1):
	for j in range(1, N+1):
		if C[i] > j:
			dp[i][j] = dp[i-1][j]
		else:
			dp[i][j] = min(dp[i-1][j], dp[i][j-C[i]]+1)

print(dp[M][N])


Measured memory_bytes: 43732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main(void) {
    
    int n,m;
    cin>>n;
    vi v(n),w(n-1);
    set<int> s;
    rep(i,n){
        cin>>v[i];
        s.insert(v[i]);
    }
    Sort(v);
    m=v[n-1];
    rep(i,n-1){
        w[i]=min(v[i],m-v[i]);
    }
    Sort(w);
    cout<<m<<" ";
    if(s.count(w[n-2])){
        fin(w[n-2]);
    } else {
        fin(m-w[n-2]);
    }

}


Measured memory_bytes: 5760
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort(a,a+3);
    cout << a[0] + a[1]<< endl;



    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}

module Main where

import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.List
import Control.Applicative
import Control.Monad
import Data.Char
import Data.Maybe
import qualified Data.Map.Lazy as M

main :: IO ()
main = do
  [n, x] <- map (read . T.unpack) . T.words <$> T.getLine
  ms <- map (read . T.unpack) <$> replicateM (fromIntegral n) T.getLine
  print $ solve ms x

solve :: [Integer]  -> Integer -> Integer
solve ms x = (x - allKindAumValue) `div` cheep + (fromIntegral $ length ms)
  where
    allKindAumValue = sum ms
    cheep = minimum ms


Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int x;
	cin >> x;
	cout << 1 - x << endl;
}

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

int main(){
    int N;
    cin >> N;
    int n = N % 10;
    string ans;
    switch(n){
        case 0: 
            ans = "pon"; break;
        case 1: 
            ans = "pon"; break;
        case 6: 
            ans = "pon"; break;
        case 8: 
            ans = "pon"; break;
        case 3: 
            ans = "bon"; break;
        default:
            ans = "hon"; break;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
    int l = 2 * i;
    int r = 2 * i + 1;
    int largest;

    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;

    if (r <= H && A[r] > A[largest]) largest = r;

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    int maxv;
    if (H < 1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if (key < A[i]) return;
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i]) {
        swap(A[i], A[i / 2]);
        i = i / 2;
    }
}

void insert(int key) {
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main() {
    int key;
    char com[10];

    while (1) {
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}


Measured memory_bytes: 6476
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

ll gcd(ll x, ll y)
{
	ll r;

	if (x == 0 || y == 0)  // 引数チェック
	{
		fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll a, b, c, d, n, m, ans = 0, ret = M;
	string s, t;
	bool flag = false;
	cin >> n;
	vll v(n);
	vb ch(n,false);
	rep(i, n) {
		cin >> v[i];
		if (i + 1 == v[i]) ch[i] = true;
	}
	//rep(i, n) cout << ch[i] << " ";
	//cout << endl;
	rep(i, n) {
		if (i == 0) {
			if (ch[i]) {
				if (ch[i + 1]) {
					ans++;
					ch[i] = ch[i + 1] = false;
				}
				else {
					ans++;
					ch[i] = false;
				}
			}
		}
		else if (i == n - 1) {
			if (ch[i]) {
				if (ch[i - 1]) {
					ans++;
					ch[i] = ch[i - 1] = false;
				}
				else {
					ans++;
					ch[i] = false;
				}
			}
		}
		else {
			if (ch[i]) {
				if (ch[i + 1]) {
					ans++;
					ch[i] = ch[i + 1] = false;
				}
				else if (ch[i - 1]) {
					ans++;
					ch[i] = ch[i - 1] = false;
				}
				else {
					ans++;
					ch[i] = false;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
 
int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}
 
int32_t main()
{
	fast;

	int n, m;
	cin>>n>>m;
	if(n==m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> seen(1000009);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    seen[a[i]] += 1;
  }
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    if(seen[a[i]] > 1) continue;
    bool ok = true;
    for(int j = 1; j * j <= a[i]; ++j) {
      if(a[i] % j == 0) {
        if(j != a[i]) ok &= seen[j] == 0;
        if(j * j != a[i]) {
          int k = a[i] / j;
          if(k != a[i]) ok &= seen[k] == 0;
        }
      }
    }
    ans += ok;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 7952
def run(N, S):
    ret = 0
    for i in range(1, N-1):
       ret = max([ret, num_dup(N, S, i)])
    return ret


def num_dup(N, S, x):
    '''
    0 < x < N-1
    '''
    s1 = list(set(S[:x]))
    s2 = list(set(S[x:]))
    cnt = 0
    for ss in s1:
        if ss in s2:
            cnt += 1
    return cnt

def main():
    N = int(input())
    S = input()
    print(run(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[fastout]
fn main() {
    input! {
        n: usize,
        xy: [(i64, i64); n]
    }
    let mut u = vec![];
    let mut v = vec![];
    for (x, y) in xy {
        u.push(x - y);
        v.push(x + y);
    }
    u.sort();
    v.sort();
    let ans = max(u[n - 1] - u[0], v[n - 1] - v[0]);
    println!("{}", ans);
}


Measured memory_bytes: 12412
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const long long oo = 1e16;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	long long n; cin >> n;
	long long ans = oo;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			long long d = n / i;
			ans = min(ans, (i - 1) + (d - 1));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

struct Vector {
	double x;
	double y;
};

#define Vectex Vector;

Vector sub_vector(const Vector& a, const Vector&b) {
	Vector ret;
	ret.x = a.x - b.x;
	ret.y = a.y - b.y;
	return ret;
}

int main() {
	double x1, y1, x2, y2, x3, y3, px, py; 
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> px >> py) {
		Vector A, B, C, P;
		A.x = x1; A.y = y1;
		B.x = x2; B.y = y2;
		C.x = x3; C.y = y3;
		P.x = px; P.y = py;

		Vector AB = sub_vector(B, A);
		Vector BP = sub_vector(P, B);
		Vector BC = sub_vector(C, B);
		Vector CP = sub_vector(P, C);
		Vector CA = sub_vector(A, C);
		Vector AP = sub_vector(P, A);

		double c1 = AB.x * BP.y - AB.y * BP.x;
		double c2 = BC.x * CP.y - BC.y * CP.x;
		double c3 = CA.x * AP.y - CA.y * AP.x;

		if((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) printf("YES\n");
		else printf("NO\n"); 
	}	
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define For(i,n,k) for(int i=(n);i<(k);i++)
typedef long long ll;
vector<int> div(int x){
    vector<int> ret;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            ret.emplace_back(i);
            if(i*i!=x) ret.emplace_back(x/i);
        }
    }
    sort(ret.rbegin(),ret.rend());
    return ret;
}
int main(){
    int n,k;
    cin >> n >> k;
    int sum=0;
    vector<int> a(n);
    For(i,0,n){
        cin >> a[i];
        sum += a[i];
    }
    vector<int> divs = div(sum);
    for(auto x:divs){
        vector<ll> p;
        For(i,0,n){
            if(a[i]%x){
                p.emplace_back(a[i]%x);
            }
        }
        if(p.size()==0){
            cout << x << endl;
            return 0;
        }
        sort(p.begin(),p.end());
        ll l=0,r=x*p.size() - accumulate(p.begin(),p.end(),0);
        ll cnt = 1e9;
        For(i,0,p.size()){
            l+=p[i];
            r-=(x-p[i]);
            if(l%x == r%x)cnt = min(cnt,max(l,r));
        }
        if(cnt<=k){
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
kill_cnt = 0
for i in range(N):
  if B[i] >= A[i]:
    kill_cnt += A[i]+min(A[i+1],B[i]-A[i])
    A[i+1] = max(A[i+1]-(B[i]-A[i]),0)
  else:
    kill_cnt += B[i]
print(kill_cnt)


Measured memory_bytes: 18624
n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
xy.sort(key = lambda x: x[1])
xy.sort()
if n == 1:
    print(1)
else:
    dif = []
    for i in range(n):
        for j in range(i + 1, n):
            dif.append((xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]))
    count_dif = {}
    for i in dif:
        count_dif.setdefault(i, 0)
        count_dif[i] += 1
    print(n - max(count_dif.values()))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll L, R;
    cin >> L >> R;
    ll M = 2019;
    ll ans = 2018;
    for ( ll i = L; i <= min(L+2018, R); i++ ) {
        for ( ll j = i+1; j <= min(i+2019, R); j++ ) {
            ll x = i * j % M;
            if ( ans > x ) ans = x;
        }
    }

    cout << ans << "\n";
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> av(n);
  for(auto& a : av){
    cin >> a;
  }

  int ret = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; ++j){
      ret = max(ret, abs(av[i] - av[j]));
    }
  }

  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, c int
	fmt.Sscan(getNextLine(scanner), &n, &c)
	dd := make([][]int, c)
	cc := make([][]int, n)
	counts := make([][]int, 3)
	for i := 0; i < 3; i++ {
		counts[i] = make([]int, c)
	}
	for i := 0; i < c; i++ {
		dd[i] = getIntList(scanner)
	}
	for i := 0; i < n; i++ {
		cc[i] = getIntList(scanner)
		for j := 0; j < n; j++ {
			cc[i][j]--
			counts[(i+j)%3][cc[i][j]]++
		}
	}
	min := -1
	for i := 0; i < c; i++ {
		for ii := 0; ii < c; ii++ {
			if i == ii {
				continue
			}
			for iii := 0; iii < c; iii++ {
				if i == iii || ii == iii {
					continue
				}
				ds := 0
				for ci := 0; ci < c; ci++ {
					ds += dd[ci][i] * counts[0][ci]
					ds += dd[ci][ii] * counts[1][ci]
					ds += dd[ci][iii] * counts[2][ci]
				}
				if min == -1 || min > ds {
					min = ds
				}
			}
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 4864
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
map<ll,bool>mp;
void solve(){
	ll n;
	cin>>n;
	if(n==2){cout<<1;return;}
	ll ans=2;
	for(ll i=2;i<=sqrt(n);i++){
		ll nn=n;
		while(nn%i==0)nn/=i;
		nn%=i;
		if(nn==1)ans++;
		mp[i]=1;
		nn=n;
		ll j=n/i;
		if(mp[j])continue;
		while(nn%j==0)nn/=j;
		nn%=j;
		if(nn==1)ans++;
		mp[j]=1;
	}
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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






int main() {
  
  char a;
  cin>>a;
  
  if(a=='A')cout<<'T'<<endl;
  if(a=='G')cout<<'C'<<endl;
  if(a=='C')cout<<'G'<<endl;
  if(a=='T')cout<<'A'<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>

using namespace std;

bool judge(char c);

int main(){
    string S;
    cin >> S;
    
    int cnt = 0;
    bool flug;      // true: white, false: black
    
    flug = judge(S[0]);
    for(int i = 1; i < S.length(); i++){
        if(flug != judge(S[i])){
            cnt++;
            flug = judge(S[i]);
        }
    }
    cout << cnt << endl;
}

bool judge(char c){
    if(c == 'W')        return true;
    else if(c == 'B')   return false;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

[A, B] = [int(i) for i in input().split()]

print(lcm(A, B))

Measured memory_bytes: 3060
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
int gcd(int x,int y){
  if(y==0)return x;
  else return gcd(y,x%y);
}

int main(void){
  int x,y;
  cin>>x>>y;
  cout<<gcd(x,y)<<endl;
  return 0;
}



Measured memory_bytes: 3116
def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)

n=int(input())
a=[int(i) for i in input().split()]

l=[0 for i in range(n)]
r=[0 for i in range(n)]
  
for i in range(1,n):
  l[i] = gcd(l[i-1],a[i-1])
  
for i in range(n-1)[::-1]:
  r[i] = gcd(r[i+1],a[i+1])
  
lr = [gcd(l[i],r[i]) for i in range(n)]
print(max(lr))

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  if (N/100 == 7 ) {
    cout << "Yes" << endl;
  }
 
  else if ( (N%100)/10 == 7 ) {
    cout << "Yes" << endl;
  }
 
  else if ( N%10 == 7 ) {
    cout << "Yes" << endl;
  }
 
  else {
    cout << "No" << endl;
  }
 
  
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
struct Coord{
  int x;
  int y;
  int trouble;
};
class Queue{
public:
  vector<Coord> vec;
  Queue(int num);
  int QSize();
  Coord TakeOut();
  void InPut(int x,int y,int trouble);
};
Queue::Queue(int num){
  vec.resize(num);
  for(int i=0;i<num;i++){
    vec[i].x=0;
    vec[i].y=0;
    vec[i].trouble=0;
  }
}
int Queue::QSize(){
  return vec.size();
}
Coord Queue::TakeOut(){
  Coord coord = vec[0];
  vec.erase(vec.begin());
  return coord; 
}
void Queue::InPut(int x,int y,int trouble){
  Coord coord;
  coord.x=x;
  coord.y=y;
  coord.trouble=trouble;
  vec.push_back(coord);
}
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<bool> > maze(h+2);
  for(int i=0;i<h+2;i++) maze[i].resize(w+2);
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      maze[i][j]=false;
    }
  }
  int wsum=0;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      char c;
      cin >> c;
      if(c=='.'){
	maze[i][j]=true;
	wsum++;
      }
    }
  }
  Queue queue(0);
  queue.InPut(1,1,0);
  while(1){
    Coord coord=queue.TakeOut();
    int x=coord.x;
    int y=coord.y;
    int t=coord.trouble;
    if(x==h&&y==w){
      cout << wsum-1-t << "\n";
      break;
    }
    if(maze[x+1][y]==true){
      queue.InPut(x+1,y,t+1);
      maze[x+1][y]=false;
    }
    if(maze[x-1][y]==true){
      queue.InPut(x-1,y,t+1);
      maze[x-1][y]=false;
    }
    if(maze[x][y+1]==true){
      queue.InPut(x,y+1,t+1);
      maze[x][y+1]=false;
    }
    if(maze[x][y-1]==true){
      queue.InPut(x,y-1,t+1);
      maze[x][y-1]=false;
    }
    
    if(queue.QSize()==0){
      cout << -1 << "\n";
      break;
    }
  }

  return 0;
}


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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  for (int i = 0; i < N; i++) {
    string s = S.substr(i, N-i), t = T.substr(0, N-i);
    if (s == t) {
      cout << 2*N - (N - i) << endl;
      return 0;
    }
  }
  cout << 2 * N << endl;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
min_a = []
for i in a:
    min_a.append(i)
ans = 10 ** 18
for i in range(N):
    s = x * i
    for j in range(N):
        min_a[j] = min(min_a[j], a[(i + j) % N])
        s += min_a[j]
    ans = min(ans, s)
print(ans)

Measured memory_bytes: 42844
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)

int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt = s.size();
	rep(i, s.size()) {
		if (i != s.size() - 1) {
			if (s[i] == s[i + 1]) cnt--;
		}
	}
	cout << cnt << endl;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, substring, erase, push_back,stoll、stoi

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed

ll n;
cin>>n;
ll f[n+1];
mem(f,0);
for(ll x=1;x*x<=n;x++)
{
	for(ll y=1;y*y<=n;y++)
	{
	for(ll z=1;z*z<=n;z++)
	{
		ll k=x*x+y*y+z*z+x*y+y*z+z*x;
		if(k<=n) f[k]++;	
	}
	
	}
}

rep(i,1,n+1)
{
	cout<<f[i]<<endl;
}
}


Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            
            string S = Console.ReadLine();
            string[] line = S.Split(' ');
            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);
            int C = int.Parse(line[2]);

            if((C > A && B > C) || (C > B && A > C))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 11092
S = input()

li = []
cnt = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        cnt += 1
    else:
        li.append(cnt)
        cnt = 0
li.append(cnt)

print(max(li))

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main()
{
  int N;
  cin>>N;
  string A;
  cin>>A;
  if(N%2==1)
  {
    cout<<"No"<<endl;
  }
  int mi=N/2;
  if(N%2==0)
  {
    REP(i,mi)
    {
      if(A[i]!=A[i+mi])
      {
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
  }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,t,a,d,m;
    cin>>n>>t>>a;
    double p;
    vector<pair<double,ll>>x;
    for(ll i=0;i<n;i++)
    {
        cin>>m;
        p=(.006)*(double)m;
        p=(double)t-p;
        //cout<<p<<endl;
        p-=(double)a;
        if(p<0)
            p=-p;
        //cout<<p<<endl;
        x.push_back({p,i});
    }
    sort(x.begin(),x.end());
    cout<<(x[0].second)+1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
//#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define countBit(x)     __builtin_popcountll(x)
const int mod = 1000000007ll;
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define inf 1e10
#define Integer int
#define Double long double
#define String string
#define HashMap unordered_map
#define ArrayList vector
#define HashSet unordered_set
#define TreeSet ordered_set 
#define TreeMap ordered_map
#define Long int
#define containsKey count
#define Stack stack 
#define PriorityQueue priority_queue
#define Deque deque
#define addFirst push_front
#define addLast push_back
#define add push_back
#define removeFirst pop_front
#define removeLast pop_back
#define Boolean bool
#define boolean bool
const int N=4003;
int dp[N][N][4],input[N];

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    String arr;
    cin>>n>>arr;

        for(int i=0;i<n;i++){
            if(arr[i]=='G')input[i]=1;
            else if(arr[i]=='B')input[i]=2;
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(input[i]!=input[j]){
                    int w=input[j];
                    dp[i][j-i][w]++;
                    dp[i][n][w]++;
                    dp[i][n][3]++;
                }
            }
        }
        //debug(dp);
    //   debug(dp[2][1][2]);
    //   debug(dp[2][n][3]);

        long ans=0;
        int xx=1^2;

        for(int i=0;i<n;i++){
           // debug("hi");

            for(int j=i+1;j<n;j++){
                if(input[i]!=input[j]){
                    ans+=dp[j][n][3]-dp[j][n][input[i]];
                    int k=xx^input[i]^input[j];
                    ans-=dp[j][j-i][k];
                }
               // debug(ans);
            }
        }
    cout<<ans;
    return 0;
}

//       g++ -g main.cpp ; ./a.exe

Measured memory_bytes: 144092
#include <stdio.h> 


int main() 

{

long int n,a,e; 

scanf("%ld %ld",&n,&a); 

if(n<500 && n>a)
{
printf("No\n"); 
}
else if(n>=500) 
{
e=n%500; 
if(e==0 || e<=a) 
{ 
printf("Yes\n"); 
}
else if(e>a) 
{
printf("No\n"); 
}
}
else if(n<=a)
{
printf("Yes\n"); 
} 
return 0; 
}  

Measured memory_bytes: 1644
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

const int N = 1e5 + 5;

int n;
int arr[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>n;
    ll sum = 0;
    REP(i,1,n){
        cin>>arr[i];
        sum += arr[i];
    }
    ll nn = (ll)n * (n+1) / 2;
    if(sum % nn != 0){
        cout << "NO" << endl;
    }else{
        ll k = sum/nn;
        bool fail = false;
        REP(i,1,n){
            int j = i+1;
            if(i == n)j = 1;

            ll diff = arr[j] - arr[i];
            diff += k*n - k;
            if(diff < 0 || arr[j]-arr[i] > k || diff % n != 0){
                fail = true;
            }
        }

        if(fail)cout << "NO" << endl;
        else cout << "YES" << endl;
    }

    return 0;
}


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

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fill(x,v) memset(x,v,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x <<": " << x << endl

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double C;

vii rpta;

void imp(){
    cout << rpta.size() << endl;
    ii aux;
    while(rpta.size()){
        aux = rpta.back();
        cout << aux.ff << " " << aux.ss << endl;
        rpta.pop_back();
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    ll k,a,b;
    cin >> k >> a >> b;
    ll fact1 = a/llabs(a);
    ll fact2 = b/llabs(b);
    a*=fact1;
    b*=fact2;
    if((a+b) == k){
        rpta.pb(mp(a*fact1, b*fact2));
        imp();
    }
    else{
        while((a+b) > 2*k){
            rpta.pb(mp(a*fact1, b*fact2));
            if(a>=k) a-=k;
            else if(a>0){b-=(k-a) ; a=0;}
            else{b-=k;}; 
        }
        if(k%2){
            if((a+b)%2){
                rpta.pb(mp(a*fact1, b*fact2));
                if((a+b)/k){
                    if(a>=k) a-=k;
                    else if(a>0){b-=(k-a) ; a=0;}
                    else{b-=k;}; 
                }
                else{
                    a+=k;
                }
            }
            rpta.pb(mp(a*fact1, b*fact2));
            ll pri, sec;
            pri = k - (a+b)/2;
            sec = k - pri;
            if(b-sec>=0) {a+=pri; b-=sec;}
            else {a-=sec; b+=pri;};
            rpta.pb(mp(a*fact1, b*fact2));
            imp();
        }
        else{
            if((a+b)%2) cout << -1 << endl;
            else{
                rpta.pb(mp(a*fact1, b*fact2));
                ll pri, sec;
                pri = k - (a+b)/2;
                sec = k - pri;
                if(b-sec>=0) {a+=pri; b-=sec;}
                else {a-=sec; b+=pri;};
                rpta.pb(mp(a*fact1, b*fact2));
                imp();
            }
        }
    }
    return 0;
}

Measured memory_bytes: 7276
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    string s,t;cin>>s>>t;
    ll n;n=s.size();
    ll m;m=t.size();
    bool b=false;
    bool bb;
    string ans="";
    for(ll i=0;i<=n-m;i++){
        bb=true;
        rep(j,0,m-1){
            if(t[j]==s[n-m-i+j] || s[n-m-i+j]=='?'){
                
            }else{
                bb=false;
                break;
            }
        }
        if(bb==true){
            b=true;
            rep(k,0,n-1){
                if(k>=n-m-i && k<=n-i-1){
                    ans=ans+t[k-(n-m-i)];
                }else{
                    if(s[k]=='?'){
                        ans=ans+'a';
                    }else{
                        ans=ans+s[k];
                    }
                }
            }
            
            break;
        }
        
    }
    if(b==1){
        cout<<ans<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d; 
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d);
}   
    
    
     

     
   





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

int main() {
  ll r,d,x; cin >> r >> d >> x;
  ll g = x;
  
  rep(i, 10){
    g = r*g - d;
    cout << g << endl;
  }
}

Measured memory_bytes: 3520
N = str(input())
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if int(N[-1]) in hon:
  print("hon")
elif int(N[-1]) in pon:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9184
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
int n,d,x,w,ans;
int main() {
	read(n);
	read(d),read(x);
	while(n--) {
		read(w);
		ans+=1+(d-1)/w;
	}
	writeln(ans+x);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll x,n;
    cin>>x>>n;
    bool c[105];
    fill(c,false);
    for(ll i=0;i<n;i++){
      ll k;
      cin>>k; 
      c[k]=true; 
    }
    ll l=x,r=x;
    while(1){
      if(c[l]==false){
        cout<<l<<endl; 
        break; 
      }
      if(c[r]==false){
        cout<<r<<endl; 
        break; 
      }
      l--,r++;
    }
    
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3620
N = int(input())
S = input()
cntE = [0 for _ in range(N)]
cntW = [0 for _ in range(N)]
for i in range(N):
    if S[i] == "E":
        cntE[i] = cntE[i-1]+1
        cntW[i] = cntW[i-1]
    else:
        cntE[i] = cntE[i-1]
        cntW[i] = cntW[i-1]+1
sumE = cntE[N-1]
sumW = cntW[N-1]
ans = sumE-cntE[0]
for i in range(1,N):
    ans = min(ans,cntW[i-1]+(sumE-cntE[i]))
print(ans)

Measured memory_bytes: 17868
#include<stdio.h>
#include<iostream>

using namespace std;

int main() {

	int a = 0;//整数変数aを作る
	int b = 0;//整数変数bを作る

	cin >> a >> b;//2つの数字を受け取り、a,bに代入

	cout << a * b << endl;//a*bを出力

	return 0;


}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>

char s[105];
int n;

bool check(int l, int r)
{
	while (l < r)
		if (s[l++] != s[r--])
			return false;
	return true;
}

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (check(1, n) && check(1, (n - 1) / 2) && check((n + 3) / 2, n))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
ll n;
cin>>n;
n--;
ll p=((n)*(n+1))/2;
cout<<p<<endl;
return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n;
	cin >>n;
	vector<int> v(n+2);
	v[0] = 0;
	rep(i,n) cin >> v[i+1];
	v.push_back(0);
	
	int alldist = 0;
	for(int i = 1 ; i < n + 2 ; i++){
		alldist+=abs(v[i]-v[i-1]);
	}
	
	vector<int> ans(n);
	For(i,1,n+1){
		ans[i] = alldist - abs(v[i]-v[i-1]) -abs(v[i+1]-v[i])+abs(v[i+1]-v[i-1]) ;
	}
	For(i,1,n+1){
		cout << ans[i] <<endl;
	}

}


Measured memory_bytes: 2040