akhauriyash/Code-Regression huggingface dataset:
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[100005],b[100005],c[100005];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        a[i]=x+max(b[i-1],c[i-1]);
        b[i]=y+max(a[i-1],c[i-1]);
        c[i]=z+max(a[i-1],b[i-1]);
    }
    printf("%d\n",max(a[n],max(b[n],c[n])));
	//system("pause");
	return 0;
}


Measured memory_bytes: 1408
n = int(input())
H = [int(i) for i in input().split()]

ans = 'Yes'
Max = H[0]
for i in range(1, n):
    if Max - H[i] >= 2:
        ans = 'No'
        break
    else:
        Max = max(Max, H[i])
        
print(ans)

Measured memory_bytes: 20372
@arr = []
def partition(p, r)
  q = @arr[r]
  i = p - 1
  (p..r-1).each do |j|
    if @arr[j] <= q
      i += 1
      @arr[i], @arr[j] = @arr[j], @arr[i]
    end
  end
  @arr[i+1], @arr[r] = @arr[r], @arr[i+1]
  i+1
end
n = gets.to_i
@arr = gets.split.map(&:to_i)
q = partition(0, n-1)
result = @arr.map(&:to_s)
result[q] = "[#{result[q]}]"
puts result.join(' ')


Measured memory_bytes: 14460
#include <stdio.h>

int main(void){
	int n, a[200001]={0}, f[200001]={0}, i, p=1, j, x,pp;
	long k;
	
	scanf("%d", &n);
	scanf("%ld", &k);
	for(i=1; i < n+1; i++){
		scanf("%d", &a[i]);
	}
	
	f[1]=1;
	for(i = 2; i < 200002; i++){
		if(i == k+2){
			printf("%d", p);
			return 0;
		}
		pp = p;
		p = a[pp];
		if(f[p] == 0){
			f[p] = i;
		}else{
			break;
		}
	}
	
	x = i - f[p];
	j = (k - (f[p]-1)) % (i - f[p]);
	
	for(i = 0; i < j; i++){
		pp = p;
		p = a[pp];
	}
	
	printf("%d", p);
	
	return 0;
}

Measured memory_bytes: 3296
if __name__ == "__main__":
    row_num, col_num = map(lambda x: int(x), input().split())
    table = [[0] * col_num] * row_num
    total_sum = 0

    for r in range(row_num):
        table[r] = list(map(lambda x: int(x), input().split()))

    for r in range(row_num):
        print(" ".join([str(elem) for elem in table[r] + [sum(table[r])]]))

    for c in range(col_num):
        col_sum = sum(map(lambda x: x[c], table))
        total_sum += col_sum
        print(f"{col_sum} ", end="")
    print(f"{total_sum}")



Measured memory_bytes: 5716
S = list(str(input()))
T = list(str(input()))

S_ = set(list(S))
T_ = set(list(T))
for c in T:
    if c not in S_:
        print(-1)
        exit()

d = [[] for _ in range(26)]
for i, s in enumerate(S):
    d[ord(s)-ord('a')].append(i)
#print(d)

q = 0
pre = -1
import bisect
for t in T:
    j = ord(t)-ord('a')
    idx = bisect.bisect_right(d[j], pre)
    if idx == len(d[j]):
        q += 1
        pre = d[j][0]
    else:
        pre = d[j][idx]
print(q*len(S)+pre+1)


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

int main() {
  string S;
  cin >> S;
 
  int n =0;
  for(int i=0;i<3;i++){
    if(S.at(i)=='R'){
      n++;
    }
  }
  
  if(n==2 && S.at(1)=='S'){
    n --;
  }
  
  cout << n << endl;
}


Measured memory_bytes: 3580
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
 
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  vi l(n);
  rep0(i,n)  cin >> l[i];
  sort(all(l));
  ll cnt = 0;
  rep0(i,n-1)  cnt += l[i];
  if(cnt > l[n-1]){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 2000

int a[N], n, sum, q, m, i;

int divide(int i,int m){
  if(sum < m)return 0;
  if(m == 0)return 1;
  if(i >= n)return 0;
  return divide(i+1,m) || divide(i+1,m-a[i]);
}

int main(){

  sum = 0;
  scanf("%d",&n);

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

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if (divide(0,m)){
      printf("yes\n");
    }else{
      printf("no\n");
    }

  }
  return 0;
}

Measured memory_bytes: 2692
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
#define ll long long
#define rg register
#define go(i,x,a) for(rg int i=a;i<x;i++)
using namespace std;

const int maxn=1e4+5;
int n,a,b,c;
char s[20];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc == '-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
//	freopen("1.in","r",stdin);
	n=rd(); int ss=0;
	go(i,n+1,1){
		scanf("%s",s); int x=strlen(s);
		go(j,x-1,0)
			if(s[j] == 'A' && s[j+1] == 'B') ss++;
		a+=(s[x-1] == 'A' && s[0] != 'B');
		b+=(s[x-1] != 'A' && s[0] == 'B');
		c+=(s[x-1] == 'A' && s[0] == 'B');
	}
	if(a > 0 && b > 0) ss+=c+min(a,b);
	else{
		if(a > 0 || b > 0){
			ss+=c;
		}else{
			if(c != 0) ss+=c-1;
		}
	}
	printf("%d\n",ss);
	return 0;
}

Measured memory_bytes: 256
use proconio::marker::*;
use proconio::*;
use std::cmp::*;

pub trait MoOperator: Sized {
    type Query;
    type Answer;
    fn size(&self) -> usize;
    fn init(&mut self);
    fn insert(&mut self, v: usize);
    fn delete(&mut self, v: usize);
    fn answer(&mut self, q: Self::Query) -> Self::Answer;
    fn solve(
        mut self,
        mut query: Vec<(usize, usize, Self::Query)>,
        answer: &mut [Self::Answer],
    ) {
        let mut state = self;
        let size = state.size();
        assert!(query.len() <= answer.len());
        assert!(query.iter().all(|p| p.0 < p.1 && p.1 <= size));
        if query.is_empty() {
            return;
        }
        let batch = (size as f64 / (query.len() as f64).sqrt()).ceil() as usize;
        let mut q = vec![];
        std::mem::swap(&mut q, &mut query);
        let mut query = (0..(size / batch + 1)).map(|_| vec![]).collect::<Vec<_>>();
        for (i, (l, r, op)) in q.into_iter().enumerate() {
            query[l / batch].push((r, l, i, op));
        }
        state.init();
        let mut x = 0;
        let mut y = 0;
        for (i, mut query) in query.into_iter().enumerate() {
            query.sort_unstable_by_key(|p| p.0);
            if i & 1 == 1 {
                query.reverse();
            }
            for (r, l, k, op) in query.into_iter() {
                for v in (min(x, l)..x).rev() {
                    state.insert(v);
                    x = l;
                }
                for v in min(y, r)..r {
                    state.insert(v);
                    y = r;
                }
                for v in min(x, l)..l {
                    state.delete(v);
                    x = l;
                }
                for v in (min(y, r)..y).rev() {
                    state.delete(v);
                    y = r;
                }
                answer[k] = state.answer(op);
            }
        }
    }
}

struct State {
    c: Vec<usize>,
    cnt: Vec<u32>,
    ans: usize,
}

impl MoOperator for State {
    type Query = ();
    type Answer = usize;
    fn size(&self) -> usize {
        self.c.len()
    }
    fn init(&mut self) {
        for c in self.cnt.iter_mut() {
            *c = 0;
        }
        self.ans = 0;
    }
    fn insert(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: usize) {
        let c = &mut self.cnt[self.c[x]];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&mut self, _q: Self::Query) -> usize {
        self.ans
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ask: Vec<_> = ask.into_iter().map(|(l, r)| (l, r, ())).collect();
    let mut ans = vec![0; q];
    State {
        c: c,
        cnt: vec![0; n],
        ans: 0,
    }.solve(ask, &mut ans);
    for a in ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 41684
#include<bits/stdc++.h>
using namespace std;
using ll= long long;
int main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(auto &i:a)cin>>i;
    ll tk=1000,stock=0;

    for(ll i=1;i<a.size();i++)
    {
        if(a[i]>a[i-1])
        {
           stock=tk/a[i-1];
           tk=tk%(stock*a[i-1]);
           tk+=(stock*a[i]);
        }
    }
    cout<<tk<<endl;
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint a(3);
    REP(i,3) cin >> a[i]; 
    sort(ALL(a));
    int ans;
    if((a[2]-a[0]+a[2]-a[1])%2==0){
        ans = (a[2]-a[0]+a[2]-a[1])/2;
    }else{
        ans = (a[2]-a[0]+a[2]-a[1]+3)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    vector<vector<double>> dp(N+1, vector<double>(N+2, 0));
    vector<double> p(N);
    rep(i, N) cin >> p[i];

    dp[0][1] = 1;
    rep(i, N) {
        rep(j, i+2) {
            dp[i+1][j+1] = dp[i][j] * p[i] + dp[i][j+1] * (1-p[i]);
        }
    }
    
    double ans = 0;
    repr(i, N/2+2, N+2) ans += dp[N][i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int MAX = 8;
		char[][] map = new char[MAX][MAX];
		for (int i = 0; i < MAX; i++) {
			map[i] = scanner.next().toCharArray();
		}
		for (int n = 1; n < 4; n++) {
			char[][] tmp = new char[MAX][MAX];
			System.out.println(n * 90);
			for (int i = 0; i < MAX; i++) {
				for (int j = 0; j < MAX; j++) {
					tmp[i][j] = map[MAX - 1 - j][i];
					System.out.print(tmp[i][j]);
				}
				System.out.println();
			}
			map = tmp;
		}
	}
}

Measured memory_bytes: 17148
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main() {
	long long int X;
	int i;
	double m;
	std::cin >> X;

	m = 100;
	i = 0;

	while (m < X) {
		i++;
		m = floor(m * 1.01);

	}

	cout << i << endl;
	return 0;
}


Measured memory_bytes: 3256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        char c1 = a[i], c2 = b[i], c3 = c[i];
        if (c1 == c2 && c2 == c3)
            continue;
        else if (c1 == c2 || c2 == c3 || c3 == c1)
            cnt++;
        else
            cnt += 2;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int n,k;
	cin >> n >>k;
	if (n >= 2 * k - 1)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

   int n;
   cin >> n;
   vector<ll> a(3*n);
   rep(i, 0, 3 * n) cin >> a[i];
   sort(all(a), greater<ll>());
   ll ans = 0;
   for (int i = 1; i < 2*n; i += 2) {
      ans += a[i];
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        long k = Long.parseLong(scan.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
            a[i]--;
        }
        scan.close();

        int[] arrive = new int[n];
        boolean[] isUsed = new boolean[n];
        Arrays.fill(isUsed, false);
        arrive[0] = 0;
        isUsed[0] = true;
        int breakTown = 0;
        int breakIndex = 0;
        for (int i = 1; i <= n; i++) {
            int next = a[arrive[i - 1]];
            if (isUsed[next]) {
                breakTown = next;
                breakIndex = i;
                break;
            }

            isUsed[next] = true;
            arrive[i] = next;
        }

        int loopStartIndex = 0;
        for (int i = 0; i < n; i++) {
            if (arrive[i] == breakTown) {
                loopStartIndex = i;
                break;
            }
        }

        int loopLength = breakIndex - loopStartIndex;
        if (k <= loopStartIndex) {
            System.out.println(arrive[(int)k] + 1);
        } else {
            long index = (k - loopStartIndex) % loopLength;
            System.out.println(arrive[(int)index + loopStartIndex] + 1);
        }

    }
}


Measured memory_bytes: 59776
#include<stdio.h>
int main(void)
{
    int n,x = 0,y = 0;
    int i;
    int time = 0;
    for(i = 0; i < 4; i++){
        scanf("%d",&n);
        time += n;
    }
    for(i = 0;; i++){
        if(time - 60 >= 0){
            time -= 60;
            x++;
        }
        else{
            y = time;
            break;
        }
    }
    printf("%d\n%d\n",x,y);

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

#define MAX_LEN 100

using namespace std;

int a[MAX_LEN];

void printArray(int *a, int len)
{
	for (int i = 0; i < len; i++)
	{
		printf("%d", a[i]);
		if (i != len - 1) printf(" ");
	}
	printf("\n");
}

void swap(int *a, int i, int j)
{
	int temp;
	temp = a[i];
	a[i] = a[j];
	a[j] = temp;
}

struct card
{
	int n;
	char c;
};

void printArray(card *cards, int len)
{
	for (int i = 0; i < len; i++)
	{
		printf("%c", cards[i].c);
		printf("%d", cards[i].n);
		if (i != len - 1) printf(" ");
	}
	printf("\n");
}

void swap(card *cards, int i, int j)
{
	card temp;
	temp = cards[i];
	cards[i] = cards[j];
	cards[j] = temp;
}

int compare(card c1, card c2)
{
	if (c1.n < c2.n)
	{
		return -1;
	}
	else if (c1.n == c2.n)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

bool isSame(card *cards1, card *cards2, int len)
{
	for (int i = 0; i < len; i++)
	{
		if (cards1[i].n != cards2[i].n)return false;
		if (cards1[i].c != cards2[i].c)return false;
	}
	return true;
}



void BubbleSort(card *cards, int len, int(*compare)(card, card))
{
	for (int i = 0; i < len - 1; i++)
	{
		for (int j = len - 1; j > i; j--)
		{
			if (compare(cards[j - 1], cards[j]) > 0)
			{
				swap(cards, j - 1, j);
			}
		}
	}
}

void SelectionSort(card *cards, int len, int(*compare)(card, card))
{
	for (int i = 0; i < len - 1; i++)
	{
		int min = i;
		for (int j = i + 1; j < len; j++)
		{
			if (compare(cards[j], cards[min]) < 0)
			{
				min = j;
			}
		}
		swap(cards, i, min);
	}
}

card cards1[MAX_LEN];
card cards2[MAX_LEN];

int main()
{
	int len;
	scanf("%d", &len);

	for (int i = 0; i < len; i++)
	{
		int n;
		char c;

		std::cin >> c >> n;

		cards1[i].n = n;
		cards1[i].c = c;
		cards2[i].n = n;
		cards2[i].c = c;
	}

	BubbleSort(cards1, len, compare);
	printArray(cards1, len);
	printf("Stable\n");

	SelectionSort(cards2, len, compare);
	printArray(cards2, len);
	if (isSame(cards1, cards2, len))
	{
		printf("Stable\n");
	}
	else
	{
		printf("Not stable\n");
	}
}


Measured memory_bytes: 3188
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

#define M 1064527

int main(){
    ll x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
   
    if(x1==0) cout << 1 << endl;
    else if(x2==0) cout << 2 << endl;
    else if(x3==0) cout << 3 << endl;
    else if(x4==0) cout << 4 << endl;
    else if(x5==0) cout << 5 << endl;
    return 0;
}

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((100*r+10*g+b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a_data;
  vector<int> b_data;
  a_data.push_back(-1);
  b_data.push_back(-1);
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    a_data.push_back(a);
    b_data.push_back(b);
  }
  sort(ALL(a_data));
  sort(ALL(b_data));

  ll ans;
  if (n % 2 == 0) {
    double mid_a = (double)(a_data[n / 2] + a_data[(n / 2) + 1]) / 2.0;
    double mid_b = (double)(b_data[n / 2] + b_data[(n / 2) + 1]) / 2.0;
    ans = 2 * (mid_b - mid_a) + 1;
  } else {
    int mid_a = a_data[(n + 1) / 2];
    int mid_b = b_data[(n + 1) / 2];
    ans = mid_b - mid_a + 1;
  }

  cout << ans << endl;
}

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

using namespace std ;

#define N 83

bool dp[N][N][3*N*N] ;
int a[N][N] , b[N][N] ; 
int n , m ;

signed main()
{
    scanf("%d%d" , &n , &m ) ;
    for(int i = 1 ; i <= n ; i++ ){
        for(int j = 1 ; j <= m ; j++ ){
            scanf("%d" , &a[i][j] ) ;
        }
    }
    for(int i = 1 ; i <= n ; i++ ){
        for(int j = 1 ; j <= m ; j++ ){
            scanf("%d" , &b[i][j] ) ;
        }
    }
    int M = 6400 ;
    dp[1][1][ a[1][1] - b[1][1] + M ] = 1 ;
    for(int i = 1 ; i <= n ; i++ ){
        for(int j = 1 ; j <= m ; j++ ){
            if( i == 1 && j == 1 ) continue ;
            for(int k = 0 ; k <= 2 * M ; k++ ){
                int t = a[i][j] - b[i][j] ;
                if( i > 1 && k - t >= 0 && k - t <= 2 * M ) 
                dp[i][j][k] |= dp[i - 1][j][k - t] ;
                if( i > 1 && k + t >= 0 && k + t <= 2 * M )
                dp[i][j][k] |= dp[i - 1][j][k + t] ;
                if( j > 1 && k - t >= 0 && k - t <= 2 * M )
                dp[i][j][k] |= dp[i][j - 1][k - t] ;
                if( j > 1 && k + t >= 0 && k + t <= 2 * M )
                dp[i][j][k] |= dp[i][j - 1][k + t] ;
            }
        }
    }
    int ans = 0 ;
    for(int i = 0 ; i <= M ; i++ ){
        if( dp[n][m][i + M] | dp[n][m][M - i] ){
            //printf("ok\n") ;
            ans = i ; break ;
        }
    }
    cout << ans ;
    return 0 ;
}

Measured memory_bytes: 135680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = br.readLine();
        String[] sp = is.split(" ");
 
        int W = Integer.parseInt(sp[0]);
        int H = Integer.parseInt(sp[1]);
        
        int x = Integer.parseInt(sp[2]);
        int y = Integer.parseInt(sp[3]);
        int r = Integer.parseInt(sp[4]);
 
        if(x - r < 0){
        	// ???????????????????????????
        	System.out.println("No");
        	return;
        }else if(y - r < 0){
        	// ???????????????????????????
        	System.out.println("No");
        	return;
        }else if(x + r > W){
        	// ???????????????????????????
        	System.out.println("No");
        	return;
        }else if(y + r > H){
        	// ???????????????????????????
        	System.out.println("No");
        	return;
        }else{
        	System.out.println("Yes");
        }
       	return;
    }
}

Measured memory_bytes: 24436
import java.util.Scanner;

public class Main {
	
	private static void kou2(int a,int b){
		int min = Math.min(a,b);
		for(int i=1;i<=min;i++){
			if(a%i + b%i == 0)
			System.out.println(i);
		}
	}
	
	private static void kou3(int a,int b,int c){
		int min  = Math.min(c,Math.min(a,b));
		for(int i=1;i<=min;i++){
				if(a%i + b%i + c%i == 0)
				System.out.println(i);
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a,b,c;
		a = sc.nextInt();
		b = sc.nextInt();
		if(n==3){
			c = sc.nextInt();
			kou3(a,b,c);
		}
		if(n==2)
			kou2(a,b);
	}
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;


int main() {
	ll N, L; cin >> N >> L;
	vector<ll> a(N);
	ll id = 1e8;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (i != 0 && a[i - 1] + a[i] >= L)id = i;
	}

	if(id==1e8)cout << "Impossible" << endl;
	else {
		cout << "Possible" << endl;
		for (int i = 1; i < id; i++) {
			cout << i << endl;
		}
		for (int i = N - 1; i > id; i--) {
			cout << i << endl;
		}
		cout << id << endl;
	}

}


Measured memory_bytes: 4048
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	v := 2 * ModPow(9, N) % Mod
	v = v + Mod - ModPow(8, N)
	v %= Mod
	ans := ModPow(10, N) + Mod - v
	ans %= Mod
	fmt.Println(ans)
}

const Mod = int(1e9) + 7

func ModPow(a, b int) (x int) {
	for x = 1; b > 0; b >>= 1 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
	}
	return
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
n, m = map(int, input().split())

ans_list = list(map(int, input().split()))[1:]
for _ in range(1, n):
    a = list(map(int, input().split()))[1:]
    tmp_list = []
    for ans in ans_list:
        if ans in a:
            tmp_list.append(ans)
    ans_list = tmp_list

print(len(ans_list))

Measured memory_bytes: 3060
"use strict"
const Main = (input) =>{
  let xs = input.trim().split(" ").map(v=>parseInt(v,10));
    let A = xs[0];
    let B = xs[1];
    let C = xs[2];
    let ans = "NO";
      for(let i=0; i<=100; i++){
        if((A*i)%B==C){
          ans = "YES"
          break;
        }
      }
    console.log(ans);
  }
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 29580
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;
 
template<int MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
 
 
const int MOD = 998244353;
using mint = Fp<MOD>;
 
int main(void){
  int N; cin >> N;
  vector<ll> a(N);
  ll S = 0;
  int i;REP(i,N) cin >> a[i], S+=a[i];
 
  vector<vector<mint> > dp(N+1,vector<mint>(S+1,0));
  dp[0][0] = 1;
  auto dp2 = dp;
 
  REP(i,N){
    for(int v = 0; v+a[i]<=S; v++){
      //赤に塗る場合の数
      dp[i+1][v+a[i]] += dp[i][v];
      //ア海外に塗るときの場合の数
      dp[i+1][v] += dp[i][v]*2;
 
      dp2[i+1][v+a[i]] += dp2[i][v];
      dp2[i+1][v] += dp2[i][v];
    }
  }
 
  mint all = modpow(mint(3),N);
  mint Complement = 0;
 
  //S/2を超える数を数え上げる
  for(i=S/2+1;i<=S;i++) Complement += dp[N][i]*3;
  if(S%2==0){
    //偶数の時にはS/2もたして，一つが0，二つがS/2になる場合を引く
    Complement += (dp[N][S/2] - dp2[N][S/2])*3; 
  }
  cout << all - Complement << endl;
  return 0;
}

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

const int N = 2e5+4;

int BIT[N];

int query(int x){
	int ans=0;
	for(;x>0;x-=(x&-x)){
		ans+=BIT[x];
	}
	return ans;
}
void update(int x,int delta){
	for(;x<N;x+=(x&-x)){
		BIT[x]+=delta;
	}
}
int fin_pos[N];
int main(){
	string s;
	cin>>s;
	vector<int> occ[26];
	long long ans=0;
	for(int i=0;i<(int)s.size();++i){
		occ[s[i]-'a'].push_back(i);
	}
	int odd_count=0;
	for(int i=0;i<26;++i){
		if(((int)occ[i].size())%2){
			odd_count++;
		}
	}
	if(odd_count>1){
		cout<<-1<<endl;
		return 0;
	}
	vector<pair<int,int> > lr; 
	for(int i=0;i<26;++i){
		for(int j=0;((int)occ[i].size())-1-j>=j;++j){
			lr.push_back(make_pair(occ[i][j],occ[i][((int)occ[i].size())-j-1]));
		}
	}
	sort(lr.begin(),lr.end());
	int idx=-1;
	for(int i=0;i<(int)lr.size();++i){
		if(lr[i].first==lr[i].second)
			idx=i;
	}
	if(idx!=-1){
		pair<int,int> k = lr[idx];
		lr.erase(lr.begin()+idx);
		lr.push_back(k);
	}
	for(int i=0;i<(int)lr.size();++i){
		fin_pos[lr[i].first+1]=i+1;
		fin_pos[lr[i].second+1]=(int)s.size()-i;
	}

	for(int i=1;i<=(int)s.size();++i){
		ans+=query(N-1)-query(fin_pos[i]);
		update(fin_pos[i],1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	string s,t;
	cin>>s>>t;
	if(t.length()-1==s.length())
	{
		bool temp=true;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]!=t[i])
			{
				temp=false;
				break;
			}
		}
		if(temp)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3632
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc167
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc167A();
            Console.Out.Flush();
        }

        public static void solve_abc167B()
        {
        }

        public static void solve_abc167A()
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            Console.WriteLine(a.Equals(b.Substring(0, b.Length - 1)) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 26724
number = gets.to_i

if 100 <= number && number <= 999
  result = number%100%10
elsif 10<=number && number<=99
  result = number%10
else
  result = number
end

if result == 3
  puts 'bon'
elsif result == 0 || result == 1 || result == 6 || result == 8
  puts 'pon'
else
  puts 'hon'
end


Measured memory_bytes: 14348
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
		int stop=1;
	
	if(n>=1&&n<=81){
	for(int i=1;i<=9;i++){
	
		for(int j=1;j<=9;j++){
			int temp = i*j;
			if(n==temp){
				printf("Yes");
				stop--;
				break;
		}
	}
	if(stop==0){
		break;
			}
	}	
		}
			else{
				printf("No");
				stop--;
				}
					if(stop>0){
					printf("No");
			
		}
	return 0;
}

Measured memory_bytes: 1704
n = int(input())
s = input()
num = float("inf")
RW = [0] * n
LW = [0] * n
RE = [0] * n
LE = [0] * n
for i in range(1, n):
    w = 0
    if s[i - 1] == "W":
        w += 1

    RW[i] = RW[i - 1] + w

for i in range(n - 2, -1, -1):
    e = 0
    if s[i + 1] == "E":
        e += 1

    LE[i] = LE[i + 1] + e

num = float("inf")
for i in range(n):
    num = min(num, RW[i] + LE[i])

print(num)



Measured memory_bytes: 31776
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,k=1; cin>>n;
    while(n>k*(k-1)/2) k++;
    if(n!=k*(k-1)/2)
    cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        cout<<k<<endl;
        vector<vector<int>> m(k);
        int cnt=1;
        for(int i=0;i<k-1;i++){
            for(int j=i+1;j<k;j++){
                m[i].push_back(cnt);
                m[j].push_back(cnt);
                cnt++;
            }
        }
        rep(i,k){
            cout<<2*n/k<<" ";
            rep(j,2*n/k-1) cout<<m[i][j]<<" ";
            cout<<m[i][2*n/k-1]<<endl;
        }
    }
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

bool is_kaibun(string s){
    bool res = true;
    for(int i=0; i < s.size() / 2; i++){
        if(s[i] != s[s.size() - 1 - i]) res = false;
    }
    return res;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        string tmp = to_string(i);
        if(is_kaibun(tmp)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Mod{
    static final int MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        LinkedList<Integer> list = new LinkedList<>();
        for(int n=0; n<N; n++){
            int x = sc.nextInt();
            if(n==0 || !list.getLast().equals(x)) list.addLast(x);
        }
        Integer[] C = list.toArray(new Integer[0]);
        N = C.length;
        //System.err.println(Arrays.toString(C));

        long[] ans = new long[N];
        long[] count = new long[200001];
        ans[0]=1; count[C[0]]=1;
        for(int n=1; n<N; n++){
            ans[n] = Mod.add(ans[n-1],  count[C[n]]);
            count[C[n]] = Mod.add(count[C[n]], ans[n-1]);
        }
        System.out.println(ans[N-1]);
    }
}

Measured memory_bytes: 103476
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
            
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }     
signed main()
{   jaldi
    int a,b;
    cin>>a>>b;
    if(a<=b)
    cout<<1;
    else
    {   if(a%b==0)
        cout<<a/b;
        else
        cout<<(a/b)+1;       
    }
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i = 0;i< n;i++)
#define INF 200
typedef long long int ll;
using namespace std;

int m,n;
int pow3[12];
int obj[200];
int dp[177150];//?????¢?´¢-1,?????¨?????????-2,?????????????????¢?´¢?????°
int fact(int num,int i){
    return (num/pow3[i])%3;
}

void dfs(int que){
    if(dp[que]!=-1)
        return;
    dp[que]=INF;
    int left=0;
    rep(i,n){   //??????????????§????????????????????????
        int flag = 1;
        rep(j,m){
            int hoge = fact(que,j);
            if(!hoge)
                continue;
            else{
                hoge--;
                if(hoge!=(obj[i]>>j&1)){
                    flag=0;
                    break;
                }
            }
        }
        left+=flag;
    }
    if(left == 1){
        dp[que]=0;
        return;
    }else if(left == 0){
        dp[que]= INF;
        return;
    }
    rep(i,m){
        if(!fact(que,i)){
            int tempmax = -1;
            rep(yn,2){
                int next = que + (yn+1)*pow3[i];
                dfs(next);
                switch(dp[next]){
                    case -1:
                        break;
                    default:
                        tempmax=max(tempmax,dp[next]);
                        break;
                }
            }
            dp[que]=min(dp[que],tempmax+1);
        }
    }
    return;
};

int main(){
    int temp = 1;
    rep(i,12){
        pow3[i]=temp;
        temp *= 3;
    }

    while(cin >> m >> n&&m){
        rep(i,pow3[m]){
            dp[i]=-1;
        }
        rep(i,n){
            obj[i]=0;
            string tmp;
            cin >> tmp;
            rep(j,m){
                obj[i]+= (tmp[j]-'0') << (m-1-j);
            }
        }
        dfs(0);
        cout << dp[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long m = sc.nextLong();
		
		if(m <= 2*n) {
			System.out.println(m/2);
		}else {
			System.out.println(n + (m-2*n)/4);
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const double pie = acos(-1.0);

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

void solve() {
    ll n; cin >> n;
    Vl a(n), b(n, 0);
    rep(i, 0, n) cin >> a[i];
    if(n%2 == 0){
        rep(i, 0, n/2) b[i] = a[(n-1)-2*i];
        rep(i, n/2, n) b[i] = a[(i-n/2)*2];
    }else{
        rep(i, 0, (n+1)/2) b[i] = a[(n-1)-2*i];
        rep(i, (n+1)/2, n) b[i] = a[1+2*(i-(n+1)/2)];
    }

    rep(i, 0, n){
        if(i) cout << " ";
        cout << b[i];
    }
    cout << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 5376
n=int(input())
v=sorted(list(map(int,input().split())))

while len(v) != 1:
  f=v[0]
  s=v[1]
  sums=(f+s)/2
  v.pop(1)
  v.pop(0)
  v.append(sums)
  v=sorted(v)

print(v[0])



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  int a, b;
  cin >> a >> b;
  cout << a * b;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a[25];
int b[25];
int c[25];

int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=n; i++) cin>>b[i];
	for(int i=1; i<n; i++) cin>>c[i];
	int last = -1;
	int curr;
	int ret = 0;
	for(int i=1; i<=n; i++){
		curr = a[i];
		ret+=b[curr];
		if(last+1==curr) ret+=c[last];
		last = curr;
	}	
	cout<<ret;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n,k,i;
  scanf("%d",&n);
  char string[n];
  scanf("%s",string);
  scanf("%d",&k);
  for(i=0;i<n;i++){
  if(string[i]!=string[k-1]){
    string[i]='*';
 }
}
 printf("%s\n",string);
 return 0;
}

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

int main() {
  int A, B, c;
  string S;
  char s;
  c=1;
  cin >> A >> B >> S;
  
  for(int i=0; i<A+B+1; i++) {
    if(S.at(i)!='-') {
      c++;
    }
  }
  s=S.at(A);
  if(s!='-') {
    c=0;
  }
  if(c==A+B+1) {
  cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}



Measured memory_bytes: 256
N = gets.to_i
list = gets.split.map(&:to_i)

u = []
for k in 0..N-1 do
  u[k] = 0
end

count = 0

for i in 0..N-2 do
    u[list[i]-1] += 1
end

for k in 0..N-1 do
  puts u[k]
end

Measured memory_bytes: 34560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		
		System.out.println((a + b) * h / 2);

	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
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
#define MAX_N 100100 * 3

int h, w, n;
int a[100100];
int table[1000][1000];
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
	int now = 1;
	int y = 0,x = 0;
	bool f = 1;
	while (f) {
		f = 0;
		table[y][x] = now;
		rep(i, 4) {
			int ny = y + dy[i], nx = x + dx[i];
			if (ny >= 0 && ny < h&&nx >= 0 && nx < w) {
				if (table[ny][nx] == 0) {
					a[now - 1]--;
					if (a[now - 1] == 0)now++;
					f = 1;
					y = ny; x = nx;
					break;
				}
			}
		}
	}
}


int main() {
	cin >> h >> w >> n;
	rep(i, n)cin >> a[i];
	solve();
	rep(i, h) {
		rep(j, w) {
			if (j != w - 1)cout << table[i][j] << " ";
			else cout << table[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 2688
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll func(int n){
  ll ret = 1LL;
  
  rep(i,n/2){
    ret *= 2;
    ret %= 1000000007;
  }
  
  return ret;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(),a.end());
  
  if(n%2){//奇数人数の場合
    if(a[0] != 0){
      cout << 0;
      return 0;
    }
    int i = 1;
    
    while(i < n){
      if(a[i] != i+1 || a[i] != i+1){
        cout << 0;
        return 0;
      }
      i += 2;
    }
    ll ans = func(n);
    cout << ans;
  }else{
    int i = 1;
    while(i < n){
      if(a[i-1] != i || a[i] != i){
        cout << 0;
        return 0;
      }
      i += 2;
    }
    
    ll ans = func(n);
    cout << ans;
    return 0;
  }
  
  return 0;
}

Measured memory_bytes: 640
from heapq import heappop, heappush
n = int(input())
grid = [list(map(int, input().split())), list(map(int, input().split()))]


def biggest(grid, start, cost=0):
    dist = [[0 for _ in range(n)] for _ in range(2)]
    dx = [1, 0]
    dy = [0, 1]
    st = [(cost, start)]
    dist[start[0]][start[1]] = grid[start[0]][start[1]] + cost
    while(st):
        c, [sx, sy] = heappop(st)
        for a, b in zip(dx, dy):
            x = sx + a
            y = sy + b
            if x >= 2 or y >= n:
              continue
            dxy = dist[sx][sy] + grid[x][y]
            if dist[x][y] >= dxy:
                continue
            dist[x][y] = dxy
            heappush(st, (dist[x][y], [x, y]))
    return dist[-1][-1]


dist = biggest(grid, [0, 0], cost=0)
print(dist)

Measured memory_bytes: 3064