akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	ll H;
	cin >> H;
	ll ans = 0;
	ll t = 1;
	while (H != 1)
	{
		ans += t;
		t *= 2;
		H /= 2;
	}
	ans += t;
	cout << ans;


}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

Measured memory_bytes: 256
#ABC 122 C - GeT AC 18:47
n, q = map(int, input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
for i in range(q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 71860
n=int(input())
mod=int(1e9)+7
l=[int(x) for x in input().split()]
sum1=0
sum2=0
for i in range(n):
    sum2=(sum2%mod+l[i]%mod)%mod
for i in range(n-1):
    sum2=sum2-l[i]
    x=(sum2%mod*(l[i]%mod))%mod
    sum1=(sum1%mod+(x%mod))%mod
print(sum1)


Measured memory_bytes: 105168
import scala.util.control.Breaks
object Main extends App {
  val b = new Breaks()
  b.breakable {
    while (true) {
      val Seq(h, w) = readLine().split(' ').map(_.toInt).toList

      if ((h, w) == (0, 0)) b.break

      println((("#" * w)  + '\n') * h)
    }
  }
}


Measured memory_bytes: 44192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){
	ll N, M, D;
	cin >> N >> M >> D;

	cout << fixed << setprecision(9) << (D == 0 ? (double)(M-1) / N : (double) (M-1) * (N-D) * 2 / N / N) << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    
   ll n;
   cin >> n;
   ll k;
   cin >> k;

    map<ll,ll> MAP;
   for(ll i=0;i<k;i++){
       ll sz;
       cin >> sz;
       while(sz--){
           ll val;
           cin >> val;
           MAP[val]++;
       }
   }
    ll c=0;
   for(ll i=1;i<n+1;i++){
       if(MAP.count(i));
       else c++;
   }
    cout << c ;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007 
#define PI atan(1)*4

typedef long long ll;
typedef long double ld;
using namespace std;


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

ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y>0){
        if(y&1)res = (res*x)%MOD;
        y = y>>1;
        x = (x*x)%MOD;
    }
    return res;
}

//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

vector<bool> vis;
vector<int> dp;
vector<vector<int> > adj;

void dfs(int n){
    for(int i = 0; i < adj[n].size();i++){
        if(!vis[adj[n][i]]){
            vis[adj[n][i]] = true;
            dfs(adj[n][i]);
        }
    }
    for(int i = 0; i < adj[n].size();i++){
        dp[n] = max(dp[n] , 1 + dp[adj[n][i]]);
    }
}
int main(){
    init;
    int n,m,i,j,k,l,p;
    cin>>n>>m;
    vis.resize(n+1 , false);
    dp.resize(n+1 , 0);
    adj.resize(n+1);
    for(i=0;i<m;i++){
        cin>>j>>k;
        adj[j].emplace_back(k);
    }
    for(i = 1;i <= n;i++){
        if(!vis[i]){
            vis[i] = true;
            dfs(i);
        }
    }
    cout<<(*max_element(dp.begin(),dp.end()))<<endl;
    return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    long long int x[n],y[n];
    for(int i=0;i<n;i++)cin >> x[i] >> y[i];
    long long int ans=5e18;
    if(k==2){
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                ans=min(ans,abs(x[i]-x[j])*abs(y[i]-y[j]));
            }
        }
        cout << ans;
    }
    else if(k==3){
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                for(int l=j+1;l<n;l++){
                    long long int MAX=max(x[i],max(x[j],x[l]));
                    long long int MAY=max(y[i],max(y[j],y[l]));
                    long long int MIX=min(x[i],min(x[j],x[l]));
                    long long int MIY=min(y[i],min(y[j],y[l]));
                    ans=min(ans,(MAX-MIX)*(MAY-MIY));                    
                }
            }
        }
        cout << ans;
    }
    else{
        for(int i=0;i<n-3;i++){
            for(int j=i+1;j<n-2;j++){
                for(int l=j+1;l<n-1;l++){
                    for(int m=l+1;m<n;m++){
                        long long int MAX=max(max(x[i],x[m]),max(x[j],x[l]));
                        long long int MAY=max(max(y[i],y[m]),max(y[j],y[l]));
                        long long int MIX=min(min(x[i],x[m]),min(x[j],x[l]));
                        long long int MIY=min(min(y[i],y[m]),min(y[j],y[l]));
                        int count=0;
                        for(int a=0;a<n;a++)if(x[a]<=MAX && x[a]>=MIX && y[a]<=MAY && y[a]>=MIY)count++;
                        if(count>=k)ans=min(ans,(MAX-MIX)*(MAY-MIY));
                    }
                }
            }
        }
        cout << ans;
    }    
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    for(ll i = 0; i < 3; i ++)
    {
        cin >> a[i];
    }
    sort(a, a + 3);
    for(ll i = 0; i < 2; i ++)
    {
        sum += abs(a[i] - a[i+1]);
    }
    cout << sum;
}


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

int main() {
	int a, b, c;
	int i = 0;
	cin >> a >> b >> c;
	for (int x = a;x <= b;x++) {
		if ((c % x) == 0)i++;
	}
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 3088
#上流からスコアが流れてくるイメージ
from sys import stdin
from collections import deque
input = stdin.readline


def bfs():
  d.append(0)
  trace[0] = 1
 
  while d:
    now = d.pop()
    for next in g[now]:
      if trace[next] == 0:
        trace[next] = 1
        score[next] += score[now]
        d.append(next)


n,q = map(int,input().split())
g = [[] for i in range(n)]

trace = [0]*n#頂点の個数
score = [0]*n

for i in range(n-1):#各々の頂点から行ける頂点のリスト
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  g[a].append(b)
  g[b].append(a)

for i in range(q):
  p,x = map(int,input().split())
  p -= 1
  score[p] += x

d = deque([])

bfs()
      
print(*score)

Measured memory_bytes: 93716
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.nextLine();
		
		if(s.equals("ABC")) {
			System.out.println("ARC");
			}
		
		else if(s.equals("ARC")){
			System.out.println("ABC");
			
		}
 
	}
 
}

Measured memory_bytes: 35760
module BinaryTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable left : int;
    mutable right : int;
    mutable depth : int;
    mutable height : int;
  }

  let make () = {
    parent = nil;
    left = nil;
    right = nil;
    depth = nil;
    height = nil
  }
end

module T = BinaryTree

let _ =
  let n = read_int () in
  let t = Array.init n (fun _ -> T.make ()) in
  let rec read i =
    if i < n then begin
      let id, l, r = Scanf.scanf "%d %d %d\n" (fun id l r -> id, l, r) in
      t.(id).T.left <- l;
      t.(id).T.right <- r;
      if l <> T.nil then t.(l).T.parent <- id;
      if r <> T.nil then t.(r).T.parent <- id;
      read (i + 1)
    end
  in
  read 0;
  let rec search_root i =
    if i = n then T.nil
    else if t.(i).T.parent = T.nil then i
    else search_root (i + 1)
  in
  let root = search_root 0 in
  let rec set_depth i d =
    t.(i).T.depth <- d;
    if t.(i).T.left <> T.nil then set_depth t.(i).T.left (d + 1);
    if t.(i).T.right <> T.nil then set_depth t.(i).T.right (d + 1);
  in
  set_depth root 0;
  let rec set_height i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).T.left <> T.nil then (set_height t.(i).T.left; hl := t.(t.(i).T.left).T.height + 1);
    if t.(i).T.right <> T.nil then (set_height t.(i).T.right; hr := t.(t.(i).T.right).T.height + 1);
    let h = max !hl !hr in
    t.(i).T.height <- h;
  in
  set_height root;
  let get_sibling i =
    if t.(i).T.parent = T.nil then T.nil
    else if t.(t.(i).T.parent).T.left <> i && t.(t.(i).T.parent).T.left <> T.nil then t.(t.(i).T.parent).T.left
    else if t.(t.(i).T.parent).T.right <> i && t.(t.(i).T.parent).T.right <> T.nil then t.(t.(i).T.parent).T.right
    else T.nil
  in
  let get_degree i =
    0 + (if t.(i).T.left <> T.nil then 1 else 0) + (if t.(i).T.right <> T.nil then 1 else 0)
  in
  let print i =
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).T.parent;
    print_string ", sibling = "; print_int (get_sibling i);
    print_string ", degree = "; print_int (get_degree i);
    print_string ", depth = "; print_int t.(i).T.depth;
    print_string ", height = "; print_int t.(i).T.height;
    print_string (if t.(i).T.parent = T.nil then ", root" else if t.(i).T.left = T.nil && t.(i).T.right = T.nil then ", leaf" else ", internal node");
    print_newline ()
  in
  Array.iteri (fun i _ -> print i) t

Measured memory_bytes: 2380
#!/usr/bin/env python
# coding: utf-8

from collections import defaultdict
def find(x, parent):
    if parent[x] == x:
        return x
    else:
        parent[x] = find(parent[x], parent)
        return parent[x]


def union(x, y, parent):
    x = find(x, parent)
    y = find(y, parent)
    if x == y:
        return
    parent[y] = x


def main():
    n, k, l = [int(i) for i in raw_input().split()]
    road_parent = range(n)
    train_parent = range(n)

    for i in range(k):
        p, q = [int(i)-1 for i in raw_input().split()]
        union(p, q, road_parent)
    for i in range(l):
        r, s = [int(i)-1 for i in raw_input().split()]
        union(r, s, train_parent)
    counter = defaultdict(int)
    for i in range(n):
        counter[(find(i, road_parent), find(i, train_parent))] += 1
    ans_list = [counter[(find(i, road_parent), find(i, train_parent))] for i in xrange(n)]
    print ' '.join(map(str, ans_list))


if __name__ == "__main__":
    main()


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

x, y = map(int, input().split())
mz = Mz = x + y
mw = Mw = x - y

for i in range(N-1):
    x, y = map(int, input().split())
    z = x + y
    w = x - y
    mz = min(mz, z)
    Mz = max(Mz, z)
    mw = min(mw, w)
    Mw = max(Mw, w)

print(max(Mz-mz, Mw - mw))


Measured memory_bytes: 76320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){

    // input
    ll n;
    cin >> n;
    VS s(n);
    rep(i, 0, n) cin >> s[i];
    
    ll ans = 0;
    rep(srt, 0, n){

        // loop detect
        queue<PL> que;
        VL dist(n, -1);
        dist[srt] = 1;
        que.push({srt, -1});
        while(!que.empty()){
            auto q = que.front();
            que.pop();
            auto cur = q.first;
            auto par = q.second;
            cerr << par << "->" << cur << endl; 
            rep(i, 0, n){
                if(s[cur][i] == '0') continue;
                if(cur == i || par == i) continue;
                if(dist[i] == dist[cur] + 1) continue;
                if(dist[i] == dist[par]) continue;
                if(dist[i] != -1) {
                    cerr << "exit: " << cur << "->" << i << endl;
                    cerr << "dist_" << i << " : " << dist[i] << endl;
                    cout << -1 << endl;
                    return 0;
                }
                dist[i] = dist[cur] + 1;
                que.push({i, cur});
                cerr << "push: " << i << " " << cur << endl; 
            }
        }
        rep(i, 0, n) cerr << dist[i] << " ";
        cerr << endl;
        auto tmp = *max_element(ALL(dist));
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pqb             	priority_queue<int>
#define pqs             	priority_queue<int,vi,greater<int> >
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)  	type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    string s,t;cin>>s>>t;
    int n=s.length(),m=t.length();
    if(m==(n+1)){
    	string temp=s;
    	temp+=t[m-1];
    	if(temp==t){
    		cout<<"Yes";
    	}
    	else{
    		cout<<"No";
    	}
    }
    else{
    	cout<<"No";
    }
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();cerr<<"\nExecution time: "<<(double)(clock()-beg)/1000<<" seconds\n";}
}

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

int main() {

    string x,y;
    cin >> x;
    cin >> y;

    if(x[0]==y[2] && x[1]==y[1] && x[2]==y[0]) cout <<"YES"<< endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;


int main(){
    ll N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<pair<pll, ll>> medic(N);
    ll a, b, c;
    rep(i,N){
        cin >> a >> b >> c;
        medic[i] = mp(mp(a, b), c);
    }
    ll inf = 1e5;
    vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>>(401,vector<ll>(401,inf)));
    dp[0][0][0] = 0;
    ll ai, bi, ci;
    rep(i,N){
            ai = medic[i].F.F;
            bi = medic[i].F.S;
            ci = medic[i].S;
        rep(a,401){
            rep(b,401){
                dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
                if (ai+a<401 && bi+b<401){
                dp[i + 1][ai + a][bi + b] =
                 min(dp[i][ai + a][bi + b], dp[i + 1][ai + a][bi + b]);
                    dp[i+1][ai + a][bi + b] = 
                min(dp[i+1][ai + a][bi + b],
                 dp[i][a][b] + ci);}
            }
        }
    }
    ll ans = inf;
    ll aa = Ma;
    ll bb = Mb;
    while (aa<=400 && bb<=400){
        ans = min(ans, dp[N][aa][bb]);
        aa += Ma;
        bb += Mb;
    }
    if (ans==1e5)
        cout << -1 << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 53504
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

def eucrid(a,b):
  a,b=max(a,b),min(a,b)
  while True:
    if a%b==0:
      return b
    else:
      a,b=b,a%b
m=a[0]
for i in range(n):
  m=m//eucrid(m,a[i])*a[i]
b=0
m=m%mod
for i in a:
  b+=m*pow(i,mod-2,mod)%mod
print(b%mod)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  map<int,int>m;
  m[1]=m[4]=m[7]=0;
  m[2]=m[8]=1;
  m[3]=m[6]=m[9]=2;
  string s;
  while(cin>>s,s!="#"){
    int p1=0,p2=0,l,r;
    l=m[s[0]-'0'];
    r=m[s[1]-'0'];
    if(r<l)p1++,swap(r,l);
    for(int i=2,p=0;i<s.size();i++,p++){
      if(p%2){
        int t=r;
        r=m[s[i]-'0'];
        if(r<l)p1++,l=r,r=t,p--;
      }
      else{
        int t=l;
        l=m[s[i]-'0'];
        if(r<l)p1++,r=l,l=t,p++;
      }
    }
    r=m[s[0]-'0'];
    l=m[s[1]-'0'];
    if(r<l)p2++,swap(r,l);
    for(int i=2,p=0;i<s.size();i++,p++){
      if(p%2){
        int t=l;
        l=m[s[i]-'0'];
        if(r<l)p2++,r=l,l=t,p--;
      }
      else{
        int t=r;
        r=m[s[i]-'0'];
        if(r<l)p2++,l=r,r=t,p--;
      }
    }
    cout<<min(p1,p2)<<endl;
  }
}

Measured memory_bytes: 3244
/*input
10
3 3 3 3 4 4 4 5 5 5
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;
#define MAX 100010

int n;
multiset<int> s;
lol a[MAX], ans;

void init() {
	ans = 0;
	s.clear();
	memset(a, 0, sizeof(a));
}

int main() {
	cin.tie(0), cout.sync_with_stdio(false);

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s.insert(a[i]);
	}
	sort(a + 1, a + 1 + n);

	lol big = -1;
	for (int i = n; i >= 1; i--) if (s.count(a[i]) >= 2) {
		if (s.count(a[i]) >= 4) {
			ans = max(a[i] * a[i], a[i] * big);
			break;
		}
		if (big != -1 && big != a[i]) {
			ans = max(ans, a[i] * big);
			break;
		}
		else
			big = a[i];
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, a, b;
        cin >> n >> a >> b;
        
        cout << min(a * n, b) << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

typedef vector<vector<Edge>> Graph;

bool ishei(int x) {

	for (int i = 0; sqrt(x) + 1 >= i; i++) {
		if (i * i == x) {
			return true;
		}
	}
	return false;

}

signed main(void) {

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> X(N);
	for(auto &x: X) cin >> x;

	int res = INT_MAX;
	for(int i = 0; i < N - K + 1; i++) {
		int l = X[i];
		int r = X[i + K - 1];

		int llen = abs(l) + abs(l - r);
		int rlen = abs(r) + abs(l - r);
		res = min({res, llen, rlen});
	}

	cout << res << endl;
}


Measured memory_bytes: 640
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]


n,m = map (int,input().split())
a = [0] * n
b = [0] * n
box = [0] * n
for i in range(n):
    a[i],b[i] = map(int,input().split())
    box[i] = [a[i],b[i]]
box.sort(key = lambda x:x[0])
s = 0
ans = 0
while m > 0:
    
    m -= box[s][1]
    ans += box[s][0] * box[s][1]
    s += 1

print(ans - (-m) * box[s - 1][0])



Measured memory_bytes: 31848
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
//#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

bool check[30][30] = { false };
int movex[] = { 0, 1, 0, -1 };
int movey[] = { 1, 0, -1, 0 };

int move(int num, int x, int y){
	int retnum = num;
	if (check[x][y]){
		retnum++;
		check[x][y] = false;
		for (int i = 0; i < 4; i++){
			retnum = move(retnum, x + movex[i], y + movey[i]);
		}
	}

	return retnum;
}

int main(void){

	int W ,H;
	// char ;

	while (scanf("%d %d", &W, &H) != EOF){
		if (W == 0 && H == 0) break;
		int ax, ay;

		for (int i = 0; i<29; i++){
			for (int j = 0; j<29; j++){
				check[i][j] = false;
			}
		}

		for (int i = 1; i<=H; i++){
				char buff[20];
				scanf("%s", buff);
				for (int j = 1; j <= W; j++){
				if (buff[j- 1] == '.') check[i][j] = true;
				else if (buff[j - 1] == '@'){
					check[i][j] = true;
					ax = i;
					ay = j;
				}
			}
		}
		
		cout << move(0, ax, ay) << endl;

	}

	return 0;
}

/*
for(i=0;i<N;i++){
cin >> X[i];
}


for(i=0;i<N;i++){
for(j=0;j<N;j++){
cin >> X[i][j];
}
}
*/

Measured memory_bytes: 1220
# -*- coding: utf-8 -*-
x, y, z = map(int, input().split())
a =max( [ x, y, z ] )
if x == a:
	print (a*10 + y + z)
elif y == a:
	print (a*10 + z + x)
elif z == a:
	print (a*10 + x + y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> A(N - 1);
  vector<int> count(N -1);
  
  for (int i = 0; i < N - 1; i++){
    cin >> A.at(i);
    count.at(A.at(i) - 1)++;
  }
  for (int i = 0; i < N - 1; i++)
    cout << count.at(i) << endl;
  cout << 0 <<endl;
}

Measured memory_bytes: 4840
/*
  -> Ossan
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define Hiraishin                                                              \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);                                                            \
  cout.tie(nullptr);
using namespace std;

void solve() {
    int n;
    cin >> n;
    int arr[n];
    unordered_map<int, vector<int>> mp;
    for(int i = 0; i < n ; i++)
    {
        cin >> arr[i];
        mp[arr[i]].push_back(i);
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        bool f = true;
        for(int j = 1; j <= sqrt(arr[i]); j++){
            if(arr[i] % j == 0){
                int f1 = j, f2 = arr[i] / j;
                if(!mp[f1].empty()){
                    if(mp[f1].size() == 1){
                      if(i != mp[f1][0]){
                          f = false; break;
                      }
                    }
                    else{
                        f = false;
                        break;
                    }
                }
                if(!mp[f2].empty()){
                    if(mp[f2].size() == 1){
                        if(i != mp[f2][0]){
                            f = false; break;
                        }
                    }
                    else{
                        f = false;
                        break;
                    }
                }
            }
        }
        cnt += f;
    }
    cout << cnt << '\n';
}

signed main() {
    Hiraishin
        solve();
    return 0;
}

Measured memory_bytes: 48312
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k)
        cout << a - k << " " << b << endl;
    else
        cout << "0 " << max(0LL, b - (k - a)) << endl;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int max = 0;
    REP(i, n) {
        if(s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        if(max < x) {
            max = x;
        }
    }
    cout << max << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp         make_pair

typedef pair<int,int> pii;

bool get_min(int a,int b,pii in,pii cmp){
  if (in.first+in.second != cmp.first+cmp.second)
    return (in.first+in.second)<cmp.first+cmp.second;
  return a*in.first+b*in.second < a*cmp.first+b*cmp.second;
}

void solve(int a,int b,int d){
  pii ret,tmp;
  bool isans=false;

  for(int i=0;;i++){
    if (d-a*i<0)break;
    if ( (d-a*i)%b == 0){
      tmp.first=i;tmp.second=(d-a*i)/b;
      if (!isans)ret=tmp,isans=true;
      else if (!get_min(a,b,ret,tmp))ret=tmp;
    }
  }

  for(int i=0;i<=a;i++){
    if ((d +b*i)%a == 0){
      tmp.first=(d+b*i)/a;tmp.second=i;
      if (!isans)ret=tmp,isans=true;
      else if (!get_min(a,b,ret,tmp))ret=tmp;
    }
  }


  for(int i=0;i<=b;i++){
    if ((d+a*i)%b == 0){
      tmp.first=i;tmp.second=(d+a*i)/b;
      if (!isans)ret=tmp,isans=true;
      else if (!get_min(a,b,ret,tmp))ret=tmp;
    }
  }

  cout <<ret.first<<" " << ret.second << endl;

  
}

main(){
  int a,b,d;
  while(cin>>a>>b>>d && a){
    solve(a,b,d);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2017
#define LL long long
#define INF 0x3f3f3f3f
#define maxn 100009
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;

bool operator<(const Pair &a, const Pair &b)
{
    return a.first > b.first;
}

string str[110];
int N,L;

int main()
{

    cin >> N >> L;
    for(int i = 0;i < N;i++) {
        cin >> str[i];
    }

    sort(str,str+N);

    for(int i = 0;i < N;i++) {
        cout << str[i];
    }
    cout << endl;

    return 0;
}


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;

  if (A+B>C+D) {
    cout << "Left" << endl;
  }else if(A+B<C+D){
    cout << "Right" <<endl;
  }else{
    cout<<"Balanced"<<endl;
  }

}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let[a,b,c]=srin(3)
  out((a[0]+b[0]+c[0]).toUpperCase())
}
main()


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n;
vll G[1005];
vll X;

ll dp[1005]; // i番目を白に固定した時の部分木内の黒の合計の最小値
// 重みの割り振りができなくなるのは、下の部分木の白または黒の合計がX_iをオーバーする場合である
// そのため一方が小さく保持されている方が上のノードで点を割り振るうえで有利になる


void dfs(ll v, ll p){
  
  vll dp2(X[v]+1,INF); // (vを白に固定する) 接続される子のうちいくつかを白にしてそのコストの合計がiのとき、黒側の合計値の最小値
  dp2[0]=0;
  
  for(auto nv: G[v]){
    if(nv==p) continue;
    dfs(nv,v);
    
    vll dp3 = move(dp2); // nvの子のうちいくつかを見ていて、白であるもの合計値がiポイントであるときの、黒側の合計値の最小値
    dp2.assign(X[v]+1,INF);
    
    rep(i, dp3.size()) if(dp3[i]!=INF){
      if(i+X[nv]  <=X[v]) chmin(dp2[i+X[nv]],dp3[i]+dp[nv]); // dp[nv]を白側の値にする
      if(i+dp[nv] <=X[v]) chmin(dp2[i+dp[nv]],dp3[i]+X[nv]); // X[nv]を白側の値にする
    }
  }
  
  dp[v]=*min_element(all(dp2));
  
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n;
  rep(i,n-1){
    ll p; cin>>p; p--;
    G[p].push_back(i+1);
    G[i+1].push_back(p);
  }
  X.resize(n);
  rep(i,n) cin>>X[i];
  
  
  dfs(0,-1);
  // rep(i,n) cout<<dp[i]<<endl;
  
  if(dp[0]<INF) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  
}

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val X = listOfInt()
    var ans = Int.MAX_VALUE
    for (l in 0 until N - K + 1) {
        val r = l + K - 1
        val d = X[r] - X[l]
        val a = d + Math.abs(X[l])
        val b = d + Math.abs(X[r])
        ans = Math.min(ans, Math.min(a, b))
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 49980
n = int(input())
w = []
for i in range(n):
    w.append(input())
w_set = []
for i in range(n-1):
    if w[i][len(w[i])-1] != w[i+1][0]:
        print("No")
        exit()
    if w.count(w[i]) > 1:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, Z, W;
	int A[2010];

	cin >> N >> Z >> W;
	rep(i, 0, N)
	{
		cin>>A[i];
	}

	int ans = abs(W - A[N - 1]);
	if (N > 1)chmax(ans, abs(A[N - 1] - A[N - 2]));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>n; lld a[n]; for(i=0;i<n;i++) cin>>a[i];
        lld gcd = 0;
        for(i=0;i<n;i++)
            gcd = __gcd(gcd,a[i]);
        if(gcd==1) j=0;
        else j=1;
        if(j==1)
            cout<<"not coprime"<<endl;
        else
        {
            lld vv[1000001];
            memset(vv,0,sizeof(vv));
            for(i=0;i<n;i++)
            {
                x = a[i];
                for(j=2;j*j<=x;j++)
                {
                    if(x%j==0)
                        vv[j]++;
                    while(x%j==0)
                        x/=j;
                    if(vv[j]>=2)
                    {
                        flag=true;
                        break;
                    }
                }
                if(x>1)
                    vv[x]++;
                if(vv[x]>=2)
                {
                    flag=true;
                    break;
                }
                if(flag)
                    break;
            }
            if(flag)
                cout<<"setwise coprime"<<endl;
            else
                cout<<"pairwise coprime"<<endl;
        }
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 19144
// https://atcoder.jp/contests/abc157/tasks/abc157_d
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 100005

int N,M,K;
vector<int> flist[MAX_N];
vector<int> blist[MAX_N];


struct UFT{
	// Union-Find Tree
	int par[MAX_N];
	int depth[MAX_N];
	void init(){
		for(int i=0;i<MAX_N;i++){
			par[i]=i;
			depth[i]=0;
		}
		return;
	}
	UFT(){
		init();
	}

	int get_root(int i){
		if(par[i]==i){
			return i;
		}
		int rt = get_root(par[i]);
		par[i] = rt;
		return rt;
	}
	void merge(int i,int j){
		if(same(i,j)) return;
		int x = get_root(i);
		int y = get_root(j);
		if(depth[x]>depth[y]){
			par[y] = x;
		}else{
			par[x] = y;
			if(depth[x]==depth[y]){
				depth[y]++;
			}
		}
		return;
	}
	bool same(int i,int j){
		return get_root(i) == get_root(j);
	}

};

int main() {
	cin >> N >> M >> K;
	UFT uft;
	int uft_cnt[MAX_N];
	rep(i,M){
		int a,b;
		cin >> a >> b;
		a--;b--;
		flist[a].push_back(b);
		flist[b].push_back(a);
		uft.merge(a,b);
	}
	rep(i,K){
		int a,b;
		cin >> a >> b;
		a--;b--;
		blist[a].push_back(b);
		blist[b].push_back(a);
	}
	rep(i,N)uft_cnt[i]=0;
	rep(i,N){
		uft_cnt[uft.get_root(i)]++;
	}
	rep(i,N){
		
		int ans = uft_cnt[uft.get_root(i)] - flist[i].size() - 1;
		rep(j,blist[i].size()){
			if(uft.same(i,blist[i][j]))ans--;
		}
		cout << ans << " ";
	}
	cout << endl;


    return 0;
}



Measured memory_bytes: 13048
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
char	s[500010];
int		ans[500010] = { 0 };
int		ans1[500010] = { 0 };
int main()
{
	int		i,j,k,n,c;
	char	x,y;
	long long a = 0;

	scanf("%d", &n);
	
	
	if (n<=2)	printf("0\n");
	else		printf("%d\n", (n-1)/2 );
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int n, m, adj[1002][1002];
vector<int>v[1002];
vector<int>smcic;
deque<int>ed;
bool viz[1002];
void dfs(int nod)
{
    int countt = 0;
    for(int j = 0; j < ed.size(); ++j)
    {
        if(adj[ed[j]][nod] && j != ed.size() - 1)
            return;
        countt += adj[nod][ed[j]];
    }
    if(countt >= 2)
        return;
    if(countt == 1)
    {
        for(int j = 0; j < ed.size(); ++j)
        {
            if(adj[nod][ed[j]])
            {
                cout << ed.size() - j + 1 << '\n';
                for(int p = j; p < ed.size(); ++p)
                    cout << ed[p] << '\n';
                cout << nod;
                exit(0);
            }
        }
    }
    if(viz[nod])
        return;
    viz[nod] = 1;
    ed.push_back(nod);
    for(int i = 0; i < v[nod].size(); ++i)
    {
        int vecin = v[nod][i];
        dfs(vecin);
    }
    ed.pop_back();
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        adj[a][b] = 1;
    }
    for(int i = 1; i <= n; ++i)
    {
        memset(viz, 0, sizeof(viz));
        ed.clear();
        dfs(i);
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 3840