akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;
char s[4];
int main(){
  rep(i,4) cin >> s[i];
  string b = "Good";
  rep(i,3) {
    if(s[i] == s[i+1]) b = "Bad";
  }
  cout << b;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

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 U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

void eratos(int n, vector<bool>& isprime) {
	REP(i, n + 1) {
		isprime[i] = true;
	}
	isprime[0] = false;
	isprime[1] = false;
	int last = ((int)sqrt(n)) + 1;
	FOR(i, 2, last) {
		if (isprime[i]) {
			int j = i + i;
			while (j <= n) {
				isprime[j] = false;
				j += i;
			}
		}
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vb isPrime(300001);
	eratos(300000, isPrime);
	int N;
	cin >> N;
	while (N != 0) {
		int ans = 0;
		FOR(i, N + 1, 2 * N + 1) {
			if (isPrime[i]) {
				ans++;
			}
		}
		cout << ans << endl;
		cin >> N;
	}
	return 0;
}



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

int i;

int main()
{
    unsigned long n, k, t;

    cin >> n >> k;

    t = n % k;
    if (t < k - t)
    {
        cout << t << endl;
    }
    else
    {
        cout << k - t << endl;
    }
}

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

struct node{
	int val;
	node*l,*r;
}dat[4000000];
int p;

inline void update(node*t,int k,int x,int l,int r){
	if(r-l==1){
		t->val+=x;return;
	}
	if(k<(l+r)/2){
		if(t->l==NULL)t->l=&dat[p++];
		update(t->l,k,x,l,(l+r)/2);
		t->val=t->l->val+(t->r?t->r->val:0);
	}
	else{
		if(t->r==NULL)t->r=&dat[p++];
		update(t->r,k,x,(l+r)/2,r);
		t->val=(t->l?t->l->val:0)+t->r->val;
	}
}
inline int query(node*t,int a,int b,int l,int r){
	if(b<=l||r<=a)return 0;
	if(a<=l&&r<=b)return t->val;
	int lb=(t->l?query(t->l,a,b,l,(l+r)/2):0);
	int rb=(t->r?query(t->r,a,b,(l+r)/2,r):0);
	return lb+rb;
}
int a[400000];
int main(){
	int n;scanf("%d",&n);
	node*root=&dat[p++];
	int N=1<<30;
	rep(i,n){
		scanf("%d",&a[i]);
		update(root,a[i],1,0,N);
	}
	rep(i,n){
		update(root,a[i],-1,0,N);
		int l=0,r=1000000000;
		int A=n/2;
		while(l!=r){
			int t=(l+r)/2;
			if(query(root,0,t+1,0,N)>=A)r=t;
			else l=t+1;
		}
		printf("%d\n",l);
		update(root,a[i],1,0,N);
	}
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> a(n);
    read(a);
    ll x = 0;
    for (int i = 0; i < n; i++) {
        x ^= a[i];
    }
    V<ll> b(n);
    for (int i = 0; i < n; i++) {
        b[i] = (x ^ a[i]);
    }
    print(b);
}

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

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  vector<int> H(N);
  for( int i = 0; i < N; i++ ) cin >> H.at(i);
  sort( H.begin(), H.end() );
  
  int under = 0;
  int over = 1000000000;
  while( over - under > 1 ){
    int AT = ( under + over ) / 2;
    int plus = 0;
    for( int i = 0; i < N; i++ ){
      if( H.at(i) > B*AT ){
        plus += ( H.at(i) - B*AT + (A-B-1) ) / (A-B);
      }
    }
    if( plus <= AT ){
      over = AT;
    }else{
      under = AT;
    }
  }
  
  cout << over << endl;
    
}


Measured memory_bytes: 1024
function Main(input) {
	tmp = input.split(" ");
	var data = [];
	data[0] = parseInt(tmp[0]);
	data[1] = parseInt(tmp[1]);
	data[2] = parseInt(tmp[2]);
	var min = 0;
	var tmp = 0;
	var tmp_max = Math.max(data[0],data[1],data[2]);
	for(var i = 0; i < 3; i++) {
		if(data[i] != tmp_max || tmp == 1){
			min += data[i];
		}
		if(data[i] == tmp_max){
			tmp = 1;
		}
	}
	console.log(min);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
from collections import defaultdict as dd
n, k = map(int, input().split())
dic = dd(lambda: [])
for i in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        dic[a].append(i)

#print(dic)

counter = 0
for i in range(1, n+1):
    if len(dic[i]) == 0:
        counter += 1
print(counter)

Measured memory_bytes: 68208
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint a, b;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	if(a > b) swap(a, b);
	for(int i = 0; i < b; i++) cout<< a;
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m,k;
	cin >> n >> m >> k;

	//k = a*b + (n-a)(m-b) = nm + ab + ab - am - nb

	rep(a,0,n+1) rep(b,0,m+1){
		if(k == a*b + (n-a)*(m-b)){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 1 << 18;
struct BIT{
  int bit[MAX_N+1],n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    memset(bit,0,sizeof(bit));
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int b[n];
  for(int i=0;i<n;i++) b[i]=a[i];
  sort(b,b+n);
  map<int,int> m;
  for(int i=0;i<n;i++) m[b[i]]=i+1;
  BIT bit(n);
  int ans=0;
  for(int i=0;i<n;i++){
    //cout<<i<<" "<<m[a[i]]<<endl;
    ans+=i-bit.sum(m[a[i]]);
    bit.add(m[a[i]],1);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 20792
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<ll> v(N);
  for(int i=0; i<N; i++) cin >> v[i];
  int ans=0;
  int temp=0;
  for(int i=0; i+1<N; i++){
    if (v[i]>=v[i+1]){
      temp++;
      ans=max(ans, temp);
    }
    else temp=0;
  }
  cout << ans <<endl;
}

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

int main()
{
	int x1, x2, x3, x4, y1, y2, y3, y4;
	int w1, w2;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	w1 = x1 - x2;
	w2 = y1 - y2;
	
	int temp;
	temp = w1;
	w1 = w2;
	w2 = temp;
	w1 *= -1;
	
	y4 = y1 - w2;
	x4 = x1 - w1;
	y3 = y2 - w2;
	x3 = x2 - w1;
	
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <tuple>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <map>
#include <sstream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

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

    

    ll ans=0;

    map<string,ll> t;
    rep(i,n)t[s[i]]++;
    
    for(int i=0;i<n;i++){
        if(t.count(s[i])){
            ans+=(t.at(s[i])-1)*(t.at(s[i]))/2;
            t.erase(s[i]);
        }
    }
    cout << ans <<endl;

    return 0; 

}


Measured memory_bytes: 18176
# B - FizzBuzz Sum
def main():
    N = int(input())
    is_fizzbuzz = [False] * (N + 1)
    is_fizzbuzz[::3] = [True] * (N // 3 + 1)
    is_fizzbuzz[::5] = [True] * (N // 5 + 1)
    ans = sum(i for i, b in enumerate(is_fizzbuzz) if not b)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22008
def insertion_sort(A, N):
    for j in range(1, N):
        key = A[j]
        i = j - 1
        while i >= 0 and A[i] > key:
            A[i+1] = A[i]
            i = i - 1
        A[i+1] = key
        print " ".join(map(str, A))

if __name__ == "__main__":
    import sys
    N = int(sys.stdin.readline().strip())
    A = [ int(e) for e in sys.stdin.readline().strip().split() ]
    print " ".join(map(str, A))
    insertion_sort(A, N)

Measured memory_bytes: 4232
/**
*    created: 22.05.2020 23:54:39
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s; cin >> s;
    int l = s.size();
    int ans = 0;
    rep(i,l) rep(j,i+1) {
        string sub = s.substr(j,i-j+1);
        bool ok = true;
        rep(k,sub.size()) {
            if (sub[k] != 'A' && sub[k] != 'C' && sub[k] != 'G' && sub[k] != 'T') {
                ok = false;
            }
        }
        if (ok) ans = max(ans, (int)sub.size());
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
int n;
cin >> n;
int cnt[1000000]={0};
rep(i,n-1){
    int k;
    cin >> k;
    cnt[k]++;
}
rep(i,n) cout << cnt[i+1] << endl;


}

Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

ll MOD=1e9+7;

ll modinv(ll x)
{
    ll res=1;
    ll pw=MOD-2;
    while(pw>0)
    {
        if(pw%2) res=(res*x)%MOD;
        pw/=2;
        x=(x*x)%MOD;
    }
    return res;
}
ll n, k;

ll ch[1009][1009];
ll a[1009];
ll dp[29][1009];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=k; i++) cin>>a[i];
    for(int i=0; i<=1000; i++)
    {
        ch[i][0]=1;
        ch[i][i]=1;
    }
    for(int i=1; i<=1000; i++)
    {
        for(int j=1; j<i; j++)
        {
            ch[i][j]=(ch[i-1][j-1]+ch[i-1][j])%MOD;
        }
    }
    for(int i=0; i<=n; i++)
    {
        if(i<=a[1]) dp[1][i]=(ch[a[1]][i]*ch[n][a[1]])%MOD;
        else dp[1][i]=0;
        //cout<<"dp i="<<1<<" db="<<i<<" ::: "<<dp[1][i]<<endl;
    }
    for(int i=2; i<=k; i++)
    {
        for(ll db=0; db<=n; db++)
        {
            for(ll akt=0; akt<=min(db, a[i]); akt++)
            {
                //ll pl=ch[a[i]][akt];
                ll pl=1LL;
                if(n-(db-akt)<akt) continue;
                pl=(pl*ch[n-(db-akt)][akt])%MOD;
                pl=(pl*ch[n-akt][a[i]-akt])%MOD;
                pl=(pl*dp[i-1][db-akt])%MOD;
                //cout<<"plusz ("<<akt<<") "<<pl<<endl;
                dp[i][db]=(dp[i][db]+pl)%MOD;
            }
            //cout<<"dp i="<<i<<" db="<<db<<" ::: "<<dp[i][db]<<endl;
        }
    }
    ll ans=dp[k][n];
    /*for(int i=1; i<=n; i++)
    {
        ans=(ans*ch[n][a[i]])%MOD;
    }*/
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7680
/// --- In the name of ALLAH --- ///


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


typedef long long              ll;
typedef vector<int>            vi;
typedef vector<ll>             vl;
typedef vector<vi>             vvi;
typedef vector<vl>             vvl;
typedef pair<int,int>          pii;
typedef pair<double, double>   pdd;
typedef pair<ll, ll>           pll;
typedef vector<pii>            vii;
typedef vector<pll>            vll;
typedef double                 dl;

#define endl                   '\n'
#define PB                     push_back
#define F                      first
#define S                      second
#define all(a)                 (a).begin(),(a).end()
#define rall(a)                (a).rbegin(),(a).rend()
#define sz(x)                  (ll)x.size()
#define wt                     ll t; cin>>t; while(t--)
#define input(a,n)             for(int i=0;i<n;i++) cin>>a[i];

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define mod 10000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


const ll mx=1e9;









int main()
{
    optimize();

   int n,m,i,j,p=0;
   cin>>n>>m;
   int k[n+1],k1[m+1];
   map<int,int>s;
   for(i=1;i<=n;i++)
   {
       cin>>k[i];
       for(j=1;j<=k[i];j++){
        cin>>k1[j];
        s[k1[j]]++;
        }
   }
   for(auto u: s)
   {
     if(u.S==n)
        p++;
   }
   cout<<p<<endl;




    return 0;
}









































Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
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; }
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)


int main() {
	ll r,n;
	scanf("%lld", &r);
	n = 3 * r*r;
	printf("%lld\n", n);
	return(0);
}

Measured memory_bytes: 128
from math import ceil
from math import floor
n = int(input())
nums = list(map(int, input().split()))
ave = sum(nums)/n
if ave%1 > 0.5:
    ave = ceil(ave)
elif ave%1 <= 0.5:
    ave = floor(ave)
ans = 0
for i in range(n):
    ans += (nums[i]-ave)**2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
const double PI=acos(-1.0);
struct Complex
{
    double r,i;
    Complex(double _r=0.0,double _i=0.0){r=_r;i=_i;}
    Complex operator +(const Complex &b){return Complex(r+b.r,i+b.i);}
    Complex operator -(const Complex &b){return Complex(r-b.r,i-b.i);}
    Complex operator *(const Complex &b){return Complex(r*b.r-i*b.i,r*b.i+i*b.r);}
}x1[max_n*4],x2[max_n*4];
void change(Complex y[],int len)
{
    int i,j,k;
    for(i=1,j=len/2;i<len-1;i++)
    {
        if(i<j)swap(y[i],y[j]);
        k=len/2;
        while(j>=k)
        {
            j-=k;
            k/=2;
        }
        if(j<k)j+=k;
    }
}
void fft(Complex y[],int len,int on)
{
    change(y,len);
    for(int h=2;h<=len;h<<=1)
    {
        Complex wn(cos(on*2*PI/h),sin(on*2*PI/h));
        for(int j=0;j<len;j+=h)
        {
            Complex w(1,0);
            for(int k=j;k<j+h/2;k++)
            {
                Complex u=y[k];
                Complex t=w*y[k+h/2];
                y[k]=u+t;
                y[k+h/2]=u-t;
                w=w*wn;
            }
        }
    }
    if(on==-1)for(int i=0;i<len;i++)y[i].r/=len;
}
int n;
ll m,a[max_n*2];
int main(){
    scanf("%d%lld",&n,&m);
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        a[x]++;
    }
    int len=1;
    while(len<200001)len<<=1;
    for(int i=0;i<len;i++){
        if(i<=100000)x1[i]=Complex(a[i],0);
        else x1[i]=Complex(0,0);
    }
    fft(x1,len,1);
    for(int i=0;i<len;i++)x1[i]=x1[i]*x1[i];
    fft(x1,len,-1);
    for(int i=0;i<max_n*2;i++)a[i]=(ll)(x1[i].r+0.5);
    ll ans=0;
    for(int i=max_n*2-1;i>=0;i--){
        ll mx=min(m,a[i]);
        m-=mx,a[i]-=mx;
        ans+=mx*i;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 14592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class254
    {
        static void Main()
        {
            string N = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            var dp = new int[N.Length + 1, K + 1,2];
            dp[0, 0,0] = 1; //0は含めないので後で引く。

            for(int i = 0; i < N.Length; i++)
            {
                int num = N[i] - '0';
                for(int j = 0; j < K; j++)
                {
                    for(int k = 0; k < 10; k++)
                    {
                        for(int l = 0; l < 2; l++)
                        {
                            int nl = l;
                            int nj = j;
                            if (l == 0)
                            {
                                if (k > num) continue;
                                if (k < num) nl = 1;
                            }
                            if (k != 0)
                            {
                                nj++;
                            }

                            dp[i + 1, nj, nl] += dp[i, j, l];
                        }
                    }
                }
            }

            int sum = 0;
            for(int i = 1; i <= N.Length; i++)
            {
                sum += dp[i, K,0]+dp[i,K,1];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
import math
H,W = map(int,input().split())
ans = float('inf')
S = H*W
def minimum(x,y,z):
    S_max = max(x,y,z)
    S_min = min(x,y,z)
    return S_max-S_min
for h in range(1,H+1):
    A = h*W
    B = math.floor((H-h)/2) * W
    C = S-A-B
    ans = min(ans,minimum(A,B,C))
    
    B = (H-h)*math.floor(W/2)
    C = S-A-B
    ans = min(ans,minimum(A,B,C))

for w in range(1,W+1):
    A = H*w
    B = math.floor((W-w)/2) * H
    C = S-A-B
    ans = min(ans,minimum(A,B,C))

    B =(W-w)*math.floor(H/2)
    C = S-A-B
    ans =  min(ans,minimum(A,B,C)) 
print(ans)
    

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int s1,s2,x,x1,i;
	char w[]={"ABCDE"};
	while(1){
		scanf("%d%d",&s1,&s2);
		if(s1==0&&s2==0) break;
		x=s1+s2; x1=0;
		for(i=1;i<5;i++){
			scanf("%d%d",&s1,&s2);
			if(x<s1+s2){
				x=s1+s2; x1=i;
			}
		}
		printf("%c %d\n",w[x1],x);
	}
	return 0;
}

Measured memory_bytes: 2752
S=input()
flag = 0
for i in range(len(S)-3):
    if S[i+2] == "C":
        flag += 1
flag2 = 0
for s in S:
    if s.upper() == s:
        flag2+=1
if flag == 1 and S[0] == "A" and flag2 == 2:
    print("AC")
else:
    print("WA")
    

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
const int INF = 1e+8;

int H[6][6] = {
	{1,5,2,3,0,4}, // North : 奥へ移動   ( y:-1 )
	{3,1,0,5,4,2}, // East  : 右へ移動   ( x:+1 )
	{2,1,5,0,4,3}, // West  : 左へ移動   ( x:-1 )
	{4,0,2,3,5,1}, // South : 手前へ移動 ( y:+1 )
	{0,2,4,1,3,5}, // Right : 右回りに回転 (移動なし)
	{0,3,1,4,2,5}  // Left  : 左回りに回転 (移動なし)
};

int dx[4] = {0,1,-1,0};
int dy[4] = {-1,0,0,1};
// 高さと幅
int h, w;
// s[y][x] := (x,y)のマスに書かれた数字
int s[11][11];


// サイコロライブラリ
// d[0] := top,   d[1] := front 
// d[2] := right, d[3] := left
// d[4] := back,  d[5] := bottom
enum{TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};

struct Cube{
	int x,y;
	vector<int> d;
	// コンストラクタで初期化
	Cube(vector<int> v, int x_, int y_){
		x = x_; y = y_;
		if( v.size() == 6 ){
			d = v;
		}else{
			d = vector<int> (6);
		}
	}
	// dirの方向に回転 (副作用なし)
	Cube roll(int dir){
		Cube result = (*this);
		vector<int> d_(6);
    	for(int i = 0 ; i < 6 ; i++ ){
        	d_[i] = d[ H[dir][i] ];
    	}
    	result.d = d_;
    	result.x += dx[dir];
    	result.y += dy[dir];
    	return result;
    }
};
bool operator<(const Cube& c1, const Cube& c2){
	if( P(c1.x,c1.y) == P(c2.x,c2.y) ){
		if( c1.d[0] == c2.d[0] ){
			return c1.d[1] < c2.d[1];
		}else{
			return c1.d[0] < c2.d[0];
		}
	}
	return P(c1.x,c1.y) < P(c2.x,c2.y);
}

typedef pair<int,Cube> State;

// ゴール g, 初期のキューブの状態 c からのダイクストラ法
int dijkstra(Cube c , P g){
	// greater<State> を指定することで コスト が小さい順に取り出せる
	priority_queue<State, vector<State>, greater<State> > q;
	
	// d[cube] := cube にたどり着く最小コスト. (cubeは位置のキューブの状態を持っている)
	map<Cube,int> d;
	
	d[c] = 0;
	State start( 0 , c );
	q.push( start );
	
	int result = INF;
	while( !q.empty() ){
		int now_cost = q.top().first;
		Cube c = q.top().second;
		q.pop();
		
		if( P(c.x,c.y) == g ){
			result = min( result , now_cost );
			
			break;
		}
		
		for(int dir=0 ; dir < 4 ; dir++ ){
			Cube c_ = c.roll( dir );
			if( c_.x < 0 || c_.y < 0 || c_.x >= w || c_.y >= h ) continue;
			
			int next_cost = now_cost + s[c_.y][c_.x] * c_.d[BOTTOM];
			if( d.count(c_) == 0 ){
				d[c_] = next_cost;
				State next( next_cost , c_ );
				q.push( next );
			}else if( next_cost < d[c_] ){
				d[c_] = next_cost;
				State next( next_cost , c_ );
				q.push( next );
			}
		}
	}
	return result;
}

int main(){
	vector<int> v(6);
	v[0] = 1; v[5] = 6;
	v[1] = 2; v[4] = 5;
	v[2] = 3; v[3] = 4;	
	
	while( cin >> h >> w , w || h ){
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				cin >> s[y][x];
			}
		}
		int sx, sy, gx, gy;
		cin >> sy >> sx >> gy >> gx;
		Cube c( v, sx, sy );
		int ans = dijkstra( c , P(gx,gy) );
		cout << ans << endl;
	}
}

Measured memory_bytes: 1036
n = int(raw_input())
num = [1000, 100, 10, 1]
cha = ['m', 'c', 'x', 'i']
for i in xrange(n):
    po = raw_input().split()
    poyo = [0, 0]
    for j in xrange(2):
        c = 1
        for k in xrange(len(po[j])):
            if po[j][k] == cha[0]:
                poyo[j] += c*num[0]
                c = 1
            elif po[j][k] == cha[1]:
                poyo[j] += c*num[1]
                c = 1
            elif po[j][k] == cha[2]:
                poyo[j] += c*num[2]
                c = 1
            elif po[j][k] == cha[3]:
                poyo[j] += c
                break
            else:
                c = int(po[j][k])
    sumpoyo = sum(poyo)
    cn = [0,0,0,0]
    ans = ''
    for j in xrange(4):
        while (sumpoyo >= num[j]):
            sumpoyo -= num[j]
            cn[j] += 1
    for j in xrange(4):
        if cn[j] > 0:
            if cn[j] > 1:
                ans += str(cn[j]) + cha[j]
            else:
                ans += cha[j]
    print ans

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

  
int main(void){
    long long A,B,C;
    long long K;
    scanf("%lld %lld %lld %lld",&A,&B,&C,&K);

    //printf("%lld %lld %lld %lld\n",A,B,C,K);

    long long ans=A-B;
    if(K%2==0){
        if(ans>1000000000000000000) printf("Unfair\n");
        else printf("%lld\n",ans);
    }

    else{
        ans*=-1;
        if(ans>1000000000000000000) printf("Unfair\n");
        else printf("%lld\n",ans);
    }

    return 0;

    
    if(A==B && B==C){
        printf("0\n");
        return 0;
    }

    for(long long i=0;i<K;i++){
        long long AB=A+B;
        long long BC=B+C;
        long long CA=C+A;

        A=BC; B=CA; C=AB;
    }

    

    return 0;
}

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

// @@ !! LIM()

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

  ll N; cin >> N;
  vector<ll> A(N), B(N), C(N), D(N);
  for (ll i = 0; i < N; i++) cin >> A[i] >> B[i];
  for (ll i = 0; i < N; i++) cin >> C[i] >> D[i];
  vector red_done(N, false), blue_done(N, false);
  auto get_right_red = [&]() -> ll {
    ll imax = -1;
    ll xmax = -1;
    for (ll i = 0; i < N; i++) {
      if (red_done[i]) continue;
      if (xmax < A[i]) {
	imax = i;
	xmax = A[i];
      }
    }
    return imax;
  };
  auto get_paired_blue = [&](ll i) -> ll {
    ll jmin = -1;
    ll ymin = 1000;
    for (ll j = 0; j < N; j++) {
      if (blue_done[j]) continue;
      if (A[i] > C[j] || B[i] > D[j]) continue;
      if (D[j] < ymin) {
	jmin = j;
	ymin = D[j];
      }
    }
    return jmin;
  };
  ll cnt = 0;
  while (true) {
    ll i = get_right_red();
    if (i < 0) break;
    ll j = get_paired_blue(i);
    if (j >= 0) {
      cnt++;
      blue_done[j] = true;
    }
    red_done[i] = true;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3604
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long double t, x; cin>>t>>x;
	printf("%Lf", t/x);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [*map(int, input().split())] + [0]
dp_yen = [1000]*(n+1)
for day in range(n):
    dp_yen[day+1] = max(dp_yen[day], dp_yen[day] + dp_yen[day]//A[day] * (A[day+1] - A[day]))
print(dp_yen[n])


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> p;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		p.push_back(make_pair(x, y));
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int x = p[j].first - p[i].first;
			int y = p[j].second - p[i].second;
			int tmp = 0;
			for (int g = 0; g < n; g++) {
				for (int h = g + 1; h < n; h++) {
					if (p[h].first - p[g].first == x && p[h].second - p[g].second == y) {
						tmp++;
					}
					if (p[h].first - p[g].first == -x && p[h].second - p[g].second == -y) {
						tmp++;
					}
				}
			}
			ans = max(ans, tmp);
		}
	}
	cout << n - ans << endl;
	return 0;
}

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

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

    vector<long long int> a(N);
    int two = 0, four = 0;
    for( int i = 0; i < N; ++i ){
        cin >> a[i];
        if( a[i]%4 == 0 ) ++four;
        else if( a[i]%2 == 0 ) ++two;
    }


    if( N/2 <= four+two/2 ) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int a[200000];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int c,d;
        cin >> c >> d;
        a[c]++;
        a[d+1]--;
    }
    rep(i,n+5)a[i+1] += a[i];
//    rep(i,n+1)show(a[i]);
    int ans = 0;
    rep(i,n+1)if(a[i] == m)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
double w=0,s=0,MAX=-1;
int main()
{
   //freopen("data.in","r",stdin);
   //freopen("data.out,"w",stdout);
   double A,B,C,D,E,F;
   cin>>A>>B>>C>>D>>E>>F;
   double rate=E/(E+100);
   for(int i=0;i*A*100<=F;i++)
   {
   	   for(int j=0;j*B*100+i*A*100<=F;j++)
   	   {
   	   	   double r=F-(j*B*100+i*A*100);
   	       for(int k=0;k*C<=r;k++)
		   {
		         for(int q=0;q*D+k*C<=r;q++)
				 {
				 	double temp_rate=(k*C+q*D)/(k*C+q*D+j*B*100+i*A*100);
				 	if(temp_rate<=rate&&temp_rate>MAX)
				 	{
				 		MAX=temp_rate;
				 		w=j*B*100+i*A*100;
				 		s=k*C+q*D;
					 }
				 }  	
		   }	
	   }
   }
   cout<<w+s<<' '<<s<<endl;
   return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter
import sys

n = int(input())
a = list(map(int,input().split()))
cnt = Counter(a)
cntsort = sorted(cnt.items())[::-1]
h = 0
flg2 = False
for k, v in cntsort:
    if(v>=4 and flg2==False):
        print(k*k)
        sys.exit()
    elif(v>=2 and flg2==False):
        flg2 = True
        h = k
    elif(v>=2 and flg2==True):
        print(h*k)
        sys.exit()
else:
    print(0)
        

Measured memory_bytes: 21668
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else if(s=="Rainy") cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import numpy as np
import sys

read = sys.stdin.buffer.read

def main():
    n, m, c = map(int, input().split())
    l = list(map(int,input().split()))
    p = [list( map( int, input().split() ) ) for i in range(n)]
    
    count=0
    for sor in p:
        tmp=c
        for i, j in enumerate(sor):
            tmp=tmp+j*l[i]
        if tmp>0:
            count+=1
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14408
#!/usr/bin/env python3

n, m = map(int, input().split())
H = list(map(int, input().split()))
routes = { i:[] for i in range(1, n+1) }
good_ten = 0

for _ in range(m):
    a, b = map(int, input().split())
    routes[a].append(b)
    routes[b].append(a)

for i in routes.keys():
    for j in routes[i]:
        if H[j-1] >= H[i-1]:
            break
    else:
        good_ten += 1

print(good_ten)

Measured memory_bytes: 37928
/*package whatever //do not write package name here */

import java.util.*;
import java.io.*;

class Main {
    static int dp[];
    static boolean vis[];
    public static void dfs(int in,ArrayList<Integer>[]graph){
       
         vis[in]=true;
         for(int i=0;i<graph[in].size();i++){
             int cur=graph[in].get(i);
            if(!vis[cur])dfs(cur,graph);
             dp[in]=Math.max(dp[in],1+dp[cur]);
         
         }
       
    }
	public static void main (String[] args)throws IOException{
		//code
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String[]s=br.readLine().split("\\s+");
		
            int n=Integer.parseInt(s[0]);
            int m=Integer.parseInt(s[1]);
            

            ArrayList<Integer>[]graph=new ArrayList[n];
            for(int i=0;i<n;i++)graph[i]=new ArrayList<>();
		   
		    for(int i=0;i<m;i++){
                s=br.readLine().split("\\s+");
                int v=Integer.parseInt(s[0])-1;
                int u=Integer.parseInt(s[1])-1;
                graph[v].add(u);
                
            }

           vis=new boolean[n];
            dp=new int[n];
            
            int max=0;
            for(int i=0;i<n;i++){
                if(!vis[i]){
                  dfs(i,graph);
                }

            }
            for(int i=0;i<n;i++)max=Math.max(max,dp[i]);
            
         
        
            System.out.print(max);
		
		    
	
		
	}
}


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

string S;

int main(){
  cin >> S;
  int ans = 100010;

  int cnt = 0;
  rep(i, S.size()){
    if (i % 2 == 0){
      if (S[i] == '0') cnt ++;
    }
    if (i % 2 == 1){
      if (S[i] == '1') cnt ++;
    }
  }
  ans = min(ans, cnt);

  cnt = 0;
  rep(i, S.size()){
    if (i % 2 == 1){
      if (S[i] == '0') cnt ++;
    }
    if (i % 2 == 0){
      if (S[i] == '1') cnt ++;
    }
  }
  ans = min(ans, cnt);
  cout << ans << endl;
}


Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	sort(all(v));
	int ans = 0;
	for(int i = 0; i < n-2; i++){
		for(int j = i+1; j < n-1; j++){
			auto it = lower_bound(v.begin()+j+1, v.end(), v[i]+v[j]);
			it--;
			ans += it-v.begin();
			ans -= j;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3672
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func div(a,b int) int {
	return a/b
}

func gcd(c,d int) int {
	if c >=d {
		if c%d == 0 {
			return d
		}
		return gcd(d, c%d)
	}
	if d%c == 0 {
		return c
	}
	return gcd(c, d%c)
}

func main() {
	var a,b,c,d int
	fmt.Scan(&a, &b, &c, &d)

	dif := b -a +1
	com := gcd(c,d)
	co := com * c/com * d/com

	dif -= (div(b,c) - div(a-1,c))
	dif -= (div(b,d) - div(a-1,d))
	dif += div(b,co) - div(a-1,co)

	fmt.Println(dif)
}

Measured memory_bytes: 512
X = int(input())

def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True

for i in range(X, 1000000):
    if isPrime(i) == True:
        print(i)
        exit()

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

using namespace std;

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

typedef complex<double> P;
typedef vector<P> polygon;

double const eps = 1e-7;

polygon poly;

struct line : public vector<P> {
  line(P const& a, P const& b) {
    push_back(a), push_back(b);
  }
};

double dot(P a, P b) {
  return real(conj(a) * b);
}

double cross(P a, P b) {
  return imag(conj(a) * b);
}

int ccw(P const& p, P a, P b) {
  a -= p, b -= p;
  if(cross(a, b) > eps) return +1;
  if(cross(a, b) < -eps) return -1;
  if(dot(a, b) < -eps) return +2;
  if(norm(a) < norm(b)) return -2;
  return 0;
}

P crosspoint(line const& a, line const& b) {
  auto va = a[1] - a[0], vb = b[1] - b[0];
  double d = cross(vb, va);
  if(abs(d) < eps) return b[0];
  return a[0] + va * cross(vb, b[1] - a[0]) * (1.0 / d);
}

polygon convex_cut(polygon const& g, line const& l) {
  polygon ret;
  int n = g.size();
  rep(i, n) {
    auto curr = g[i % n], next = g[(i + 1) % n];
    if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
    if(ccw(l[0], l[1], curr) * ccw(l[0], l[1], next) < 0) {
      ret.push_back(crosspoint(line(curr, next), l));
    }
  }
  return ret;
}

double area(polygon const& g) {
  double ret = 0;
  rep(i, g.size()) {
    ret += cross(g[i], g[(i + 1) % g.size()]);
  }
  return abs(ret) / 2.0;
}

bool ok(P const& p) {
  double ph = area(poly) / 2.0;
  for(double rad = 0.0; rad < 2 * cos(-1); rad += 0.01) {
    line l = line(p, p + polar(1.0, rad));
    auto k = convex_cut(poly, l);
    if(abs((area(k) - ph) / ph) > eps) return false;
  }
  return true;
}

int main() {
  int N; cin >> N;
  P g;
  rep(i, N) {
    double x, y; cin >> x >> y;
    poly.push_back(P(x, y));
    g += P(x, y);
  }
  g /= N;
  if(N % 2 || !ok(g)) cout << "NA" << endl;
  else printf("%.10f %.10f\n", g.real(), g.imag());
  return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
using namespace std;

int N;
vector<vector<int>> vec;
vector<vector<int>> chi;
vector<int> par;

void dfs(int v){
    if(chi[v].size() == 0){
        vec[par[v]].push_back(0);
        return;
    }

    for(auto c : chi[v])
        dfs(c);

    if(v!=N){
        vector<int> &vv = vec[v];
        sort(vv.begin(), vv.end(), greater<int>());
        for(int i=0; i<vv.size(); i++)
            vv[i] += i + 1;
        vec[par[v]].push_back(*max_element(vv.begin(), vv.end()));
    }

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vec.resize(N+1);
    par.resize(N+1); chi.resize(N+1);
    for(int i=1; i<N; i++){
        int a;
        cin >> a;
        a--;
        par[i] = a;
        chi[a].push_back(i);
    }
    par[0] = N;
    chi[N].push_back(0);

    dfs(0);
    cout << vec[N][0] << endl;

    return 0;
}


Measured memory_bytes: 17792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int r,g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
    return 0;
}


Measured memory_bytes: 256
N = int (input ())
A = [int (x) for x in input().split()]
X = A[0]
P = 0
for i in range (N-1):
  if A[i+1] < X:
    P += X-A[i+1]
  elif A[i+1] > X:
    X = A[i+1]
print (P)

Measured memory_bytes: 32016
import numpy as np
N,M = map(int, input().split())

a = np.zeros(M)
b = np.zeros(M)
for i in range(M):
  a[i],b[i] = map(int, input().split())
  
for i in range(1,N+1):
  print((a==i).sum() + (b==i).sum())


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

int alphabet[26];

int main()
{
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); ++i) ++alphabet[S[i] - 'a'];
    for(int i = 0; i < 26; ++i) if(alphabet[i] > 1) {
        cout << "no" << endl; return 0;
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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


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

    vector<long double> x(n);

    long double ans = 0;
    for(int i = 0; i < n; i++){
        long double price;
        string type;
        cin >> price >> type;
        if(type == "BTC"){
            price *= 380000.0;
        }
        ans += price;
    }

    cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t[2],a[5][100010],to[100010];
char buffer[10000010],*hed;
inline char Getchar(){
    return *hed++;
}
inline int rd(){
    register int x=0;
    char c;
    do c=Getchar();
    while(!isdigit(c));
    do{
        x=(x<<1)+(x<<3)+(c^48);
        c=Getchar();
    }while(isdigit(c));
    return x;
}
inline int abs(int x){
    return x>=0?x:-x;
}
int main(){
    int len=fread(buffer,1,10000000,stdin);
    hed=buffer;
    n=rd();
    for(int i=1;i<=3;i++)
        for(int j=1;j<=n;j++)
            a[i][j]=rd();
    for(register int i=1;i<=n;i++){
        to[i]=a[2][i]/3+1;
        if(!((a[1][i]-a[2][i]==-1&&a[2][i]-a[3][i]==-1&&a[1][i]%3==1)||(a[1][i]-a[2][i]==1&&a[2][i]-a[3][i]==1&&!(a[1][i]%3)))||(abs(i-to[i])&1)){
            puts("No");
            return 0;
        }
        t[i&1]^=(a[1][i]>a[2][i]);
    }
    for(register int i=1;i<=n;i++){
        while(to[i]!=i){
            t[i&1^1]^=1;
            swap(to[i],to[to[i]]);
        }
    }
    puts(t[0]||t[1]?"No":"Yes");
    return 0;
}

Measured memory_bytes: 7164
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
tmp = 0
for i, a in enumerate(A[:-1]):
    tmp -= pow(-1, i) * a
ans[0] = (A[-1] - tmp) // 2
for i in range(1, N):
    ans[i] = A[i - 1] - ans[i - 1]
print(' '.join(map(lambda x: str(x*2), ans)))


Measured memory_bytes: 97208
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		if (a + b >= x && a <= x){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21716
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[100002],js,os;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2)js++;
		else os++;
	}
	if(js%2)printf("NO");
	else printf("YES");
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;

    return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import statistics
N = int(input())
A = [int(a)-(i+1) for i, a in enumerate(input().split())]
ans = float('inf')
medi = int(statistics.median(A))
for b in range(medi-1, medi+2):
  ans = min(ans, sum([abs(A[i]-b) for i in range(N)]))
print(ans)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int ab, bc, ca;
  cin >> ab >> bc >> ca;

  double ans = ab * bc / 2.0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate


class CoeffTable:
    def __init__(self, n):
        self.n = n
        if n == 2:
            (self.p2, self.p1, self.m1, self.m2) = (0, 1, 1, 0)
        if n % 2 == 0:
            self.p1 = self.m1 = 1
            self.p2 = self.m2 = (n - 1) // 2
        else:
            self.p1 = 0
            self.m1 = 2
            self.p2 = (n - 1) // 2
            self.m2 = (n - 2) // 2
    def reverse(self):
        (self.p2, self.p1, self.m1, self.m2) = (
            self.m2,
            self.m1,
            self.p1,
            self.p2,
        )

    def cumsum(self):
        return list(accumulate([self.p2, self.p1, self.m1, self.m2]))



def main(n, seq):
    seq = sorted(seq, reverse=True)
    coeff = CoeffTable(n)
    cm = coeff.cumsum()
    ans1 = (
        2 * sum(seq[0 : cm[0]])
        + 1 * sum(seq[cm[0] : cm[1]])
        - 1 * sum(seq[cm[1] : cm[2]])
        - 2 * sum(seq[cm[2] : cm[3]])
    )
    coeff.reverse()
    rcm = coeff.cumsum()
    ans2 = (
        2 * sum(seq[0 : rcm[0]])
        + 1 * sum(seq[rcm[0] : rcm[1]])
        - 1 * sum(seq[rcm[1] : rcm[2]])
        - 2 * sum(seq[rcm[2] : rcm[3]])
    )
    ans = max(ans1, ans2)
    print(ans)
    return


if __name__ == "__main__":
    n = int(input())
    sample = []
    for _ in range(n):
        sample.append(int(input()))
    main(n, sample)


Measured memory_bytes: 8328