akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

# 解法メモ
# ひとつでも山の雨の量がわかれば全て求まる
# 3つの山があり、1つめの山の値をxとしたとき
# 1つめ: x
# 2つめ：A1 - x
# 3つめ：A2 - (A1 - x)
# 1つめ：A3 - (A2 - (A1 - x))
# 1つめ２つを式にする
# x = A3 - (A2 - (A1 - x))
# x = A3 - A2 + A1 - x
# 2x = A3 - A2 + A1
summary = 0

for i in range(N):
    if i % 2 == 0:
        summary += A[i]
    else:
        summary -= A[i]

for i in range(N):
    print(summary)
    summary = (A[i] - (summary//2)) * 2


Measured memory_bytes: 14092
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        xy:[(usize,usize);n]
    }
    let m = 1e5 as usize;
    //0~1e5:x,1e5~2e5:y
    let mut g = Graph::new(2 * m);
    for (x, y) in xy.iter() {
        let (x, y) = (x - 1, y - 1);
        g.add_undirectional_edge(x, y + m, 1);
    }
    let mut visited = vec![false; 2 * m];
    let mut ans: i64 = 0;
    for i in 0..2 * m {
        if visited[i] {
            continue;
        }
        let mut x_count = 0;
        let mut y_count = 0;
        let mut bfs = VecDeque::new();
        bfs.push_back(i);
        visited[i] = true;
        while let Some(now) = bfs.pop_front() {
            if now < m {
                x_count += 1;
            } else {
                y_count += 1;
            }
            for next in g[now].iter() {
                if visited[next.to] {
                    continue;
                }
                visited[next.to] = true;
                bfs.push_back(next.to);
            }
        }
        ans += x_count * y_count;
    }
    println!("{}", ans - n as i64);
}

#[derive(Debug, Copy, Clone)]
pub struct Edge {
    pub to: usize,
    pub cost: i64,
}
impl Edge {
    pub fn new(to: usize, cost: i64) -> Edge {
        Edge { to: to, cost: cost }
    }
}
pub struct Graph {
    adjacency: Vec<Vec<Edge>>,
}
impl Graph {
    pub fn new(size: usize) -> Self {
        Graph {
            adjacency: vec![vec![]; size],
        }
    }
    pub fn len(&self) -> usize {
        self.adjacency.len()
    }
    pub fn add_directional_edge(&mut self, from: usize, to: usize, cost: i64) {
        self.adjacency[from].push(Edge::new(to, cost));
    }
    pub fn add_undirectional_edge(&mut self, from: usize, to: usize, cost: i64) {
        self.add_directional_edge(from, to, cost);
        self.add_directional_edge(to, from, cost);
    }
}
impl std::ops::Index<usize> for Graph {
    type Output = Vec<Edge>;
    fn index(&self, vertex: usize) -> &Self::Output {
        &self.adjacency[vertex]
    }
}

Measured memory_bytes: 14964
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let h: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut dp = vec![1 << 30; n];
    dp[0] = 0;
    dp[1] = (h[1] - h[0]).abs();

    for i in 2..n {
        if dp[i] > dp[i - 1] + (h[i] - h[i - 1]).abs() {
            dp[i] = dp[i - 1] + (h[i] - h[i - 1]).abs();
        }
        if dp[i] > dp[i - 2] + (h[i] - h[i - 2]).abs() {
            dp[i] = dp[i - 2] + (h[i] - h[i - 2]).abs();
        }
    }
    println!("{}", dp[n - 1]);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define pi 3.14159265358979323846
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--)
  
long long fact(long long a, long long b){
    int r= max(a, b);
    int v= min(a, b);
    int l=1;
    // if(v==0)
    for(int i=r+1; i<=a+b; i++){
        l*=i;
    }
    for(int i=v; i>=2; i--){
        l/=i;
    }
    return l;
}

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

int powr(int a) { 
    int var=1;
    for(int i=0; i<a; i++){
        var*=2;
    }
    return var;
}

void func(int a, bool i){
    cout << a;
    if(a==100){
        i=1;
    }
    else if(a==0){
        return;
    }
    if(!i)
        func(a+1, i);
    else
        func(a-1, i);
}

signed main(){   
    fast;
    int n;
    cin >> n;
    int a[3][n];
    rep(i,0,n){
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    }
    int d, b, c, pb=a[0][0], pc=a[1][0], pd=a[2][0];
    for(int i=1; i<n; i++){
        b = max(pc,pd)+a[0][i];
        c = max(pb,pd)+a[1][i];
        d = max(pb,pc)+a[2][i];
        pb=b;
        pc=c;
        pd=d;
    }
    cout << max(pd,max(pb, pc));
} 

Measured memory_bytes: 5960
from collections import  deque

n,m=map(int,input().split())
graph=[[] for i in range(n)]
count=[]
for i in range (m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    count.append([a-1,b-1])

def dfs(st,check):
    check[st]=1
    for th in graph[st]:
        if check[th]==0 :
           dfs(th,check)

ans=0
for i in range(m):
    graph[count[i][0]].remove(count[i][1])
    graph[count[i][1]].remove(count[i][0])
    check = [0 for k in range(n)]
    dfs(0,check)
    if 0 in check:
        ans+=1
    graph[count[i][0]].append(count[i][1])
    graph[count[i][1]].append(count[i][0])

print(ans)

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define erep(i,n) for (int i = 1; i <= (n); ++i)
#define brep(i,n) for (int i = n; i >= 0; i--)
#define pb push_back
using namespace std;
using P = pair<int,int>;
using ll = long long;
using Graph = vector<vector<int> > ;


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


int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    int sum = 0;

    rep(i,k){
        sum += p[i];
    }

    cout << sum << endl;

}

Measured memory_bytes: 3632
S = input()
YYMM, MMYY = 0, 0
if int(S[:2]) > 0 and int(S[:2]) <= 12:
  MMYY = 1
if int(S[2:]) > 0 and int(S[2:]) <= 12:
  YYMM = 1
if YYMM == 0 and MMYY == 0:
  print('NA')
elif YYMM == 0 and MMYY == 1:
  print('MMYY')
elif YYMM == 1 and MMYY == 0:
  print('YYMM')
else:
  print('AMBIGUOUS')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n % 10 == 3) {
    cout << "bon" << '\n';
  } 
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
    cout << "pon" << '\n';
  }
  else {
    cout << "hon" << '\n';
  }
}

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

#define ll long long
// #define endl '\n'

// void max_self(int &a, int b){a = max(a, b);}
void min_self(int &a, int b){a = min(a, b);}

void solve(){
	string s, t; cin>>s>>t;
	int n = (int)s.length(), m = (int)t.length();
	int mi = n;
	for(int i = 0; i<n; i++){
		if(i + m > n) break;
		int ans = 0;
		for(int j = 0; j<m; j++){
			if(s[i + j] != t[j]) ans++;
		}
		min_self(mi, ans);
	}
	cout<<mi<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3668
var
s,t,r,g:ansistring;
m,n,i,j,k,x,y,z:longint;
begin
    readln(s);
    for i:=1 to length(s) do
    begin
        if s[i]=' ' then
        begin
        y:=i;
            break;
        end;
    end;
    for i:=y+1 to length(s) do
    begin
        if s[i]=' ' then
        z:=i;
    end;
    t:='';
    r:='';
    g:='';
    for i:=1 to y-1 do
    begin
        t:=t+s[i];
    end;
    for i:=y+1 to z-1 do
    begin
        r:=r+s[i];
    end;
    for i:=z+1 to length(s) do
    g:=g+s[i];
    val(t,m);
    val(g,n);
    if r='+' then
    begin
        writeln(m+n);
    end
    else
    begin
        writeln(m-n);
    end;
end.

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

ll a,b,c,d;

ll gcd(ll x, ll y){
  while(y){
    x %= y;
    swap(x,y);
  }
  return x;
}
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}

int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%lld%lld%lld%lld", &a,&b,&c,&d);

  ll l = lcm(c,d);

  ll ans = (b-a+1);

  ans -= b/c + b/d - b/l;
  ans += (a-1)/c + (a-1)/d - (a-1)/l;

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


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

long long d;
const long long t = 26;
vector<long long> c, res;
vector<vector<long long>> s;

void solve();
long long calc();

int main() {
  cin >> d;
  c.resize(t);
  res.resize(d);
  for (auto &p : c) cin >> p;
  s.resize(d, vector<long long>(t, 0));
  for (auto &v : s)
    for (auto &p : v) cin >> p;
  for (auto &p : res) {
    cin >> p;
    --p;
  }
  solve();
  calc();
  return 0;
}

void solve() {}

long long calc() {
  long long sum = 0;
  vector<long long> memo(t, 0);
  for (int i = 0; i < d; ++i) {
    int num = res[i];
    sum += s[i][num];
    for (int j = 0; j < t; ++j)
      if (j != num)
        sum -= (memo[j] += c[j]);
      else
        memo[j] = 0;
    cout << sum << endl;
  }
  return sum;
}

Measured memory_bytes: 3592
@D=map[glob<>],@@=0..$'-<>=~$";map{for$x(split){$k=($i+$j++)%3;$$k[$_]+=$D[$x-1][$_]for@@}$j=!++$i}<>;$\=1e15;for$i(@@){for$j(@@){$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$0[$i]-$1[$j]-$2[$_]for@@}}print

Measured memory_bytes: 1664
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
e=[(i+1)*0.5 for i in p]
ex=[]

for i in range(N):
  if i==0:
    ex.append(e[0])
  else:
    ex.append(ex[i-1]+e[i])

ans=0
ex.insert(0,0)
for i in range(N-K+1):
  if ans<ex[i+K]-ex[i]:
    ans=ex[i+K]-ex[i]
print(ans)

Measured memory_bytes: 24688
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

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

  int32_t A, B, C;
  cin >> A >> B >> C;
  if ((A == B && A != C) || 
      (A == C && A != B) ||
      (B == C && A != B)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		cout << a * b << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  if (a%k==0 ||b%k==0){
    cout<<"OK"<<endl;}
  else if (b/k-a/k>=1){
    cout<<"OK"<<endl;}
  else{ cout<<"NG"<<endl;}
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
#define int ll
#define N 100005
#define pb push_back
#define pv(x) cout<<#x<<": ";for(auto k:x){ cout<<k<<" "; }cout<<endl;
#define dbg(x) cout<<#x<<": "<<x<<endl;

int n,m,ni,mi;
// int num[N];
int ok=false;

void solve(){
	int k;
	cin >> n >> k;
	vector<int> v(n);
	vector<int> when(n,-1);
	for(int i=0;i<n;i++){
		cin >> v[i];
		v[i]--;
	}
	int time=0;
	int pos=0;
	int delta;
	when[0]=0;
	while(1){
		pos=v[pos];
		time++;
		k--;
		if(k==0)break;
		if(when[pos]!=-1){
			delta=time-when[pos];
			break;
		}
		when[pos]=time;
	}
	k=k%delta;
	while(k--){
		pos=v[pos];
	}

	cout<<pos+1<<endl;
}

int32_t main(){cin.tie(0);ios_base::sync_with_stdio(NULL);
	int t=1;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 6368
#include<iostream>
#include<string.h>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;
string s;
bool b=false;
int y,l;
int main()
{
	cin>>s;
	l=s.size();
	for(register int i=0;i<l;i++)
	{
		if(s[i]=='C') 
		{
			for(register int j=i+1;j<l;j++)
			{
				if(s[j]=='F') 
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}	
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

string str;

string k[3];
int f[1000000];

vector<string> ans_list;

int main(){

	k[0] = "()";
	k[1] = "[]";

	while (true){
		getline(cin, str);
		if (str == ".")
			break;

		int num;
		int f_c = -1;

		for (num = 0; num < str.length(); num++){
			if (k[0][0] == str[num]){
				f_c++;
				f[f_c] = 0;
			}
			else if (k[1][0] == str[num]){
				f_c++;
				f[f_c] = 1;
			}
			else if (k[0][1] == str[num]){
				if (f_c < 0 || f[f_c] != 0)
					break;
				f_c--;
			}
			else if (k[1][1] == str[num]){
				if (f_c < 0 || f[f_c] != 1)
					break;
				f_c--;
			}
		}

		if (num == str.length() && f_c < 0)
			ans_list.push_back("yes");
		else
			ans_list.push_back("no");


	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define MI          map<int, int>
#define PI          pair<int, int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
ll dp[N], a[N];
int main(){
    int n;sc(n);
    int k;sc(k);
    fr(i, 1, n) lsc(a[i]);
    fr(i, 2, n) dp[i]=mod*1LL*mod;
    fr(i, 2, n){
        for(int j=i-1;j>=max(1, i-k);j--){
            dp[i] = min(dp[i], dp[j] + abs(a[i]-a[j]));
        }
    }
    lpr(dp[n]);n_l;
    return 0;
}



Measured memory_bytes: 5120
#include <iostream>

using namespace std;

const uint64_t R = 1'000'000'007L;

int a[100'001];
int occurence[100'000];

uint64_t perm[100'001];

uint64_t dpow(const uint64_t x, const uint64_t y)
{
    if (y == 0)
    {
        return 1;
    }
    else if (y % 2 == 0)
    {
        return dpow(x * x % R, y / 2);
    }
    else
    {
        return x * dpow(x, y - 1) % R;
    }
}

uint64_t inv(const uint64_t x)
{
    return dpow(x, R - 2);
}
uint64_t comb(const uint64_t n, const uint64_t k)
{
    return perm[n] * inv(perm[n - k]) % R * inv(perm[k]) % R;
}

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

    int twin1, twin2;
    for (int i = 0; i < n; i++)
    {
        occurence[i] = -1;
    }
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
        a[i]--;
        if (occurence[a[i]] == -1)
        {
            occurence[a[i]] = i;
        }
        else
        {
            twin1 = occurence[a[i]];
            twin2 = i;
        }
    }
    for (int i = 0; i <= n + 1; i++)
    {
        if (i == 0)
        {
            perm[i] = 1;
        }
        else
        {
            perm[i] = perm[i - 1] * i % R;
        }
    }
    //cout << "twin: " << twin1 << ", " << twin2 << endl;

    for (uint64_t k = 1; k <= (uint64_t)n + 1; k++)
    {
        uint64_t res = n + 1 - (twin2 - twin1 + 1);
        uint64_t result = (R + comb(n + 1, k) - (res < k - 1 ? 0 : comb(res, k - 1))) % R;
        cout << result << endl;
    }

    return 0;
}

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

signed main(void)
{
	int n;
	long long ans, sum;
	cin >> n;
	int a[n + 2];

	sum = 0;
	a[0] = a[n + 1] = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += abs(a[i] - a[i - 1]);
	}
	sum += abs(a[n + 1] - a[n]);
	for(int i = 1; i <= n; i++)
	{
		ans = sum;
		ans -= abs(a[i] - a[i - 1]);
		ans -= abs(a[i + 1] - a[i]);
		ans += abs(a[i - 1] - a[i + 1]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int n,d,x;
  cin>>n;
  cin>>d>>x;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=x;
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      if(i%a[j]==0)ans++;
    }
  }

  cout<<ans;
  return 0;
}


Measured memory_bytes: 384
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (_, X) = read!(usize, i64);
    let L = read![[i64]];

    let mut d = 0;
    let mut count = 0;
    for l in L {
        count += 1;
        d += l;

        if d > X {
            break;
        }
    }
    if d <= X {
        count += 1;
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n; cin >> n;
	if (n < 65) {
		cout << 0 << endl;
	}
	else if (n <= 90) {
		cout << 1 << endl;
	}
	else if (n < 97) {
		cout << 0 << endl;
	}
	else if (n <= 122) {
		cout << 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	cin >> n;
}


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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)

//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}

//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))

int lcm(int a,int b){
   return a*b/__gcd(a,b);
}
 
vb pn((int)1e4+10); 
void prime_number(int n){
   fill(all(pn),true);
   pn[0]=false;pn[1]=false;
   loop(i,2,n/2+1){
      if(!pn[i]) continue;
      for(int j=2;i*j<=n;j++){
         pn[i*j]=false;
      }
   }
}

int main(){
   int r,c;
   
   while(cin>>r>>c){
      if(r+c==0)break;
      if(r%2==1&&c%2==1) cout << "no" << endl;
      else cout << "yes" << endl;
   }
}

Measured memory_bytes: 1196
#include <iostream>

using namespace std;

int main()
{
  int N,T;
  cin >> N >> T;

  if((N>200000)||(N<1)){
    return 0;
  }

  if((T>1000000000)||(T<1)){
    return 0;
  }

  double *ti;
  ti=new double[N];
  for(int i=0 ; i<N ; i++){
    cin >> ti[i];
  if((ti[i]>1000000000)||(ti[i]<0)){
     return 0;
  }
  if(i>0){
    if(ti[i]<ti[i-1]){
     return 0;
    }
  }
  }


  int S=0;
  for(int i=0 ; i<(N-1) ; i++){
    if((ti[i+1]-ti[i])>T){
      S=S+T;
    }
    else{
      S=S+ti[i+1]-ti[i];
        }
  }

     cout << S+T;

}

Measured memory_bytes: 1792
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun power(x: Int, n: Int): Int = when {
    n == 0 -> 1
    n == 2 -> (x * x)
    n % 2 == 1 -> (power(x, n - 1) * x)
    else -> {
        val tmp = power(x, n / 2)
        tmp * tmp
    }
}

fun oneCount(b: Int): Int {
    var i = 0
    var cnt = 0
    while (power(2, i) <= b) {
        if ((b shr i) and 1 == 1) {
            cnt++
        }
        i++
    }
    return cnt
}

fun main(args: Array<String>) {
    val N = readInt()
    val say: MutableList<MutableList<Pair<Int, Int>>> = mutableListOf()

    for (i in 0 until N) {
        val a = readInt()
        val list: MutableList<Pair<Int, Int>> = mutableListOf()
        for (j in 0 until a) {
            val (fir, end) = readIntList()
            list.add(Pair(fir - 1, end))
        }
        say.add(list)
    }

    var res = 0
    for (b in 0 until power(2, N)) {
        var ok = true
      
        for (i in 0 until N) {
            val fromState = (b shr i) and 1
          
            for (j in 0 until say[i].size) {
                val toNum = say[i][j]
                val toState = (b shr toNum.first) and 1
                val fromSay = toNum.second

                if (fromState == 1 && toState != fromSay) {
                    ok = false
                    break
                }
            }
        }

        if (ok) {
            res = oneCount(b).coerceAtLeast(res)
        }
    }

    println(res)
}


Measured memory_bytes: 40936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int r, d, x;
  cin >> r >> d >> x;

  rep(i, 10){
    x*=r;
    x-=d;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int a[6];
    for(int i=0;i<6;++i){
        cin>>a[i];
    }
    string s;
    cin>>s;
    int aoki;
    for(int i=0;i<s.size();++i){
        if(s[i]=='N'){
            aoki=a[0];
            a[0]=a[1];
            a[1]=a[5];
            a[5]=a[4];
            a[4]=aoki;
        }
        else if(s[i]=='S'){
            aoki=a[0];
            a[0]=a[4];
            a[4]=a[5];
            a[5]=a[1];
            a[1]=aoki;
        }
        else if(s[i]=='E'){
            aoki=a[0];
            a[0]=a[3];
            a[3]=a[5];
            a[5]=a[2];
            a[2]=aoki;
        }
        else if(s[i]=='W'){
            aoki=a[0];
            a[0]=a[2];
            a[2]=a[5];
            a[5]=a[3];
            a[3]=aoki;
        }
    }
    cout<<a[0]<<endl;
    return 0;
}



Measured memory_bytes: 3180
def resolve():
    s = input()
    sss = [i for i in s]
    flag = False
    if s[0] == "A":
        sss[0] = "a"
        if s[2:-1].count("C") == 1:
            sss[sss.index("C")] = "c"
            s = "".join(sss)
            if s.islower():
                flag = True
                print("AC")
    if not flag:
        print("WA")
        
resolve()

Measured memory_bytes: 3060
/**
 *	@file: C.cpp
 *	@author: Huy Le
 *	@created: 08-03-2020 08:24:59
**/


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

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n,m;
vector<int> c;
vector<vector<pair<int,int>>> q;
vector<int> ans, cnt;
vector<int> BIT;

void update(int ind, int value) {
	++ind;
	for(; ind <= n; ind += ind&-ind)
		BIT[ind] += value;
}

int query(int ind) {
	//++ind;
	int sum  = 0;
	for(; ind > 0; ind -= ind&-ind)
		sum += BIT[ind];
	return sum;
}

void solve() {
	read(n,m);
	c = vector<int>(n);
	q = vector<vector<pair<int,int>>>(n);
	BIT = vector<int>(n + 1);
	read(c);
	for(int i = 0; i < m; ++i) {
		int x,y;
		read(x,y);
		--x;
		--y;
		q[y].push_back({x, i});
	}
	ans = vector<int>(m);
	cnt = vector<int>(n, -1);
	map<int,int> mp;
	for(int i = 0; i < n; ++i) {
		if(mp.find(c[i]) != mp.end())
			update(mp[c[i]], -1);
		update(i, 1);
		for(auto a : q[i]) {
			ans[a.second] = query(n) - query(a.first);
		}
		mp[c[i]] = i;
	}
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

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

    unordered_map<string, int> occ;
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        string s; cin >> s;
        occ[s]++;
    }

    vector<pair<int, string>> v;
    for(auto &p : occ) v.push_back({p.second, p.first});
    sort(begin(v), end(v));

    vector<string> sol;
    for(int i = v.size() - 1, cnt = v.back().first; i >= 0 && v[i].first == cnt; i--)
        sol.push_back(v[i].second);

    sort(begin(sol), end(sol));
    for(string &s : sol) cout << s << endl;
}

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

int main() {
  int64_t a,b,c,d,e,f;
  cin >>a >>b;
  if(a<b){
    c = a;
    for(int i=1; i<b; i++){
      d = 10*c+a;
      c = d;
    }
    cout <<c <<endl;
  }
  else{
    e=b;
    for(int j=1;j<a;j++){
      f = 10*e+b;
      e=f;
    }
    cout <<e <<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        
        String result = "No";
        if ((n%500) <= a) result = "Yes";

        System.out.println(result);
    }
}


Measured memory_bytes: 35360
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

int sum[510][510];
typedef pair<int,int> pii;

class DAtCoderExpress2 {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, m, q, x, y;
		in >> n >> m >> q;
		memset(sum, 0, sizeof(sum));

		for (int i = 0; i < m; ++i) {
			in >> x >> y;
			sum[x][y] ++;
		}
		for (int j = 1; j <= n; ++j) {
			for (int i = 1; i <= n; ++i) {
				sum[i][j] += sum[i-1][j];
			}
		}
		for (int i = 1; i <= n ; ++i) {
			for (int j = 1; j <= n ; ++j) {
				sum[i][j] += sum[i][j-1];
			}
		}
		for (int i = 0; i < q; ++i) {
			in >> x >> y;
			out << sum[y][y] - sum[y][x-1] - sum[x-1][y] + sum[x-1][x-1] << '\n';
		}
	}
};


int main() {
	DAtCoderExpress2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1920
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int a[100010],b[100010],c[100010];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,m;scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		a[x]^=1;b[x%m]++;
	}
	for (int i=1;i<=100000;i++) c[i%m]+=a[i];
	int ans=0;
	for (int i=0;i<=m/2;i++)
		if ((i+i)%m==0)
			ans+=b[i]/2;
		else
		{
			int x;
			if (b[i]>b[m-i]) x=i; else x=m-i;
			ans+=b[m-x];
			int t=max((c[x]&1)^(b[m-x]&1),c[x]-b[m-x]);
			ans=ans+(b[x]-b[m-x]-t)/2;
		}
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 1536
#include <stdio.h>

int main()
{
    long long x,t;
    scanf("%lld %lld",&x,&t);
    
    if(x>t)
    {
        printf("%lld\n",x-t);
    }
    else
    {
        printf("0\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	set<pair<int,int>> mp;
	mp.insert({1,399});
        mp.insert({400,799});
	mp.insert({800,1199});
	mp.insert({1200,1599});
	mp.insert({1600,1999});
	mp.insert({2000,2399});
	mp.insert({2400,2799});
	mp.insert({2800,3199});
	int n,mi=0,ma=0;
	cin >> n;
	set<pair<int,int>> taken;
	int a[n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		for(auto k=mp.begin();k!=mp.end();++k){
			if(a[i]>=k->first&&a[i]<=k->second && taken.find(make_pair(k->first,k->second))==taken.end())
			{
				//cout<<a[i]<<" inserted\n";
				taken.insert(make_pair(k->first,k->second));
				++mi;
//cout<<mi<<" mi incre\n";
				++ma;
			}
		}
		
 
	}
for(int i=0;i<n;++i){
if(a[i]>3199)
		{
			if(mi>0)
				++ma;
			else
			{
//cout<<mi<<" mi incremented\n";
				++mi;
				++ma;
 
			}
		}
}
	cout<<mi<<" "<<ma<<endl;
	return 0;
}

Measured memory_bytes: 256
small :: [Int]
small = [3,5,7,11,13,17,19]

eightFactors :: Int -> [Int]
eightFactors n = filter (<=n) $ l1 ++ l2
 where
  l1 = [p*(q^3) | p<-small, q<-small, p/=q]
  l2 = [p*q*r | p <- small, q<- filter (>p) small, r<-filter (>q) small]

main = do
 n <- read <$> getLine
 putStrLn $ show $ length $ eightFactors n


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
	int A[1010001];
	for(int i = 1; i <= 1010000; i++){
		if(i % 1000000 == 0){
			A[i] = 3;
		}
		else if(i % 10000 == 0){
			A[i] = 2;
		}
		else if(i % 100 == 0){
			A[i] = 1;
		}
		else{
			A[i] = 0;
		}
	}
	int D, N;
	cin >> D >> N;
	int cnt = 0;
	for(int i = 1; i <= 1010000; i++){
		if(A[i] == D){
			cnt++;
		}
		if(cnt == N){
			cout << i << "\n";
			break;
		}
	}
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
using namespace std;
int n;
pair<int,int> a[100005], b[100005];
int vis[100005], p[100005];
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i].first, a[i].second = i;
	for (int i = 0; i < n; i++)cin >> b[i].first, b[i].second = i;
	sort(a, a + n);
	sort(b, b + n);
	for (int i = 0; i < n; i++)
		if (a[i].first > b[i].first)
		{
			cout << "No\n";
			return 0;
		}
	// 必然能通过n-1次交换完成归位
	
	int cnt = 1, cur = 0;
	for (int i = 0; i < n; i++)
		p[a[i].second] = b[i].second;
	while (!vis[cur])
	{
		vis[cur] = true;
		cur = p[cur];
	}
	for (int i = 0; i < n; i++)
		if (!vis[i])
		{
			cnt++; break;
		}
	if (cnt == 2)	// 至少有两个 circles
	{
		cout << "Yes\n";
		return 0;
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (b[i].first >= a[i + 1].first)
			// 说明 i+1 和 i 可以交换
			// (p1,...pn)不是唯一满足条件的交换结果
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 2560
using System;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int x, a, b;
        x = int.Parse(str[0]);
        a = int.Parse(str[1]);
        b = int.Parse(str[2]);
        int da, db;
        da = Math.Max(a - x, x - a);
        db = Math.Max(b - x, x - b);
        Console.WriteLine((da < db) ? "A" : "B");
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct Cake{
	int w;
	int h;
	int men;
};

int main() {
	int n, w, h;
	while (cin >> n >> w >> h, n | w | h){
		vector<Cake> vca;
		vca.push_back({ w, h,w*h });
		REP(i, n){
			int p, s;
			cin >> p >> s;
			s = s % (vca[p - 1].w + vca[p - 1].h);
			if (s < vca[p - 1].w){
				int w1 = min(s, vca[p - 1].w - s);
				int w2 = max(s, vca[p - 1].w - s);
				int h = vca[p - 1].h;
				vca.erase(vca.begin() + p - 1);
				vca.push_back({ w1, h, w1* h });
				vca.push_back({ w2, h, w2* h });
			}
			else{
				int w = vca[p - 1].w;
				int h1 = min((s - w), vca[p - 1].h - (s - w));
				int h2 = max((s - w), vca[p - 1].h - (s - w));
				vca.erase(vca.begin() + p - 1);
				vca.push_back({ w, h1, w* h1 });
				vca.push_back({ w, h2, w* h2 });
			}

		}
		vector<int> vi;

		REP(i, vca.size())vi.push_back(vca[i].men);
		SORT(vi);
		REP(i, vi.size()){
			cout << vi[i] ;
			if (i != vi.size() - 1)cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cmath>

#define eps 1e-9
double sgn(double x){
	if(x<-eps)return -1;
	if(x>eps)return 1;
	return 0;
}
struct pnt{
	double x,y;
	pnt(){}
	pnt(double _x,double _y){x=_x;y=_y;}
	void inp(){scanf("%lf%lf",&x,&y);}
	double ang(){return atan2(y, x);}
};
pnt operator+(const pnt&a,const pnt&b){
	return pnt(a.x+b.x,a.y+b.y);
}
pnt operator-(const pnt&a,const pnt&b){
	return pnt(a.x-b.x,a.y-b.y);
}
pnt operator*(const pnt&a,double x){
	return pnt(a.x*x,a.y*x);
}
pnt operator/(const pnt&a,double x){
	return pnt(a.x/x,a.y/x);
}
double operator%(const pnt&a,const pnt&b){
	return a.x*b.x+a.y*b.y;
}
double operator*(const pnt&a,const pnt&b){
	return a.x*b.y-a.y*b.x;
}
pnt intersect(const pnt&a,const pnt&b,const pnt&c,const pnt&d){
	double t = ((a-c) * (c-d)) / ((a-b) * (c-d));
	return a + (b-a) * t;
}

pnt a[111];int n;
const double pi = acos(-1.0);

double norm(double x){
	while(x < -pi)x += 2 * pi;
	while(x > pi)x -= 2 * pi;
	return x;
}
double len(double s,double e){
	e -= s;
	while(e < 0)e += 2 * pi;
	while(e > 2 * pi)e -= 2 * pi;
	return e;
}
bool in(double x,double s,double e){
	if(s < e)return s <= x && x <= e;
	return x >= s || x <= e;
}
bool chk(double x,double y){
	x -= y;
	return sgn(x) == 0 || sgn(x - 2 * pi) == 0 || sgn(x + 2 * pi) == 0;
}
bool inter(double&s1,double&e1,double s2,double e2){
	if((!in(s1, s2, e2) || chk(s1, e2)) && (!in(e1, s2, e2)||chk(e1,s2)))return false;
	double newS, newE;
	if(in(s2, s1, e1))
		newS = s2;
	else
		newS = s1;
	if(in(e2, s1, e1))
		newE = e2;
	else
		newE = e1;
	s1 = newS;
	e1 = newE;
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		a[i].inp();
	for(int i=1; i<=n; i++){
		int ff = 1;
		double ss, ee;
		for(int j=1; j<=n; j++)if(i!=j){
			double mid = (a[j] - a[i]).ang();
			double S = norm(mid + pi / 2), E = norm(mid - pi / 2);
			if(ff == 1){
				ff = 0;
				ss = S;
				ee = E;
			}else{
				if(!inter(ss, ee, S, E)){
					ff = -1;
					break;
				}
			}
		}
		double ret;
		if(ff == -1)
			ret = 0;
		else
			ret = len(ss, ee)/ (2 * pi);
		if(ret > 0.7)ret = 0;
		printf("%.12lf\n",ret);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string a,b,x,y;
  cin >> a >> b;
  if(a=="H"){
    x=a;
    if(b=="H"){
        y="H";
    }
    else{
        y="D";
    }
  }
  if(a=="D"){
    x=a;
    if(b=="H"){
        y="D";
    }
    else{
        y="H";
    }
  }
  cout << y;
}

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

typedef long long ll;
#define pll pair<ll, ll>
#define REP(i, n) for(ll i=0; i<n; i++)
#define F first
#define S second

ll pow(ll x, ll n) {
    ll ret = 1;
    while(0 < n) {
        if((n % 2) == 0) {
            x *= x;
            n /= 2;
        }else{
            ret *= x;
            --n;
        }
    }
    return ret;
}

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

    ll cnt = 0;
    while(H > 1) {
        H = H /2;
        cnt += 1;
    }

    ll ans = 0;
    for(ll i=0; i<cnt+1; i++) {
        ans += pow(2, i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M,K,fac[MAXN],invfac[MAXN],pw[MAXN];
int s[MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int C(int n,int m) {
    if(n < m) return 0;
    else return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;	
    }
    return res;
}
void Solve() {
    read(N);read(M);read(K);
    fac[0] = 1;
    for(int i = 1 ; i <= 1000000 ; ++i) fac[i] = mul(fac[i - 1],i);
    invfac[1000000] = fpow(fac[1000000],MOD - 2);
    for(int i = 999999 ; i >= 0 ; --i) invfac[i] = mul(invfac[i + 1],i + 1);
    pw[0] = 1;
    for(int i = 1 ; i <= 1000000 ; ++i) pw[i] = mul(pw[i - 1],3);
    int l = 0,r = 0;s[0] = 1;
    for(int i = 1 ; i <= M + K ; ++i) {
	int tmp = inc(mul(s[i - 1],2),inc(C(i - 1,r + 1),MOD - C(i - 1,l)));
	++r;++l;
	while(r + 1 <= i && r + 1 <= M) {update(tmp,C(i,r + 1));++r;}
	while(r > M) {update(tmp,MOD - C(i,r));--r;}
	while(i - l > K) {update(tmp,MOD - C(i,l));++l;}
	while(i - (l - 1) <= K && (l - 1) >= 0) {update(tmp,C(i,l - 1));--l;}
	s[i] = tmp;
    }
    int ans = 0;
    for(int i = 0 ; i <= M + K ; ++i) {
	int t = mul(C(N - 1 + i,N - 1),s[i]);
	t = mul(t,pw[M + K - i]);
	update(ans,t);
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 15872
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define rep(i, N) for(int i=0; i<(int)N; i++)
#define rrep(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;

int order_time(int t) {
  while(t % 10 != 0) t++;
  return t;
}

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

  int xi = 0, x = 10;
  rep(i, 5){
    if(a[i]%10!=0 && x > a[i]%10) {
      xi = i;
      x = a[i]%10;
    }
  }

  int _sum = 0;
  rep(i, 5) {
    if(i == xi) _sum += a[i];
    else _sum += order_time(a[i]);
  }
  cout << _sum << endl;
}

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;
int main(){
    int n,k;
    cin>>n>>k;
    vector<double>p(n);
    double ans=0;
    rep(i,n){
        double a; cin>>a;
        p[i]=a/2+0.5;
    }
    rep(i,k){
        ans+=p[i];
    }
    double mx=ans;
    rep(i,n-k){
        ans-=p[i];
        ans+=p[i+k];
        mx=max(mx,ans);
    }
    printf("%.10f",mx);
}

Measured memory_bytes: 1792