akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long

using namespace std;

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

  int n; cin >> n;
  string s; cin >> s;

  int r = 0;
  int b = 0;
  for (int i = 0; i < n; ++i) if (s[i] == 'R') ++r; else ++b;

  if (r > b) cout << "Yes";
  else cout << "No";
  cout << endl;



  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int c[10][10];
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      c[i][j] = 0;
    }
  }
  for(int i=1; i<=n; i++){
    string a=to_string(i);
    c[int(a[0]-'0')][int(a[a.size()-1]-'0')]++;
  }
  int ans=0;
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      ans += c[i][j]*c[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*GRATITUDE*/
/*1916057*/
//Arise Awake and Stop Not Till the Goal is reached. 
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

/*************************************************************************************************/
//Write your functions here..............................

/***************************************************************************************************/

void solve() {
/*Write your code here*/
 int n; double d; cin>>n>>d;
 int a,b,cnt=0;
 for_f (1,n,1) {
  cin>>a>>b;
  if(a*a+b*b<=d*d) ++cnt;
 }
 cout<<cnt<<endl;
}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 

Measured memory_bytes: 3744
#include<stdio.h>
int main(){
	int a;
	scanf("%d",&a);
	if(a%7==1)printf("fri\n");
	else if(a%7==2)printf("sat\n");
	else if(a%7==3)printf("sun\n");
	else if(a%7==4)printf("mon\n");
	else if(a%7==5)printf("tue\n");
	else if(a%7==6)printf("wed\n");
	else printf("thu\n");
	return 0;
}


Measured memory_bytes: 2120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();

		for(int i = 0; i < a.length;i++) {
			System.out.print(a[i]);
			if(b.length > i) System.out.print(b[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 21460
a = int(input())
d = '1'
if 400 <= a <= 599:
  d = '8'
elif 600 <= a <= 799:
  d = '7'
elif 800 <= a <= 999:
  d = '6'
elif 1000 <= a <= 1199:
  d = '5'
elif 1200 <= a <= 1399:
  d = '4'
elif 1400 <= a <= 1599:
  d = '3'
elif 1600 <= a <= 1799:
  d = '2'
else:
  d = '1'
print(d)

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

int main() {
  
  string S;
  cin >> S;
  int sum = 0;
  
  while (S != "0"){
    vector<char> C(S.size());
    for (int i = 0 ; i < S.size(); i++) {
      C.at(i) = S.at(i);
    }
    
    vector<int> N(S.size());
    for (int i = 0 ; i < S.size(); i++) {
      N.at(i) = C.at(i) - '0';
    }
    
    for (int i = 0 ; i < S.size(); i++) {
      sum += N.at(i);
    }
    
    cout << sum << endl;
    sum = 0;
    cin >> S;
  }
  
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)

/*
  ch は小さいほうが良い
 */

struct Trie {
    struct Node {
        int val;
        Node * ch[26];
        Node() : val(0) {
            fill(ch, ch+26, nullptr);
        }
        ~Node(){
            for(auto & p : ch) if(p != nullptr) delete p;
        }
    };
    Node *r;

    void insert(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()){
                cur->val++;
                break;
            } else {
                auto &nxt = cur->ch[(int)*p-'A'];
                if(nxt == nullptr) nxt = new Node();
                cur = nxt;
                ++p;
            }
        }
    }
    bool erase(string const &s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur->val > 0 ? cur->val--, true : false;
            auto &nxt = cur->ch[(int)*p-'A'];
            if(nxt == nullptr) return false;
            cur = nxt;
            ++p;
        }
    }
    bool find(string const& s){
        auto p = s.begin();
        auto cur = r;
        while(1){
            if(p == s.end()) return cur->val > 0;
            auto &nxt = cur->ch[(int)*p-'A'];
            if(nxt == nullptr) return false;
            cur = nxt;
            ++p;
        }
    }
    Trie() : r(new Node()) {}
    ~Trie() { delete r; }
};

int main(){
    int n;
    cin >> n;
    Trie t;
    rep(i,n){
        string com, str;
        cin >> com >> str;
        if(com[0] == 'i'){
            t.insert(str);
        } else {
            puts(t.find(str) ? "yes" : "no");
        }
    }
}

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

int main(){
    int A,B;
    cin>>A>>B;

    if(B==1){
        cout<<"0";
    }else{
        cout<<(A-B);
    }
}

Measured memory_bytes: 256
import math
def gcdf(a, b):
    if b == 0:
        return a
    return gcdf(b, a % b)
memo = {}
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            #print(i, j, l)
            if (i, j) not in memo.keys():
                memo[(i, j)] = gcdf(i, j)
                gcd = memo[i, j]
            else:
                gcd = memo[(i, j)]
            if (gcd, l) not in memo.keys():
                memo[(gcd, l)] = gcdf(gcd, l)
                ans += memo[(gcd, l)]
            else:
                ans += memo[(gcd, l)]
print(ans)

Measured memory_bytes: 81920
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
int n,a,b;
long long be[100001];
long long beki(int n,int k){
    long long ans = 1;
    be[0] = n;
    for(int i = 1;i<1000;i++){
        be[i] = (be[i-1]*be[i-1]) % 1000000007;
    }
    int w = 0;
    while(k > 0){
        if (k%2==1){
            ans = (ans * be[w])% 1000000007;
        }
        w += 1;
        k /= 2;
       
    }
    
    return ans;
}
long long comb(int n, int r)
{
    if (n - r < r) r = n - r;
    if (r == 0) return 1;
    if (r == 1) return n;

    int numerator[r];
    int denominator[r];

    for (int k = 0; k < r; k++)
    {
        numerator[k] = n - r + k + 1;
        denominator[k] = k + 1;
    }

    for (int p = 2; p <= r; p++)
    {
        int pivot = denominator[p - 1];
        if (pivot > 1)
        {
            int offset = (n - r) % p;
            for (int k = p - 1; k < r; k += p)
            {
                numerator[k - offset] /= pivot;
                denominator[k] /= pivot;
            }
        }
    }

    long long result = 1;
    for (int k = 0; k < r; k++)
    {
        if (numerator[k] > 1) result = (numerator[k]*result)%1000000007;
    }

    return result;
}
int main(){
    cin >> n >> a >> b;
    long long l = beki(2,n);
    long long ans = l - comb(n,a)-comb(n,b) -1;
    if (ans < 0){
        ans += 1000000007;
        if (ans < 0){
             ans += 1000000007;
        }
        cout << ans << endl;
    } else {
    cout << ans << endl;
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<double,double>;
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;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<P> po(n);
    rep(i,n) cin >> po[i].first >> po[i].second;
    double sum = 0;
    int cnt = 0;
    auto dif = [&](int a,int b) {
        double af = po[a].first,as = po[a].second,bf = po[b].first,bs = po[b].second;
        return sqrt((af-bf)*(af-bf)+(as-bs)*(as-bs));
    };
    vector<int> per(n);
    rep(i,n) per[i] = i;
    do {
        cnt++;
        rep(i,n-1) {
            sum += dif(per[i],per[i+1]);
        }
    } while (next_permutation(all(per)));
    double ans = sum/cnt;
    printf("%.8f",ans);
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        char[] ch = sc.next().toCharArray();
        final int N = ch.length;
        final long K = Long.parseLong(sc.next());
        char ans = '1';
        
        for (int i = 0; i < N; i++) {
            if (ch[i] != '1' && i < K) {
                ans = ch[i];
                break;
            }
        }

        out.println(ans);
        
        out.flush();
    }
}

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

int main(){
  int sum,a1,a2,n,m,t;
  sum=0;
  cin>>n>>m>>t;
  cin>>a1;
  sum=sum+a1-m;
  for(int i=1;i<n;i++){
    cin>>a2;
    if(a2-a1>m*2)sum=sum+a2-a1-(m*2);
    a1=a2;
  }
  if(t-a1-m>0)sum=sum+t-a1-m;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;

  if(b-a == c-b){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
}

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

int main(){

        string line;
        getline(cin,line);
        int a=1;

        for(int i=0;i<100&&line[i]!=0;i+=2){
               if(line[i]!='R'&&line[i]!='U'&&line[i]!='D'){
                       a=0;
               }
        }

        for(int i=1;i<100&&line[i]!=0;i+=2){
               if(line[i]!='L'&&line[i]!='U'&&line[i]!='D'){
                       a=0;
               }
        }

        if(a==1){
                cout<<"Yes";
        }else{
                cout<<"No";
        }
        return 0;
}



Measured memory_bytes: 256
N=int(input())
flag=0
for i in range(1,3500):
    for j in range(1,3500):
        if (4*i*j-N*i-N*j)>0:
            if (N*i*j)%(4*i*j-N*i-N*j)==0:
                print(i,j,(N*i*j)//(4*i*j-N*i-N*j))
                flag=1
                break
    if flag==1:
        break

Measured memory_bytes: 40556
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec_raw<>() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.to_string()).collect::<Vec<String>>().clone()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

/*fn get_score(r: usize,c:usize,n: usize,map: &Vec<Vec<usize>>) -> usize {
    let current = map[r][c].clone();
    match r {
        0 => if c < n - 1 { current + map[r + 1][c + 1] } else { current }
        1 => if c > 0 { current + map[r - 1][c - 1]} else {current}
        _ => panic!()
    }
}*/

fn get_result(return_point: usize,n: usize,map: &Vec<Vec<usize>>) -> usize{

    let mut r = 0;
    let mut c = 0;
    let mut flag = false;
    let mut result = map[r][c];

    for i in 0..n {
        if c == return_point && !flag {
            r = 1;
            flag = true;
            result += map[r][c]
        } else {
            c += 1;
            result += map[r][c]
        }
    }
    result
}

fn solve_a(){

    /*let mut str1 = read_vec_raw()[0].clone();
    let str2 = read_vec_raw()[0].clone();
    str1.push_str(&str2);*/

    let n : usize = read();
    let map : Vec<Vec<usize>> = read_vec2(2);
    let mut result = 0;

    /* n通りから1通りを選ぶ問題と考えられる */
    for i in 0..n {
        let tmp = get_result(i,n,&map);
        if tmp > result {
            result = tmp;
        }
    }

    println!("{}",result);
}

fn main (){

    solve_a();
}

Measured memory_bytes: 4352
#include<iostream>
#include<map>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		map<int, int> p;
		for (int i = 0; i < n; i++) {
			int id, m[4], s[4], sum = 0;
			cin >> id >> m[0] >> s[0] >> m[1] >> s[1] >> m[2] >> s[2] >> m[3] >> s[3];
			for (int i = 0; i < 4; i++) 
				sum += (m[i]*60);
			for (int i = 0; i < 4; i++)
				sum += s[i];
			p.insert(map<int, int>::value_type(sum, id));
		}
		map<int, int>::iterator it = p.begin();
		cout << (*it).second << endl;
		it++;
		cout << (*it).second << endl;
		it = p.end();
		it--;
		it--;
		cout << (*it).second << endl;
	}
}

Measured memory_bytes: 3328
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if (w == 0 && h == 0)
				break;
			int gy = -1;
			int gx = -1;
			boolean[][] map = new boolean[h + 2][w + 2];
			for (int i = 1; i <= h; i++) {
				char[] c = scanner.next().toCharArray();
				for (int j = 1; j <= w; j++) {
					if (c[j - 1] == '#') {
						map[i][j] = true;
					} else if (c[j - 1] == '&') {
						gy = i;
						gx = j;
					}
				}
			}
			int[][] dxy = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
			int[][] cnt = new int[h + 2][w + 2];
			
			for (int[] c : cnt) {
				Arrays.fill(c, 1 << 10);
			}
			cnt[0][0] = 0;
			Deque<List<Integer>> deque = new ArrayDeque<List<Integer>>();
			deque.offer(Arrays.asList(0, 0));
			while (!deque.isEmpty()) {
				List<Integer> list = deque.poll();
				int y = list.get(0);
				int x = list.get(1);
				for (int[] d : dxy) {
					int dy = y + d[0];
					int dx = x + d[1];
					if (0 <= dy && dy < h + 2 && 0 <= dx & dx < w + 2) {
						int r;
						if (map[y][x] && !map[dy][dx]) {
							r = 1;
						} else {
							r = 0;
						}
						if (cnt[dy][dx] > cnt[y][x] + r) {
							cnt[dy][dx] = cnt[y][x] + r;
							deque.offer(Arrays.asList(dy, dx));
						}
					}
				}
			}
			System.out.println(cnt[gy][gx]);
		}
	}
}

Measured memory_bytes: 35160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A, B, N;
  cin >> A >> B >> N;
  if(B - 1 <= N) {
  long long  X = B - 1;
  long long H = floor(A * X / B) - A * floor(X / B);
  cout << H << endl;
  }
  
  else {
    long long H = floor(A * N / B) - A * floor(N / B);
    cout << H << endl;
  }
}

Measured memory_bytes: 3588
"""Minimum cost Sort."""

def min_cost_sort(A):
    """Sort list A in ascending order.
 
    And return the switching cost in sorting.
    """
    B = list(A)
    B.sort()
    cost = 0
    min_w = B[0]
    for i, b in enumerate(B):
        tmp_cost = 0
        bi = A.index(b)
        n = 1
        while bi != i:
            n += 1
            st = B[bi]
            si = A.index(st)
            tmp_cost += b + st
            A[bi], A[si] = st, b
            bi = si
        dec = (n - 1) * (b - min_w)
        inc = 2 * (min_w + b)
        if dec < inc:
            cost += tmp_cost
        else:
            cost += tmp_cost - dec + inc
    return cost


n = input()

A = list(map(int, input().split()))

ans = min_cost_sort(A)

print(ans)

Measured memory_bytes: 7788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}

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

  int n;
  while(1){
    cin >> n;
    if(n == 0) break;

    int score[n];
    REP(i, n) cin >> score[i];
    stable_sort(score, score+n);

    int min = 1000001;
    REP(i, n-1) if(min > abs(score[i]-score[i+1])) min = abs(score[i]-score[i+1]);

    cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d: ",c)
int c=1;
using namespace std;
int main(){
    int t;
    cin>>t;
    t = t+t*t+t*t*t;
    cout<<t<<endl;

    }



Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;

signed main() {
	int N;
	cin >> N;
	string S;
	cin >> S;	
	int i = 0;
	int cnt = N;
	while(cnt>i) {
		if (S[i] == S[i + 1]) {
			S.erase(i, 1);
			i--;
			cnt--;
		}
		i++;
	}
	cout << S.size() << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    cout<<c-min(a-b,c)<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
}

int main(){
    ll a = in();
    ll b = in();
    ll m = in();
    vector<ll> va(a);
    vector<ll> vb(b);
    cin >> va >> vb;
    ll ans = *min_element(all(va)) + *min_element(all(vb));
    rep(i,m){
        ll x = in()-1;
        ll y = in()-1;
        ll c = in();
        chmin(ans,va[x]+vb[y]-c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
#include <limits.h>
//#include <math.h>

int main() {
  int n, k, c;
  scanf("%d%d%d", &n, &k, &c);
  char s[n+5];
  scanf("%s", s);
  int cnt[n+1], j = INT_MAX;
  cnt[n] = 0;
  for (int i=n-1; i>=0; i--) {
    if (s[i] == 'x' || j - i < c + 1)
      cnt[i] = cnt[i+1];
    else {
      cnt[i] = cnt[i+1] + 1;
      j = i;
    }
  }
  //for (int i=0; i<n; i++) printf("%d ", cnt[i]);
  int ans[k+1];
  ans[0] = INT_MIN;
  j = 0;
  for (int i=0; i<n && j<=k; i++) {
    if (s[i] == 'o' && ans[j] + c < i) {
      j++;
      ans[j] = i;
    }
  }
  //for (int i=1; i<=k; i++) printf("%d ", ans[i]);
  for (int i=0; i<k; i++) {
    if (cnt[ans[i+1]] == cnt[ans[i+1]+1]+1 && cnt[ans[i+1]] == k - i)
      printf("%d\n", ans[i+1]+1);
  }
  return 0;
}


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

using namespace std;
using ll = long long;

const int M = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; ++i) {
        ll c = 1 + ((n * (n + 1) - (n - i) * (n - i + 1))) / 2 - (i * (i - 1)) / 2;
        ans = ((ans % M) + (c % M)) % M;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3652
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, k;
    while (cin >> n >> k)
    {
        int* p = new int[n + 5], x,ji=0;
        double max = 0,ans=0;
        for (int i = 1; i <= n; i++)
        {
            cin >> p[i];
            if (ji < k)
            {
                ans = ans + double(p[i] + 1) / 2;
                
                if (ans > max) max = ans;
                ji++;
                
            }
            if (ji == k)
            {
                ans = ans - double(p[i - k + 1]+1)/2;
                
                ji--;;
            }
        }
        
        cout << fixed << setprecision(12) << max << '\n';
    }
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define INF -1000000000

struct edge{
    int from;
    int to;
    int cost;
};

int V,E,r;
edge G[510000];
int D[110000];

void bellman_ford(int s){
    int i;
    bool update;
    edge e;

    for(i=0;i<V;i++)D[i]=INF;
    D[s]=0;
    while(true){
        update=false;
        for(i=0;i<E;i++){
            e=G[i];
            if(D[e.from]!=INF && (D[e.to]==INF || D[e.to]>D[e.from]+e.cost)){
                D[e.to]=D[e.from]+e.cost;
                update=true;
            }
        }
        if(!update)break;
    }
}

int main(){
    int i;
    cin>>V>>E>>r;
    for(i=0;i<E;i++){
        cin>>G[i].from>>G[i].to>>G[i].cost;
    }

    bellman_ford(r);

    for(i=0;i<V;i++){
        if(D[i]!=INF)cout<<D[i]<<"\n";
        else cout<<"INF\n";
    }
}



Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	vector<string> a;
	int N, L;
	string s;
	cin >> N >> L;

	while (N != 0) {
		cin >> s;
		a.push_back(s);
		N -= 1;
	}

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

	vector<string>::iterator i;

	for (i = a.begin(); i != a.end(); i++) {
		cout << *i;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    int now = 101;
    int ans = 0;
    REP(i,n) {
        if (a[i] == a[i-1]) {
            a[i] = now++;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
using System;
using System.Linq;
using System.Text;

namespace ITP1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).Reverse();
            var sb = new StringBuilder();
            foreach (var n in nums)
            {
                sb.Append(string.Format(" {0}", n));
            }
            Console.WriteLine(sb.ToString().TrimStart());
        }
    }
}

Measured memory_bytes: 9592
A, B, C = input().split(" ")
A, B, C = int(A), int(B), int(C)
ans = 0
while True:
    if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
        print(ans)
        break
    if A == B and B == C:
        print(-1)
        break
    A, B, C = (B + C) / 2,  (C + A) / 2, (A + B) / 2
    ans += 1

Measured memory_bytes: 61968
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt(),d=sc.nextInt(),x=sc.nextInt();
		
		int[] xs = new int[10];
		xs[0]=r*x-d;
		for(int i=1;i<10;i++) {
			xs[i]=r*xs[i-1]-d;
		}
		
		for(Integer i : xs)System.out.println(i);
		
	}

}


Measured memory_bytes: 21844
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	int N, K;
	string s;
	cin >> N >> K >> s;

	int inv = 0;
	rep(i, N - 1)if (s[i] != s[i + 1])inv++;
	inv = max(inv - 2 * K, 0);
	cout << N - 1 - inv << endl;
	return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc091/tasks/abc091_b
// B - Two Colors Card Game
#include <stdio.h>
#include <string.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(int argc, const char * argv[]) {
    int n, m, i, j;
    char s[100][10], t[100][10];
    int c, max;
    
    n = get_num();
    for (i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    m = get_num();
    for (i = 0; i < m; i++) {
        scanf("%s", t[i]);
    }

    max = 0;
    
    for (int i = 0; i < n; i++) {
        c = 0;
        for (j = 0; j < n; j++) {
            if (strcmp(s[i], s[j]) == 0) {
                c++;
            }
        }
        for (j = 0; j < m; j++) {
            if (strcmp(s[i], t[j]) == 0) {
                c--;
            }
        }
        
        if (c > max) {
            max = c;
        }
    }
    
    printf("%d\n", max);
    
    return 0;
}


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

int main(){
	int N,K;
	string str;
	cin >> N;
	cin >> str;
	cin >> K;

	for(int i=0;i<N;i++){
		if(str[i]!=str[K-1]){
			str[i]='*';
		}
	}

	cout << str << "\n";

}



Measured memory_bytes: 256
#include <stdio.h>

int binarySearch(int,int *,int);

int main()
{
  int n,q,i,j,cnt=0,re;
  
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  } 
  scanf("%d",&q);
  int t[q];
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  
  for(i=0;i<q;i++){
    if(binarySearch(n,s,t[i])==0){
      cnt++;
    }
    
  }
  printf("%d\n",cnt);
  
  
  return 0;
}


int binarySearch(int n,int *A,int key){
  int left,right,mid;
  left=0;
  right=n;

  
  
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]){
      return 0;
    }
    else if(key>A[mid]){
      left=mid+1;
    }
    else if(key<A[mid]){
      right=mid;
    }
  }
  return 1;
}



Measured memory_bytes: 2312
#include <cstdio>
#include <cstring>
#define N 100004
using namespace std;

char s[N];
int n , to[N] , cnt[N];

int myabs(int x)
{
	return x > 0 ? x : -x;
}

int main(void)
{
	scanf("%s" , s + 1);
	n = strlen(s + 1);
	for(int i = 1 ; i <= n ; i ++)
	{
		if(s[i] == 'L')
		{
			int x = i - 1;
			while(x && s[x] == 'R')
				to[x--] = i;
		}
		if(s[i] == 'R')
		{
			int x = i + 1;
			while(x <= n && s[x] == 'L')
				to[x++] = i;
		}
	}
	for(int i = 1 ; i <= n ; i ++)
		(myabs(i - to[i]) & 1) ? cnt[ to[to[i]] ]++ : cnt[ to[i] ]++;
	for(int i = 1 ; i <= n ; i ++)
		printf("%d " , cnt[i]);
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long[] townmonster = new long[n+1];
        for(int i=0;i<n+1;i++){
            townmonster[i] = sc.nextLong();
        }

        long[] yusha = new long[n+1];
        for(int i=0;i<n;i++){
            yusha[i] = sc.nextLong();
        }
        yusha[n] = 0;

        long count =0;
        long yojou = 0;
        for(int i=0;i<n+1;i++){
            long target = townmonster[i];
            long yusha_yoryoku = yusha[i];
            if(target >= yusha_yoryoku + yojou){
                //System.out.println("if target=" + target + " yusha_yoryoku=" + yusha_yoryoku + " yojou=" + yojou + " count=" + count);
                count += yusha_yoryoku+yojou;
                yojou = 0;
            }else{
                //System.out.println("else target=" + target + " yusha_yoryoku=" + yusha_yoryoku+ " yojou=" + yojou + " count=" + count);
                count +=target;
                long nokori = target - yojou;
                if(nokori >0){
                    yojou = yusha_yoryoku-nokori;
                }else{
                    yojou = yusha_yoryoku;
                }
            }
        }
        System.out.println(count);




    }
}

Measured memory_bytes: 65088
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  def solve(sc: => Scanner): Unit = {
    val A = Array.fill(sc.nextInt)(sc.nextInt)
    var nowR = 0
    var nowL = (A.size - 1) * 10
    var flag = true
    for (i <- Range(0, A.size)) {
      if (i * 10 <= nowR) {
        nowR = math.max(nowR, i * 10 + A(i))
      } else {
        flag = false
      }
      if ((A.size - i - 1) * 10 >= nowL) {
        nowL = math.min(nowL, (A.size - i - 1) * 10 - A(A.size - i - 1))
      } else {
        flag = false
      }
    }
    if (flag) {
      println("yes")
    } else {
      println("no")
    }
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 276836
from math import atan, degrees
a,b,x= map(int,input().split())
yoseki = a**2*b
if x <= yoseki/2:
    # b*y*a/2==x
    y= 2*x/b/a
    # ９０からシータを引けば良い
    print(90-degrees(atan(y/b)))
else:
    # a*y*a/2==yoseki-x
    y = 2*(yoseki-x)/a**2
    print(degrees(atan(y/a)))


Measured memory_bytes: 62148
#include <iostream>
using namespace std;
int main(void){
  for(;;){
    int N, A, B, C;
    long long int X;
    cin >> N >> A >> B >> C >> X;
    if(N == 0){ return 0; }
    int Y[N];
    for(int i = 0 ; i < N ; i++){
      cin >> Y[i];
    }
    int i = 0;
    bool finish = false; int ans = -1;
    for(int step = 0 ; step <= 10000 && finish == false ; step++){
      if(X == Y[i]){
	if(i == N - 1){finish = true; ans = step;}else{i++;}
      }
      X = (A * X + B) % C;
    }
    cout << ((finish==true)?(ans):(-1)) << endl;
  }
}



Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
int n;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  ll ans = 1;
  FOR(i, 1, n+1) ans=ans*i%MOD;
  bool d=true, p=true;
  int c=0;
  for(char h:s){
    bool z = (h=='W');
    if(p==z) d^=true;
    if(d){
      c++;
    }else{
      ans=ans*c%MOD;
      c--;
    }
    p=z;
  }
  cout << (c?0:ans) << endl;
}

Measured memory_bytes: 720
//            ____             ____
//           /@@@@\           |@@@@|      ____
//          /@@@@@@\          |@@@@|     |@@@@|
//         /@@@@@@@@\         |@@@@|   __|@@@@|___    ____       ____      ___  _________     ____        ____    ____________      ___  _________     ____         ____
//        /@@@@/\@@@@\        |@@@@|   @@@@@@@@@@@   |@@@@|     |@@@@|    |@@@\/@@@@@@@@@\   (@@@@\      /@@@@)  /@@@@@@@@@@@@|    |@@@\/@@@@@@@@@\   (@@@@\       /@@@@)
//       /@@@@/  \@@@@\       |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|    \@@@@@|   \@@@@\    /@@@@/  |@@/     |@@@@|    |@@@@|    \@@@@@|   \@@@@\     /@@@@/
//      /@@@@(____)@@@@\      |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|    \@@@@\  /@@@@/            |@@@@|    |@@@@|     |@@@@|    \@@@@\   /@@@@/
//     /@@@@@@@@@@@@@@@@\     |@@@@|     |@@@@|      |@@@@|     |@@@@|    |@@@@|     |@@@@|     \@@@@\/@@@@/    /@@@@@@@@@@@@@|    |@@@@|     |@@@@|     \@@@@\ /@@@@/
//    /@@@@@@@@@@@@@@@@@@\    |@@@@|     |@@@@|___   |@@@@|____/@@@@@|    |@@@@|     |@@@@|      \@@@@@@@@/    (@@@@(   )@@@@@|    |@@@@|     |@@@@|      \@@@@|@@@@/
//   /@@@@/          \@@@@\   |@@@@|     |@@@@@@@@    \@@@@@@@@@@@@@@|    |@@@@|     |@@@@|       \@@@@@@/      \@@@@\_/@@@@@@|    |@@@@|     |@@@@|       \@@@@@@@/
//  /@@@@/            \@@@@\  |@@@@|      \@@@@@@/      \@@@@@/  \@@@|    |@@@@|     |@@@@|        )@@@@/        \@@@@@@@/\@@@|    |@@@@|     |@@@@|        \@@@@@/
//                                                                                                (@@@@/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

//-----------------------------------------------
#define all(x)  x.begin(), x.end()
#define sz(x)   (int)x.size()
#define sq(x)   (x) * (x)
#define fr      first
#define sc      second
//-----------------------------------------------
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<ll, int>;

const int N = 300 * 1000 + 5;
const ll mod = 1000000007;
const ll INF = 1000000 * 1ll * 10000000 * 1ll * 1000;
const ld pi = acosl(-1.0);

int n;
vector<int> a;

void input() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
}

void solve(int testId) {
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += a[i / 2];
    }
    cout << ans << endl;
}



int main() {
    // freopen("test", "r", stdin);
    int testcases = 1;
    // scanf("%d", &testcases);
    for(int testId = 1; testId <= testcases; testId++) {
        input();
        solve(testId);
    }
    return 0;
}


Measured memory_bytes: 4032
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, a, b, c = map(int,input().split())
    D = {"AB" : (0, 1), "AC" : (0, 2), "BC" : (1, 2)}
    E = {0 : 'A', 1 : 'B', 2 : 'C'}
    queries = [D[input()] for _ in range(n)]
    s = a + b + c

    if s != 2:
        ans = []
        state = [a, b, c]
        for i, j in queries:
            if state[i] == 0 and state[j] == 0:
                print("No")
                return
            if state[i] < state[j]:
                state[i] += 1
                state[j] -= 1
                ans.append(E[i])
            else:
                state[i] -= 1
                state[j] += 1
                ans.append(E[j])
        print("Yes")
        print(*ans, sep = '\n')
        return

    # s = 2
    dp = set()
    dp.add((a, b, c))
    prev = [{} for _ in range(n)]
    for k in range(n):
        ndp = set()
        i, j = queries[k]
        for state in dp:
            if state[i] > 0:
                next = list(state)
                next[i] -= 1
                next[j] += 1
                next = tuple(next)
                ndp.add(next)
                prev[k][next] = state
            if state[j] > 0:
                next = list(state)
                next[j] -= 1
                next[i] += 1
                next = tuple(next)
                ndp.add(next)
                prev[k][next] = state
        dp = ndp

    if not dp:
        print("No")
        return

    for now in dp:
        break

    ans = []
    for k in range(n - 1, -1, -1):
        pa, pb, pc = prev[k][now]
        a, b, c = now
        if a > pa:
            ans.append('A')
        elif b > pb:
            ans.append('B')
        elif c > pc:
            ans.append('C')
        now = prev[k][now]
    ans.reverse()


    print("Yes")
    print(*ans, sep = '\n')
resolve()

Measured memory_bytes: 127052
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int yen = 0;
		if (a < 6) {
			yen = 0;
		} else if (a > 5 & a < 13) {
			yen = b / 2;
		} else {
			yen = b;
		}
		System.out.println(yen);
	}
}

Measured memory_bytes: 21844
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def nc2(n):
    return n * (n-1) // 2
def main():
    n, m = LI()
    A = LI()
    cnt = 0
    cumsum = [0] * (n+1)
    d = collections.defaultdict(int)
    for i in range(n):
        cumsum[i+1] = (cumsum[i] % m + A[i] % m) % m
        d[cumsum[i+1]] += 1
    for k, v in d.items():
        cnt += nc2(v)
        if k % m == 0:
            cnt += v
    print(cnt)



main()



Measured memory_bytes: 84844
import numpy as np

N,W=map(int,input().split())

dp=np.zeros(W+1,dtype=int)

for _ in range(N):
  w,v=map(int,input().split())
  #dp[:-w]までの部分は、wの荷物を抱えても重量制限を超えないため、
  #ここに価値を乗せたものと今までのものを要素ごとに比べるnp.maximumを使う
  dp[w:]=np.maximum(dp[:-w]+v,dp[w:])

print(dp[W])

Measured memory_bytes: 15464
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	//freopen("input.txt", "r", stdin); // redirects standard input
	//freopen("output.txt", "w", stdout); // redirects standard output

	int n, a, b, c, i, j, k;
	cin >> n >> a >> b >> c;
	vector<string> ss(n);

	if (a > 5) a = 5;
	if (b > 5) b = 5;
	if (c > 5) c = 5;

	vector<map<tuple<int, int, int>, char>> dp(n + 1);
	dp[0][{a, b, c}] = ' ';

	for (i = 0; i < n; i++) {
		string s;
		cin >> s;
		ss[i] = s;

		for (auto p : dp[i]) {
			tie(a, b, c) = p.first;
			if (s == "AB") {
				if (b > 0) dp[i + 1][{ a + 1, b - 1, c }] = 'A';
				if (a > 0) dp[i + 1][{ a - 1, b + 1, c }] = 'B';
			}
			if (s == "AC") {
				if (c > 0) dp[i + 1][{ a + 1, b, c - 1 }] = 'A';
				if (a > 0) dp[i + 1][{ a - 1, b, c + 1 }] = 'C';
			}
			if (s == "BC") {
				if (b > 0) dp[i + 1][{ a, b - 1, c + 1 }] = 'C';
				if (c > 0) dp[i + 1][{ a, b + 1, c - 1 }] = 'B';
			}
		}
	}

	if (dp[n].empty()) cout << "No\n";
	else {
		cout << "Yes\n";

		vector<char> ans;
		tie(a,b,c) = dp[n].begin()->first;
		char ch = dp[n].begin()->second;

		for (i = n - 1; i >= 0; i--) {
			if (ss[i] == "AB") a++, b++;
			if (ss[i] == "AC") a++, c++;
			if (ss[i] == "BC") c++, b++;

			ans.push_back(ch);
			if (ch == 'A') a -= 2;
			if (ch == 'B') b -= 2;
			if (ch == 'C') c -= 2;

			ch = dp[i][{a, b, c}];
		}

		reverse(ans.begin(), ans.end());
		for (auto ch : ans) cout << ch << "\n";
	}



	return 0;
}

Measured memory_bytes: 218724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    string s,t;cin >> s >>t;
    vvl dp(s.size()+1,vl(t.size()+1));
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],max(dp[i][j+1],dp[i+1][j]));
        }
    }
    /*rep(i,s.size()+1){
        rep(j,t.size()+1){
            cout << dp[i][j]<<" ";
        }
        cout <<endl;
    }*/
    string ans;ll now=t.size();
    perl(i,s.size()+1,1){
        while(dp[i][now]==dp[i][now-1])now--;
        if(dp[i][now]!=dp[i-1][now])ans+=s[i-1];
    }
    rev(all(ans));cout << ans <<endl;
}

Measured memory_bytes: 73668