akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int k, n;
  cin >> k >> n;
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  int dif = 0, cnt = 0;
  for(int i = 0; i < n - 1 ; i++){
    if(dif <= data.at(i + 1) - data.at(i)){
      dif = data.at(i + 1) - data.at(i);
      cnt = i;
    }
    else{
      continue;
    }
  }
  cout << min(k - (data.at(cnt + 1) - data.at(cnt)), data.at(n -1) - data.at(0)) << endl;
}

    


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

int main() {
 int N,cnt=0,ans=0;
  cin >> N;
  vector<int> high(N);
  for(int i=0;i<N;i++){
  cin >> high[i];
  }

  for(int i=1;i<N;i++){
     for(int j=0;j<i;j++){
       if(high[i] >= high[j]){
       cnt++;
       }
     }
     if(cnt ==i){
      ans++;

     }
   cnt =0;
  }

  cout << ans+1 << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto hw = readInts();
		auto h = hw[0];
		auto w = hw[1];
		if(h == 0 && w == 0) {
			return;
		}

		auto hm = 150;
		auto wm = 150;
		auto less = (int w1, int h1, int w2, int h2) {
			return w1*w1 + h1*h1 < w2*w2 + h2*h2 ||
				(w1*w1 + h1*h1 == w2*w2 + h2*h2 && h1 < h2);
		};

		for(int i = 1; i < 150; ++i) {
			for(int j = i+1; j < 150; ++j) {
				auto d2 = h*h + w*w;
				if(less(w, h, j, i) && less(j, i, wm, hm)) {
					hm = i;
					wm = j;
				}
			}
		}
		writeln(hm, " ", wm);
	}
}

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

int n,a,b;

int isWinning(int other, int now){
    int ans = 0;
    if(now==n && other==n-1) return 0;
    if(now==0 && other==1) return 0;
    if(now+1!=(n+1))
        if(!isWinning(now, now+1)) ans |= 1;
    if(now-1!=0)
        if(!isWinning(now, now-1)) ans |= 1;
    return ans;
}



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

    int x = b-a;
    if(x&1){
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(all(a),greater<ll>());

    ll ans = 0;
    rep(i,n){
        if(i == 0) continue;
        ll k = i/2;
        ans += a[k];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4784
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]

re=10**18
for i in range(2**N):
    mlst=[0 for i in range(M)]
    lst=[i>>m&1 for m in range(N)]
    #print(lst)
    value=0
    for n in range(N):
        if lst[n]:
            for m in range(M):
                mlst[m]+=CA[n][m+1]
            value+=CA[n][0]
    for m in range(M):
        if mlst[m]<X:
            break
    else:
        #print(mlst,value)
        re=min(re,value)

if re==10**18:
    print(-1)
else:
    print(re)


Measured memory_bytes: 73716
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define Zero(dp) memset(dp,0,sizeof(dp))
#define pb emplace_back
using namespace std;
int32_t main(){
/*
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
*/
ios
int t=1;
//cin>>t;
while(t--)
{
	int n;cin>>n;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[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-1];
}
}

Measured memory_bytes: 1792
s = input()
import collections
from collections import deque
list_A = deque()
list_Z = deque()
for i in range(len(s)) :
    if s[i] == "A" :
        list_A.append(i)
    if s[i] == "Z" :
        list_Z.append(i)
print(list_Z[-1] - list_A[0] + 1)

Measured memory_bytes: 11496
import numpy as np
H,W = list(map(int,input().split()))

A=[]
for h in range(H):
    a = input()
    if '#' in a:
        A.append(list(a))

A=np.array(A).T
A_=[]
for w in range(W):
    a=A[w]
    if '#' in a:
        A_.append(a)
        
A_=np.array(A_).T
for a in A_:
    print(''.join(a))

Measured memory_bytes: 27144
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int update (int k, int l, int t) {
	return l > t ? k : max(k, l);
}

int main() {
	int k {}, s {}, t {}, l {};
	for (char c; (c = gcu()) != '\n';) {
		switch (s) {
		case 0:
			if (c == 'J')
				s = l = 1;
			break;
		case 1:
			if (c == 'O')
				s++, t = 1;
			else if (c == 'J')
				l++;
			else
				s = 0;
			break;
		case 2:
			if (c == 'I')
				s++, l = min(l, t), t = 1, k = update(k, l, t);
			else if (c == 'O') {
				if (++t > l)
					s = 0;
			} else
				s = l = 1;
			break;
		case 3:
			if (c == 'I')
				k = update(k, l, ++t);
			else {
				k = update(k, l, t);
			   	if (c == 'J')
					s = l = 1;
				else
					s = 0;
			}
			break;
		}
	}
	outl(k);
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long[] a=new long[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt()-i-1;
		}

		Arrays.sort(a);
		long b=a[a.length/2];
		
		long sum=0;
		for(long v:a){
			sum+=Math.abs(b-v);
		}
		System.out.println(sum);
	}
}




Measured memory_bytes: 92012
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    string s; cin >> s;

    s[k-1] -= 'A' - 'a';

    cout << s;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-i-1]){
      n++;
    }
  }
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

# フェルマーの小定理
# ・aはpの倍数ではない
# ・pは素数
# の場合に以下が成り立つ。
# a**(p-1) = 1
def nCr(n, r, mod):
  p = 1
  q = 1
  for i in range(r):
    p = (p * (n - i)) % mod
    q = (q * (r - i)) % mod
  return p * pow(q, mod-2, mod)

n, a, b = map(int, sys.stdin.readline().split())
MOD = 10 ** 9 + 7
ans = pow(2, n, MOD) - 1
ans = (ans - nCr(n, a, MOD) - nCr(n, b, MOD)) % MOD
print(ans)

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

bool is_prime[55560];
int ans[60];

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

    for (int i = 0; i <= 55555; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    int p = 0;
    for (int i = 2; i <= 55555; i++) {
        if (is_prime[i]) {
            if (i % 5 == 1) {
                ans[p++] = i;
                if (p >= N) break;
            }
            for (int j = 2 * i; j <= 55555; j += i) is_prime[j] = false;
        }
    }
    for (int i = 0; i < N; i++) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL x,y;
    R(x,y);
    W(x/__gcd(x,y)*y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
	int s;
	cin >> s;
	if (s == 7 || s == 5 || s == 3)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}



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

int main() {
    int n, m; cin >> n >> m;
    vector<int> cnt(n);
    while (m--) {
        int a, b; cin >> a >> b; a--, b--;
        cnt[a]++, cnt[b]++;
    }
    bool ok = all_of(begin(cnt), end(cnt), [&](auto &e) { return e % 2 == 0; });
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 1e9+7;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=2e5+10;

int f[maxn];
int n,m;

inline void init()
{
	for(int i=0;i<=n;i++)
		f[i]=i;
}

int getf(int x)
{
	if(f[x]==x)
		return x;
	else 
		return f[x]=getf(f[x]);
}

void merge(int x,int y)
{
	x=getf(x);
	y=getf(y);
	
	if(x!=y)
		f[y]=x;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	cin>>n>>m;
	
	init();
	
	for(int i=0,x,y;i<m;i++)
	{
		cin>>x>>y;
		merge(x,y);
	}
	
	map<int,int>book;
	
	int maxx=0;
	
	for(int i=1;i<=n;i++)
	{
		int now=getf(i);
		book[now]++;
		
		if(book[now]>maxx)
			maxx=book[now];
	}
	
	cout<<maxx<<endl;
	
	return 0;
}

Measured memory_bytes: 13760
n, a, b, c, d = list(map(int, input().split()))
s = list(input())
a = a-1
b = b-1
c = c-1
d = d-1
s[a] = "A"
s[b] = "B"
ans = True
flag = 0

while a<n and b<n:
  while a<b:
    if a==c:
      break
    elif a+1<n and a+1<b and s[a+1]==".":
      s[a] = "."
      s[a+1] = "A"
      a += 1
    elif a+2<n and a+2<b and s[a+2]==".":
      s[a] = "."
      s[a+2] = "A"
      a += 2
    else:
      break

  if a+2<n and d<c and s[a+1]=="B" and s[a+2]==".":
    s[a] = "."
    s[a+2] = "A"
    a += 2

  if b<a:
    while a<n:
      if a==c:
        break
      elif a+1<n and s[a+1]==".":
        s[a] = "."
        s[a+1] = "A"
        a += 1
      elif a+2<n and s[a+2]==".":
        s[a] = "."
        s[a+2] = "A"
        a += 2
      else:
        ans = False
        break

  if a==c and b==d:
    break
  elif b+1<n and s[b+1]==".":
    s[b] = "."
    s[b+1] = "B"
    b += 1
  elif b+2<n and s[b+2]==".":
    s[b] = "."
    s[b+2] = "B"
    b += 2
  else:
    ans = False
    break

if ans:
  print("Yes")
else:
  print("No")

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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

typedef vector<vector<int>> Graph; // G[u] = {v,...}

bool augment(const Graph& g, int src, vector<int>& matchTo, vector<bool>& visited) {
    if (src < 0) return true;
    for (int dst : g[src]) if (!visited[dst]) {
        visited[dst] = true;
        if (augment(g, matchTo[dst], matchTo, visited)) {
            matchTo[src] = dst;
            matchTo[dst] = src;
            return true;
        }
    }
    return false;
}

int bipartiteMatching(const Graph& g, int L, vector<ii>& matching) {
    const int n = g.size();
    vector<int> matchTo(n, -1);
    int match = 0;
    rep(u, L) {
        vector<bool> visited(n);
        if (augment(g, u, matchTo, visited)) ++match;
    }
    rep(u, L) {
        if (matchTo[u] >= 0) { // make explicit matching
            //matching.push_back( ii(u, matchTo[u]) );
        }
    }
    return match;
}

int bip(int N, vector<ii>& arc){
    Graph g(N*2);
    for (ii a: arc){
        g[a.first].pb(N+a.second);
        g[N+a.second].pb(a.first);
    }
    vector<ii> matching;
    int match = bipartiteMatching(g, N, matching);
    return match;
}


int solve(int N, vi& a, vi& b, vi& c, vi& d) {
    vector<ii> arc;
    arc.reserve(N*N);
    rep(i,N) rep(j,N) {
        if (a[i] < c[j] && b[i] < d[j]) arc.pb(ii(i,j));
    }
    return bip(N,arc);
}

int main() {
    int N; cin >>N;
    vi a(N), b(N), c(N), d(N);
    rep(i,N){
        cin >> a[i] >> b[i];
    }
    rep(i,N){
        cin >> c[i] >> d[i];
    }
    cout << solve(N,a,b,c,d) << endl;
    return 0;
}


Measured memory_bytes: 256
import collections
h, w= map(int, raw_input().split())
n,ais = int(raw_input()), map(int, raw_input().split())
mat = [[-1 for _ in range(w)] for ii in range(h)]
c = 0
for i in range(len(mat)):
	for j in (range(len(mat[0])) if i % 2 else range(len(mat[0])-1,-1,-1)) : 
		mat[i][j] = c +1
		ais[c] -= 1
		if ais[c] == 0: c +=1
for l in mat: print ' '.join(map(str,l))

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

int main() {
  int ans = 0;
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
    ans = 1;
  } else if (a.size() < b.size()) {
    ans = -1;
  } else {
    ans = a.compare(b);
  }
  if (ans > 0) {
    cout << "GREATER"
         << "\n";
  } else if (ans < 0) {
    cout << "LESS"
         << "\n";
  } else {
    cout << "EQUAL"
         << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
    ss = input()
    s.append(ss)
print('AC x '+str(s.count('AC')))
print('WA x '+str(s.count('WA')))
print('TLE x '+str(s.count('TLE')))
print('RE x '+str(s.count('RE')))

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

int main()
{
    int n, a, b;
    string s;
    cin >> n >> a >> b;
    cin >> s;
    int qual = 0;
    int rankOvers = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a' && qual < a+b) {
            cout << "Yes\n";
            qual++;
        }
        else if (s[i] == 'b' && qual < a+b && rankOvers <= b) {
            cout << "Yes\n";
            qual++;
            rankOvers++;
        }
        else cout << "No\n";
    }
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
  while(x->left != NIL)   
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key)
    {
      if(k < u->key) u = u->left;
      else u = u->right;
    }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  
  if(y->left != NIL)
    {
      x = y->left;
    }else{
    x = y->right;
  }
  
  if(x != NIL) x->parent = y->parent;
  
  if(y->parent == NIL)
    {
      root = x;
    }else{
    if(y == y->parent->left)
      {
	y->parent->left = x;
      }else{
      y->parent->right = x;
    }
  
    if(y != z)
      {
	z->key = y->key;
      }
    free(y);
  }
}

  void insert(int k)
  {
    Node y = NIL;
    Node x = root;
    Node z;
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL){
      y = x;
      if(z->key < x->key){
	x = x->left;
      }else{
	x = x->right;
      }
      z->parent = y;
    }
    if(y == NIL)
      {
	root = z;
      }
    else if(z->key < y->key)
      {
	y->left = z;
      }
    else
      {
	y->right = z;
      }
  }

  void inorder(Node u)
  {
    if(u == NIL)
      {
	return;
      }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  void preorder(Node u)
  {
    if(u == NIL)
      {
	return;
      }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }


  int main()
  {
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ )
      {
	scanf("%s", com);
	if ( com[0] == 'f' )
	  {
	    scanf("%d", &x);
	    Node t = treeSearch(root, x);
	    if ( t != NIL ) printf("yes\n");
	    else printf("no\n");
	  }
	else if ( com[0] == 'i' )
	  {
	    scanf("%d", &x);
	    insert(x);
	  }
	else if ( com[0] == 'p' )
	  {
	    inorder(root);
	    printf("\n");
	    preorder(root);
	    printf("\n");
	  }
	else if ( com[0] == 'd' )
	  {
	    scanf("%d", &x);
	    treeDelete(treeSearch(root, x));
	  }
      }
    return 0;
  }
  



Measured memory_bytes: 25124
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    N, M, *AB = map(int, read().split())

    count = N * (N - 1) // 2
    ans = [count]
    uf = UnionFind(N)

    for a, b in zip(reversed(AB[::2]), reversed(AB[1::2])):
        a -= 1
        b -= 1
        if not uf.same(a, b):
            count -= uf.size(a) * uf.size(b)
            uf.union(a, b)
        ans.append(count)

    print(*reversed(ans[:-1]), sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 25564
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

X,Y= [int(i) for i in input().split()]
x=min(X,Y)
y=max(X,Y)

a=y%x
if a !=0:
        while a > 1:
                y=x
                x=a
                a=y%x
                
print(len(set(factorize(x))) + 1 if a==0 else 1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  long long h,w;
  cin>>h>>w;
  if(h==1||w==1) cout<<1<<endl;
  else if(h*w%2==0) cout<<h*w/2<<endl;
  else cout<<h*w/2+1<<endl;
  
}

Measured memory_bytes: 256
MOD = 10**9 + 7
n, m = map(int, input().split())
if abs(n - m) > 1:
    ans = 0
else:
    ans = 1
    for i in range(1, n+1):
        ans *= i
        ans %= MOD
    for i in range(1, m+1):
        ans *= i
        ans %= MOD
    if n == m:
        ans *= 2
        ans %= MOD
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	vi v(N); rep(i, N) cin >> v[i];
	vi vc = v;
	sort(rall(vc));
	rep(i, N) {
		if (v[i] == vc[0]) cout << vc[1] << endl;
		else cout << vc[0] << endl;
	}

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 4736
x = int(input())
y = [int(i) for i in input().split(' ')]
if x == len(y):
  ma = max(y)
  del (y[y.index(max(y))])
  other = sum(y)
  if ma - other < 0:
    print('Yes')
  else: 
    print('No')
else:
  print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int n;
int a[110];

void print(void)
{
	for (int i = 0; i<n; i++) {
		if (i>0) cout << " ";
		cout << a[i];
	}
	cout << endl;
}

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

	int ans = 0;
	for (int i = 0; i<n - 1; i++) {
		int min = i;
		for (int j = i; j<n; j++) {
			if (a[min] > a[j]) {
				min = j;
			}
		}
		int v = a[i]; a[i] = a[min]; a[min] = v;
		if (min != i) {
			ans++;
		}
	}

	print();
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n+1];
  k[0]=0;
  rep(i,n){
    int a;
    cin >> a;
    k[i+1]=k[i]+a;
  }
  int mi=100000000;
  rep(i,n){
    mi=min(mi,abs(k[i+1]-(k[n]-k[i+1])));
  }
  cout << mi << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  cin>>x>>y;
  if((y-2*x < 0) ||
  (y-2*x)%2 != 0 ||
  (y-2*x)/2 > x ||
   y%2 != 0 ) 	cout<<"No";
  else cout<<"Yes"<<endl;
}

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

int main() {

	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	vector<int> check(n+1, 0);
	for(ll i=1; i<=n; i++)
		cin>>a[i];
	vector<int> ver;
	ll j=0;
	ll x=1;
	ll o=0;
	ll pet = 0;
	int alpha = 0, f=0;
	while(true) {
		if(j>k) {
			f = 1;
			break;
		}
		if(check[x] == 0) {
			check[x] = 1;
			pet = x;
			x = a[x];
		}
		else if(check[x] == 1) {
			if(alpha == 0)
				o = j;
			alpha = 1;
			pet = x;
			ver.push_back(x);
			check[x] = 2;
			x = a[x];
			

		}
		else if(check[x] == 2) {
			f = 0;
			pet = x;
			break;
		}

	   // cout<<j<<" ";
		j++;
	}
	//cout<<endl;
	//for(int i=1; i<=n; i++)
	  //  cout<<check[i]<<" ";
	if (f == 1) {
		cout<<pet;
		//cout<<f;
	}
	else {
	   cout<<ver[(k-o)%(ver.size())];
	   //cout<<f;
    }
	return 0;
}

Measured memory_bytes: 6208
t = int(input())
con = []
for i in range(t):
    a, b = map(int, input().split())
    if a==b:
        con.append(1)
    else:
        con.append(0)
    ans =0
a = []
for i in con:
    if i ==1:
        ans += 1
        a.append(ans)
    else:
        ans = 0
        a.append(ans)
if max(a) >= 3:
    print("Yes")
else:
    print("No")

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

double a[55];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%lf", a + i);
	sort(a, a + n);
	for(int i = 1; i < n; i++)
		a[i] = (a[i] + a[i-1]) / 2.0;
	printf("%.12lf\n", a[n-1]);
}


Measured memory_bytes: 256
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(n)]

sum = 0
mr = 0
ks = sorted(k)

for i in range(n):
    if ks[i][1] < (m-mr):
        sum += ks[i][0] * ks[i][1]
        mr += ks[i][1]

    else:
        sum += ks[i][0] * (m - mr)
        break

print(sum)

Measured memory_bytes: 28132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    ll a, b, c, d; cin >> a >> b >> c >> d;

    ll ans = a * c;
    ans = max(ans, b * d);
    ans = max(ans, a * d);
    ans = max(ans, b * c);

    cout << ans << '\n';

    return 0;
}


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

int main() {
    int n,b,f,r,v;
    int building[4][3][10] = {0};
    
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        
        building[b-1][f-1][r-1] += v;
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << building[i][j][k];
            }
            cout << endl;
        }
        if(i != 3){
            cout << "####################" << endl;
        }
    }
}


Measured memory_bytes: 3076
fun main(args: Array<String>) {
    abc056c()
}

fun abc056c() {
    val x = readLine()!!.toLong()

    val answer = lowerBound(x)

    println(answer)
}

private fun lowerBound(key: Long): Long {
    var ng = -1L
    var ok = key

    val predicate = fun(mid: Long, key: Long): Boolean {
        return (1..mid).sum() >= key
    }

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (predicate(mid, key)) ok = mid else ng = mid
    }
    return ok
}


Measured memory_bytes: 33912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int k;
    cin >> k;
    int s[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << s[k] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	while(s.hasNext()) {
	    String t = s.nextLine();
	    t = t.replace("apple", "\n");
	    t = t.replace("peach", "apple");
	    t = t.replace("\n", "peach");
	    System.out.println(t);
	}
    }
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    ans = []
    tmp = [i for i in range(2, n + 1) if i != n - (n & 1)]
    l = 0
    r = n - 3 - (n & 1)
    for i in range(n // 2):
        ans.append(tmp[::1])
        tmp[l] -= 1
        tmp[r] += 1
        l += 1
        r -= 1
    ans += ans[::-1]
    l = []
    for i in range(1, n):
        for t in ans[i - 1]:
            if i < t:
                l.append((i, t))
    print(len(l))
    for li in l:
        print(*li)




    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 44144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n;
    const double rate = 380000;
    double x;
    char str[10];
    int i;
    double ans;

    scanf("%d", &n);

    ans = 0;
    for (i = 0; i < n; i++) {
        scanf("%lf %s", &x, str);
        if (strcmp(str, "JPY") == 0) { //JPY
            ans += x;
        } else { //BTC
            ans += x * rate;
        }
    }


    printf("%.6f\n", ans);

    return 0;
}


Measured memory_bytes: 128
/*
AizuOnline A0119
Title Taro's obsession
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
#define SHOUGENNO 100
#define NINZUU 20
int n,m;
int x[SHOUGENNO],y[SHOUGENNO];
int flag[NINZUU+1];
//
void show()
{
  int i;
  for(i=1;i<=n;i++)
    printf("%d:",flag[i]);
  printf("\n");
}
main()
{
  int i,cnt;

  scanf("%d ",&n);
  scanf("%d ",&m);
  for(i=0;i<m;i++)
    scanf("%d %d",&x[i],&y[i]);
  for(i=0;i<n;i++)
    flag[i]=0;

  cnt=n;

  while(cnt>1)
    {
      for(i=1;i<=n;i++)
	if(flag[i]>0)
	  flag[i]=0;
      //show();
      for(i=0;i<m;i++)
	if(flag[x[i]]!=-1)
	  flag[y[i]]=1;
      for(i=1;i<=n;i++)
	{
	  if(flag[i]==0 && i!=2)
	    {
	      printf("%d\n",i);
	      cnt--;
	      flag[i]=-1;
	    }
	}
      //show();
    }
  printf("2\n");
return(0);
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
     ll k,n,sum=0;
         cin>>n>>k;
         int c[n];
         for(ll i=0; i<n; i++){
            cin>>c[i];
            sum+=c[i];
            
            }
            sort(c,c+n);
            if(n<=k){
			  cout<<0; return 0;
			}
            for(ll i=n-k; i<n; i++)
              sum-=c[i];
         
            cout<<sum<<endl;
          
         }
//aaaaa

Measured memory_bytes: 1024
require 'prime'
ps = Prime.each(10000).to_a
loop do
    m, a, b = gets.split.map(&:to_i)
    break if m == 0 && a == 0 && b == 0
    max = mp = mq = 0
    ps.each do |p|
        break if p * p > m
        ps.each do |q|
            next if q < p
            break if q.to_f*a.to_f/b.to_f > p
            break if p * q > m
            if p * q > max
                max = p * q
                mp = p
                mq = q
            end
        end
    end
    puts "#{mp} #{mq}"
end

Measured memory_bytes: 6272
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		long N = s.nextLong();
		int maxs = (int)Math.sqrt(N);
		long[][] sosu = new long[maxs][3]; // 0=素因子, 1=累乗数, 2=割った回数
		
		int result = 0;
		
		// 素因氏分解を実施
		int index = 0;
		for(int i = 2; i < maxs; i++) {
			if(N%i==0) {
				sosu[index++][0] = i;
				sosu[index - 1][2] = 1;
				while(N%i==0) {
					sosu[index - 1][1] = sosu[index - 1][1] + 1;
					N /= i;
				}				
			}
		}
		if(N > 1) {
			sosu[index][0] = N;
			sosu[index][1] = 1;
			sosu[index][2] = 1;
			
		}
		
		// 素数の中身をみていく
		for(int i = 0; i < maxs; i++) {
			if(sosu[i][0] == 0)
				break;
			
			while(sosu[i][1] - sosu[i][2] > -1) {
				sosu[i][1] = sosu[i][1] - sosu[i][2];
				sosu[i][2] = sosu[i][2] + 1;
				result++;
			}
		}
		
		System.out.println(result);
    }
}

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

int main() {
  string s;
  cin >> s;
  bool is = true;
  if (s[0]=='A' && s[1]=='A' && s[2]=='A')
    is = false;
  if (s[0]=='B' && s[1]=='B' && s[2]=='B')
    is = false;
  if (is)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
score = [tuple(map(int, input().split())) for _ in range(q)]


def gen_a(m, n):
    if n == 1:
        return {(i,) for i in range(1, m + 1)}
    else:
        bef_a = gen_a(m, n - 1)
        ret = set()
        for bef in bef_a:
            for i in range(bef[-1], m + 1):
                ret.add(bef + (i,))
        return ret


ans = 0
for a_tuple in gen_a(m, n):
    score_a = 0
    for a, b, c, d in score:
        a, b = a - 1, b - 1
        if a_tuple[b] - a_tuple[a] == c:
            score_a += d
    ans = max(score_a, ans)

print(ans)

Measured memory_bytes: 37696
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

vector<int> prime_numbers(int n){
    if (n <= 1){
        return vector<int>(0);
    }
    vector<int> ans = {2};
    for(int i = 3;i <= n;i++){
        bool is_prime = true;
        for(int j = 0; ans[j] * ans[j] <= i;j++){
            if (i % ans[j] == 0){
                is_prime = false;
                break;
            }
        }
        if (is_prime){
            ans.push_back(i);
        }
    }
    return ans;
}

int main()
{
  // 整数の入力
  ll N;
  cin >> N;
  vector<ll> A(N);
//   vector<int> all_primes = prime_numbers(1000);
//   all_primes.push_back(1);
  for (size_t i = 0; i < N; i++)
  {
      cin >> A[i];
  }
  sort(A.begin(),A.end());
  set<ll> primes;
  map<ll,ll> counts;
  ll prime_count = 0;
//   primes.push_back(A[0]);
  for(int i = 0; i < N;i++){
      counts[A[i]]++;
      bool is_prime = true;
      for(int j = 1; j <= 1000;j++){
          if (A[i] % j == 0){
              if (primes.find(A[i]/j) != primes.end() || primes.find(j) != primes.end()){
                  is_prime = false;
                  break;
              }
          }
      }
      if (is_prime){
        primes.insert(A[i]);
      }
  }
  ll ans = 0;
  for (auto p:primes)
  {
      if (counts[p] == 1){
          ans++;
      }
  }
  cout << ans << endl;
//   for(auto p: all_primes){
//       cout << p << endl;
//   }
  return 0;
}

Measured memory_bytes: 26668
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *right;
    Node *left;
    Node *parent;
};

Node *root, *NIL;

void Insert(int k);
void Inorder(Node *u);
void Preorder(Node *u);

int main() {
    int n;
    cin >> n;
    string com;
    for ( int i = 0; i < n; i++ ) {
        cin >> com;
        if ( "insert" == com ) {
            int x;
            cin >> x;
            Insert(x);
        } else if ( "print" == com ) {
            Inorder(root);
            cout << '\n';
            Preorder(root);
            cout << '\n';
        }
    }
    
    return 0;
}

void Insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while ( x != NIL ) {
        y = x;
        if ( z->key > x->key ) {
            x = x->right;
        } else {
            x = x->left;
        }
    }
    
    z->parent = y;
    if ( NIL == y ) {
        root = z;
    } else if ( z->key > y->key ) {
        y->right = z;
    } else {
        y->left = z;
    }
}

void Inorder(Node *u) {
    if ( NIL == u ) return;
    Inorder(u->left);
    printf(" %d", u->key);
    Inorder(u->right);
}

void Preorder(Node *u) {
    if ( NIL == u ) return;
    printf(" %d", u->key);
    Preorder(u->left);
    Preorder(u->right);
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
 */

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N, A, B, C, D, E;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cin >> N >> A >> B >> C >> D >> E;

  ll v = min(A,min(B,min(C,min(D,E))));
  cout << 4 + (N+v-1)/v << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,x=0,n;
  scanf("%d %d" ,&a , &b);
  for(n=0;n<2;n++){
    
    if(a==b){
      x+=a;
      a--;
    }
   else if(a>b){
    x+=a;
    a--;
  }
   else {
      x+=b;
     b--;
   }
  }
  printf("%d",x);
  
  return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<f64> = sc.vec(N);
    let mut ans = 0.;
    for i in 0..N {
        ans += 1./A[i];
    }
    ans = 1./ans;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m=INF,ans=0;
	cin >> n;
	vector<ll> a(n);
	FOR(i,0,n){
		cin >> a[i];
		if(m>abs(a[i]))m=abs(a[i]);
		ans += abs(a[i]);
	}
	FOR(i,0,n-1){
		if(a[i]<0){
			a[i] *= -1;
			a[i+1] *= -1;
		}
	}
	if(a[n-1]<0){
		ans -= m*2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024