akhauriyash/Code-Regression huggingface dataset:
// Aizu Vol0 0012: A Point in a Triangle
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

#define EPSILON 0.0001

int isSameSide(double x1, double y1, double x2, double y2,
	double xa, double ya, double xb, double yb)
{
	double sa, sb;

	sa = (x2 - x1) * (ya - y1) + (y2 - y1) * (x1 - xa);
	sb = (x2 - x1) * (yb - y1) + (y2 - y1) * (x1 - xb);
	if (-EPSILON <= sb && sb <= EPSILON) return 0;
	if (sa * sb >= 0) return 1;
	return -1;
}

int main()
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	
	while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", 
		&x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) == 8) {
		if (isSameSide(x1, y1, x2, y2, x3, y3, xp, yp) != 1) goto NO;
		if (isSameSide(x2, y2, x3, y3, x1, y1, xp, yp) != 1) goto NO;
		if (isSameSide(x3, y3, x1, y1, x2, y2, xp, yp) != 1) goto NO;
		puts("YES");
		continue;
	NO: puts("NO");
	}
	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;


void print() {
    cout << endl;
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}
 
template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}
 
template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}
 


int main(){
  int n; cin >> n;
  string s;cin >> s;
  int ans = 0;
  
  rep(i,n-1){
    vector<int> vec(26, 0);
    rep(j, i+1){
      int t = s.at(j) - 'a';
      vec.at(t)++;
    }
    int tmp = 0;
    for(int j = i+1; j < n;j++){
      int t = s.at(j) - 'a';
      if(vec.at(t)){
        tmp++;
        vec.at(t) = 0;
      }
    }
    ans = max(ans, tmp);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt +=1

print(cnt)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};
const int N = 1001;

vector<int> g[N+4];
ll v,d;
void add_edge(int from,int to){
  g[from].push_back(to);
  g[to].push_back(from);
}
vector<ll> f(N+4,0);

void dfs(int k,int c){
  if(f[k] == c) return ;
  f[k] = c;
  for(auto &&e : g[k]){
    dfs(e,c);
  }
}

int solve(){
  int res = 0;
  f = vector<ll>(N+4,0);
  REP(i,2,v+2){
    if(f[i] == 0){
      ++res;
      dfs(i,res);
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int fib[N+4];
  fib[0] = 1,fib[1] = 1;
  REP(i,2,N+4){
    fib[i] = (fib[i-1] + fib[i-2]) % N;
  }
  while(cin >> v >> d){
    rep(i,N+4){
      g[i].clear();
    }
    REP(i,2,v+2){
      REP(j,i+1,v+2){
        if(abs(fib[i] - fib[j]) < d){
          add_edge(i,j);
        }
      }
    }
    cout << solve()<< endl;
  }
  return 0;
}

Measured memory_bytes: 5060
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9


struct Puzzle {
  int f[N2];
  int space;
  string path;

bool operator < (const Puzzle &p)const{
  for(int i=0;i<N2;i++){
    if(f[i] == p.f[i])continue;
    return f[i] > p.f[i];
  }
  return false;
}
};  

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int i=0;i<N2;i++)
    if(p.f[i] != (i + 1))return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while(!Q.empty()){
    u = Q.front();
    Q.pop();
    if(isTarget(u))return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r = 0;r<4;r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx < 0||ty<0||tx>=N||ty>=N)continue;
      v = u;
      swap(v.f[u.space],v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if(!V[v]){
	V[v] = true;
	v.path += dir[r];
	Q.push(v);
      }
    }
  }

  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}




Measured memory_bytes: 30652
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>

using namespace std;

int main (void)
{
	int a[10],a1,a2,a3;
	a1 = 0;
	a2 =0;
	a3 = 0;

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

	for (int  i = 0; i < 10; i++)
	{
		if (a[i] >= a1)
		{
			a3 = 0;
			a3 = a2;
			a2 = 0;
			a2 = a1;
			a1 = 0;
			a1 = a[i];

		}
		else if (a2 <= a[i])
		{
			a3 = 0;
			a3 = a2;
			a2 = 0;
			a2 = a[i];
		}
		else if (a[i] >= a3)
		{
			a3 = 0;
			a3 = a[i];
		}

	}
	cout << a1 << endl << a2 << endl << a3 << endl;
}

Measured memory_bytes: 3088
n = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()
for i in range(1,n-1):
    for j in range(i+1,n):
        for k in range(j+1,n+1):
            if L[i-1] != L[j-1] and L[j-1] != L[k-1] and L[i-1] + L[j-1] > L[k-1]:
                ans += 1 
print(ans)

Measured memory_bytes: 73236
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int sign(int x){
  if(x>0) return 1;
  else return -1;
}
int main(){
  int n, k, i, ans=1000000000, tmp;
  cin >> n >> k;
  int x[n];
  for(i=0; i<n; i++)
    cin >> x[i];
  for(i=0; i<=n-k; i++){
    if(sign(x[i])==sign(x[i+k-1]))
      tmp=max(abs(x[i]), abs(x[i+k-1]));
    else
      tmp=min(abs(x[i]), abs(x[i+k-1]))*2+max(abs(x[i]), abs(x[i+k-1]));
    if(tmp<ans)
      ans=tmp;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i,n){
    cin >> x[i];
  }
  ll tired = 0;
  for (ll i = 1; i < n; i++){
    tired += min((x[i] - x[i - 1]) * a, b);
  }
  print(tired);
}

Measured memory_bytes: 4000
import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

    print(-(-(N-K)//(K-1))+1)

if __name__ == '__main__':
    main()


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

using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif
#define rep(i,n) for (int i = 0; i < (n); ++i)

#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main() {
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> bucket;
    rep(i,n) {
        cin >> a[i];
        bucket[a[i]]++;
    }

    int sum = 0;
    for (auto& p : bucket) {
        const int t = p.second;
        sum += t * (t - 1) / 2;
    }
    rep(i, n) {
        cout << sum - (bucket[a[i]] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter
from collections import defaultdict

N,M = map(int,readline().split())
D = [0] + list(map(int,readline().split()))
m = map(int,read().split())
UV = list(zip(m,m))

graph = [[] for _ in range(N+1)]
for u,v in UV:
    graph[u].append((v,D[v]))
    graph[v].append((u,D[u]))

subgraph = [[] for _ in range(N+1)]
is_ng = False
for v in range(1,N+1):
    graph[v].sort(key = itemgetter(1))
    w,d = graph[v][0]
    if D[v] < d:
        is_ng = True
        break
    subgraph[w].append(v)

if is_ng:
    print(-1)
    exit()

INF = 10 ** 9
wt_edge = defaultdict(lambda:INF)
color = [0] * (N+1)

# (index, weight), sorted by wt
I = sorted(enumerate(D), key = itemgetter(1))[1:]

for v, wt in I:
    if color[v]:
        continue
    stack = [v]
    color[v] = 1
    v0 = v
    while stack:
        v = stack.pop()
        cw = 3 - color[v]
        for w in subgraph[v]:
            if w == v0:
                continue
            color[w] = cw
            wt_edge[(v,w)] = D[w]
            wt_edge[(w,v)] = D[w]
            stack.append(w)

S = ''.join('B' if x == 1 else 'W' for x in color[1:])
C = [wt_edge[(u,v)] for u,v in UV]

print(S)
print('\n'.join(map(str,C)))

Measured memory_bytes: 147044
#include<stdio.h>

int main()
{
    int a,b,c,d,e,f;
    double x,y;
    while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)==6){
        y = (a*f-d*c)/(double)(a*e-d*b);

        x = (c-b*y)/(double)a;

        printf("%.3lf %.3lf\n",x,y);
    }


    return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    unordered_map<ll, ll> mp1;
    unordered_map<ll, ll> mp2;
    for (ll y = 1; y <= n; y++)
    {
        mp1[y - a[y]]++;
    }
    for (ll y = 1; y <= n; y++)
    {
        mp2[y + a[y]]++;
    }
    ll ans = 0;
    for (ll x = 1; x <= n; x++)
    {
        ans += mp1[x + a[x]];
        ans += mp2[x - a[x]];
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);

using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
ll mod=1e9+7;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////
 vector <int> adj[200005];
    bool visited[200005];
const int N = 1e6+1;
ll greatestPF[N];
int cnt,nodes,edges;
  void dfs(int s) {
        visited[s] = true;
        cnt++;

        for(int i = 0;i < adj[s].size();++i)    {
         if(visited[adj[s][i]] == false)
         {
             dfs(adj[s][i]);
         }
        }
    }

int mem[100005][3],a[200005],b[105],n,m,k,frq[1000005];
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}
int sieve[N];
int main()
{
int T=1;
///T=D();
while(T-->0)
{
    int x,y,n;
    cin>>x;
    cout<<!x;
    
}

}


Measured memory_bytes: 8312
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


ll f(ll n){
  if(n==0) return 0;

  return n%10+f(n/10);
}

int main(){
  ll k;
  cin>>k;

  ll n=1;
  ll p=1;
  ll i=0;
  while(i<k){
    cout<<n<<endl;
    ll a=n+p;
    ll b=n+p*10;
    if(a*f(b)<=b*f(a))
      n = a;
    else{
      n = b;
      p*=10;
    }
    i++;
  }


  return 0;
}

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

#define rep(x, n) for(int i = x; i < (n); ++i)

using namespace std;
using ll = long long;

int main(void)
{
  string n;
  cin >> n;
  ll sum = 0;
  for (char c : n) {
    sum += c - '0';
  }
  cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int K, N, X, Y, res;
  rd(N);
  rd(K);
  rd(X);
  rd(Y);
  res =min_L(K, N)* X +max_L(0, N-K)* Y;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int N, K, X, Y, res;
//   rd(N,K,X,Y);
//   res = min(K,N) * X + max(0,N-K) * Y;
//   wt(res);
// }


Measured memory_bytes: 256
import itertools

# 入力                                                                                   
S = list(input())

# 組み合わせを求める                                                                     
#list(itertools.combinations(S, 2))                                                      

# indexのリストを作成                                                                    
index = []
for i in range(len(S)):
    index.append(i)

result = 0
for i in range(1,len(S)):
    list_C =  list(itertools.combinations(index, i))
    # 組み合わせを順番に見ていく                                                         
    for one in list_C:
        T = S
        # その組み合わせに応じて足していく                                               
        sum_list = []
        devide = 0
        for key in range(0,i):
            sum_list.append(''.join(T[devide:one[key]]))
            devide = one[key]
        sum_list.append(''.join(T[devide:]))
        if '' not in sum_list:
            result += sum(list(map(int,sum_list)))
result += int(''.join(S))
print(result)


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map { it.toInt() }
    var r = 0

    d.forEachIndexed { i, x ->
        d.forEachIndexed { j, y ->
            if (i != j) {
                r += x * y
            }
        }
    }

    println(r / 2)
}


Measured memory_bytes: 37828
#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 MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

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

int main(){
	lint n;cin>>n;
	lint m=linf;
	rep(i,n-1){
		m=min(m,digs(i+1)+digs(n-i-1));
	}cout<<m<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		int A = a.nextInt();
		A = A % 10;
		if(A == 3) {
			System.out.println("bon");
		}else if(A == 0 || A == 1 || A == 6 || A == 8) {
			System.out.println("pon");
		}else{
			System.out.println("hon");
		}
	}
}

Measured memory_bytes: 35608
#include <iostream>
#include <vector>
#include <algorithm>



using namespace std;

int N;
vector<int>P;


int main()
{


	cin >> N;
	int ans = 0;

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


	ans++;
	int m = P[0];
	for (int i = 1; i < N; i++) {
		if (P[i] <= m) { ans++; }

		m = min(m,P[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int A,B,C; cin>>A>>B>>C;
  int ans=(A-A/2)*B*C-A/2*B*C;
  ans=min(ans,(B-B/2)*C*A-B/2*C*A);
  ans=min(ans,(C-C/2)*A*B-C/2*A*B);
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl a(N);
  rep(i, N) cin >> a[i];

  ll ans = 0;
  ll p;

  rep(i, N){
    p = 0;
    while(a[i] % 2 == 0){
      a[i] /= 2;
      p++;
    }
    ans += p;
  }

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


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] ia = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            HashSet<int> ih = new HashSet<int>();
            for (int i = 0; i < N; i++)
                ih.Add(ia[i]);

            if (N == ih.Count)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

    }
}


Measured memory_bytes: 43672
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main(){
    ll A; 
    double B; 
    cin >> A >> B;
    B*=100.;
    ll B1 = round(B);
    ll ans = A * B1;
    ans /= 100;
    cout << ans << endl;
}


Measured memory_bytes: 3768
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

var sc = bufio.NewScanner(os.Stdin)

type graph struct {
	d map[int]int
}

func main() {
	sc.Split(bufio.ScanWords)
	// INF := 100000000000000000

	n, k := scanInt(), scanInt()
	a := []int{0}
	a = append(a, scanInts(n)...)

	journey := []int{1}
	for i := 0; i < 2*n+100; i++ {
		next := a[journey[len(journey)-1]]
		journey = append(journey, next)
	}

	if k < n+1 {
		fmt.Println(journey[k])
		return
	}
	loopEnd := n
	loopStart := n - 1

	// ループを見つける
	for journey[loopStart] != journey[loopEnd] {
		loopStart--
	}
	period := loopEnd - loopStart

	k %= period

	for k < n {
		k += period
	}
	fmt.Println(journey[k])
}


Measured memory_bytes: 16380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int M = 1e9+7;
#define F(i,a,b) for(int i=a;i<b;i++)
int main() {
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=1;i<=n;i++) cin>>a[i];
  vector<vector<ll>> dp(n+1,vector<ll> (k+1,0));
  vector<ll>prefix(k+1,0);
  prefix[0] = 1;
  for(int child=0;child<=n;child++) dp[child][0] = 1;
  for(int candies=1;candies<=k;candies++) prefix[candies] += prefix[candies-1];
  for(int child=1;child<=n;child++)
  {
    for(int candies=1;candies<=k;candies++)
    {
      ll left=0;
      if(candies-a[child]>0)
        left = prefix[candies-a[child]-1];
      dp[child][candies] = (prefix[candies] - left+M)%M;
      //prefix[candies] = (dp[child][candies]+prefix[candies-1])%M;
    }
    for(int candies=1;candies<=k;candies++)
    {
        prefix[candies] = (prefix[candies-1] + dp[child][candies])%M; 
    }
  }
  /*
  F(i,0,n+1)
  {
    F(j,0,k+1)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  cout<<dp[n][k];
  return 0;
}


Measured memory_bytes: 83020
#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; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
        int N,M,a; cin >> N >> M >> a;
        if (N+M+a == 0) break;
        a--;
        vector<tuple<int, int, int>> A(M);
        rep(i,M) {
            int h,p,q; cin >> h >> p >> q;
            p--; q--;
            A[i] = make_tuple(h,p,q);
        }

        vector<int> ans(N);
        rep(i,N) ans[i] = i;
        sort(all(A)); reverse(all(A));
        rep(i,M) {
            swap(ans[get<1>(A[i])],ans[get<2>(A[i])]);
        }
        rep(i,N) if (ans[i] == a) cout << i+1 << endl;
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_N = 50;
 
long long dp[MAX_N+1][MAX_N+1][MAX_N*MAX_N+1];
 
int main() {
	ios_base::sync_with_stdio(false);
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	int total_sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		total_sum += x[i];
	}
	for (int i = 0; i < n; i++) {
		dp[i][0][0] = 1;
	}
	dp[0][1][x[0]] = 1;
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= i+1; j++) {
			for (int k = 1; k <= total_sum; k++) {
				dp[i][j][k] = dp[i-1][j][k];
				if (k - x[i] >= 0) {
					dp[i][j][k] += dp[i-1][j-1][k-x[i]];
				}
			}
		}
	}
	long long result = 0;
	for (int j = 1; j <= n; j++) {
		result += dp[n-1][j][a*j];
	}
	cout << result << '\n';
	return 0;
}

Measured memory_bytes: 48128
N = int(input())
point = {}
for i in range(N):
    s_i = input()
    if s_i not in point:
        point[s_i]=1
    else:
        point[s_i]+=1

M = int(input())
for i in range(M):
    t_i = input()
    if t_i not in point:
        continue
    else:
        point[t_i]-=1

ans = 0
for i in point.keys():
    ans = max(ans, point[i])

if ans > 0:
    print(ans)
else:
    print(0)
    

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

L_old1 = 2
L_old2 = 1

if N == 1:
    L_new = L_old2
else:
    for i in range(2,N+1):
         L_new = L_old1 + L_old2
         L_old1 = L_old2
         L_old2 = L_new

print(L_new)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int h[100][100]={},m[100][100]={},s[100][100]={};
	int min;
	rep(i,3)
	{
		int min_1,min_2,min;
		cin>>h[0][i]>>m[0][i]>>s[0][i]>>h[1][i]>>m[1][i]>>s[1][i];
		min_1=(h[0][i]*3600+m[0][i]*60+s[0][i]);
		min_2=(h[1][i]*3600+m[1][i]*60+s[1][i]);
		min=min_2-min_1;

		cout<<min/3600<<" ";
		min%=3600;
		cout<<min/60<<" ";
		min%=60;
		cout<<min<<endl;
	}
	return 0;
}

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

int main() {
    int H,W,K,i,j,idx=1;
    cin >> H >> W >> K;
    vector<string> s(H);
    vector<vector<int>> a(H, vector<int>(W, 0));

    for(i=0; i<H; i++)
        cin >> s.at(i);
    
    for(i=0; i<H; i++)
        for(j=0; j<W; j++) {
            if(s.at(i).at(j) == '#') {
                a.at(i).at(j) = idx;
                idx++;
            } else if(j != 0) {
                a.at(i).at(j) = a.at(i).at(j-1);
            }
        }
    
    for(i=0; i<H; i++)
        for(j=W-2; j>=0; j--)
            if(a.at(i).at(j) == 0)
                a.at(i).at(j) = a.at(i).at(j+1);
    
    for(i=1; i<H; i++)
        if(a.at(i).at(0) == 0)
            for(j=0; j<W; j++)
                a.at(i).at(j) = a.at(i-1).at(j);
    
    for(i=H-2; i>=0; i--)
        if(a.at(i).at(0) == 0)
            for(j=0; j<W; j++)
                a.at(i).at(j) = a.at(i+1).at(j);
    
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++)
            cout << a.at(i).at(j) << " ";
        cout << endl;
    }
}

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

const int N = 5e5+5;
const int mod = 1e9+7;
long long fact[N], factinv[N];

long long power(long long a, long long b){
    long long ans = 1;
    while(b>0){
        if (b&1){
            ans = (ans*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return ans;
}

long long inv(int a){
    return power(a, mod-2)%mod;
}

long long ncr(int n, int r){
    long long ans = 1;
    ans = (ans*fact[n])%mod;
    ans = (ans*factinv[r])%mod;
    ans = (ans*factinv[n-r])%mod;
    return ans;
}

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

    int n, m;
    cin>>n>>m;
    fact[0] = 1;
    factinv[0] = 1;
    for (int i=1; i<N; i++){
        fact[i] = (fact[i-1]*i)%mod;
        factinv[i] = inv(fact[i])%mod;
    }
    long long ans = 0;
    for (int i=0; i<=n; i++){
        long long curr = (i%2?-1:1);
        if (curr<0) curr += mod;
        curr = (curr*(ncr(n, i)))%mod;
        curr = (curr*(ncr(m-i, n-i)))%mod;
        curr = (curr*(fact[n-i]))%mod;
        ans = (ans+curr)%mod;
    }

    ans = (ans*ncr(m, n))%mod;
    ans = (ans*fact[n])%mod;

    cout<<ans<<endl;

    return 0 ;
}


Measured memory_bytes: 11456
from collections import deque
h,w,k = map(int,input().split())
A = []
ans = 10**10
for i in range(h):
    A.append(input())
    for j in range(w):
        if A[i][j] == 'S':
            start = (i,j)
d = [[10**10]*w for _ in range(h)]
d[start[0]][start[1]] = 0
que = deque([start])
dx = [0,-1,0,1]
dy = [-1,0,1,0]
while que:
    px,py = que.popleft()
    ans = min(ans, 2 + (min(px,py,h-px-1,w-py-1)-1)//k)
    for i in range(4):
        nx = px + dx[i]
        ny = py + dy[i]
        if 0 <= nx < h and 0 <= ny < w and A[nx][ny] == '.' and d[nx][ny] == 10**10:
            d[nx][ny] = d[px][py] + 1
            if d[nx][ny] <= k:
                que.append((nx,ny))
print(ans)


Measured memory_bytes: 64988
function main(input) {
  const args = input.split("\n");
  const N = args[0];
  const A = args[1];
  const An = A.split(" ");

  var SUM = 0
  for(var i = 0; i<N; i++) {
    SUM = SUM + (1/An[i]);
  }

  console.log(1/SUM);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if(A==B) cout << A*2 << endl;
  else{
    if(A>B){
      cout << A+A-1 <<endl;
    }
    else{
      cout << B+B-1 <<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    using namespace std;

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

    int S1, S2;
    S1 = A*B;
    S2 = C*D;

    int ans = S1;

    if (S2 > ans)
        ans = S2;

    cout << ans;

    return 0;
}

Measured memory_bytes: 764
S = input()

if int(S[0:2])>=1 and int(S[0:2]) <=12:
  if int(S[2:4])>=1 and int(S[2:4]) <= 12:
    Answer = 'AMBIGUOUS'
  else:
    Answer = 'MMYY'
elif int(S[2:4])>=1 and int(S[2:4]) <= 12:
  Answer = 'YYMM'
else:
  Answer = 'NA'
  
print(Answer)

Measured memory_bytes: 3064
/*/ Author: KaySeeKay /*/

#include<bits/stdc++.h>
using namespace std;	

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}
int vis[N];
vector<int>v[N];
int par[N];
// int Find(int x){
// 	if(x==par[x])return x;
// 	return par[x]  = Find(par[x]);
// }
int cnt;
void dfs(int s){
	++cnt;
	vis[s]=1;
	for(auto i : v[s])if(!vis[i])dfs(i);
}
/*/-----------------------------Code begins----------------------------------/*/


signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n,m;
		cin >>n >> m;
		map<int,int>mp;
		fm{
			int x,y;
			cin >> x>>y;
			mp[x]++;
			mp[y]++;
			v[x].pb(y);
			v[y].pb(x);
		}
		int ans=0;
		fn1{
			if(!vis[i]){
				cnt =0 ;
				dfs(i);
				ans=max(ans,cnt);
			}
		}
		cout<<ans;

	
	}
	return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	ll dp[n][5][4][4];	//A,C,G,T	AGC,ACG,GAC		021,012,201
	FOR(i,0,n)FOR(j,0,4)FOR(k,0,4)FOR(l,0,4)dp[i][l][j][k] = 0;
	FOR(i,0,4)FOR(j,0,4)FOR(k,0,4){
		if(i == 0 && j == 2 && k == 1)continue;
		if(i == 0 && j == 1 && k == 2)continue;
		if(i == 2 && j == 0 && k == 1)continue;
		dp[2][i][j][k] = 1;
	}
	FOR(i,2,n-1){
		FOR(m,0,4)FOR(j,0,4)FOR(k,0,4)FOR(l,0,4){
			if(j == 0 && k == 2 && l == 1)continue;
			if(j == 0 && k == 1 && l == 2)continue;
			if(j == 2 && k == 0 && l == 1)continue;
			if(m == 0 && k == 2 && l == 1)continue;
			if(m == 0 && j == 2 && l == 1)continue;
			dp[i+1][j][k][l] += dp[i][m][j][k];
			dp[i+1][m][k][l] %= MOD;
		}
	}
	ll ans = 0;
	FOR(k,0,4)FOR(i,0,4)FOR(j,0,4){
		ans += dp[n-1][k][i][j];
		ans %= MOD;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int a;
    std::cin>>a;
    int b[a];
    for(int i=0;i<a;i++){
        std::cin>>b[i];
    }
    for(int i=1;i<a;i++){
        int j=i-1;
        int v=b[i];
        for(int i=0;i<a;i++){
            if(i==a-1) std::cout<<b[i]<<std::endl;
            else std::cout<<b[i]<<" ";
        }
        while(j>=0&&b[j]>v){
            std::swap(b[j],b[j+1]);
            j--;
        }
    }
    for(int i=0;i<a;i++){
        if(i==a-1) std::cout<<b[i]<<std::endl;
        else std::cout<<b[i]<<" ";
    }
    return 0;
}



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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  if(a==b && a==c && b==c) cout << 1 << endl;
  else if(a==b || b==c || a==c) cout << 2 << endl;
  else cout << 3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vi k(n);
    rep(i,n)cin>>k[i];
    bool c=true;
    int t=0;
    rep(i,n)
      if(k[i]>=2)c=false;
      else if(k[i]==0)t++;
    if(c) cout<<"NA"<<endl;
    else  cout<<n+1-t<<endl;
  }
}

Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = ReadInts();
            var ans = 0;
            ans += NM[0] * (NM[0] - 1) / 2;
            ans += NM[1] * (NM[1] - 1) / 2;
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,m,k;
	cin>>n>>m>>k;
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <=m; ++j)
		{
			if (i*j+(n-i)*(m-j)==k)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
b,c,d,e,f;main(a){while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f))printf("%.3f %.3f\n",(c*e-b*f+0.)/(a*e-b*d)+0.,(c*d-a*f+0.)/(b*d-a*e)+0.);}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int n; cin >> n;
    string s,t;
    cin >> s >> t;
    
    irep(i, n){ 
        cout << s[i] << t[i];
    }
    return 0;
}   
/** atcoder **/


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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);


main() {
	did_you_calis_enough
	int n;cin >> n;
	cout << n + (n * n) + (n * n * n);
}

//Coded by LoliThief

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    string S, T;
    cin >> S >> T;

    ll N = SZ(S);
    bool f = true;
    REP(i,0,N) {
        if(S[i] != T[i]) f = false;
    }
    if(f) _PR("Yes");
    else _PR("No");

    return 0;
}

/*



*/

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

using namespace std;

#define int long long

const int N = 2e5+1;
int n, a[N], pre[N], f1[N], f2[N];

int sum(int l,int r){
	return pre[r] - pre[l-1];
}

signed main(){
	cin >> n;
	for(int i=1;i<=n;++i) cin >> a[i], pre[i] = pre[i-1] + a[i];
	
	f1[2] = 1;
	for(int i=3,l=1;i<=n-2;++i){
		while(abs(sum(l+1,i)-sum(1,l))>abs(sum(l+2,i)-sum(1,l+1))) ++l;
		f1[i] = l;
	}
	f2[n-1] = n;
	for(int i=n-2,r=n;i>=3;--i){
		while(i<=r-2 && abs(sum(i,r-1)-sum(r,n))>abs(sum(i,r-2)-sum(r-1,n))) --r;
		f2[i] = r;
	}	
	int ans = 1e18;
	for(int i=2;i<=n-2;++i){
		int l1 = sum(1,f1[i]), l2 = sum(f1[i]+1,i);
		int r1 = sum(i+1,f2[i+1]-1), r2 = sum(f2[i+1],n);

		ans = min(max({l1,l2,r1,r2}) - min({l1,l2,r1,r2}), ans);
	}
	cout << ans;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), X = input();
    
    int gcd = abs(X - input());
    range(i, 1, N) {
        int x = input();
        gcd = __gcd(gcd, abs(X - x));
    }
    
    cout << gcd << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		for (int i = 0; i < n; i++) {
			if (arr[i] != (i + n % 2) / 2 * 2 + (n + 1) % 2) {
				System.out.println(0);
				return;
			}
		}
		int ans = 1;
		for (int i = 0; i < n / 2; i++) {
			ans *= 2;
			ans %= MOD;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 52372
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int n; ll w;
vector<int>weight(110);
vector<int>value(110);
vector<vector<ll> >dp(110,vector<ll>(100100));


int main(){
  cin>>n>>w;
  for(int i=0;i<n;i++) cin>>weight[i]>>value[i];

  for(int i=0;i<n;i++){
    for(int j=0;j<=w;j++){
      if(j-weight[i]>=0){
        chmax(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
      }
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  cout<<dp[n][w]<<endl;

}

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

using namespace std;

void solution()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;

	if(a==0)
		cout<<"1"<<endl;
	else if(b==0)
		cout<<"2"<<endl;
		else if(c==0)
		cout<<"3"<<endl;
		else if(d==0)
		cout<<"4"<<endl;
		else if(e==0)
		cout<<"5"<<endl;

}

int main()
{
	solution();
	return 0;
}



Measured memory_bytes: 3616
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    string ans;
    while(n){
        ans+=(n%26==0?26:n%26)+'`';
        if(n%26==0)--n;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}



Measured memory_bytes: 3628
<?php
 
$n = trim(fgets(STDIN));
$p = explode(" ", trim(fgets(STDIN)));
$count = 1;
$current = $p[0];
foreach ($p as $num) {
	if ($current > $num) {
      $count++;
      $current = $num;
    }
}
echo $count . PHP_EOL;

Measured memory_bytes: 18932
object Main extends App {

  val n = scala.io.StdIn.readInt()
  val dArr = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def solve(): Long = {
    val sortedArr = dArr.sorted
    val half = n / 2
    sortedArr(half) - sortedArr(half - 1)
  }
  println(solve)

}


Measured memory_bytes: 42856
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main() {
	int n; cin >> n;
	if (n % 111 == 0) {
		cout << n << endl;
		return 0;
	}
	n /= 111; n += 1;
	cout << n * 111 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(int argc, char *argv[])
{
	int n,m,i,j,k,l;
	int ara[3][3];
	int str[10];
	for(i=0;i<3;i++){
			for(j=0;j<3;j++){
				scanf("%d",&ara[i][j]);
			}
	}
	scanf("%d",&n);
	for(k=0;k<n;k++){
		scanf("%d",&str[k]);
		for(i=0;i<3;i++){
			for(j=0;j<3;j++){
				if(ara[i][j]==str[k])ara[i][j]=-101;
			}
		}
	}
	
    if(ara[0][0]==-101 && ara[0][1]==-101 && ara[0][2]==-101)printf("Yes");
    
    else  if(ara[1][0]==-101 && ara[1][1]==-101 && ara[1][2]==-101)printf("Yes");
    
    else  if(ara[2][0]==-101 && ara[2][1]==-101 && ara[2][2]==-101)printf("Yes");
    
    else  if(ara[0][0]==-101 && ara[1][0]==-101 && ara[2][0]==-101)printf("Yes");
    
    else  if(ara[0][1]==-101 && ara[1][1]==-101 && ara[2][1]==-101)printf("Yes");
    
    else  if(ara[0][2]==-101 && ara[1][2]==-101 && ara[2][2]==-101)printf("Yes");
    
    else  if(ara[0][0]==-101 && ara[1][1]==-101 && ara[2][2]==-101)printf("Yes");
    
    else  if(ara[0][2]==-101 && ara[1][1]==-101 && ara[2][0]==-101)printf("Yes");
    
	else printf("No");
		
}

Measured memory_bytes: 256
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1000001;
const int mod = 1000000007;


int main(){
    int x, y;
    cin>>x>>y;
    int amount = 0;
    if(x == 1 && y == 1)amount = 1000000;
    else if(x == 2 && y == 2)amount = 400000;
    else if(x == 3 && y == 3)amount = 200000;
    else{
        if(x == 1 || y == 1)amount += 300000;
        if(x == 2 || y == 2)amount += 200000;
        if(x == 3 || y == 3)amount += 100000;
    }

    cout<< amount << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<ll>l(2 * n); REP(i, 2 * n)l[i] = in();
    sort(ALL(l));
    ll ans = 0;
    REP(i, n)ans += l[2 * i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b) printf("a < b\n");
	if(a>b) printf("a > b\n");
	if(a==b) printf("a == b\n");

	return 0;
}

Measured memory_bytes: 1792