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

bool possible;
ll calculate(vector<ll> v)
{
	for (ll i = 0; i < v.size(); ++i)
	{
		if (v[i] > i)
		{
			possible = false;
			return 0;
		}
	}
	for (int i = 1; i < v.size(); ++i)
	{
		if (v[i] > v[i-1] + 1)
		{
			possible = false;
			return 0;
		}
	}
	ll ans = 0;
	ll curr = 0;
	for (ll i = v.size() - 1; i >= 0; --i)
	{
		if (v[i] != curr)
		{
			ans += v[i];
			curr = v[i] - 1;
		}
		else
			curr--;
	}
	return ans;
}

int main()
{
	ll n;
	cin>>n;
	possible = true;
	ll a[n];
	for (ll i = 0; i < n; ++i)
		cin>>a[i];
	if (a[0] != 0)
	{
		printf("-1\n");
		return 0;
	}
	vector<vector<ll>> v;
	std::vector<ll> curr;
	for (ll i = 0; i < n; ++i)
	{
		if (a[i] == 0)
		{
			if (curr.size() > 0)
				v.push_back(curr);
			curr.clear();
		}
		curr.push_back(a[i]);
	}
	if (curr.size() > 0)
		v.push_back(curr);
	ll ans = 0;
	for (auto each : v)
	{
		ans += calculate(each);
		if (!possible)
			break;
	}
	if (!possible)
		printf("-1\n");
	else
		printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 14764
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector< vector<int> >;

int main(){
	ll N;
	cin >> N;
	ll A[N],B[N];
	for (ll i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
	}
	sort(A,A+N);
	sort(B,B+N);
	ll a,b;
	if(N%2 == 1){
		a = A[(N-1)/2];
		b = B[(N-1)/2];
		cout << b-a+1 << endl;
	}
	else{
		a=A[N/2-1]+A[N/2];
		b=B[N/2-1]+B[N/2];
		cout << b-a+1 << endl;
	}
}

Measured memory_bytes: 6760
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans = 0;
    ll x;
    cin >> x;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N,M;
	cin >> N >> M;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	map<int,int> ma;
	int cnt = 0;
	ma[0]++;
	for(int i = 0;i < N;i++) {
		cnt += vec.at(i);
		ma[cnt % M]++;
	}
	int ret = 0;
	for(auto x:ma) {
		int B = x.second;
		ret += B * (B - 1) / 2;
	}
	cout << ret << endl;
}

Measured memory_bytes: 4992
def read():
    N = int(input())
    As = list(map(int, input().split(' ')))
    return N, As


def func(N, As):
    prev = -1
    ans = 0
    for n in range(N):
        if n == 0:
            prev = As[n]
            continue
        t = As[n]
        if prev > t:
            ans += prev - t
        prev = max(t, prev)
    return ans


if __name__ == '__main__':
    N, As = read()
    print(func(N, As))


Measured memory_bytes: 32240
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        f: [[usize; 10]; n],
        p: [[i64; 11]; n]
    }
    let mut res = std::i64::MIN;

    for b in 1..1 << 10 {
        let mut op = vec![0; n];
        for i in 0..10 {
            if b & 1 << i != 0 {
                for j in 0..n {
                    op[j] += f[j][i];
                }
            }
        }
        let mut acc = 0;

        for i in 0..n {
            acc += p[i][op[i]];
        }
        res = max(res, acc);
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
import Prelude hiding (abs)
import Control.Monad
import Control.Arrow ((&&&))
import Data.List (nub, sort, group)
import Data.Maybe (fromMaybe)
import qualified Data.IntMap as M

type RoadCount = M.IntMap Int

main :: IO ()
main = do
    [n,m] <- (map read . words) <$> getLine
    abs <- map readLine2 <$> replicateM m getLine
    mapM_ print $ solve n abs

-- |
--
-- >>> solve 4 [(1,2),(2,3),(1,4)]
-- [2,2,1,1]
--
-- >>> solve 2 [(1,2),(2,1),(1,2),(2,1),(1,2)]
-- [5,5]
--
-- >>> solve 8 [(1,2),(3,4),(1,5),(2,8),(3,7),(5,2),(4,1),(6,8)]
-- [3,3,2,2,2,1,1,2]
solve :: Int -> [(Int,Int)] -> [Int]
solve n abs = map (getRoads m) [1 .. n]
  where
    (as, bs) = unzip abs
    xss = group . sort $ as ++ bs
    road_count = map (head &&& length) xss
    m = M.fromList road_count

getRoads :: RoadCount -> Int -> Int
getRoads m x = fromMaybe 0 $ M.lookup x m

readLine2 :: String -> (Int,Int)
readLine2 = tuplify2 . map read . words
    where
      tuplify2 [] = (0, 0)
      tuplify2 [x] = (x, 0)
      tuplify2 (x:y:_) = (x, y)


Measured memory_bytes: 1020
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  vector<ll>a(5);
  rep(i,0,5)cin>>a[i];
  rep(i,0,5)if(!a[i])cout<<i+1<<endl;
  return 0;
}

Measured memory_bytes: 3612
/*****************************
*  Author :: Prasanna Kumar  *
*****************************/

/***********************************
* Unus pro omnibus, omnes pro uno  *
***********************************/
#include<bits/stdc++.h>
using namespace std;

// #define __AnAkLuSmOs freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define __AcHiLlEs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define i_64 long long

void solve() {
    i_64 a, b;
    cin >> a >> b;
    if (b & 1) {
        cout << "No\n";
        return;
    }
    if (b < 2 * a or b > a * 4) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}

signed main() {
    // #ifndef ONLINE_JUDGE 
    //     __AnAkLuSmOs    
    // #endif

    __AcHiLlEs

    i_64 t(1);
    // cin >> t;
    for (i_64 i = 1; i <= t; /*cout << "Case " << i << ": ",*/ solve(), i++);
    return 0;
}
    

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <complex>

using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P, point;

point three_point_circle(const point& a, const point& b, const point& c) {
  point x = 1.0/conj(b - a), y = 1.0/conj(c - a);
  return (y-x)/(conj(x)*y - x*conj(y)) + a;
}

int main()
{
	int n;

	cin >> n;
	for (int i = 0; i < n; i++){
		point points[3];
		for (int j = 0; j < 3; j++){
			double x, y;
			cin >> x >> y;
			points[j] = point(x, y);
		}
		point center = three_point_circle(points[0], points[1], points[2]);
		printf("%.3f %.3f %.3f\n", real(center), imag(center), abs(center - points[0]));
	}
}

Measured memory_bytes: 1268
#include <stdio.h>

int main(void){
    int N,K,X,Y,ans=0;
    int i;
    scanf("%d%d%d%d",&N,&K,&X,&Y);
    
    for(i=1;i<=N;i++){
        if(i<=K){
            ans += X;
        }
        else{
            ans += Y;
        }
    }
    
    printf("%d\n",ans);
    return 0;
}


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

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

    // n要素の整数の配列a
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }

    // 答えを保持する変数
    // 絶対値を最大化する問題なので、十分小さい値(0)を最初に入れておく
    int ans = 0;

    // 条件を満たす全ての組み合わせを試す
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            // 添字が同じになる場合はNG
            if(i == j){
                continue;
            }

            // max(a, b)は、aとbのうち大きいもの
            // abs(x)は、xの絶対値
            // ansと比較することで、より大きい値を見つけた時にのみ答えを書き換えることができる
            ans = max(ans, abs(a[i] - a[j]));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n, a, b;
    cin >> n >> a >>b;
    int sum = 0;
    
    for(int i =1 ; i <= n; i++){
        int c = 0, t = i;
        for(int j = 0; j < 5; j++) c += t % 10, t /= 10;
        if(c >= a && c <= b){
            sum+= i;
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
  int n, k, a;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++){
    cin >> a;
    ans += min(abs(k-a), abs(a));
  }
  ans *= 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

maxCount = 0
answer = 0

for n in range(1, N+1, 1):
    target = n
    flg = True
    count = 0
    

    while flg:
        if target % 2 == 0:
            target /=  2
            count += 1
        else:
            flg = False

    if ( maxCount <= count):
        maxCount = count
        answer = n

print(answer)

Measured memory_bytes: 3060
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int N = 201234;
int a[N], b[N];

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	int mx = 0;
	for (int i = 0; i < n; i++) {
		mx = max(mx, a[i]);
		b[i] = mx;
	}
	for (int i = 0; i < n; i++) {
		ans += (b[i] - a[i]);
	}
	cout << ans << '\n';
}

int32_t main() {
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 6700
#include<bits/stdc++.h>
using namespace std;
long long m[1000][1000],dp[1000][1000];
int main()
{
long long n,i,j;
scanf("%lld",&n);
for(i=0;i<2;i++)
   for(j=0;j<n;j++)
      scanf("%lld",&m[i][j]);
      
for(i=0;i<2;i++)
    for(j=0;j<n;j++)
       {
        if(i==0 && j==0)
           dp[i][j]=m[i][j];
         if(i==0 && j>0)
            dp[i][j]=dp[i][j-1]+m[i][j];
         if(j==0 && i>0)
            dp[i][j]=dp[i-1][j]+m[i][j];
            
         if(i>0 && j>0)
            dp[i][j]=max((dp[i-1][j]+m[i][j]),(dp[i][j-1]+m[i][j]));
            
         
       
       }
       printf("%lld\n",dp[1][n-1]);

return 0;
}

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

char map[104][104];

void next(int x,int y,int r){
	int sum=0;
	int nx[4]={0,1,0,-1};
	int ny[4]={-1,0,1,0};
	for(int i=0;i<4;i++)if(map[x+nx[i]][y+ny[i]]=='#')sum++;
	if(sum<=1){
		map[x][y]='#';
		if(map[x+nx[r]*2][y+ny[r]*2]=='#'){
			r=(r+1)%4;
			next(x+nx[r],y+ny[r],r);
		}
		else{
			next(x+nx[r],y+ny[r],r);
		}
	}
}

void cal(int n){
	for(int i=0;i<104;i++)for(int j=0;j<104;j++)map[i][j]=' ';
	for(int i=0;i<104;i++)map[i][0]=map[0][i]=map[i][n+3]=map[n+3][i]='#';
	next(2,n+1,0);
}

void draw(int n){
	for(int i=2;i<=n+1;i++){
		for(int j=2;j<=n+1;j++){
			cout<<map[j][i];
		}
		cout<<endl;
	}
}
int main(){
	int d,n;
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>n;
		cal(n);
		draw(n);
		if(i!=d)cout<<endl;
	}
	return 0;
}


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

int main() {

    int n;
    cin >> n;
    set<string> ss;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ss.insert(s);
    }
    cout << ss.size() << endl;

    return 0;

}


Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(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 = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;

    ll res;

    if(k % 2){
        ll dv = n / k;
        res = dv * dv * dv;
    }
    else{
        ll p = 0, q = 0;
        REP(i, n){
            if((i + 1) % k == 0) p++;
            if((i + 1) % k == k / 2) q++;
        }
        res = p * p * p + q * q * q;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import collections
    N, P = map(int, input().split())
    S = input()[::-1]
    ans = 0
    if P == 2 or P == 5:
        for i, s in enumerate(S):
            if int(s) % P == 0:
                ans += N - i
    else:
        mod = [0] * P
        mod[0] = 1
        current = 0
        X = 1
        for s in S:
            current = (current + int(s) * X) % P
            ans += mod[current]
            mod[current] += 1
            X = X * 10 % P
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 41840
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
 
 
  string s;
  cin>>s;
  if(s=="AAA"||s=="BBB"){
      cout<<"No"<<endl;
      return 0;
  }
  cout<<"Yes"<<endl;
  
  
  
  

  
  
 
}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,p,i,s=0,mx=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>p;
        s+=p;
        mx=max(mx,p);
    }
    cout<<s-(mx/2)<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int A,B;
	cin>>A>>B;
	if(B%A==0)
		cout<<A+B<<endl;
	else
		cout<<B-A<<endl;
	return 0;
}




















Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#include <cassert>
#include <queue>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

ll res[9];
ll nRow, nCol;
vector<pair<int,int> > ps;

int main(void) {
  int nBlack;
  scanf("%lld%lld%d", &nRow, &nCol, &nBlack);
  REP(i, nBlack) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    for(int r = a-2; r <= a; ++r) {
      for(int c = b-2; c <= b; ++c) {
        if(r >= 0 && c >= 0 && r+2 < nRow && c+2 < nCol) {
          ps.push_back(make_pair(r, c));
        }
      }
    }
  }
  sort(ps.begin(), ps.end());
  int nn = ps.size();
  res[0] = (nRow-2)*(nCol-2);
  REP(i, nn) {
    int ii = i + 1;
    for(; ii < nn && ps[i] == ps[ii]; ++ii)
      ;
    int cnt = ii-i;
    ++res[cnt];
    --res[0];
    i = ii-1;
  }

  REP(i, 10) {
    printf("%lld\n", res[i]);
  }
  
  return 0;
}



Measured memory_bytes: 10220
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int h, a;
    cin >> h >> a;

    int ans = 0;
    while (0 < h) {
        ans++;
        h -= a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	string O, E, ans;
	cin >> O >> E;

	if (O.size() == E.size()) {

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

			cout << O[i];
			cout << E[i];

		}
		cout << endl;

	}
	else {

		for (int i = 0; i < O.size() - 1; i++) {

			cout << O[i];
			cout << E[i];

		}
		cout << O[O.size() - 1] << endl;

	}

	return 0;
}

Measured memory_bytes: 256
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)


Measured memory_bytes: 26184
--AOJ Swapping Two Numbers

rlength :: Int -> Int -> Int
rlength a b = 2 * (a + b)

rInt :: String -> Int
rInt str = read str :: Int

swap :: Int -> Int -> String
swap a b 
  |a <= b    = show a ++ " " ++ show b
  |otherwise = show b ++ " " ++ show a         

main :: IO ()
main = do
  input <- getLine
  let doubleInt = map rInt $ words input
  let a = head doubleInt
      b = last doubleInt
  if a == 0 && b == 0
     then return ()
     else do putStrLn $ swap a b
     	     main

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

int n;
int p[MAX_N];
string t[MAX_N];
vector<int> G[MAX_N];
map<string,int> change;

void solve(int pos,int depth){
  for(int i=0;i<depth;i++)cout<<'.';
  if(pos)cout<<t[pos]<<endl;
  for(int i=0;i<(int)G[pos].size();i++){
    int w=G[pos][i];
    solve(w,depth+1);
  }
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i]>>t[i];
    change[t[i]]=i;
    G[p[i]].push_back(i);
  }
  solve(0,-1);
  return 0;
}

Measured memory_bytes: 1508
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int d[110];
    cin >> n;
    for(int i=0; i< n ;i++){
        cin>>d[i];
    }
    
    set<int> values;
    for(int i=0;i<n;i++){
        values.insert(d[i]);
    }
    cout << values.size() << endl;
    
    return 0;
}

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

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

	int a = x - (x / 100) * 100;
	int t = a;
	int am5 = t / 5;
	t -= 5 * am5;
	int am4 = t / 4;
	t -= 4 * am4;
	int am3 = t / 3;
	t -= 3 * am3;
	int am2 = t / 2;
	t -= 2 * am2;
	int am1 = t / 1;

	int sum = am5 * 105 + am4 * 104 + am3 * 103 + am2 * 102 + am1 * 101;
	if (x < sum) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    private static List<Long> primeFactors(long n) {
        List<Long> list = new ArrayList<>();
        while (n % 2 == 0) {
            list.add(2L);
            n /= 2;
        }
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            while (n % i == 0) {
                list.add(i);
                n /= i;
            }
        }
        if (n > 2) {
            list.add(n);
        }
        return list;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        List<Long> list = primeFactors(n);
        Collections.sort(list);
        Map<Long, Long> map = new HashMap<>();
        for (int i = 0; i < list.size(); i++) {
            map.put(list.get(i), map.getOrDefault(list.get(i), 0L) + 1);
        }
        long ans = 0;
        for (Entry<Long, Long> e : map.entrySet()) {
            long v = e.getValue();
            int cnt = 1;
            while (v - cnt >= 0) {
                ans++;
                v -= cnt;
                cnt++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 35876
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    int F[50];
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        F[i] = F[i - 1] + F[i - 2];
    }
    std::cout << F[n] << std::endl;
}


Measured memory_bytes: 3104
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

void work() {
  int x = read();
  printf("%d\n", (x - 2) * 180);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 256
S=input()
x=int(S[:2])
y=int(S[2:4])
if 1<=x<=12:
    if 1<=y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=y<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 9184
n = int(raw_input())

for i in range(n):
    ball = map(int, raw_input().split())
    a = [0]
    b = [0]
    for j in ball:
        if a[-1] < j:
            a.append(j)
        elif b[-1] < j:
            b.append(j)
        else:
            print "NO"
            break
    else:
        print"YES"



Measured memory_bytes: 4632
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  maximums <- listArray (1, n - 1) . map (read::String -> Int) . words <$> getLine
  let ans = foldl (\acc i -> acc + (min (maximums ! i) (maximums ! (i - 1)))) (maximums ! 1) [2..(n - 1)]
  print $ ans + maximums ! (n - 1)



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a;
    cin >> a;
    char op;
    cin >> op;
    int b;
    cin >> b;

    if (op == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int ll
void test_case(){
	ll x; cin >> x;
	ll ans = 0, a = 100;
	while( a < x){
		a += a/100;
		ans++;
	}
	cout<<ans<<"\n";
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

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

	int testCase;
	cin >> testCase;

	map<string, int> list;

	int maxCnt = 1;
	string temp;
	
	for (int i = 0; i < testCase; i++) {
		cin >> temp;

		if (list.find(temp) != list.end()) {
			list.find(temp)->second++;

			if (maxCnt <= list.find(temp)->second) {
				maxCnt = list.find(temp)->second;
			}
		}
		else {
			list.insert({temp, 1});
		}
	}
	
	vector<string> answer;

	for (auto i = list.begin(); i != list.end(); i++) {
		if (i->second == maxCnt) {
			answer.push_back(i->first);
		}
	}

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

	for (int i = 0; i < answer.size(); i++) {
		cout << answer[i] << endl;
	}
}	

Measured memory_bytes: 25584
# ABC099D - Good Grid
import sys
input = sys.stdin.readline

from collections import Counter
from itertools import product


def main():
    N, C = map(int, input().split())
    D = [0] + list([0] + list(map(int, input().split())) for _ in range(C))
    grid = tuple(tuple(map(int, input().split())) for _ in range(N))
    cost = [Counter() for _ in range(3)]
    for i, g in enumerate(grid):  # classify each cell by mod3
        for j in range(3):
            cost[(i + j) % 3].update(g[j::3])
    dist = [[] for _ in range(3)]
    # compute the actual cost to change color
    for i, tgt in product(range(3), range(1, C + 1)):
        cur = sum(D[src][tgt] * cnt for src, cnt in cost[i].items())
        dist[i].append(cur)
    ans = 1 << 60
    # fix two colors and compute the minimum cost
    for i, j in product(range(C), repeat=2):
        if i == j:
            continue
        cur = dist[0][i] + dist[1][j]
        cur += min(x for k, x in enumerate(dist[2]) if k not in (i, j))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 5356
#include <stdio.h>          // printf(), getc()
#include <ctype.h>          // isdigit()

// #define CASE1 1
#define MAX_N 1000000
#define MAX_G 15

const char NUL = '\0';
int count;
#ifdef CASE1
int G[MAX_G];
#else
const int G[11] = {1, 8, 23, 77, 281, 1073, 4193, 16577, 65921, 262913, 1050113};
#endif
int ix;

void
insertionSort(int a[MAX_N], int n, int g)
{
	int i, j;

	for (i = g; i < n; ++i)
	{
		int v = a[i];
		for (j = i - g; j >= 0 && v < a[j]; j -= g)
		{
			a[j + g] = a[j];
			count++;
		}

		a[j + g] = v;
	}
}

void
shellsort(int a[MAX_N], int n)
{
	int i;


#ifdef CASE1
	ix = 0;
	int h;
	for (h = 1; h <= n;)
	{
		G[ix++] = h;
		h = 3 * h + 1;
	}
#else
	for (ix = 0; ix < MAX_G && G[ix] <= n; ++ix)
		;
#endif

	for (i = ix - 1; i >= 0; --i)
		insertionSort(a, n, G[i]);
}

void
print_number(int n)
{
	char text[12];
	char* s = &text[11];
	*s = NUL;
	do
	{
		int m = n % 10;
		*--s = m + '0';
		n /= 10;
	} while (n != 0);

	printf("%s", s);
}

int
main(int argc, char** argv)
{
	int a[MAX_N];
	int n, m;
	int i;
	int c;

	c = getc(stdin);
	n = 0;
	while (isdigit(c))
	{
		n = n * 10 + c - '0';
		c = getc(stdin);
	}

	for (i = 0; i < n; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		m = 0;
		while (isdigit(c))
		{
			m = m * 10 + c - '0';
			c = getc(stdin);
		}

		a[i] = m;
	}

	count = 0;
	shellsort(a, n);

	printf("%d\n", ix);
	for (i = ix - 1; i >= 0; --i)
		printf("%d%c", G[i], (i != 0) ? ' ' : '\n');

	printf("%d\n", count);
	for (i = 0; i < n; ++i)
	{
		print_number(a[i]);
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 4412
n = gets.chomp.to_i
tt = gets.chomp.split(" ").map(&:to_i)
vv = [0] + gets.chomp.split(" ").map(&:to_i) + [0]
ttsum = tt.inject(:+)

ll = Array.new(n+2)
rr = Array.new(n+2)
ll[0] = 0
ll[1] = 0
rr[0] = 0

n.times do |i|
  ll[i+2] = ll[i + 1] + tt[i]
end
(n-1).times do |i|
  rr[i+1] = rr[i] + tt[i]
end
rr[n] = ttsum
ll[n+1] = ttsum
rr[n+1] = ttsum

def f(x, l, r, v)
  if x < l
    ret = v + (l - x)
  elsif x <= r
    ret = v
  else
    ret = v + (x - r)
  end
  return ret
end

arr = []
a = 0.0
while a <= ttsum
  v = (0..(n+1)).map{|i| f(a, ll[i], rr[i], vv[i])}.min
  arr << v
  a += 0.5
end
ans = 0
(arr.length - 1).times do |i|
  s = ((arr[i] + arr[i+1]) * 0.5 / 2.0)
  ans += s
end

puts ans

Measured memory_bytes: 4092
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   const compare = (a, b) => {
   return a - b;
   }
   xs.sort(compare);
   let count = 0;
   for(let i=0; i<xs.length; i++){
      if(xs[i]==xs[i+1]){
      count +=1;
      }else{
      count +=0;
      }
   }
   if(count==0 || count==2){
     console.log('No');
   }else if(count==1){
     console.log('Yes');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
import sys
import math
readline = sys.stdin.buffer.readline

s = readline().rstrip().decode('utf-8')
n = len(s)

if n%2 != 0:
    print("No")
    exit()
else:
    for i in range(0,n,2):
        if s[i:i+2] != "hi":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) {}

    void init(int n) {
        par.assign(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<int> A(m), B(m);
    rep(i, m) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }

    UnionFind tree(n);
    ll cur = n * (n - 1) / 2;
    vector<ll> res;
    rep(i, m) {
        res.push_back(cur);

        int a = A[m-1-i], b = B[m-1-i];
        if (tree.issame(a, b)) continue;

        ll sa = tree.size(a), sb = tree.size(b);
        cur -= sa * sb;
        tree.unite(a, b);
    }

    reverse(res.begin(), res.end());
    rep(i, res.size()) {
        cout << res[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin>>s;
    string rs=s;
    reverse(rs.begin(),rs.end());
    for(int i=0;i<s.size();i++)
    {
        if(rs[i]=='b')rs[i]='d';
        else if(rs[i]=='d')rs[i]='b';
        else if(rs[i]=='p')rs[i]='q';
        else if(rs[i]=='q')rs[i]='p';
    }
    if(s==rs)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 512
n, mw = map(int, input().split())
iwv = [list(map(int, input().split())) for _ in range(n)]

vw = [0] * (mw + 1)

for i in range(n):
  for j in reversed(range(iwv[i][0], mw + 1)):
    vw[j] = max(vw[j], vw[j - iwv[i][0]] + iwv[i][1])
  
print(max(vw))


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

typedef struct{
	double x;
	double y;
}point;

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

	int N;
	int i,j;
	int counter=0;
	double sum=0;
	double ave;
	double answer;

	cin >> N;

	point given[N];

	for(i=0;i<N;i++){
		cin >> given[i].x >> given[i].y;
	}

	for(i=0;i<N;i++){
		//cout << given[i].x << " " << given[i].y << endl;
		for(j=i+1;j<N;j++){
			sum+=sqrt(pow(given[i].x-given[j].x,2.0)+pow(given[i].y-given[j].y,2.0));
		}
	}

	answer=(double)	sum/N;
	answer*=2;
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;int main(){int a,b,c,d,e,f,g,h[13]={0,0,31,59,90,120,151,181,212,243,273,304,334};while(1){cin>>a>>b>>c>>d>>e>>f;if(a==-1)break;g=f-c+h[e]-h[b]+(d-a)*365;if(e<3)d--;if(b<3)a--;g+=d/4-a/4-d/100+a/100+d/400-a/400;cout<<g<<endl;}return 0;}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    if((A*B*1)%2!=0 || (A*B*2)%2!=0 || (A*B*3)%2!=0 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
S_len = len(S)
S_list = list(S)
fin_S = ''
# if S[0] == 'A' and 'C' in S[2:S_len-1]:

if S_list[0] == 'A':
    S_list[0] = 'a'
    #print(S[2:S_len-1])
    if 'C' in S[2:S_len-1]:
        C_index = S.index('C')
        #print(C_index)
        if 2 <= C_index < S_len-1:
            S_list[C_index] = 'c'
            for i in range(S_len):
                fin_S+=S_list[i]
                #print(fin_S)

if fin_S.islower():
    print('AC')
    exit()

print('WA')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<iterator>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define SIZE 100001
 

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N;
    cin>>N;
    if(N%1000!=0)
    cout<<abs(N%1000-1000)<<"\n";
 else
 cout<<0<<"\n";
	
	return 0;
}

 
 

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;
int N,H[100];
int main() {
cin >> N;
for (int i = 0; i < N; ++i){
    cin >> H[i];
}
int count=1;
std::vector<int> v = {};
for (int i = 1; i < N; ++i){
    std::vector<int> v = {};
    for(int j = 0; j < i; ++j){
        v.push_back(H[j]);
}
sort(v.begin(), v.end(), greater<int>());
if(H[i]>=v[0]) count ++;
}
cout << count << endl;
return 0;

}


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


int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int score;
    int xa = min(k,a);
    k -= xa;
    int xb = min(k,b);
    k -= xb;
    int xc = min(k,c);
    cout << 1*xa -1*xc << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>



int main(void) {

    unsigned long long int a;
    double b;
    scanf("%lld %lf", &a, &b);

    unsigned long long int b_ll = (unsigned long long int)(b * 100 + 0.001);
    //printf("%lld\n", b_ll);

    printf("%lld", (long long int)((a * b_ll) / 100));

    return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define READ      freopen("input.txt", "r", stdin);
#define WRITE     freopen("output.txt", "w", stdout);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
const ll MAX = 3001;
const ll INF = 1e18L + 5;
ll x_t = 0, y_j = 0;
ll dp[MAX][MAX];

ll max_score(ll a[], ll l, ll r) {

	if (l > r) return 0;
	if (l == r) return a[l];
	if (dp[l][r] != -1) return dp[l][r];

	ll ans = a[l] - max_score(a, l + 1, r);
	ans = max(ans, a[r] - max_score(a, l, r - 1));
	dp[l][r] = ans;
	return dp[l][r];

}




int main() {

	_cin
	// READ
	// WRITE
	ll n;
	cin >> n;
	ll a[n];
	rep(i, 0, n) cin >> a[i];

	memset(dp, -1, sizeof(dp));

	cout << max_score(a, 0, n - 1);




}

Measured memory_bytes: 74228
from math import gcd
def division(n):
    if n < 2:
        return [1]
    prime_factors = [1]
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)
    return prime_factors

a,b = map(int,input().split())
d = set(division(gcd(a,b)))
print(len(d))

Measured memory_bytes: 9436
def main():
    N, K = map(int, input().split())

    candy = [0] * N
    for _ in range(K):
        d = int(input())
        *a, = (int(x) - 1 for x in input().split())
        for x in a:
            candy[x] += 1

    print(candy.count(0))


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9176
import sys

def search(n):
    result = list()
    for a in xrange(10):
        for b in xrange(10):
            for c in xrange(10):
                if a + b + c <= n:
                    if n - (a+b+c) < 10:
                        result.append([a, b, c, n - (a+b+c)])
                    else:
                        pass
                else:
                    pass
    return len(result)

for line in sys.stdin.readlines():
    line = line.strip()
    n = int(line)
    print search(n)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

int n, u, v, m, tmp;
P rr[1000001], cc[1000001];
int rx[500], ry[500], cx[500], cy[500], rcr[2], ccr[2];

int main(){
    cin.sync_with_stdio(false);
    cin >> n >> u >> v >> m;
    fill(rr, rr + 1000001, P(-1, -1));
    fill(cc, cc + 1000001, P(-1, -1));
    rep(i, n)rep(j, n) {
        cin >> tmp;
        rr[tmp] = P(i, j);
    }
    rep(i, n)rep(j, n) {
        cin >> tmp;
        cc[tmp] = P(i, j);
    }

    int rp = 0, cp = 0;
    int wf = -1;
    rep(i, m) {
        int t;
        cin >> t;
        if (n > 1) {
            if (rr[t] != P(-1, -1)) {
                ry[rr[t].fi]++;
                if (ry[rr[t].fi] == n) rp++;
                rx[rr[t].se]++;
                if (rx[rr[t].se] == n) rp++;
                if (rr[t].fi == rr[t].se) rcr[0]++;
                if (rcr[0] == n) rp++, rcr[0]++;
                if (rr[t].fi + rr[t].se == n - 1) rcr[1]++;
                if (rcr[1] == n) rp++, rcr[1]++;
            }
            if (cc[t] != P(-1, -1)) {
                cy[cc[t].fi]++;
                if (cy[cc[t].fi] == n) cp++;
                cx[cc[t].se]++;
                if (cx[cc[t].se] == n) cp++;
                if (cc[t].fi == cc[t].se) ccr[0]++;
                if (ccr[0] == n) cp++, ccr[0]++;
                if (cc[t].fi + cc[t].se == n - 1) ccr[1]++;
                if (ccr[1] == n) cp++, ccr[1]++;
            }
        } else {
            if (rr[t] != P(-1, -1)) rp = 1;
            if (cc[t] != P(-1, -1)) cp = 1;
        }
        if (wf < 0 && rp >= u && cp >= v) wf = 0;
        else if (wf < 0 && rp >= u) wf = 1;
        else if (wf < 0 && cp >= v) wf = 2;
    }

    cout << ((wf <= 0) ? "DRAW" : ((wf == 1) ? "USAGI" : "NEKO")) << endl;

    return 0;
}

Measured memory_bytes: 18856
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    A = [int(i) for i in input().strip().split()]
    odds = 1
    for a in A:
        if a % 2 == 0:
            odds *= 2
        else:
            continue

    return 3**N - odds


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a<b&&b<c)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 17320
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stdio.h>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
	int n;	cin >> n;
	int temp;


	pair<int, int>a[100002];
	rep(i, n) {
		cin >> temp;
		a[i] = make_pair(temp, i);
	}
	sort(a, a + n);


	rep(i, n) {
		if (i == n - 1) { cout << a[i].second + 1 << " "; }
		else { cout << a[i].second + 1 << endl; }
	}

	return 0;
}

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

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 P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    ll N;
    cin>>N;
    vector<ll> v(N+1,0LL);
    for(ll i = 1; i <= N; i++){
        for(ll j = i; j <= N; j += i){
            v[j]++;
        }
    }
    ll ans = 0;
    rep(i,N+1){
        ans += i*v[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 81348
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    auto one_try = 1900 * M + 100 * (N-M);
    auto p_success = pow(1.0/2, M);
    double exp = 0;
    for(int i=1; i<1000; i++) {
        auto t = one_try * i * p_success * pow(1-p_success, i-1);
        exp += t;
    }
    cout << exp << endl;

    return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 2e5 + 10, INF = 1e9 + 7, MOD = 1e9 + 7;
int fac[N], inv[N], c[N], w[N], mn[N], cnt[N];

LL powMod(LL a, LL b) {
    LL ret = 1;
    while (b) {
        if (b & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

int main() {
    fac[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = 1ll * fac[i-1] * i % MOD;
    inv[N - 1] = powMod(fac[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 0; i < n; i++) scanf("%d%d", c + i, w + i);
    int c1, c2, w1, w2;
    w1 = w2 = INF;
    for (int i = 0; i < n; i++) if (w[i] < w1)  w1 = w[i], c1 = c[i];
    for (int i = 0; i < n; i++) if (w[i] < w2 && c[i] != c1) w2 = w[i], c2 = c[i];
    fill(mn + 1, mn + n + 1, INF);
    for (int i = 0; i < n; i++) mn[c[i]] = min(mn[c[i]], w[i]);
    for (int i = 0; i < n; i++) {
        if (c[i] == c1) {
            if (w[i] == w1 || w[i] + w1 <= x || w[i] + w2 <= y) cnt[c[i]]++;
        } else {
            if (w[i] == mn[c[i]] && mn[c[i]] + w1 <= y) cnt[c[i]]++;
            else if (w[i] + w1 <= y || w[i] + mn[c[i]] <= x && mn[c[i]] + w1 <= y) cnt[c[i]]++;
        }
    }
    int ans = 1, sum = 0;
    for (int i = 1; i <= n; i++) if (cnt[i]) {
        sum += cnt[i];
        ans = 1ll * ans * inv[cnt[i]] % MOD;
    }
    ans = 1ll * ans * fac[sum] % MOD;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#ABC043Bprint(1,end='')
s=input()
s_=[]
for i in range(len(s)):
    if s[i]=="1":
        s_.append("1")
    if s[i]=="0":
        s_.append("0")
    if s[i]=="B":
        if len(s_)!=0:
            s_.pop()

print(''.join(s_))        

Measured memory_bytes: 9112
#include "bits/stdc++.h"
using namespace std;
int main()
{
    long long n, m;
    scanf("%lld %lld", &n, &m);
    if (n > m)
    {
        swap(n, m);
    }
    if (n == 1)
    {
        printf("%lld\n", m == 1 ? 1 : m - 2);
    }
    else
    {
        printf("%lld\n", (n - 2) * (m - 2));
    }
}



Measured memory_bytes: 256