akhauriyash/Code-Regression huggingface dataset:
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    int r;
    scanf("%d",&r);
    printf("%d\n",3*r*r);
    return 0;



}

Measured memory_bytes: 128
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
k = int(input())
sum = 0
for a in range(k):
    for b in range(a+1):
        for c in range(b+1):
            if a == b and b == c:
                sum+=gcd(a+1, b+1, c+1)
            elif a!=b and b!=c and c!=a:
                sum += 6*gcd(a+1, b+1, c+1)
            else:
                sum += 3*gcd(a+1, b+1, c+1)
print(sum)

Measured memory_bytes: 9632
#include<bits/stdc++.h>
#define LL long long
#define ls o << 1
#define rs o << 1 | 1
using namespace std;
typedef pair<LL,LL> pll;
const int maxn = 1e5 + 10;
int n;
LL c, x[maxn], v[maxn];
vector<pll> V;

LL sum[maxn], res[maxn];

struct Tree
{
    LL mx;
}tree[4 * maxn];

void Build(int o, int l, int r)
{
    if(l == r){
        tree[o].mx = res[l];
        return  ;
    }
    int m = (l + r) >> 1;
    Build(ls, l, m);
    Build(rs, m + 1, r);
    tree[o].mx = max(tree[ls].mx, tree[rs].mx);
}

LL Query(int o, int l, int r, int ql, int qr)
{
    if(ql > qr)
        return -1LL;
    if(ql <= l && r <= qr)
        return tree[o].mx;
    LL ret = -1;
    int m = (l + r) >> 1;
    if(ql <= m)
        ret = max(ret, Query(ls, l, m, ql, qr));
    if(qr > m)
        ret = max(ret, Query(rs, m + 1, r, ql, qr));
    return ret;
}

int main()
{
    scanf("%d%lld", &n, &c);
    for(int i = 0; i < n; i ++){
        LL x, v;
        scanf("%lld%lld", &x, &v);
        V.push_back(pll(x, v));
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < n; i ++)
        x[i] = V[i].first, v[i] = V[i].second;

    x[n] = c;
    LL ans = 0;
    for(int i = n - 1; i >= 0; i --)
        sum[i] = sum[i + 1] + v[i] - abs(x[i] - x[i + 1]), ans = max(ans, sum[i]);

    for(int i = 0; i < n; i ++){
        if(i == 0){
            res[i] = v[i] - x[i];
        }else {
            res[i] = res[i - 1] + v[i] - abs(x[i] - x[i - 1]);
        }
        ans = max(ans, res[i]);
    }


    Build(1, 0, n);
    for(int i = n - 1; i >= 0; i --){
        if(sum[i] < 0)
            continue;
        LL mx = Query(1, 0, n, 0, i - 1);
        ans = max(ans, sum[i] + max(0LL, mx - (c - x[i])));
    }

    for(int i = 0; i < n; i ++){
        if(i == 0){
            sum[i] = v[i] - x[i];
        }else {
            sum[i] = sum[i - 1] + v[i] - abs(x[i] - x[i - 1]);
        }
    }

    for(int i = n - 1; i >= 0; i --)
        res[i] = res[i + 1] + v[i] - abs(x[i] - x[i + 1]);

    Build(1, 0, n);
    for(int i = 0; i < n; i ++){
        if(sum[i] < 0)
            continue;
        LL mx = Query(1, 0, n, i + 1, n - 1);
        ans = max(ans, sum[i] + max(0LL, mx - x[i]));
    }

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


Measured memory_bytes: 8176
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 10;

int n, size[N], p[N];
map <long long, int> who_is;
vector <int> c[N];
long long d[N];

void contradict_if (bool, string = "no exit msg");
long long dfs (int, int = -1);
int get_par (int);

int32_t main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		who_is[d[i]] = i;
	}

	vector <int> ver(n);
	iota (ver.begin(), ver.end(), 0);
	sort (ver.begin(), ver.end(), [] (int a, int b) {
		return d[a] > d[b];
	});
	int root = ver.back();

	for (int v: ver) {
		if (v == root)
			continue;

		size[v]++;
		contradict_if (size[v] * 2 > n, "size failture");

		p[v] = get_par(v);
		size[p[v]] += size[v];
		c[p[v]].push_back(v);
	}

	contradict_if (dfs(root) != d[root], "Root failed");
	for (int v: ver)
		for (int u: c[v])
			cout << v + 1 << ' ' << u + 1 << endl;
}

void contradict_if (bool condition, string msg) {
	if (!condition)
		return;
	cout << -1;
	// cerr << " " << msg;
	cout << endl;
	exit(0);
}

int get_par (int v) {
	long long pev = d[v] - n + 2 * size[v];
	contradict_if (who_is.find(pev) == who_is.end(), "parent not found");
	return who_is[pev];
}

long long dfs (int v, int pv) {
	long long res = 0;
	for (int u: c[v])
		res += size[u] + dfs(u, v);
	return res;
}

// SamMHD :: 05/12/2018 12:30:04 :: Another Tree...

Measured memory_bytes: 17408
from collections import deque
S = deque([str for str in input()])
dic = 1
Q = int(input())
for i in range(0,Q):
    Query = input()
    if Query == '1':
        dic = dic*(-1)
    else:
        T, F, C = Query.split()
        if (int(F)*dic == 2) or (int(F)*dic == -1):
            S.append(C)
        else:
            S.appendleft(C)
print(''.join(list(S)[::dic]))

Measured memory_bytes: 10724
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <string>
#include <iostream>

using namespace std;

char down_cast(char c) {
    if(isupper(c)) c=tolower(c);
    return c;
}

int main(void) {
    string s,t;
    int c[26]={};
    while(getline(cin,t)) s+=t;

    for(int i=0;i<s.size();i++) {

        if(s[i]==' ' || s[i]=='.') continue;
        c[down_cast(s[i])-'a']++;
    }

    for(int i=0;i<26;i++) {
        printf("%c : %d\n",i+'a',c[i]);
    }
    


}



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

int main(){
  string S;
  cin >> S;
  int64_t K;
  cin >> K;
  int64_t ans=0;
  bool flag=false;
  char c=S.at(0);
  bool judge=true;
  int64_t x=0;
  for(int i=1;i<S.size();i++){
    if(flag){
      flag=false;
      continue;
    }
    if(S.at(i)==S.at(i-1)){
      ans++;
      flag=true;
    }
  }
  if(S.size()%2!=0){
    for(int i=1;i<S.size();i++){
      if(c!=S.at(i)){
        judge=false;
        break;
      }
    }
    if(judge){
      for(int64_t i=1;i<=K;i++){
        if(i%2==0){
          x+=ans+1;
        }else{
          x+=ans;
        }
      }
      cout << x << endl;
      return 0;
    }
  }
  int64_t n=ans;
  c=S.at(0);
  judge=false;
  flag=true;
  string T="";
  if(S.size()>=2){
    if(S.at(0)==S.at(S.size()-1)){
      for(int i=0;i<S.size();i++){
        if(c==S.at(i)){
          T+=S.at(i);
        }else{
          if((flag)&&(T.size()%2!=0)){
            judge=true;
          }
          T=S.at(i);
          c=S.at(i);
          flag=false;
        }
      }
      if((judge)&&(T.size()%2!=0)){
        judge=true;
      }else{
        judge=false;
      }
      if(judge){
        n+=(ans+1)*(K-1);
        cout << n << endl;
        return 0;
      }
    }
    }
  ans*=K;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

      int n =0,k  =0,  result=0;

scanf("%d", &n) ;int  h[100001] ;

      scanf("%d", &k);

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

      scanf("%d" , &h[i] );

      if(h[i]>=k) result++ ;}

      printf("%d", result);return  0;}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    cout<<count(all(s),'1')<<endl;
}


Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000



int main(){
    int n;
    cin>>n;
    char S[110],T[110];
    cin>>S>>T;
    rep(i,0,n){
        cout<<S[i]<<T[i];
    }
    cout<<endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <sys/time.h>

void calc_skip(char pattern[], int m, int skip[]) {
	skip[0] = -1;
	int j = 0;
	for (int i = 1; i < m; i++, j++) {
		if (pattern[i] == pattern[j]) skip[i] = skip[j];
		else {
			skip[i] = j;
			while (0 <= j && pattern[i] != pattern[j]) j = skip[j];
		}
	}
	skip[m] = j;
}

void kmp(char text[], char pattern[]) {
	int n = strlen(text), m = strlen(pattern), skip[m + 1], i = 0, j = 0, flag = 1;
	calc_skip(pattern, m, skip);
	while (i < n) {
		if (text[i] == pattern[j]) {
			i++;
			j++;
			if (j == m) {
				flag = 0;
				//	printf("%d番目からpatternが見つかりました。\n", i - j);
				printf("%d\n", i - j);
				j = skip[j];
			}
		}
		else {
			j = skip[j];
			if (j == -1) {
				i++;
				j++;
			}
		}
	}
	//	if (flag) puts("文字列が見つかりませんでした。");
}

int main(void) {
	char text[1000001], pattern[10001];
	scanf("%s%s", text, pattern);
	struct timeval s, e;
	gettimeofday(&s, NULL);
	kmp(text, pattern);
	gettimeofday(&e, NULL);
	//	printf("%f", 1.0e-6 * (e.tv_usec - s.tv_usec) + e.tv_sec - s.tv_sec);
	return 0;
}


Measured memory_bytes: 2872
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;


typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int N;
vector<int> h(100010);
vector<int> dp(100010);
int main(void){
    cin >> N;
		for(int i = 1; i <= N; i++) cin >> h[i];
		dp[0] = INF;
		dp[1] = 0;
		for(int i = 2; i <= N; i++){
			dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
		}
		cout << dp[N] << endl;

}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    REP(i, n+1){
        REP(j, n+1){
            int s = r*i + g*j;
            if(n >= s && (n - s) % b == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void scd(int &a){scanf("%d",&a);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a,b;
	scdd(a,b);
	if(a>b)
	printf("a > b\n");
	else if(a<b)
	printf("a < b\n");
	else if(a==b)
	printf("a == b\n");
	return 0;
}

Measured memory_bytes: 3108
s = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())

num = 0
cnt = 1
while((num+pow(26,cnt)) < n):
    num += pow(26,cnt)
    cnt += 1

n -= num
n -= 1

ans = ""
while(cnt > 0):
    a = n // pow(26,cnt-1)
    n -= (pow(26,cnt-1)*a)
    cnt -= 1
    ans = ans + s[a]
print(ans)

Measured memory_bytes: 9180
# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())

d = {}
for i in range(2, n+1):
    p = prime_factorize(i)
    for cp in p:
        if cp in d:
            d[cp] += 1
        else:
            d[cp] = 1

cnt = {75:0, 25:0, 15:0, 5:0, 3:0}
for i in d:
    for j in cnt:
        if d[i] >= j-1:
            cnt[j] += 1
ans = cnt[75] + cnt[25]*(cnt[3]-1) + cnt[15]*(cnt[5]-1) + cnt[5]*(cnt[5]-1)//2*(cnt[3]-2)
print(ans)

Measured memory_bytes: 9256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! {
        n: u64,
        a: [usize; n],
    }
    let mut sum = 0;
    sum = a.iter().sum();
    if sum % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }

}


Measured memory_bytes: 6396
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	
	if(a>=b&&a>=c)
	printf("%d",b+c);
	
	else if(b>=a&&b>=c)
	printf("%d",a+c);
	
	else
	printf("%d",a+b);
	
	return 0;
}

Measured memory_bytes: 1712
from functools import reduce

def main():
    n, a, b = map(int,input().split())
    mod = 10 ** 9 + 7
    def f(k):
        num = reduce(lambda x,y: x * y % mod, range(n, n-k, -1))
        den = reduce(lambda x,y: x * y % mod, range(1, k+1))
        return num * pow(den, mod-2, mod) % mod
    ans = pow(2,n,mod) - f(a) - f(b) - 1
    ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
    

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long

using namespace std ;

const int MAXN = 1001 * 1001 ; 

int a[MAXN] , n ;

bool check(int i)
{
	int s = 0 , x = a[i] ; 
	for( ; s < n ; s ++ ) 
	{
		if(s==i) continue ; 
		if(a[s]>2*x) return 0 ; 
		x += a[s] ; 
	}
	return 1 ;
}

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	cin >> n ; 
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i] ; 
	sort(a,a+n) ; 
	int l = -1 , r = n - 1 ;
	while(r-l>1)
	{
		int mid = (r+l) / 2; 
		if(check(mid))
			r = mid ; 
		else
			l = mid; 
	}
	cout << n - r << '\n' ; 
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <cassert>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define bounded(x, N) 0<=(x) && (x) < (N)
#define boundedXY(x,y,M,N) bounded(x, M) && bounded(y, N)

#define rrep(i, a, N) for (i=(N)-1;i>=(a);i--)
#define rep(i, a, N) for (i=(a);i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;

const int MAXN = 100001;
int f[2][MAXN] = {};

int main() {
	std::ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int i;
	rep(i, 0, n) {
		int k;
		cin >> k;
		f[i%2][k]++;
	}

	int m[2][2]= { {0, 0}, {0, 0} };
	int el[2][2] = { {0, 0}, {0, 0} };

	int j;
	rep(i, 0, MAXN) {
		rep(j, 0, 2) {
			if (f[j][i] > m[j][0] && f[j][i] > m[j][1]) {
				m[j][1] = m[j][0];
				m[j][0] = f[j][i];
				el[j][0] = i;
			} else if (f[j][i] > m[j][1]) {
				m[j][1] = f[j][i];
				el[j][1] = i;
			}
		}
	}

	if (el[0][0] != el[1][0]) {
		cout << n - (m[0][0] + m[1][0]) << endl;
	} else if (m[0][0] + m[1][1] > m[0][1] + m[1][0]) {
		cout << n -(m[0][0] + m[1][1]) << endl;
	} else {
		cout << n -(m[0][1] + m[1][0]) << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#inlcude<stringstream>
#define ll long long
#define MODD 1000000007
using namespace std;

int main() {
    ll n ,k;cin>>n>>k;
    ll sum=0;
    if(k==0)cout<<n*n<<endl;
    else {
        for(ll i = k+1;i<=n;i++){
            sum+=(n/i)*(i-k);
            if(n%i>=k) sum+=n%i-k+1;
        }
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
//
// Created by Yu on 2020/08/11.
//


#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
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

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

int main() {
    int n;
    cin>>n;
    ll x;
    cin>>x;
    for (int i = 1; i < n; ++i) {
        ll a;
        cin>>a;
        x = gcd(x,a);
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3640
while true
    a, op, b = gets.chomp.split
    break if op == "?"

    a = a.to_i
    b = b.to_i

    case op
    when "+" then
        puts a + b
    when "-" then
        puts a - b
    when "*" then
        puts a * b
    when "/" then
        puts a / b
    end
end

Measured memory_bytes: 8552
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int res = 0;
    for(int i = 0; i <= 9; i++) {
        for(int j = 0; j <= 9; j++) {
            for(int k = 0; k <= 9; k++) {
                vector<int> check(3);
                check[0] = i, check[1] = j, check[2] = k;
                int now = 0;
                rep(l, N) {
                    if(s[l] - '0' == check[now]) {
                        now++;
                        if(now == 3) {
                            res++;
                            break;
                        }
                    }
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long 
 
int main(){
    int x;
    cin>>x;
    
    while(true){
    int flg=0;
    for(int i=2;i*i<x;i++)
     { 
       if(x%i==0)
         flg=1;
     }
    if(flg==1){
      x++;
    }
    else{
      cout<<x;
      break;}
    }
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

    string to_string(const string& s) { return '"' + s + '"'; }
    void debug_out() { cout << endl; }
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) { cout << " " << to_string(H); debug_out(T...); }
    #ifdef LOCAL
        #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    #else
        #define debug(...) 3;
    #endif

    #define fast_io ios_base::sync_with_stdio(false); \
                    cin.tie(nullptr); cout.tie(nullptr);
    using ld = long double;  using ui = uint_fast32_t;
    using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

void solve() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'a') continue;
        int d = 'z' - s[i] + 1;
        if (k >= d) {
            k -= d;
            s[i] = 'a';
        }
    }
    s[n - 1] += k % 26;
    cout << s << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io; int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) solve();
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m;
  cin >> m;
  rep(l,m){
    ll y,n,a,cost,fund;
    double rate;
    cin >> fund >> y>>n;
    ll ans = 0,money = fund;
    rep(i,n){
      money = fund;
      cin >> a >> rate >> cost;
      if(a){
        rep(j,y){
          money += ll(money*rate) - cost;
        }
      }
      else{
        ll sum = 0;
        rep(i,y){
          sum += ll(money*rate);
          money -= cost;
        }
        money += sum;
      }
      ans = max(ans,money);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
const int Inf = 1e9 + 5;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int rowMask = 0; rowMask < (1 << n); rowMask++) {
        for (int colMask = 0; colMask < (1 << m); colMask++) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (((rowMask >> i & 1) == 0) && ((colMask >> j & 1) == 0) && (a[i][j] == '#')) {
                        cnt++;
                    } 
                }
            }
            if (cnt == k) {
                ans++;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

int main(){
    int n,c(1000000),ans(0);
    cin >> n;
    rep(i,n){
        int p;  cin >> p;
        if(p<=c){
            c = p;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

//floor(a/b)=(a-a%b)/bとすることでfloorを消せる

int main(){
    ll a, b, n;
    cin >> a >> b >> n;

    ll x=n;
    if(n>= b-1) x = b-1;
    ll ans = a*(x%b)/b;
    cout << ans << endl;
    

    
}   

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

int prim(int v, vector< vector< pair<int,int> > > G){
  //v: 頂点数, G: 隣接リスト
  int INF = 1000000000;
  priority_queue< pair<int, int> > wait;
  int result = 0;
  vector<bool> connected(v,false);
  vector<int> cost(v,INF);
  wait.push(make_pair(0, 0));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = -wait.top().first;
    wait.pop();
    if(!connected[nowpoint]){
      result += nowcost;
      connected[nowpoint] = true;
      for(int i = 0; i < G[nowpoint].size(); ++i){
	int nextpoint = G[nowpoint][i].second;
	int nextcost = G[nowpoint][i].first;
	if(nextcost < cost[nextpoint]){
	  wait.push(make_pair(-nextcost, nextpoint));
	  cost[nextpoint] = nextcost;
	}
      }
    }
  }
  return result;
}

int main(){
  int N;
  cin >> N;
  int x, y;
  vector< pair<int,int> > X, Y;
  for(int i = 0; i < N; ++i){
    cin >> x >> y;
    X.push_back(make_pair(x,i));
    Y.push_back(make_pair(y,i));
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  
  vector< vector< pair<int,int> > > G(N);
  for(int i = 1; i < N; ++i){
    int x1 = X[i-1].first, x2 = X[i].first, s = X[i-1].second, t = X[i].second;
    G[s].push_back(make_pair(abs(x1-x2),t));
    G[t].push_back(make_pair(abs(x1-x2),s));
    int y1 = Y[i-1].first, y2 = Y[i].first;
    s = Y[i-1].second, t = Y[i].second;
    G[s].push_back(make_pair(abs(y1-y2),t));
    G[t].push_back(make_pair(abs(y1-y2),s));
  }
  cout << prim(N,G) << endl;
  return 0;
}


Measured memory_bytes: 18284
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X,A,B = map(int,readline().split())

print('delicious' if B-A<=0 else 'safe' if B-A<=X else 'dangerous')


Measured memory_bytes: 3060
e1,e2,e3,e4=map(int,input().split())
if e1==e2 and e3==e4:
    print("yes")
elif e2==e3 and e1==e4:
    print("yes")
elif e1==e3 and e2==e4:
    print("yes")
elif e1==e2==e3==e4:
    print("yes")
else:
    print("no")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int N, K, x;
  long int t=0;
  cin >> N >> K;
  vector<long int> vec(N);
  
  for (long int i=0; i<N; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  
  for (long int i=0; i<N-K; i++) {
    t += vec[i];
  }
  
  cout << t << endl;
  
  return 0;
  
}

Measured memory_bytes: 1792
from collections import Counter

h, w = map(int, input().split())
ctr = Counter()
for _ in range(h):
    ctr.update(input())

need = [0] * 3  # need[x]:=2**x個重複している要素の必要数
if h % 2 == 0:
    if w % 2 == 0:
        need[2] = h * w
    else:
        need[2] = h * w - h
        need[1] = h
else:
    if w % 2 == 0:
        need[2] = h * w - w
        need[1] = w
    else:
        need[2] = h * w - (h + w - 1)
        need[1] = h + w - 2
        need[0] = 1

for power in range(2, -1, -1):
    for char in ctr:
        if not need[power]:
            break
        p2 = pow(2, power)
        while ctr[char] >= p2:
            ctr[char] -= p2
            need[power] -= p2

if any(p > 0 for p in need):
    print('No')
else:
    print('Yes')

# ee
# 4: h*w

# eo, even=h
# 2: h
# 4: h*w - h

# oo
# 1: 1
# 2: h+w-1
# 4: h*w-(h+w)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define PI (3.141592653589793)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int V,E;
vector<int> G[100010];
int dp[100010];

int search(int vertex){
    if(G[vertex].size()==0)return 0;
    if(dp[vertex]!=-1) return dp[vertex];
    int res=0;
    rep(i,G[vertex].size()){
        chmax(res, search(G[vertex].at(i))+1);
    }
    return dp[vertex]=res;
}

signed main(){
    cin>>V>>E;
    vector<int> ways(V,0);
    rep(i,E){
        int x,y; cin>>x>>y;
        G[x-1].push_back(y-1);
        ways[y-1]++;
    }
    vector<int> vs;
    rep(i,V){
        if(ways.at(i)==0)vs.push_back(i);
    }
    fill(dp,dp+V,-1);
    int ans=0;
    rep(i,vs.size()){
        chmax(ans, search(vs.at(i)));
    }
    cout<<ans<<endl;
}

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

using namespace std;

vector<stack<int> > st;

void f0()
{
    int p1,p2;
    cin>>p1>>p2;

    st[p1].push(p2);
}

void f1()
{
    int p;
    cin>>p;

    if(!st[p].empty())
        cout<<st[p].top()<<endl;
}

void f2()
{
    int p;
    cin>>p;

    if(!st[p].empty()) st[p].pop();
}

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

    cin>>n>>q;

    st.resize(n);

    while(q--)
    {
        int op;
        cin>>op;

        switch(op)
        {
            case 0:f0();break;
            case 1:f1();break;
            case 2:f2();break;
        }
    }


    return 0;
}



Measured memory_bytes: 4400
#include <stdio.h>

int main(void){
    int n, x;
    int i, j, k;
    int c;

    while(1){
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0)
            break;
        c = 0;
        for(i = 1; i <= n; i++){
            for(j = 1; j < i; j++){
                for(k = 1; k < j; k++){
                    if(i == j && j == k) continue;
                    if(i + j + k == x)
                        c++;
                }
            }
        }
        printf("%d\n", c);
    }
    return 0;
}

Measured memory_bytes: 1828
#include <iostream>
#include <algorithm>
#include <numeric>
const int NUM = 10000;

using namespace std;

int main() {
    int n, a[NUM];
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    cout << *min_element(a, a + n) << " "
         << *max_element(a, a + n) << " "
         << accumulate(a, a + n, 0LL) << endl;
    return 0;
}


Measured memory_bytes: 3140
import sys
import math

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    check_pairwise()
    check_set()
    return


def check_pairwise():
    active = set()
    for i in range(0, n):
        pp = getprimes(a[i])
        for p in pp:
            if p in active:
                return
            else:
                active.add(p)
    print("pairwise coprime")
    exit()



def check_set():
    active = getprimes(a[0])
    for i in range(1, n):
        if not a[i] % a[i-1] == 0:
            rm = []
            for act in active:
                if not a[i] % act == 0:
                    rm.append(act)
            for r in rm:
                active.remove(r)
                if not active:
                    print("setwise coprime")
                    exit()
    if not active:
        print("setwise coprime")
        exit()
    print("not coprime")
    exit()




def getprimes(num):
    if not num:
        return set()
    if num in primes:
        return set([num])
    pp = set()
    for p in iterprimes:
        if p > int(math.sqrt(num)+2):
            break
        if num % p == 0:
            pp.add(p)
            if num // p in primes:
                pp.add(num // p)

    return pp




def n_primes(n):
    nums = list(range(0, n + 1))
    primes = []
    for i in range(2, n + 1):
        num = nums[i]
        if num != 0:
            primes.append(num)
            for i in range(0, n // num + 1):
                nums[i * num] = 0
    return primes


n = RN()
a = sorted(RA())
iterprimes = n_primes(10 ** 6)
primes = set(iterprimes)
solve()


Measured memory_bytes: 182560
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int a; cin >> a;
		string s; cin >> s;
		cout << (a >= 3200 ? s : "red") << endl;
    return;
}

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



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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N; N *= 2;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	sort(arr.begin(), arr.end());
	int ans = 0;
	for (int i = 0; i < N; i += 2) {
		ans += arr[i];
	}
	print(ans);
}

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

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    bool f=true;
    if(x+r>w) f=false;
    else if(x-r<0) f=false;
    else if(y+r>h) f=false;
    else if(y-r<0) f=false;
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<stack>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)

using namespace std;


int main(){
	stack<int> rail;
	int num;

	while (cin >> num){
		if (num == 0){
			cout << rail.top() << endl;
			rail.pop();
		}
		else{
			rail.push(num);
		}
	}


}

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

using namespace std;

int main() {
	int N, a, b, sum;
	cin >> N;
	sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		sum += b - a + 1;
	}
	cout << sum << endl;
}

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

#define MAX 100001

int T[MAX];
bool P[MAX];

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

  int N, M, pn, ac = 0, wa = 0;
  string s;
  cin >> N >> M;

  for (int i = 1; i <= N; i++)
  {
    P[i] = false;
    T[i] = 0;
  }
  
  for (int i = 0; i < M; i++)
  {
    cin >> pn >> s;
    if(s == "AC")
    {
      if(!P[pn])
      {
        ac++;
        wa += T[pn];
        P[pn] = true;
      }
    }
    else if (s == "WA")
    {
      if(!P[pn]) T[pn]++;
    }
  }

  cout << ac << " " << wa << endl;

  return 0;
}

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

const int maxn = 2e5+5;

int n, arr[maxn];

int main(){
   cin >> n;
   for (int i = 0; i < n; i++) cin >> arr[i];
   for (int i = n - 1; i >= 0; i -= 2) printf("%d ", arr[i]);
   for (int i = (n % 2); i < n; i += 2) printf("%d ", arr[i]);
   return 0;
}

Measured memory_bytes: 2944
import collections

N = int(input())
As =  list(map(int, input().split()))
Bs = [As[i]+i+1 for i in range(N)]
Cs =  collections.Counter(Bs)

rlt = 0
#print(Cs)
for j in range(1,N):
  c = As[j] - (j+1)
  rlt += Cs[-c]
  #print(c)

print(rlt)

Measured memory_bytes: 133952
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
#define ll long long
ll INF = 9e17;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	reverse(h.begin(), h.end());

	int ans = 0;
	int val = 0;
	for(int i=1;i<n;i++) {
		if(h[i-1] <= h[i]) val++;
		else val = 0;
		ans = max(ans,val);
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll maxs = 1e6;

int main()
{
    ll n;
    cin >> n;
    ll a[n],i;
   // a[0] = LLONG_MAX;
    for(i = 0;i < n;i++)
        cin >> a[i];
    ll dp[n] = {0};
    dp[1] = llabs(a[1] - a[0]);
    for(i = 2;i < n;++i)
    {
        dp[i] = min((llabs(a[i] - a[i - 2]) + dp[i - 2]),(llabs(a[i] - a[i - 1]) + dp[i - 1]));
    }
    
    cout << dp[n - 1];
}

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

map<int, int> col;

void dfs(vector<vector<pair<int, int>>> &to, int current, int currentcolor, int k) {
  int index = 0;
  for (int i = 0; i < to.at(current).size(); i++) {
    auto x = to.at(current).at(i);
    if (col[x.first]) continue;
    col[x.first] = (currentcolor + index) % k + 1;
    to.at(current).at(i) = make_pair(x.first, col[x.first]);
    index++;
    dfs(to, x.first, col[x.first], k);
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> to(n);
  map<pair<int, int>, int> g;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to.at(a).emplace_back(b, 0);
    to.at(b).emplace_back(a, 0);
    g[make_pair(min(a, b), max(a, b))] = i;
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    k = max(k, (int) to.at(i).size());
  }
  cout << k << endl;
  col[0] = 1;
  dfs(to, 0, 1, k);
  vector<int> c(n - 1);
  for (int i = 0; i < n; i++) {
    for (auto x : to.at(i)) {
      int j = x.first, color = x.second;
      if (color == 0) continue;
      c.at(g[make_pair(min(i, j), max(i, j))]) = color;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << c.at(i) << endl;
  }
  for (int i = 0; i < n; i++) {
    for (auto x : to.at(i)) {
      cerr << i << " " << x.first << " " << x.second << endl;
    }
  }
}


Measured memory_bytes: 18304
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char s[1000];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<n;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        long h = sc.nextLong();
      	long w = sc.nextLong();
      	long ans;
      
      	if(h == 1 || w == 1) ans = 1;
      	else if(h*w % 2 == 0) ans = h*w/2;
      	else ans = h*w/2+1;
          
      	System.out.println(ans);      	        
	}
}

Measured memory_bytes: 35640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n], b[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(a,a+n);
  int lar=a[n-1], slar=a[n-2];
  for(int i=0;i<n;++i){
  if(b[i]==lar) cout<<slar<<'\n';
    else cout<<lar<<'\n';
  }
}


Measured memory_bytes: 3200
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int a,b;
    char op;
    cin>>a>>op>>b;
    if(op=='+')cout << a+b;
    else cout << a-b << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3572