akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long long a[N];
map<long long,int>ma;
int n,b[N],vi[N],si[N],fa[N];
bool com(int x,int y){
	return a[x]>a[y];
}
int now,v[N],nex[N],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
long long dfs(int x,int deep){
	long long ans=deep;
	for(int i=head[x];i;i=nex[i])
		ans+=dfs(v[i],deep+1);
	return ans;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		ma[a[i]]=b[i]=i;
	}
	sort(b+1,b+n+1,com),vi[0]=1;
	for(int i=1;i<=n;i++)	si[i]=1;
	for(int i=1;i<n;i++){
		int k=ma[a[b[i]]-n+si[b[i]]*2];
		fa[b[i]]=k,si[k]+=si[b[i]],vi[b[i]]=1;
		if(vi[k]){
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<n;i++)
		addedges(fa[b[i]],b[i]);
	if(dfs(b[n],0)!=a[b[n]]){
		puts("-1");
		return 0;
	}
	for(int i=1;i<n;i++)
		printf("%d %d\n",b[i],fa[b[i]]);
	return 0;
}


Measured memory_bytes: 12672
#include <stdio.h>
#include <string.h>

int main(){
  char N[200001];
  scanf("%s", N); // scanf("%d", &N);
  int S = 0;
  
  int k = 0; 
  
  int L = strlen(N); //N の中に入っっている文字の個数
  
  while(k < L){
    S = S + N[k] - '0';
  	k++; //k = + 1; と同じ
  }
  
  if(S % 9 == 0) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
#define lint long long

int main(){
    int N, M;
    cin >> N;
    
    map<string, int> blue, red;
    
    for(int i = 0; i < N; ++i){
        string temp;
        cin >> temp;
        ++blue[temp];
    }
    
    cin >> M;
    
    for(int i = 0; i < M; ++i){
        string temp;
        cin >> temp;
        ++red[temp];
    }
    
    int ans = 0;
    
    for(auto e: blue){
        ans = max(ans, (e.second - red[e.first]));
    }
    
    cout << ans << endl;
}


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

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((a+b)<(c+d)){
    cout<<"Right";
  }else if((a+b)>(c+d)){
    cout<<"Left";
  }else{
   cout<<"Balanced";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 n, a, b;
    cin >> n >> a >> b;
    int64 ans = min(b - 1, n - a);
    if ((b - a) % 2 == 0) {
        ans = min(ans, (b - a) / 2);
    }
    else {
        ans = min(ans, (a - 1) + (b - a + 1) / 2);
        ans = min(ans, (n - b) + (b - a + 1) / 2);
    }
    cout << ans;
    
}

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

int main(){
	long long int q,h,s,d;
	cin>>q>>h>>s>>d;
	long long int n;
	cin>>n;
	
	long long int a,b,c,e;
	a=q*4*n;
	b=h*2*n;
	c=s*n;
	if(n%2==0){
		e=d*(n/2);
	}else{
		long long int n2=n/2+1;
		e=min((n2-1)*d+4*q,min((n2-1)*d+2*h,(n2-1)*d+s));
	}
	
	long long int ans=min(a,min(b,min(c,e)));
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int a,b;
 cin>>a>>b;
 if(b%a==0) cout<<a+b;
 else cout<<b-a;
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3592
main = do
    n <- readLn :: IO Int
    let h = n `div` 3600
    let m = (n - h * 3600) `div` 60
    let s = (n - h * 3600 - m * 60)
    putStrLn $ (show h) ++ ":" ++ (show m) ++ ":" ++ (show s)

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll k;
	cin >> k;

	vector<vector<ll>> memo(k+1, vector<ll>(k+1));
	rep(i,k){
		rep(j,k){
			memo[i+1][j+1] = gcd(i+1,j+1);
		}
	}

	ll res = 0;
	rep(i,k) rep(j,k) {
		ll tmp = gcd(i+1,j+1);
		rep(l,k){
		res += memo[tmp][l+1];
		}
	}

	cout << res << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 3920
#include <iostream>
#include <stack>

using namespace std;

#define MAX 110
int num;
int matrix[MAX][MAX];
int dst[MAX];
int counter = 0;
int D[MAX];
int F[MAX];

void input(){
    cin >> num;
    for(int i=0;i<MAX;i++){
        dst[i] = -1;
        for(int j=0;j<MAX;j++){
            matrix[i][j] = 0;
        }
    }
    for(int i=1;i<=num;i++){
        int v; cin >> v;
        int tmp; cin >>tmp;
        for(int j=0;j<tmp;j++){
            int vi; cin >> vi;
            matrix[v-1][vi-1] = 1;
        }
    }
}

void dfs(int cur){
    counter++;
    D[cur] = counter;
    for(int i=0; i< num;i++){
        if(matrix[cur][i] == 1 && D[i]== 0)
            dfs(i);
    }
    counter++;
    F[cur] = counter;
    return;
}

int check(){
    for(int i=0;i<num;i++){
        if(D[i]==0)
            return i;
    }
    return -1;
}

int main(){
    input();
    for(int i=0;i<MAX;i++){
        D[i] = 0;
        F[i] = 0;
    }
    dfs(0);
    while(check()!=-1){
        int a = check();
        dfs(a);
    }
    for(int i=0;i<num;i++){
        cout << i+1 << " " << D[i] << " " << F[i] << endl;
    }
}

Measured memory_bytes: 1212
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

// 2015
// A Happy New Year!!!

int main(){
    for(int x = 1; x <= 9; x++){
        for(int y = 1; y <= 9; y++){
            printf("%dx%d=%d\n", x, y, x * y);
        }
    }
    return 0;
}

Measured memory_bytes: 1096
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

vector<lint> enum_div(lint n) {
	//nの約数を列挙
	vector<lint> ret;
	for (lint i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			if (i != n) {
				ret.push_back(i);
			}
			if (i * i != n) {
				if (n/i != n) {
					ret.push_back(n / i);
				}
			}
		}
	}
	return ret;
}

int main() {
	lint cnt = 0;
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}

	lint Z = pow(10, 6) + 3;
	vector<lint>B(Z);

	rep(i, N) {
		B[A[i]]++;
	}

	set<lint>S;
	rep(i, N) {
		S.insert(A[i]);
	}
	rep(i, N) {
		vector<lint>V;
		V = enum_div(A[i]);
		bool flag = false;
		rep(j, V.size()) {
			if (S.count(V[j])) {
				flag = true;
			}
		}

		if (B[A[i]] != 1) {
			flag = true;
		}

		if (flag == false) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 21948
#include <iostream> 
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int long long n,ans=1;
	while(cin>>n){
	for(int i=1;i<=n;i++){
		ans*=i;
	}
	cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
ll m=0,a=0,r=0,c=0,h=0,n,ans=0,x[6];
string s;
ll xx(int a1,int a2,int a3){
	return x[a1]*x[a2]*x[a3];
}

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>s;
		if(s[0]=='M')m++;
		else if(s[0]=='A')a++;
		else if(s[0]=='R')r++;
		else if(s[0]=='C')c++;
		else if(s[0]=='H')h++;
	}
	x[1]=a;
	x[2]=r;
	x[3]=m;
	x[4]=c;
	x[5]=h;
	ans+=xx(1,2,3);
	ans+=xx(1,2,4);
	ans+=xx(1,2,5);
	ans+=xx(1,3,4);
	ans+=xx(1,3,5);
	ans+=xx(1,4,5);
	ans+=xx(2,3,4);
	ans+=xx(2,3,5);
	ans+=xx(2,4,5);
	ans+=xx(3,4,5);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
//#define int long long 
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,k;
	cin>>n>>k;
	vector<double> vec(n);
	cin>>vec;
	double ans=minf;	
	double t=0;
	for(int i=0;i<k;i++){
		t+=((vec[i]+1)/2);
	}
	ans=t;
//	tr1(ans);
	for(int i=k;i<n;i++){
		t+=(vec[i]+1)/2;
		t-=(vec[i-k]+1)/2;
		ans=max(ans,t);
	}
	cout<<setprecision(10)<<fixed<<ans<<endl;
	
 
 
 
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 1792
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	tx=abs(tx - sx);
	ty= abs(ty - sy);
	
	rep(i, ty) {
		cout << 'U';
	}
	rep(i, tx) {
		cout << 'R';
	}
	rep(i, ty) {
		cout << 'D';
	}
	rep(i, tx) {
		cout << 'L';
	}
	cout << 'L';
	rep(i, ty+1) {
		cout << 'U';
	}
	rep(i, tx+1) {
		cout << 'R';
	}
	cout << "DR";
	rep(i, ty+1) {
		cout << 'D';
	}
	rep(i, tx+1) {
		cout << 'L';
	}
	cout << 'U' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1 && b!=1){cout<<"Alice"<<endl;}
    else if(b==1&&a!=1){cout<<"Bob"<<endl;}
    else if(a > b){cout<<"Alice"<<endl;}
    else if(b>a){cout<<"Bob"<<endl;}
    else{cout<<"Draw"<<endl;}

    return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    vector<int> a(n+1);
    priority_queue<int> pq;
    rep(i,n){
        cin >> a[i];
        pq.push(a[i]);
    }
    rep(i,m){
        int x = pq.top();
        x /= 2;
        pq.pop();
        pq.push(x);
    }
    ll res=0;
    while(!pq.empty()){
        res += pq.top();
        pq.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 4248
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

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

fn main() {
    input! {
        n: i64,
    }
    let mut count_out = 0;
    for j in 1..n + 1 {
        if j % 2 == 0 {
            continue;
        }
        let mut count = 0;
        for i in 1..j + 1 {
            if j % i == 0 {
                count += 1;
            }
        }
        if count == 8 {
            count_out += 1;
        }
    }
    println!("{}", count_out);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const ll N=205;
const double eps=1e-6;
const int mod=1e9+7;
int MIN,sum;
int c[10][10],a[N][N];
bool vis[N][N];
int dfs(int x,int sum)
{
    if(x == 1) return MIN=sum;
    for(int i=0; i<10; i++)
    {
        // printf("2222\n");
        if(x!=i&&sum+c[x][i] < MIN)
        {
            vis[x][i]=1;
            dfs(i,sum + c[x][i]);
         //   printf("MIN=%d\n",MIN);
            vis[x][i]=0;
        }
    }
}
int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        mem(vis,0);
        for(int i=0; i<10; i++)
            for(int j=0; j<10; j++)
                cin>>c[i][j];
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                cin>>a[i][j];
        /*for(int i=0; i<10; i++)
        {
            for(int j=0; j<10; j++)
                cout<<c[i][j];
            cout<<endl;
        }
        for(int i=0; i<h; i++)
        {
            for(int j=0; j<w; j++)
                cout<<a[i][j];
            cout<<endl;
        }*/
        ll ans=0;
       // printf("223\n");
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
            {
                if(a[i][j]!=-1&&a[i][j]!=1)
                {
                   // printf("%d\n",a[i][j]);
                    MIN=c[a[i][j]][1];
                  //  printf("MIN=%d\n",MIN);
                   /// int tmp = min(MIN,dfs(a[i][j],0));
                   dfs(a[i][j],0);
                   int tmp=MIN;
                   // printf("tmp=%d\n",tmp);
                    ans += tmp;
                    //printf("313\n");
                }
            }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

long combi(int n, int r) {
  int i;
  long p = 1;
  for (i = 1; i <= r; i++) {
    p = p * (n - i + 1) / i;
  }
  return p;
}

int main() {
  int n, p;
  cin >> n >> p;
  int a[50];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  int count_even = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      count_even++;
    }
  }

  long ans_even = 1;
  for (int i = 0; i < count_even; i++) {
    ans_even *= 2;
  }
  
  int count_odd = n - count_even;
  long ans_odd = 0;
  int k = 0;

  if (p == 1) {
    k = 1;
  }

  while (k <= count_odd) {
    ans_odd += combi(count_odd, k);
    k += 2;
  }

  long answer;
  answer = ans_even * ans_odd;

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    j = N-1
    while j > i:
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            ans += 1
        j -= 1
print(*A)
print(ans)



Measured memory_bytes: 5604
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	for(int i=0;i<n-1;++i)
		for(int j=i+1;j<n;++j)
			if(a[i]>a[j])
				swap(a[i],a[j]);
	double x=a[0]*1.0;
	for(int i=1;i<n;++i)
		x=(x+a[i])/2;
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


int main()
{
	map<string, int> mp;
	string S;
	int K;
	cin >> S >> K;

	int i = 0;

	for (int l = 1; l <= K; ++l)
	{
		for (int i = 0; i < S.length(); ++i)
		{
			mp[S.substr(i, l)] = 0;
		}
	}

	auto itr = mp.begin();
	for (int i = 1; i < K; ++i)
	{
		//cout << itr->first << endl;
		++itr;
	}
	cout << itr->first << endl;

	return 0;
}

Measured memory_bytes: 1920
#include "stdio.h"


struct card{
    char c;
    int n;
};

int main()
{
    struct card a[36], b[36],x[36];
    int n, j=0, i=0, mini;
    scanf("%d", &n);
    
    for (i = 0; i <= n - 1; i++){
        scanf(" %c%d", &a[i].c,&a[i].n);
        b[i].c = a[i].c;
        b[i].n = a[i].n;
       

    }
    /*bublle*/
    for (i = 0; i < n ; i++) {
        for (j = n - 1; j > i; j--) {
            if (a[j].n < a[j - 1].n) {
                x[j] = a[j];
                a[j] = a[j - 1];
                a[j - 1] = x[j];
            }
        }
    }
    /*selectsort*/

    for (i = 0; i < n ; i++) {
        mini = i;
        for (j = i; j < n; j++) {
            if (b[j].n < b[mini].n)
                mini = j;
        }
            x[i] = b[i];
            b[i] = b[mini];
            b[mini] = x[i];
        }
    
      
    j = 0;
    for (j = 0; j < n - 1; j++)
        printf("%c%d ", a[j].c, a[j].n);

    printf("%c%d\n", a[n - 1].c, a[n - 1].n);
    printf("Stable\n");
    
    j = 0;
    for (j = 0; j < n - 1; j++)
    printf("%c%d ", b[j].c,b[j].n);

    printf("%c%d\n", b[n - 1].c, b[n - 1].n);

    j = 0;
    for (j = 0; j < n ; j++) {
        if (a[j].c != b[j].c) {
            printf("Not stable\n");
            break;
        }
    }
    if(j==n)
        printf("Stable\n");

    return 0;
}

Measured memory_bytes: 1852
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int n, m;
vector<Int> children[108000];
vector<Int> parents[108000];

Int ind[108000];
Int p = 1;
Int a, b;
Int dfs(Int x){
  for(int i = 0;i < children[x].size();i++){
    int to = children[x][i];
    if(ind[to] > 0)continue;
    dfs(to);
  }
  ind[x] = p++;
}

int main(){
  cin >> n >> m;
  for(int i = 0;i < n - 1 + m;i++){
    cin >> a >> b;a--,b--;
    children[a].push_back(b);
    parents[b].push_back(a);
  }

  for(int i = 0;i < n;i++){
    if(ind[i] == 0)dfs(i);
  }

  for(int i = 0;i < n;i++){
    int ans = -1;
    for(Int j = 0;j < parents[i].size();j++){
      int p = parents[i][j];
      if(ans == -1 || ind[ans] > ind[p])ans = p;
    }
    cout << ans+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

void solve(ll n, ll k, ll s){
    vec ans;
    if(s==1e9){
        rep(i,k)ans.push_back(1e9);
        rep(i,n-k)ans.push_back(1);
    }else{
        rep(i,k)ans.push_back(s);
        rep(i,n-k)ans.push_back(1e9);
    }
    rep(i,n){
        cout<<ans[i]<<(i==n-1?'\n':' ');
    }
}

int main(){
    ll n;
    scanf("%lld",&n);
    ll k;
    scanf("%lld",&k);
    ll s;
    scanf("%lld",&s);
    solve(n, k, s);
}


Measured memory_bytes: 2164
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   
    long double ans = 0;
    ll n;
    cin >> n;
    static const ll MAX = 201;
    ll t[MAX] = {};
    ll v[MAX] = {};
    for (ll i=1;i<=n;i++){
        cin >> t[i];
    }
    for (ll i=1;i<=n;i++){
        cin >> v[i];
    }
    ll tsum[MAX] = {};
    ll tmp = 0;
    for (ll i=1;i<=n;i++){
        tmp += t[i];
        tsum[i] = tmp;
    }
    ll vnow = 0;
    ll lim1, lim2;
    lim1 = mop;
    lim2 = 0;
    ll tidx = 1;
    for (ll i=0;i<tsum[n];i++){
        if(i == tsum[tidx-1]){
            lim2 = v[tidx];
            tidx++;
        }
        ll tmp = 0;
        lim1 = mop;
        for (ll j=tidx-1;j<=n;j++){
            tmp = tsum[j] - i + v[j+1];
            if(lim1 > tmp){
                lim1 = tmp;
            }
        }

        if(lim1 - vnow >= 2){
            if(lim2 - vnow >= 1){
                ans += vnow + 0.5;
                vnow++;
            }else{
                ans += vnow;
            }
        }else if(lim1 - vnow == 1){
            if(lim2 - vnow >= 1){
                ans += vnow + 0.25;
            }else{
                ans += vnow;
            }
        }else{
            ans += vnow - 0.5;
            vnow--;
        }
//        cout << i << " " << vnow << " " << lim1 << endl;
    }
    cout << fixed;
    cout << setprecision(5);
    cout << ans << endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
	int n;
	double s, ss;
	double x[1000];
	while(true){
		s = 0;
		ss = 0;
		cin >> n;
		if(!n) return 0;
		for(int i = 0; i < n; i++){
			cin >> x[i];
			s += x[i];
		}
		s /= n;
		for(int i = 0; i < n; i++){
			ss += (x[i] - s)*(x[i] - s);
		}
		ss /= n;
		printf("%.8f\n", sqrt(ss));
	}
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] / (fac[k] * fac[n - k]);
}


//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[10101][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>b(n), ans;
	vector<bool>flag(n);
	rep(i, n) {
		cin >> b[i];
	}
	while (b.size() > 0) {
		ll k = b.size();
		bool flag = false;
		for (ll i = k-1;i >= 0;--i) {
			if (b[i] == i + 1) {
				flag = true;
				ans.push_back(b[i]);
				b.erase(b.begin() + i);
				break;
			}
		}
		if (flag == false) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (ll i = n - 1;i >= 0;--i) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3584
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65 and m+f < 80:
        print("B")
    elif m+f >= 50 and m+f < 65:
        print("C")
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

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

vector<vector<int>> G(3e5);
vector<bool> seen(3e5,false);
int cnt;

void bfs(int r) {
  queue<int> Q;
  Q.push(r);
  seen[r]=true;
  int u;
  while(!Q.empty()) {
    u=Q.front();
    Q.pop();
    cnt++;
    for(int next:G[u]) {
      if(seen[next]==false) {
        seen[next]=true;
        Q.push(next);
      }
    }
  }
}

int main() {
  int n,m; cin>>n>>m;
  int a,b,ans=0;
  for(int i=0;i<m;i++) {
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=1;i<=n;i++) {
    if(seen[i]==false) {
      cnt=0;
      bfs(i);
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 17540
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>mp;

void  solve(int x)
{
    int a,b;
    b = a = x%10;
    x = x/10;
    while(x)
    {
        b = x%10;
        x = x/10;
    }
    mp[{b,a}]++;
    //if(a!=b)mp[{b,a}]++;
}
int main()
{

    int i,j,k,l,m,n,t,ans=0;

    cin>>n;

    for(i=1; i<=n; i++)
       {
           solve(i);
       }
    for(i=1; i<=9; i++)
    {
        for(j=1; j<=9; j++)
        {
            ans += (mp[ {i,j}]*mp[ {j,i}]);
        }
    }

    //for(i=1;i<=9;i++)ans+=mp[{i,0}];

    cout<<ans<<endl;

}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

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

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int A, B; cin >> A >> B;
  int x = A + B;
  if (x % 2 == 0) {
    cout << x / 2 << endl;
  }else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}



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

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

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

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

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

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

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

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

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

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

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

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

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

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

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

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let x: Vec<usize> = sc.vec(5);
    for i in 0..5 {
        if x[i] == 0 {
            println!("{}", i+1);
            return;
        }
    }
}


Measured memory_bytes: 2112
// AOJ 2135 Reverse a Road
// 2018.2.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 15000
typedef struct { short t, s, r; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].r < que[i].r)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].r < que[min].r)) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, int r)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].r = r;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].r > que[i].r)) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

short hi[1002], to[1002][100], no[1002][100];
char mk[1002][1002][2];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int *rno, int start, int goal)
{
	int i, s, t, r, e, k;

	memset(mk, 0, sizeof(mk));
	qsize = 0;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, r = que[0].r, deq();
		if (s == goal) { *rno = r; return t; }

		if (r == 0) {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i];
				if (k) {
					if (!mk[e][s][1]) mk[e][s][1] = 1, enq(e, t+1, k);
				} else {
					if (!mk[s][e][0]) mk[s][e][0] = 1, enq(e, t+1, 0);
				}
			}
		} else {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i];
				if (k || mk[s][e][1]) continue;
				mk[s][e][1] = 1, enq(e, t+1, r);
			}
		}
	}
	return -1;
}

int main()
{
	int N, S, T, M, a, b, i, k, ans;

	while (N = in()) {
		N++, S = in(), T = in();
		M = in();

		memset(hi, 0, N << 1);
		memset(mk, 0, sizeof(mk));
		for (i = 1; i <= M; i++) {
			a = in(), b = in();
			if (mk[a][b][0]) continue;
			mk[a][b][0] = 1;
			k = hi[a]++, to[a][k] = b, no[a][k] = 0;
			k = hi[b]++, to[b][k] = a, no[b][k] = i;
		}

		ans = dijkstra(&k, S, T);
		printf("%d %d\n", ans, k);
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

ll ans;
ll p10[19];

void gogo (int dhi, int dlo, ll K, ll nmult)
{
    if (dhi <= dlo)
    {
        if (dhi == dlo) nmult *= 10;
        if (!K)
            ans += nmult;
        return;
    }

    ll ndiff = p10[dhi] - p10[dlo];
    for (int i = -9; i <= 9; i++)
    {
        ll knew = K + i * ndiff;
        if (abs(knew) < p10[dhi])
        {
            int nways = 10 - abs (i);
            if (dlo == 0 && i <= 0) nways--;
            gogo (dhi - 1, dlo + 1, knew, nmult * nways);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    ans = 0;
    p10[0] = 1;
    for (int i = 1; i < 19; i++)
        p10[i] = p10[i-1] * 10;

    ll D;
    cin >> D;
    for (int ndig = 1; ndig <= 18; ndig++)
        gogo (ndig - 1, 0, D, 1);

    cout << ans << "\n";
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    ii = [2**i for i in range(6)]

    while True:
        t,n = LI()
        if t == 0 and n == 0:
            break

        s = [c for c in str(n)]
        l = len(s)

        r = None
        rm = -1
        rc = 0
        for i in range(2**(l-1)):
            k = []
            c = s[0]
            for j in range(l-1):
                if ii[j] & i:
                    c += s[j+1]
                else:
                    k.append(c)
                    c = s[j+1]
            k.append(c)
            m = sum(map(int,k))
            if m <= t:
                if rm < m:
                    rm = m
                    r = k
                    rc = 1
                elif rm == m:
                    rc += 1
        if rc == 0:
            rr.append('error')
        elif rc > 1:
            rr.append('rejected')
        else:
            rr.append('{} {}'.format(rm, ' '.join(r)))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9036
/*
* @Author: Kabid
* @Date:   {{create_time}}
* @Last Modified by:   Kabid
* @Last Modified time: 2020-09-19 12:16:37
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');

int t;       //test cases
ll i, j;	 //iterators
ll n, k , p, q,  d, m, c, c1, c2, d1; //variables;
ll mx = LLONG_MIN, mn = LLONG_MAX;		// max min
string s, s1, s2;		// string
ll a [1000001], b [200001] , mox [200001];	// array
map <int, int > mp;
vector <vector<ll>> vc;
vector <ll> v;
set <ll> st;
bool r;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cin >> t; q=t;
	t = 1;
	while (t--) {


		cin >> p >> q >> d >> m;
		mx = max(mx, p * d);
		mx = max(mx, p * m);
		mx = max(mx, q * d);
		mx = max(mx, q * m);
		cout << mx << endl;
	}


	return 0;

}


Measured memory_bytes: 3660
#include <iostream>
#include <bitset>
#include <vector>
#include <cmath>
using namespace std;

int main() {

    int N, D;
    cin >> N >> D;

    vector<vector<int>> nd_vec(N, vector<int>(D));

    int cnt = 0;

    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++){
            int t;
            cin >> t;

            nd_vec.at(i).at(j) = t;
        }
    }

    for (int i = 0; i < N; i++){
       
        for (int ii = 0; ii < N; ii++){
            if(i == ii){
                continue;
            }

            int sum = 0;
            for (int j = 0; j < nd_vec.at(i).size(); j++){


                sum += pow((nd_vec.at(i).at(j) - nd_vec.at(ii).at(j)),2);
            }

            double d = sqrt(sum);
            int in = sqrt(sum);
            // cout << "i : " << i << endl;
            // cout << "ii: " << ii << endl;
            // cout << "d: " << d << endl;
            
            if(d == in){
                cnt++;
            }



        }
    }


    cout << cnt / 2<< endl;

}

Measured memory_bytes: 3724
def main():
    s = input()
    num = 0

    while num < len(s) - 7:
        if s[num:num+6] == "dreamd" or s[num:num+8] == "dreamera":   #"dream"確定
            num += 5
        elif s[num:num+8] == "dreamerd" or s[num:num+8] == "dreamere":  #"dreamer"確定
            num += 7
        elif s[num:num+6] == "erased" or s[num:num+6] == "erasee":    #"erase"確定
            num += 5
            #print('erase')
        elif s[num:num+7] == "eraserd" or s[num:num+7] == "erasere":    #"eraser"確定
            num += 6
        else:
            print("NO")
            exit()
    if s[num:num+5] == "dream" or s[num:num+7] == "dreamer" or s[num:num+5] == "erase" or s[num:num+6] == "eraser":
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()

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

int main(){
    cin >> s1;
    for(int i = 0; i < s1.length(); i++){
        if(s1[i] == 'A'){
            if(s1[i+1] == 'C') {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";
    return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    repA(i,1,n) cin>>a[i];
    set<ll> st;
    st.insert(1000ll);
    for(int i=1;i<=n;)
    {
      ll j;
      vector<ll> temp;
      for(j=i;j<=n;j++)
      {
        if(j==i)
        {
          temp.pb(a[j]);
          continue;
        }
        if(a[j]>a[j-1]) temp.pb(a[j]);
        else break;
        // if(j==n) temp.pb(a[j]);
        //if(a[j+1]<a[j]) break;
        //if(j<n)
      }
      // for(auto it:temp) watch(it);
      if(temp.size()>1)
      {
        ll mn=*min_element(temp.begin(),temp.end());
        ll mx=*max_element(temp.begin(),temp.end());
        ll ans=((*st.rbegin())/mn)*mx;
        ans+=((*st.rbegin())%mn);
        // watch(ans);
        st.insert(ans);
      }
      i=j;
    }
    ll ans=*st.rbegin();
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
  // cin t;
   while(t--){
            ll x;
            cin >> x;
            ll a , b;
            cin >> a >> b;
            for(int i = a ; i <= b ; i ++)
            {
                if(i % x == 0)
                {cout << "OK" << endl;return 0;}
            } 
            cout << "NG" << endl;
   }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, M; cin >> N >> M;
  vector<int> S(N), T(M);
  for (auto& s : S) {
    cin >> s;
  }
  for (auto& t : T) {
    cin >> t;
  }

  vector<vector<cpp_int>> dp(N, vector<cpp_int>(M));
  vector<vector<cpp_int>> sum(N, vector<cpp_int>(M));

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      auto i0 = i - 1;
      auto j0 = j - 1;
      if (S[i] == T[j]) {
        dp[i][j] += (i0 >= 0 && j0 >= 0) ? sum[i0][j0] : 0;
        dp[i][j] += 1;
      }
      if (i0 >= 0) { sum[i][j] += sum[i0][j]; }
      if (j0 >= 0) { sum[i][j] += sum[i][j0]; }
      if (i0 >= 0 && j0 >= 0) { sum[i][j] -= sum[i0][j0]; }
      sum[i][j] += dp[i][j];

      dp[i][j] = (dp[i][j] + MOD) % MOD;
      sum[i][j] = (sum[i][j] + MOD) % MOD;
    }
  }
  cpp_int ans = sum[N-1][M-1] + 1;
  ans %= MOD;
  cout << ans.str() << CRLF;

  return;
}

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

  solve();

  return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L 
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,d;
	cin>>n>>d;
	d*=d;
	int count=0;
	for(int i=0;i<n;i++){
		ll val,x,y;
		cin>>x>>y;
		val=x*x+y*y;
		if(val<=d)
			count++;
	}
	cout<<count<<endl;
	return 0;
}


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

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

  int ans = 1;
  rep (i, n) {
    if (2 * ans > ans + k) ans += k;
    else ans *= 2;
  }

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


Measured memory_bytes: 256
N = int(input())
count_A_right = 0
count_B_left  = 0
AB_count = 0
same_count = 0

for _ in range (N):
    S = input()
    temp = 0
    if S[0] == 'B':
        count_B_left +=1
        temp +=1
    if S[-1] == 'A':
        count_A_right +=1
        temp +=1
    if temp ==2:
        same_count+=1
        count_A_right -=1
        count_B_left  -=1
    for i in range (len(S)-1):
        if S[i:i+2] == 'AB':
            AB_count +=1

if same_count-1>=0:
    AB_count += same_count-1#一つのBAに変更して加える
    count_A_right +=1
    count_B_left  +=1
    if count_A_right==1 and count_B_left ==1:
        print(AB_count)
    else:
        print(AB_count+min(count_A_right,count_B_left))
else:
    print(AB_count+min(count_A_right,count_B_left))

Measured memory_bytes: 46040