akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int solve(vector<int> a) {
	int n = (int)a.size();
	int ans = 0;
	for (int i = 0; i < n; i++) {
		// for (int j = i + 1; j < n; j++) {
		// 	ans += a[j] - a[i];
		// }
		ans += i * a[i];
		ans -= (n - 1 - i) * a[i];
	}
	return ans % MOD;
} 

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

	int n, m;
	cin >> n >> m;
	vector<int> f(n);
	for (auto &t : f) {
		cin >> t;
	}
	vector<int> s(m);
	for (auto &t : s) {
		cin >> t;
	}
	int ans = solve(f) * solve(s);
	cout << ans % MOD << endl;
}

Measured memory_bytes: 3328
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

import math

count_1up = 0
count_2up = 0

for a, b in zip(A, B):
    if a - b >= 0:
        count_1up += a - b
    else:
        count_2up += math.ceil((b - a) / 2)

diff = sum(B) - sum(A)

# print(diff, count_1up, count_2up)
if diff < 0:
    print("No")
elif diff < count_1up or diff < count_2up:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 41840
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin >> s;

	for(int i=0;i<s.size();i++){
			cout << "x";
	}
	
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [k,a,b] <- getIntList
    let ans | a >= k = 1+k
            | a >= b-2 = 1+k
            | otherwise = b + p*(b-a) + q
            where (p,q) = (k-a-1) `divMod` 2
    print ans

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int seg[1048576]; 
void update(int k, int a){
	k += 524287; 
	seg[k] = a; 
	while(k > 0){
		k = (k - 1) / 2; 
		seg[k] = max(seg[k * 2 + 1], seg[k * 2 + 2]); 
	}
}
long long query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0; 
	if(a <= l && b >= r) return seg[k]; 
	else{
		long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2); 
		long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r); 
		return max(vl, vr); 
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N, K; cin >> N >> K;
	int A[300010]; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	for(int i = 0; i < N; i++){
		int l = max(A[i] - K, 0); 
		int r = min(A[i] + K, 300000); 
		int mx = query(l, r+1, 0, 0, 524288); 
		update(A[i], mx + 1); 
	}
	cout << query(0, 300001, 0, 0, 524288) << "\n"; 
}

Measured memory_bytes: 7196
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n, k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  ll ans = 0;
  for (int m = 0; m <= min(k, n); m++) {        // m: 取り出す回数
    for (int x = 0; x <= m; x++) {              // x: 左から取り出す回数
      vector<ll> a;
      rep(i, x) a.push_back(v[i]);
      rep(i, m-x) a.push_back(v[n-i-1]);
      sort(ALL(a), greater<ll>());
      rep(i, k - m) {                      // 価値が負のものを k-m 回まで捨てる
        if (!a.empty() && a.back() < 0) a.pop_back();
        else break;
      }
      chmax(ans, SUM(a));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n,m;

int main(){
    scanf("%d%d",&n,&m);
    printf("%d\n", n*m);
    return 0;
}
/*

*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


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

int main(){
  using namespace std;
  unsigned long N;
  cin >> N;
  unsigned long ans{numeric_limits<unsigned long>::max()};
  for(unsigned long i{1}; i * i <= N; ++i)if(N % i == 0)ans = min(ans, i + N / i);
  cout << ans - 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b)forn(i,a)
    {
        printf("%d",b);
    }
    else forn(i,b)
    {
        printf("%d",a);
    } 
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,t;
cin>>s>>t;
int size1=s.size();
int size2=t.size();
int dp[size1+1][size2+1];
for(int i=0;i<=size1;i++)
{
for(int j=0;j<=size2;j++)
dp[i][j]=0;
}
for(int i=0;i<size1;i++)
{
//int p=1;
for(int j=0;j<size2;j++)
{
if(s.at(i)==t.at(j))
{
dp[i+1][j+1]=1+dp[i][j];
//if(p)
//cout<<s.at(i)<<endl;
//p=0;
}
else
dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
}
}
//cout<<dp[size1][size2];
string ans;
int i=size1;
int j=size2;
while(i>0 && j>0)
{
if(s.at(i-1)==t.at(j-1))
{

ans.push_back(s.at(i-1));
i--;
j--;
}
else
{
if(dp[i][j-1]>dp[i-1][j])
j--;
else 
i--;
}
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;

return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 1e6 + 10;
int n, val[maxn];

int main() {
  cin >> n;
  rep(i, 1, n) scanf("%1d", val + i);
  if (n == 1) return printf("%d", val[1]), 0;
  n--;
  bool flg1 = 0, flg2 = 0;
  rep(i, 1, n) val[i] = abs(val[i] - val[i + 1]), flg1 |= val[i] == 1, flg2 |= val[i] == 2;
  bool res2 = 0;
  if (!flg1 && flg2) {
    res2 = 1;
    rep(i, 1, n) val[i] >>= 1;
  }
  if (flg1 && flg2) {
    rep(i, 1, n) if (val[i] == 2) val[i] = 0;
  }
  int res = 0;
  rep(i, 1, n) if (val[i]) {
    res ^= (((n - 1) & (i - 1)) == (i - 1));
  }
  cout << res * (res2 ? 2 : 1) << endl;
  return 0;
}

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

#define ull unsigned long long
#define ll long long
#define ul unsigned long

using namespace std;

int main()
{
	ul result = 0;
	ul N = 0;
	cin >> N;

	vector < ul > data;

	for(ul i = 0; i < N; ++i)
	{
		ul a = 0;
		cin >> a;
		data.push_back(a - 1);
	}

	for(ul i = 0; i < N; ++i)
	{
		if(data[data[i]] == i)
		{
			++result;
		}
	}

	cout << result / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 1400
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$n = $sc->nextInt();

$arr = [];
for ($i = 0; $i < $n; $i++) {
    $arr[$i] = $i + 1;
}
$arr2 = $arr;

$key = 0;
$cnt_max = 0;
for ($i = 0; $i < count($arr2); $i++) {
    $cnt = 0;
    while ($arr2[$i] % 2 === 0) {
        $arr2[$i] /= 2;
        $cnt++;
    }
    if ($cnt_max <= $cnt){
        $cnt_max = $cnt;
        $key = $i;
    }
}

echo $arr[$key];

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

int D;
const int M = 26;
vector<int> C;
vector<vector<int>> S;
vector<int> T;

template<class T> inline bool chmax(T &a, T b)
{
    if(a < b)
    {
        a = b;
        return true;
    }
    return false;
}

std::mt19937 mt{ std::random_device{}() };

int randint(int lower, int upper)
{
    std::uniform_int_distribution<int> dist(lower, upper);
    return dist(mt);
}

int calc_score()
{
    int ans = 0;
    vector<int> last(M, -1);
    for(int i=0; i<D; i++)
    {
        ans += S[i][T[i]];
        last[T[i]] = i;
        for(int j=0; j<M; j++)
        {
            ans -= C[j] * (i - last[j]);
        }
    }
    return ans;
}

int main()
{
    int tstart = clock();
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> D;
    C.resize(M);
    for(int i=0; i<M; i++) cin >> C[i];
    S.resize(D);
    for(int i=0; i<D; i++)
    {
        S[i].resize(M);
        for(int j=0; j<M; j++)
        {
            cin >> S[i][j];
        }
    }

    T.resize(D);
    vector<int> CNT(D, 0);
    vector<vector<int>> Greater(D, vector<int>(M));
    for(int i=0; i<D; i++)
    {
        vector<int> minS = S[i];
        sort(minS.begin(), minS.end(), greater<int>());
        for(int j=0; j<M; j++)
        {
            int k=0;
            for(k=0; k<M; k++)
            {
                if(S[i][k] == minS[j]) break;
            }
            Greater[i][j] = k;
        }
        T[i] = Greater[i][0];
        CNT[i]++;
    }
    int score = calc_score();
    while(1.0 * (clock() - tstart) / CLOCKS_PER_SEC < 1.95)
    {
        // cout << 1.0 * (clock() - tstart) / CLOCKS_PER_SEC << endl;
        int H = randint(0, D-1);
        int Q = Greater[H][CNT[H]];
        if(CNT[H] < M - 1) CNT[H]++;
        int tmp = T[H];
        T[H] = Q;
        int nscore = calc_score();
        if(score < nscore)
        {
            score = nscore;
        }
        else
        {
            T[H] = tmp;
        }
    }
    for(int i=0; i<D; i++)
    {
        cout << T[i] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;

struct data{
	
	string name;
	int w;
	int l;
	int e;
	int t;
	static bool s  (const data& x,const data& y){
        return x.t>y.t;
    }
};

int main(){
	
	int n;
	int f=0;
	while(cin>>n,n!=0){
		if(f!=0)
		cout<<endl;
		vector<data> m(n);
		for(int i=0;i<n;i++){
			cin>>m[i].name>>m[i].w>>m[i].l>>m[i].e;
			m[i].t=m[i].w*3+m[i].e;
		}
		sort(m.begin(),m.end(),data::s);
		for(int i=0;i<n;i++)
			cout<<m[i].name<<","<<m[i].t<<endl;
		f=1;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    vec a(N+1);
    a[0] = 0;
    rep(i,N) cin>>a[i+1];
    a.push_back(0);
    ll sum = 0;
    rep(i,N+1) sum += abs(a[i+1] - a[i]);
    rep(i,N){
        cout<<sum - abs(a[i+2] - a[i+1]) - abs(a[i+1] - a[i]) + abs(a[i+2] - a[i])<<endl;
    }
}

Measured memory_bytes: 2032
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	int n, x, cou = 0;
	bool bo = true;
	double s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		s = sqrt(double(x));
		for (int j = 2; (double)j <= s; ) {
			if (x % j == 0) {
				bo = false;
				break;
			}
			if (j == 2) j++;
			else j += 2;
		}
		if (bo == true) cou++;
		else  bo = true;
	}
	cout << cou << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int D=366;
int K=26;
int main()
{
  int d,cc=0,i,j,r,rj,x;
  int c[K],s[D][K],t[D],m[D],l[D][K],res[D],
  t2[D],m2[D],l2[D][K],res2[D];
  cin >> d;
  for(i=0;i<K;i++){
    cin >> c[i];
    cc+=c[i];
  }
  for(i=1;i<=d;i++)
    for(j=0;j<K;j++)
      cin >> s[i][j];
  fill(l[0],l[0]+K,0);
  m[0]=0;
  res[0]=0;
  for(i=1;i<=d;i++){
    r=0;
    rj=-1;
    copy(l[i-1],l[i-1]+K,l[i]);
    for(j=0;j<K;j++)
      if(s[i][j]+c[j]*(i-l[i][j])>r){
        r=s[i][j]+c[j]*(i-l[i][j]);
        rj=j;
      }
    m[i]=m[i-1]+cc-c[rj]*(i-l[i][rj]);
    t[i]=rj;
    l[i][rj]=i;
    res[i]=res[i-1]+s[i][rj]-m[i];
  }
  for(x=d-1;x>=1;x--){
    copy(t,t+D,t2);
    t2[x]=t[x+1];
    t2[x+1]=t[x];
    copy(m,m+D,m2);
    for(j=0;j<x;j++)
      copy(l[j],l[j]+K,l2[j]);
    copy(res,res+D,res2);
    for(i=x;i<=d;i++){
      copy(l2[i-1],l2[i-1]+K,l2[i]);
      m2[i]=m2[i-1]+cc-c[t2[i]]*(i-l2[i][t2[i]]);
      l2[i][t2[i]]=i;
      res2[i]=res2[i-1]+s[i][rj]-m2[i];
    }
    if(res2[d]>res[d]){
      copy(t2,t2+D,t);
      copy(m2,m2+D,m);
      for(j=x;j<=d;j++)
        copy(l2[j],l2[j]+K,l[j]);
      copy(res2,res2+D,res);
    }
  }
  for(i=1;i<=d;i++)
    cout << t[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>

int main()

{

  char cp;

  scanf ("%c", &cp);

    if(cp=='a' || cp=='e' || cp=='i' || cp=='o' || cp=='u' ||
       cp=='A' || cp=='E' || cp=='I' || cp=='O' || cp=='U')
    {
        printf("vowel", cp);
    }
    else {
        printf("consonant", cp);
    }


  return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int N,M,pos,dist;

int main(){
    cin>>N>>M;
    int a[N],b[N],c[M],d[M];
    rep(i,N){
        cin>>a[i]>>b[i];
    }
    rep(i,M){
        cin>>c[i]>>d[i];
    }
    rep(i,N){
        pos=1;
        dist=1e9;
        rep(j,M){
            if(dist>abs(a[i]-c[j])+abs(b[i]-d[j])){
                // out(j);
                // out(dist);
                pos=j+1;
                dist=abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        out(pos);
    }
}


Measured memory_bytes: 256
program ABC136D
    implicit none
    integer(8)::i,j,N
    integer(8),dimension(100000)::L,RL_R
    character(100000)::S
    read(5,*)S
    N=len_trim(S)
    L=0
    j=1

    do i=1,N-1
        if(S(i:i)=="R".and.S(i+1:i+1)=="L")then
            RL_R(j)=i
            j=j+1
        end if
    end do

    j=1
    do i=1,N
        if(i<=RL_R(j))then
            if(mod(RL_R(j)-i,2)==0)then
                L(RL_R(j))=L(RL_R(j))+1
            else
                L(RL_R(j)+1)=L(RL_R(j)+1)+1
            end if
        else if(S(i:i)=="L")then
            if(mod(i-RL_R(j),2)==0)then
                L(RL_R(j))=L(RL_R(j))+1
            else
                L(RL_R(j)+1)=L(RL_R(j)+1)+1
            end if
        else
            j=j+1
            if(mod(RL_R(j)-i,2)==0)then
                L(RL_R(j))=L(RL_R(j))+1
            else
                L(RL_R(j)+1)=L(RL_R(j)+1)+1
            end if
        end if
    end do

    do i=1,N
        write(*,fmt='(i0,1x)',advance='no')L(i)
    end do
    print'(A)',""
end program ABC136D

Measured memory_bytes: 1956
#include <iostream>
#include <algorithm>
#define SORT(v, n) sort(v, v+n)
#define print(x) cout << x << endl;

using namespace std;
int main(void){
    int X[3];
    cin >> X[0] >> X[1] >> X[2];
    SORT(X, 3);
    
    if(X[0] == 5 && X[1] == 5 && X[2] == 7){
     	print("YES");
    }else{
     	print("NO");     
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
r = 0
for i in range(2**(len(s)-1)):
  fml = ""
  for j in range(len(s)-1):
    fml += s[j]
    if((i>>j)%2): fml += "+"
  fml += s[-1]
  r += eval(fml)
print(r)

Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a; double b; cin >> a >> b;
  b *= 100.1;
  ll nb = b;
  cout << a * nb / 100 << endl;

}


Measured memory_bytes: 3688
li2 = []
cnt = 1
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a,b,c,d,e]
k = int(input())
for y in li:
    li2.append(y-a)
    li2.append(y-b)
    li2.append(y-c)
    li2.append(y-d)
    li2.append(y-e)


for x in li2:
    if x < 0:
        x = -x
    if x > k:
        cnt = 1
        break
        
    else:
         cnt = 0
if cnt == 0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    map<string, int> st;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st[s]++;
    }
    cout << "AC x " << st["AC"] << endl;
    cout << "WA x " << st["WA"] << endl;
    cout << "TLE x " << st["TLE"] << endl;
    cout << "RE x " << st["RE"] << endl;
}

Measured memory_bytes: 3604
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = do
	s <- getLine
	putStrLn $ if last s == 's'
		then s ++ "es"
		else s ++ "s"

Measured memory_bytes: 3832
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

int bsearch(ll a[],int n,ll x)
{
  int l=1,r=n;
  ll mini=1e18;
  int ans=0;
  while(l<=r)
  {
    int mid=(l+r)>>1;
    if(abs(a[mid]-x)<mini)
    {
      mini=abs(a[mid]-x);
      ans=mid;  
    }
    if(a[mid]-x>0) r=mid-1;
    else l=mid+1;
  }
  return ans;
}
void solve()
{
     int n,m,q; cin>>n>>m>>q;
     ll a[n+2],b[m+2];
     a[0]=1e18,a[n+1]=1e18,b[0]=1e18,b[m+1]=1e18;
     rep(i,1,n+1) cin>>a[i];
     rep(i,1,m+1) cin>>b[i];
     while(q--)
     {
       ll x,ans; cin>>x;
       int idx1=bsearch(a,n,x);
       int idx2=bsearch(b,m,x);
       if((x>=a[idx1] && x>=b[idx2]) || (x<=a[idx1] && x<=b[idx2]))
       ans=max(abs(x-a[idx1]),abs(x-b[idx2]));
       else{
        ans=min(abs(x-a[idx1])*2+abs(x-b[idx2]),abs(x-b[idx2])*2+abs(x-a[idx1]));
        if(a[idx1]>b[idx2]) 
          {
            ans=min(max(abs(x-a[idx1]),abs(x-b[idx2+1])),ans);
            ans=min(max(abs(x-a[idx1-1]),abs(x-b[idx2])),ans);
          }
          else{
            ans=min(max(abs(x-a[idx1]),abs(x-b[idx2-1])),ans);
            ans=min(max(abs(x-a[idx1+1]),abs(x-b[idx2])),ans);
          }
       }
       cout<<ans<<endl;
     }
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  bool flag=true;
  cin>> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>> a[i];
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0);
      else flag=false;
    }
  }
  if(flag){
    cout<<"APPROVED"<<"\n";
  }else{
    cout<<"DENIED"<<"\n";
  }
}

Measured memory_bytes: 256
s1 = input()
s2 = s1[::-1]
for i in range(len(s1)):
	if s1[i] == "A":
		start = i + 1
		break
for i in range(len(s2)):
	if s2[i] == "Z":
		goal = len(s2) - i 
		break

print(goal - start + 1)

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

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

    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    LL ans = 0;

    for (int i = 0; i < N; i++) {
        LL pre = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        LL over = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += pre * over;
    }


    cout << ans;

    return 0;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(std::string S) {
  if(S[2]==S[3] && S[4]==S[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3616
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int K;
  cin >> K;
  cout << (K / 2) * (K - K / 2) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

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

using namespace std;
int main(){
    int n;
    cin>>n;
    for(int a=1; a<=9; a++){
        for(int b=1; b<=9; b++){
            if(a*b==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
}
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,n) for(int i=0; i<n; i++)
#define forp(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        arrin(a,n);
        ll sum=0;
        sort(a,a+n);
        reverse(a,a+n);
        sum+=a[0];
        n--;
        rep(i,n/2){
            sum+=2*a[i+1];
        }
        if(n%2==0) sum-=a[n/2];
        cout<<sum<<nl;
    }
    return 0;
}

Measured memory_bytes: 4752
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-48,ch=getchar();
	}
	return x*f;
}
char s[101000];
int a[101000],L[101000],R[101000],ll[101000],rr[101000];
int main()
{
	int n=read(),k=read();
	scanf("%s",s+1);
	for(int i=1; i<=n; i++) a[i] = s[i]-'0';
	if(k==0) {
		int kkk=0,ans=0;
		for(int i=1; i<=n; i++) {
			if(a[i-1]==0&&a[i]==1) kkk=0;
			if(a[i]==1) kkk++;
			ans = max(ans,kkk);
		}
		printf("%d\n",ans);
		return 0;
	}
	int nowl = 1,q = 0;
	a[0]=1,a[n+1]=1;
	for(int i=1; i<=n; i++) {
		if(a[i]==0&&a[i-1]==1) rr[q]=i-1,L[++q] = i,ll[q]=nowl;
		if(a[i]==0&&a[i+1]==1) R[q] = i,nowl = i+1;
	}
	rr[q]=n;
	if(q==0) {
		printf("%d\n",n);
		return 0;
	}
	int ans = 0;
	for(int i=1; i<=q; i++) {
		int p = i+k-1;
		if(p>q) p=q;
		ans = max(ans,rr[p]-ll[i]+1);
	}
	printf("%d\n",ans );
	return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#define N 200000
 
int main(){
  int n,i,R[N];
  int max,min;
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++)
    scanf("%d",&R[i]);
     
    min=R[0];
    max=R[1]-R[0];
     
  for(i=1;i<n;i++){
    if(R[i]-min>max) max=R[i]-min;
    if(R[i]<min) min=R[i];
    }
     
    printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#include<iostream>
using namespace std;
int main()
{
  long A;
  string X;
  cin >> A;
  if(A == 0){
    X = "0";
  }
else{
  while(A != 0){
    if (A % (-2) == 0){
      X = "0" + X;
    }
    else{
      X =  "1" + X;
      A --;
    }
    A /= (-2);
  }
}
  cout << X  << endl;
}


Measured memory_bytes: 256
;; B - Count ABC

(defun solve (S)
  (count t
    (maplist #'starts-with-ABC (coerce S 'list))))

(defun starts-with-ABC (ls)
  (and (>= (length ls) 3)
       (equal (subseq (coerce ls 'string) 0 3) "ABC")))

(let* ((N (read))
       (S (read-line)))
  (princ (solve S))
  (fresh-line))


Measured memory_bytes: 14180
from math import gcd

a, b, c, d = map(int, input().split())
n = c * d // gcd(c,d)
x = (b // c) - ((a-1) // c)
y = (b // d) - ((a-1) // d)
z = (b // n) - ((a-1) // n)
print(b-a+1-(x+y-z))

Measured memory_bytes: 9144
use std::io;

fn main() {
    let input = input_number();
    let n = input[0] as usize;
    let m = input[1] as usize;
    let l = input[2] as usize;
    let mut nm: Vec<Vec<i64>> = vec![];
    for _ in 0..n {
        nm.push(input_number());
    }
    let mut ml: Vec<Vec<i64>> = vec![];
    for _ in 0..m {
        ml.push(input_number());
    }
    for i in 0..n {
        for j in 0..l {
            let sum = (0..m).fold(0, |sum, k| sum + nm[i][k] * ml[k][j]);
            print!("{}", sum);
            if j != l-1 { print!(" "); }
        }
        println!("");
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<i64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<i64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
int A[5000];
vector<int> g[5000];
ll dp[5000][5000][2];
ll dp2[5000][2];

int dfs(int u, int par) {
	int res = 1;
	dp[u][0][A[u] > 0] = A[u];
	
	for (int v : g[u]) if (v != par) {
		int c = dfs(v, u);
		fill(dp2[0], dp2[res + c], longINF);
		REP(i, res) {
			REP(j, c) {
				REP(k, 2) REP(l, 2) {
					if (dp[u][i][k] != longINF && dp[v][j][l] != longINF) {
						chmin(dp2[i + j][k == 1 && l == 1], dp[u][i][k] + dp[v][j][l]);
						if (l == 0 && dp[v][j][l] >= 0) continue;
						chmin(dp2[i + j + 1][k], dp[u][i][k]);
					}
				}
			}
		}
		REP(i, res + c) REP(j, 2) dp[u][i][j] = dp2[i][j];
		res += c;
	}
	return res;
}

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	REP(i, N - 1) {
		int u, v;
		scanf("%d %d", &u, &v);
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	fill(dp[0][0], dp[N][0], longINF);
	dfs(0, -1);
	
	int ans = N - 1;
	REP(i, N) if (dp[0][i][0] < 0 || dp[0][i][1] != longINF) {
		ans = i;
		break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 391808
#define N 100001 
long p[N],r[N],n,m,i,b[N],a[N][2],c,d;int f(int x){if(p[x]==x)return x;return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);p[x]=y;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",a[i],&a[i][1]);b[m]=n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){c=a[i][0],d=a[i][1];if(f(c)==f(d))b[i]=b[i+1];else{b[i]=b[i+1]-r[f(c)]*r[f(d)];u(c,d);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct BIT{
private:
   int sz;
   vector<ll> node;
public:
   BIT(int n):sz(n),node(n+1){};
   void add(int k,ll x){
       k++;
       while(k<=sz){
           node[k]+=x;
           k+=k&-k;
       }
   }
   ll sum(int k){
       k++;
       ll ret=0;
       while(k>0){
           ret+=node[k];
           k-=k&-k;
       }
       return ret;
   }
   ll sum(int l,int r){
       return sum(r-1)-sum(l-1);
   }
   ll get(int k){
       return sum(k,k+1);
   }
};

int main(){
    ll n;cin>>n;
    ll a[n],b[n];
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int l=0,r=n,m=1;
    while(r-l>1){
        m=(l+r)/2;
        BIT bit(2*n+1);
        int sum=n;
        bit.add(sum,1);
        ll ans=0;
        rep(i,n){
            if(a[i]>=b[m])++sum;
            else --sum;
            ans+=bit.sum(sum);
            bit.add(sum,1);
        }
        if(ans*2<n*(n+1)/2)r=m;
        else l=m;
    }
    cout<<b[l]<<endl;
    return 0;
}


Measured memory_bytes: 3428
N = int(input())
*A, = map(int, input().split())
dic = {}
ans = 0
for i in range(N):
    if A[i] + i in dic:
        dic[A[i] + i] += 1
    if A[i] + i not in dic:
        dic[A[i] + i] = 1
    if i - A[i] in dic:
        ans += dic[i - A[i]]
print(ans)

Measured memory_bytes: 40272
#include <cmath>
#include <iostream>

using namespace std;

int main() {
    int n;
    int tupleCount = 0;

    cin >> n;

    for (int i = 1; i < n; i++) {
        tupleCount += (n - 1) / i;
    }

    cout << tupleCount << endl;

    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int A, P;

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

  cin>>A>>P;

  int ans = (A*3 + P)/2;
  out(ans);
  

  return 0;
}


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;        if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

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

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int dp[n+1][3];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = a[0][0], dp[0][1] = a[0][1], dp[0][2] = a[0][2];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            if (j == 0) {
                dp[i][j] = a[i][j] + max(dp[i-1][j + 1], dp[i-1][j + 2]);
            } else if (j == 1) {
                dp[i][j] = a[i][j] + max(dp[i-1][j - 1], dp[i-1][j + 1]);
            } else {
                dp[i][j] = a[i][j] + max(dp[i-1][j - 1], dp[i-1][j - 2]);
            }
        }
    }

    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}

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

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

    return 0;
}



Measured memory_bytes: 9800
#!/usr/bin/ruby
n,k=gets.split.map(&:to_i)
s=gets.chomp.chars.map{|c|c==?A ? 0 : 1}
f=0
i=0
while i<n&&k>0
	if (1-s[i]+f)%2>0
		s[i]=[1,0][f]
	else
		f^=1
		s[n+i]=[0,1][f]
		i+=1
	end
	k-=1
end
if 0<k
	if n%2>0
		print [?B,?A][(~s[i]+f+k)%2]
	end
	puts 'BA'*(n/2)
else
	puts s[i,n].map{|c|[?B,?A][(~c+f)%2]}*''
end


Measured memory_bytes: 30716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> m.at(i);
    sum+=m.at(i);
  }
  int x=X-sum;
  sort(m.begin(),m.end());
  cout << N+x/m.at(0) << endl;
  

  return 0;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math
# import numpy as np

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

N, *A = map(int, read().split())
print('YES' if N==len(set(A)) else 'NO')

Measured memory_bytes: 24192
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;


int main(){
    string N;
    cin >> N;
    int mod=0;
    REP(i,N.size()){
        mod += int(N[i]) - int('0');
    }
    string ans = "No";
    if(stoi(N)%mod==0){
        ans = "Yes";
    }
    cout << ans;

}

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

int main(){
  char b;

  cin >> b;

  if(b=='A') cout << "T\n";
  else if(b=='T') cout << "A\n";
  else if(b=='C') cout << "G\n";
  else cout << "C\n";
}

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

string check(int num);

int main(){
	int ans = 0;
	string s,p;
	cin >> s;
	
	while(cin >> p){
		if(p == "END_OF_TEXT")break;
		if(s.size() != p.size())continue;
		transform(p.begin(), p.end(), p.begin(), ::tolower);
		if(s==p)ans++;
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 3164
#%%
def dfs_deep_measure(st, n, reach, color):
    ans_list = [[0, 0, 0, 0, 0] for i in range(n)]
    # check, color, last_point, this_point
    stack = [st]
    ans_list[st][0] = 1
    ans_list[st][1] = -1
    ans_list[st][2] = -1
    ans_list[st][3] = st
    while len(stack) > 0:
        tmp = stack.pop(-1)
        tmp_list = reach[tmp]
        c = ans_list[tmp][1]
        for i, j in tmp_list:
            if ans_list[i][0] != 1:
                stack.append(i)
                ans_list[i][0] = 1
                c += 1
                ans_list[i][1] = c % color
                ans_list[i][2] = tmp
                ans_list[i][3] = i
                ans_list[i][4] = j
    return ans_list


n = int(input())
a, b = [0] * n, [0] * n
reach = [[] for _ in range(n)]
for i in range(n-1):
    a[i], b[i] = map(lambda x: int(x)-1, input().split())
    reach[a[i]].append([b[i], i])
    reach[b[i]].append([a[i], i])

st = -1
color = -1
for i in range(n):
    if len(reach[i]) > color:
        color = len(reach[i])
        st = i

#print(st, n, reach, color)
#print(dfs_deep_measure(st, n, reach, color))

ans_list = dfs_deep_measure(st, n, reach, color)
ans_list.sort(key=lambda x: x[4])

#print(ans_list)
print(color)
for i in range(len(ans_list)):
    if ans_list[i][1] == -1:
        pass
    else:
        print(ans_list[i][1]+1)



Measured memory_bytes: 58496