akhauriyash/Code-Regression huggingface dataset:
// Input macro
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)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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)*}
    };
}

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")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "3 5\n.....\n.#.#.\n.....\n" => "11211\n1#2#1\n11211\n",
    "3 5\n#####\n#####\n#####\n" => "#####\n#####\n#####\n",
    "6 6\n#####.\n#.#.##\n####.#\n.#..#.\n#.##..\n#.#...\n" => "#####3\n#8#7##\n####5#\n4#65#2\n#5##21\n#4#310\n",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        h: isize,
        w: isize,
        v: [chars; h],
    };

    let mut v = v;

    let d = [
        (-1, -1),
        (-1, 0),
        (-1, 1),
        (0, -1),
        (0, 1),
        (1, -1),
        (1, 0),
        (1, 1),
    ];

    for i in 0..h {
        for j in 0..w {
            if v[i as usize][j as usize] == '#' {
                continue;
            }

            let mut count = 0;

            for &(dx, dy) in d.iter() {
                let ni = i + dy;
                let nj = j + dx;

                if ni < 0 || h <= ni {
                    continue;
                }
                
                if nj < 0 || w <= nj {
                    continue
                };

                if v[ni as usize][nj as usize] == '#' {
                    count += 1;
                }
            }

            v[i as usize][j as usize] = std::char::from_digit(count as u32, 10).unwrap();
        }
    }

    let mut ans = String::new();
    for i in 0..h {
        let s = format!("{}\n",v[i as usize].iter().cloned().collect::<String>());
        ans.push_str(&s);
    }

    ans
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(){
  int n, m;  scanf("%d%d", &n, &m);
  int from1[200003] = {0};
  int toN[200003] = {0};
  for(int i=0; i<m; i++){
    int f, t;  scanf("%d%d", &f, &t);
    if(f == 1)
      from1[t] = 1;
    else if(t == n)
      toN[f] = 1;

  }
  for(int i=1; i<=n; i++){
    if(from1[i] && toN[i]){
      printf("POSSIBLE\n");
      return 0;
    }
  }
  printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 1664
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_l = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Printf.printf "%d\n" @@
  List.fold_left (fun acc x -> acc + (x-1)) 0 a_l


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22)cout << "bust";
    else cout << "win";



    
}

/*
*/


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

using namespace std;

int main()
{
    int n;
    long long b, ans = 0;
    cin >> n;

    vector<long long> a(n+1);
    for(int i = 0; i <= n; ++i) cin >> a[i];

    for(int i = 0; i < n; ++i) {
        cin >> b;

        ans += min(a[i], b);
        b -= min(a[i], b);
 
        ans += min(a[i + 1], b);
        a[i + 1] -= min(a[i + 1], b);
    }

    cout << ans << '\n';
}

Measured memory_bytes: 1024
N = int(input())
bill = []
for _ in range(4):
    bill.append([[0]*10 for _ in range(3)])


for _ in range(N):
    b, f, r, v = map(int, input().split())
    bill[b-1][f-1][r-1] += v

for i, b in enumerate(bill):
    for x in b:
        print("", *x)
    if i < 3:
        print("#"*20)


Measured memory_bytes: 5624
package main
import "fmt"
func main() {
  var a,b,c,d,e int
  var p,q,r,s,t int
  var m,x int
  fmt.Scan(&a,&b,&c,&d,&e)
  p = ceil(a,10)
  q = ceil(b,10)
  r = ceil(c,10)
  s = ceil(d,10)
  t = ceil(e,10)
  x = p+q+r+s+t
  m = x
  if m > x-p+a { m = x-p+a }
  if m > x-q+b { m = x-q+b }
  if m > x-r+c { m = x-r+c }
  if m > x-s+d { m = x-s+d }
  if m > x-t+e { m = x-t+e }
  fmt.Println(m)
}
func ceil(n int,m int) int {
  if n%m == 0 { return n }
  return (n/m+1)*m
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int cnt=0;
    string s;
    cin >> s;
    for (int i=0; i<3; i++)
        if (s[i]=='A') cnt++;
    if (!cnt || cnt==3) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

int F[50];
int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i <= n; i++) {
        if (i <= 1) F[i] = 1;
        else {
            F[i] = F[i-1] + F[i-2];
        }
    }
    printf("%d\n", F[n]);
}


Measured memory_bytes: 3212
n = int(input())
aa = [0]*n
bb = [0]*n
for i in range(n):
    aa[i], bb[i] = map(int, input().split())

def get_2med(arr):
    m = len(arr)
    ar = sorted(arr)
    if m%2 == 0:
        return ar[m//2-1] + ar[m//2]
    else:
        return ar[(m+1)//2-1]
    
minmed = get_2med(aa)
maxmed = get_2med(bb)
print(maxmed - minmed + 1)

Measured memory_bytes: 27092
<?php
	fscanf(STDIN, "%d %d", $N, $M);

	$isArray = array();
	$waCountArray = array();
	$acCount = 0;

	for ($i=1; $i<=$N; $i++) {
      $isArray[$i] = false;
      $waCountArray[$i] = 0;
    }

	for ($i=1; $i<=$M; $i++) {
      fscanf(STDIN, "%d %s", $p, $S);
      
      if ($isArray[$p]) {
        continue;
      }

      if ($S === 'AC') {
        $isArray[$p] = true;
        $acCount++;
      } else {
        $waCountArray[$p]++;
      }
    }

	$waCount = 0;
	foreach ($waCountArray as $key => $value) {
      if ($isArray[$key]) {
        $waCount += $value;
      }
    }
	
	echo ($acCount.' '.$waCount);

?>

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

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

using namespace std;

using pii = pair<int, int>;

class disjoint_set {
private:
    std::vector<size_t> parents;
    std::vector<size_t> ranks;
    std::vector<size_t> component_sizes;
public:
    const size_t n_vertices;
    size_t n_components;

    disjoint_set(size_t n_vertices) : n_vertices(n_vertices), parents(n_vertices), ranks(n_vertices, 0), n_components(n_vertices), component_sizes(n_vertices, 1) {
        for (size_t i = 0; i < n_vertices; ++i) {
            parents[i] = i;
        }
    }

    size_t root(size_t x) {
        if (parents[x] == x) {
            return x;
        } else {
            return parents[x] = root(parents[x]);
        }
    }

    void merge(size_t x, size_t y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }
        if (ranks[x] < ranks[y]) {
            parents[x] = y;
            component_sizes[y] += component_sizes[x];
        } else {
            parents[y] = x;
            component_sizes[x] += component_sizes[y];
            if (ranks[x] == ranks[y]) {
                ++ranks[x];
            }
        }
        --n_components;
    }

    bool is_same(size_t x, size_t y) {
        return root(x) == root(y);
    }

    size_t component_size(size_t x) {
        return component_sizes[root(x)];
    }
};

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

    int N, K, L;
    cin >> N >> K >> L;

    disjoint_set ds1(N);
    REP(_, K) {
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        ds1.merge(p, q);
    }

    disjoint_set ds2(N);
    REP(_, L) {
        int r, s;
        cin >> r >> s;
        --r;
        --s;
        ds2.merge(r, s);
    }

    map<pii, int> cnt;
    REP(i, N) {
        cnt[pii(ds1.root(i), ds2.root(i))]++;
    }

    REP(i, N) {
        cout << cnt[pii(ds1.root(i), ds2.root(i))] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 23620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int c[51][51];
void f(){
    rep(i, 0, 51) c[i][0] = 1;
    rep(i, 1, 51){
        rep(j, 1, 51){
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }
}

signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> v(n);
    map<int, int> mp;
    rep(i, 0, n){
        cin >> v[i];
        mp[v[i]]++;
    }
    sort(all(v));
    reverse(all(v));
    double sum = 0;
    int end = v[a - 1], p = 0, q = mp[v[a - 1]];
    rep(i, 0, a){
        sum += v[i];
        if(v[i] == end) p++;
    }
    int ans = 0;
    f();
    // cout << p << " " << q << endl;
    if(p != a){
        ans = c[q][p];
    }else{
        int MAX = min(q, p + b - a);
        // cout << MAX << endl;
        rep(i, p, MAX + 1){
            ans += c[q][i];
        }
    }
    double ave = sum / (double)a;
    printf("%.10lf\n", ave);
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,a,b;

int main(){
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main()
{
    ll x;
    scanf("%lld",&x);
    ll a=x/500;
    x-=a*500;
    ll b=x/5;
    printf("%lld",a*1000+b*5);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>a,b;
int main()
{
    int n,temp;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        a.push_back(temp);
   }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        cout<<lower_bound(a.begin(), a.end(), temp) - a.begin() <<" ";
        cout<<upper_bound(a.begin(), a.end(), temp) - a.begin() << endl;
    }
}


Measured memory_bytes: 3528
using System;
using System.Linq;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var result = 0;
            for (var i = 1; i <= s.Length; i++)
            {
                var count = 0;
                for (var j = i-1; j <= s.Length - 1; j++)
                {
                    if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') count++;
                    else break;
                }
                if (result < count) result = count;
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
# frozen_string_literal: true

a, b, k = gets.split.map(&:to_i)

while k.positive?
  if a >= 1000000000000 && k >= 1000000000000
    a -= 1000000000000
    k -= 1000000000000
  elsif a >= 100000000000 && k >= 100000000000
    a -= 100000000000
    k -= 100000000000
  elsif a >= 10000000000 && k >= 10000000000
    a -= 10000000000
    k -= 10000000000
  elsif a >= 1000000000 && k >= 1000000000
    a -= 1000000000
    k -= 1000000000
  elsif a >= 100000000 && k >= 100000000
    a -= 100000000
    k -= 100000000
  elsif a >= 10000000 && k >= 10000000
    a -= 10000000
    k -= 10000000
  elsif a >= 1000000 && k >= 1000000
    a -= 1000000
    k -= 1000000
  elsif a >= 100000 && k >= 100000
    a -= 100000
    k -= 100000
  elsif a >= 10000 && k >= 10000
    a -= 10000
    k -= 10000
  elsif a >= 1000 && k >= 1000
    a -= 1000
    k -= 1000
  elsif a >= 100 && k >= 100
    a -= 100
    k -= 100
  elsif a >= 10 && k >= 10
    a -= 10
    k -= 10
  elsif a >= 1 && k >= 1
    a -= 1
    k -= 1

  elsif b >= 1000000000000 && k >= 1000000000000
    b -= 1000000000000
    k -= 1000000000000
  elsif b >= 100000000000 && k >= 100000000000
    b -= 100000000000
    k -= 100000000000
  elsif b >= 10000000000 && k >= 10000000000
    b -= 10000000000
    k -= 10000000000
  elsif b >= 1000000000 && k >= 1000000000
    b -= 1000000000
    k -= 1000000000
  elsif b >= 100000000 && k >= 100000000
    b -= 100000000
    k -= 100000000
  elsif b >= 10000000 && k >= 10000000
    b -= 10000000
    k -= 10000000
  elsif b >= 1000000 && k >= 1000000
    b -= 1000000
    k -= 1000000
  elsif b >= 100000 && k >= 100000
    b -= 100000
    k -= 100000
  elsif b >= 10000 && k >= 10000
    b -= 10000
    k -= 10000
  elsif b >= 1000 && k >= 1000
    b -= 1000
    k -= 1000
  elsif b >= 100 && k >= 100
    b -= 100
    k -= 100
  elsif b >= 10 && k >= 10
    b -= 10
    k -= 10
  elsif b >= 1 && k >= 1
    b -= 1
    k -= 1
  end

  break if k.positive? && a.zero? && b.zero?
end

puts "#{a} #{b}"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int a[10001];
main() {
	int n=read(),ans=0;
	for(int i=1; i<=n; i++)
		a[i]=read();
	for(int i=1; i<=n; i++)
		for(int j=1; j<i; j++)
			ans+=a[i]*a[j];
	cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

typedef struct{
  char mark;
  int  num;
}Card;

Card A[MAX];

void change(Card *x,Card *y) {
  Card z=*x;
  *x=*y;
  *y=z;
}

int partition( int p, int r){
  int j;
  int  x = A[r].num;
  int i = p-1;
  
  for (j = p;j<r;j++){
    if (A[j].num <= x){
      i = i+1;
      change(&A[i],&A[j]);
    }
  }
  change(&A[i+1],&A[r]);
  return i+1;
}

void quickSort(int p,int r){
  int q;
  
  if (p <r){
    q = partition(p, r);
    quickSort(p, q-1);
    quickSort(q+1, r);
  }
}
//-----------------------------------------------------------merge
void merge(Card *A,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j,k;
  int count;
  
  Card L[n1];
  Card R[n2];
  
  for (i = 0;i< n1;i++)L[i] = A[left + i];
  for (i = 0;i< n2;i++)R[i] = A[mid + i];
  
  L[n1].num = 1000000001;
  R[n2].num = 1000000001;

  i = 0;
  j = 0;

  for (k = left;k<right;k++){
    count++;
    if (L[i].num <= R[j].num){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
  }  
}

void mergeSort(Card *A,int left,int right){//Aの左と右を入力で　昇順 安定
  int mid;
  
  if (left+1 < right){    
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
//-----------------------merge
int main(){//構造体に対するソート
  int i;
  int n;
  int flag=1;
  Card B[100000];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){//入力
    scanf(" %c%d",&A[i].mark,&A[i].num);
    B[i]=A[i];
  }
  
  quickSort(0,n-1);//ソート//A[]を使う　配列スタートからエンドまで指定
  mergeSort(B,0,n);//Bを使う 0~n

  
  for(i=0;i<n;i++){ //JUDGE　　違ってたらflagで0
    if(A[i].mark!=B[i].mark)flag=0;	 
  }
 
  if(flag)printf("Stable\n");
  else printf("Not stable\n");
  
  for(i=0;i<n;i++){//OUTPUT
    printf("%c %d\n",A[i].mark,A[i].num);
  }
 
  return 0;
}



Measured memory_bytes: 4052
import math
a, b, n = map(int, input().split())

if n < b:
    x = n
    score = math.floor(a*x/b) - a * math.floor(x/b)
    print(score)
    
else:
    x = b-1
    score = math.floor(a*x/b) - a * math.floor(x/b)
    print(score)

Measured memory_bytes: 9192
#include<stdio.h>
#define N 100000

int check_down(int a[],int x,int idx,int n){

	for(int i=idx;i>=0;i--)
		if(a[i]<x)return i+1;
		
	return 0;

}

int check_up(int a[],int x,int idx,int n){

	for(int i=idx;i<n;i++)
		if(a[i]>=x)return i;
		
	return n;

}


int lower_bound(int a[],int x,int n){
	int left=0;
	int right=n-1;
	int mid;
	char past='N';
	
	while(left<=right){
		mid=(left+right)/2;
		/*printf("left:%d  mid:%d  right:%d\n",left,mid,right);*/
		
		if(a[mid]==x){
			for(int i=mid;i>=0;i--)
				if(a[i]!=x)return i+1;
			return 0;
		}
		
		else if(a[mid] > x){
			if(past=='R')return check_down(a,x,mid,n);
			right=mid-1;
			past='L';
		}
		else if(a[mid] < x){
			if(past=='L')return check_up(a,x,mid,n);
			left=mid+1;
			past='R';
		}
		
	}
	
	if(past=='L')return 0;
	
	if(past=='R')return n;
	
}



int main(){
	int n,i,q,x;
	int a[N];
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
	
		scanf("%d",&x);
		printf("%d\n",lower_bound(a,x,n));
	
	}
	
	return 0;
	
}


Measured memory_bytes: 2156
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    
    n = ii()
    print((n+1)//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int n;
  string s;

  cin >> n >> s;

  int r = 0;
  int b = 0;
  rep(i, 0, n) {
    (s[i] == 'R') ? (++r) : (++b);
  }

  puts(r > b ? "Yes" : "No");
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 1 ; i <= n ; i++)

using namespace std;

int main()
{
  while(true){
    int n,r;
    cin >> n >> r;
    if(n == 0 && r == 0) break;
    
    vector<int> card;
    rep(i, n){
      card.push_back(i);
    }
    int p,c;
    for( ; r > 0 ; r--){
      cin >> p >> c;

      p = n - p - c + 1;
      for( ; c > 0 ; c--){
	card.push_back(card[p]);
	card.erase(card.begin() + p);
      }
    }
    cout << card.back() << '\n';
  }
}

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

int N;
string S;
int R;
typedef bitset<26> B;

B go(string s) {
  B res;
  for(int i = 0; i < (int)s.size(); ++i) res[s[i] - 'a'] = 1;
  return res;
}
int main() {
  cin >> N >> S;
  for(int i = 0; i < N; ++i) {
    R = max(R, (int)(go(S.substr(0, i)) & go(S.substr(i))).count());
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int m, f, r, sum;
	
	
	while(1){
		scanf("%d %d %d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1 ){
			break;
		}
		sum = m + f;
	    if(m == -1 || f == -1){
			printf("F\n");
		}
		else if(sum >= 80){
			printf("A\n");
		}
		else if(sum >= 65){
			printf("B\n");
		}
		else if(sum >= 50 || r >= 50){
			printf("C\n");
		}
		else if(sum >= 30){
			printf("D\n");
		}
		else {
			printf("F\n");
		}
	}
	
	
	return (0);
}
		
		

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int n, m, a, b;
	cin>>n>>m;
	int edge[8][8];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			edge[i][j]=0;
		}
	}
	for(int i=0; i<m; i++){
		cin>>a>>b;
		edge[a-1][b-1]=1;
		edge[b-1][a-1]=1;
	}

	vector<int> data(n-1);
	for(int i=0; i<n-1; i++){
		data[i]=i+1;
	}
	long cnt=0;
	do{
		bool flag=true;
		int p=0;
    	for(unsigned int i=0; i<n-1; ++i){
    		if(!edge[p][data[i]]){
				flag=false;
				break;
			}
			p=data[i];
		}
		if(flag){
			cnt++;
		}
	}while(next_permutation(data.begin(), data.end()));

	cout<<cnt<<endl;

	return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#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(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BTrickOrTreat {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, K;
    cin >> N >> K;
    vector<bool> check(N, false);
    rep(i, N) {
      int d;
      cin >> d;
      int temp;
      rep(j, d) {
        cin >> temp;
        check[temp - 1] = true;
      }
    }
    int ans = 0;
    rep(i, N) {
      if (check[i] == false) ans++;
    }
    cout << ans << endl;
  }
};


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


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <queue>
#define INF 100
using namespace std;

int n;
int h[17],w[17];
int dp[1<<16];
int fie[4][4];
bool ok[4][4][4][4];

int bfs(int s){
	queue<int> que;
	for(int i=0;i<1<<16;i++){
		dp[i]=INF;
	}
	que.push(s);
	dp[s]=0;
	while(que.size()){
		int bit=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=i+1;k<=4;k++){
					for(int l=j+1;l<=4;l++){
						if(!ok[i][j][k][l])continue;
						for(int c=0;c<3;c++){
							int nbit=bit;
							for(int x=i;x<k;x++){
								for(int y=j;y<l;y++){
									int nshift=y*4+x;
									if((nbit>>nshift & 1) && fie[x][y]!=c)nbit-=(1<<nshift);
									if(!(nbit>>nshift & 1) && fie[x][y]==c)nbit+=(1<<nshift);
								}
							}
							if(dp[nbit]==INF){
								dp[nbit]=dp[bit]+1;
								que.push(nbit);
							}
						}
					}
				}
			}
		}
	}
	return dp[(1<<16)-1];
}

int main(void){
	scanf("%d",&n);
	memset(ok,false,sizeof(ok));
	for(int i=0;i<n;i++){
		scanf("%d %d",&h[i],&w[i]);
		for(int j=-3;j<4;j++){
			for(int k=-3;k<4;k++){
				int lx=max(0,j);
				int ly=max(0,k);
				int rx=min(4,j+w[i]);
				int ry=min(4,k+h[i]);
				if(lx>=rx || ly>=ry)continue;
				ok[lx][ly][rx][ry]=true;
			}
		}
	}
	for(int i=0;i<4;i++){
		string str;
		cin >> str;
		for(int j=0;j<4;j++){
			if(str[j]=='R')fie[j][i]=0;
			if(str[j]=='G')fie[j][i]=1;
			if(str[j]=='B')fie[j][i]=2;
		}
	}
	printf("%d\n",bfs(0));
	return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
bool ch(ll a, ll b, ll x, ll y){
	if(a>b){
		swap(a,b);
	}
	if(x>y){
		swap(x,y);
	}
	bool z=0;
	if(x<=a&&a<=y || x<=b&&b<=y){
		z=1;
	}
	return z;
}
int main(){
	IOS
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	for(int i=1;i<=n;i++){
		/*
		a+((i-1)*c),a+((i-1)*d);
		a-((i-1)*d),a-((i-1)*c);
		b-((n-i)*d),b-((n-i)*c);
		b+((n-i)*c),b+((n-i)*d);
		*/
		if( ch(a+((i-1)*c),a+((i-1)*d),
				b+((n-i)*c),b+((n-i)*d))==1||
			ch(a+((i-1)*c),a+((i-1)*d),
				b-((n-i)*d),b-((n-i)*c))==1||
			ch(a-((i-1)*d),a-((i-1)*c),
				b+((n-i)*c),b+((n-i)*d))==1||
			ch(a-((i-1)*d),a-((i-1)*c),
				b-((n-i)*d),b-((n-i)*c))==1){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}
/*
 
*/

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll dp[3001][3001];
int main(void) {
	ll a;
	long double b;
	cin >> a >> b;
	printf("%lld\n", (ll)floor(a * b));
	return 0;
}


Measured memory_bytes: 3796
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
const int maxn = 1000000 + 10;
const int N = maxn << 1;
const int maxE = 3000000;
const int INF = 0x3f3f3f3f;

int n, h[N], ecnt, tot, S, T;
struct enode{
	int v, n, w, op;
	enode() {}
	enode(int _v, int _n, int _w, int _op):v(_v), n(_n), w(_w), op(_op) {}
}e[maxE << 1];

inline void addedge(int u, int v, int w) {
	ecnt ++; e[ecnt] = enode(v,h[u],w,ecnt + 1); h[u] = ecnt;
	ecnt ++; e[ecnt] = enode(u,h[v],0,ecnt - 1); h[v] = ecnt;
}

int level[N], q[N << 1], cur[N];
inline bool bfs() {
	memset(level,0,sizeof(level));
	int head = 1, tail = 0;
	level[S] = 1; q[++ tail] = S;
	for(int i = S;i <= tot;i ++) cur[i] = h[i];
	while(head <= tail) {
		int u = q[head]; head ++;
		for(int i = h[u];~ i;i = e[i].n) {
			int v = e[i].v;
			if(!level[v] && e[i].w > 0) {
				level[v] = level[u] + 1;
				q[++ tail] = v;
				if(v == T) return 1;
			}
		}
	}
	return 0;
}

int dfs(int u, int c) {
	if(u == T || c == 0) return c;
	int tmp = 0;
	for(int &i = cur[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(level[v] == level[u] + 1) {
			int x = dfs(v,min(c,e[i].w));
			if(x) {
				e[i].w -= x; e[e[i].op].w += x;
				tmp += x; c -= x;
				if(!c) break;
			}
		}
	}
	if(!tmp) level[u] = -1;
	return tmp;
}

int pre[maxn], used[maxn], lis[maxn];
vector<int> g[maxn], from[maxn];

int main() {
	scanf("%d", &n); tot = n;
	S = 0; T = ++ tot; ecnt = 0;
	memset(h,-1,sizeof(h));
	for(int i = 2;i <= n;i ++) addedge(i,T,1);
	for(int i = 1;i < n;i ++) {
		int p = ++ tot;
		addedge(S,p,1);
		int k; scanf("%d", &k);
		for(int j = 1;j <= k;j ++) {
			int x; scanf("%d", &x);
			g[i].push_back(x);
			from[x].push_back(i);
			addedge(p,x,INF);
		}
	}
	int flow = 0;
	while(bfs())
		flow += dfs(S,INF);
	if(flow < n - 1) {
		puts("-1");
		return 0;
	}
	for(int u = 2;u <= n;u ++) {
		for(int i = h[u];~ i;i = e[i].n) {
			int v = e[i].v;
			if(v != T && e[i].w) lis[v - n - 1] = u;
		}
	}
	int head = 1, tail = 0;
	q[++ tail] = 1; pre[1] = -1;
	while(head <= tail) {
		int u = q[head]; head ++;
		for(int i = 0, Sz = from[u].size();i < Sz;i ++) {
			int id = from[u][i];
			if(used[id]) continue;
			used[id] = 1;
			int v = lis[id];
			pre[v] = u;
			q[++ tail] = v;
		}
	}
	for(int i = 2;i <= n;i ++) {
		if(!pre[i]) {
			puts("-1");
			return 0;
		}
	}
	for(int i = 2;i <= n;i ++) {
		int u = lis[i - 1], v = pre[u];
		printf("%d %d\n", u, v);
	}
	return 0;
}


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

int bound(int X, int N, int L[]){
    int i, height, count;
    height = 0;
    count = 1;
      
    for ( i = 0; i < N; i++ ) {
        height += L[i];
        if (height <= X) {
          count++;
        }
    }
    
    return count;
}

int main(void){
    // Your code here!
    int N, X, i;
    cin >> N >> X;
    int L[N];
    
    for ( i = 0; i < N; i++ ) cin >> L[i];
    
    cout << bound(X, N, L) << endl;
}

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

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

    vector<int> l;
    int a = 0;

    int max = 0;
    int max_poji = 0;

    for(int i = 0; i < N; i++){
        cin >> a;
        l.push_back(a);
        if(a > max){
            max = a;
            max_poji = i;
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++){
        if(i == max_poji){
            continue;
        }
        ans += l[i];
    }

    if(ans > max){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  
  bool judge = true;
  long long dis = c - a - b;
  if(dis < 0){
    judge = false;
  }else{
    judge = dis * dis > 4 * a * b ? true : false;
  }
  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> wyst(100001, 0);
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        ++wyst[x];
    }
    int odp = 0;
    for (int i = 0; i < 100001; ++i)
    {
        int il = wyst[i];
        if (i != 0)
            il += wyst[i - 1];
        if (i != 100001)
            il += wyst[i + 1];
        odp = max(odp, il);
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 640
import math
s=int(input())
if s<=2:
  print(0)
else:
  ans=1
  for i in range(1,s//3):
    ans+=math.factorial(s-(i+1)*3+i)//(math.factorial(s-(i+1)*3)*math.factorial(i))
    ans%=(10**9+7)
  print(ans)

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

int main() {
    Int n, m;
    cin >> n >> m;
    vector<vector<Int>> s(m);
    for (Int i = 0; i < m; i++) {
        Int k;
        cin >> k;
        s[i].resize(k);
        for (Int j = 0; j < k; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
        //print(s[i]);
    }
    vector<bool> p(m);
    for (Int i = 0; i < m; i++) {
        Int x;
        cin >> x;
        p[i] = x == 1;
    }
    Int res = 0;
    for (Int bit = 0; bit < (1<<n); bit++) {
        vector<bool> light(m, false);
        for (Int i = 0; i < m; i++) {
            bool c = false;
            for (Int j = 0; j < (Int)s[i].size(); j++) {
                if (bit & (1<<s[i][j])) {
                    c = not c;
                }
            }
            light[i] = c;
        }
        bool check = true;
        for (Int i = 0; i < m; i++) {
            if (p[i] != light[i]) {
                check = false;
            }
        }
        if (check) {
            res++;
        }
        // print("bit: ", bitset<2>(bit));
        // print(light);
        // print(p);
    }
    print(res);
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, sum1 = 0, sum2 = 0, b = 0, c = 0, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i%2) {
      if (sum1+a < 0) {
        sum1 += a;
      } else {
        b += 1+(sum1+a);
        sum1 = -1;
      }
      if (sum2+a > 0) {
        sum2 += a;
      } else {
        c += 1-(sum2+a);
        sum2 = 1;
      }
    } else {
      if (sum1+a > 0) {
        sum1 += a;
      } else {
        b += 1-(sum1+a);
        sum1 = 1;
      }
      if (sum2+a < 0) {
        sum2 += a;
      } else {
        c += 1+(sum2+a);
        sum2 = -1;
      }
    }
  }
  cout << min(b,c);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> dist;
vector<vector<P>> graph;

void dfs(int u, int pre, ll cost) {
    if (dist[u] != 0) return;
    dist[u] = cost;
    for (P p:  graph[u]) {
        if (p.first != pre) {
            dfs(p.first, u, cost + p.second);
        }
    }
}

void Main() {
    int N;
    cin >> N;
    graph.resize(N);
    dist.resize(N + 1);
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].emplace_back(b, c);
        graph[b].emplace_back(a, c);
    }
    int Q, K;
    cin >> Q >> K;
    vector<P> query(Q);
    rep(i, Q) cin >> query[i].first >> query[i].second;
    dfs(K - 1, -1, 0);
    rep(i, Q) {
        P p = query[i];
        ll ans = dist[p.first - 1] + dist[p.second - 1];
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 15872
n = input()

p = [0 for i in xrange(n + 1)]

for i in xrange(1, n + 1):
    p[i - 1], p[i] = map(int, raw_input().split())
    
m = [[0 for j in xrange(n + 1)] for i in xrange(n + 1)]

for i in xrange(1, n + 1):
    m[i][i] = 0
    
for l in xrange(2, n + 1):
    for i in xrange(1, n - l + 2):
        j = i + l - 1
        m[i][j] = float("inf")
        for k in xrange(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j])

print m[1][n]

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

using namespace std;

typedef long long ll;

int main() {
    ll W,H,x,y; cin>>W>>H>>x>>y;
    cout << setprecision(10) << double(W)*double(H)/2.0 << " " << (x*2==W && y*2==H) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(fabs(c-a)<=d)
    {
        printf("Yes\n");
    }
    else if(fabs(a-b)<=d&&fabs(c-b)<=d)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

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

int main(){
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }

    cout << Alice - Bob << endl;


    return 0;
}

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

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

int N, A[100000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> A[i];

    sort(A, A+N);
    vector<P> ans;
    int M;
    for(int i=1;i<N-1;i++){
        if(A[i] < 0){
            ans.push_back( P(A[N-1], A[i]) );
            A[N-1] = A[N-1] - A[i];
        } else {
            ans.push_back( P(A[0], A[i]) );
            A[0] = A[0] - A[i];
        }
    }

    M = A[N-1] - A[0];

    cout << M << endl;
    for(auto i : ans)   cout << i.first << " " << i.second << endl;
    cout << A[N-1] << " " << A[0] << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
bool cmp(pi64 a,pi64 b)
{
  return b.se*b.fi>a.se*a.fi;
}
 
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
i64 n,m,c;
cin>>n>>m;
vector<pi64>a;
forn(i,n)
{i64 b,c;
  cin>>c>>b;
  a.pb({c,b});
}
sort(a.begin(),a.end());
i64 count=0,price=0;
int j=0;
while(count<m)
{
if(count+a[j].se>m-1)
{
  price+=(m-count)*a[j].fi;
  count+=m-count;
  break;
}
 
  count+=a[j].se;

  price+=a[j].fi*a[j].se;
  j++;
}
// cout<<count<<"\n";
 cout<<price;
    return 0;
  }

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#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

int main(){
	string s;
	cin >> s;
	int n = s.length();
	int perm[n];
	for(int i = 0; i < n; i++) perm[i] = s[i] - 'a';
	int i = 0;
	
	int available = (1 << 26) - 1;
	vector<int> vec;
	for(int j = 0; j < n; j++) available ^= (1 << (s[j] - 'a')), vec.push_back(s[j] - 'a');
	if(n != 26){
		cout << s;
		for(int j = 0; j < 26; j++) if(available >> j & 1){
			cout << (char)('a'+j);
			return 0;
		}
	}
	vector<string> options;
	for(int i = n - 1; i >= 0; i--){
		available = (1 << 26) - 1;
		for(int j = 0; j < i; j++) available ^= (1 << (s[j]-'a'));
		for(int j = 0; j < 26; j++) if(available >> j & 1){
			string s2 = s.substr(0, i);
			s2.append(1, 'a' + j);
			// cerr << s2 << endl;
			if(s2 > s) options.push_back(s2);
		}
	}
	sort(options.begin(), options.end());
	cout << (options.empty() ? "-1" : options[0])<<endl;
	
}

Measured memory_bytes: 256
// Author : amnptl
//    Godbless

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007     // Check Question

ll power(ll base, ll exponent, ll modx = mod) 
{
    ll ret = 1 % modx;
    base %= modx;
    while(exponent) 
    {
        if(exponent & 1) 
        {
            ret = (ret * base) % modx;
        }
        base = (base * base) % modx;
        exponent >>= 1;
    }
    return ret;
}
 
//nCr mod 
ll inv(ll val, ll modx = mod) 
{
    return power(val, modx - 2, modx);
}
 
vector <ll> fac, ifac;
void preFac(ll sz) 
{
    fac.resize(sz + 1),
    ifac.resize(sz + 1);
    fac[0] = 1;
    for(int i = 1; i <= sz; i++) 
    {
        fac[i] = (i * fac[i - 1]) % mod;
    }
    ifac[sz] = inv(fac[sz]);
    for(int i = sz - 1; i >= 0; i--) 
    {
        ifac[i] = ((i + 1) * ifac[i + 1]) % mod;
    }
}
ll nCr(ll N, ll R)
{
    if(R <= N && R >= 0) {
        return ((fac[N] * ifac[R]) % mod * ifac[N - R]) % mod;
    }
    return 0;
}
// nCr mod
 
int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    preFac(1000000);	// preComputation
    // Code begins here: 
   	ll n,k; cin>>n>>k; ll a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	sort(a,a+n); ll ans = 0;
	for(int i=k-1; i<n; i++)
		ans += nCr(i,k-1)*a[i],ans%=mod;
	for(int i=0; i<=(n-k); i++)
		ans -= (nCr(n-i-1,k-1)*a[i])-mod,ans%=mod;
	if(ans<0) ans += mod;
	cout<<ans<<endl;	
    return 0;
}

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

const int N = 50, mod = 1e9 + 7;
typedef long long ll;

ll adj[N][N];
ll n, v[N][N];

ll sum (ll a, ll b) {
	a += b;
	while(a < 0) {
		a += mod;
	}
	while(a >= mod)
		a -= mod;
}

void mult (ll a[N][N], ll b[N][N], ll c[N][N]) {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) 
			c[i][j] = 0;
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < n; k++) {
			for (int j = 0; j < n; j++) {
				c[i][j] = (c[i][j] + 1LL * a[i][k] * b[k][j] % mod) % mod;
			}
		}
	}	
}

ll k;

ll pw (ll a[N][N], ll b) {
	ll ans[N][N];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			ans[i][j] = (i == j);
	while(b) {
		if(b % 2) {
			mult(ans, a, v);
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					ans[i][j] = v[i][j];
		}
		mult(a, a, v);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = v[i][j];
		b /= 2;
	}
//	for (int i = 0; i < n; i++, cout << "\n")
//		for (int j = 0; j < n; j++)
//			cout << ans[i][j] << " ";
	for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				a[i][j] = ans[i][j];
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> adj[i][j];
		}
	}
	pw(adj, k);
	ll ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			ans += adj[i][j];
			ans %= mod;
		}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    if(a%2&&b%2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256