akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxi = 1e18;

int main(){
    int n;
    cin >> n;
    bool zero = false;
    ll ar[n];
    for(int i = 0; i < n; i++){
        ll cur;
        cin >> ar[i];
        if(ar[i] == 0) zero = true;
    }
    if(zero){
        cout << 0 << '\n';
    }else{
        ll sol = 1;
        bool ex = false;
        for(int i = 0; i < n; i++){
            if(ar[i] > maxi/sol){
                cout << -1 << '\n';
                ex = true;
                break;
            }else{
                sol *= ar[i];
            }
        }
        if(!ex) cout << sol << '\n';
    }
}

Measured memory_bytes: 4332
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vi a(N);
    vii G(H, vi(W));
    rep(i, 0, N) cin >> a[i];
    int cur_i = 0;
    rep(r, 0, H){
        if(r % 2 == 0){
            for(int c=0; c<W; c++){
                if(a[cur_i] == 0) cur_i++;
                G[r][c] = (cur_i + 1);
                a[cur_i]--;
            } 
        } else {
            for(int c=W-1; c >= 0; c--){
                if(a[cur_i] == 0) cur_i++;
                G[r][c] = (cur_i + 1);
                a[cur_i]--;
            } 
        }

    }
    rep(i, 0, H){
        rep(j, 0, W){
            cout << G[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}




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

using namespace std;

#define ll long long int
#define MOD 1000000007
#define mt make_tuple
#define eb emplace_back
#define error(args...){string _s = #args; replace(_s.begin(),_s.end(),',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args){cerr<<*it<<" = "<<a<<endl; err(++it,args...);}



int main()
{
	ll n,i,j,k,l;
	cin>>n;
	vector<ll> V;
	for(i=0;i<n;++i)
        cin>>l,V.push_back(l);
    sort(V.begin(),V.end());
    cout<<abs(V[V.size()-1]-V[0]);
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 21:46:51 2018

@author: sk
"""

# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 21:46:51 2018

@author: sk
"""


b =str( input())

a = list(b)



if b[0]==b[1]:
  if b[1]==b[2]:
    print("Yes")
  else :
    print("No")

elif b[1]==b[2]:
  if b[2]==b[3]:
    print("Yes")
  else :
    print("No")
else:
  print("No")













Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k; cin >> k;
  int n = 50;
  cout << n << "\n";
  ll base = k/50;
  ll rem = k%50;
  rep(i, n+1) if(i != n-rem) cout << base+i << " ";
  cout << "\n";
  return 0;
}


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

int main() {
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--, b--, c--, d--;
  bool frag=true;
  vector<bool> S(n, false);
  for (int i=0; i<n; i++) {
    char x; cin>>x;
    if (x=='.') S[i]=true;
  }
  for (int i=a; i<c-1; i++) {
    if (S[i]==S[i+1]&&(!S[i])) frag=false;
  }
  for (int i=b; i<d-1; i++) {
    if (S[i]==S[i+1]&&(!S[i])) frag=false;
  }
  if (c>d) {
    bool tmp=false;
    for (int i=b-1; i<d; i++) {
      if (S[i]&&S[i+1]&&S[i+2]) tmp=true;
    }
    if (!tmp) frag=false;
  }

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

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	ll mi = 1e+10;
	int flag = 1;
	int ans = -1;
	while (flag) {
		rep(i, N) {
			if (A[i] % 2 == 0)A[i] /= 2;
			else {
				flag = 0;
				break;
			}
		}
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N,K; cin>>N>>K;
    vector<ll> a(N,0);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }

    vector<ll> subtotal;
    for (int i = 0; i < N; ++i) {
        ll tmp=a[i];
        subtotal.push_back(tmp);
        for (int j = i+1; j < N; ++j) {
            tmp+=a[j];
            subtotal.push_back(tmp);
        }
    }
    ll ans=0ll;
    for (int i = 39; i >= 0; --i) {
        int cnt=0;
        ll cmp=ans+(1ll<<i);
        for(ll s:subtotal){
            if((s&cmp)==cmp) ++cnt;
        }
        if(cnt>=K) ans=cmp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5620
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline split-ints-into-vector))
(defun split-ints-into-vector (string dest-vector &key (offset 0) (key #'identity))
  (declare (string string)
           (function key)
           ((array * (*)) dest-vector)
           ((integer 0 #.most-positive-fixnum) offset))
  (loop with position = 0
        for idx from offset below (length dest-vector)
        do (setf (values (aref dest-vector idx) position)
                 (parse-integer string :start position :junk-allowed t))
           (setf (aref dest-vector idx) (funcall key (aref dest-vector idx)))
        finally (return dest-vector)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (x (read))
         (xs (make-array n :element-type 'uint32)))
    (split-ints-into-vector (read-line) xs)
    (dotimes (i n)
      (setf (aref xs i) (abs (- (aref xs i) x))))
    (println (reduce #'gcd xs))))

#-swank(main)


Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int x; cin >> x;

  vector<pair<int, int>> v;
  for(int i = -300; i < 300; i++){
    v.push_back({i*i*i*i*i, i});
  }

  for(auto p : v){
    int b = p.first;
    for(auto q : v){
      if(q.first == x + b){
        for(auto y : v){
          if(y.first == x + b){
            cout << y.second << " " << p.second << endl;
            return 0;
          }
        }
        // cout << p.second << " " << p.second << endl;
        // return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3656
#include <cmath>
#include <iostream>
#include <utility>

unsigned long long GetGCD(unsigned long long a, unsigned long long b)
{
    unsigned long long r = 0;
    while(true)
    {
        if(a < b)
        {
            std::swap(a, b);
        }
        r = a % b;
        if(r == 0)
        {
            return b;
        }
        a = b;
        b = r;
    }
}

int main()
{
    unsigned long long a = 0UL;
    std::cin >> a;
    unsigned long long b = 0UL;
    std::cin >> b;
    
    unsigned long long gcd = GetGCD(a, b);
    unsigned long long result = 0UL;
    const long double upperRange = std::ceil(std::sqrt(static_cast<long double>(gcd)));

    for(unsigned long long i = 2; i <= upperRange; ++i)
    {
        if(gcd % i == 0)
        {
            ++result;
            while(gcd % i == 0)
            {
                gcd /= i;
            }
        }
    }
    
    if(gcd != 1)
    {
        ++result;
    }
    
    // 必ず1は約数
    ++result;
    std::cout << result << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps (1e-8)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n,m,l;cin>>n>>m>>l;
    int v[301][301]={0};
    for(int i=1;i<=300;i++)for(int j=1;j<=300;j++)if(i!=j)v[i][j]=1e18;
    
    while(m--){
        int a,b,c;cin>>a>>b>>c;
        v[a][b]=v[b][a]=c;
    }
    
    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)v[i][j]=min(v[i][j],v[i][k]+v[k][j]);
    
    
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
        if(v[i][j]<=l)v[i][j]=1;
        else v[i][j]=1e18;
    }
    
    for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)v[i][j]=min(v[i][j],v[i][k]+v[k][j]);
    
    int q;cin>>q;
    while(q--){
        int a,b;cin>>a>>b;
        cout<<((v[a][b])!=1e18?v[a][b]-1:-1)<<"\n";
    }
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int M=1e9+7;
ll dp[21][1<<21];
int n;
int mat[21][21];
ll calc(int i,int left){
    if(i==n){
        return 1;
    }
    if(dp[i][left]!=-1){
        return dp[i][left];
    }
    ll ans=0;
    for(int j=0;j<n;j++){
        if(mat[i][j]==1){
            int res=1<<j;
            if(left&res){
                ans+=calc(i+1,left^res)%M;  
                ans%=M;
            }
        }
    }
    return dp[i][left]=ans;
}
void solve(){
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>mat[i][j];
        }
    }
    ll sol=calc(0,(1<<21)-1);
    cout<<sol<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 347656
#include<iostream>
#include<vector>
int main() {
	int n;
	int bobp = 0;
	int alicep = 0;
	int maxp = 0;
	int maxn;
	std::cin >> n;
	std::vector<int>array(n);
	for (int i = 0; i < n; i++) {
		std::cin >> array[i];
	}
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < n; i++) {
			if (maxp < array[i]) {
				maxp = array[i];
				maxn = i;
			}
		}
		if (j % 2 == 0) {
			alicep += maxp;
		}
		else {
			bobp +=maxp;
		}
		array[maxn] = 0;
		maxp = 0;
	}
	std::cout << alicep - bobp;
	return 0;
}

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

int dp[501];
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  dp[0] = 1;
  for(int i = 0; i <= 100; i++) if(dp[i]) {
    dp[i+4] = 1;
    dp[i+7] = 1;
  }
  #define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;
  Yes(dp[n])
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <set>
#include <iterator>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int n, m, tmp;
	std::vector<int> a, b;
	std::vector<int> result;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> tmp;
#else
		std::cin >> tmp;
#endif
		a.push_back(tmp);
	}

#if INPUT_FROM_FILE
	ifs >> m;
#else
	std::cin >> m;
#endif
	
	
	for(int i = 0; i < m; i++){
#if INPUT_FROM_FILE
		ifs >> tmp;
#else
		std::cin >> tmp;
#endif
		b.push_back(tmp);
	}

	std::set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(result, result.end()));

	for(int i = 0; i < result.size(); i++){
		std::cout << result[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 6024
N, M=map(int, input().split())
solved=[False]*N
wal=[0]*N
ac=0
wa=0
for _ in range(M):
  p, s=input().split()
  p=int(p)-1
  if solved[p]:
    continue
  if s=="AC":
    solved[p]=True
    ac+=1
    wa+=wal[p]
  else:
    wal[p]+=1
print(ac, wa)  

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

ll n,ans,  kac[N];
char s[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("outt.txt", "w", stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(ll i = 1; i <= n; i++){
		if(s[i] == 'A')
			kac[i] = kac[i - 1] + 1;
		else
			kac[i] = 0;
		if(s[i] == 'C' and s[i - 1] == 'B'){
			// cout << i << " " << kac[i - 2] << endl;
			ans += kac[i - 2];
			kac[i] = kac[i - 2];
		}
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

const ll maxn = 100 * 1000 + 218;

struct TEdge {
  ll a;
  ll b;
  ll w;
  TEdge() {}
  TEdge(ll a, ll b, ll w):
    a(a),
    b(b),
    w(w)
  {
  }

  void Load() {
    cin >> a >> b >> w;
    a--;
    b--;
  }

  bool operator <(const TEdge& other) const {
    return w < other.w;
  }
};

ll n, m;
ll x[maxn];

ll parent[maxn];
ll weight[maxn];

ll GetRoot(ll v) {
  if (v == parent[v]) return v;
  ll w = GetRoot(parent[v]);
  parent[v] = w;
  return w;
}

ll GetWeight(ll v) {
  ll root = GetRoot(v);
  return weight[root];
}

void Merge(ll v1, ll v2) {
  if (rand() % 2) {
    swap(v1, v2);
  }
  v1 = GetRoot(v1);
  v2 = GetRoot(v2);
  if (v1 == v2) return;
  parent[v2] = v1;
  weight[v1] += weight[v2];
}

bool visited[maxn];

void DFS(ll v, ll maxW, const vector<vector<pair<ll, ll>>>& g, const vector<TEdge>& e, vector<bool>& used) {
  //cerr << "v, maxW = " << v << " "<< maxW << endl;
  if (visited[v]) return;
  visited[v] = true;
  for (auto p : g[v]) {
    ll to = p.first;
    ll id = p.second;
    ll w = e[id].w;
    //cerr << " cur w, id = " << w << " " << id << " " << used[id] << endl;
    if (w > maxW) continue;
    used[id] = true;
    DFS(to, maxW, g, e, used);
  }
}

int main()
{
  cin >> n >> m;
  for (ll i = 0; i < n; ++i) cin >> x[i];
  vector<TEdge> e(m);
  for (ll i = 0; i < m; ++i) e[i].Load();

  sort(e.begin(), e.end());
  for (ll i = 0; i < n; ++i) {
    parent[i] = i;
    weight[i] = x[i];
  }

  vector<bool> valid(m);

  for (ll i = 0; i < m; ++i) {
    Merge(e[i].a, e[i].b);
    //prllf("e[i].w, componentWeight = %d %d\n", e[i].w, GetWeight(e[i].a));
    if (e[i].w <= GetWeight(e[i].a)) {
      valid[i] = true;
    }
  }

  //cerr << "Valid:\n";
  //cerr << endl; for (ll i = 0; i < m; ++i) if (valid[i]) cerr << e[i].a << " " << e[i].b << " " << e[i].w << endl;

  vector<vector<pair<ll, ll>>> g(n);
  for (ll i = 0; i < m; ++i) {
    g[e[i].a].push_back({e[i].b, i});
    g[e[i].b].push_back({e[i].a, i});
  }

  vector<bool> used(m);
  
  for (ll i = m; i >= 0; --i) {
    if (!valid[i]) continue;
    //cerr << "DFS!\n";
    DFS(e[i].a, e[i].w, g, e, used);
  }

  //cerr << "Done\n";

  ll result = 0;
  for (ll i = 0; i < m; ++i) if (!used[i]) result++;

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 18304
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x;
  cin >> x;
  if(x<1200) cout << "ABC" << endl;
  else if(x<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

ll n;
vector<ll> adj[N];

ll dp0[N];  // for white node
ll dp1[N];  // for black node

void dfs(ll v,ll p)
{
    dp0[v]=1;
    dp1[v]=1;
    for(auto u:adj[v])
    {
        if(u==p){continue;}
        dfs(u,v);
        dp0[v]=(dp0[v]*(dp0[u]+dp1[u])%M)%M;
        dp1[v]=(dp1[v]*dp0[u])%M;
    }
}

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

    cin>>n;
    for(ll i=0;i<n-1;++i)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dfs(1,0);

    ll ans=(dp0[1]+dp1[1])%M;

    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;

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

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

    int r = 1 << 30;
    for (int i = 0; i < n - k + 1; i++) {
        int t = h[i + k - 1] - h[i];
        r = min(r, t);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, 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(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    cin>>N;
    vector< pair<ll, ll> > A, B, Asur, Bsur;
    ll a, b;
    vector< pair<bool, ll> > se;
    rep(i, N) cin>>a>>b, A.push_back({a, i}),B.push_back({b, i});
    rep(i, N){
        Asur.push_back({A[i].first+B[i].first, i});
        Bsur.push_back({B[i].first+A[i].first, i});
        se.push_back({false, i});
    }
    sort(all(Asur));
    sort(all(Bsur));
    ll anum=N-1, bnum=N-1;
    ll asum=0, bsum=0;
    rep(i, N){
        if(i%2==0){
            while(se[Asur[anum].second].first) anum--;
            asum+=A[Asur[anum].second].first;
            se[Asur[anum].second].first=true;
        }
        if(i%2!=0){
            while(se[Bsur[bnum].second].first) bnum--;
            bsum+=B[Bsur[bnum].second].first;
            se[Bsur[bnum].second].first=true;
        }
        //cout<<asum<<sp<<bsum<<endl;
    }
    cout<<asum-bsum<<endl;
    return 0;
}


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

int main() {
	long long q,h,s,d,n;
	scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
	long long oo=min(q*4,min(h*2,s)), ot=min(oo*2,d);
	long long ans=n/2*ot;
	if (n%2==1) ans+=oo;
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 2e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

void work()
{
    int n;
    cin >> n;
    n /= 1000;
    printf("AB%c\n", 'C' + n);
}

//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
//#define LOCAL
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<random>
using namespace std;
using lld = long long int;
using llu = unsigned long long int;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using pll = pair<lld, lld>;
using piii = pair<pii, pii>;
using pdii = pair<int, pii>;
lld a, b, n;
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	while (t--) {
		scanf("%lld %lld %lld", &a, &b, &n);
		lld x;
		if (b <= n) {
			x = b - 1;
		}
		else {
			x = n;
		}
		printf("%lld\n", (a * x) / b);
	}
}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstdint>
using namespace std;

int main()
{
  uint64_t n;

  cin >> n;
  vector<uint64_t> vec;
  vec.resize(n);
  uint64_t f = 0;
  uint64_t l = 0;
  cin >> vec[0];
  for (uint64_t i = 1; i < n; ++i) {
    cin >> vec[i];
    if (vec[i-1] > vec[i] + l) {
      uint64_t a = vec[i-1] - vec[i] - l;
      f = (i & 1) ? f + a : f - a;
      l = l + a;
    }
    l = vec[i-1] - l;
  }
  f += (vec[n-1] - l - f) / 2;
  cout << 2 * f << " ";
  l = f;
  for (uint64_t i = 1; i < n; ++i) {
    cout << 2 * (vec[i-1] - l) << " ";
    l = vec[i-1] - l;
  }

  return 0;
}





Measured memory_bytes: 2048
X, Y, A, B, C = map(int, input().split())
P = sorted([int(i) for i in input().split()], reverse=True)
Q = sorted([int(i) for i in input().split()], reverse=True)
R = sorted([int(i) for i in input().split()])

S = sorted(P[:X]+Q[:Y]+R, reverse=True)

print(sum(S[:X+Y]))


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

using namespace std;
typedef long long ll;

int r;
string s;
vector <char> bv[2];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> s;
    int Q; cin >> Q;

    r = 0;
    for (int q = 0; q < Q; q++)
    {
        int t; cin >> t;
        if (t == 1)
        {
            r = 1 - r;
        }
        else
        {
            int x; char c;
            cin >> x >> c;
            if (x == 1)
                bv[r].push_back(c);
            else
                bv[1-r].push_back(c);
        }
    }

    vector <char> v;
    for (int i = (int) bv[0].size() - 1; i >= 0; i--)
        v.push_back(bv[0][i]);
    for (int i = 0; i < s.length(); i++)
        v.push_back(s[i]);
    for (int i = 0; i < bv[1].size(); i++)
        v.push_back(bv[1][i]);
    if (r) reverse (v.begin(), v.end());

    for (char c : v) cout << c;
    cout << "\n";
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> x(N);
  for (int i=0; i<N; i++) cin >> x[i];
  vector<ll> res;
  for (int l=0; l<N-K+1; l++) {
    int r = l+K-1;
    ll num1 = abs(x[l])+abs(x[r]-x[l]), num2 = abs(x[r])+abs(x[r]-x[l]);
    res.push_back(min(num1, num2));
  }
  sort(res.begin(), res.end());
  cout << res[0] << endl;
  return 0;
}

Measured memory_bytes: 1660
N = int(input())
v = list(map(int, input().split()))

from collections import defaultdict

even = [[0,i] for i in range(10**5+1)]
odd = [[0,i] for i in range(10**5+1)]

for i in range(N//2):
    j = 2*i
    k = 2*i + 1
    even[v[j]][0] += 1
    odd[v[k]][0] += 1

even_sorted = sorted(even, key=lambda x:x[0], reverse = True)
odd_sorted = sorted(odd, key=lambda x:x[0], reverse = True)

if even_sorted[0][1] != odd_sorted[0][1]:
    print(N - even_sorted[0][0] - odd_sorted[0][0])
else:
    print(min(N - even_sorted[0][0] - odd_sorted[1][0], N - odd_sorted[0][0] - even_sorted[1][0]))

Measured memory_bytes: 78828
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int N = sc.nextInt();
      
      	switch(N%10){
          case 2:
          case 4:
          case 5:
          case 7:
          case 9:
            System.out.println("hon");
            break;
          
          case 0:
          case 1:
          case 6:
          case 8:
            System.out.println("pon");
            break;
            
          case 3:
            System.out.println("bon");
            break;  
      		
        }
	}
}

Measured memory_bytes: 27028
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct BiMatch{
  int n,time;
  vector<vector<int>> G;
  vector<int> match,used,dead;

  BiMatch(){}
  BiMatch(int n):n(n),time(0),G(n),
                 match(n,-1),used(n,-1),dead(n,0){}

  void add_edge(int u,int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  int dfs(int v){
    used[v] = time;
    for(int u:G[v]){
      if(dead[u]) continue;
      int w=match[u];
      if((w<0) || (used[w]<time && !dead[w] && dfs(w))){
        match[v]=u;
        match[u]=v;
        return 1;
      }
    }
    return 0;
  }

  int build(){
    int res=0;
    for(int v=0;v<n;v++){
      if(dead[v]) continue;
      if(match[v]<0){
        time++;
        res+=dfs(v);
      }
    }
    return res;
  }

  int disable(int v){
    assert(!dead[v]);
    int u=match[v];
    if(~u) match[u]=-1;
    match[v]=-1;
    dead[v]=1;
    time++;
    return ~u?dfs(u)-1:0;
  }

  int enable(int v){
    assert(dead[v]);
    dead[v]=0;
    time++;
    return dfs(v);
  }
};
//END CUT HERE

signed GRL_7_A(){
  int X,Y,E;
  cin>>X>>Y>>E;
  BiMatch bm(X+Y);
  for(int i=0;i<E;i++){
    int x,y;
    cin>>x>>y;
    bm.add_edge(x,X+y);
  }
  cout<<bm.build()<<endl;
  return 0;
}
/*
  verified on 2019/06/16
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp
*/

signed main(){
  GRL_7_A();
  return 0;
}



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n;
    cin >> n;
    vector<int> add;
    vector<int> sub;

    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        add.pb(x + y);
        sub.pb(x - y);
    }
    sort(all(add));
    sort(all(sub));

    cout << max(add[n - 1] - add[0], sub[n - 1] - sub[0]) << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int w[n];
    int pref[n];
    cin >> w[0];
    pref[0]=w[0];
    for(int i=1;i<n;i++)
    {
        cin >> w[i];
        pref[i]=pref[i-1]+w[i];
    }
    int mabs=1<<30;
    for(int i=0;i<n-1;i++)
    {
        mabs=min(mabs,abs(pref[i]-(pref[n-1]-pref[i])));
    }
    cout << mabs;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll N;
ll c[15][15];//0から9
int main(){
    cin>>N;
    rep(i,0,10){
        rep(j,0,10){
            c[i][j]=0;//初期化
        }
    }
    
    rep(i,1,N+1){
        string s=to_string(i);
        c[s[0]-'0'][(s[s.length()-1])-'0']+=1;
    }
    ll ans=0;
    rep(i,0,10){
        rep(j,0,10){
            ans+=c[i][j]*c[j][i];
        }
    }
    puts(ans);
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/joi2012yo/tasks/joi2012yo_e

from collections import deque


class Point:
    def __init__(self):
        super().__init__()
        self.up = 1
        self.down = 1
        self.left = 1
        self.right = 1


def solve(W, H):
    Points = {}
    for i in range(H):
        for j in range(W):
            point = Point()
            Points[(i, j)] = point

    for i in range(H * 2 - 1):
        if i % 2 == 0:
            # | | | vertical
            walls = list(map(int, input().split()))
            for j, wall in enumerate(walls):
                Points[(i//2, j)].right = wall
                Points[(i//2, j + 1)].left = wall
        else:
            # - - - horizontal
            walls = list(map(int, input().split()))
            for j, wall in enumerate(walls):
                Points[(i//2, j)].down = wall
                Points[(i//2 + 1, j)].up = wall

    queue = deque()
    queue.appendleft((0, 0, 1))
    checked = set()
    goal = (H-1, W-1)

    result = 0
    while queue:
        # print(queue)
        i, j, d = queue.pop()
        if (i, j) in checked:
            continue
        checked.add((i, j))

        if (i, j) == goal:
            result = d
            break

        point = Points[(i, j)]
        tmp_d = d+1
        if point.up == 0:
            queue.appendleft((i-1, j, tmp_d))
        if point.down == 0:
            queue.appendleft((i+1, j, tmp_d))
        if point.left == 0:
            queue.appendleft((i, j-1, tmp_d))
        if point.right == 0:
            queue.appendleft((i, j+1, tmp_d))

    print(result)


if __name__ == "__main__":
    while True:
        W, H = map(int, input().split())
        if W == 0 and H == 0:
            break

        solve(W, H)



Measured memory_bytes: 6356
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    ll n,m;
    cin >> n;
    map<string,ll> s,t;
    rep(i,n){
        string p;
        cin >> p;
        s[p]++;
    }
    cin >> m;
    rep(i,m){
        string q;
        cin >> q;
        t[q]++;
    }
    ll ans=0;
    for(auto x:s){
        ans=max(ans,x.se-t[x.fi]);
    }
    cout << ans << endl;
} 


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc106/tasks/abc106_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 A*B-A-B+1でほい
 ================================================================
 */

ll solveA(){
    ll res = 0;
    ll A,B; cin >> A >> B;
    res = A*B - A - B + 1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solveA() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] data = S.toCharArray();
        int[] sum = new int[N+1];
        Arrays.fill(sum, 0);
        int answer = Integer.MAX_VALUE;
        boolean badfound = false;
        int whitecount = 0;
        boolean blackfound = false;
        for (int i = 0; i < N; i++) {
            if (blackfound && data[i] == '.') {
                whitecount += 1;
            }
            if (i < N - 1 && data[i] == '#' && data[i+1] == '.') {
                badfound = true;
            }
            if (data[i] == '#') {
                blackfound = true;
                sum[i+1] += sum[i] + 1;
                continue;
            }
            sum[i+1] += sum[i];
        }
        if (badfound) {
            for (int i = 0; i < N; i++) {
                answer = Math.min(sub(N, sum, i + 1), answer);
            }
            answer = Math.min(whitecount, answer);
        } else {
            answer = 0;
        }
        System.out.println(answer);
    }
    public static int sub(int N, int[] sum, int from) {
        int blackcount_before_from = sum[from];
        int whitecount_before_from = from - sum[from];
        int whitecount_after_from = N - sum[N] - whitecount_before_from;
        return blackcount_before_from + whitecount_after_from;
    }
}


Measured memory_bytes: 28712
# ABC 156 C

N = int(input())
X = [int(j) for j in input().split()]
X = sorted(X)
m = N * (100**2)
for i in range(min(X),max(X)+1):
    tmp = sum([(x-i) ** 2 for x in X])
    if tmp < m:
        m = tmp
print(m)

Measured memory_bytes: 2940
#include <stdio.h>

int main() {
	int a, b, t;
	scanf("%d %d %d", &a, &b, &t);
	int i = 1, cont = a, soma = 0;
	while(cont <= t){
		cont = a*i;
		soma = b*(i-1);
		i++;
	}
	printf("%d\n", soma);


	return 0;
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		A = new int[N];
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(strArr[i]);
		}
		cnt++;
	}

	int[] A;

	public void solve() {
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < N; i++) {
			if (A[i] < min)
				min = A[i];
			if (A[i] > max)
				max = A[i];
		}
		System.out.println(max - min);
	}
}


Measured memory_bytes: 21204
#include<stdio.h>
long long int pwo(long long int x,long long int y)
{
    long long int i,a,mod = 1000000000 + 7;
    a = x;
    if(y == 0)
    {
        return 1;
    }
    for(i = 1 ; i < y ; i++)
    {
        x = x*a;
        x = x % mod;
    }
    return x;
}
int main(void)
{
    long long int n,i,j,mod = 1000000000 + 7,sum = 0;
    scanf("%lld",&n);
    sum = pwo(10,n) % mod - 2 * pwo(9,n) % mod + pwo(8,n) % mod;
    sum %= mod;
    
    while(sum < 0)
    {
        sum+= mod;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <array>
//#include <fstream>
  
int main(){
    const int max_sum = 20;
    const int min_sum = 0;
    const int max_number = 100;
    int N;
    //std::ifstream ifs("517.txt");
      
    while(std::cin >> N){
        //数列を保存
        std::array<int, max_number> numbers;
        //count[i][j]:i番目までの計算でjを作ることのできるパターンを保存
        std::array<std::array<long long int, max_sum + 1>, max_number> count;
        
        for(int i = 0; i < max_number; ++i){
            count[i].fill(0);
        }
        for(int i = 0; i < N; ++i){
            //ifs >> numbers[i];
            std::cin >> numbers[i];
        }
          
        count[0][numbers[0]] = 1;
        for(int i = 1; i < N; ++i){
            for(int j = 0; j <= max_sum; ++j){
                if(j + numbers[i] <= max_sum){
                    count[i][j + numbers[i]] += count[i - 1][j];
                }
                if(j - numbers[i] >= min_sum){
                    count[i][j - numbers[i]] += count[i - 1][j];
                }
            }
        }
        std::cout << count[N - 2][numbers[N - 1]] << std::endl;
    }
      
    //ifs.close();
    return 0;
}

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

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; ++i) cin >> a[i];
  vector<int> broken(N + 1, 0);
  for (auto b : a) {
    broken[b] = true;
  }
  vector<int> dp(N + 1, 0);
  dp[0] = 1;

  constexpr int mod = 1000000007;

  for (int i = 0; i < N; ++i) {
    if (!broken[i + 1]) {
      dp[i + 1] += dp[i];
      dp[i + 1] %= mod;
    }
    if (i + 2 <= N && !broken[i + 2]) {
      dp[i + 2] += dp[i];
      dp[i + 2] %= mod;
    }
  }

  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 4316
N = int(input())
A = [int(i) for i in input().split()]
A.append(0)
total = abs(A[0])
for i in range(N):
    total += abs(A[i + 1] - A[i])

for i in range(N):
    dif = 0
    if i == 0:
        dif = abs(A[1] - A[0]) + abs(A[0]) - abs(A[1])
    else:
        dif = abs(A[i + 1] - A[i]) + abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i - 1])
    print(total - dif)


Measured memory_bytes: 14048
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

ll absll(ll a){
    if(a > 0) return a;
    else return -1*a;
}
int main() {

    ll n; cin >> n;
    ll ans = MAX;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];

    vector<ll> s(n+1,0);
    rep(i,n) s[i+1] = s[i] + v[i];

    for(ll i = 1; i < n; i ++){
        ans = min(ans,absll((s[n]-s[i])-s[i]));
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 6360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lesson0401
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            double sideA = double.Parse(s[0]);
            double sideB = double.Parse(s[1]);
            double C = double.Parse(s[2]);

            //????????¢????§??????????
            // ?§???????* ??/180
            double radianC = C * Math.PI / 180;
            //sinC = h/sideB
            //   h = sinC * sideB
            double h = Math.Sin(radianC) * sideB;
            //??¢??? S = 1/2 * a * b* sinC
            double S = 0.5 * sideA * sideB * Math.Sin(radianC);
            //???????????????c^2 = a^2 + b^2 -2 * a * b * cosC 
            double sideC = Math.Sqrt(Math.Pow(sideA, 2) + Math.Pow(sideB, 2) - 2 * sideA * sideB * Math.Cos(radianC));
            //????????????????¶????
            double L = sideA + sideB + sideC;

            Console.WriteLine("{0,1:f4}",S);
            Console.WriteLine("{0,1:f4}",L);
            Console.WriteLine("{0,1:f4}",h);
            
        }
    }
}

Measured memory_bytes: 9452
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

int main()
{
	string str;
	ll p[12];
	p[0]=1;
	for(int i=1; i<12; i++){
		p[i]=p[i-1]*10;
	}
	for(int i=1; i<=11; i++){
		int d1=0, d2=9;
		while(d1!=d2){
			int mid=(d1+d2+1)/2;
			string str1=str+to_string(mid);
			printf("? %lld\n", stoll(str1));
			fflush(stdout);
			char c;
			scanf(" %c", &c);
			if(c=='Y'){
				d1=mid;
			}else{
				d2=mid-1;
			}
		}
		if(i>1 && d1==9){
			ll x=stoll(str);
			if(x!=p[i-2]){
				string str1=to_string(x-1);
				str1+="90";
				printf("? %lld\n", stoll(str1));
				fflush(stdout);
			}else{
				printf("? %lld\n", 10000000000);
				fflush(stdout);
				char c1;
				scanf(" %c", &c1);
				if(c1=='Y'){
					printf("! %lld\n", p[i-1]);
					fflush(stdout);
					return 0;
				}else{
					printf("? %lld\n", p[i]);
					fflush(stdout);
				}
			}
			char c;
			scanf(" %c", &c);
			if(c=='N'){
				int e1=0, e2=9;
				while(e1!=e2){
					int emid=(e1+e2)/2;
					string str2=str+to_string(emid);
					str2+='0';
					printf("? %lld\n", stoll(str2));
					fflush(stdout);
					char c;
					scanf(" %c", &c);
					if(c=='Y'){
						e2=emid;
					}else{
						e1=emid+1;
					}
				}
				str+=to_string(e1);
				printf("! %lld\n", stoll(str));
				fflush(stdout);
				return 0;
			}else{
				str+='9';
			}
		}else if(i==1 && d1==9){
			printf("? %d\n", 10);
			fflush(stdout);
			char c;
			scanf(" %c", &c);
			if(c=='N'){
				int e1=1, e2=9;
				while(e1!=e2){
					int emid=(e1+e2)/2;
					string str2=to_string(emid);
					str2+='0';
					printf("? %lld\n", stoll(str2));
					fflush(stdout);
					char c;
					scanf(" %c", &c);
					if(c=='Y'){
						e2=emid;
					}else{
						e1=emid+1;
					}
				}
				str+=to_string(e1);
				printf("! %lld\n", stoll(str));
				fflush(stdout);
				return 0;
			}else{
				printf("? %lld\n", 10000000000);
				fflush(stdout);
				char c;
				scanf(" %c", &c);
				if(c=='Y'){
					printf("! %d\n", 1);
					fflush(stdout);
					return 0;
				}else{
					str+='9';
				}
			}
		}else{
			str+=to_string(d1);
		}
	}
	return 0;
}

Measured memory_bytes: 692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			while (n-- != 0)
			{
				var xyr = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
				double xa = xyr[0], ya = xyr[1], ra = xyr[2], xb = xyr[3], yb = xyr[4], rb = xyr[5];
				double d = ((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
				double sr = ((ra + rb) * (ra + rb));
				double dr = ((ra - rb) * (ra - rb));
				Console.WriteLine((d > sr) ? 0 : (d < sr && dr < d) ? 1 : (dr > d) ? ((ra > rb) ? 2 : -2) : 1);
			}
		}
	}
}

Measured memory_bytes: 6024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size()-1) == b.at(0) && b.at(b.size()-1)==c.at(0) ) { cout << "YES" << endl; }
  else { cout << "NO" << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


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

 double t=1900*m+100*(n-m);
 double  wa=1-(1/pow(2,m));
 double  ca=1/pow(2,m); 
 double res=0;

  //cout<<"正解の確率:"<<ca<<" 不正解の確率:"<<wa<<endl;

FOR(i,1,1000000){
  
  if(i==1)res+=t*ca;
  else{
  //cout<<res<<"に"<<t*i*pow(wa,i-1)*ca<<"を足す"<<endl;
  //cout<<t*i<<"秒かかる確率が"<<pow(wa,i-1)*ca<<endl;
  res+=t*i*pow(wa,i-1)*ca;
  
  }
   //cout<<res<<endl;
}
  cout<<res<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"


  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	char a;
	cin >> a;
	if(islower(a)){
		cout << "a";
	}
	else{
		cout << "A";
	}
	
	
}


Measured memory_bytes: 3632