akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if((a * b) % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
using namespace std;

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

signed main(){
	io();
	int h, a; cin >> h >> a;
	int ans = 0;
	while(h > 0){
		h -= a;
		++ans;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3504
import java.io.*;

class Main{
	public static void main(String[] args){
      
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
  	try{
  			String str = br.readLine();
  			int num = Integer.parseInt(str);
  
  			double p = 3.14;
  
  			System.out.println(2.0*p*num);
       }catch(Exception e){
 	   }
   }
}

Measured memory_bytes: 32952
#include<bits/stdc++.h>
using namespace std;
struct edge {int u, v, w;};
vector<edge>G;
int L;
void add(int u, int v, int w) {G.push_back((edge) {u , v , w});}
int main() {
  cin >> L;
  int t = 1;
  for (int i = 0; i < 21; ++i) if (L & (1 << i)) t = i;
  for (int i = 1; i <= t - 1; i++) add(i, i+1, 1 << i-1), add(i, i+1, 0);
  add(t, 20, 0);
  add(t, 20, 1 << t-1);
  int g = 1 << t;
  while (g < L) {
    t = 1;
    for(int i = 0; i < 21; ++i) if ((1 << i) & (L - g)) t = i;
    add(t+1, 20 , g);
    g |= 1 << t;
  }
  cout << "20 " << G.size() << endl;
  for (auto it = G.begin(); it != G.end(); ++it) cout << it->u << ' ' << it->v << ' ' << it->w << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn];
vector<int> fac[5];
void gf(int a,int num)
{
	fac[num].push_back(1);
	fac[num].push_back(a);
	int i;
	for(i=2;i*i<a;i++)
		if(a%i==0)
		{
			fac[num].push_back(i);
			fac[num].push_back(a/i);
		}
	if(i*i==a)
		fac[num].push_back(1);
	sort(fac[num].begin(),fac[num].end());
}
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//  fl();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	gf(a[1],1);
	gf(a[2],2);
	int ans=-maxn;
	for(int t=1;t<=2;t++)
	{
		for(int i=fac[t].size()-1;i>=0;i--)
		{
			int tmp=fac[t][i],num=0;
			bool sign=true;
			for(int j=1;j<=n;j++)
			{
				if(a[j]%tmp!=0)
					num++;
				if(num>1)
				{
					sign=false;
					break;
				}
			}
			if(sign)
			{
				ans=max(ans,tmp);
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

// @@ !! LIM(UnionFind)
// --> UnionFind
// ---- inserted library file UnionFind.cc

class UnionFind {
protected:
  int size;
  vector<int> _leader;
  vector<int> _rank;
  vector<int> _gsize;
  unordered_map<int, vector<int>> _groups;
  
public:
  UnionFind(int s);
  int leader(int i);
  int merge(int i, int j);
  int groupSize(int i);
  const unordered_map<int, vector<int>>& groups();
  const vector<int>& group(int i);
};

UnionFind::UnionFind(int s) {
  size = s;
  _leader = vector<int>(size);
  for (int i = 0; i < size; i++) { _leader.at(i) = i; }
  _rank = vector<int>(size, 1);
  _gsize = vector<int>(size, 1);
}

int UnionFind::leader(int i) {
  int cur = i;
  int nxt = _leader.at(cur);
  vector<int> seen;
  while (cur != nxt) {
    seen.push_back(cur);
    cur = nxt;
    nxt = _leader.at(cur);
  }
  for (auto j : seen) _leader.at(j) = cur;
  return cur;
}

int UnionFind::merge(int i0, int j0) {
  if (!_groups.empty()) {
    cerr << "merge() cannot be called after group() or groups()." << endl;
    exit(1);
  }
  int li = leader(i0);
  int lj = leader(j0);
  if (li == lj) return li;
  int ri = _rank.at(li);
  int rj = _rank.at(lj);
  int rep = li;
  int other = lj;
  if      (ri <  rj) swap(rep, other);
  else if (ri == rj) _rank.at(rep)++;
  _leader.at(other) = rep;
  _gsize.at(rep) += _gsize.at(other);
  return rep;
}

int UnionFind::groupSize(int i) {
  return _gsize.at(leader(i));
}

const unordered_map<int, vector<int>>& UnionFind::groups() {
  if (_groups.empty()) {
    for (int i = 0; i < size; i++) _groups[leader(i)].push_back(i);
  }
  return _groups;  
}

const vector<int>& UnionFind::group(int i) { return groups().at(leader(i)); }



// ---- end UnionFind.cc
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  UnionFind uf(N);
  for (ll i = 0; i < M; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    uf.merge(a, b);
  }
  ll cnt = 0;
  for (ll i = 0; i < N; i++) {
    if (uf.leader(i) == i) cnt++;
  }
  cout << cnt - 1 << endl;

  return 0;
}



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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cout.precision(10);               \
	cout << fixed;
#define int long long int
#define pb push_back
#define endl "\n"
#define all(a) a.begin(), a.end()
#define N 1009
#define M 1000009
#define mod 1000000007
int powi(int a, int b)
{
	if (b == 0)
		return 1;
	int see = powi(a, b / 2);
	see *= see;
	see %= mod;
	if (b % 2)
		see *= a;
	see %= mod;
	return see;
}

int n, m;
int a, b;
vector<int> v[N];
bool edge[N][N];
vector<pair<int, int>> ed;
int par[N];
bool vis[N];
vector<int> globl;

void pre()
{
	memset(vis, 0, sizeof(vis));
}

int32_t main()
{
	IOS;
	pre();
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		globl.push_back(-1);
	}
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		v[a].push_back(b);
		edge[a][b] = 1;
		ed.push_back({a, b});
		if (edge[b][a] == 1)
		{
			cout << "2\n"
			     << a << endl
			     << b << endl;
			return 0;
		}
	}
	for (auto i : ed)
	{
		// bfs from second
		pre();
		bool cycle = 0;
		queue<int> q;
		q.push(i.second);
		while (!q.empty())
		{
			int tp = q.front();
			vis[tp] = 1;
			for (auto j : v[tp])
			{
				if (vis[j] == 1 && j == i.first)
				{
					while (!q.empty())
						q.pop();
					par[j] = tp;
					break;
				}
				if (vis[j] == 1)
					continue;
				par[j] = tp;
				q.push(j);
			}
			if (q.size() > 0)
				q.pop();
		}
		if (vis[i.first] == 0)
		{
			continue;
		}
		vector<int> ans;
		int temp = i.first;
		while (temp != i.second)
		{
			ans.push_back(temp);
			temp = par[temp];
		}
		ans.push_back(i.second);
		if (ans.size() <= globl.size())
		{
			globl = ans;
		}
	}
	if (globl[0] == -1)
	{
		cout << "-1\n";
		return 0;
	}
	cout << globl.size() << endl;
	for (auto i : globl)
	{
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int gcd(int a, int b){
    while(b != 0){
        int tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

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

    vector<int> v(n+1, 0);
    for(int i=0; i<n; ++i)
        v[i+1] = gcd(v[i], a[i]);

    int tmp = 0;
    int ans = 0;
    for(int i=n-1; i>=0; --i){
        ans = max(ans, gcd(v[i], tmp));
        tmp = gcd(tmp, a[i]);
    }
    cout << ans << endl;

    return 0;
}


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

int sort(const void *a,const void *b){return *(long long*)a>*(long long*)b?1:0;}

int main(void){
    long long n,a[50000],count=3;
    scanf("%lld",&n);
    a[0]=3;
    a[1]=5;
    a[2]=7;
    for (int i=0; i<50000; i++){
        for (int j=3; j<=7; j+=2){
            a[count]=a[i]*10+j;
            count++;
            if (a[count-1]>999999999){
                break;
            }
        }
        if (a[count-1]>999999999){
            break;
        }
    }
    for (int i=0; i<count; i++){
        long long t=a[i],h3=0,h5=0,h7=0;
        if (t<100){
            a[i]=3333333333;
        } else {
            while(t!=0){
                if (t%10==3){
                    h3=1;
                }
                if (t%10==5){
                    h5=1;
                }
                if (t%10==7){
                    h7=1;
                }
                t/=10;
            }
            if (h3==0 || h5==0 || h7==0){
                a[i]=3333333333;
            }
        }
    }
    qsort (a,count,sizeof(long long),sort);
    for (int i=0; i<count; i++){
        if (a[i]>n){
            printf("%d\n",i);
            break;
        }
    }
    
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

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


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

void work()
{
    LL n, m;
    cin >>n >>m;
    if(n == 1 || m == 1) cout <<1 <<endl;
    else cout <<(n * m + 1) / 2 <<endl;
}

int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

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

    vector<pair<long long, long long>> list;
    for (long long i = 2; i * i <= N; i++) {
        long long cnt = 0;
        while (N % i == 0) {
            N /= i;
            ++cnt;
        }
        list.push_back({i, cnt});
        // cout << "i, cnt, N = " << i << ", " << cnt << ", " << N << endl;
    }
    //  cout << "last: " << N << endl;
    if (N != 1) {
        list.push_back({N, 1});
    }

    long long ans = 0;
    for (auto p : list) {
        long long cnt = p.second;
        for (long long i = 1; i <= cnt; ++i) {
            cnt -= i;
            ++ans;
            // cout << p.first << ", " << i << endl;
        }
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int tax8,tax10;

    for(int i=1; i<=10000; i++){
        tax8=i*0.08;
        tax10=i*0.1;
        if(a==tax8 && b==tax10){
            cout << i << endl;
            break;
        }
        if(i==10000) cout << -1 << endl;
    }
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
thr = q - k
scores = [0] * n
for i in range(q):
    ai = int(input())
    scores[ai - 1] += 1

for score in scores:
    result = 'Yes' if score > thr else 'No'
    print(result)


Measured memory_bytes: 4680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long double g[3001][3001]={0.0};
long double v[3001];
ll n;
void solve()
{
    //memset(g,0,sizeof(g));
    g[1][0]=1.0-v[0];
    for(ll j=2;j<=n;j++)
    {
        g[j][0]=g[j-1][0]*(1.0-v[j-1]);
    }
    g[1][1]=v[0];
    for(ll i=2;i<=n;i++)
    {
        g[i][i]=g[i-1][i-1]*v[i-1];
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<i;j++)
        {
            g[i][j]=g[i-1][j]*(1.0-v[i-1])+g[i-1][j-1]*(v[i-1]);
        }
    }
    long double sum=0.0;
    for(ll i=n/2+1;i<=n;i++)
    {
        sum=sum+g[n][i];
    }
    cout<<fixed<<setprecision(10)<<sum;
}
int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    solve();
}


Measured memory_bytes: 85496
from collections import deque

N,X,Y=map(int,input().split())
ans=[0]*(N+1)

for i in range(1,N+1):
    que=deque([(i,0)])
    used=[False]*(N+1)
    used[i]=True
    while que:
        v,dist=que.popleft()
        ans[dist]+=1
        if v!=1 and not used[v-1]:
            que.append((v-1,dist+1))
            used[v-1]=True
        if v!=N and not used[v+1]:
            que.append((v+1,dist+1))
            used[v+1]=True
        if v==X and not used[Y]:
            que.append((Y,dist+1))
            used[Y]=True
        if v==Y and not used[X]:
            que.append((X,dist+1))
            used[X]=True

for i in range(1,N):
    print(ans[i]//2)


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

const int maxn = 105, maxw = 1e5+5;
int N, W;
int weight[maxn], val[maxn];

ll dp[maxn][maxw];
ll f(int i, int w) {
    if (w > W) return -999999999;
    if (i == N) return dp[i][w] = 0;
    if (dp[i][w] != -1) return dp[i][w];
    return dp[i][w] = max(f(i+1,w),val[i] + f(i+1,w+weight[i]));    
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> weight[i] >> val[i];
    }
    memset(dp,-1,sizeof dp);
    ll ans = f(0,0);
    cout << ans << '\n'; 

    return 0;
}



Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    if(N==0)
    {
        cout<<0;
        return 0;
    }
    string S;
    while (N != 0)
    {

        int a = abs(N % 2);
        S = S + (to_string(a));
        N -= a;
        N /= (-2);
    }
    reverse(all(S));
    cout << S;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
#include <random>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i > M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;

typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}
template<class T>
T POW(T n, T m) {
	T res = 1;
	rep(i, 0, m) {
		res *= n;
	}
	return res;
}

ll power(ll x, ll y, ll mod) {
	if (y == 0)return 1;
	if (y == 1)return x % mod;
	if (y == 1)return x % mod;
	if (y % 2 == 0)return POW(power(x, y / 2, mod), 2LL) % mod;
	return ((POW(power(x, y / 2, mod), 2LL) % mod)*(x%mod)) % mod;
}
ll div(ll a, ll  b, ll mod) {
	return (a* power(b, mod - 2, mod)) % mod;
}

template<
	typename Inputs,
	typename Functor,
	typename T = typename Inputs::value_type>
	void sort_by(Inputs& inputs, Functor f) {
	std::sort(std::begin(inputs), std::end(inputs),
		[&f](const T& lhs, const T& rhs) { return f(lhs) < f(rhs); });
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;

ll MOD_NUM = POW(10LL, 9LL) + 7;




int main() {
	ll N;
	cin >> N;
	vll x(N), y(N), h(N);
	rep(i, 0, N)cin >> x[i] >> y[i] >> h[i];

	vll X, Y, Z;
	rep(i, 0, 101) {
		rep(j, 0, 101) {
			bool flg = true;
			ll H = -1;
			rep(k, 0, N) {
				if (h[k] > 0) {
					if (H == -1) H = h[k] + abs(x[k] - i) + abs(y[k] - j);
					else {
						if (H != h[k] + abs(x[k] - i) + abs(y[k] - j)) {
							flg = false;
						}
					}
				}

			}
			if (flg) {
				X.push_back(i);
				Y.push_back(j);
				Z.push_back(H);


			}
		}
	}
	
	rep(i, 0, X.size()) {
		bool flg = true;
		rep(k, 0, N) {
			if ( h[k]!=max(Z[i] -abs(x[k]- X[i]) - abs(y[k] - Y[i]),0LL)) {
				flg = false;
			}
		}
		if(flg) cout << X[i] << " " << Y[i] << " " << Z[i];
	}

	return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    char A[105];
    int mp[26];
    bool vis[26];
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        memset(A,'\0',sizeof(A));
        memset(mp,0,sizeof(mp));
        memset(vis,false,sizeof(vis));
        scanf("%s",A);
        int Max = 0;
        for(int i=0;A[i]!='\0';i++)
        {
            int sum = 0;
            memset(vis,false,sizeof(vis));
            if(mp[A[i]-97] == 0) mp[A[i]-97]++;
            for(int j=i+1;A[j]!='\0';j++)
            {
                if(mp[A[j]-97] && !vis[A[j]-97])
                {
                    vis[A[j]-97] = true;
                    sum ++;
                }
            }
            Max = max(Max,sum);
        }
        printf("%d\n",Max);
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
answer = 'Yes'
if S != S[::-1]:
    answer = 'No'
first = S[:len(S) // 2]
last = S[len(S) // 2 + 1:]
if first != first[::-1]:
    answer = 'No'
if last != last[::-1]:
    answer = 'No'
print(answer)

Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,p,sum=0;
    cin>>n>>k;
    while(n--)
    {
        cin>>x;
        if(x<(k-x))
            p=x;
        else
            p=k-x;
        sum=sum+2*(p);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve(){
    int n; cin>>n;
    int s = 100, cnt=0;
    while(s<n) {
        cnt++;
        s = s+ (s/100);
    }
    cout<<cnt;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 3652
import math
l, r = map(int, input().split(' '))

R = min(l+2018, r)
min_x = 2018

for i in range(l, R+1):
    for j in range(i+1, R+1):

        x = (i*j) % 2019
        if x < min_x:
            min_x = x
print(min_x)


Measured memory_bytes: 2940
n = int(input())
*w, = map(int,input().split())
l = []
for i in range(n):
  a = sum(w[:i])
  #print(a)
  b = sum(w[i:])
  #print(b)
  ans = abs(a-b)
  l.append(ans)
print(min(l))


Measured memory_bytes: 2940
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int h;
    int w;
    int num_move=0;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    vector<pair<int, int>> xy_start;
    vector<pair<int, int>> xy_end;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<h; i++){
        if(i%2==0){
            for(int j=0; j<w; j++){
                if(a[i][j]%2!=0){
                    if(j<w-1){
                        a[i][j]--;
                        a[i][j+1]++;
                        xy_start.push_back(make_pair(i, j));
                        xy_end.push_back(make_pair(i, j+1));
                        num_move++;
                    }else if(i<h-1){
                        a[i][j]--;
                        a[i+1][j]++;
                        xy_start.push_back(make_pair(i, j));
                        xy_end.push_back(make_pair(i+1, j));
                        num_move++;
                    }
                }
            }
        }else{
            for(int j=w-1; j>=0; j--){
                if(a[i][j]%2!=0){
                    if(j>0){
                        a[i][j]--;
                        a[i][j-1]++;
                        xy_start.push_back(make_pair(i, j));
                        xy_end.push_back(make_pair(i, j-1));
                        num_move++;
                    }else if(i<h-1){
                        a[i][j]--;
                        a[i+1][j]++;
                        xy_start.push_back(make_pair(i, j));
                        xy_end.push_back(make_pair(i+1, j));
                        num_move++;
                    }
                }
            }
        }
    }

    cout << num_move << endl;
    for(int i=0; i<num_move; i++){
        cout << xy_start[i].first+1 << " " << xy_start[i].second+1 << " " << xy_end[i].first+1 << " " << xy_end[i].second+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5228
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int a[1010101], b[1010101];
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	ll ans = 0;
	int nx = 0, ny = 0;
	for (int i = 0; i < mx; i++)
	{
		int z;
		scanf("%d", &z);
		a[z]++;
		if (a[z] >= 2)goto l01;
	}
	for (int i = 0; i < my; i++)
	{
		int z;
		scanf("%d", &z);
		b[z]++;
		if (b[z] >= 2)goto l01;
	}
	ans = 1;
	for (int i = mx*my; i >= 1; i--)
	{
		if (a[i] == 1 && b[i] == 1)nx++, ny++;
		else if (a[i] == 1)ans = ans*ny%mod, nx++;
		else if (b[i] == 1)ans = ans*nx%mod, ny++;
		else ans = ans*max(0, nx*ny - (mx*my - i)) % mod;
	}
l01:;
	printf("%lld\n", ans);
}

Measured memory_bytes: 4224
#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

int main(){
	for(int n,m,l;scanf("%d%d%d",&n,&m,&l),n;){
		int s=0,g=n-1;

		static int dis[100][100],cost[100][100];
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)	dis[i][j]=(i==j?0:-1);
		for(int i=0;i<m;i++){
			int a,b,d,e;	scanf("%d%d%d%d",&a,&b,&d,&e);
			a--,b--;
			dis[a][b]=dis[b][a]=d;
			cost[a][b]=cost[b][a]=e;
		}

		static int cmin[100][101];
		static bool visited[100][101];
		for(int i=0;i<n;i++)for(int j=0;j<=l;j++){
			cmin[i][j]=1<<30;
			visited[i][j]=false;
		}

		int ans;
		priority_queue< pair<int,pii> > pq;	pq.push(mp(0,mp(s,l)));
		while(!pq.empty()){
			pair<int,pii> a=pq.top();	pq.pop();
			int nowcost=-a.first,u=a.second.first,bud=a.second.second;
			if(u==g){ ans=nowcost; break; }
			if(visited[u][bud])	continue;
			visited[u][bud]=true;

			for(int v=0;v<n;v++){
				if(~dis[u][v]){
					int nextcost=nowcost+cost[u][v];
					int nextbud=bud;
					if(!visited[v][nextbud]){
						if(nextcost<cmin[v][nextbud]){
							pq.push(mp(-nextcost,mp(v,nextbud)));
							cmin[v][nextbud]=nextcost;
						}
					}

					nextcost=nowcost;
					nextbud=bud-dis[u][v];
					if(nextbud>=0 && !visited[v][nextbud]){
						if(nextcost<cmin[v][nextbud]){
							pq.push(mp(-nextcost,mp(v,nextbud)));
							cmin[v][nextbud]=nextcost;
						}
					}
				}
			}
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1084
N = gets.chomp.to_i
X = gets.chomp.split(" ").map(&:to_i)

def calc(p)
  X.map {|v| (v - p)**2 }.inject(&:+)
end

ans = Float::INFINITY
1.upto(100) do |p|
  c = calc(p)
  ans = c if c < ans
end
puts ans


Measured memory_bytes: 1916
s = input()

n_b = 0
for i in range(len(s)):
    if s[i] == 'B':
        n_b += 1

ans = 0
j = 0
for i in range(len(s)):
    if s[i] == 'B':
        j += 1
        ans += (len(s) - j) - i

print(ans)


Measured memory_bytes: 3500
N, M = map(int,input().split())
ans = list("x"*N)
for i in range(M):
    s,c = map(int,input().split())
    if ans[s-1] == str(c) or ans[s-1] == "x":
        ans[s-1] = str(c)
    else:
        print(-1)
        exit()
if ans[0] == "0" and N > 1:
    print(-1)
    exit()
if ans[0] == "x" and N > 1:
    ans[0] = "1"
for i in range(N):
    if ans[i] == "x":
        ans[i] = "0"
print("".join(ans))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    string input;
    char before;
    bool isBad = false;

    cin >> input;
    if(input[0] == input[1]){
        isBad = true;
    }
    if(input[1] == input[2]){
        isBad = true;
    }
    if(input[2] == input[3]){
        isBad = true;
    }

    string msg;
    msg = isBad ? "Bad" : "Good";
    cout << msg << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	unsigned long long a,b,c,d,maxx=1230,minn=0,m,n;
	while (cin>>a>>b){
		m=a;
		n=b;
		if (a>b){
			while(1){
				maxx=a%b;
				a=b;
				b=maxx;
				if (maxx==0){
					maxx=a;
					break;
				}
				
			}
		}
		else {
			while(1){
				maxx=b%a;
				b=a;
				a=maxx;
				if (maxx==0){
					maxx=b;
					break;
				}
			}
		}
		a=m;
		b=n;
		cout<<maxx<<" "<<a*b/maxx<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int best = 0, tam = 0;
  for(auto i : s){
    if(i == 'A' || i == 'C' || i == 'G' || i == 'T') tam++;
    else tam = 0;
    best = max(best, tam);
  }
  cout << best << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n%2==0)	printf("0.5000000000");
	else{
		double tmp=n,tmp2=(int)n/2+1;
		double ans=tmp2/tmp;
		printf("%.8lf",ans);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())

d = []

for _ in range(n):
    d1, d2 = map(int, input().split())
    
    d.append((d1, d2))
    
# # print(d)


for i in range(n-3+1):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print('Yes')
        break
        
else:
    print('No')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MX=60;
const ll mod=1000000007;
ll n,dp[MX][4];
string s[2];
ll DP(ll x,ll y){
    if(x==n)return 1;
    ll &ret=dp[x][y];if(ret!=-1)return ret;
    ret=0;
    if(y==0){
        if(s[0][x]==s[1][x]){
            return ret=(3*DP(x+1,1))%mod;
        }
        else{
            return ret=(6*DP(x+1,2))%mod;
        }
    }
    if(y==1){
        if(s[0][x]==s[1][x])return ret=(2*DP(x+1,1))%mod;
        if(s[0][x]!=s[1][x])return ret=(2*DP(x+1,2))%mod;
    }
    if(y==2){
        if(s[0][x]==s[0][x-1])return ret=DP(x+1,y)%mod;
        if(s[0][x]!=s[1][x])return ret=(3*DP(x+1,2))%mod;
        return ret=DP(x+1,1)%mod;
    }
}
int main(){
    cin>>n;
    cin>>s[0]>>s[1];
    memset(dp,-1,sizeof(dp));
    cout<<DP(0,0)%mod<<endl;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
ans=n*n
if(k!=0)
  cnt=0
  (k+1).upto(n) do |b|
    cnt+=(n+1)/b*(b-k)+ [0,(n+1)%b-k].max
  end
  ans=cnt
end
puts ans

Measured memory_bytes: 1788
class Solution:
    def solve(self, N: int, X: int, L) -> str:

        count = 1
        distance = 0

        for l in L:
            distance += l
            if distance > X:
                break

            count += 1

        return count


if __name__ == '__main__':

    # standard input
    N, X = map(int, input().split())
    L = list(map(int, input().split()))

    # solve
    solution = Solution()
    print(solution.solve(N, X, L))


Measured memory_bytes: 3060
#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 int MOD = 1e9+7;
const double EPS = 1.0e-10;
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() {
	deque<char> s;
	string str;
	cin >> str;
	rep(i,str.size()) s.push_back(str[i]);
	int q,rev = 0;
	cin >> q;
	for(int i = 0; i < q; i++){
		int t;
		cin >> t;
		if(t==1){
			rev = (rev+1)%2;
		}else{
			int f; char c;
			cin >> f >> c;
			if(!rev){
				if(f==1) s.push_front(c);
				else s.push_back(c);
			}else{
				if(f==1) s.push_back(c);
				else s.push_front(c);
			}
		}
	}

	while(s.size()){
		if(!rev){
			cout << s.front();
			s.pop_front();
		}else{
			cout << s.back();
			s.pop_back();
		}
	}
	cout << endl;
	return 0;
}

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

A, B = min(A, B), max(A, B)
d = B - A
if d % 2 == 0:
    print(d // 2)
else:
    if (A - 1 <= N - B):
        A, B = A - 1, B - 1
    else:
        A, B = N - B, N - A
    ans = min(B, A + 1 + (B - A - 1) // 2)
    print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<math.h>
#include<stack>
#include<sstream>
#include <typeinfo>
#include<sstream>
using namespace std;


int main(){
	stack<string>ope;
	string n;
	int answer=0;
	string mo;

	while(cin>>n){
		if(n=="+"||n=="*"||n=="-"){
			string a=ope.top();
			ope.pop();
			string b=ope.top();
			ope.pop();
			int x=0,y=0;
			stringstream ss;
			ss<<a;
			ss>>x;
			ss.str("");
			ss.clear(std::stringstream::goodbit);
			ss<<b;
			ss>>y;
			if(n=="+"){
				answer=x+y;
			}
			else if(n=="-"){
				answer=y-x;
			}
			else if(n=="*"){
				answer=x*y;
			}
			stringstream s1;
			s1<<answer;
			ope.push(s1.str());
		}
		else ope.push(n);
	}
		cout<<ope.top()<<endl;


	return 0;
}

Measured memory_bytes: 1240
//                                ** ALLAH **
//                        who is Hussain? -> whoishussain.org

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1000000007;
inline int in(){ int x; scanf("%d",&x); return x; }
int n, c[26], d[26];
string s[100], ans;;
int32_t main(){
        for(int i = 0; i < 26; i++) c[i] = mod;
        cin >> n;
        for(int i = 0;i < n;i ++) {cin >> s[i]; 
                for(int j = 0; j < 26; j++) d[j] = 0;
                for(int j = 0;j < s[i].size();j ++) d[s[i][j]-'a']++;
                for(int j = 0;j < 26; j++) c[j] = min(c[j], d[j]);
        }

        for(int i = 0; i < 26;i ++){
               if( c[i] == mod ) continue;
               else { for(int j = 0;j < c[i]; j++) ans += 'a' + i;
               }
        }
        cout << ans << '\n';
}


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

int n,m,x;

void master(int i,int nedan,vector<int> rikaido,vector<vector<int>> &hon,vector<int> &value,vector<int> &result){
    if(i==n){
        for(int rikai:rikaido){
            if(rikai<x){
                return;
            }
        }
        result.push_back(nedan);
        return;
    }
    master(i+1,nedan,rikaido,hon,value,result);//買わない
    for(int j=0;j<m;j++){
        rikaido.at(j) += hon.at(i).at(j);
    }
    master(i+1,nedan+value.at(i),rikaido,hon,value,result);//買う
}

int main(){
    cin >> n >> m >> x;
    vector<vector<int>> hon(n,vector<int>(m));
    vector<int> value(n);
    for(int i=0;i<n;i++){
        cin >> value.at(i);
        for(int j=0;j<m;j++){
            cin >> hon.at(i).at(j);
        }
    }
    vector<int> result;
    vector<int> rikaido(m);
    master(0,0,rikaido,hon,value,result);
    if(result.size()==0){
        cout << -1 << endl;
    }else{
        cout << *min_element(result.begin(),result.end()) << endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans=1e9;
    int tmp;
    for(int i=0;i<S.length()-2;i++){
        tmp=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        ans=min(ans,abs(tmp-753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	boolean eo = false;
      	
      	for(int i = 1; i <= 9&& !eo;i++){
          if(n%i==0 && n/i <= 9) eo = true;
        }
 		
      	if(eo) System.out.println("Yes");
      	else System.out.println("No");
        
	}
}


Measured memory_bytes: 35588
import collections

n = int(input())
dd = list(map(int, input().split()))
m = int(input())
tt = list(map(int, input().split()))
cd = collections.Counter(dd)
ct = collections.Counter(tt)

if m > n:
  print('NO')
  exit()
        
for t in ct: 
  if ct[t] <= cd[t]:
    continue
  else:
    print('NO')
    exit()
print('YES')


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[100005];

int main() {
  fill_n(dp, 100005, 9999999999LL);

  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> h_list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    h_list[i] = v;
  }

  dp[0] = 0;
  for (ll i = 0; i < N; i++) {
    for (ll k = 1; k <= K; k++) {
      ll next = i + k;
      if (next < N) {
        dp[next] = min(dp[next], dp[i] + abs(h_list[i] - h_list[next]));
      }
    }
  }

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


Measured memory_bytes: 1792
/*
 * atcoder/abc148/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
vector<int> A;
void solve() {
  cin >> N;
  A.resize(N);
  loop(n,0,N) cin >> A[n];

  int count = 0;
  int cur = 1;
  for (auto&& a: A) {
    if (cur == a) cur++;
    else count++;
  }
  if (count == N) cout << -1 << endl;
  else cout << count << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(int argc, char const *argv[])
{
  int m, d; cin >> m >> d;
  int c = 0;
  rep(i,m) {
    rep(j,8) {
      int d1=j+2;
      if((i+1)%d1==0) {
        int d10 = (i+1)/d1;
        if(d10<10 && d10 >= 2 && d10 * 10 + d1 <= d){
          ++c;
        } 
      }
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long n;
	scanf("%lld",&n);
	for(long long i=sqrt(n);i>=1;i--)
	{
		if(n%i)continue;
		printf("%lld",i+n/i-2);return 0;
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; ++i){
        cin >> as[i];
    }
    bool first=true;
    for(int i=n-1; i>=0; i-=2){
        if(first){
            first=false;
        } else{
            cout << " ";
        }
        cout << as[i];
    }
    for(int i=n%2; i<n; i+=2){
        if(first){
            first=false;
        } else{
            cout << " ";
        }
        cout << as[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3072
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    unordered_map<int, int> mp;
    for(auto &x : v){
        cin >> x;
    }
    sort(ALL(v));
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int x = v[i] + v[j];
            int pos = lower_bound(ALL(v), x) - v.begin();
            // debug(i, j, pos);
            if(pos > j)
                ans += pos - j - 1;
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
arr=Array.new(50).map{Array.new(100,"#")}
arr2=Array.new(50).map{Array.new(100,".")}

arr=arr+arr2

a,b=gets.split
a=a.to_i
b=b.to_i

i=0
(a-1).times{
    aa=i/50
    bb=i%50
    
    arr[aa*2][bb*2]="."
   
   
   i+=1 
}

j=0

(b-1).times{
    aa=j/50
    bb=j%50
    
 
    arr[aa*2+55][bb*2]="#"
    
   
   
   j+=1 
}
puts "100 100"

i=0
100.times{
  puts arr[i].join
   i+=1 
}




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

using namespace std;
#define long long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n;
long f[N][2], ok[N]; //0_black, 1_white
vector<int> g[N], leaf;

void Dfs(int k)
{
    ok[k] = 1;
    f[k][0] = f[k][1] = 1;
    for (int node : g[k]) if (!ok[node]) {
        ok[node] = 1; Dfs(node);
        (f[k][0] *= (f[node][0] + f[node][1])) %= MOD;
        (f[k][1] *= f[node][0]) %= MOD;
    }
}

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1, x, y; i < n; ++i) cin >> x >> y, g[x].push_back(y), g[y].push_back(x);
    Dfs(1);
    cout << (f[1][0] + f[1][1]) % MOD;

    return 0;
}


Measured memory_bytes: 12288
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N, K;
    cin >> N >> K;

    map<int, int> mp;
    int A[N];
    int bucket[N]= {0};    
    for(int i = 0; i < N; i++)
        cin >> A[i];

    for(int i = 0; i < N; i++)
    {
        bucket[A[i]]++;
    }
    
    sort(bucket, bucket + N, greater<int>());

    int sum = 0;
    for(int i = 0; i < K; i++)
    {
        sum += bucket[i];
    }

    cout << N - sum << endl;

    return 0;
}


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

using namespace std;

int solve(const string& s)
{
    int N = s.size(), L = 0, ans = 0;
    const string t { "ACTG" };
    const set<char> valid(t.begin(), t.end());

    while (L < N)
    {
        if (valid.count(s[L]) == 0)
        {
            L++;
            continue;
        }
            
        auto R = L + 1;

        while (R < N and valid.count(s[R]))
            ++R;

        ans = max(ans, R - L);
        L = R;
    }

    return ans;
}

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

    string s;
    cin >> s;

    auto ans = solve(s);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
def main():
    A, B = [int(x) for x in input().split()]
    for num in range(1, 10001):
        if int(num * 0.08) == A and int(num * 0.1) == B:
            print(num)
            return
        elif int(num * 0.08) > A and int(num * 0.1) > B:
            break
    
    print(-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
//Only the Creator has given me strength!

#include<cstdio>

#include<sstream>

#include<cstdlib>

#include<cctype>

#include<cmath>

#include<algorithm>

#include<set>

#include<queue>

#include<stack>

#include<list>

#include<iostream>

#include<fstream>

#include<numeric>

#include<string>

#include<vector>

#include<cstring>

#include<map>

#include<iterator>

#include<bitset>

typedef long long ll;

#define pi 3.1415926535897931159979635

#define pb push_back

#define vctr vector < int >

#define vvtr vector < vctr >

using namespace std;

ll mod=1e7+7;

void fastio() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int main() {

    fastio();

    int n,ans=0;

    cin>>n;

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

    ans+=(n-1)/i;

    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 3196
import fractions
import math

N,M = map(int,input().split())
A = list(map(int,input().split()))
A = [ a//2 for a in A ]

flg = True
times = None
for i,a in enumerate(A):
  t = 0
  while a%2==0:
    a //= 2
    t += 1

  if times is None:
    times = t
  else:
    if times != t:
      flg = False
      break
  A[i] = a
M >>= times

if not flg:
  print(0)
  exit()

lcm = 1
for i in range(N):
  lcm = lcm * A[i] // fractions.gcd(lcm, A[i])
  if lcm > M:
    print(0)
    exit()

print(math.ceil((M // lcm)/2))

Measured memory_bytes: 96248
import itertools

n = int(input())
persons = list(itertools.product([0, 1], repeat=n))
testimony = [[] for _ in range(n)]


for i in range(n):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**n):
    flag = 0
    for j in range(n):
        if (i>>j)&1 == 1:
            for x, y in testimony[j]:
                if (i>>x)&1 != y:
                    flag = 1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[1:].count('1'))
print(honest)

Measured memory_bytes: 9204
A,B = map(int, input().split())

PB =[A, B]

L_PB = max(PB)
S_PB = min(PB)

coin1 = L_PB

L_PB -= 1

if S_PB <= L_PB:
    coin2 = L_PB

else:
    coin2 = S_PB

print(coin1 + coin2)


Measured memory_bytes: 9148
#include<stdio.h>
#include<stdint.h>
#include<string.h>
#include<math.h>
int main(){
  int i,j,k,N,s[26],t[26],l;
  char c[50];
  int8_t *p;
  for(j=0;j<26;++j)s[j]=10000;
  
  scanf("%d\n",&N);
  //  printf("%d\n",N);
  for(i=N;i;--i){
    p=c;
    gets(c);
    //    puts(c);
    l=strlen(c);
    for(j=0;j<26;++j)t[j]=0;
    for(j=0;j<l;++j){
      ++t[*p++-97];
    }
    //    for(j=0;j<26;++j)printf("%d",t[j]);
    //    puts("");

    for(j=0;j<26;++j){
      //      if(t[j])if(s[j]>t[j])s[j]=t[j];
      //if(!t[j])t[j]=10000;
      if(s[j]>t[j])s[j]=t[j];
    }
    //    for(i=0;i<26;++i)
    //printf("%d %d\n",i+97,s[i]);

    //    puts("");
  }
  //  puts("");
  //  for(j=0;j<26;++j)printf("%d",t[j]);
      
  for(i=0;i<26;++i)
    if(s[i]!=0)
      for(j=0;j<s[i];++j)printf("%c",i+97);
  return 0;
}
    
   
     

Measured memory_bytes: 128
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e5;

int main()
{
  FastIO();
  int tc, ca = 0;
  int n;
  cin >> n;
  map <string, int> m;
  for (int i = 0;i < n;i++){
    string s;
    cin >> s;
    m[s]++;
  }
  cout << m.size() << '\n';
  return 0;
}


Measured memory_bytes: 19284