akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;
 
const int INF = 1e9 + 7;
 
using namespace std;
 
int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;

	priority_queue<
	    pair<int, int>,
	    vector<pair<int, int>>,
	    greater<pair<int, int>>> job;
	rep (i, 0, n) {
	    int tmp1, tmp2;
	    cin >> tmp1 >> tmp2;
	    job.push(make_pair(tmp1, tmp2));
	}

	priority_queue<int> select;
	int res = 0;

	rep (i, 1, m+1) {
	    while (job.size() > 0) {
		if (job.top().first <= i) {
		    select.push(job.top().second);
		    job.pop();
		} else {
		    break;
		}
	    }
	    if (select.size() == 0)
		continue;
	    res += select.top();
	    select.pop();
	}

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


Measured memory_bytes: 1908
n = int(input())
sp = []
for i in range(n):
    sp.append(list(input().split()))
ans = sorted(sp,key=lambda x:int(x[1]),reverse=True)
ans1 = sorted(ans,key=lambda x:x[0])
for i in ans1:
    print(sp.index(i) + 1)

Measured memory_bytes: 3060
//
//   “Daḷhaṃ sikkhatha santiyā.” - Utthana Sutta (Sutta Nipata) 
//    Saket Saumya 
//    MAY 02 2020
//

#include<bits/stdc++.h>

using namespace std;


#define ll long long 
#define all(x) x.begin(),x.end()
#define endl '\n'
#define RESET   "\033[0m"
#define RED     "\033[31m"      /* Red */
#define what_is(x) cerr << RED << #x << " is " << x  << RESET << endl;
 

const long long MOD = 1e9+7 ;
const int N=(2e5)+5;
const long long INF=1LL << 57;
 
// Data Structures
vector <ll> vec(N),v1, v2, v3;
vector < pair <ll, pair < ll , ll >  > > vp, vp1, vp2;
set < ll > se;
unordered_set <ll > use;
multiset < ll > ms;
map <  ll, ll > mp, done, mp1;
unordered_map < string, ll > ump;


ll t, n, m, p, q, x, y, a, b, c, mini= LLONG_MAX, maxi= LLONG_MIN,res, ans;


queue <pair <ll, ll > > bfsq;
ll vis[N];
vector < pair <ll, ll> >  adj[N], adj1[N];
ll visited[1005][1005] ;
char mat[1005][1005];
ll dp[105][10005];


//<-------------------------------------------CODE STARTS HERE --------------------------------------------------------------->// 


signed  main(){
        
            ios_base::sync_with_stdio(false);
            cin.tie(nullptr);cout.tie(nullptr);
          
            cin >> n;
            cin >> a>> b;
            bool flag = false;
            for (int i=a; i<=b; ++i){
                    if (i % n == 0){
                        flag = true;
                        break;
                    }    
            }
            if (flag)           cout << "OK" << endl;
            else                cout << "NG" << endl;
























                
                
                
 
                
 
 
 
        
        
 
 
 
}       
       
 
 
       
       
       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 
       
 
 
       
       
       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 

       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 
       
 
 
       
       
       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 




Measured memory_bytes: 14176
#include <stdio.h>

#define min(x, y) ((x) < (y) ? (x) : (y))

int main(void) {
	int n, k;

	scanf("%d %d", &n, &k);

	int cur = 1;
	for (int i = 0; i < n; i++)
		cur = min(cur * 2, cur + k);

	printf("%d\n", cur);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <vector>
#include <iostream>
#include <functional>

struct cmp
{
    bool operator()(std::pair<int, int> p1, std::pair<int, int> p2)
    {
        const auto min1 = p1.first > p1.second ? p1.second : p1.first;
        const auto max1 = p1.first < p1.second ? p1.second : p1.first;
        const auto min2 = p2.first > p2.second ? p2.second : p2.first;
        const auto max2 = p2.first < p2.second ? p2.second : p2.first;

        if (min1 == min2)
            return max1 < max2;
        else
            return min1 < min2;
    }
};

int main()
{
    int n;
    long long max_comfort = 0;
    std::vector<int> players;
    std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, cmp> pq;
    players.reserve(200000);

    std::cin >> n;

    for (int i = 0; i < n; i++)
    {
        int a;
        std::cin >> a;
        players.push_back(a);
    }

    std::sort(players.begin(), players.end(), std::greater<int>());

    pq.push({players[0], players[0]});

    for (int i = 1; i < n; i++)
    {
        const auto top = pq.top();
        pq.pop();
        max_comfort += top.first < top.second ? top.first : top.second;

        pq.push({players[i], top.first});
        pq.push({players[i], top.second});
    }

    printf("%lld", max_comfort);

    return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	string s;
	cin>>s;
	if(c<d){
		if(b<a){
			bool ans=false;
			for(int i=a+1;i<=c+1;i++){
				if(s[i]=='.'&&s[i-1]=='.'&&s[i-2]=='.'){
					ans=true;
					break;
				}
			}
			if(ans==false){
				cout << "No"<<endl;
				return 0;
			}
		}
	}
	if(d<c){
		if(a<b){
			bool ans=false;
			for(int i=b+1;i<=d+1;i++){
				if(s[i]=='.'&&s[i-1]=='.'&&s[i-2]=='.'){
					ans=true;
					break;
				}
			}
			if(ans==false){
				cout << "No"<<endl;
				return 0;
			}
		}
	}
	ll L=min(a,b),R=max(c,d);
	for(int i=L+1;i<=R;i++){
		if(s[i]=='#'&&s[i-1]=='#'){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 640
K = int(input())


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)
print(ans)


Measured memory_bytes: 76676
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    double n;
    double max_n = 0, min_n = INF;
    while(cin >> n) {
        max_n = max(max_n, n);
        min_n = min(min_n, n);
    }
    cout << max_n - min_n << endl;
    return 0;
}

Measured memory_bytes: 1280
from collections import Counter
from operator import mul
from functools import reduce


def nCr(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


n = int(input())
a = list(map(int, input().split()))

ac = dict(Counter(a))

ans = 0
for k, v in ac.items():
    if v < 2:
        ac[k] = (v, 0)
    else:
        c = nCr(v, 2)
        ac[k] = (v, c)
        ans += c

for i in a:
    v = ac[i]
    if v[0] - 1 < 2:
        print(ans - v[1])
    else:
        print(ans - v[1] + nCr(v[0] - 1, 2))


Measured memory_bytes: 28584
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

const int MAX_LEN = 100000;

int main() {
  string s, t;
  int q, sl[MAX_LEN+2] = {0}, tl[MAX_LEN+2] = {0};
  cin >> s >> t >> q;
  for (int i=0; i<s.length(); i++) {
    sl[i+1] = sl[i];
    if (s[i] == 'A') {
      sl[i+1]++;
    } else if (s[i] == 'B') {
      sl[i+1] += 2;
    }
  }
  for (int i=0; i<t.length(); i++) {
    tl[i+1] = tl[i];
    if (t[i] == 'A') {
      tl[i+1]++;
    } else if (t[i] == 'B') {
      tl[i+1] += 2;
    }
  }
  for (int i=0; i<q; i++) {
    int a, b, c, d, scnt, tcnt;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    scnt = sl[b] - sl[a-1];
    tcnt = tl[d] - tl[c-1];
    if (scnt % 3 == tcnt % 3) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        long[] numbers = new long[n];
        int ans = 0;
        
        for(int i = 0; i < n; i++){
            numbers[i] = Long.parseLong(input[i]);
        }
        
        label:
        while(true){
            for(int i = 0; i < n; i++){
                if(numbers[i] % 2 == 0){
                    numbers[i] /= 2;
                }else{
                    break label;
                }
            }
            ans++;
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32640
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vi a(n);
	for (auto& i : a)
		cin >> i;
	k = min(k, n);
	SORT(a);
	int s = 0;
	for (int i = 0; i < n - k; i++)
		s += a[i];
	cout << s << '\n';
}

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

int ans[100000];
int main(){
   int n;
   cin >> n;
   
   for(int x=1;x<=100;++x){
      for(int y=1;y<=100;++y){
           for(int z=1;z<=100;z++){
         int a= x*x+y*y+z*z+x*y+y*z+z*x;
         ans[a]++;
       }
      }
   }
   for(int i=1;i<=n;i++) cout << ans[i] << endl;
}


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

#define L 100005

typedef struct{
  char name[100];
  int t;
}Pro;

Pro Q[L];
int head,matu,n;

void enque(Pro a){
  Q[matu]=a;
  matu=(matu+1)%L;
}

Pro dque(){
  Pro a=Q[head];
  head=(head+1)%L;
  return a;
}

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

int main(){
  int i,q,c,el=0;
  Pro a;

  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  matu=n+1;

  while(head!=matu){
    a=dque();
    c=min(q,a.t);
    a.t-=c;
    el+=c;

    if(a.t>0)enque(a);
    else {
      printf("%s %d\n",a.name,el);
    }
  }

  return 0;
}

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

using namespace std;
typedef pair<int, pair<string, int>> vp;


bool compare_with_restaurant_name(vp left, vp right) {
    return left.second.first < right.second.first;
}

bool compare_with_score(vp left, vp right) {
    return left.second.second > right.second.second;
}


int main() {
    int n; cin >> n;
    string s; int p;

    vector<pair<string, int>> restaurants(n);
    vector<vp> restaurants_with_idxs(n);

    for (int i=0; i<n; ++i) {
        cin >> s >> p;
        restaurants[i] = make_pair(s, p);
        restaurants_with_idxs[i] = make_pair(i+1, restaurants[i]);
    }

	// first of all, we sort restaurants using by their name
    sort(restaurants_with_idxs.begin(), restaurants_with_idxs.end(), compare_with_restaurant_name);


	// collect segments of restaurants whose names are the same
    vector<pair<int, int>> partisions;
    int left  = 0;
    int right = 0;
    string prev_city_name = restaurants_with_idxs[0].second.first;

    for (int i=1; i<n; ++i) {
        if (restaurants_with_idxs[i].second.first == prev_city_name) {
            right++;
        }
        else {
            partisions.push_back(make_pair(left, right));
            left  = i+1;
            right = i+1;
        }
        
        prev_city_name = restaurants_with_idxs[i].second.first;
    }

    if (left != right) {
        partisions.push_back(make_pair(left, right));
    }


	// sort restaurants whose names are the same by their points
    int left_part, right_part;
    int cursor = 0;
    int partision_length = partisions.size();

    for (pair<int, int> partision: partisions) {
        left_part  = partision.first;
        right_part = partision.second;

        if (cursor == 0) right_part++;
        if (cursor != 0)  left_part--;

        sort(restaurants_with_idxs.begin()+left_part,
             restaurants_with_idxs.begin()+right_part,
             compare_with_score);

        cursor++;
    }


    for (vp restaurants_with_idx: restaurants_with_idxs) {
        cout << restaurants_with_idx.first << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int64_t> a(n);
  for (int i = 0; i != n; ++i) {
    cin >> a[i];
  }
  int64_t min = a[0], max = a[0];
  int64_t sum = 0;
  for (auto x : a) {
    if (x < min)
      min = x;
    else if (max < x)
      max = x;
    sum += x;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1000000000
#define MOD 1000000007

int main(){

    string a;
    cin >> a;

    if(a.size()>=6){
        if((a[2]==a[3])&&(a[4]==a[5])){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
    else{
        cout << "No\n";
    }

}







Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;

    string ans = "yes";
    int n = s.size();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j && s[i] == s[j]) {
                ans = "no";
                break;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    
    int m, k;
    
    cin >> m;
    cin >> k;
    
    int op;
    
    int cards[2*m];
    int temp[2*m];
    
    for(int j = 0; j < 2*m; j++) {
        cards[j] = j+1;
    }
     
    for(int i = 0; i < k; i++) {
        cin >> op;
        
        if(op == 0) {
            
            for(int x = 0; x < 2*m; x++)
                {
                    temp[x] = cards[x];
     
                }            
            for(int l = 0; l < m; l++) {
                cards[2*l] = temp[l];
                cards[2*l+1] = temp[m+l];
            }
        } else {
             for(int x = 0; x < 2*m; x++)
                {
                    temp[x] = cards[x];
     
                }     
            for(int l = 0; l < 2*m; l++) {
                cards[l] = temp[(l + op) % (2*m)];
            }
        }
        
        
    }
    
    for(int i = 0; i < 2*m; i++) {
        cout << cards[i] << endl;
    }
    
    
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;
ll n, k;

//level n ,layer x

ll fun(ll n, ll x)
{
	if (n == 0)
		return (x <= 0 ? 0 : 1);
	if (x <= lay[n - 1] + 1)
		return fun(n - 1, x - 1);
	return p[n - 1] + 1 + fun(n - 1, x - 1 - (lay[n - 1] + 1));
	
}

int main()
{
	cin >> n >> k;
	lay.push_back(1), p.push_back(1);
	for (int i = 1; i <= n; i++)
	{
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int BUBEN = 2200;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vi64 a(n);
    forn(i, n) cin >> a[i];
    map< vector<pi64>, int > m;
    for (i64 x: a) {
        map<i64, int> v;
        i64 y = x;
        for (int i = 2; i <= BUBEN; ++i) {
            int z = 0;
            while (y % i == 0) y /= i, ++z;
            if (z % 3 == 1) v[i] = 1;
            if (z % 3 == 2) v[i] = -1;
        }
        if (y > 1) {
            i64 t = sqrt(y);
            while (t * t < y) ++t;
            if (t * t == y) v[t] = -1;
            else v[y] = 1;
        }
        vector<pi64> vv;
        for (auto w: v) vv.pb(mp(w.fi, w.se));
        ++m[vv];
    }

    int ans = 0;
    for (auto w: m) {
        vector<pi64> v = w.fi, u = v;
        if (v.empty()) {
            ++ans;
            continue;
        }
        for (auto &x: u) x.se = -x.se;
        if (m.count(u) && u < v) continue;
        int res = w.se;
        if (m.count(u)) uax(res, m[u]);
        ans += res;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 15488
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(void){
    double n; cin >> n;
    int a = (n/2.0)+1;

    if((int)n%2==0) cout << 0.50;
    else cout << a/n;
    return 0;
}

Measured memory_bytes: 256
def f(A, s):
    X = [0] * N
    q = []
    a = 0
    for i in range(N):
        b = a
        X[i] = X[i-1]
        a = A[i]
        if a * s < 0:
            X[i] += 1
            a *= -2

        if i == 0:
            continue
            
        r = b/a
        while r >= 4:
            q.append(i)
            r /= 4

        while r < 1:
            X[i] += 2 * (i - (0 if len(q) == 0 else q.pop()))
            r *= 4
            
    return X

N = int(input())
A = [int(a) for a in input().split()]
X = f(A,-1)
Y = f(A[::-1],1)

mi = min(X[-1], Y[-1])
for i in range(N-1):
    mi = min(mi, X[i] + Y[-2-i])
print(mi)

Measured memory_bytes: 30484
#include<iostream>
#include<string>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(void){
    int ans=0,A,B;
    cin >> A >> B;
    if(A<=8&&B<=8){
        printf("Yay!");
    }else{
        printf(":(");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<ctime>
#include<map>
#include<string>
#include<vector>
#include<set>

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)
#define Cor(i,l,r) for (int i = l; i >= r; --i)
#define Fill(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define MP make_pair
#define PII pair<int,int>
#define flt double
#define INF (0x3f3f3f3f)
#define MaxN 1020304
#define MaxNode 1020304
#define MD 1000000007
#define ele(x) (1 << ((x) - 1))
#define PFF pair<flt,flt>
#define UPD(a,b) { a = min(a,b); }

const flt eps = 1e-7;
int dcmp(flt x) {
	return (x < -eps) ? -1 : ((x > eps) ? 1 : 0);
}

PFF operator - (PFF a,PFF b) { return MP(a.FI - b.FI,a.SE - b.SE); }
PFF operator + (PFF a,PFF b) { return MP(a.FI + b.FI,a.SE + b.SE); }
PFF operator * (PFF a,flt b) { return MP(a.FI * b,a.SE * b); }
flt operator * (PFF a,PFF b) { return a.FI * b.SE - a.SE * b.FI; }
flt operator / (PFF a,PFF b) { 
	if (dcmp(b.FI)) return a.FI / b.FI;
	return a.SE / b.SE;
}

flt dot(PFF a,PFF b) { return a.FI * b.FI + a.SE * b.SE; }
flt mod(PFF a) {
	return sqrt(a.FI * a.FI + a.SE * a.SE); 
}

bool Longer(PFF a,PFF b,PFF c) {
	return dcmp((c - a) / (b - a) - 1.) >= 0;
}

flt xmul(PFF a,PFF b,PFF c) {
	return (c - a) * (c - b);
}

PFF GetInter(PFF a,PFF b,PFF c,PFF d) {
	PFF as = a, ae = a + b;
	PFF bs = c,be = c + d;
	flt u = xmul(as,ae,bs);
	flt v = xmul(ae,as,be);
	if (dcmp(u + v) == 0) return MP(-INF,-INF);
	return MP(bs.FI * v + be.FI * u,bs.SE * v + be.SE * u) * (1. / (u + v));
}

int n;
PFF a[MaxN]; pair<int,flt> f[1111][11][11];

int main() {
	//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	while (scanf("%d",&n) != EOF && n) {
		For(i,1,n) scanf("%lf%lf",&a[i].FI,&a[i].SE);
		int All = (1 << n) - 1;
		For(i,1,n) For(j,1,n) For(k,0,All) f[k][i][j] = MP(INF,INF);
		For(i,1,n) For(j,1,n) if (i != j) {
			f[ele(i) | ele(j)][i][j] = MP(0,mod(a[i] - a[j]));
		}
		For(S,0,All) For(i,1,n) For(j,1,n) if (f[S][i][j].FI < n) {
			For(k,1,n) if (!(S & ele(k))) {
				int tInc = 1;
				if (dcmp(fabs((a[k] - a[i]) * (a[i] - a[j]))) == 0 && Longer(a[j],a[i],a[k])) tInc = 0; 
				UPD(f[S | ele(k)][k][i],MP(f[S][i][j].FI + tInc,f[S][i][j].SE + mod(a[k] - a[i])));
			}
			For(k,1,n) if (!(S & ele(k))) {
				For(l,1,n) if (!(S & ele(l)) && k != l) {
					if (dcmp((a[i] - a[j]) * (a[l] - a[k])) != 0) {
						if (k == 4 && l == 3) {
							int z = k;
						}
						PFF tInter = GetInter(a[j],a[i] - a[j],a[k],a[l] - a[k]);
						if (Longer(a[j],a[i],tInter) && Longer(a[l],a[k],tInter)) {
							UPD(f[S | ele(k) | ele(l)][l][k],MP(f[S][i][j].FI + 1,f[S][i][j].SE + mod(tInter - a[i]) + mod(tInter - a[l])));
						}
					}
				}
			}
		}
		pair<int,flt> ans = MP(INF,INF);
		For(i,1,n) For(j,1,n) ans = min(ans,f[All][i][j]);
		printf("%d %.12lf\n",ans.FI,ans.SE);
	}
	return 0;
}

Measured memory_bytes: 19284
S = input()
Q = int(input())

a = []
b = []
rev = 0

for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        a, b = b, a
        rev += 1
    else:
        if q[1] == '1':
            a.append(q[2])
        else:
            b.append(q[2])

#print(a)
#print(b)
if rev % 2 == 1:
    S = S[::-1]
ans = ''.join(a[::-1]) + S + ''.join(b)
print(ans)

Measured memory_bytes: 6252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    int ab=0,a=0,b=0,aob=0;
    for(int i = 0; i < n; i++) {
        string s;cin >> s;
        if(s[0]=='B') b++;
        if(s[s.size()-1]=='A') a++;
        if(s[0]=='B' && s[s.size()-1]=='A') aob++;

        for(int i = 0; i < s.size()-1; i++) {
            if(s[i]=='A' && s[i+1]=='B') ab++;
        }
    }

    if(aob==a && a==b && a>0){
        ab += a-1;
    }
    else ab += min(a,b);

    cout << ab << endl;

    return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-

T = 0
F = 2
C = 4

s = input()
q = int(input())

cnt = 0

front = ""
back = ""

for i in range(q):
    query = input()

    if query[T] == "1":
        cnt += 1
        continue

    # モード通常
    if cnt % 2 == 0:
        if query[F] == "1":
            front +=  query[C]
        else:
            back += query[C]

    # モード反転
    else:
        if query[F] == "1":
            back += query[C]
        else:
            front +=  query[C]


# print(cnt)
# print(front)
# print(s)
# print(back)

# moji = front+s+back

if cnt % 2 == 0:
    print(front[::-1]+s+back)
    pass
else:
    print(back[::-1]+s[::-1]+front)
    # print(s[::-1])



Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int n,k,a[30000],j;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		j+=a[i];
	}
		
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++)
	{
		j-=a[i];
	}
	cout<<j<<endl;
    return 0;
}

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

int main(){
  int N;
  int diff;
  cin >> N;
  int a[N+10];
  for(int i = 0;i<N;i++){
	cin >> a[i];
  }
  sort(a,a+N,greater<>());
  for(int i = 0;i<N;i++){
    if(i%2 == 0) diff += a[i];
    if(i%2 == 1) diff -= a[i];
  }
  cout << diff << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++) cin >> a[i];
  bool used[N];
  fill(used, used + N, false);

  int ans = 0;
  for(int i = 0; i < N; i++){
    int to = a[i] - 1;
    if(!used[i] && !used[to] && a[to] == i + 1){
      ans++;
      used[i] = true;
      used[to] = true;
    }
  }

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


Measured memory_bytes: 768
#include<cstdio>
#include<queue>
#include<algorithm>
#define	LL long long
#define For(i, a, b) for(register int i = a; i <= b; ++i)
using namespace std;
const int maxn = 2e5 + 5;
struct _01 {
	int c0, c1, id;
	bool operator < (const _01 & A) const {
		return 1ll * c0 * A.c1 < 1ll * A.c0 * c1;
	}
};
priority_queue<_01 > q;
int fa[maxn], n, a, u, v, cnt[maxn][2];
LL ans;

namespace DSU {
	int fa[maxn];
	void init(int n) {For(i, 0, n) fa[i] = i;}
	int find(int x) {return x == fa[x] ? x : fa[x] = find(fa[x]);}
	void combine(int a, int b) {fa[find(a)] = find(b);}
}

int main() {
	scanf("%d", &n), DSU::init(n);
	For(i, 2, n) scanf("%d", &fa[i]);
	For(i, 1, n) {
		scanf("%d", &a), u = a == 0, v = a == 1, cnt[i][a] = 1;
	}
	For(i, 2, n) q.push((_01){cnt[i][0], cnt[i][1], i});
	_01 now;
	while(!q.empty()) {
		now = q.top(), q.pop();
		u = DSU::find(now.id);
		if(cnt[u][0] == now.c0 && cnt[u][1] == now.c1) {
			v = DSU::find(fa[u]);
			ans += 1ll * cnt[v][1] * cnt[u][0];
			cnt[v][1] += cnt[u][1];
			cnt[v][0] += cnt[u][0];
			DSU::combine(u, v);
			if(v != 1) q.push((_01) {cnt[v][0], cnt[v][1], v});
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,m;
    while(cin >>n>>m,n){
        vector<int> a(n);
        rep(i,n) cin >>a[i];

        int ans = -1;
        rep(i,n)rep(j,i){
            if(a[i]+a[j] <= m) ans = max(ans, a[i]+a[j]);
        }

        if(ans==-1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
		int[] c = new int[n];
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			for(int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int[][] b = bi(n);
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < (int)Math.pow(2, n); i++) {
			int[] buy = b[i];
			int[] total = new int[m];
			int money = 0;
			for(int j = 0; j < n; j++) {
				money += buy[j] * c[j];
				for(int k = 0; k < m; k++) {
					total[k] += (int) (buy[j] * a[j][k]);
				}
			}
			boolean check = true;
			for(int j = 0; j < m; j++) {
				if(total[j] < x) {
					check = false;
					break;
				}
			}
			if(check && ans > money) {
				ans = money;
			}
		}
		if(ans == Integer.MAX_VALUE) {
			ans = -1;
		}
			
		System.out.println(ans);
	}
	
	static int[][] bi(int n) {
		int all = (int)Math.pow(2, n);
		int[][] a = new int[all][n];
		for(int i = 0; i < all; i++) {
			Arrays.fill(a[i], 0);
			int x = 0;
			int num = i;
			while(num >= 2) {
				a[i][x] = num%2;
				x++;
				num /= 2;
			}
			a[i][x] = num;
		}
		return a;
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 35180
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

struct Operate{int sx,sy,gx,gy;};

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

    int h,w;cin>>h>>w;
    vector<vector<int>> a(h,vector<int>(w));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>a[i][j];
      }
    }
    vector<Operate> v;
    for(int i=0;i<h;i++){
      if(i%2==0){
        for(int j=0;j<w;j++){
          if(a[i][j]%2==0) continue;
          int gx,gy;
          if(j==w-1){
            gx=i+1; gy=j;
          }
          else{
            gx=i; gy=j+1;
          }
          if(gx<0 || h<=gx || gy<0 || w<=gy) continue;
          v.push_back(Operate{i,j,gx,gy});
          a[i][j]--;a[gx][gy]++;
        }
      }
      else{
        for(int j=w-1;j>=0;j--){
          if(a[i][j]%2==0) continue;
          int gx,gy;
          if(j==0){
            gx=i+1; gy=j;
          }
          else{
            gx=i; gy=j-1;
          }
          if(gx<0 || h<=gx || gy<0 || w<=gy) continue;
          v.push_back(Operate{i,j,gx,gy});
          a[i][j]--;a[gx][gy]++;
        }
      }
    }
    cout<<v.size()<<endl;
    for(int i=0;i<(int)v.size();i++){
      cout<<v[i].sx+1<<" "<<v[i].sy+1<<" "<<v[i].gx+1<<" "<<v[i].gy+1<<endl;
    }
}


Measured memory_bytes: 5236
#include<stdio.h>
int main() {
  int i, j, n;
  while (scanf("%d", &n) != EOF) {
    for (j = 0; j < 10; j ++) {
      if (n & 1 << j) {
	printf("%d", 1 << j); break;
      }
    }
    for (i = j + 1; i < 10; i ++) {
      if (n & 1 << i) printf(" %d", 1 << i);
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main() {
  while (true) {
    string s;
    cin >> s;
    if (s == "#") break;

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, b--, c--, d--;
    int h = 1, w = 0;
    vector<string> board;
    string t = "";
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '/') {
        board.emplace_back(t);
        t = "";
        h++;
        w = 0;
      } else {
        if (s[i] == 'b') {
          t += 'b';
          w++;
        } else {
          for (int j = 0; j < s[i] - '0'; j++) {
            w++;
            t += '.';
          }
        }
      }
    }
    board.emplace_back(t);

    board[a][b] = '.';
    board[c][d] = 'b';

    string ans = "";
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (board[i][j] == 'b') {
          ans.push_back('b');
        } else {
          if (!isdigit(ans.back()))
            ans.push_back('1');
          else
            ans.back() += 1;
        }
      }
      ans += '/';
    }
    ans.pop_back();
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int buff1 =x-a;
		int buff2 = x-b;

		if(buff1<0) {
			buff1=buff1*-1;
		}
		if(buff2<0) {
			buff2=buff2*-1;
		}
		if(buff1>=buff2) {
			System.out.println("B");
		}else {
			System.out.println("A");
		}


	}

	public static long res(long n) {
		if(n<2) {
			return 1;
		}

		return n*res(n-2);
	}
}




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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int n, k;
    cin >> n >> k;
    vl a(n);
    rep (i, n) cin >> a[i];


    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4776
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    P = [ni() for _ in range(n)]
    p = max(P)
    print(sum(P) - p // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 3000;
double prob[N][N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  prob[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    double p; cin >> p;
    prob[i][0] = prob[i - 1][0] * (1 - p);
    for (int j = 1; j <= i; j++) {
      prob[i][j] = prob[i - 1][j] * (1 - p) + prob[i - 1][j - 1] * p;
    }
  }
  double ans = 0;
  for (int h = (n + 1) / 2; h <= n; h++) {
    ans += prob[n][h];
  }
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}


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

int main() {
  int s;
  cin >> s;
  int s1 = s / 100;
  int s2 = (s % 100) / 10;
  int s3 = s % 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
import itertools

N = int(input())

Ss = ['M', 'A', 'R', 'C', 'H']
I = set(['M', 'A', 'R', 'C', 'H'])
D = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
l = []
for i in range(N):
    S = str(input())
    s = S[0]
    if (s in I):
        D[s] = D[s]+1

cmbs = itertools.combinations(Ss, 3)

p = 0
for cmb in cmbs:
    i,j,k = cmb
    if (D[i] == 0 or D[j] == 0 or D[k] == 0):
        continue
    else:
        p += D[i] * D[j] * D[k]

k = 0
for _,j in D.items():
    if j != 0:
        k += 1

if k < 3:
    print(0)
else:
    print(int(p))


Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
using namespace std;
const long double eps = 1.0e-5L;
int Q; long double a, b, c, d;
int main() {
	cin >> Q;
	while (Q--) {
		cin >> a >> b >> c >> d;
		b *= 1 / a, c *= 1 / a, d *= 1 / a;
		long double l = -1.0e+6L, r = 1.0e+6L;
		for (int i = 0; i < 70; i++) {
			long double m = (l + r) / 2;
			if (m * m * m + b * m * m + c * m + d > 0) r = m;
			else l = m;
		}
		long double g1 = b + l, g0 = c + b * l + l * l;
		long double e = g1 * g1 - 4 * g0;
		int ret1 = 0, ret2 = 0;
		if (l > eps) ret1++;
		if (l < -eps) ret2++;
		if (e > -eps) {
			long double s = (e > eps ? sqrt(e) : 0);
			long double t1 = (-g1 - s) / 2;
			long double t2 = (-g1 + s) / 2;
			if (t1 > eps) ret1++;
			if (t1 < -eps) ret2++;
			if (t2 > eps) ret1++;
			if (t2 < -eps) ret2++;
		}
		cout << ret1 << ' ' << ret2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define N 305 
using namespace std;
int n,k,mod;
int c[N][N],f[N][N],sum[N][N];

int main()
{
	cin>>n>>k>>mod;
	c[0][0] = 1;
	for(int i=1;i<N;++i)
	{
		c[i][0] = 1;
		for(int j=1;j<N;++j) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
	for(int i=0;i<=k;++i) f[1][i] = 1,sum[1][i] = k - i + 1;
	for(int i=2;i<=n + 1;++i)
	{
		for(int j=k;j>=0;--j)
		{
			for(int t = i - 1;t;--t)
			{
				f[i][j] = (f[i][j] + 1ll * f[i - t][j] * c[i - 2][t - 1]  % mod * sum[t][j + 1] % mod) % mod;
			}
			sum[i][j] = (sum[i][j + 1] + f[i][j]) % mod;
		}
	}
	cout<<f[n + 1][0]<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%s\n",c%gcd(a,b)?"NO":"YES");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int i, x, y, z, a, flag = 0;

  scanf("%d %d", &x, &y);

  if(x<y){
    z = x;
  }else if(x>y){
    z = y;
    flag = 1;
  }else{
    flag = 2;
  }
      

    if(flag == 0){
    for(i = y%x; i > 0; i--){
      if(y % i == 0){
	if(x % i == 0){
	  printf("%d\n", i);
	  break;
	}
      }
    }
    }else if(flag == 1){
    for(i = x%y; i > 0; i--){
      if(x % i == 0){
	if(y % i == 0){
	  printf("%d\n", i);
	  break;
	}
      }
    }
    }else{
      printf("%d\n", x);
    }
      
  
  return 0;
}



Measured memory_bytes: 2144
import sys
import math
from collections import deque
import bisect

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
	A, B, Q = NMI()
	S = [-float("inf")] + [NI() for _ in range(A)] + [float("inf")]
	T = [-float("inf")] + [NI() for _ in range(B)] + [float("inf")]
	Q = [NI() for _ in range(Q)]

	for q in Q:
		s_idx = bisect.bisect_left(S, q)
		t_idx = bisect.bisect_left(T, q)
		sl, sr, tl, tr = S[s_idx-1], S[s_idx], T[t_idx-1], T[t_idx]
		LL = max(abs(q - sl), abs(q - tl))
		RR = max(abs(q - sr), abs(q - tr))
		LR = abs(q - sl) * 2 + abs(q - tr)
		RL = abs(q - sr) * 2 + abs(q - tl)
		LR2 = abs(q - tl) * 2 + abs(q - sr)
		RL2 = abs(q - tr) * 2 + abs(q - sl)
		res = min(LL, RR, LR, LR2, RL, RL2)
		print(res)


if __name__ == "__main__":
	main()

Measured memory_bytes: 16548
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
"""
~~ Author : Bhaskar
~~ Dated : 13~06~2020
"""

import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque

INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize) - 1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a, b: (a * b) // gcd(a, b)
setbit = lambda x: bin(x)[2:].count("1")
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace("\n", "")
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())


def solve():

    a,b = NUMS(int)
    print(a*b)
    


if __name__ == "__main__":
    try:
        sys.stdin = open("input.txt", "r")
    except:
        pass
    solve()


Measured memory_bytes: 9432
D,G = map(int,input().split())
P = [0]*D
C = [0]*D
for i in range(D):
    P[i],C[i] = map(int,input().split())

def count(bit):
    cnt = 0
    point = 0
    i = 0
    comp = [False]*D
    while bit > 0:
        if bit&1:
            cnt += P[i]
            point += P[i]*100*(i+1) + C[i]
            comp[i] = True
        i += 1
        bit = bit >> 1
    if point >= G:return cnt
    for i in range(D-1,-1,-1):
        if comp[i]:continue
        if point + 100*(i+1)*(P[i]-1) < G:
            cnt += P[i] - 1
            point += 100*(i+1)*(P[i]-1)
        else:
            cnt += (G-point-1)//(100*(i+1)) + 1
            return cnt
    return 1e100

ans = 1e100
for i in range(2**D):
    # i:下からj桁目は100j問題でc-bonusを取るか
    ans = min(ans, count(i))
print(ans)


Measured memory_bytes: 3064
a = [['the'], ['this'], ['that']]
for i in range(25):
    for b in a:
        s = ''
        for c in b[-1]:
            s += chr((ord(c) - ord('a') + 1) % 26 + ord('a'))
        b.append(s)


def f(s):
    for b in a:
        for i in range(26):
            if s.find(b[i]) != -1:
                t = ''
                for c in s:
                    if c.isalpha():
                        t += chr((ord(c) - ord('a') - i + 26) % 26 + ord('a'))
                    else:
                        t += c
                return t
    return None

try:
    while True:
        print f(raw_input())
except:
    pass

Measured memory_bytes: 4240