akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;
string s;
vector<ll> a;

int main(){
    //cin >> ;
    //cout << ans << endl;

    scanf("%lld", &N);
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    scanf("%lld", &K);
    set<ll> db;
    ans = INF;
    db.insert(N);
    while(1){
        ll stmp = db.size();
        if(N >= K){
            N %= K;
        }
        else{
            N = N - K;
            N *= -1;
        }
        db.insert(N);
        if(stmp == db.size()){
            break;
        }
    }
    cout << *db.begin() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int maxn = 2e5 + 5;
typedef long long ll;
typedef uint64_t HT;
const int mod = 1e9 + 7;
int pre[N], sum[N];
int find(const int &x) {
    return x == pre[x] ? x : pre[x] = find(pre[x]);
}
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        pre[i] = i;
        sum[i] = 1;
    }
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        int xx = find(x);
        int yy = find(y);
        if (xx != yy) {
            pre[xx] = yy;
            sum[yy] = sum[yy] + sum[xx];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (find(i) == i) ans = max(ans, sum[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11224
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	ll N,A,B;
	cin >> N >> A >> B;
	if(A > B) {
		cout << 0 << endl;
		return 0;
	}
	if(N==1 && A!=B) {
		cout << 0 << endl;
		return 0;
	}
	
	cout << B*(N-1)+A-A*(N-1)-B+1 << endl;
	
	

  return 0;
}


Measured memory_bytes: 256
require 'set'

MV = [[0,1,2,14,18,27,28,29,15,20],
      [6,7,8,12, 9,21,22,23,17,11],
      [0,3,6, 9,15,23,26,29,20,17],
      [2,5,8,11,12,21,24,27,18,14]]
 
def check arr
  [0,9,12,15,18,21,30].each_cons(2){ |s,t| return false if (s...t).any?{ |i| arr[i] != arr[s] } }
  true
end

def check2 arr
  return 0 if check arr
  s = Set.new
  s.add arr
  q = []
  q << [arr, 0]
  loop do
    arr, cnt = q.shift
    MV.each do |a|
      tmp = arr.dup
      5.times{ |i| tmp[a[i]], tmp[a[5+i]] = tmp[a[5+i]], tmp[a[i]] }
      return cnt + 1 if check tmp
      unless s.include? tmp
        q << [tmp, cnt + 1] 
        s.add tmp
      end
    end
  end
end
 
gets.to_i.times do
  p check2 gets.split(" ").map(&:to_i) 
end

Measured memory_bytes: 9280
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int A, B;
int a[2000000];

int main(int argc, char** argv) {
    cin >> A >> B;
    if (A <= 8 && B <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll ans[2010];
void solve(int T)
{
    int s;
    cin >> s;
    ans[3]=ans[4]=ans[5]=1;
    for(int i=6;i<=2000;i++)
    {
        ans[i] = (ans[i-1]+ans[i-3])%mod;
    }
    cout << ans[s];
}



signed main()
{
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while (cin>>n)
    {
        if(n==0) break;
        Int ans=0;
        ans+=(n/pow(5,1));
        ans+=(n/pow(5,2));
        ans+=(n/pow(5,3));
        ans+=(n/pow(5,4));
        ans+=(n/pow(5,5));
        ans+=(n/pow(5,6));
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3136
// ABC117_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    double N, M;
    cin >> N >> M;
//    vector<int> vec(N);
//    REP(i, N) cin >> vec[i];
    
    // calculation
    
    cout << N/M << "\n";
    
//    cout << N << M << "\n";
    
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

vector<int64> dijkstra(int32 n, int32 s, vector<vector<pii>> &adj){
    vector<int64> d(n, LLINF);
    d[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top();que.pop();
        int v = p.second;
        if(d[v] < p.first)continue;
        for(int i = 0; i < (signed)adj[v].size(); i++){
            int32 to, cost;
            tie(to, cost) = adj[v][i];
            if(d[to] > d[v] + cost){
                d[to] = d[v] + cost;
                que.push(pii(d[to], to));
            }
        }
    }
    return d;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;t--;
    vector<vector<pii>> adjYen(n);
    vector<vector<pii>> adjSnuuk(n);
    REP(i,m){
        int32 u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;v--;
        adjYen[u].emplace_back(v, a);
        adjYen[v].emplace_back(u, a);
        adjSnuuk[u].emplace_back(v, b);
        adjSnuuk[v].emplace_back(u, b);
    }
    vector<int64> dYen = dijkstra(n, s, adjYen);
    vector<int64> dSnuuk = dijkstra(n, t, adjSnuuk);
    vector<int64> ans(n);
    ans[n-1] = dYen[n-1] + dSnuuk[n-1];
    FORR(i,n-2,0){
        ans[i] = min(ans[i+1], dYen[i] + dSnuuk[i]);
    }
    REP(i,n){
        cout << fixed << setprecision(0);
        ANS(1e15 - ans[i]);
    }
    return 0;
}

Measured memory_bytes: 19016
use std::io;
use std::io::prelude::*;

struct SegTree {
    n: usize,
    nodes: Vec<(i32, Option<i32>)>,
}

impl SegTree {
    fn new(n: usize) -> SegTree {
        let n = 1 << f64::log2(n as f64).ceil() as usize;
        SegTree {
            n,
            nodes: vec![(0, None); 2 * n - 1],
        }
    }

    fn update(&mut self, s: usize, t: usize, x: i32, ni: usize, l: usize, r: usize) {
        self.eval(ni);
        if r <= s || t <= l {
            return;
        }
        if s <= l && r <= t {
            self.nodes[ni].1 = Some(x * (r - l) as i32);
            self.eval(ni);
            return;
        }
        let m = (l + r) / 2;
        self.update(s, t, x, 2 * ni + 1, l, m);
        self.update(s, t, x, 2 * ni + 2, m, r);
        self.nodes[ni].0 = self.nodes[2 * ni + 1].0 + self.nodes[2 * ni + 2].0;
    }

    fn eval(&mut self, ni: usize) -> i32 {
        match self.nodes[ni].1.take() {
            Some(x) => {
                self.nodes[ni].0 = x;
                if ni < self.n - 1 {
                    self.nodes[2 * ni + 1].1 = Some(x / 2);
                    self.nodes[2 * ni + 2].1 = Some(x / 2);
                }
            }
            None => {}
        }
        self.nodes[ni].0
    }

    fn get_sum(&mut self, s: usize, t: usize, ni: usize, l: usize, r: usize) -> i32 {
        self.eval(ni);
        if s <= l && r <= t {
            self.nodes[ni].0
        } else if r <= s || t <= l {
            0
        } else {
            let m = (l + r) / 2;
            self.get_sum(s, t, 2 * ni + 1, l, m) + self.get_sum(s, t, 2 * ni + 2, m, r)
        }
    }
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let line0 = lines.next().unwrap().unwrap();
    let n = line0.split_whitespace().next().unwrap().parse().unwrap();

    let mut st = SegTree::new(n);

    for l in lines.map(Result::unwrap) {
        let mut words = l.split_whitespace();
        let com = words.next().unwrap().parse().unwrap();
        let s: usize = words.next().unwrap().parse().unwrap();
        let t: usize = words.next().unwrap().parse().unwrap();
        let n = st.n;
        match com {
            0 => {
                let x = words.next().unwrap().parse().unwrap();
                st.update(s, t + 1, x, 0, 0, n);
            }
            1 => println!("{}", st.get_sum(s, t + 1, 0, 0, n)),
            _ => (),
        }
    }
}



Measured memory_bytes: 9232
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            //System.Threading.Thread.Sleep(1000);
        }
 
        public void Solve(ConsoleInput cin)
        {
            int[] list = cin.ReadIntArray(3);
            int b = cin.ReadInt;
 
            Array.Sort(list);
 
            int sum = list[2];
            for (int i = 0; i < b; i++)
            {
                sum = sum * 2;
            }
 
            sum += list[0] + list[1];
 
            Console.WriteLine(sum);
        }
    }
 
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
S = input()
a = int(S[:2])
b = int(S[2:])
aa = 0<a and 13>a
bb = 0<b and 13>b
if aa:
    if bb:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if bb:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <set>
using namespace std;
int main()
{
	int x, n;
	scanf("%d %d", &x, &n);
	set<int> p;
	for(int i = 0; i < n; i++)
	{
		int q;
		scanf("%d", &q);
		p.insert(q);
	}
	int d = 0;
	while(true)
	{
		if(p.find(x - d) == p.end())
		{
			printf("%d\n", x - d);
			return 0;
		}
		if(p.find(x + d) == p.end())
		{
			printf("%d\n", x + d);
			return 0;
		}
		d++;
	}
}

Measured memory_bytes: 3792
#include <stdio.h>

int main(void)
{
	int y, m, d;
	
	while (scanf("%d %d %d", &y, &m, &d) != EOF){
		if (y * 10000 + m * 100 + d >= 19890108){
			printf("heisei %d %d %d\n", y - 1989 + 1, m, d);
		}
		else if (y * 10000 + m * 100 + d >= 19261225){
			printf("showa %d %d %d\n", y - 1926 + 1, m, d);
		}
		else if (y * 10000 + m * 100 + d >= 19120730){
			printf("taisho %d %d %d\n", y - 1912 + 1, m, d);
		}
		else if (y * 10000 + m * 100 + d >= 18680908){
			printf("meiji %d %d %d\n", y - 1868 + 1, m, d);
		}
		else {
			printf("pre-meiji\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 608
st = str(input())

ans = 0
tmp = 0
for i in range(len(st)):
    if st[i] == 'A' or st[i] == 'T' or st[i] == 'G' or st[i] == 'C':
        tmp += 1
    else:
        if ans < tmp:
            ans = tmp
        tmp = 0

if ans < tmp:
    ans = tmp
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
# define M_PI 3.14159265358979323846
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=0;i<n-1;i++)
    {
        int temp;
        cin>>temp;
        if(mp[temp]==0)
        {
            mp[temp]=1;
        }
        else
        {
            mp[temp]+=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
}

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

const int N = 3001;
long double dp[N][N];
long double p[N];
int n;

long double solve(int i, int cnt) {
    if (i == 0) {
        return cnt > (n - cnt);
    }
    long double& ans = dp[i][cnt];
    if (ans > -0.5) {
        return ans;
    }
    ans = solve(i - 1, cnt + 1) * p[i] + solve(i - 1, cnt) * (1 - p[i]);
    return ans;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp[i][j] = -1;
        }
    }
    double res = solve(n, 0);
    printf("%.10f", res);
    return 0;
}


Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    vector<string> S(3);
    int N;
    cin >> N;
    cin >> S;
    int ans = 0;
    REP(i, N) {
        set<char> s;
        REP(j, 3) {
            s.insert(S[j][i]);
        }
        ans += SZ(s) - 1;
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=1e6+1;
  ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
  //
  //	
    	ll  solve(){
    		ll a,b,x,y;
    		cin>>a>>b>>x>>y;
    		ll ans=b/x-a/x+(a%x==0)+(b/y-a/y+(a%y==0))-(b/lcm(x,y)-a/lcm(x,y)+(a%lcm(x,y)==0));
    		// cout<<ans<<" ";
    		cout<<(b-a+1-ans);
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

Measured memory_bytes: 256
N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)
A =[]
B =[]
total =0

for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B)

Measured memory_bytes: 17344
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll len;
        cin>>len;
        vector<ll> arr(len);
        for(auto &i:arr) cin>>i;
        sort(arr.begin(),arr.end());
        set<ll> uniq;
        ll cnt = 0;
        for(auto i=0; i<len; i++){
            for(auto j=i; j<len; j++){
                for(auto k=j; k<len; k++){
                    uniq.insert(arr[i]); uniq.insert(arr[j]); uniq.insert(arr[k]);
                    if(uniq.size() == 3){
                        vector<ll> temp(uniq.begin(),uniq.end());
                        sort(temp.begin(),temp.end());
                        if(temp[0]+temp[1] > temp[2]) cnt++;
                        uniq.clear();
                    }
                    else{
                        uniq.clear();
                    }
                }
                uniq.clear();
            }
            uniq.clear();
        }
        cout<<cnt<<endl;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3672
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int ans = N - K + 1;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<b; i++)
#define REP(i, n)    for(int i=0; i<(n); i++)
#define fst first
#define pb push_back
#define mp make_pair
#define ALL(obj) (obj).begin(), (obj).end()
using ul = unsigned long;
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;



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

  string c;
  cin >> c;
  int n = c.size();
  int count =0;
  REP(i, n-1){
    if(c[i]!=c[i+1]) count ++;
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 512
N = int(input())
z = [tuple(map(int,input().split())) for i in range(N)]
z.sort()
y = [(z[i][1],i) for i in range(N)]
y.sort()
cost = [[] for i in range(N)]
for i in range(N-1):
    j = y[i][1]
    cost[i].append((i-1,min(abs(z[i][0]-z[i-1][0]),abs(z[i][1]-z[i-1][1]))))
    j_ = y[i-1][1]
    cost[j].append((j_,min(abs(y[i][0]-y[i-1][0]),abs(z[j][0]-z[j_][0]))))
    cost[i].append((i+1,min(abs(z[i+1][0]-z[i][0]),abs(z[i+1][1]-z[i][1]))))
    j_ = y[i+1][1]
    cost[j].append((j_,min(abs(y[i+1][0]-y[i][0]),abs(z[j_][1]-z[j][1]))))

i = N-1
j = y[i][1]
cost[i].append((i-1,min(abs(z[i][0]-z[i-1][0]),abs(z[i][1]-z[i-1][1]))))
j_ = y[i-1][1]
cost[j].append((j_,min(abs(y[i][0]-y[i-1][0]),abs(z[j][0]-z[j_][0]))))


import heapq

def prim(cost):
    V = len(cost)
    res = 0
    mincost = [float('inf')]*V
    used = [False]*V
    hq = []
    mincost[0] = 0
    heapq.heappush(hq,(0,0))
    done = 0
    while hq:
        weight,u = heapq.heappop(hq)
        if not used[u]:
            used[u] = True
            done += 1
            res += weight
            mincost[u] = weight
            for v, v_cost in cost[u]:
                if not used[v]:
                    heapq.heappush(hq,(v_cost,v))
            if done == V:
                break
    return res

print(prim(cost))

Measured memory_bytes: 91672
var
	s,t:String;
	flag:Boolean;
	i,j:Longint;
begin
	readln(s);
	readln(t);
	for i:=length(s)-length(t) downto 0 do begin
		flag:=True;
		for j:=1 to length(t)do if(s[i+j]<>'?')and(s[i+j]<>t[j])then begin
			flag:=False;
			break;
		end;
		if flag then begin
			for j:=1 to i do if s[j]='?'then write('a')else write(s[j]);
			for j:=1 to length(t)do write(t[j]);
			for j:=i+length(t)+1 to length(s)do if s[j]='?'then write('a')else write(s[j]);
			writeln;
			exit;
		end;
	end;
	writeln('UNRESTORABLE');
end.


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll l,r;
	cin>>l>>r;
	if(r-l+1>=2019){
		cout<<0;
		return 0;
	}
	int res=-1;
	for(ll int i=l;i<=r;i++){
		for(ll int j=i+1;j<=r;j++){
			int temp=((i%2019)*(j%2019))%2019;
			if(res==-1){
				res=temp;
			}else{
				res=min(res,temp);
			}
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
#include <utility>
#include <tuple>
 
#define rep(i,f,n) for(int (i)=(f);i<(n);i++)
#define LL long long int
 
 /* 
 greater<int>() 
 sortの第三因数に入れて降順 
sqrt(double) √を求める 
pair<int,int> x=make_pair(a,b)
x.first
tuple
get<番目>(変数名)
 */
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 
int main(void){

    int n;
    cin >>n;

    int a[n+1],b[n+1],c[n+1];
    rep(i,1,n+1){
        scanf("%d",&a[i]);
    }
    rep(i,1,n+1){
        scanf("%d",&b[i]);
    }

    rep(i,1,n){
        scanf("%d",&c[i]);
    }
    int mae=6000;
    int ans=0;
    rep(i,1,n+1){
        if(a[i]==mae+1){
            ans+=c[mae];
        }
        ans+=b[a[i]];
        mae=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;
typedef long long LL;
LL fac[MAXN];

LL qpow (LL a, LL b)
{
  LL ans = 1;
  while(b)
  {
    if(b & 1) ans = ans * a % MOD;
    a = a * a % MOD;
    b = b / 2;
  }
  return ans;
}

LL C (LL a, LL b)
{
  LL ans = fac[a] * qpow(fac[b], MOD - 2) % MOD;
  ans = ans * qpow((fac[a-b] + MOD) % MOD, MOD - 2) % MOD;
  return ans;
}

int main()
{
  int n , m , k;
  fac[0] = 1;
  for (int i = 1; i < MAXN; i++) fac[i] = fac[i - 1] * i % MOD;
  scanf("%d%d%d",&n,&m,&k);
  LL ans = 1;
  ans = ans * C(n*m,k) % MOD * C(k,2) % MOD * (n+m) % MOD * qpow(3,MOD-2) % MOD;
  printf("%lld\n",ans);

}

Measured memory_bytes: 1792
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
int tot;
ll val[105];

il int count(ll x){
	int ans=0;
	while(x) ++ans,x/=10;
	return ans;
}

il ll dfs(ll num,int id,bool first){
	if(id==tot){
		if(!val[id]){
			if(!num) return first?9:10;
			return 0;
		}else{
			if(num%val[id]) return 0;
			if(num>=0) return qmax(0ll,10-num/val[id]-first);
			else return qmax(0ll,10-(-num/val[id])-(first&&!num));
		}
	}
	if(num<0){
		num=-num;
		ll tmp=num/val[id];
		if(tmp>9) return 0;
		ll ans=dfs(-num+tmp*val[id],id+1,false)*qmax(0ll,10-tmp-(first&&!tmp));
		if(num%val[id]&&tmp<9) ans+=dfs(-num+(tmp+1)*val[id],id+1,false)*qmax(0ll,9-tmp);
		return ans;
	}else{
		ll tmp=num/val[id];
		if(tmp>9) return 0;
		ll ans=dfs(num-tmp*val[id],id+1,false)*(10-tmp-first);
		if(tmp<9) ans+=dfs(num-(tmp+1)*val[id],id+1,false)*(10-tmp-1-first);
		return ans;
	}
}

il ll getans(ll n,int w){
	tot=0;
	if(!--w) return 0;
	for(int i=w;i>=0;i-=2){
		ll cur=0;
		rep0(j,i) cur=cur*10+9;
		rep0(j,w-i>>1) cur*=10;
		val[++tot]=cur;
	}
//	rep(i,1,tot) cerr<<val[i]<<endl;
//	cerr<<"end"<<endl;
	return dfs(n,1,true);
}

int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	rep(i,count(n),count(n)<<1) ans+=getans(n,i);
	printf("%lld\n",ans); 
	return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
 
for i in range(n+1):#10000の数
  for j in range(n-i+1):#5000の数
    k = n-i-j
    if k >= 0  and 10000*i + 5000*j + 1000*k == y :
      print(i, j, k)
      exit()
      
print(-1, -1, -1)
    

Measured memory_bytes: 3060
N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])

Measured memory_bytes: 7748
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int main() {
  int w, h, n; cin >> w >> h >> n;
  VVI rect(w, VI(h, 0));
  REP(i, n) {
    int x, y, a; cin >> x >> y >> a;
    switch (a) {
      case 1:
        REP(j, h) {
          REP(k, x) rect[k][j] = 1;
        }
        break;
      case 2:
        REP(j, h) {
          FOR(k, x, w) rect[k][j] = 1;
        }
        break;
      case 3:
        REP(j, w) {
          REP(k, y) rect[j][k] = 1;
        }
        break;
      case 4:
        REP(j, w) {
          FOR(k, y, h) rect[j][k] = 1;
        }
        break;
    }
  }
  int ans = 0;
  REP(i, w) {
    ans += h - accumulate(rect[i].begin(), rect[i].end(), 0);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
rank = []
p = []


def makeSet(x):
    p.append(x)
    rank.append(0)


def union(x, y):
    link(findSet(x), findSet(y))


def link(x, y):
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] = rank[y] + 1


def findSet(x):
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]


def same(x, y):
    return findSet(x) == findSet(y)


n, q = map(int, input().split())
for i in range(n):
    makeSet(i)
for i in range(q):
    com, x, y = map(int, input().split())

    if com == 0:
        union(x, y)
    elif com == 1:
        print(int(same(x, y)))


Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll k,n;
cin>>n>>k;
ll ans;
if(n<k)
  {
      ll ans1=n,ans2=k-n;
      ans=min(ans1,ans2);
  }
else
{
    ll ans1,ans2;
    ans1=n%k;
    ans2=k-n%k;
    ans=min(ans1,ans2);
}
cout<<ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#ifdef LOCAL
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
typedef long long ll;
#define PB push_back
#define MP make_pair

#define N 112345
#define INF 11234567890123456
int n, m; long long x;
ll h[N];
vector<pair<int, ll>> g[N];
ll d[N], c[N];
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;

int main(){
	scanf("%d%d%lld", &n, &m, &x);
	REP(i, n) scanf("%lld", h+i);
	REP(i, m){
		int a, b; ll c;
		scanf("%d%d%lld", &a, &b, &c); a--; b--;
		g[a].PB(MP(b, c));
		g[b].PB(MP(a, c));
	}
	fill(d, d+N, INF);
	fill(c, c+N, false);
	d[0]=0;
	que.push(MP(0, 0));
	while(que.size()){
		auto p=que.top(); que.pop();
		int i=p.second;
		if(c[i]) continue;
		c[i]=true;
		ll t=max(x-d[i], 0LL); //Now height
		DEBUG("%d d=%lld t=%lld\n", i, d[i], t);
		for(auto e:g[i]){
			int j=e.first;
		 	ll u=e.second; //fly cost
			if(h[i]<u) continue;
			if(c[j]) continue;
			ll v=d[i];
			if(u<=t){
				if(t-u>h[j]){
					v+=t-h[j];
				}else{
					v+=u;
				}
			}else{
				v+=(u-t)+u;
			}
			DEBUG("%d->%d %lld+%lld=%lld\n", i, j, d[i], v-d[i], v);
			if(d[j]>v){
				d[j]=v;
				que.push(MP(d[j], j));
			}
		}
	}
	ll ans=0;
	if(d[n-1]>=INF){
		ans=-1;
	}else if(d[n-1]<=x){
		ans=d[n-1]+(h[n-1]-(x-d[n-1]));
	}else{
		ans=d[n-1]+h[n-1];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 24492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
#define int long long
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int n;
    cin >> n;
    int a[3 * n];
    rep (i, 0, 3 * n) cin >> a[i];

    priority_queue<int, vector<int>, greater<int>> qs;
    int s[n * 2 + 1];
    s[0] = 0;
    rep (i, 0, n) {
        s[i + 1] = s[i] + a[i];
        qs.push (a[i]);
    }
    rep (i, n, 2 * n) {
        int mi = qs.top();
        if (mi < a[i]) {
            s[i + 1] = s[i] - mi + a[i];
            qs.pop();
            qs.push (a[i]);
        } else {
            s[i + 1] = s[i];
        }
    }

    priority_queue<int> qt;
    int t[n * 2 + 1];
    t[0] = 0;
    rep (i, 0, n) {
        t[i + 1] = t[i] + a[3 * n - 1 - i];
        qt.push (a[3 * n - 1 - i]);
    }
    rep (i, n, 2 * n) {
        int ma = qt.top();
        if (ma > a[3 * n - 1 - i]) {
            t[i + 1] = t[i] - ma + a[3 * n - i - 1];
            qt.pop();
            qt.push (a[3 * n - 1 - i]);
        } else {
            t[i + 1] = t[i];
        }
    }
    ll ans = -INF;
    rep (i, n, 2 * n + 1) {
        ans = max (ans, s[i] - t[n * 3 - i]);
        // cout << s[i] << " " << t[n*3-i] << "\n";
    }
    cout << ans << "\n";
}


Measured memory_bytes: 10472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll A[N];
  ll X[N];
  ll sum = 0;
  ll sum2 = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum += A[i];
    if(i%2==1 && i>0) sum2 += A[i];
  }
  X[0] = sum - 2*sum2;
  for(int i=1;i<N;i++){
    X[i] = 2*A[i-1] - X[i-1];
  }
  for(int i=0;i<N;i++){
    cout << X[i] << " ";
  }
  cout << endl;
}


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

int main(){
    std::vector<int> a, b;
    a.resize(4);
    b.resize(4);
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
        int hitcount = 0, blowcount = 0;
        for(int i = 0; i < 4; ++i){
            if(a.at(i) == b.at(i))
                ++hitcount;
        }
        for(int value_a : a){
            for(int value_b : b){
                if(value_a == value_b)
                    ++blowcount;
            }
        }
        std::cout << hitcount << " " << blowcount - hitcount << std::endl;
    }
}

Measured memory_bytes: 1196
//

fun main() {
    intro_heuristicsa()
}

fun intro_heuristicsa() {
    val d = readLine()!!.toInt()
    val c = readLine()!!.split(" ").map { it.toInt() }
    val s = MutableList(d) { listOf<Int>() }
    repeat(d) {
        s[it] = readLine()!!.split(" ").map { it.toInt() }
    }
    val nextContest = (1..26).toMutableList()
    nextContest.shuffle()
    val minloss_last = IntArray(26) { 0 }
    val max_last = IntArray(26) { 0 }
    val max_pattern = mutableListOf<Int>()
    val minloss_pattern = mutableListOf<Int>()
    repeat(d) {
        val scores = s[it].mapIndexed { index, i -> index to i }
        val day = it + 1
        val minloss_disapoint = minloss_last.mapIndexed { index, i -> (it - i + 1) * c[index] }.sum()
        val minloss_score = scores.maxBy { (index, value) -> value + (c[index] * (day - minloss_last[index])) - minloss_disapoint }!!
        minloss_pattern.add(minloss_score.first + 1)
        minloss_last[minloss_score.first] = day
        val max_score = scores.maxBy { it.second }!!
        max_pattern.add(max_score.first + 1)
        max_last[max_score.first] = day
    }
    val max_score = computeScore(max_pattern, s, c)
    val minloss_score = computeScore(minloss_pattern, s, c)
    if (max_score > minloss_score) {
        max_pattern.forEach(::println)
    } else {
        minloss_pattern.forEach(::println)
    }
}

private fun computeScore(selected: List<Int>, s: List<List<Int>>, c: List<Int>): Int {
    var score = 0
    val last = IntArray(26) { 0 }
    for (i in selected.indices) {
        val contest = selected[i]
        val day = i + 1
        score += s[i][contest - 1]
        last[contest - 1] = day
        score -= last.mapIndexed { index, i -> (day - i) * c[index] }.sum()
    }
    return score
}


Measured memory_bytes: 41328
#include<bits/stdc++.h>
using namespace std;
const int maxn=5+2e5;    
int a[maxn];
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int k,n;
    cin>>k>>n;

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

    int ans=0,mx=0;
    for (int i=0;i<n-1;i++)
    {
        ans+=a[i+1]-a[i];
        mx=max(mx,a[i+1]-a[i]);
    }
    ans+=a[0]+k-a[n-1];
    mx=max(mx,a[0]+k-a[n-1]);

    cout<<ans-mx<<'\n';
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();

		if(a<b)System.out.println((a+w<b)? b-(a+w):"0");
		else System.out.println((b+w<a)? a-(b+w):"0");
	}
}

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


int main(void){
  int x1,y1,x2,y2,a,b,x3,y3,x4,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  a = x2 - x1;
  b = y2 - y1;
  x3 = x2 - b;
  y3 = y2 + a;
  x4 = x3 - a;
  y4 = y3 - b;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
def takeAllByX(z, w, xs):
    return abs(w - xs[-1])

def forceLastByX(z, w, xs):
    return abs(xs[-2] - xs[-1])

def forceLast2ByX(z, w, xs):
    return play2ByY(z, w, xs[-2:])


def takeAllByY(z, w, xs):
    return abs(z - xs[-1])

def forceLastByY(z, w, xs):
    return abs(xs[-2] - xs[-1])

def play2ByY(z, w, xs):
    ta = takeAllByY(z, w, xs)
    fl = forceLastByY(z, w, xs)
    return min(ta, fl)



if __name__ == "__main__":
    n, z, w = list(map(int, input().split()))
    xs = tuple(map(int, input().split()))
    i = len(xs)
    if i == 1:
        print(takeAllByX(z, w, xs))
    elif i == 2:
        print(max(takeAllByX(z, w, xs), forceLastByX(z, w, xs)))
    else:
        print(max(takeAllByX(z, w, xs), forceLastByX(z, w, xs), forceLast2ByX(z, w, xs)))





Measured memory_bytes: 3188
a=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
cnt=0

while True:
    b,f,r,v=list(map(int,input().split()))
    a[b-1][f-1][r-1]+=v
    cnt+=1
    if cnt==n:
        break

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" "+str(a[i][j][k]),end="")
        print()
    if i!=3:
        print("#"*20)



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

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define debug(x) cout << #x << ": " << x << endl
using ll = long long;

#define int ll

//**********

signed main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    int ans = 0;
    
    if (n>1&&m>1) ans = (n-2)*(m-2);
    if (n==1&&m>1) ans = m-2;
    if (n>1&&m==1) ans = n-2;
    if (n==1&&m==1) ans = 1;
    
    printf("%lld\n",ans);
    
    return 0;
    
}








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

int main (void) {
    string n;
    cin >> n;
    string res = "";

    switch (n[n.length()-1]) {
        case '3': res = "bon"; break;
        case '0':
        case '1':
        case '6':
        case '8': res = "pon"; break;
        default: res = "hon"; break;
    }

    cout << res << endl;


}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,n;
	cin>>x>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];}
	int y=x,b=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(y==a[j]){
				if(b%2==0){
					y=y-1-b;
					b=b+1;
				}
				else{
					y=y+1+b;
					b=b+1;
				}
			}
		}
	}	
cout<<y<<endl;
return 0;

		

}

Measured memory_bytes: 3472
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    ll N, K;
    cin >> N;
    cin >> K;

    ll ans = N%K;

    cout << min(ans, abs(ans-K))  << "\n";


    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int W = (int)Integer.parseInt(sc.next());
    	int H = (int)Integer.parseInt(sc.next());
    	int x = (int)Integer.parseInt(sc.next());
    	int y = (int)Integer.parseInt(sc.next());
    	int r = (int)Integer.parseInt(sc.next());

    	if((x-r)<0 || (x+r)>W || (y-r)<0 ||(y+r)>H){
    		System.out.println("No");
    	}else {
    		System.out.println("Yes");
    	}
		}
    }
    


Measured memory_bytes: 26332
import numpy as np

O=list(input())
E=list(input())
lenOE=len(O)+len(E)

if lenOE%2==1: # もしOとEを足して奇数長なら、都合のためにダミーを最後に足す
    E+="."

print("".join(np.asarray([O,E]).T.reshape(-1,)[:lenOE]))

Measured memory_bytes: 21516
N = gets.chomp.chars.map(&:to_i)
K = gets.to_i

DIGITS = N.size
dp = Array.new(DIGITS + 1) { Array.new(2) { Array.new(K + 2, 0) } }
dp[0][0][0] = 1
DIGITS.times do |i|
  d = N[i]
  # same
  if d == 0
    (0..K).each do |k|
      dp[i + 1][0][k] = dp[i][0][k]
    end
  else
    (0..K).each do |k|
      c = 0
      (0..i).each do |ii|
        c += 1 if N[ii] != 0
      end
      dp[i + 1][0][c] = 1
    end
  end
  # lower
  (0..9).each do |n|
    (0..K).each do |k|
      if n == 0
        dp[i + 1][1][k] += dp[i][1][k]
      else
        dp[i + 1][1][k + 1] += dp[i][1][k]
      end
    end
  end
  # same -> lower
  (0..d).each do |n|
    next if n == d
    (0..K).each do |k|
      if n == 0
        dp[i + 1][1][k] += dp[i][0][k]
      else
        dp[i + 1][1][k + 1] += dp[i][0][k]
      end
    end
  end
end

ans = dp[DIGITS][0][K] + dp[DIGITS][1][K]
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
map<char,ll> mp;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>s;
    rep(i,n)mp[s[i]]++;
    ans=1;
    rep(i,n){
        (ans*=mp[s[i]]+1)%=MOD;
        mp[s[i]]=0;
    }
    Cout(ans-1);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 string s; cin >> s;
  int count = 0;
  for(int i = 0; i < 3; ++i) {
    if(s[i] == '1') count ++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int[] count = new int[26];
        char[] alpha = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

        StringBuilder input = new StringBuilder();

        while(scanner.hasNextLine()){
            String x = scanner.nextLine();
            if(x.length() == 0){
                break;
            }
            input.append(x);
        }



        char[] text = input.toString().toLowerCase().toCharArray();

        for(char txt : text){
            for(int i = 0; i < alpha.length; i++){
                if(txt == alpha[i]){
                    count[i]++;
                }
            }
        }

        for(int i = 0; i < alpha.length; i++){
            System.out.println(alpha[i] + " : " + count[i]);
        }

        scanner.close();
    }
}



Measured memory_bytes: 26052