akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
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! {
        n: i64,
        m: i64,
    }
    if n >=3 && m >= 3 {
        println!("{}", (n-2) * (m-2));
    } else if n == 2 || m == 2 {
        println!("0");
    } else if n == 1 && m == 1 {
        println!("1");
    } else if n == 1 {
        println!("{}", m - 2)
    } else if m == 1 {
        println!("{}", n - 2);
    }
}

Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]
dp=[0]*W
if S[0][0]=='#':
  dp[0]=1
for j in range(1,W):
  if S[0][j]!=S[0][j-1] and S[0][j-1]=='.':
    dp[j]=dp[j-1]+1
  else:
    dp[j]=dp[j-1]
for i in range(1,H):
  if S[i][0]!=S[i-1][0] and S[i-1][0]=='.':
    dp[0]=dp[0]+1
  for j in range(1,W):
    hidari=1 if S[i][j]!=S[i][j-1] and S[i][j-1]=='.' else 0
    ue=1 if S[i][j]!=S[i-1][j] and S[i-1][j]=='.' else 0
    dp[j]=min(dp[j-1]+hidari,dp[j]+ue)
print(dp[-1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
const int mod=1e9+7;

int main(void){
    ll n,m;
    cin>>n>>m;
    vector<ll> x(n+1),y(m+1);
    REP(i,1,n+1)cin>>x[i];
    REP(i,1,m+1)cin>>y[i];
    ll tx=0,ty=0;
    REP(i,1,n+1)tx+=(2*i-1-n)*x[i];
    REP(i,1,m+1)ty+=(2*i-1-m)*y[i];
    tx%=mod;
    tx*=ty%mod;
    cout<<tx%mod<<endl;
    return 0;
}


Measured memory_bytes: 1792
#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;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) {
        int ai;
        cin >> ai;
        a[i] = ai;
    }
    rep(i,n) {
        int bi;
        cin >> bi;
        b[i] = bi;
    }

    int ans = 0;
    rep(i,n) {
        int sum = 0;
        for (int u=0; u<=i; u++) sum += a[u];
        for (int l=i; l<n; l++) sum += b[l];
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long X, Y;
  cin >> X >> Y;
  long long A = (X * 2 + Y) / 3;
  long long B = (Y * 2 + X) / 3;
  if ((A ^ B) != 0){
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, k, m=1e9+7, cnt[100009], f[100009],ph[100009];
vector<int> v[100009];
ll ans;
ll fastpower(ll b, ll p)
{
    if(p == 0)
        return 1 ;
    return p % 2 == 0 ? fastpower((b * b) % m, p / 2) : (b * fastpower((b * b) % m, p / 2) % m) % m;
}
void solve()
{
    for(int i=1; i<=k; i++)
    {
        for(int j=i; j<=k; j+=i)
            v[j].push_back(i);
        cnt[i]=k/i;
        if(i==1)
            ph[i]=1;
        else if(v[i].size()==2)
            ph[i]=-1;
        else if(i%(1LL*v[i][1]*v[i][1])==0)
            ph[i]=0;
        else
            ph[i]=-ph[i/v[i][1]];
    }
    for(int i=1; i<=k; i++)
        for(auto j : v[i])
            f[j]=(1LL*f[j]+1LL*fastpower(cnt[i],n)*ph[i/j])%m;
    for(int i=1; i<=k; i++)
    {
        ans+=1LL*f[i]*i;
        ans%=m;
    }
    cout<<(ans+m)%m;
}
int main()
{
    IO
    cin>>n>>k;
    solve();
}


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

#define pb push_back
#define ll long long
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<n;i++)

using namespace std;

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

	ll n; cin>>n;

	ll a[n+2],b[n+1];

	f(i,1,n+2) cin>>a[i];
	f(i,1,n+1) cin>>b[i];

	ll ans=0;
	f(i,1,n+1){
		ans+=min(a[i]+a[i+1],b[i]);
		a[i+1]=max(0ll,a[i+1]-max(0ll,b[i]-a[i]));
	}
	// ans+=(min(a[n],b[n]));
	cout<<ans;


	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;

static const ll INF = (ll)1 << 62;

int main() {
	ll a, b, c; cin >> a >> b >> c;
	ll ans = 0;
	while (1) {
		if (a & 1 || b & 1 || c & 1) {
			break;
		}
		ll A = 0, B = 0, C = 0;
		C += a / 2 + b / 2;
		B += a / 2 + c / 2;
		A += b / 2 + c / 2;

		if (a == A && b == B && c == C) {
			cout << -1 << endl;
			return 0;
		}

		a = A;
		b = B;
		c = C;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a_ls = list(map(int, input().split()))
break_cnt = 0
now_figure = 0
for i in range(len(a_ls)):
    if (now_figure+1) == a_ls[i]:
        now_figure+=1
    else:
        break_cnt+=1
if now_figure == 0:
    print(-1)
else:
    print(break_cnt)


Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string x,y,z;
    cin>>x>>y>>z;
    cout<<x[0]<<y[1]<<z[2]<<endl;

    return 0;
}


Measured memory_bytes: 3644
import sys
from collections import Counter
n = int(input())
ls = []
if n == 1:
    print(1)
else:
    for i in range(n):
        x, y = [int(i) for i in sys.stdin.readline().split()]
        ls.append((x, y))
    res = []
    for i in range(n - 1):
        for j in range(i+1, n):
            res.append((ls[j][0] - ls[i][0], ls[j][1] - ls[i][1]))
            res.append((- ls[j][0] + ls[i][0], - ls[j][1] + ls[i][1]))
    ct = Counter(res)
    print(n - max(ct.values()))

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s;
  cin >> s;

  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
class Stack():
    def __init__(self):
        self.top = -1
        self.lists = []
    def push(self,x):
        self.top += 1
        self.lists.append(0)
        self.lists[self.top] = x
    def pop(self):
        if self.top >= 0:
            self.top -= 1
            return self.lists[self.top+1]
        else :
            print("Error")
def main():
    input_list = [i for i in input().split()]
    stack = Stack()
    for i in range(len(input_list)):
        if input_list[i] == '+':
            number_1 = stack.pop()
            number_2 = stack.pop()
            stack.push(number_2+number_1)
        elif input_list[i] == '-':
            number_1 = stack.pop()
            number_2 = stack.pop()
            stack.push(number_2-number_1)
        elif input_list[i] == '*':
            number_1 = stack.pop()
            number_2 = stack.pop()
            stack.push(number_2 * number_1)
        else:
            stack.push(int(input_list[i]))
    print(stack.lists[stack.top])
if __name__ == "__main__":
    main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector

int main(void)
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  string s; cin >> s;

  rep(i,s.size() - 1)
    if(s[i] == s[i + 1]){
      cout << i + 1 << " " << i + 2 << endl;;
      return 0;
    }

  rep(i,s.size() - 2)
    if(s[i] == s[i + 2]){
      cout << i  + 1 << " " << i + 3 << endl;
      return 0;
    }

  cout << "-1 -1\n";
}

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

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

    if((a == b) && (a == c) && (b == c)
    || (a != b) && (a != c) && (b !=c))
        cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
    }
        
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;++i)
int cnt = 0;
void mysort(vector<int>&a) {
	int n = a.size();
	rep(i, n - 1)
	{
		for (int j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j-1],a[j]);
				cnt++;
			}
		}
	}
}
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	mysort(a);
	rep(i, n) {
		if (i != 0) { cout << " "; }
		cout << a[i];
	}
	cout << endl << cnt<< endl;
	return 0;
}


Measured memory_bytes: 3100
import sys
sys.setrecursionlimit(1000000)
memo = {0:1}
def fact(num):
  if num in memo:return memo[num]
  memo[num] = num * fact(num - 1)
  return memo[num]
n = int(input())
print(fact(n + 1) + 2)
for i in range(n):
  print(i + 2)


Measured memory_bytes: 8356
# -*- coding: utf-8 -*-
while 1:
    (H,W) = [int(i) for i in input().split()]
    if H==W==0:
        break
    for i in range(H):
        for j in range(W):
            if (i+j)%2==0: print('#',end="")
            else: print('.',end="")
        print('')
    print('')

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 5;
const int M = 2e5 + 5;

int n, m, tot, head[M], indeg[N];

struct Edge {
    int v, w, nxt;
} edge[M];

void add(int u, int v, int w) {
    edge[tot].v = v;
    edge[tot].w = w;
    edge[tot].nxt = head[u];
    head[u] = tot++;
}

int vis[N];
LL dis[N], mx;

bool bfs(int u) {
    memset(vis, 0, sizeof(vis));
    queue <int> q; q.push(u); vis[u] = 1;
    dis[u] = 0; mx = 0;
    while (!q.empty()) {
        u = q.front(); q.pop();
        mx = max(mx, dis[u]);
        if (mx > (LL) 1e9) return 0;
        for (int i = head[u]; ~i; i = edge[i].nxt) {
            int v = edge[i].v, w = edge[i].w;
            if (dis[v] == -1) {
                dis[v] = dis[u] + w;
            } else if (dis[v] != dis[u] + w) {
                return 0;
            }
            if (!vis[v]) {
                vis[v] = 1;
                q.push(v);
            }
        }
    }
    return 1;
}

int topsort() {
    queue <int> q;
    int in[N];
    for (int i = 1; i <= n; ++i) {
        in[i] = indeg[i];
        if (in[i] == 0) q.push(i);
    }
    int k = 0, flag = 0;
    while (!q.empty()) {
        if (q.size() != 1) flag = 1;
        int u = q.front(); q.pop();
        k++;
        for (int i = head[u]; ~i; i = edge[i].nxt) {
            int v = edge[i].v;
            in[v]--;
            if (in[v] == 0) q.push(v);
        }
    }
    if (k < n) return -1;
    if (flag) return 0;
    return 1;
}

int main() {
    memset(head, -1, sizeof(head));
    memset(dis, -1, sizeof(dis));
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        add(u, v, w);
        indeg[v]++;
    }
    if (topsort() == -1) {
        puts("No");
        return 0;
    }
    for (int i = 1; i <= n; ++i) {
        if (indeg[i] == 0) {
            if (!bfs(i)) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 5708
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int a,b;
  string str;
  cin >> a >> b >> str;
  int ln = str.size();
  for(int i = 0; i < ln; i++){
    if(i != a && str[i] == '-'){
      cout << "No" << endl; return 0;
    }
  }
  if(str[a] != '-'){
    cout << "No" << endl; return 0;
  } else {
    cout << "Yes" << endl; return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k;
#define N 100005
int a[N];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k;
	for (int i = 0 ; i < n ; ++i) {
		cin >> a[i];
	}
	int ans = (n - 1) / (k - 1);
	if (ans * (k - 1) < (n - 1)) ++ans;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int N, K;
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        N = int.Parse(s[0]);
        K = int.Parse(s[1]);
        int ans = K;
        for(int i = 1; i < N; i++)
        {
            ans *= K - 1;
        }
        Console.WriteLine(ans);
    }
   
}




Measured memory_bytes: 2772
unittest
{
	assert( [ "Sunny" ].parse.expand.solve == "Cloudy" );
	assert( [ "Rainy" ].parse.expand.solve == "Sunny" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	if( s == "Sunny"  ) return "Cloudy";
	if( s == "Cloudy" ) return "Rainy";
	if( s == "Rainy"  ) return "Sunny";
	assert( false );
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli x,y;

int main(){
    cin >> x >> y;
    if(x - y == 0 || x - y == 1 || y - x == 1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
      bb: [usize; n],
      cc: [usize; n],
    }
    let mut aa = aa;
    let mut bb = bb;
    let mut cc = cc;
    aa.sort();
    bb.sort();
    cc.sort();

    let mut sb : Vec<usize> = vec![0; n+1];

    {
        let mut ci = 0;
        for bi in 0..n {
            let b = bb[bi];
            while ci < n {
                if cc[ci] > b { break; }
                ci += 1;
            }
            sb[bi+1] = sb[bi] + n - ci;
        }
    }

    let mut ans = 0;
    let mut bi = 0;
    for ai in 0..n {
        let a = aa[ai];
        while bi < n {
            if bb[bi] > a { break; }
            bi += 1;
        }
        ans += sb[n] - sb[bi]
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from bisect import bisect_left

n = getN()
nums = getList()

ans = [0 for i in range(n)]

for i, num in enumerate(nums):
    ans[num-1] = i+1

print(*(ans))

Measured memory_bytes: 56732
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

int main() {
	double a, b;
	cin >> a >> b;
	printf("%.10lf\n", (a * b) / (a + b));
}

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

void solve() {
    double L;
    cin >> L;
    double third =  L / 3.0;
    cout << fixed << setprecision(10) << third * third * third << endl;
}

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


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

vector<int> f() {
  vector<bool> n(55556, true);
  n[0] = false, n[1] = false;
  for (int i = 2; i * i <= 55555; ++i) {
    if (n[i]) {
      for (int j = i * i; j <= 55555; j += i)
        n[j] = false;
    }
  }

  vector<int> res(1);
  for (int i = 2; i <= 55555; ++i)
    if (n[i] && i % 5 == 1)
      res.push_back(i);

  return res;
}

int main() {
  int N;
  cin >> N;
  vector<int> p = f();
  for (int i = 1; i <= N; ++i) {
    if (i == N)
      cout << p[N] << endl;
    else
      cout << p[i] << ' ';
  }
}

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

string s;

int main()
{
    cin >> s;
    if (s == "RRR") printf("3\n");
    else if (s == "RRS" || s == "SRR") printf("2\n");
    else if (s == "SSS") printf("0\n");
    else printf("1\n");
    return 0;
}


Measured memory_bytes: 3584
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    t = 0
    for j in range(m):
        t += a[i][j] * b[j]
    if t + c > 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import sys

def comb(n, r, mod=None):
    if r == 0 or r == n:
        return 1
    r = min([r, n-r])
    x, y = 1, 1
    ans = 1
    for i in range(1, r+1):
        if mod:
            x *= n+1-i
            y *= i
            x %= mod
            y %= mod
        else:
            ans *= n+1-i
            ans //= i
    ans = x*pow(y, mod-2, mod)%mod if mod else ans
    return ans

def main():
    input = sys.stdin.readline
    h, w, a, b = map(int, input().split())
    mod = pow(10, 9)+7
    
    bef, aft = 1, comb(h+w-b-2, h-1, mod)
    ans = 0
    for i in range(h-a):
        ans += bef*aft
        ans %= mod
        
        bef = bef*(i+b)*pow(i+1, mod-2, mod)%mod
        aft = aft*(h-i-1)*pow(h-i+w-b-2, mod-2, mod)%mod
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from collections import defaultdict
H, W, K = map(int, input().split())  # H行, W列, 1エリア内にK個以下のホワイトチョコレートにしたい
gridgraph = [list(input()) for _ in range(H)]
ans = 10**10
# Hに関するビット全探索を行うイメージ
for i in range(1 << (H-1)):
    bits = []
    for j in range(H-1):
        bits.append((i >> j) & 1)  # iのjビット目が立っているかどうかを調べる
    separate_row = True
    cnt = sum(bits)  # 横に切る場所, 最終的に ans = min(ans, cnt)をする
    all_accumulation = defaultdict(int)
    # その列を区切るか区切らないかを貪欲法で判断していく
    for j in range(W):
        now_area = 0
        now_accumulation = defaultdict(int)
        for i in range(H):
            # iが変動していく
            # 今見ている列のものだけも、数えておく必要がある
            now_accumulation[now_area] += int(gridgraph[i][j])
            if i != H-1:
                now_area += bits[i]
        # その列を見終わったら、cntをインクリメントすることでリセットできる
        if all([K >= v for v in now_accumulation.values()]):
            for key in now_accumulation.keys():
                all_accumulation[key] += now_accumulation[key]
            # 累積されていたものに足した
            if all([K >= v for v in all_accumulation.values()]):
                continue
            else:
                cnt += 1
                # 今見ていたところの左側を分割して、累積部分の値を現在のものに変更する
                all_accumulation = now_accumulation.copy()
        else:
            # その行だけを見てもKを超えるものがあるなら行の分割の仕方が論外
            separate_row = False
            break
    if separate_row:
        ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 55384
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
N, K = map(int, input().split())
P = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

P.sort()
print(sum(P[:K]))

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

int main() {
    string S_a, S_b, S_c;
    cin >> S_a >> S_b >> S_c;
    int i = 0, j = 0, k = 0;
    char next_tern = S_a[0];
    while(i <= S_a.size() && j <= S_b.size() && k <= S_c.size()) {
        if(next_tern == 'a') {
            next_tern = S_a[i++];
        } else if(next_tern == 'b') {
            next_tern = S_b[j++];
        } else {
            next_tern = S_c[k++];
        }
//cout << next_tern << endl;
    }
    char ans;
    if(i > S_a.size()) {
        ans = 'A';
    } else if(j > S_b.size()) {
        ans = 'B';
    } else {
        ans = 'C';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let a:usize = read();
    let b:usize = read();
    println!("{}", a * (n / (a+b)) + min(a, n%(a+b)));
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v)
      return false;
    if (parent[u] > parent[v])
      swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool issame(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

struct edge {
  int from, to;
  ll cost;

  edge(int from, int to, ll cost) : from(from), to(to), cost(cost) {}

  bool operator<(const edge& o) const {
    return cost < o.cost;
  }
};

int V, E;
vector<edge> G;

/* O(E log V) */
ll kruskal() {
  sort(G.begin(), G.end());

  UnionFind uf(V);
  ll min_cost = 0;

  for (int ei = 0; ei < E; ei++) {
    edge e = G[ei];
    if (!uf.issame(e.from, e.to)) {
      min_cost += e.cost;
      uf.unite(e.from, e.to);
    }
  }

  return min_cost;
}

int main() {
  int N;
  cin >> N;
  vector<ll> x(N), y(N);
  typedef pair<ll, int> P;

  vector<P> X(N), Y(N);
  rep(i, N) {
    cin >> x[i] >> y[i];
    X[i] = mp(x[i], i);
    Y[i] = mp(y[i], i);
  }

  sort(all(X));
  sort(all(Y));

  V = N;
  E = 2 * (N - 1);
  rep(i, N - 1) {
    G.pb(edge(X[i].se, X[i + 1].se, abs(X[i].fi - X[i + 1].fi)));
    G.pb(edge(Y[i].se, Y[i + 1].se, abs(Y[i].fi - Y[i + 1].fi)));
  }

  cout << kruskal() << endl;
}

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

typedef pair <int, int> pii;

const int MaxN = 200000 + 5;

int N;
int A[MaxN];
vector <pii> vec;

void init() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
}

bool is_increase() {
    for (int i = 2; i <= N; ++i)
        if (A[i] <= A[i - 1]) return false;
    return true;
}

inline bool check(int m) {
    vec.clear();

    vec.push_back(make_pair(1, 0));
    int id = A[1]; if (id != 1) vec.push_back(make_pair(id, 0));
    for (int i = 2; i <= N; ++i) {
        /* printf("m = %d, i = %d\n", m, i);
        for (auto v : vec) {
            printf("[%d, %d]\n", v.first, v.second);
        } */
        if (A[i] > id) {
            id = A[i];
            vec.push_back(make_pair(id, 0));
        } else if (A[i] == id) {
            if ((vec.end() - 1) -> first != id) vec.push_back(make_pair(id, 0));

            int worst = id;
            while ((vec.end() - 1) -> second == m - 1) {
                worst = (vec.end() - 1) -> first - 1;
                vec.erase(vec.end() - 1);
                if (vec.empty() == true) return false;
                if ((vec.end() - 1) -> first != worst)
                    vec.push_back(make_pair(worst, 0));
            }

            pii p = *(vec.end() - 1);
            p.second++;
            vec.erase(vec.end() - 1);
            vec.push_back(p);

            if ((vec.end() - 1) -> first != id) vec.push_back(make_pair(id, 0));
        } else {
            id = A[i];
            while ((vec.end() - 1) -> first > id) {
                vec.erase(vec.end() - 1);
                if (vec.empty() == true) return false;
            }

            if ((vec.end() - 1) -> first != id) vec.push_back(make_pair(id, 0));

            int worst = id;
            while ((vec.end() - 1) -> second == m - 1) {
                worst = (vec.end() - 1) -> first - 1;
                vec.erase(vec.end() - 1);
                if (vec.empty() == true) return false;
                if ((vec.end() - 1) -> first != worst)
                    vec.push_back(make_pair(worst, 0));
            }

            pii p = *(vec.end() - 1);
            p.second++;
            vec.erase(vec.end() - 1);
            vec.push_back(p);

            if ((vec.end() - 1) -> first != id) vec.push_back(make_pair(id, 0));
        }

        // printf("m = %d, id = %d\n", m, id);
    }

    return true;
}

void solve() {
    if (is_increase() == true) {
        cout << 1 << endl;
        return;
    }

    int lbound = 2, rbound = N, ans;
    while (lbound <= rbound) {
        int mid = (lbound + rbound) >> 1;
        if (check(mid) == true) {
            ans = mid;
            rbound = mid - 1;
        } else {
            lbound = mid + 1;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1660
#include<stdio.h>
int main(void){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x-r<0 || x+r>w || y-r<0 || y+r>h){
		printf("No\n");
	}else printf("Yes\n");
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  N++;
  
  vector<int> n(N);
  vector<int> m(M);

  int a, b;
  
  for(int i=0; i<M; i++){
    cin >> a >> b;
    
    n.at(a) += 1;
    n.at(b) += 1;
  }
  
  for(int i=1; i<N; i++){
    cout << n.at(i) << endl;
  }
}


Measured memory_bytes: 3592
# -*- coding: utf-8 -*-

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:    # a[i]がKより大きいなら計算する必要なし
        break
    while b[j] > K - a[i]: # b[j] が K - a[i] 以下になるまで繰り返す
        j -= 1
    # 最大値を常に計算する
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47556
using System;

class Program
{
  /// <summary>
  ///   The main entry point for the application
  /// </summary>
  [STAThread]
  public static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    string a = Console.ReadLine();
    string b = Console.ReadLine();
    string c = Console.ReadLine();
    int count = 2 * n;
    for (int i = 0; i < n; i++)
    {
      if(a[i] == b[i] && b[i] != c[i]) count --;
      if(a[i] != b[i] && b[i] == c[i]) count --;
      if(a[i] != b[i] && a[i] == c[i]) count --;
      if(a[i] == b[i] && b[i] == c[i]) count -= 2;
    }
    Console.WriteLine(count);
  }
}


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

int main(int argc, char const *argv[])
{
	int a,b,c;
	string s;

	cin >> a >> b >> c;
	
	if (a < b && b < c) s = "Yes";
	else s = "No";

	cout << s << endl;

	return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

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

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
typedef priority_queue<int, vector<int>, greater<int> > heapq;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int N, D; cin >> N >> D;
    cout << (N + D * 2) / (D * 2 + 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ESP 1e-5

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
	cin >> a[i];
    }
    int front_max = a[0];
    ll ans = 0;
    for(int i = 0; i < n; i++){
	if(a[i] > front_max){
	    front_max = a[i];
	}else if(a[i] < front_max){
	    ans += front_max - a[i];
	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3988
n = gets.chomp.to_i

an = gets.chomp.split(" ").map(&:to_i);
bn = gets.chomp.split(" ").map(&:to_i);
cn = gets.chomp.split(" ").map(&:to_i);

before = -1
sum = 0

an.each do |a|
   #puts "#{before} - #{a}"
   sum += cn[a-2] if before  == a - 1
   before = a
end
bn.each { |b| sum += b }

puts (sum)

Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int n;
	scanf("%d", &n);

	int benefit = -1000000000;
	int Rj;
	scanf("%d", &Rj);

	for (int i = 1; i < n; ++i) {
		int Rt;
		scanf("%d", &Rt);

		int tmp = Rt - Rj;
		if (tmp > benefit)
			benefit = tmp;

		if (Rt < Rj)
			Rj = Rt;
	}
	cout << benefit << endl;

	return 0;
}

Measured memory_bytes: 3164
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (a + b + c - std::max({ a,b,c })) << std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[26];
char c=getchar();
int main(){
  while(c>='a'&&c<='z'){
    a[c-'a']++;
    c=getchar();
  }
  for(int i=0;i<26;i++){
    if(a[i]==0){
      putchar(i+'a');
      return 0;
    }
  }
  puts("None");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define se second
#define ll long long
#define pb push_back
using namespace std;
 
const ll INF = 1e16 + 1;
const ll N = 2e3 + 5;			
const ll mod = 1e9 + 7;
const long double eps = 1E-7;
 
int res;
int main()
{
	 int x , y;
    cin >> x >> y;
    for(int i=0; i<=x; i++){
        int x2 = i * 2;
        int x3 = (x - i) * 4;
        if(x2 + x3 == y)
            return cout << "Yes", 0;
    }
    cout << "No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct Combinations {

    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;

    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }

    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }

    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }

    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }

};

ll N,K;
const ll MOD = 1000000007LL;

int main ()
{
    cin >> N >> K;
    Combinations inst(10000, MOD);

    for (ll i = 1LL; i <= K; i++) {
        ll ans = inst.nCr(N - K + 1, i) * inst.nHr(i, K - i);

        cout << ans % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] s = new char[101];
        int n = in.read(s);
        
        int ans = Integer.MAX_VALUE;
        for (char c = 'a'; c <= 'z'; c++) {
            s[n] = c;
            int max = 0;
            for (int i = 0, cnt = 0; i <= n; i++) {
                if (s[i] == c) {
                    max = Math.max(max, cnt);
                    cnt = 0;
                } else {
                    cnt++;
                }
            }
            ans = Math.min(ans, max);
        }
        
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32588
#include <iostream>
using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;

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

int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

void relax(int u, int v, int* d, int** mat){ 
    if(d[v] > d[u] + mat[u][v]) d[v] = d[u] + mat[u][v];
}

void dijkstra(int n, int** mat, int* d){
    int cur_v = 0;
    int* visited = new int[n];
    rep(i, 0, n) visited[i] = 0;
    d[cur_v] = 0;
    while(true){
        visited[cur_v] = 1;
        rep(j, 0, n){
            if(mat[cur_v][j] > -1){
                relax(cur_v, j, d, mat); 
            }
        }
        // pick next cur_v (with minimum unvisited)
        int min_visited = inf;
        int next_v = -1;
        rep(k, 0, n){
            if(!visited[k] && d[k] < min_visited){
                min_visited = d[k];
                next_v = k;
           }
        }
        if(next_v == -1) break;
        cur_v = next_v;
    } 
}


int main(){
    int n;
    cin >> n;
    int** mat = new int*[n];
    rep(i, 0, n){
        mat[i] = new int[n];
        rep(j, 0, n){
            mat[i][j] = -1;
        }
    }

    rep(i, 0, n){
        int v;
        int k;
        cin >> v >> k;
        rep(j, 0, k){
            int vout, c;
            cin >> vout >> c;
            mat[v][vout] = c;
        }
    }
    int* d = new int[n];
    rep(i, 0, n){ d[i] = inf; }
    dijkstra(n, mat, d);
    rep(i, 0, n){
        cout << i << " " << d[i] << endl;
    }


    return 0;
}





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

int main() {
  
  int A, B;
  cin >> A >> B;
  int out;
  out = ((B - 1) / (A - 1));
  if((B - 1) % (A - 1) != 0){
    out++;
  }

  cout << out;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(v, pv):
    for nv in g[v]:
        if nv == pv:
            continue
        cnt[nv] += cnt[v]
        dfs(nv, v)


(N, Q), *ABPX = [list(map(int, s.split())) for s in open(0)]
g = [set() for _ in range(N)]
for a, b in ABPX[:N - 1]:
    g[a - 1].add(b - 1)
    g[b - 1].add(a - 1)

cnt = [0] * N
for p, x in ABPX[N - 1:]:
    cnt[p - 1] += x
dfs(0, -1)
print(*cnt)


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

const int N = 1e5 + 5;
typedef long long LL;

int n;
LL a[N], ans;

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

	return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

struct segtree {
    vector<int> lazy, dat;
    int n;

    segtree(int n_, int init){
        n = 1;
        while(n < n_) n *= 2;
        dat.assign(n*2, init);
        lazy.assign(n*2, -1);
    }

    void set(int l, int r, int x){
        set(l, r, x, 0, n, 1);
    }

    void set(int l, int r, int x, int segl, int segr, int n){
        push(segl, segr, n);
        if(segr <= l || r <= segl);
        else if(l <= segl && segr <= r) lazy[n] = x;
        else {
            int segm = (segl + segr) / 2;
            set(l, r, x, segl, segm, n*2);
            set(l, r, x, segm, segr, n*2+1);
        }
    }

    int get(int k){
        return get(k, 0, n, 1);
    }

    int get(int k, int segl, int segr, int n){
        push(segl, segr, n);
        if(segl + 1 == segr) return dat[n];
        int segm = (segl + segr) / 2;
        if(k < segm) return get(k, segl, segm, n*2);
        else return get(k, segm, segr, n*2+1);
    }

    void push(int segl, int segr, int node){
        if(lazy[node] != -1){
            dat[node] = lazy[node];
            if(segl + 1 != segr){
                lazy[node*2] = lazy[node];
                lazy[node*2+1] = lazy[node];
            }
            lazy[node] = -1;
        }
    }
};

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

    int n, q;
    cin >> n >> q;
    segtree st(n, 2147483647);
    for(int iq = 0; iq < q; ++iq){
        int t;
        cin >> t;
        // dump(t);
        if(t == 0){
            int s, t, x;
            cin >> s >> t >> x;
            ++t;
            st.set(s, t, x);
        } else {
            int i;
            cin >> i;
            cout << st.get(i) << '\n';
        }
    }
}

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

using namespace std;

#define N 100

int mat[N + 2][N + 2];
int a[N * N + 1];

int main(){
	int h, w, n, i, j, k;

	scanf("%d%d", &h, &w);
	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		scanf("%d", a + i);
	}

	for (i = 1, k = 1; i <= h; i++){
		for (j = 1; j <= w; j++){
			mat[i][j] = k;

			a[k]--;

			if (!a[k]){
				k++;
			}
		}

		i++;

		if (i > h){
			break;
		}

		for (j = w; j >= 1; j--){
			mat[i][j] = k;

			a[k]--;

			if (!a[k]){
				k++;
			}
		}
	}

	for (i = 1; i <= h; i++){
		for (j = 1; j < w; j++){
			printf("%d ", mat[i][j]);
		}

		printf("%d\n", mat[i][j]);
	}

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[100];

int pop()
{
	top--;
	return S[top+1];
}

void push(int x)
{
	S[++top] = x;
}

int main()
{
	char ch[10];
	int a, b;
	top = 0;
	//freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    while(scanf("%s", ch) != EOF)
    {
    	if(ch[0] == '+')
    	{
			a = pop();
			b = pop();
			push(a + b); 
		}
		else if(ch[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a); 
		}
		else if(ch[0] == '*')
		{
			a = pop();
			b = pop();
			push(a * b); 
		}
		else
			push(atoi(ch));
	}
	printf("%d\n", pop());
    //printf("%lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 548
import sys


def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]

    hash = []
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                hash.append((h, w))

    if hash == []:
        print('Impossible')
        sys.exit()

    s = hash[0]

    nd = ((1, 0), (0, 1))

    q = [s]
    cnt = 1
    while q:
        x0, y0 = q[0]
        del q[0]
        for dx, dy in nd:
            x = x0 + dx
            y = y0 + dy
            if x < H and y < W:
                if A[x][y] == "#":
                    cnt += 1
                    q.append((x, y))
                    break

    if cnt == len(hash):
        print('Possible')
    else:
        print('Impossible')

main()


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

using namespace std;

int main(){
  int A, B, C, X, Y;
  int ans;
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
  if (A+B < 2*C){
    ans = A * X + B * Y;
  }
  else{
    if (X > Y){
      int tmp = X;
      X = Y;
      Y = tmp;
      tmp = A;
      A = B;
      B = tmp;
    }
    ans = X * (2 * C);
    if (B <= 2*C){
      ans += (Y - X) * B;
    }
    else{
      ans += (Y - X) * 2 * C;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,dp[100005][2];
vi a[100005];
int dfs(int node,int col,int par){
    if(dp[node][col]!=-1) return dp[node][col];
    int ans=1;
    for(auto i:a[node]){
        if(i!=par){
            if(col==0){
                ans=ans*(dfs(i,0,node)+dfs(i,1,node))%hell;
            }
            else ans=ans*dfs(i,0,node)%hell;
        }
    }
    return dp[node][col]=ans;
}
void solve(){
    cin>>n;
    rep(i,0,n-1){
        int x,y;
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    memset(dp,-1,sizeof dp);
    cout<<(dfs(1,0,0)+dfs(1,1,0))%hell<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main()
{

  string s,t ;
  cin >> s >> t ;
  int ans = 0;
  
  for(int i=0;i<3;i++){
    if(s[i]==t[i]) ans++ ;
  }
  
  cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256