akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  1000000007
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, ans = 0, sum = 0 ; cin >> n ; 
    map <int,int> cnt;
    cnt[0]=1; 
    while (n--){
    	int a; cin >> a; 
    	sum += a;
    	ans += cnt[sum];
    	cnt[sum]++;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main()
{
    int $=1;
    //cin>>$;
    while($--)
    {
        long long kk,a=0;
        cin>>kk;
        for(int i=1;i<=kk;i++)
        {
            for(int j=1;j<=kk;j++)
            {
                for(int k=1;k<=kk;k++)
                {
                    int m=__gcd(i,j);
                    a+=__gcd(m,k);
                }
            }
        }
        cout<<a<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int n;
    int a[100001];
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        int c=a[n-1];
        int t=c/2;
        int m=1000000000;
        int s;
        for(int i=0;i<n-1;i++)
            if(abs(a[i]-t)<=m)
            {
                m=abs(a[i]-t);
                s=a[i];
            }
        cout<<c<<" "<<s<<endl;
    }
}


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

using namespace std;

#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define pii pair < ll, ll >
#define ok puts("ok");

const int N = (int)1e5 + 6;
const int inf = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector < pii > gr[N];
vector < pair < pii, ll > > edge;
ll shdist;
ll d1[N], d2[N], dp1[N], dp2[N], dp[N];
int n, m;
ll ans = 0;

void dijkstra(int s, int t, int id) {
  vector < ll > d(n + 1, linf);
  memset(dp, 0, sizeof(dp));
  set < pii > q;
  q.insert(mk(0, s));
  d[s] = 0;
  dp[s] = 1;
  while (!q.empty()) {
    pii v = *q.begin();
    q.erase(q.begin());
    for (auto to : gr[v.sc]) {
      if (d[v.sc] + to.sc < d[to.fr]) {
        q.erase(mk(d[to.fr], to.fr));
        d[to.fr] = d[v.sc] + to.sc;
        dp[to.fr] = dp[v.sc];
        q.insert(mk(d[to.fr], to.fr));
      } else if (d[v.sc] + to.sc == d[to.fr]) {
        dp[to.fr] += dp[v.sc];
        dp[to.fr] %= inf;
      }
    }
  }
  if (id == 1) {
    for (int i = 1; i <= n; i++) {
      d1[i] = d[i];
      dp1[i] = dp[i];
    }
  } else {
     for (int i = 1; i <= n; i++) {
      d2[i] = d[i];
      dp2[i] = dp[i];
     }
  }
}

ll sqr (ll x) {
  return x * x % inf;
}

ll sub (ll a, ll b) {
  return (a - b + inf) % inf;
}

main () {
  scanf("%d %d", &n, &m);
  int s, t; scanf("%d %d", &s, &t);
  for (int i = 1; i <= m; i++) {
    ll u, v, w; scanf("%lld %lld %lld", &u, &v, &w);
    gr[u].pb(mk(v, w));
    gr[v].pb(mk(u, w));
    edge.pb(mk(mk(u, v), w));
  }
  dijkstra(s, t, 1);
  shdist = d1[t];
  dijkstra(t, s, 2);
  ans = (dp1[t] * dp1[t]) % inf;
  for (int i = 1; i <= n; i++) {
    if (d1[i] == d2[i] && d1[i] + d2[i] == shdist) {
      ans -= (sqr(dp1[i]) * sqr(dp2[i])) % inf;
    }
  }
  for (auto ed : edge) {
    int x = ed.fr.fr, y = ed.fr.sc;
		ll c = ed.sc;
		if(d1[x] > d1[y])
			swap(x, y);
		if(d1[x] + d2[y] + c == d1[t] && ((d1[x] <= d2[y] && d1[x] + c > d2[y]) || (d1[x] > d2[y] && d2[y] + c > d1[x]))){
			ans = sub(ans, (sqr(dp1[x]) * sqr(dp2[y]) % inf));
		}
  }
  printf("%lld", ans % inf);
}


Measured memory_bytes: 28292
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int X;
  int Y;
  int Z;
  cin>>X;
  cin>>Y;
  cin>>Z;
  swap(X,Y);
  swap(X,Z);
  cout<<X;
  cout<<" ";
  cout<<Y;
  cout<<" ";
  cout<<Z;
}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main()
{
  long int k,n,max=0;
  cin>>k>>n;
  long int a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  for(int i=0;i<n-1;i++)
  {
      if(a[i+1]-a[i]>max)
        max=a[i+1]-a[i];
  }
  if(k-a[n-1]+a[0]>max)
    max=k-a[n-1]+a[0];
  cout<<k-max;
  return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
def main():
    import numpy
    N = int(input())
    P =[int(i) for i in input().split()]
    #print(P)
    count = 0
    for i in range(1,N-1):
        tmp = [P[i-1],P[i],P[i+1]]
        #print(tmp)
        PP=numpy.array(tmp)
        #print(PP)
        PPI = PP.argsort()
        #print(PPI)
        if PPI[1] == 1:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18540
import sys
from pprint import pprint

import math

d, g = map(int, sys.stdin.readline().strip().split(" "))

p = []
c = []
for _ in range(d):
    p_i, c_i = map(int, sys.stdin.readline().strip().split(" "))
    p.append(p_i)
    c.append(c_i)

ans = 10 ** 9
for i in range(2**d):
    use = [0] * d
    for j in range(d):
        if ((i >> j) & 1):
            use[d - 1 - j] = 1
    # pprint(use)
    score = 0
    tmp_ans = 0
    max_i = -1
    for i, use_i in enumerate(use):
        if use_i:
            tmp_ans += p[i]
            score += p[i] * (i+1) * 100 + c[i]
        else:
            max_i = i
    # print("tmp_ans: ", tmp_ans, " score:", score, " max_i:", max_i)
    if score < g  and max_i > -1:
        num = math.ceil((g - score) / ((max_i+1) * 100))
        # print("num:", num)
        if num < p[max_i]:
            tmp_ans += num
            score += num * ((max_i+1) * 100)
    # print(tmp_ans, score)
    if score >= g:
        ans = min(ans, tmp_ans)
        
print(ans)

Measured memory_bytes: 41456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int main()
{
	int n=read(),D=read();
	cout<<(n+2*D)/(2*D+1)<<endl;
	return 0;
}


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

using namespace std;

int N;

void dfs(string str, char maxchar){ 
  int length = str.size();
  if (length == N){
    cout << str << endl;  
  }else{
    for(char c='a'; c<=(char)(maxchar+1); c++){
      dfs(str+c, max(c, maxchar));  
    }
  }
}

int main(){
  cin >> N;
  dfs("a", 'a');
  return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner Sc =new Scanner(System.in);
        int a = Sc.nextInt();
        int b = Sc.nextInt();
        int c = Sc.nextInt();

        if(a < b && b < c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
const int N = 3*1e3;
string s, t;
int dp[N][N];
int f(unsigned int i, unsigned int j){
    if( i == s.size() || j == t.size() )
        return 0;
    if( dp[i][j] != -1 )
        return dp[i][j];
    if( s[i] == t[j] )
        return dp[i][j] = f(i+1, j+1) + 1;
    return dp[i][j] = max(f(i+1, j), f(i, j+1));
}
void p(unsigned int i, unsigned int j){
    if( i == s.size() || j == t.size());
    else
    if( s[i] == t[j] ){
        cout << s[i];
        p(i+1, j+1);
    }
    else
    if( dp[i+1][j] > dp[i][j+1] )
        p(i+1, j);
    else
        p(i, j+1);
}
int main() {
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    f(0, 0);
    p(0, 0);
    return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    string s; cin >> s;
    vector<string> word = {"dream","dreamer","erase","eraser"};
    
    queue<int> que;
    que.push(0);
    vector<bool> ok(100005,false);
    bool ans = false;
    ok.at(0) = true;
    while(!que.empty()){
        int v = que.front();
        if(v == s.size()){
             ans = true;
             break;
        }
        que.pop();

        for(string wo : word){
            if(ok.at(v+wo.size())) continue;

            if(wo == s.substr(v , wo.size())){
                 que.push(v+wo.size());
            }
        }
    }
    ans ? cyes : cno;
    return 0;   
}


Measured memory_bytes: 512
use std::io::{stdout, Write, BufWriter};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: i64,
        w: i64,
    }
    if h == 1 || w == 1 {
        println!("1");
    } else {
        println!("{}", h * (w / 2) +  ((h + 1) / 2) * (w % 2));
    }
}


Measured memory_bytes: 4352
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut d = get!([usize]);
    d.sort();
    println!("{}", d[n/2] - d[n/2-1]);
}


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c;
 cin >> a >> b>> c;
 if(a==b&&b==c){
   cout << 1<< endl;
 }
 if((a==b&&b!=c)||(a==c&&b!=c)||(b==c&&c!=a)){
   cout << 2 << endl;
 }
 if(a!=b&&b!=c&&a!=c){
   cout << 3<< endl;
 }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	bool flag = true;
	rep(i, sz(s)) {
		if (s[i] != t[i]) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,g,h,w,num,sum,ans;
ll x[500005];//y[500005],z[500005];
bool ok[500005];
//ll l[500005],r[500005];
int dp[100005][505];
//char s[500005],t[500005];

ll dfs(ll v,ll p,ll cost){
    ll num = -INF;
    for(int i=0;i<G[v].size();i++){
        
        num = max(num,dfs(G[v][i],v,cost));
    }
    if(num == -INF){
        return 1;
    }
    num ++;
    if(num == k){
        if(ok[v]){
            return 0;
        }
        ans++;
       // p(v);
        return -INF;
    }else{
        return num;
    }
}



int main(){
    cin >> n >> k;
    if(k >= n){
        cin >> a;
        if(a == 1){
            p(0);
        }else{
            p(1);
        }
        return 0;
    }else if(k == 1){
        for(i =0;i<n;i++){
            cin >> a;
            if(a != 1)ans++;
        }
        p(ans);
    }else{
        for(i=0;i<n;i++){
            cin >> x[i];
        }
        if(x[0] != 1){
            ans++;
            x[0] = 1;
        }
        for(i=1;i<n;i++){
            G[x[i]].pb(i+1);
            if(x[i] == 1){
                ok[i+1] = 1;
            }
        }
        ok[1] = 1;
        a = dfs(1,-1,0);
        p(ans);
    }
    return 0;
}






Measured memory_bytes: 36096
program main

  implicit none
  
  character(10) ::  s

  read(*,*) s
  
  if ( s == "hi" .or. s == "hihi" .or. s == "hihihi" &
     & .or. s == "hihihihi" .or. s == "hihihihihi" ) then
    print*, "Yes"
  else
    print*, "No"
  end if

end program main


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

const int MAXN = 1e5+10;
int a[MAXN];
ll dp[MAXN];
int n;

ll solve(int i){
    if(i == n-1) return 0;
    ll &r = dp[i];
    if(r != 1e16+10) return r;
    if(i+1<n){
        r = min(r, abs(a[i]-a[i+1])+solve(i+1));
    }
    if(i+2<n){
        r = min(r, abs(a[i]-a[i+2])+solve(i+2));
    }

    return r;
}

int main() {FIN;
    cin>>n;
    fore(i,0,n){
        cin>>a[i];
        dp[i] = 1e16+10;
    }
    cout<<solve(0)<<"\n";
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  ll ans = 0;
  rep(i,n){
    ans += a[i]/2;
    if(a[i]%2 && i < n-1){
      if(a[i+1] != 0){
        ans++;
        a[i+1]--;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N;
  vl X(N);rep(i,N)cin>>X[i];
  vl Y(N);
  rep(i,N){
    Y[i]=X[i];
  }
                       
  sort(all(X));ll left=X[N/2],right =X[N/2-1];
  for(ll i=0;i<N;i++){
    if(Y[i]<=right)cout<<left<<endl;
    else if(Y[i]>=left)cout<<right<<endl;
    
  }
  
 
}


Measured memory_bytes: 5376
while 1:
    try:
        n,r = map(int,raw_input().split())
        cs = map(int,(raw_input()+" 0").split())
    except:
        break
    C = range(n)
    A,B,C = C[n/2:],C[:n/2],[]
    for i in range(r):
        c = cs[i]
        while A or B:
            C += A[:c] + B[:c]
            A,B = A[c:],B[c:]
        A,B,C = C[n/2:],C[:n/2],[]
    print A[-1]

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	fast();
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes\n";
	}  else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3636
n = int(input())
h = list(map(int,input().split()))

ans = 0
for i in range(max(h)):
    c = 0
    for j in range(n):
        if h[j] != 0:
            h[j] -= 1
            c += 1
        else:
            if c != 0:
                ans += 1
                c = 0
        if j == n-1 and c != 0:
            ans += 1
print(ans)

Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	long long K;
	cin >> K;
	
	queue<long long > q;
	for (int i = 1; i <= 9; i++) q.push(i);
	while (!q.empty()) {
		long long x = q.front(); q.pop();
		K--;
		if (K == 0) { cout << x << endl; break; }
		
		for (int y = (x % 10) - 1; y <= (x % 10) + 1; y++) {
			if (y < 0 || y >= 10) continue;
			q.push(x * 10 + (long long)y);
		}
	}
	return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
s = input()

index_lst = []
num_lst = []
before = '-1'
for K, i in enumerate(s):
    if i != before:
        before = i
        index_lst.append(K)
        num_lst.append(int(i))
N = len(index_lst)
index_lst += [n] * (2*k+10)

S = 0
for i in range(N):
    S = max(S, index_lst[i+2*k] - index_lst[i]) if num_lst[i] == 0 else max(S, index_lst[i+2*k+1] - index_lst[i])
print(S)

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

int main(){
    string S, T;
    cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes\n";
    else cout << "No\n";
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	int ans = 0;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n-1-i]) {
			ans++;
		}
	}
	cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,k,l,u,v,t,arr[100009],brr[100009],vis[100009],vis1[100009],ans;
vector<int>vv[100009];
void bfs(int node)
{
    queue<int>q;
    arr[node]=0;
    q.push(node);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        vis[x]=1;
        for(int ii=0;ii<vv[x].size();ii++){
            int y=vv[x][ii];
            if(vis[y])
                continue;
            q.push(y);
            arr[y]=arr[x]+1;
        }
    }
    return;
}
void bfs1(int node)
{
    queue<int>q;
    brr[node]=0;
    q.push(node);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        vis1[x]=1;
        for(int ii=0;ii<vv[x].size();ii++){
            int y=vv[x][ii];
            if(vis1[y])
                continue;
            q.push(y);
            brr[y]=brr[x]+1;
        }
    }
    return;
}
int main()
{
    scanf("%d %d %d",&n,&u,&v);
    for(i=1;i<n;i++){
        scanf("%d %d",&k,&l);
        vv[k].push_back(l);
        vv[l].push_back(k);
    }
    bfs(v);
    bfs1(u);
    for(i=1;i<=n;i++){
      if(brr[i]<=arr[i])
        ans=max(ans,arr[i]-1);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 7424
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let H:usize = sc.read();
    let W:usize = sc.read();
    let K:usize = sc.read();
    let mut P:Vec<(usize, usize)> = vec![];
    let A:Vec< Vec< char>> = (0..H).map(|_| sc.chars()).collect();
    // for i in 0..H{
    //     for j in 0..W{
    //         println!("{}", A[i][j]);
    //     }
    //     println!("huga");
    // }
    let mut ans:Vec< Vec< usize>> = vec![ vec![0; W]; H];
    let mut now:usize = 1;

    for i in 0..H{
        for j in 0..W{
            if A[i][j] == '#'{
                P.push((i, j));
                ans[i][j] = now;
                now += 1;
            }
        }
    }
    for k in 0..K{
        ans[P[k].0][P[k].1] = k+1;
        let X = P[k].0;
        let Y = P[k].1;
        let mut LY:usize = Y;
        if Y > 0{
            for y in (0..Y).rev(){
                if ans[X][y] > 0{
                    break
                }
                LY = y;
                ans[X][y] = k+1;
            }
        }
        let mut U:Vec<usize> = vec![];
        U.push(X);
        if X > 0{
            for x in (0..X).rev(){
                if ans[x][LY] > 0{
                    break
                }
                ans[x][LY] = k+1;
                U.push(x);
            }
        }
        let lenU = U.len();
        let mut D:Vec<usize> = vec![];
//        D.push(LY);
        for y in LY..W{
            let mut check = true;
            for i in 0..lenU{
                if (ans[U[i]][y] > 0) && (ans[U[i]][y] != k+1){
                    check = false;
                }
            }
            if !check{
                break
            }
            D.push(y);
            for i in 0..lenU{
                ans[U[i]][y] = k+1;
            }
        }
        let lenD = D.len();

        for x in X..H{
            let mut check = true;
            for i in 0..lenD{
                if (ans[x][D[i]] > 0) && (ans[x][D[i]] != k+1){
                    check = false;
                }
            }
            if !check{
                break
            }
            for i in 0..lenD{
                ans[x][D[i]] = k+1;
            }

        }        
    }
    for i in 0..H{
        for j in 0..W{
            print!("{} ", ans[i][j]);
        }
        println!("");
    }

    

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




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

int main() {
  string s; 
  cin >> s;
  if (s.at(0) != 'A') {
    cout << "WA" << endl;
    return (0);
  }
  s.at(0) = tolower(s.at(0));
  int i = s.find('C');
  if (i < 2 || s.size() - 2 < i) {                                                                    
    cout << "WA" << endl;
    return (0);
  }
  s.at(i) = tolower(s.at(i));
  for (i = 0; i < s.size(); i++) {
    if (isupper(s.at(i))) {
      cout << "WA" << endl;
      return (0);
    }
  }
  cout << "AC" << endl;
}

Measured memory_bytes: 256
#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;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int k = 0;
  rep(i, n) if (p[i] != i+1) k++;
  if (k <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<time.h>
#include<stack>
#include<map>
#include<set>
#include<string>
using namespace std;
int main()
{
    int i,j,n,k,l;
    int a,b,m;
    cin>>n>>a>>b;
    int s[100008]={0};
    for(i=0;i<n;i++)cin>>s[i];
    long long int r=0,da;
    for(i=1;i<n;i++)
    {
        da=s[i]-s[i-1];
        da*=a;
        if(da>b)r+=b;
        else r+=da;
    }
    cout<<r<<endl;
    return 0;
}


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

int main(){
  int n;
  vector<int> a(100010);
  cin>>n;
  for(int i=0;i<n;i++){
      int in;
      cin>>in;
      a[in]++;
  }
  int ans=0;
  for(int i=0;i<100000-2;i++){
      ans=max(ans,a[i]+a[i+1]+a[i+2]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        int n=s.length();
        int ans=0;
        for (int i = 1; i < n; i++) {
            if(s.charAt(i-1)!=s.charAt(i))ans++;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 23880
#include<complex>
#include<cstdio>
#include<cmath>
using namespace std;
typedef complex<double> P;
double F(double a,double b,double c){
	return acos((b*b+c*c-a*a)/(2*b*c));
}
int main(){
	int n;
	double d,e,f,g,h,i;
	for(scanf("%d",&n);n--;){
		scanf("%lf%lf%lf%lf%lf%lf",&d,&g,&e,&h,&f,&i);
		P a(d,g),b(e,h),c(f,i);
		double A=abs(b-c),B=abs(c-a),C=abs(a-b),
		s=sin(2*F(A,B,C)),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;
		printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(F(A,B,C))/2);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    vector<int> v(1, 1);
    for (int i = 1; i < sz(s); i++) {
        if (s[i] == s[i - 1]) {
            v.back()++;
        } else {
            v.push_back(1);
        }
    }
    cout << sz(v) - 1 << "\n";
}

Measured memory_bytes: 1480
#include <stdio.h>

#define N 255
#define NIL -2000001

typedef struct{
  int key;
  int right,left,parent;
}Node;

Node T[N];
int A[N];
int n;

void makeTree(Node *,int *);
void print(Node *);

int main(){

  int i;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  makeTree(T,A);

  print(T);

  return 0;
}



void makeTree(Node T[],int A[]){
  int i;

  for(i=0;i<n;i++){
    T[i].key = NIL;
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right =NIL;
  }
  
  for(i=0;i<n;i++){
    T[i].key = A[i];
    if(i>0)T[i].parent = A[(i-1)/2];
    if(2*(i+1)<=n)T[i].left = A[2*(i+1)-1];
    if(2*(i+1)<=n-1)T[i].right = A[2*(i+1)];
  }
}

void print(Node T[]){
  int i;
  for(i=0;i<n;i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",T[i].key);
    if(T[i].parent != NIL)printf("parent key = %d, ",T[i].parent);
    if(T[i].left != NIL)printf("left key = %d, ",T[i].left);
    if(T[i].right != NIL)printf("right key = %d, ",T[i].right);
    printf("\n");
  }
}

Measured memory_bytes: 604
import math
A,B,H,M = map(int,input().split())
r = 30*H+M/2-6*M
if r >= 180:
    r = 360 - r
c = math.cos(math.radians(r))
l = math.sqrt(A*A+B*B-2*A*B*c)
print(l)

Measured memory_bytes: 9376
h, w = map(int, input().split())
s = []
s.append(["#"] * (w + 2))
for i in range(h):
    s.append(["#"] + list(input()) + ["#"])
s.append(["#"] * (w + 2))

num = [[-1 for i in range(w + 2)] for i in range(h + 2)]
for i in range(1, h + 1):
    l = 0
    m = 0
    while l < w + 2:
        if s[i][l] == "#":
            l += 1
            continue
        else:
            m = l
            while s[i][m] == ".":
                m += 1
            else:
                for j in range(l, m):
                    num[i][j] += m - l
                l = m
for i in range(1, w + 1):
    l = 0
    m = 0
    while l < h + 2:
        if s[l][i] == "#":
            l += 1
            continue
        else:
            m = l
            while s[m][i] == ".":
                m += 1
            else:
                for j in range(l, m):
                    num[j][i] += m - l
                l = m
print(max([max([num[i][j] for j in range(w + 2)]) for i in range(h + 2)]))

Measured memory_bytes: 270152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define INF 10000000000000LL
#define DIM 100007
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> myset;
typedef  pair< long long, pair<long long, long long> > ppll;
ll n,m,c,x,x2,y2,e,h,k,res1,a1,a2,w,a3,y,z,a4,a5,a6,last,LL,timer,start,finish,maxmask,newmax,reslast,tests,police,brothers;
string s,s1;
ll al,ar;
ll mas[100007],dp[100007];
int main(){

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>mas[i];
    }
    dp[1]=0;
    dp[2]=abs(mas[1]-mas[2]);
    for(int i=3;i<=n;i++){
            dp[i]=INF;
        for(int j=i-1;j>=max(i-k,1ll
                             );j--){
            dp[i]=min(dp[i],dp[j]+abs(mas[i]-mas[j]));
        }

    }
    cout<<dp[n]<<endl;
}


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

result = 100000000000

def calc(x, base):
    r = 0
    while x:
        x, m = divmod(x, base)
        r += m
    return r

for i in range(N + 1):
    result = min(result, calc(i, 6) + calc(N - i, 9))

print(result)


Measured memory_bytes: 2940
// AOJ 2412: Village
// 2017.12.8 bal4u@uu

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

#define HASHSIZ 3000017
typedef struct { unsigned long long t; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

void insert(int x, int y)
{
	unsigned long long t = ((unsigned long long)x << 32) | y;
	HASH *p = hash + (int)(t % HASHSIZ);

	while (p->t) {
		if (p->t == t) return;
		if (++p == hashend) p = hash;
	}
	p->t = t;
}

int lookup(int x, int y)
{
	unsigned long long t = ((unsigned long long)x << 32) | y;
	HASH *p = hash + (int)(t % HASHSIZ);

	while (p->t) {
		if (p->t == t) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

#define BASE 1000000000
int ans;
char buf[30], *p;

int getdbl()
{
	int minus = 0;
	int n = 0;

	if (*p == '-') minus = 1, p++;
	while (*p >= '0') n = (n<<3)+(n<<1) + (*p++ & 0xf);
//	n *= 1000;
	if (*p == '.') p++;
	while (*p >= '0') n = (n<<3)+(n<<1) + (*p++ & 0xf);
//		if (*p >= '0') n += (*p++ & 0xf) * 100;
//		if (*p >= '0') n += (*p++ & 0xf) * 10;
//		if (*p >= '0') n += (*p++ & 0xf);
//	}
	p++;
	if (minus) n = -n;
	return n;
}

int main()
{
	int n, r, x0, y0, x, y, i, j;

	fgets(p=buf, 30, stdin);
	n = atoi(p); while (*p >= '0') p++; p++;
	r = getdbl();
	while (n--) {
		fgets(p=buf, 30, stdin);
#if 0
		x0 = getdbl(), y0 = getdbl();
		if (x0 < 0) x = (x0+1)/r-1; else x = x0/r;
		if (y0 < 0) y = (y0+1)/r-1; else y = y0/r;
#else
		x = getdbl()/r, y = getdbl()/r;
#endif

		for (i = x-1; i <= x+1; i++) for (j = y-1; j <= y+1; j++) {
			if (lookup(i+BASE, j+BASE)) goto next;
		}
		ans++, insert(x+BASE, y+BASE);
next:;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int cnt = 0;
  if(a != b) cnt++;
  if(b != c) cnt++;
  if(c != a) cnt++;

  if(cnt == 0) cnt++;

  cout << cnt << endl;

  return 0;
}

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

int main(){
  int s,cnt=2;
  cin>>s;
  if(s==1 || s==2)
    cnt=4;
  else{
    while(s!=1){
      if(s%2)
        s = 3*s+1;
      else
        s /= 2;
      cnt++;
    }
  }
  cout<<cnt<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> B(n);
    rep(i, n - 1) cin >> B[i];
    int ans = B[0] + B[n - 2];
    rep(i, n - 2) {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll  = long long;
using v   = vector<int>;
using P   = pair<int,int>;
using vp  = vector<P>;
using vvp = vector<vp>;

int main(){
    int n,m; cin>>n>>m;
    
    vvp pyi(n);
    
    int p,y;
    rep(i,m){
        cin>>p>>y;
        p--;
        pyi[p].emplace_back(y,i);
    }
    
    rep(i,n){
        sort(pyi[i].begin(), pyi[i].end());
    }
    
    vp num(m);
    
    rep(i,n){
        rep(j,pyi[i].size()){
            num[pyi[i][j].second].first = i+1;
            num[pyi[i][j].second].second = j+1;
        }
    }
    
    rep(i,m){
        printf("%06d%06d\n", num[i].first, num[i].second);
    }
    
    return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
long long a[5],vis[5],sum;
void dfs(int x,long long s,int k)
{
    if(k==3)
    {
        sum+=s;
        return;
    }
    for(int i=x+1;i<=4;i++)
        if(!vis[i])
        {
            vis[i]=1;
            dfs(i,s*a[i],k+1);
            vis[i]=0;
        }
}
int main()
{
    int n;
    while(cin>>n)
    {
        memset(a,0,sizeof(a));
        sum=0;
       for(int i=1;i<=n;i++)
       {
           string b;
           cin>>b;
           if(b[0]=='M')
            a[0]++;
           else if(b[0]=='A')
            a[1]++;
           else if(b[0]=='R')
            a[2]++;
           else if(b[0]=='C')
            a[3]++;
           else if(b[0]=='H')
            a[4]++;
       }
       dfs(-1,1,0);
       cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m, q = gets.chomp.split().map(&:to_i)
array = []
q.times do 
  array << gets.chomp.split.map(&:to_i)
end

ans = 0

[*1..m].repeated_combination(n).to_a.each do |comb|
  sum = 0
  array.each do |a, b, c, d|
    sum += d if (comb[b-1] - comb[a-1]) == c
  end
  ans = [ans, sum].max
end

puts ans



Measured memory_bytes: 27856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl;
#define pv(v) for(auto a: v){ cout << a << endl; }

int main() {
  int n; cin >> n;
  p(180*(n-2))
}


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

int main(void) {
	int a,b,d,r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b ;
	f = 1.000000000 * a / b;
	cout << fixed;
	cout << setprecision(5);
	cout << d << " " << r << " " << f << endl;
	

	return 0;
}


Measured memory_bytes: 3280
import java.util.Scanner;

import java.lang.Math;

public class Main {
  private static int gcd(int x, int y) {
    if (x == 0)
      return y;
    return gcd(y % x, x);
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++)
      A[i] = scanner.nextInt();

    int[] pre = new int[N];
    pre[0] = A[0];
    for (int i = 1; i < N; i++)
      pre[i] = gcd(pre[i - 1], A[i]);

    int[] post = new int[N];
    post[N - 1] = A[N - 1];
    for (int i = N - 2; i >= 0; i--)
      post[i] = gcd(post[i + 1], A[i]);

    int ans = Math.max(pre[N - 2], post[1]);
    for (int i = 1; i < N - 1; i++)
      ans = Math.max(ans, gcd(pre[i - 1], post[i + 1]));

    System.out.println(ans);
  }
}


Measured memory_bytes: 49540
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int main(){
   int a,b;
   cin >> a >> b;
   int ans;
   if(a >= 6 && a <= 12){ans = b/2;}
   else if(a >= 13){ans = b;}
   else if(a <= 5){ans = 0;}

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
var a, b, c, d, g : int64;
    
function ceilInt(ca, cb : int64) : int64;
begin ceilInt := (ca + cb - 1) div cb end;

function f(l, r, divisor : int64) : int64;
begin
  l := ceilInt(l, divisor) * divisor;
  r := (r div divisor) * divisor;
  f := (r - l) div divisor + 1;
end;

function gcd(ga, gb : int64) : int64;
begin
  if ga < gb then begin
    ga := ga xor gb;
    gb := ga xor gb;
    ga := ga xor gb;
  end;
  if gb = 0 then gcd := ga
  else gcd := gcd(gb, ga mod gb);
end;

begin
  read(a, b, c, d);
  g := gcd(c, d);
 writeln( (b - a + 1) - (f(a, b, c) + f(a, b, d) - f(a, b, c div g * d)) );
end.

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int s[13] = {};
	int h[13] = {};
    int	c[13] = {};
	int d[13] = {};						//Cards.
	int deck, i;						//The number of cards Taro has.
	char mark, dummy;					//dummy is used for scanf().
	int num;							//Card number.

	scanf("%d", &deck);
	scanf("%c", &dummy);

	//Enter the cards.
	i = 0;
	while(i < deck)
	{
		scanf("%c %d", &mark, &num);
		switch(mark)
		{
			case 'S':
				s[num - 1] = 1;
				break;
			case 'H':
				h[num - 1] = 1;
				break;
			case 'C':
				c[num - 1] = 1;
				break;
			case 'D':
				d[num - 1] = 1;
				break;
		}
		scanf("%c", &dummy);
		i++;
	}

	//Display lost cards.
	i = 1;
	while(i <= 13)
	{
		if(s[i - 1] == 0)
			printf("S %d\n", i);
		i++;
	}
	i = 1;
	while(i <= 13)
	{
		if(h[i - 1] == 0)
			printf("H %d\n", i);
		i++;
	}
	i = 1;
	while(i <= 13)
	{
		if(c[i - 1] == 0)
			printf("C %d\n", i);
		i++;
	}
	i = 1;
	while(i <= 13)
	{
		if(d[i - 1] == 0)
			printf("D %d\n", i);
		i++;
	}

	return (0);
}



Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;
const int MAXN = 200005;
typedef long long ll;
struct Node{
	ll x,y;
	int id;
	bool operator < (const Node &b)const
	{
		return x==b.x?y<b.y:x<b.x;
	}
}a[MAXN],t[MAXN];
int tot,n;
ll d;
int now,front,back,sa,sb,fa[MAXN];
ll ans[MAXN];
int getan(int x)
{
	return x==fa[x]?x:fa[x]=getan(fa[x]);
}
#define NEXT {++back;continue;}
void solve(int delta)
{
//	for(int i=1;i<=n;++i)cout<<a[i].x<<" "<<a[i].y<<endl;
//	cout<<endl;
	front=1,back=0;
	int end=0,last=0;
	a[0].x=-998244353;
	for(int i=1;i<=n;++i){
		if(a[i].x!=a[i-1].x){
			while(front<=back && a[front].x+d<a[i].x)++front;
			if(a[front].x+d>a[i].x || front>back)NEXT;
			end=front;
			while(end<back && a[end+1].x+d==a[i].x)++end;
			tot=last=0;
//			cout<<"##  "<<front<<" "<<end<<" "<<a[end].x<<" "<<a[i].x<<endl;
			if(a[end].x+d==a[i].x){
				last=1;
//				cout<<"@@  "<<i<<" "<<a[end].x<<" "<<a[i].x<<"  ";
	//			cout<<"----"<<endl;
				for(int i=front;i<=end;++i)t[++tot]=a[i],++front;//,cout<<a[i].id<<" "<<a[i].x<<" "<<a[i].y<<endl;
	//			cout<<"----"<<endl;
			}	
		}
	//	cout<<i<<" "<<a[end].x<<" "<<a[i].x<<" "<<end<<endl;
		if(a[end].x+d==a[i].x){
			int pos=lower_bound(t+1,t+tot+1,(Node){a[i].x-d,a[i].y-d-delta,a[i].id})-t;
			last=max(last,pos);
	//		cout<<"END"<<end<<endl;
	//		cout<<"Found Pos"<<i<<" "<<pos<<endl;
			if(pos==tot+1 || t[last].y>a[i].y+d+delta)NEXT;
	//		cout<<"END"<<end<<endl;
			for(;last<=tot && t[last].y<=a[i].y+d+delta;++last){
				fa[getan(a[i].id)]=getan(t[last].id);
			}
	//		cout<<"END"<<end<<endl;
	//		cout<<"Now  "<<a[i].id<<" "<<last<<" "<<pos<<endl;
			ans[a[i].id]+=last-pos;
	//		cout<<"END"<<end<<endl;
			if(last!=pos)--last;
		}
		++back;
	}
//	for(int i=1;i<=n;++i)if(ans[i])cout<<"Ans : "<<i<<" "<<ans[i]<<endl;
}
ll final_ans[MAXN],sx,sy,tx,ty;
int main()
{
	scanf("%d%d%d",&n,&sa,&sb);
	for(int i=1,x,y;i<=n;++i){
		fa[i]=i;
		scanf("%d%d",&x,&y);
		a[i].x=x-y,a[i].y=x+y;
		a[i].id=i;
		if(i==sa)sx=x,sy=y;
		if(i==sb)tx=x,ty=y;
	}
	d=abs(sx-tx)+abs(sy-ty);
//	cout<<d<<endl;
	sort(a+1,a+n+1);
	solve(0);
	for(int i=1;i<=n;++i)swap(a[i].x,a[i].y);
	sort(a+1,a+n+1);
	solve(-1);
	for(int i=1;i<=n;++i)final_ans[getan(i)]+=ans[i];//,cout<<ans[i]<<" ";
//	cout<<endl;
	cout<<final_ans[getan(sa)]<<endl;
	return 0;
}


Measured memory_bytes: 9728