akhauriyash/Code-Regression huggingface dataset:
target = input()
num_order = int(input())

for _ in range(num_order):
    order = input().split()
    a = int(order[1])
    b = int(order[2])
    
    if order[0] == "print":
        print(target[a:b + 1])
    elif order[0] == "reverse":
        target = target[:a] + "".join(list(reversed(target[a:b + 1]))) + target[b + 1:]
    else:
        p = order[3]
        target = target[:a] + p + target[b + 1:]


Measured memory_bytes: 5616
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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 INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> d(n+1);
    REP(i, n) cin >> d[i];
    d[n++] = 0;

    vector<ll> m(13, 0);
    REP(i, n) m[d[i]]++;

    if (*max_element(ALL_OF(m)) > 2) {
        cout << 0 << endl;
        return 0;
    }

    auto cond = [&](ll di) -> bool {
        return m[di] == 2 || di == 0 || di == 12;
    };
    vector<ll> ddbl;
    copy_if(ALL_OF(d), back_inserter(ddbl), cond);
    d.erase(remove_if(ALL_OF(d), cond), d.end());
    sort(ALL_OF(ddbl));
    REP(i, ddbl.size()) {
        if (ddbl[i] && i % 2) {
            ddbl[i] = (24 - ddbl[i]) % 24;
        }
    }

    ll n2 = d.size();
    ll ans = 0;
    
    REP(i, 1 << n2) {
        vector<ll> d2 = d;
        REP(j, n2) {
            if (i & 1 << j && d2[j]) {
                d2[j] = 24 - d2[j];
            }
        }
        copy(ALL_OF(ddbl), back_inserter(d2));
        sort(ALL_OF(d2));
        ll s = INF;
        REP(i, n) {
            ll diff = abs(d2[(i+1)%n] - d2[i]);
            chmin(s, min(diff, 24 - diff));
        }
        chmax(ans, s);
    }
    cout << ans << endl;

}

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

typedef long long ll;

ll calc(string s){
    ll res=0,tmp=0;
    for(int i=0;i<(int)s.length();i++){
        if(s[i]=='+'){
            res+=tmp;
            tmp=0;
        }
        else{
            tmp*=10;tmp+=s[i]-'0';
        }
    }
    return res+tmp;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    string s;cin>>s;
    int len=s.length();
    ll res=0;
    for(int i=0;i<(1<<(len-1));i++){
        ll tmp=i;
        string stmp="";stmp+=s[0];
        for(int j=1;j<len;j++){
            if(tmp%2) stmp+='+';
            stmp+=s[j];
            tmp/=2;
        }
            res+=calc(stmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int ans = 1;
		long tmp = x;
		while(tmp <= y) {
			if(tmp * 2 <= y) {
				ans++;
			
			}
			tmp = tmp*2;
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> step(n + 2, 0);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        step[a] = -1;
    }

    step[0] = 1;
    for (int i = 0; i < n; i++) {
        if (step[i] == -1) {
            continue;
        }

        if (step[i + 1] != -1) {
            step[i + 1] = (step[i + 1] + step[i]) % 1000000007;
        }
        if (step[i + 2] != -1) {
            step[i + 2] = (step[i + 2] + step[i]) % 1000000007;
        }
    }

    cout << step[n] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define MOD 1000000007

pair<ll, ll> operator-(const pair<ll, ll> &p1, const pair<ll, ll> &p2) {
  return make_pair(p1.first - p2.first, p1.second - p2.second);
}

pair<ll, ll> operator*(ll a, pair<ll, ll> &p) {
  return make_pair(p.first * a, p.second * a);
}

pair<ll, ll> euclid(ll x, ll y, pair<ll, ll> xc = {1, 0}, pair<ll, ll> yc = {0, 1}) {
  if(y == 0)
    return xc;

  return euclid(y, x % y, yc, xc - (x / y) * yc);
}

ll inverse(ll a) {
  return (euclid(MOD, a).second + MOD) % MOD;
}


vector<ll> factorial(210000), inverse_factorial(210000);

ll combination(ll a, ll b) {
  ll ret = (factorial[a] * inverse_factorial[a - b]) % MOD;
  ret = (ret * inverse_factorial[b]) % MOD;
  return ret;
}

int main(){

  ll tmp = 1;
  factorial[0] = 1;

  for(ll i = 1; i < 210000; i++) {
    factorial[i] = (factorial[i - 1] * i) % MOD;
  }

  inverse_factorial[0] = 1;

  for(ll i = 1; i < 210000; i++) {
    inverse_factorial[i] = (inverse_factorial[i - 1] * inverse(i)) % MOD;
  }

  int n;
  cin >> n;

  vector<int> a(n + 1);

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

  unordered_map<int, int> um;

  pair<int, int> duplicate;

  for(int i = 0; i < n + 1; i++) {
    if(um.find(a[i]) != um.end()) {
      duplicate = make_pair(um[a[i]], i);
    }
    um[a[i]] = i;
  }

  int x = n - (duplicate.second - duplicate.first);

  cout << n << endl;

  for(int i = 2; i <= n + 1; i++) {
    if(x < i - 1) {
      cout << combination(n + 1, i) << endl;
      continue;
    }
    cout << (combination(n + 1, i) + MOD - combination(x, i - 1)) % MOD << endl;

  }


}


Measured memory_bytes: 8996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <queue>

using namespace std;

using ll = long long;

ll N;
ll A[200005];
ll cnt[200005];

ll calc(ll n)
{
    return n*(n-1)/2;
}

int main()
{
    cin >> N;
    ll a;
    for(int i = 0;i < N;i++)
    {
        cin >> A[i];
        A[i]--;
        cnt[A[i]]++;
    }
    ll sum = 0;
    for(int i = 0;i < N;i++)
    {
        sum += calc(cnt[i]);
    }
    for(int i = 0;i < N;i++)
    {
        cout << sum - cnt[A[i]] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]){
    long int N;
    long int flow[5];
    std::cin >> N;
    for(auto &f : flow){
        std::cin >> f;
    }

    long int maxFlow = *std::min_element(std::begin(flow),std::end(flow));
    long int hasMod = N%maxFlow == 0 ? 0 : 1;
    std::cout << (N/maxFlow)+ hasMod + 4 << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = STDIN.gets.chomp.split('').sort.group_by{|t| t}.to_a
flg = true
n.each do |d|
 test = d.flatten.count - 1
  if !test.even?
    flg = false
  end
end

if flg
  puts 'Yes'
else
  puts 'No'
end



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

using namespace std;

constexpr int64_t mod_factor = 1'000'000'007LL;

int solve(const string& S) {
  if (S.front() != 'B' || S.back() != 'B')
    return 0;

  int64_t result = 1;
  bool is_left = true;
  int l_cnt = 1;
  int half = S.size() / 2;
  for (size_t i = 1; i < S.size(); ++i) {
    if (S[i] == S[i - 1]) {
      is_left = !is_left;
    }
    if (is_left) {
      ++l_cnt;
      if (l_cnt > half) {
        return 0;
      }
    } else {
      if (l_cnt <= 0) {
        return 0;
      }
      result = (result * l_cnt) % mod_factor;
      l_cnt -= 1;
    }
  }
  if (l_cnt != 0) {
    return 0;
  }
  for (int i = half; i > 1; --i) {
    result = (result * i) % mod_factor;
  }
  return result;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  auto ans = solve(S);
  cout << ans << endl;
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, L = map(int, input().split())
    A = list(map(int, input().split()))

    init = -1
    for i in range(1, n):
        if A[i] + A[i - 1] >= L:
            init = i
            break
    else:
        print("Impossible")
        exit()
    res = []
    for i in range(1, init):
        res.append(i)

    for i in reversed(range(init + 1, n)):
        res.append(i)
    res.append(init)
    print("Possible")
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 19788
N, W = map(int, input().split())
dp = [0] + [W+1] * (N*100)
for i in range(N):
    v, w = map(int, input().split())
    for j in range(i*100, -1, -1):
        if dp[j+v] > dp[j] + w:
            dp[j+v] = dp[j] + w

for v, w in zip(range(N*100, -1, -1), dp[::-1]):
    if w < W+1:
        print(v)
        break

Measured memory_bytes: 7956
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

struct LowLink {
    const vector<vector<int>> &G;
    vector<bool> used;
    vector<int> ord,low,articulation;
    vector<pair<int, int>> bridge;

    LowLink (const vector<vector<int>> &G) : G(G) {}

    int dfs(int v, int k, int pv) {
        used[v] = true;
        ord[v] = k++;
        low[v] = ord[v];
        bool is_articulation = false;
        int cnt = 0;
        for (auto &nv : G[v]) {
            if (!used[nv]) {
                ++cnt;
                k = dfs(nv, k, v);
                low[v] = min(low[v],low[nv]);
                is_articulation |= ~pv && low[nv] >= ord[v];
                if (ord[v] < low[nv]) bridge.emplace_back(minmax(v, nv));
            } else if (nv != pv) {
                low[v] = min(low[v],ord[nv]);
            }
        }
        is_articulation |= pv == -1 && cnt > 1;
        if (is_articulation) articulation.emplace_back(v);
        return k;
    }

    virtual void build() {
        used.assign(G.size(), false);
        ord.assign(G.size(), 0);
        low.assign(G.size(), 0);
        int k = 0;
        for (int i = 0; i < G.size(); i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M) {
        int s,t; cin >> s >> t;
        G[s].emplace_back(t);
        G[t].emplace_back(s);
    }

    LowLink LL(G);
    LL.build();
    sort(all(LL.bridge));
    for (auto i : LL.bridge) cout << i.first << " " << i.second << endl;
}



Measured memory_bytes: 4536
/*
 * I'm strong. Stronger than all of you. Extremely strong.
 * I can kill all those Titans there. Even if I'm alone.
 * You're either incompetent or you're spineless cowards.
 * How pathetic.
 * You can sit here and suck on your fingers. Yeah, do that.
 * ~ Mikasa Ackerman
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  LL N;
  cin >> N;
  assert(N < 1e9);
  const int MAX = 3500;
  int ba, bb, bc;
  int done = 0;
  for (LL a = 1; a <= MAX && !done; a++) {
    for (int b = a; b <= MAX; b++) {
      int l = b, r = MAX;
      while (l <= r) {
        int c = (l + r) / 2;
        LL diff = 4 * a * b * c - N * (a * b + b * c + c * a);
        if (diff == 0) {
          done = 1;
          ba = a;
          bb = b;
          bc = c;
          break;
        }
        if (diff < 0) l = c + 1;
        if (diff > 0) r = c - 1;
      }
    }
  }
  if (done) cout << ba << " " << bb << " " << bc << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,(input().split())))
M = max(a)
a.remove(M)
nim = 10**9
for i in range(len(a)):
    d = abs(M - a[i]*2)
    if d < nim:
        nim = d
        nimi = i
print(M,a[nimi])

Measured memory_bytes: 62704
if __name__=="__main__":
    N = int(input())+1
    i0 = 2
    i1 = 1
    if N==1:
        print(2)
    elif N==2:
        print(1)
    else:
        temp_x=i0
        temp_y=i1
        temp = 0
        i = 3
        while not i>N :
            temp = temp_x+temp_y
            temp_x = temp_y
            temp_y = temp
            i+=1
        print(temp)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a;
		int cnt = 0;
		for(int i=0;i<N;i++) {
			a = sc.nextInt();
			while(a%2 == 0) {
				cnt++;
				a /= 2;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 34136
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
sort(v.begin(),v.end());
ll sum=0;
for(ll i=0;i<n-k;i++)
{
    sum+=v[i];
}
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 2420
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int gcd(int a, int b) {
		while (a % b != 0) {
			int tmp = b;
			b = a % b;
			a = tmp;
		}
		return b;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int X = sc.nextInt();

		int[] x = new int[N];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			x[i] = Math.abs(a - X);
		}
		sc.close();

		if (N == 1) {
			out.println(x[0]);
			return;
		}

		Arrays.sort(x);

		int ans = x[0];
		for (int i = 1; i < N; i++) {
			ans = gcd(ans, x[i]);
		}

		out.println(ans);

	}

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

}


Measured memory_bytes: 50768
"use strict";

const gcdArray = array => {
    let len, a, b;
	
    len = array.length;
    a   = array[0];
	
    for (let i=1; i<len; i++) {
        b = array[i];
        a = getGcd(a, b);
    }

    return a;
}

const getGcd = (a, b) => {
    return a ? getGcd(b % a, a) : b;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    let A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>b-a);
    
    const max = A[0];
    let   gcd = gcdArray(A);
    
    if(max < K) {
        console.log("IMPOSSIBLE");
        return;
    }
    
    console.log(K % gcd === 0 ? "POSSIBLE" : "IMPOSSIBLE");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 28480
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    int n; 
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    rep(i, n) {
        cin >> x[i] >> u[i];
    }
    rep(i, n) {
        if(u[i] == "BTC") {
            x[i] *= 380000;
        }
    }
    double ans = 0;
    rep(i, n) {
        ans += x[i];
    }
    cout << ans << endl;
}


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


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

int n;
ll a[200005], b[200005];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    bool ok = true;
    rep(i, n) if (a[i] > b[i]) { ok = false; break; }
    if (!ok) { cout << -1 << endn; return; }

    priority_queue<pair<ll, int>> que;
    ll ans = 0;
    rep(i, n) if (a[i] < b[i]) que.emplace(b[i], i);
    while (!que.empty()) {
        auto i = que.top().second; que.pop();
        auto s = b[(i + 1) % n] + b[(n + i - 1) % n];
        bool update = false;
        while (a[i] < b[i] && b[i] > s) {
            update = true;
            if (a[i] >= s && (b[i] - a[i]) % s != 0) { update = false; break; }
            auto nb = max(a[i], b[i] % s);
            ans += (b[i] - nb) / s;
            b[i] = nb;
        }
        if (!update) break;
        if (a[i] < b[i]) que.emplace(b[i], i);
    }

    ok = true;
    rep(i, n) if (a[i] != b[i]) { ok = false; break; }
    if (ok) cout << ans << endn;
    else cout << -1 << endn;
}

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


Measured memory_bytes: 9584
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()

B = [0]*N

B[0] = sum(A)-2*sum(A[1::2])

for i in range(1,N):
    B[i] = 2*A[i-1]-B[i-1]

print(*B)

Measured memory_bytes: 63984
while True:
    [m,f,r] = map(int,input().split())
    if m==-1 and f==-1 and r==-1: break
    if  m==-1 or f==-1:
        gr='F'
    elif  m + f >=80:
        gr='A'
    elif  m + f >=65:
        gr='B'
    elif  m + f >=50:
        gr='C'
    elif  m + f >=30 and r>=50:
        gr='C'
    elif  m + f >=30:
        gr='D'
    else:
        gr='F'
    print(gr)

Measured memory_bytes: 7620
#include <stdio.h>

int main(void)
{
	int card[4][13] = {0};
	int i, j, k, x, n;
	char m;
	
	scanf("%d", &n);
	
	for(k = 0; k < n; k++)
	{
		scanf(" %c%d", &m, &x);
		
		if(m == 'S')
		card[0][x-1] = 1;
		else if(m == 'H')
		card[1][x-1] = 1;
		if(m == 'C')
		card[2][x-1] = 1;
		if(m == 'D')
		card[3][x-1] = 1;
	}
	
	for(i = 0; i < 4;i++)
	{
		for(j = 0;j < 13;j++)
		{
			if(card[i][j] == 0)
			{
				if(i == 0)
				printf("S %d\n", j + 1);
				else if(i == 1)
				printf("H %d\n", j + 1);
				else if(i == 2)
				printf("C %d\n", j + 1);
				else if(i == 3)
				printf("D %d\n", j + 1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a[3];
  rep(i,3) cin >> a[i];
  sort(a,a+3);
  pr(a[2]-a[0]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end

local function solve()
  if 0 < t[1] then return -1 end
  local cnt = 0
  for i = 2, n do
    if t[i - 1] + 1 < t[i] then
      return -1
    elseif t[i] < t[i - 1] + 1 then
      cnt = cnt + t[i - 1]
    end
  end
  return cnt + t[n]
end

print(solve())


Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n, max;
    cin >> n;
    max = 1;
    string S[n];
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
 
    sort(S, S+n);
    int A[n];
    A[0] = 1;
 
    for(int i = 1 ; i < n; i++){
        if(S[i-1] == S[i]){
            A[i] = A[i - 1] + 1;
            if(max < A[i]){
                max = A[i];
            }
        }else if(S[i - 1] != S[i]){
            A[i] = 1;
        }
    }
    for(int i = 0; i < n; i++){
        if(A[i] == max){
            cout << S[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

int main()
{
  int n;
  cin >> n;
  int num = 0;
  bool yes = false;
  for (int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    if (a == b)
    {
      num++;
    }
    else
    {
      num = 0;
    }
    if (num >= 3)
    {
      yes = true;
    }
  }

  if (yes)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9+21;
const long long LINF = (long long) 1e18;
const long double PI = 2 * acos((long double)0);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
#define Mahmud main()
#define endl "\n"
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define alla(arr,n) arr,arr+n
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define pb push_back
///Debug
#define dbg1(x) std::cerr<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<','<<#z<<"="<<(z)<<endl;
#define dbgArr(arr,n) cerr<<#arr<<"=["; printArray(arr,n,0,93); cerr<<endl;
///traversing
#define rep(n) for(int i=0;i<n;++i)
#define trv(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();++i)
///necessary functions
inline ll Int()
{
    ll _x=0,_tmp=1;
    char _tc=getchar();
    while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
    if( _tc == '-' ) _tc=getchar(), _tmp = -1;
    while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
    return _x*_tmp;
}
inline long double Double()
{
    long double d;
    scanf("%Lf",&d);
    return d;
}
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
int ton(string x)
{
    int y;
    std::istringstream ss(x);
    ss >> y;
    return y;
}
template<typename T>
string tostring(T x)
{
    ostringstream ss;
    ss << x ;
    return ss.str();
}

///Current Code vars
#define N 100010
long long n,k,c,d;
int arr[N+1],brr[N+1];
///Current Code functions

string s;

void solve()
{
    int a,b;
    cin>>a>>b;
    if((a+b)%3==0) puts("Possible");
    else if(a%3==0 || b%3==0) puts("Possible");
    else puts("Impossible");
}

int Mahmud
{
    // ios_base::sync_with_stdio(0); //cin.tie(0);
  //#ifdef _LOCAL_
    //freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
  //while(1)
    solve();
  //#ifdef _LOCAL_
    //printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
  //#endif
    return 0;
}


Measured memory_bytes: 256
s = input()
n = int(s)
r = 0

for bit in range(2**(len(s)-1)):
    e = s[0]
    for i in range(len(s)-1):
        if ((bit>>i)&1) == 1:
            e += '+'
        e += s[i+1]
    r += sum(map(int, e.split('+')))
print(r)


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

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

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

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

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

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

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

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

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

void solve()
{
    ll x;
    cin>>x;

    ll curr=100;
    For(i,0,3760)
    {
        curr=curr*(1.01);
        if(curr>=x)
        {
            cout<<i+1<<endl;
            return;
        }
    }


}

signed main() 
{
    fast_cin();
    
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

lint digs(lint a){//各桁の和
	lint re=0;
	while(a)re+=a%10,a/=10;
	return re;
}

int main(){
	lint n;cin>>n;cout<<(n%10?digs(n):10);
}

//sub-EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  int s[n],sum=0,j=0;
  for(int i=0;i<n;++i){
    cin>>s[i];
    sum+=s[i];
  }
  sort(s,s+n);
  if(sum%10==0){
    while(s[j]%10==0 && j!=n-1) j++;
    sum-=s[j];
  }
  if(j==n-1 && j>1) cout<<0<<endl;
  else cout<<sum<<endl;
  return 0;
}


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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> board(H, vector<char>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> board[i][j];
    }
  }
  int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (board[i][j] == '#') continue;
      int cnt = 0;
      for (int k = 0; k < 8; ++k) {
        int x = j + dx[k];
        int y = i + dy[k];
        if (x >= 0 && x < W && y >= 0 && y < H && board[y][x] == '#') cnt++; 
      }
      board[i][j] = '0' + cnt;
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cout << board[i][j];
    }
    cout << endl;
  }
}

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


long long int c, n, k, cisim[100][2], dp[102][100010], toplam=0;

long long int recursive(int konum, int kar){
	if(dp[konum][kar])return dp[konum][kar];
	if(kar==0)return 0;
	if(konum>=n)return 1000000010;
	if(kar<0)return 1000000010;
	dp[konum][kar]=min(recursive(konum+1, kar), recursive(konum+1, kar-cisim[konum][1])+cisim[konum][0]);
	return dp[konum][kar];
}

int main(void){
	cin>>n>>c;
	for(int i=0;i<n;i++){
		cin>>cisim[i][0]>> cisim[i][1];
		toplam+=cisim[i][1];
	}	
	for(int i=toplam;i>0;i--){
		int y=recursive(0,i);
		if(y<=c){
			cout<<i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 78080
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[4][13] = {};
	int x,y;
	char c[] = "SHCD";
	char b;
	for(int i=0;i<n;i++){
		cin >> b >> y;
		for(int j=0;j<4;j++) if(b==c[j]) x = j;
		a[x][y-1] = 1;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++) if(a[i][j]==0) cout << c[i] << " " << j+1 << endl;
	}
}



Measured memory_bytes: 3092
from math import gcd
n,m = map(int, input().split())
x = list(map(int, input().split()))

x.append(m)
x = sorted(x)
l = [0]*n
for i in range(n): l[i] = x[i+1] - x[i]

ans = l[0]
for i in range(1,n): ans = gcd(ans,l[i])
print(ans)

Measured memory_bytes: 20376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
string s;
string arr[5] = { "","dream","dreamer","erase","eraser" };
queue<int> q;
int main()
{
	cin >> s;
	q.push(0);
	while (!q.empty())
	{
		int p = q.front();
		q.pop();
		if (p == s.size())
		{
			cout << "YES" << endl;
			return 0;
		}
		for (int i = 1; i <= 4; i++)
		{
			if (s.substr(p, arr[i].size()) == arr[i])
			{
				q.push(p + arr[i].size());
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3712
N = gets.to_i

a = Array.new(3){Array.new(N+1)}

for i in 1..N do
  a[0][i], a[1][i], a[2][i] = gets.split.map(&:to_i)
end

dp = Array.new(N+1){Array.new(3)}

dp[1][0] = a[0][1]
dp[1][1] = a[1][1]
dp[1][2] = a[2][1]

for i in 2..N do
  for j in 0..2 do
    max = -Float::INFINITY

    for k in 0..2 do
      next if k==j
      gain = dp[i-1][k] + a[j][i]

      if gain > max
        max = gain
      end

    end

    dp[i][j] = max
  end
end

puts [dp[N][0], dp[N][1], dp[N][2]].max


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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int minv = Integer.parseInt(br.readLine());
      int n1   = Integer.parseInt(br.readLine());
      int maxv = n1- minv;
      if ( n1 < minv ) minv = n1;

      for( int i=2,r; i<n; i++) {
        r = Integer.parseInt(br.readLine());
        if ( r-minv > maxv ) maxv = r-minv;
        if ( r < minv ) minv = r; 
      }

      System.out.println(maxv);
    }
  }
}


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

int n;
int Num[233];
long long Min = 1e12;

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> Num[i];
	for(int i = - 100; i <= 100; i++){
		long long Now = 0;
		for(int j = 1; j <= n; j++) Now += (i - Num[j]) * (i - Num[j]);
		Min = min(Min, Now);
	}
	cout << Min << endl;
	return 0;
	
}

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

int main(){
    int N;
    cin>>N;
    if(N<105) cout<<0<<endl;
    else if(N<135) cout<<1<<endl;
    else if(N<165) cout<<2<<endl;
    else if(N<189) cout<<3<<endl;
    else if(N<195) cout<<4<<endl;
    else cout<<5<<endl;

}

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

int main() {
  vector<int> A(5);
  for (int i = 0; i < 5; i++) {
    cin >> A.at(i);
  }
  
  for(int i=0; i<5; i++){
    if(A.at(i) == 0){
      cout << (i+1) << endl;
    }
  }

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define MAXNUM 333333
int num[MAXNUM];
int main()
{
    int n,a;scanf("%d",&n);
    rep(i,1,n+1)scanf("%d",&a),num[a]++;
    sort(num+1,num+n+1);
    int nowres=n,nownum=n,nowpos=n,x=0;
    rep(i,1,n+1)
    {
        while(nowres*1ll*i>nownum)
        {
            nowres--;
            while(nowpos>0&&num[nowpos]>nowres)x++,nowpos--;
            nownum-=x;
        }
        printf("%d\n",nowres);
    }
}

Measured memory_bytes: 2048
fn main(){
    let nd: Vec<usize> = read_vec();
    let n = nd[0];
    let d = nd[1] as i64;
    let vxy: Vec<Vec<i64>> = (0..n).map(|_| read_vec()).collect();

    let ans: usize = vxy.iter().fold(0, |ct, xy| if xy[0] * xy[0] + xy[1] * xy[1] <= d * d {ct + 1} else {ct});
        
    println!("{}", ans)
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 12840
#include<stdio.h>
#include<string.h>
int main()
{
    char a[10];
    int i,flag=0;
    scanf("%s",a);
    for(i=0;a[i];i++)
        if(a[i]=='7')
        flag=1;
    if(flag==1)
        printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 1732
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define MAXN 5010
#define e 65436534565367ull

namespace IO
{
	inline int getint()
	{
		int x=0,p=1;char c;
		c=getchar();
		while (c<=32)c=getchar();
		if(c==45)p=-p,c=getchar();
		while (c>32)x=x*10+c-48,c=getchar();
		return x*p;
	}
	inline void _putint(int x)
	{
		if(x)_putint(x/10),putchar(x%10+48);
	}
	inline void putint(int x)
	{
		if(x==0) putchar(48);
	    else if(x<0)putchar(45),_putint(-x);
		else _putint(x);
	}
}

using namespace IO;

int main()
{
	int a,b,c;
	a=getint();
	b=getint();
	c=getint();
	int d=abs(b-c);
	if(d&1)printf("Borys\n");
	else printf("Alice\n");
	return 0;	
} 

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

signed main(){
	int a,b,c;cin>>a>>b>>c;
	
	for(int i=0;i<1000;i++){
		if((i*a)%b==c){
			cout<<"YES"<<endl;
			return 0;
			}
		}
	cout<<"NO"<<endl;	
	}


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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int gcd(int a, int b){
    if(a==b){
        return a;
    }
    if(a<b){
        swap(a, b);
        return gcd(b, a-b);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n, x; read(n, x);

    set<int> s;

    s.insert(x);

    for(int i=0; i<n; i++){
        int tmp; cin>>tmp;
        s.insert(tmp);
    }

    vector<int> v;

    for(int x: s){
        v.push_back(x);
    }

    int ans = v[1]-v[0];

    int vlen = v.size();

    for(int i=1; i<vlen-1; i++){
        int tmp = v[i+1]-v[i];
        ans = __gcd(ans, tmp);
    }

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

Measured memory_bytes: 8468
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
namespace mp = boost::multiprecision;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    vs a;
    string s;
    int l,n;
    cin>>n>>l;
    rep(i,n) cin>>s,a.pb(s);
    sort(all(a));
    for(auto s:a)cout<<s;
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;


const ll mod = 1e9+7;
const double eps = 1e-9;




void solve(){
    int h , a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 09.07.2020 09:46:09
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  vector<int> v;
  int tmp;
  REP(i,n)
  {
    cin>>tmp;
    v.emplace_back(tmp);
  }

  SORT(v);

  int cnt=1,ans=0;
  REP(i,n-1)
  {
    if(v[i]==v[i+1])cnt++;
    else
    {
      if(cnt%2!=0)ans++;
      cnt=1;
    }
  }

  if(cnt%2!=0)ans++;

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3832
#!/usr/bin/env python3
# coding=utf-8

import sys

n, y = map(int, sys.stdin.readline().strip().split(" "))
currents = [10000, 5000, 1000]
flag = False
for i in range(0, n + 1):
    if flag:
        break
    for j in range(0, n + 1 - i):
        if flag:
            break
        if currents[0] * i + currents[1] * j + currents[2] * (n - i - j) == y:
            print("{} {} {}".format(i, j, n - i - j))
            flag = True
if not flag:
    print("-1 -1 -1")


Measured memory_bytes: 3064
from numba import njit,prange


@njit(cache=True,parallel=True)
def solve(n,x,y):
    ans = [0] * (n - 1)
    for i in prange(n):
        for j in prange(n):
            c = min(abs(i - j), abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
            if c:
                ans[c-1] += 1
    return ans


n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = solve(n,x,y)
for ai in ans:
    print(ai//2)


Measured memory_bytes: 112320
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (register int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (register int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
long long a,b,ans;
int main()
{
	cin>>a>>b;
	if(a==1)ans+=300000;
	if(a==2)ans+=200000;
	if(a==3)ans+=100000;
	if(b==1)ans+=300000;
	if(b==2)ans+=200000;
	if(b==3)ans+=100000;
	if(a==1&&b==1) ans+=400000;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int w, a, b;
    scanf("%d %d %d", &w, &a, &b);
    
    if (a>b+w){
        printf("%d\n", a-b-w);
    }else if (b>a+w){
        printf("%d\n", b-a-w);
    }else{
        printf("%d\n", 0);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstring>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    char ch;
    char sentence[100];
    char cp[100] = {};
    scanf("%s", sentence);
    strcpy(cp, sentence);
    strcat(sentence, cp);

    char cs[100];
    scanf("%s", cs);

    if ( strstr(sentence, cs) == NULL ) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }



    return 0;
}


Measured memory_bytes: 3244
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S;
    cin>>S;
    if(S[0]==S[1]||S[0]==S[1]||S[1]==S[2]||S[2]==S[3])cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  ll n;
  cin >> n;
  int d = n;
  int c = 0;
  int b = 0;
  for(int i = 0; i < 10; i++) {
    if(n < 10) {
      c = c + n;
      b++;
      break;
    }
    if(b == 1) {
      break;
    }
    int a = n % 10;
    n = n - a;
    n = n / 10;
    c = c + a;
  }
  if(d % c == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc090_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<vector<int>> c(2, vector<int>(N, 0));
  rep(i, 2) {
    rep(j, N) { cin >> c[i][j]; }
  }

  ll ans = 0;
  rep(i, N) {
    ll tmp = 0;
    rep(j, N) {
      if (j == i) tmp += c[0][j];
      int l = (j >= i) ? 1 : 0;
      tmp += c[l][j];
    }
    ans = max(ans, tmp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3616
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    n, m = LI()
    if n == m:
        print("Yes")
    else:
        print("No")

    return


# B
def B():
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    A()
    return


# Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38384
N, M = map(int, input().split())
p = list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

unionfind = UnionFind(N + 1)
for _ in range(M):
    x, y = map(int, input().split())
    unionfind.union(x, y)
ans = 0
for i in range(N):
    if i + 1 != p[i]:
        if unionfind.same(p[i], i + 1):
            ans += 1
    else:
        ans += 1
print(ans)

Measured memory_bytes: 88940