akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <vector>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uit;
typedef double f2;
typedef long double f3;
#define N 100050
#define OUTSIZE 1050
#define rep(n) for(i=1;i<=n;i++)
#define per(n) for(i=n;i;i--)
namespace SA {
	int n,ws[OUTSIZE],wa[OUTSIZE],wb[OUTSIZE],rk[OUTSIZE],height[OUTSIZE],sa[OUTSIZE];
	char w[OUTSIZE];
	void build(int m) {
		int i,j,p,*x=wa,*y=wb;
		rep(m)ws[i]=0;
		rep(n)ws[x[i]=w[i]]++;
		rep(m)ws[i]+=ws[i-1];
		per(n)sa[ws[x[i]]--]=i;
		for(j=1;j<n;j<<=1) {
			for(p=0,i=n;i>n-j;i--) y[++p]=i;
			rep(n)if(sa[i]>j) y[++p]=sa[i]-j;
			rep(m)ws[i]=0;
			rep(n)ws[x[i]]++;
			rep(m)ws[i]+=ws[i-1];
			per(n)sa[ws[x[y[i]]]--]=y[i];
			swap(x,y);
			m=1;
			rep(n)x[sa[i]]=y[sa[i]+j]==y[sa[i+1]+j]&&y[sa[i]]==y[sa[i+1]]?m:m++;
			if(m>n) break;
		}
		rep(n)rk[sa[i]]=i; 
		p=0;
		rep(n)if(rk[i]!=n) {
			j=rk[i]+1;
			for(;w[i+p]==w[sa[j]+p];p++) ;
			height[rk[i]]=p;
			if(p) p--;
		}
	}
	void init() {
		n=6; w[1]='a'; w[2]='b'; w[3]='a'; w[4]='b'; w[5]='b'; w[6]='a';
		build(128);
	}
}
namespace Scape_Goat_Tree {
	#define ls ch[p][0]
	#define rs ch[p][0]
	int ch[OUTSIZE][2],val[OUTSIZE],siz[OUTSIZE],tot[OUTSIZE],ex[OUTSIZE],S[OUTSIZE],V[OUTSIZE],tp,koishi;
	int root,f[OUTSIZE],cnt;
	f2 AL=0.75;
	void pushup(int p) {
		siz[p]=siz[ls]+siz[rs]+ex[p];
		tot[p]=tot[ls]+tot[rs]+1;
	}
	int GG(int p) {
		return tot[p]*AL<max(tot[ls],tot[rs]);
	}
	int newnode(int v) {int p=++cnt; siz[p]=tot[p]=ex[p]=1; val[p]=v; return p;}
	void insert(int &p,int v,int fa) {
    	if(!p) {p=newnode(v); f[p]=fa; return ;}
    	insert(ch[p][v>val[p]],v,p);
    	pushup(p); if(GG(p)) koishi=p;
	}
	void init() {
		insert(root,1,0); insert(root,2,0); insert(root,3,0);
		insert(root,4,0); insert(root,5,0);
	}
	#undef ls
	#undef rs
}
#undef N
#define N 905
int n,m;
char mp[N][N];
ll ans;
int s1[N][N],s2[N][N];

int main() {
	scanf("%d%d",&n,&m);
	int i;
	for(i=1;i<=n;i++) scanf("%s",mp[i]+1);
	int j;
	int tmp=max(n,m);
	n=m=tmp;
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) mp[i][j]=(mp[i][j]=='#');
	int ln=n*2-1;
	for(i=1;i<=ln;i++) {
		for(j=1;j<=ln;j++) {
			s1[i][j]=s1[i][j-1]+(i-j+1>=1?mp[i-j+1][j]:0);
			s2[i][j]=s2[i][j-1]+(n-i+j>=1?mp[n-i+j][j]:0);
		}
	}
	int tx,ty;
	for(i=1;i<=ln;i++) {
		for(j=1;j<=n;j++) {
			int x=i-j+1,y=j;
			if(x<1||x>n) continue;
			for(tx=x-1,ty=y+1;tx>=1&&ty<=n;tx--,ty++) {
				int tmp=x-tx;
				if(mp[x][y]&&mp[tx][ty]) {
					ans+=s1[i+tmp+tmp][j+tmp+tmp]-s1[i+tmp+tmp][j+tmp-1];
					if(i-tmp-tmp>=1) ans+=s1[i-tmp-tmp][j]-s1[i-tmp-tmp][max(0,j-tmp-1)];
				}
			}
		}
	}
	for(i=1;i<=ln;i++) {
		for(j=1;j<=n;j++) {
			int x=n-i+j,y=j;
			if(x<1||x>n) continue;
			for(tx=x+2,ty=y+2;tx<=n&&ty<=n;tx++,ty++) {
				int tmp=tx-x;
				if(mp[x][y]&&mp[tx][ty]) {
					ans+=s2[i+tmp+tmp][j+tmp+tmp-1]-s2[i+tmp+tmp][j+tmp];
					if(i-tmp-tmp>=1) ans+=s2[i-tmp-tmp][j-1]-s2[i-tmp-tmp][max(0,j-tmp)];
				}
			}
		}
	}

	printf("%lld\n",ans);
}


Measured memory_bytes: 6528
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

L = [0]*26

v = 0
ans = [0]*D
import copy
for i in range(1, D+1):
    max_score = -float('inf')
    max_idx = 0
    for j in range(26):
        temp = v
        temp += S[i-1][j]
        L_ = copy.copy(L)
        L_[j] = i
        for k in range(26):
            for l in range(i, min(i+14, D+1)):
                temp -= C[k]*(i-L_[k])
        if temp >= max_score:
            max_score = temp
            max_idx = j
    v = max_score
    L[max_idx] = i
    ans[i-1] = max_idx+1
print(*ans, sep='\n')


Measured memory_bytes: 75668
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let (a,v) = read!(i64,i64);
	let (b,w) = read!(i64,i64);
	let t = read!(i64);
	if (v-w)*t >= (b-a).abs() {
		println!("YES");
	}
	else {
		println!("NO");
	}
}

fn run() {
    solve();
}


Measured memory_bytes: 2220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

vector<vector<int> > edge(500002, vector<int>(0));
vector<int> p(500002, 0);

vector<int> ans(500002);

void dfs(int vertex, int counter){
  ans[vertex] = counter + p[vertex];

  for(int i = 0; i < edge[vertex].size(); ++i){
    dfs(edge[vertex][i], ans[vertex]);
  }


}

int main(){
  int n;
  int q;
  cin >> n >> q;

  rep(i, n - 1){
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
  }

  rep(i, q){
    int P, X;
    cin >> P >> X;
    
    p[P] += X;
  }


  dfs(1, 0);

  for(int i = 1; i <= n; ++i){
    cout << ans[i] << endl;
  }

}


Measured memory_bytes: 30464
#include <iostream>

using namespace std;

int main(){
    int X;cin >> X;
    int ureshi = 0;
    while(X >= 500){
        X -= 500;
        ureshi+=1000;
    }
    while(X >= 5){
        X -= 5;
        ureshi+=5;
    }
    cout << ureshi << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toLong() }
    val cb = mutableMapOf<Long,Int>()
    a.forEach {
        cb[it] = (cb[it]?:0)+1
    }
    repeat(m) {
        val (b,c) = readLine()!!.split(" ").map { it.toLong() }
        cb[c] = (cb[c]?:0)+b.toInt()
    }

    val x = cb.toList().sortedByDescending { it.first }
    var sum = 0L
    var count = 0
    var i = 0
    while(count<n){

        if(count+x[i].second<n){
            count += x[i].second
            sum += x[i].first * x[i].second
        }else{
            sum += (n-count) * x[i].first
            println(sum)
            break
        }
        i++
    }
}



Measured memory_bytes: 149712
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int N;
int main() {
    vector<int> v(200005);
    map<int, ll> m;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
        ++m[v[i]];
    }
    ll c = 0;
    for (auto & kv : m) {
        // cout << kv.first << " " <<  kv.second << endl;
        c += kv.second * (kv.second - 1) / 2;
    }
    for (int k = 0; k < N; ++k) {
        int n = m[v[k]];
        // cout << v[k] << " " << c << " " <<  (n * (n - 1) / 2) << " " << ((n - 1) * (n - 2) / 2) << endl;
        if (n == 1)  {
            cout << c << endl;
        } else {
            cout << c - (n * (n - 1) / 2) + ((n - 1) * (n - 2) / 2) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main(){
    int n,ans;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(!m[x]) v.push_back(x);
        m[x]++;
    }
    while(0){
    	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	}
    for(int i=0;i<v.size();i++) 
		if(!(m[v[i]]<v[i])) ans+=m[v[i]]-v[i]; 
		else ans+=m[v[i]];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> m(n - 1);
  int res = a[n - 1];
  repr(i, n - 2) {
    res = max(res, a[i]);
    m[i] = res;
  }

  int v = m[0] - a[0], ans = 0;
  rep(i, n - 1) {
    if (m[i] - a[i] == v) ans++;
    else if (m[i] - a[i] > v) {
      v = m[i] - a[i];
      ans = 1;
    }
  }
  cout << ans << endl;





  
  return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int h,w,k;cin>>h>>w>>k;
  vector<vector<char>> s(h,vector<char>(w));
  int i,j,l;
  rep(i,h)rep(j,w)cin>>s[i][j];
  ll ans=10000000;
  for(i=0;i<(1<<(h-1));i++)
  {
    ll kans=0;
    vector<int> part(1);
    int now=0;
    part[0]=1;
    for(j=1;j<h;j++)
    {
      if(i&(1<<(j-1)))
      {
        part.push_back(1);
        now++;
      }
      else part[now]++;
    }
    int len=part.size();
    kans=len-1;
    now=0;
    vector<int> counts(len,0);
    vector<int> kcounts(len,0);
    bool fin=false;
    for(j=0;j<w;j++)
    {
      now=0;
      int left=part[0];
      for(l=0;l<h;l++)
      {
        if(left==0)
        {
          now++;
          left=part[now];
        }
        if(s[l][j]=='1')kcounts[now]++;
        left--;
      }
      bool ch=false;
      rep(j,len)if(counts[j]+kcounts[j]>k)ch=true;
      if(ch)
      {
        kans++;
        rep(j,len)counts[j]=0;
      }
      rep(j,len)counts[j]+=kcounts[j];
      rep(j,len)kcounts[j]=0;
      bool outs=false;
      rep(j,len)if(counts[j]>k)outs=true;
      if(outs)break;
      if(j==w-1)fin=true;
    }
    if(fin)ans=min(kans,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    double sum=0;
    rep(i,N){
        double a;
        cin>>a;
        double x=1/a;
        sum+=(double)x;
    }
    cout<<setprecision(12)<<1/sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
s = input()
u = ""
v = ""
ans = 0
for i in range(n):
    u += s[i]
    v = ""
    for j in range(i+1,n):
        v += s[j]
    u2 = collections.Counter(u)
    v2 = collections.Counter(v)
    ukey = []
    vkey = []
    for key in u2.keys():
        ukey.append(key)
    for key in v2.keys():
        vkey.append(key)
    same = 0
    for i in ukey:
        for j in vkey:
            if i == j:
                same += 1
    ans = max(ans,same)
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n);
    forn(i, n) cin >> a[i];
    int l = 1, r = 1e9 + 1;
    while (l != r) {
        int m = (l + r) / 2;
        int cnt = 0;
        forn(i, n) cnt += (a[i] - 1) / m;
        if (cnt <= k) r = m;
        else l = m + 1;
    }
    cout << l << "\n";
    return 0;
}

Measured memory_bytes: 3932
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <list>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <math.h>
#include <unordered_map>
#include <string>

typedef long long ll;
typedef double db;
const ll mod=1000000007;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* author : hey_it_works(kunal)
 It works, idk how exactly*/

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  string s;
  string t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]!=t[i])
    {
      cnt++;
    }
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back



int main() {
	int n;
	cin >> n ;
	std::vector<long long int > v(n+1);

	for (long long int i = 1; i <= n; ++i)
	{
		/* code */
		cin >> v[i];
	}

	long long int initSum =0;

	for (long long int i = 1; i <= n; ++i)
	{
		/* code */
		initSum = initSum + v[i];
	}
	unordered_map<long long int ,long long  int> mp;

	for (long long int i = 1; i <=n; ++i)
	{
		/* code */
		mp[v[i]]++;
	}

	long long int q;

	cin >> q;

	for (long long int k = 1; k <= q; ++k)
	{
		long long int b,c;
		cin >> b >> c;
		if(mp[b]!=0){
		    long long int sum  = initSum - (mp[b]*b) + (mp[b] * c);
		
		    mp[c] = mp[c]+mp[b];
		    mp[b] = 0;
		    initSum = sum;
		}
		
		
		cout << initSum << endl;

 	}
}

Measured memory_bytes: 7696
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

int main(){
  int n; cin>>n;
  vector<int> s(n);
  for(auto&& e:s) cin>>e;
  int q; cin>>q;
  vector<int> t(q);
  for(auto&& e:t) cin>>e;
  int c=0;
  for(const auto& e:t){
    for(const auto& d:s){ if(d==e){ ++c; break; } }
  }
  cout<<c<<'\n';
  return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<std::pair<size_t, size_t>> ab(M);
  for (auto& p: ab)
    scanf("%zu %zu", &p.second, &p.first);

  std::sort(ab.begin(), ab.end());
  for (auto& p: ab)
    std::swap(p.first, p.second);

  int res = 0;
  size_t last = 0;
  for (const auto& p: ab) {
    size_t a, b;
    std::tie(a, b) = p;
    if (last < a) {
      ++res;
      last = b-1;
    }
  }

  printf("%d\n", res);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<string,int> a;
int main()
{
	int n,num=0;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(a[s]==0)
		{
			num++;a[s]++;
		} 
		else a[s]++;
	}
	cout<<num;
    return 0;
}

Measured memory_bytes: 19256
#include<stdio.h>
 
int main(void){
 
int s=0;
 
int x=0;
int y=0;
  
scanf("%d",&s);
  
x=s/100;
y=s%100;
  
if(x>=1 && x<=12){
	if(y>12 || y==0){
    printf("MMYY");
    }else{printf("AMBIGUOUS");}
}else if(y>=1 && y<=12){
	if(x>12 || x==0){
    printf("YYMM");
    }else{printf("AMBIGUOUS");}
}else{
  printf("NA");
}
  
return 0; 
}

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

using namespace std;

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

  int res = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 2; j < 10; j++) {
      for (int k = 2; k < 10; k++) {
        if (10 * j + k <= d && j * k == i) {
          res++;
        }
      }
    }
  }

  cout << res << '\n';
  return 0;
}

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

string s;

void input(){
  cin >> s;
}

void solve(){
  input();
  string ans = "Yes";
  rep(i, s.size()){
    if( s.at(i) == 'U' || s.at(i) == 'D')continue;
    if( i % 2 == 0 && s.at(i) == 'R')continue;//0-indexedなので余り０の時に奇数番目
    if( i % 2 == 1 && s.at(i) == 'L')continue;
    ans = "No";
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools
tmp = [i for i in range(1,N+1)]
#print(tmp)
tmp2 = itertools.permutations(tmp)
a,b = 0,0
for n,j in enumerate(tmp2):
  #print(n,j)
  if list(j)==P:
    a = n+1
    #print(a)
  if list(j)==Q:
    b = n+1
    #print(b)
res=abs(a-b)

print(res)

Measured memory_bytes: 3064
use std::io::*;

fn operate<T: IntoIterator<Item = (u8, u8)>>(iter: T) {
  let mut bits = 0u64;

  for (query, i) in iter {
    match query {
      0 => println!("{}",
        if bits & (1u64 << i) != 0 {
          "1"
        } else {
          "0"
        }
      ),

      1 => { bits |= 1u64 << i; },

      2 => { bits &= !(1u64 << i); },

      3 => { bits ^= 1u64 << i; },

      4 => println!("{}",
        if bits == !0u64 { "1" } else { "0" }
      ),

      5 => println!("{}",
        if bits != 0u64 { "1" } else { "0" }
      ),

      6 => println!("{}",
        if bits == 0u64 { "1" } else { "0" }
      ),

      7 => println!("{}", bits.count_ones()),

      8 => println!("{}", bits),

      _ => unreachable!()
    }
  }
}

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines().map(|l| l.unwrap());

  let n = lines.next().unwrap().parse().unwrap();
  let list = lines.take(n).map(|line| {
    let mut args = line.split_whitespace().map(|s| s.parse::<u8>().unwrap());

    (args.next().unwrap(), args.next().unwrap_or(0))
  });

  operate(list);
}



Measured memory_bytes: 5044
#!/usr/bin/env python3
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for _ in range(m):
    p,x=map(int,input().split())
    t_true=t[p-1]
    t[p-1]=x
    print(sum(t))
    t[p-1]=t_true

Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;


    UnionFind(ll N): par(N), siz(N, 1LL) {
        for (ll i = 0; i < N; ++i) par[i] = i;
    }

    void init(ll N) {
        par.resize(N);
        siz.assign(N, 1LL);
        for (ll i = 0; i < N; ++i) par[i] = i;
    }


    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }


    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    UnionFind tree(n);
    rep(i,0,m){
        int a,b; cin >> a >> b;
        a--; b--;
        tree.unite(a,b);
    }

    int ans = 0;
    rep(i,0,n){
        if(tree.root(i) == i) ans++;
    }
    ans--;
    cout << ans << enld;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  unordered_map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  int64_t ans = 0;
  for (auto p : mp) {
    int s = p.second;
    ans += (int64_t)s*(s-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

class segtree{
public:
	static const int N=1<<20;
	static const ll INF=1LL<<60;
	P dp[1<<21];
	ll lazy[1<<21];
	segtree(){
		for(int i=0;i<N;i++){
			dp[N-1+i]=P(0,i);
		}
		for(int i=N-2;i>=0;i--){
			dp[i]=min(dp[i*2+1],dp[i*2+2]);
			lazy[i]=0;
		}
	}

	void init(){
		for(int i=0;i<N;i++){
			dp[N-1+i]=P(0,i);
		}
		for(int i=N-2;i>=0;i--){
			dp[i]=min(dp[i*2+1],dp[i*2+2]);
			lazy[i]=0;
		}
	}

	void lazy_eval(int k){
		if(lazy[k]==0)return;
		dp[k].first+=lazy[k];
		if(k<N-1){
			lazy[k*2+1]+=lazy[k];
			lazy[k*2+2]+=lazy[k];
		}
		lazy[k]=0;
	}

	void lazy_upd(int k){
		dp[k]=min(dp[k*2+1],dp[k*2+2]);
	}

	void update(int a,int b,ll v,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(b<=l || r<=a)return;
		if(a<=l && r<=b){
			lazy[k]+=v;
			lazy_eval(k);
			return;
		}
		int mid=(l+r)/2;
		update(a,b,v,k*2+1,l,mid);
		update(a,b,v,k*2+2,mid,r);
		lazy_upd(k);
		return;
	}

	P query(int a,int b,int k=0,int l=0,int r=N){
		lazy_eval(k);
		if(b<=l || r<=a)return P(INF,-1);
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		P vl=query(a,b,k*2+1,l,mid);
		P vr=query(a,b,k*2+2,mid,r);
		lazy_upd(k);
		return min(vl,vr);
	}
};

int n;
int a[200005];
int b[200005];
int cnt[200005];
int rest[200005];
int ans[200005];
segtree seg;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		rest[b[i]]++;
	}
	for(int i=0;i<=n;i++){
		if(rest[i]==0){
			//printf("%d hoge\n",i);
			seg.update(i,i+1,9999999);
		}else{
			seg.update(i,i+1,n-cnt[i]-rest[i]);
		}
	}
	for(int i=0;i<n;i++){
		P p=seg.query(0,n+1);
		if(p.first<0){
			printf("No\n");
			return 0;
		}
		P p1=seg.query(0,a[i]);
		P p2=seg.query(a[i]+1,n+1);
		//printf("%lld %d %lld %d\n",p1.first,p1.second,p2.first,p2.second);
		p=min(p1,p2);
		ans[i]=p.second;
		rest[p.second]--;
		if(rest[p.second]==0){
			seg.update(p.second,p.second+1,9999999);
		}else{
			seg.update(p.second,p.second+1,1);
		}
		seg.update(0,a[i],-1);
		seg.update(a[i]+1,n+1,-1);
		//printf("%d\n",ans[i]);
	}
	printf("Yes\n");
	for(int i=0;i<n;i++){
		printf("%d%c",ans[i],i+1==n?'\n':' ');
	}
	return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> di(n);
  for(int i=0; i<n; i++){
    cin >> di[i];
  }

  sort(di.begin(), di.end());

  if( di.size() % 2 == 1 ){
    cout << 0 << endl;
  }

  int right = di.size()/2;
  int left = di.size()/2-1;

  cout << di[right] - di[left] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<min(a*b, min(a, b)*c)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max()/4 ;
const ll linf = numeric_limits<ll>::max()/4 ;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////
int n;

int a[20] = {};

int dfs(int i,int se ){

    if(i >= n){
       // P(se);
        ret se%2 == 0;
    }

    
    int ans = dfs(i+1,se * (a[i]-1));
    ans += dfs(i+1,se * (a[i]+1));
    ans += dfs(i+1,se * a[i]);

    ret ans;
}

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

	P(dfs(0,1));
    
	return  0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  string s; std::cin >> s;
  vi cnt;
  rep(i, n) {
    int sum = 0;
    while (i < n && s[i] == s[i+1])
      i++, sum++;
    sum++;
    cnt.pb(sum);
  }
  int start = (s[0] == '1'), len = cnt.size();
  srep(i, 1, len) cnt[i] += cnt[i-1];
  int ans = (s[0] == '1' ? cnt[0] : 0);
  for(int i =  start; i < len; i+=2) {
    int l = max(0, i-1), r = min(len-1, i+2*(k-1)+1);
    if (l-1 >= 0) chmax(ans, cnt[r] - cnt[l-1]);
    else chmax(ans, cnt[r]);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int N;
    cin >> N;
    
    vl s(N);
    in(N,s);
    
    int i = 1;
    int ans = 0;
    
    while (i < N) {
        while (s[i-1] == s[i]) {
            i++;
            if(i == N-1) break;
        }
        
        if(s[i-1] <= s[i]){
            while (s[i-1] <= s[i]) {
                i++;
                if(i == N) break;
            }
        }else{
            while (s[i-1] >= s[i]) {
                i++;
                if(i == N) break;
            }
        }
        
        ans += 1;
        if(i == N-1) ans++,i++;
        i++;
        
        
    }
    if(N==1) ans = 1;
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 1024
N = (int)(input())
A = list(map(int,input().split()))

swapOperation = 0

for i in range(0,N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    if minj != i:
        v = A[i]
        A[i] = A[minj]
        A[minj] = v
        swapOperation += 1

print(' '.join(map(str,A)))
print(swapOperation)

Measured memory_bytes: 7720
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int N_MAX = 100000;

int N;
int a[N_MAX];
int b[N_MAX];
int c[N_MAX];

int dp[N_MAX + 1][3];
int *abc[3] = { a, b, c };

void solve() {
  REP(i, N) REP(j, 3) REP(k, 3) {
    if (j != k) dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[k][i]);
  }
  int ans = 0;
  REP(i, 3) ans = max(ans, dp[N][i]);
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d%d%d", a + i, b + i, c + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

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

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		long A[] = new long[n];
		
		for(int i=0;i<n;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		
		sort(A,0,A.length-1);
		
		int play[][] = new int[m][2];
		
		
		for(int i=0;i<m;i++){
			int b = Integer.parseInt(sc.next());
			int c = Integer.parseInt(sc.next());
			
			play[i][0] = b;
			play[i][1] = c;
			
		}
		
		sort2(play,0,m-1);
		long sum =0;
		int count = 0;
		int j;
		for(int i=0;i<m;i++) {
			
			for(j =count;((j-count)<play[m-i-1][0])&&(j<n);j++) {
				if(A[j]>play[m-i-1][1]) {
					break;
				}
				A[j] = play[m-i-1][1];
				
			}
			count += j-count;
		if(j==n)break;
		}
		
		for(int i =0;i<n;i++) {
			sum += A[i];
		}
		
		
		System.out.println(sum);
	}
	
	
	public static void sort(long[] array, int left, int right){
        if(left <= right){
            long p = array[(left + right) >>> 1];
            int l = left;
            int r = right;
            while(l <= r){
                while (array[l] < p){
                    l ++;
                }
                while (array[r] > p){
                    r --;
                }
                if (l <= r){
                    long tmp = array[l];
                    array[l] = array[r];
                    array[r] = tmp;
                    l++ ;
                    r-- ;
                }
            }
            sort(array, left, r);
            sort(array, l, right);
        }
    }
	
	 public static void sort2(int[][] array, int left, int right){
	        if(left <= right){
	            int p = array[(left + right) >>> 1][1];
	            int l = left;
	            int r = right;
	            while(l <= r){
	                while (array[l][1] < p){
	                    l ++;
	                }
	                while (array[r][1] > p){
	                    r --;
	                }
	                if (l <= r){
	                    int tmp = array[l][1];
	                    array[l][1] = array[r][1];
	                    array[r][1] = tmp;
	                     tmp = array[l][0];
	                    array[l][0] = array[r][0];
	                    array[r][0] = tmp;
	                    l++ ;
	                    r-- ;
	                }
	            }
	            sort2(array, left, r);
	            sort2(array, l, right);
	        }
	    }
}

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

//各桁の和を計算する関数
int findSumOfDigits(int n){
    int sum=0;
    while(n>0){//nが0になるまで
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int total=0;
    for(int i=0;i<N+1;i++){
        int sum=findSumOfDigits(i);
        if(A<=sum&&sum<=B){
            total+=i;
        }
    }
    cout<<total<<endl;
}

Measured memory_bytes: 256
ans = 0
def solve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    def f(a, b, kyori, li):
        if b == (1 << n) - 1:
            global ans
            ans += kyori
            return
        for i in range(n):
            if not ((b >> i) & 1):
                t = ((XY[a][0] - XY[i][0]) ** 2 + (XY[a][1] - XY[i][1]) ** 2) ** .5
                f(i, b | (1 << i), kyori + t, li + [i])
    for i in range(n):
        f(i, 1 << i, 0, [i])
    def g(a):
        ret = a
        for i in range(2, a):
            ret *= i
        return ret
    print(ans / g(n))
solve()


Measured memory_bytes: 3188
n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
  x,y=map(int,input().split())
  x,y=x-1,y-1
  g[x].append(y)
  g[y].append(x)

path=[g[0][0]]
pathr=[0]
#path=[12,4]
setpath=set([0,g[0][0]])
while True:
  flg=True
  for nv in g[path[-1]]:
    if nv not in setpath:
      flg=False
      path.append(nv)
      setpath.add(nv)
      break
  for nv in g[pathr[-1]]:
    if nv not in setpath:
      flg=False
      pathr.append(nv)
      setpath.add(nv)
      break
  if flg:break

print(len(path)+len(pathr))
pathr.reverse()
pathr+=path
path=[str(pi+1) for pi in pathr]
print(' '.join(path))
#print(path)
#print(setpath)

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

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

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


//
int main(){
	int N;cin>>N;
	vector<int> A(N);
	REP(i,N)cin>>A[i];


	int x = 0;
	REP(j,N){
		x += (j%2 ? -A[j] : A[j]);
	}
	cout << x;
	REP(i,N-1)cout << " " << (x = 2*A[i]-x);
	cout << endl;

	return 0;
}




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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    v[n - 1] /= 2;
    int sum = 0;
    rep(i, n) sum += v[i];
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long a,b,c,d,ac,ad,bc,bd;
	cin>>a>>b>>c>>d;
	ac=a*c;
	ad=a*d;
	bc=b*c;
	bd=b*d;
	cout<<(ac>(ad>(bc>bd?bc:bd)?ad:(bc>bd?bc:bd))?ac:(ad>(bc>bd?bc:bd)?ad:(bc>bd?bc:bd)));
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    const int M = 1000000;
    vec cnt(M + 1, 0);
    REP(i, N) cnt[A[i]]++;
    
    int ans = 0;
    FOR(i, 1, M + 1){
        FOR(j, 2, M / i + 1) cnt[i * j] += cnt[i];
    }
    REP(i, N) if(cnt[A[i]] == 1) ans++;

    Out(ans);

    return 0;
}


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

int mod = 1000000007;

int main()
{

    int64_t A, B, N;
    cin >> A >> B >> N;

    if (B <= N)
        cout << (B - 1) * A / B;
    
    else
        cout << N * A / B;
}

Measured memory_bytes: 3624
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func main() {
	defer write.Flush()

	var s string
	fmt.Fscan(read, &s)

	if s == "SUN" {
		fmt.Fprintln(write, 7)
	} else if s == "MON" {
		fmt.Fprintln(write, 6)
	} else if s == "TUE" {
		fmt.Fprintln(write, 5)
	} else if s == "WED" {
		fmt.Fprintln(write, 4)
	} else if s == "THU" {
		fmt.Fprintln(write, 3)
	} else if s == "FRI" {
		fmt.Fprintln(write, 2)
	} else if s == "SAT" {
		fmt.Fprintln(write, 1)
	}
}


Measured memory_bytes: 640
#include <cstdio>
 
using namespace std;
 
char s[1000001];
int Ipos[1000001];
 
int main()
{
	int N;
	
	scanf("%d", &N);
	scanf("%s", s);
	
	int ctr = 0;
	for (int i = N - 1; i >= 0; i--){
		if (s[i] == 'I') Ipos[++ctr] = i;
	}
	
	int left = 0, right = N;
	
	while (left != right){
		int center = (left + right + 1) / 2;
		
		int Jnum = 0, Onum = 0, Inum = 0;
		
		for (int i = 0; i < N; i++){
			if (s[i] == 'J' || (i < Ipos[center] && s[i] == 'I'))  Jnum++;
			if (s[i] == 'O' && Onum < Jnum) Onum++;
			if (s[i] == 'I' && Inum < Onum && i >= Ipos[center]) Inum++;
		}
		
		if (Jnum >= center && Onum >= center && Inum >= center) left = center;
		else right = center - 1;
	}
	
	printf("%d\n", left);
	
	return (0);
}

Measured memory_bytes: 5908
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main (void) {
    int A, B, C, K;
    int i, j, count=0, count2;
    int integer, value, value2;
    
    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);
    
    for(;B <= A && count <= K;count ++) {
        B *= 2;
    }
    
    for( ; C<=B && count <= K; count ++) {
        C *= 2;
    }
    if(C>B && B>A && count <= K) printf("Yes");
    else printf("No");

    
    return 0;
}



Measured memory_bytes: 2152
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sa = [0,a[0]]
    for i in a[1::]:
        sa.append(sa[-1]+i)

    mi = 10**18
    ll = 1
    rr = 3
    for ci in range(2,n-1):
        ls = sa[ci]
        rs = sa[-1]
        nms = []
        pld = 10**18
        for l in range(ll,ci):
            al = sa[l]
            d = abs(ls-2*al)
            if pld > d:
                pld = d
                sl = (al,ls-al)
                if l == ci:
                    ll = ci-1
            else:
                ll = l-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        pld = 10**18
        for r in range(rr,n):
            ar = sa[r]
            d = abs(rs+ls-2*ar)
            if pld > d:
                pld = d
                sl = (rs-ar,ar-ls)
                if r == n-1:
                    rr = n-1
            else:
                rr = r-1
                break
        nms.append(sl[0])
        nms.append(sl[1])
        d = max(nms)-min(nms)
        if mi > d:
            mi = d

    print(mi)


    return None

if __name__ == '__main__':
    main()


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

int main() 
{
    long long H,N;
    cin >> H >> N;
    long long sum = 0;
    for(int i = 0; i < N; i++){
        int A = 0;
        cin >> A;
        sum += A;
    }
    
    if (H <= sum) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n,m;
	cin>>n>>m;
	ll s=0;
	int a[m];
	for(int i=0;i<m;i++)
	{
	    cin>>a[i];
	    s=s+a[i];
	}
	if(n-s<0)
	{
	    cout<<-1<<endl;
	}
	else
	{
	    cout<<n-s<<endl;
	}
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#define task ""
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6 + 2;
int n, a[N];
bool ck[N];
bool ok[N];

void Read(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		ok[a[i]] = 1;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i < N; ++i)
		if(ok[i]){
			for(int j = i * 2; j < N; j += i)
			{
				ck[j] = 1;
			}
			//cout << i << " ";
		}
	//cout << "\n";
}

void Solve(){
	int cnt = 0;
	for(int i = 1; i <= n; ++i){
		//cout << a[i] << " ";
		if(!(ck[a[i]] || a[i] == a[i - 1] || a[i] == a[i + 1]))
			++cnt;
	}
	//cout << "\n";
	//for(int i = 1; i <= n; ++i){
//
//		if(!(ck[a[i]] || a[i] == a[i - 1] || a[i] == a[i + 1]))
//			cout << a[i] << " ";
//	}
	cout << cnt;
}

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	Read();
	Solve();
}


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

int main(){
  int A, B;
  cin >> A >> B;
  int count = 0;
  for(int i = A; i <= B; i++){
    string s = to_string(A);
    //cout << s << endl;
    if(s[0] == s[4] && s[1] == s[3]){
      count++;
    }
    A++;
  }
  cout << count << endl;
}

Measured memory_bytes: 384