akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace
namespace { // cumsum

template <typename U, typename T, typename InputIt>
std::vector<U> cumsum(InputIt first, InputIt last, T init) {
  std::vector<U> sum((last-first)+1);
  sum[0] = static_cast<U>(init);
  size_t i = 0;
  for (auto iter = first; iter != last; ++iter, ++i) {
    sum[i+1] = sum[i] + *iter;
  }
  return sum;
}

} // namespace

using namespace std;

void solve(int N, vector<lli> const &As) {
  auto const sum = cumsum<lli>(begin(As), end(As), 0);
  vector<vector<lli>> dp(N+1, vector<lli>(N+1, infty<lli>));
  REP(i, N) { dp[i][0] = dp[i][1] = 0; }
  FOR(len, 2, N) for (int i = 0; i + len <= N; ++i) {
    int const j = i + len;
    FOR(k, i, j-1) {
      int s = k - i, t = len - s;
      chmin(dp[i][len], dp[i][s] + dp[k][t] + (sum[j]-sum[i]));
    }
  }
  cout << dp[0][N] << endl;
}

int main() {
  int N; cin >> N;
  vector<lli> As;
  REP(i, N) {
    lli A;
    cin >> A;
    As.push_back(A);
  }
  solve(N, As);
  return 0;
}


Measured memory_bytes: 1536
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
h = na()

flag = True
for i in range(n - 1, 0, -1):
    if h[i] < h[i - 1]:
        h[i - 1] -= 1
        if h[i] < h[i - 1]:
            flag = False

print("Yes" if flag else "No")

Measured memory_bytes: 14396
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveD();
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		List<Long> list = new ArrayList<>();
		for (int i = 0; i < 3 * N; i++) {
			list.add(sc.nextLong());
		}

		List<Long> maxSumList = getSumList(list, new PriorityQueue<>(Comparator.naturalOrder()), N);
		Collections.reverse(list);
		List<Long> minSumList = getSumList(list, new PriorityQueue<>(Comparator.reverseOrder()), N);

		List<Long> scoreList = new ArrayList<>();
		for (int splitIndex = N; splitIndex <= 2 * N; splitIndex++) {
			scoreList.add(maxSumList.get(splitIndex - 1) - minSumList.get(3 * N - 1 - splitIndex));
		}
		System.out.println(scoreList.stream().max(Comparator.naturalOrder()).get());
	}

	private List<Long> getSumList(List<Long> list, PriorityQueue<Long> queue, int limitSize) {
		List<Long> sumList = new ArrayList<>();
		long sum = 0L;
		for (long value : list) {
			queue.add(value);
			sum += value;
			if (queue.size() > limitSize) {
				sum -= queue.remove();
			}
			sumList.add(sum);
		}
		return sumList;
	}
}

Measured memory_bytes: 119724
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;

signed main(){
    map<string,int> map;
    int q;
    cin>>q;
    while(q--){
        int y;
        string k;
        cin>>y>>k;
        if(y==0){
            int x;
            cin>>x;
            map[k]=x;
        }
        else{
            cout<<map.find(k)->second<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 27732
#include<iostream>

using namespace std;

const int DIGIT_NUM = 9;
bool outputAdjst = false;

void puzzleCheck(int num[], int nowNumber, bool *bFound){
	int zeroCount = 0;
	int twoCount = 0;

	if( *bFound ) return ;

	for(int i = 0; i < DIGIT_NUM; i++){
		if( num[i] >= 3 ){
			num[i] -= 3;
			puzzleCheck(num, nowNumber, bFound);
			num[i] += 3;
			if( *bFound ) return ;
		}
	}

	for(int i = 0; i < DIGIT_NUM - 2; i++){
		if( num[i] >= 1 && num[i+1] >= 1 && num[i+2] >= 1 ){
			--num[i];--num[i+1];--num[i+2];
			puzzleCheck(num, nowNumber, bFound);
			++num[i];++num[i+1];++num[i+2];
			if( *bFound ) return ;
		}
	}

	for(int i = 0; i < DIGIT_NUM; i++){
		switch( num[i] ){
			case 0:
				zeroCount++;
				break;
			case 2:
				twoCount++;
				break;
		}
	}

	if( twoCount == 1 && zeroCount == DIGIT_NUM - 1 ){
		if( outputAdjst ) cout << ' ' << nowNumber;
		else cout << nowNumber;
		*bFound = true;
		outputAdjst = true;
	}

	return ;
}

int main(void){
	while( true ){
		int num[DIGIT_NUM] = {0,};
		bool clear = false;
		bool end = false;

		outputAdjst = false;

		for(int i = 0; i < 13; i++){
			int d = 0;
			if( scanf("%1d", &d) != 1 ){
				end = true;
				break;
			}
			num[d-1]++;
		}

		if( end ) break;
		
		for(int i = 0; i < DIGIT_NUM; i++){
			bool found = false;
			bool invalid = false;
			
			if( i > 0 ) num[i - 1]--;
			num[i]++;
			if( num[i] >= 5 ) continue;

			/*for(int j = 0; j < DIGIT_NUM; j++) if(num[j] >= 5)invalid = true;
			if( invalid ) continue;*/
			
			puzzleCheck(num, i + 1, &found);

			if( found ) clear = true;
		}
		if( clear ) cout << '\n';
		else cout << "0\n";
	}
	return 0;
}

Measured memory_bytes: 0
//
//  main.cpp
//  atcoderX
//
//  Created by 村井真奈美 on 2018/06/16.
//  Copyright © 2018年 村井真奈美. All rights reserved.
//

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

int main() {
    
    int N;
    cin >>N;
    
    vector<int> num(N);
    int ct = 0;
    
    for(int i = 0 ; i<N ; i++){
        cin >> num[i];
    }
    for(int i=0 ; i<N ; i++){
        while(num[i]%2 == 0){
            ct++;
            num[i] /= 2;
        }
    }
    
    cout << ct << endl;
 
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll k; cin>>n>>k;
	map<int, ll> mp;
	for(int i = 0; i < n; i++){
		int a, b;
		cin>>a>>b;
		mp[a] += b;
	}
	for(auto x : mp){
		if(k <= x.second){
			cout<<x.first<<endl;
			break;
		}
		k -= x.second;
	}

	return 0;
}

Measured memory_bytes: 4224
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> hh(N);
    rep(i, N) cin >> hh.at(i);

    sort(hh.begin(), hh.end());
    reverse(hh.begin(), hh.end());

    int64_t sum = 0;

    for (int i = K; i < hh.size(); i++)
    {
        sum += hh.at(i);
    }
    cout << sum << endl;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

typedef long long ll;
typedef pair<ll, ll> P;

const int MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  int a,b,c;cin>>a>>b>>c;
  (a+b+c<=21) ? OUT("win") : OUT("bust");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

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

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
LL gcd(LL a, LL b){
	return (b == 0) ? a : gcd(b, a%b);
}
int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL n;
	cin>>n;
	VL arr(n);
	rep(i,0,n){
		cin>>arr[i];
	}
	// sort(ALL(arr));
	LL g;
	if(arr[1] > arr[0])
		g = gcd(arr[1], arr[0]);
	else
		g = gcd(arr[0], arr[1]);
	rep(i,2,n){
		if(g >= arr[i])
			g = gcd(g, arr[i]);
		else
			g = gcd(arr[i], g);
	}
	cout<<g;
  	return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll n;
ll ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        ans+=a;
    }
    cout<<ans-n<<endl;
}


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

int main(){
    int N,A,B;
    cin>>N>>A>>B;

    cout<<min(N*A,B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;


int main() {
    fast;
    string s; cin >> s;
    vector<pii> q;
    int n = s.size();
    int cnt = 0, minp = 1e9;
    FOR(i, n, 0)
    {
        if(s[i] == '>')
        {
            cnt++;
            minp = min(minp, i);
        }
        else
        {
            if(cnt)
            {
                q.pb({minp, cnt});
                minp = 1e9;
            }
            cnt = 0;
        }
    }
    if(cnt)
    {
        q.pb({minp, cnt});
    }
    vector<int> ans;
    int l = 0, up = q.size();
    //cout << up << endl;
    if(q.size() == 0)ans.pb(0);
    else
    {
        if(q[0].f == 0)
        {
            ans.pb(q[0].s);
            l++;
        }
        else ans.pb(0);
    }
    FOR(i, n, 0)
    {
        //OUTV(ans);cout << endl;
        if(l < up)
        {
           // cout << "ASFD" << endl;
            if(q[l].f == i + 1)
            {
                ans.pb(max(ans[i] + 1, q[l].s));
                l++;
                continue;
            }
        }
        if(s[i] == '<')ans.pb(ans[i] + 1);
        else
        {
            ans.pb(q[l - 1].s - (i + 1 - q[l - 1].f));
        }
    }
    //OUTV(ans); cout << endl;
    ll sum = 0;
    for(auto e : ans)sum += e;
    cout << sum;
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    vector<bool> judge(n, true);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (h[a - 1] <= h[b - 1]) judge[a - 1] = false;
        if (h[b - 1] <= h[a - 1]) judge[b - 1] = false;
    }
    int ans = 0;
    rep(i, n) {
        if (judge[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t = h2*60+m2 - (h1*60+m1);
    cout << max(0, t-k) << endl;

    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    vi cnt(26);
    int n = sz(s);
    rep(i, n) cnt[s[i]-'a']++;
    rep(i, 26) {
        if (cnt[i] == 0) {
            cout << (char)(i+'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>
#include<math.h>

int main(){
    int n;
    int sco[1000];
    int sum;
    double a,dis,m;
    while(1){
        scanf("%d",&n);
        if(n==0)
            break;
        sum=0;
        a=0;
        dis=0;
        m=0;
        for(int i=0;i<n;i++){
            scanf("%d",&sco[i]);
            sum+=sco[i];
        }
        m=(double)sum/n;
        for(int i=0;i<n;i++){
            dis+=pow((sco[i]-m),2);
        }
        dis=dis/n;
        a=sqrt(dis);
        printf("%f\n",a);
 
    }
    return 0;
}


Measured memory_bytes: 2772
using System;

namespace ConsoleApp
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var a = int.Parse(ss[0]);
            var b = int.Parse(ss[1]);
            var t = int.Parse(ss[2]);

            Console.WriteLine(t / a * b);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int a,b;
	cin >> a >> b;
	if((a+b)%2) cout << "IMPOSSIBLE" << endl;
	else cout << (a+b)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
// ABC 126 B: YYMM or MMYY
// https://atcoder.jp/contests/abc126/tasks/abc126_b

#include <iostream>
#include <vector>

int main() {
    std::vector<int> sequence(4);
    for (int i=0; i<sequence.size(); i++) {
        char tmp;
        std::cin >> tmp;
        sequence.at(i) = static_cast<int>(tmp-'0');
    }
    int first_part = sequence.at(0)*10 + sequence.at(1);
    int second_part = sequence.at(2)*10 + sequence.at(3);
    if (first_part <= 12 && first_part != 0) {
        if (second_part <= 12 && second_part != 0) {
            std::cout << "AMBIGUOUS" << "\n";
        } else {
            std::cout << "MMYY" << "\n";
        }
    } else {
        if (second_part <= 12 && second_part != 0) {
            std::cout << "YYMM" << "\n";
        } else {
            std::cout << "NA" << "\n";
        }
    }
}

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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = (int)1e9+7;
const int N = (int)1e5 + 7;

vector <int> g[N];
bool vis[N];
int sz;
bool can;
bool val[N];

void dfs(int s)
{
	vis[s] = true;
	sz++;

	for(int i=0;i<g[s].size();i++)
		{
			if(!vis[g[s][i]])
				{	
					val[g[s][i]] = !val[s];	
					dfs(g[s][i]);
				}
			else if(val[s]==val[g[s][i]])
				can = true;		
		}
}

int main()
{
//ios_base::sync_with_stdio(0); 
	cout.precision(15);
	cout.setf(ios::fixed);

	LL n,m;
	int a,b;
	cin >> n >> m;

	for(int i=0;i<m;i++)
		{
			cin >> a >> b;
			a--;b--;
			g[a].PB(b);
			g[b].PB(a);
		}

	LL t1 = 0,t2 = 0,si= 0;	

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

			if(!vis[i])
				{
				sz = 0;
				dfs(i);
				
				if(sz!=1)
				{if(can)	
					t1++;
				else
					t2++;
				}

				if(sz == 1) 
					si++;
				}
		}	

	// cout<<t1<<' '<<t2<<' '<<si<<endl;	

	LL ans = t1*t1 + 2LL*t2*(t1+t2) + si*(2*n-1) - si*(si-1);	

	cout<<ans<<endl;
}



Measured memory_bytes: 9728
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    vector<ll> pay;
    pay.push_back(1);
    for (ll i = 1; pow(6, i) <= N; i++) {
        pay.push_back(pow(6, i));
    }
    for (ll i = 1; pow(9, i) <= N; i++) {
        pay.push_back(pow(9, i));
    }
    sort(pay.begin(), pay.end());
    

    vector<ll> dp(N + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < pay.size(); i++) {
        for (int j = 0; j <= N; j++) {
            if (j + pay[i] <= N) {
                dp[j + pay[i]] = min(dp[j + pay[i]], dp[j] + 1);
            }
        }
    }

    cout << dp[N] << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}


}



Measured memory_bytes: 3652
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 2e5 + 5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    boost
    string s;
    cin >> s;
    if(count(all(s), 'A') && count(all(s), 'B')) cout << "Yes\n";
    else cout << "No\n";
}


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

flag = False
if N % 7 == 0 or N % 4 == 0 or N % 11 == 0:
	print('Yes')

else:
	for i in range(14):
		if flag == True: break
		for j in range(25):
			if i * 7 + j * 4 == N:
				print('Yes')
				flag = True
				break
			elif i * 7 + j * 4 > N:
				break
	if flag == False:	print('No')	

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>

struct ModInt {
    static int MOD;

    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

int ModInt::MOD;
using mint = ModInt;

using lint = long long;

void solve() {
    int n, p;
    std::cin >> n >> p;
    ModInt::MOD = p;

    if (p == 2 || p == 5) {
        lint ans = 0, acc = 1;
        while (n--) {
            char c;
            std::cin >> c;
            if ((c - '0') % p == 0) ans += acc;
            ++acc;
        }
        std::cout << ans << std::endl;
        return;
    }

    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());

    lint ans = 0;
    mint sum = 0;
    std::vector<lint> cnt(p, 0);
    cnt[0] = 1;

    mint ten = 1;
    for (char c : s) {
        mint d = c - '0';
        sum += d * ten;
        ten *= 10;

        ans += cnt[sum.val];
        ++cnt[sum.val];
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<ios>
using namespace std;
int h,m,s;
main()
{
    while(cin>>h>>m>>s,h>=0)
    {
        int a,b,c;
        printf("%02d:%02d:%02d\n",a=2-h-(m||s),b=m||s?60-m-!!s:0,c=s?60-s:0);
        c*=3;
        b=b*3+c/60;c%=60;
        a=a*3+b/60;b%=60;
        printf("%02d:%02d:%02d\n",a,b,c);
    }
}


Measured memory_bytes: 3196
#include <iostream>
#include<cstring>
#include<cmath>
#include<climits>
#define INF 0x3f3f3f3f
using namespace std;

int minCost(int h[],int n,int k){
    int dp[n];
    memset(dp,INF,sizeof(dp));
    dp[0] = 0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k && i-j>=0;j++){
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    return dp[n-1];
}

int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    cout<<minCost(h,n,k);
    return 0;
}

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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 998244353 
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const int K = 1e5 + 5;
bool dp[K];


int32_t main(void)
{
    FASTER;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n, k;
    DI(n, k);
    int d[n];
    F(i, 0, n)
    	SI(d[i]);
    for(int i = 1; i < K; i++)
    {
    	bool ok = false;
    	for(int j = 0; j < n; j++)
    	{
    		if(i - d[j] < 0)
    			break;
    		ok |= !dp[i - d[j]];
    	}
    	dp[i] = ok;
    }
    if(dp[k])
    	SO("First");
   	else
   		SO("Second");
    
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>

int main(){
    int a, b, c;
    scanf("%d%d", &a, &b);
    int mn = -1e9;
    if(mn < a + b) mn = a + b;
    if(mn < a * b) mn = a * b;
    if(mn < a - b) mn = a - b;
    printf("%d\n", mn);
}

Measured memory_bytes: 128
#include <stdio.h>
  #include <math.h>
  int min(int a,int b){
    return a<b ? a:b;
  }
  int max(int a,int b){
    return a>b ? a:b;
  }

  int main() {
    float a,b;
    int c;
    scanf("%f %f",&a,&b);
    c=(int)ceil(a/b);
    printf("%d\n",c);



    return 0;
  }


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<string, int> P;

int N,A,B,C;
ll inf = 1e9;
int l[10];

int dfs(int cur, int a, int b, int c){
	if(cur==N){
		if(a>0&&b>0&&c>0){
			return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		}else{
			return inf;
		}
	}
	int ret0 = dfs(cur + 1, a, b, c);
	int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
	return min(min(min(ret0,ret1),ret2),ret3);
}

int main(){
	cin >> N >> A >> B >> C;
	for(int i=0;i<N;i++) cin >> l[i];
	
	cout << dfs(0,0,0,0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#include<stdlib.h>



int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    while(n>=10){
        n=n%10;
        
    }
    switch(n){
        case 0:printf("pon");return 0;
        case 1:printf("pon");return 0;
        case 2:printf("hon");return 0;
        case 3:printf("bon");return 0;
        case 4:printf("hon");return 0;
        case 5:printf("hon");return 0;
        case 6:printf("pon");return 0;
        case 7:printf("hon");return 0;
        case 8:printf("pon");return 0;
        case 9:printf("hon");return 0;
    }
}

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

int main(void)
{
	char a;
	cin >> a;

	switch(a)
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			cout << "vowel" << endl;
			break;
		default:
			cout << "consonant" << endl;
	}	

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    string s;
    cin >> s;
    int res = 700;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'o') {
            res += 100;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  size_t N, K;
  cin >> N >> K;
  size_t c = 0;
  for(size_t i = 0 ; i < N; ++i){
    size_t Hi;
    cin >> Hi;
    if(K <= Hi) ++c;
  }

  cout << c ;
}

Measured memory_bytes: 256
#include <stdio.h>
int solve(int,int);

int n,q;
int A[20];
int m[200];

int main()
{
  int i,s;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
 
  for(i=0;i<q;i++){
    s=solve(0,m[i]);
    if(s == 1)printf("yes\n");
    if(s == 0)printf("no\n");
  }

  return 0;
}

int solve(int i,int m)
{ 
  if(m == 0)return 1;
 
  if(i >= n)return 0;

  if(solve(i+1,m)==1)return 1;
  if(solve(i+1,m-A[i])==1)return 1;

  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define MOD pow(10,9)+7
#define LLINF pow(2,61)-1
#define INF pow(2,29)-1


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

  ll result = LLINF;
  for (ll i=1; i*i<=N; i++) {
    if (N%i==0) result = min(result, i+N/i);
  }
  cout << result-2 << endl;
  return 0;
}

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

int main(){
    int n,k,s;
    cin>>n>>k>>s;
    for(int i = 0 ; i < k ; i++)
        cout<<s<<' ';
    if(s == 1e9){
        for(int i = 0 ; i < n-k ; i++)
            cout<<s-1<<' ';
    }
    else{
        for(int i = 0 ; i < n-k ; i++)
            cout<<s+1<<' ';
    }
    cout<<'\n';
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,E,K;
  cin >> A >> B >> C >> D >> E >>K;
  if(E-A<=K){
  	cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000

bool is_ok(int n,int *b){

  for(int i=1;i<=n;i++){
    if(b[i-1]!=i) return false;
  }

  return true;
}

void calc(int n){
  int b[SIZE];
  int sumb = 0;

  for(int i=0;i<n;i++){
    scanf("%d",b+i);
    sumb += b[i];
  }
  
  for(int i=1;;i++){
    if(i*(i+1)/2 == sumb) break;
    if(i*(i+1)/2 > sumb){
      puts("-1");
      return;
    }
  }
  
  for(int i=0;;i++){
    if(i > 10000){
      puts("-1");
      return;
    }
    
    if(is_ok(n,b)){
      printf("%d\n",i);
      return;
    }
    
    int t = 0;
    
    for(int j=0;j<n;j++) b[j]--;

    for(int j=0;j<n;j++){
      if(b[j] > 0){
        b[t] = b[j];
        t++;
      }
    }

    b[t] = n;
    n = t+1;
  }

}

int main(){
  int n;
  
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int n;

bool dfs(int v, vvi &G, vi &color,int col = 0){
  color[v] = col;
  rep(nv,n) {
    if(G[v][nv] == 1e9 || v == nv) continue;
    if(color[nv] == -1){
      if(!dfs(nv, G, color, 1-col)) return false;
    }
    else{
      if(color[v] == color[nv]) return false;
    }
  }

  return true;
}

int main(){
  int n; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  vector<string> s2(n);
  int ans = 0;
  rep(a,n) {
    rep(i,n) rep(j,n) {
      s2[i] = s[(i+a)%n];
    }
    bool ok = true;
    for(int i = 0; i < n; i++) {
      for(int j = i+1; j < n; j++) {
        if(s2[i][j] != s2[j][i]) ok = false;
      }
    }
    if(ok) ans += n;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int i,n,a[55],x,y;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(abs(a[i])>=x)
		{
			x=abs(a[i]);
			y=i;
		}
	}
	cout<<2*n-2<<endl;
	for(i=1;i<=n;i++)
		if(i!=y)
		{
			cout<<y<<" "<<i<<endl;
			a[i]+=a[y];
		}
	if(a[y]>0)
	{
		for(i=1;i<n;i++)
			cout<<i<<" "<<i+1<<endl;
	}else
	{
		for(i=n;i>1;i--)
			cout<<i<<" "<<i-1<<endl;
	}
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = [int(x) for x in input().split(" ")]
Amax = max(A)
dp = np.ones(Amax, dtype=bool)
appear = np.zeros(Amax, dtype=int)
for a in A:
  appear[a-1] += 1

for i in range(1, len(dp)+1):
  if not dp[i-1]:
    continue
  if appear[i-1] != 0:
    j = 2
    while j * i <= Amax:
      dp[j * i - 1] = False
      j += 1

count = 0
for a in A:
  if appear[a-1] > 1:
    continue
  else:
    count += dp[a-1]
print(count)


Measured memory_bytes: 51296
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
ll s[105];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=103;i++)
	{
		s[i]=i*i;
	}
	for(int h=1;h<=n;h++)
	{
		ll ans=0;
		int tmp=-1;
		for(int i=1;i<=103;i++)
		{
			if(s[i]<h&&s[i+1]>=h)
			{
				tmp=i+1;
				break;
			}
		}
		for(int i=1;i<tmp;i++)
		{
			for(int j=i;j<tmp;j++)
			{
				for(int k=j;k<tmp;k++)
				{
					if((i*i+j*j+k*k+i*j+i*k+j*k)==h)
					{
						if(i==j&&j==k)
						ans+=1;
						else if((i!=j)&&(j!=k)&&(i!=k))
						ans+=6;
						else
						ans+=3;
					}
				}
			}
		}
	cout<<ans<<endl;
	}
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, i, *r, total_r, temp;
    string s;
    cin >> n >> s;
    r = new ll[n];
    if (s[0] == 'W')
        r[0] = 0;
    else
        r[0] = 1;
    for (i = 1; i < n; i++)
    {
        if (s[i] == 'R')
            r[i] = r[i - 1] + 1;
        else
            r[i] = r[i - 1];
    }
    total_r = r[n - 1];
    for (i = 0, temp = 0; i < total_r; i++)
        if (s[i] == 'R')
            temp++;
    cout << (total_r - temp) << endl;
}

Measured memory_bytes: 5268
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N;
vector<ll> vec;

void solve() {
	ll A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2;
}

int main() {
	solve();
	cout << endl;
	return 0;
}


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

int main() {
  int n, l;
  cin >> n >> l;
  string ans;
  vector<string> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    ans += a[i];
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)

long long N, Q, D, d[700005], q[700005], s[700005], t[700005];
int main() {
	cin >> N >> D;
	for (int i = 1; i <= N; i++)scanf("%lld", &d[i]);
	cin >> Q;
	for (int i = 1; i <= Q; i++)scanf("%lld", &q[i]);
	long long E = D; s[0] = E;
	for (int i = 1; i <= N; i++) {
		E = min(E, abs(E - d[i]));
		s[i] = E;
	}
	for (int i = N; i >= 1; i--) {
		if (d[i] <= 2 * t[i] + 1)t[i - 1] = d[i] + t[i];
		if (d[i] > 2 * t[i] + 1)t[i - 1] = t[i];
	}
	for (int i = 1; i <= Q; i++) {
		if (s[q[i] - 1] <= t[q[i]])printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	char s[60][60];
	cin>>h>>w;
	REP(i, h+2){
		REP(j, w+2) s[i][j]='.';
	}
	REP(i, h){
		REP(j, w) cin>>s[i+1][j+1];
	}
	int dx[8]={0, 1, 0, -1, -1, 1, 1, -1};
	int dy[8]={-1, 0, 1, 0, -1, -1, 1, 1};
	bool ok=true;
	FOR(i, 1, h+1){
		FOR(j, 1, w+1){
			if(s[i][j]=='#'){
				REP(k, 8){
					if(k<=3 && s[i+dx[k]][j+dy[k]]=='#') break;
					else if(k>=4 && s[i+dx[k]][j+dy[k]]=='#'){
						ok=false;
						break;
					}
				}
			}
		}
	}
	ok ? cout<<"Yes"<<'\n' : cout<<"No"<<'\n';
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int cnt1=0, cnt2=0;
  for(int i=0; i<S.size(); i++) {
    if(S.at(i)=='0') {
      cnt1++;
    }
    else {
      cnt2++;
    }
  }
  cout << min(cnt1, cnt2)*2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

const ll mod=1e9+7;
ll n,a[200010],sum,ans;

int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		ans=(ans+a[i]*sum%mod)%mod;
		sum=(sum+a[i])%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5192
module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end

include Memoizable 
def f(w, i, unused)
	return 0 if w < 0
	if i == $hobbits.size
		return w < unused ? 1 : 0
	end
	(f(w - $hobbits[i], i+1, unused) + f(w, i+1, $hobbits[i])) % 1_000_000_007
end

memoize :f

n, w = gets.split.map &:to_i
$hobbits = (1..n).map{ gets.to_i }.sort.reverse

p f(w, 0, Float::INFINITY)

Measured memory_bytes: 151960
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    long ans =0;
    //vector < vector <int > > l(n,vector<int>(2));
    for(int i = 0 ; i < n ; i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        ans += (tmp2 - tmp1) +1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define dist(a,b) max((a)-(b),(b)-(a))
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  vector<li> a(n+2,0); rep(i,n) cin >>a[i+1];
  li s=0;
  rep(i,n+1){
    s+=dist(a[i],a[i+1]);
  }
  rep(_i,n){
    int i=_i+1;
    li d1=dist(a[i],a[i-1])+dist(a[i],a[i+1]);
    li d2=dist(a[i-1],a[i+1]);
    print(s-d1+d2);
  }
}


Measured memory_bytes: 4008
#import<cstdio>
int n,k;
main() {
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j){
            for(k=0;(((i^j)>>k++)&1)==0;);
            printf("%d\n",k);
        }
}

Measured memory_bytes: 384