akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define MAX 100005

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

P Q[MAX];
int head,tail,n;

void enqueue(P x)
{
  Q[tail]=x;
  tail=(tail+1)%MAX;
}

P dequeue()
{
  P x=Q[head];
  head=(head+1)%MAX;
  return x;
}

int min(int a,int b)
{
  return a<b?a:b;
}

int main()
{
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);

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

  while(head!=tail)
    {
      u=dequeue();
      c=min(q,u.t);
      u.t-=c;
      elaps+=c;
      if(u.t>0) enqueue(u);
      else
	{
	  printf("%s %d\n",u.name,elaps);
	}
    }
  return 0;
}

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

int main(){
	vector<int> a(5);
	rep(i,5) cin >> a[i];
	int k;
	cin >> k;
	
	rep(i,5){
		rep(j,5){
			if(abs(a[i]-a[j]) > k){
				cout << ":(" << endl;
					return 0;
			}
		}
	}
	
	cout << "Yay!" << endl;

	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long 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(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.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; }
const ll inf = 1000000001;
const ll INF = 2e18;
//const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< 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 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a*b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char s[110];

int main() {
  int ans = 0;
  scanf("%s", s);
  if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
    ans = 1;
  if (s[1] == 'R' && (s[0] == 'R' || s[2] == 'R'))
    ans = 2;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
    ans = 3;
  printf("%d\n", ans);
  return 0;
}

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

const int INF = 0x3f3f3f3f;
const int maxn = (int)(3 * 1e5 + 5);

int es[maxn];

int main() {
    int n;
    string str;
    cin >> n >> str;
    es[0] = 0;
    for (int i = 1; i <= n; i++) {
        es[i] = es[i - 1];
        if (str[i - 1] == 'E') {
            es[i]++;
        }
    }
    int ans = INF;
    for (int i = 0; i < n; i++) {
        ans = min(ans, i - es[i] + (es[n] - (es[i] + (str[i] == 'E' ? 1 : 0))));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1924
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<vector<int> > xyh(n, vector<int>(3));
  for (auto &x: xyh) {
    for (auto &y: x) cin >> y;
  }

  sort(xyh.rbegin(), xyh.rend(), [](auto &a, auto &b){return a[2] < b[2];});

  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      bool good = true;
      int h = xyh[0][2] + abs(i - xyh[0][0]) + abs(j - xyh[0][1]);
      for (int k = 1; k < n; k++) {
        if (max(h - abs(i - xyh[k][0]) - abs(j - xyh[k][1]), 0) != xyh[k][2]) {
          good = false;
          break;
        }
      }
      if (good) {
        cout << i << " " << j << " " << h << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

int main(){
	int n; cin>>n;
	vector<string> vs(n);
	vector<int> vi(n);
	rep(i,n) {cin>>vs[i]; cin>>vi[i];}
	string x; cin>>x;
	
	auto itr=find(vs.begin(),vs.end(),x);
	int idx=distance(vs.begin(),itr);
	
	int ans=0;
	for(int i=idx+1; i<n; i++){
		ans+=vi[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 1000010
using namespace std;

//辺の塗り分けの最小値 = 出次数の最大値 = max(k,G[u].size())

// 節点uに対し時節点vの色は 1,2,~,G[u].size()
//ただし、節点uの色以外 if(c[u] == cur(=c[v])) cur++;
//組み合わせ(辺) (u,v)の色(cur)を保存 map<P,int> ec
//c[v = 0~G[u].size()] = cur++;
//ただし(c[u] == c[v](=cur) ) cur++;
//e_c[u,v] = ec[v,c] = cur;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> G(n);
    vector<int> visited(n,0);
    vector<int> c(n,0);
    vector<P> e;
    map<P,int> ec;
    
    for(int i=0; i<(n-1); i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        e.push_back(make_pair(a,b));
    }

    int k = 0;
    visited[0] = 1;
    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int u = que.front(); que.pop();

        if( k< G[u].size() ) k = G[u].size();
        int cur =1;

        for(int j = 0;j < G[u].size() ;j++){
            int v =G[u][j];
            if(visited[v]) continue;
            if(c[u] == cur) cur++;
            c[v] = ec[make_pair(u,v)] = ec[make_pair(v,u)] = cur++;
            que.push(v);
            visited[v] = 1;
        }
    }

    cout<< k <<endl;
    for(int i = 0; i<(n-1); i++){
        pair<int,int> key = e[i];
        int ans = ec[key];
        cout<< ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 22004
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    fast();
    int p[100005]={0};
    ll sum=0,n,q,temp,a,b;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        sum+=temp;
        p[temp]++;
    }
    cin>>q;
    while(q--)
    {
        cin>>a>>b;
        sum=sum-a*p[a]+b*p[a];
        p[b]+=p[a],p[a]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4052
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int w[305], dp[305][305];
signed main(void)
{
	while(true) {
		int n;
		cin >> n;
		if(!n) break;
		REP(i, n) cin >> w[i];
		REP(i, 305) REP(j, 305) dp[i][j] = 0;

		FOR(W, 2, n+1) {
			REP(i, n) {
				int j = i+W-1;
				if(j >= n) continue;
				//cout << i << " " << j << endl;

				if(dp[i+1][j-1] == W-2 && abs(w[i] - w[j]) <= 1) dp[i][j] = W;
				FOR(k, i, j) {
					dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
					//cout << dp[i][j] << endl;
				}
			}
		}
		/*REP(i, n) {
			cout << i << ":";
			REP(j, n) {
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}*/
		cout << dp[0][n-1] << endl;
	}


	return 0;
}

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

int main(){
    string str;
    cin >> str;
    // cout << str[str.size()-1];
    if(str[str.size()-1] == 's') cout << str << "es" << endl;
    else                         cout << str << "s" << endl;
    return 0;
}

Measured memory_bytes: 3628
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    FOR(i, 2, N + 1) {
        int n = i;
        int j = 2;
        while (n != 1) {
            if (n % j == 0) {
                mp[j]++;
                n /= j;
            } else j++;
        }
    }
    int ans = 1;
    for (auto itr:mp) ans = mul(ans, itr.second + 1);

    cout << ans << 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;
using ll = long long;
using P = pair<int,int>;

const int A = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11100
def magic_square(n):
    a = [[0 for i in range(n)] for j in range(n)]

    x = n//2
    y = (n+1)//2
    i = 1
    while True:
        if a[y][x] == 0:
            a[y][x] = i
            i += 1
            x += 1
            y += 1
        else:
            x -= 1
            y += 1
            
        if x >= n:
            x = 0
        elif x < 0:
            x = n-1
        if y >= n:
            y = 0
        
        if i > (n*n):
            break
    return a

def print_square(a):
    for aa in a:
        for aaa in aa:
            print('{0:4d}'.format(aaa),end="")
        print('')

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = magic_square(n)
        print_square(a)

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, x;
  cin >> n >> x;
  vll a(n);
  vin(a);
  sort(all(a));
  ll rem =x;
  ll ans = 0;
  while(ans != n && rem - a.at(ans) >= 0){
    rem -= a.at(ans);
    ans++;
  }
  if(ans == n && rem > 0) ans--;
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

const int MAXN = 1e5;

int main(int argc, char *argv[])
{
    int N;
    priority_queue<int, vector<int>, greater<int>> front;
    vector<int> middle;
    priority_queue<int> back;
    vector<ll> sum_front, sum_back;

    cin >> N;

    middle.resize(N);
    sum_front.resize(N+1);
    sum_back.resize(N+1);
    sum_front[0] = 0;
    sum_back[N] = 0;
    
    FOR(i, N) {
        int a;
        cin >> a;
        front.push(a);
        sum_front[0] += a;
    }
    FOR(i, N) cin >> middle[i];
    FOR(i, N) {
        int a;
        cin >> a;
        back.push(a);
        sum_back[N] += a;
    }

    FOR(i, N) {
        if (front.top() < middle[i]) {
            sum_front[i+1] = sum_front[i] + middle[i] - front.top();
            front.pop();
            front.push(middle[i]);
        }
        else sum_front[i+1] = sum_front[i];
    }

    for(int i = N-1; i >= 0; i--) {
        if (back.top() > middle[i]) {
            sum_back[i] = sum_back[i+1] + middle[i] - back.top();
            back.pop();
            back.push(middle[i]);
        }
        else sum_back[i] = sum_back[i+1];
    }

    ll ans = LLONG_MIN;
    FOR(i, N+1) {
        if (sum_front[i] - sum_back[i] > ans)
            ans = sum_front[i] - sum_back[i];
    }

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


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,k,ans=1;

main() {
    cin >> n >> k;
    rep(i,n) {
        if (ans < k) ans += ans;
        else ans += k;
    }
    ct(ans)
}

Measured memory_bytes: 256
N, M = map(int, input().split())
x = [ list(map(int, input().split())) for i in range(M)]
bucket = {str(i):0 for i in range(1, N+1)}
for i in x:
    for p in i:
        bucket[str(p)] += 1
for i in range(1, N+1):
    print(bucket[str(i)])

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

int match_t(int pos, string s, string t);
string substitute(int pos, string s, string t);

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

	string result="UNRESTORABLE";
	string temp;

	if (t.size()>s.size())
	{
		cout << result << endl;
		return 0;
	}

	for (int i=0;i<=s.size()-t.size();++i)
	{
		if (match_t(i,s,t)!=0)
		{
			temp=substitute(i,s,t);
			//fprintf(stderr,"matched at %d, %s\n",i,temp.c_str());
			if ((result=="UNRESTORABLE")||(temp<result))
			{
				result=temp;
			}
		}
	}
	cout << result << endl;
}



int match_t(int pos, string s, string t)
{
	for (int i=0;i<t.size();++i)
	{
		if ((s[pos+i]!='?')&&(s[pos+i]!=t[i]))
		{
			return 0;
		}
	}
	return 1;
}

string substitute(int pos, string s, string t)
{

	for (int i=0;i<t.size();++i)
	{
		if (s[pos+i]=='?')
		{
			s[pos+i]=t[i];
		}
	}

	for (int i=0;i<s.size();++i)
	{
		if (s[i]=='?')
		{
			s[i]='a';
		}
	}

	return s;
}




Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, tmp; 
    cin >> n;
    vector<int> s;
    for (int i = 0; i < n; ++i){
        cin >> tmp;
        s.push_back(tmp);
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    cout << s.size() << endl;
}

Measured memory_bytes: 256
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
A = sorted([(x+l, x-l) for x, l in xl])
now = A[0][0]
cnt = 1
for i, j in A:
  if now <= j:
    cnt += 1
    now = i
print(cnt)  

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

int main(){
  string s;
  cin >> s;
  
  if(s == "Sunny")
    cout << "Cloudy\n";
  else if(s == "Cloudy")
    cout << "Rainy\n";
  else
    cout << "Sunny\n";
  
}

Measured memory_bytes: 256
def calc(a,b,f):
    a=int(a)
    b=int(b)
    if f==0:
        return a+b
    else:
        return a-b

s=input()
op=[0]*3
for i in range(2):
    a=calc(s[0],s[1],i)
    for j in range(2):
        b=calc(a,s[2],j)
        for k in range(2):
            c=calc(b,s[3],k)
            if c==7:
                ret=[i,j,k]               
for i in range(3):
    if ret[i]==0:
        ret[i]="+"
    else:
        ret[i]="-"
for i in range(3):
    print(s[i]+ret[i],sep="",end="")
print(s[3]+"=7")

Measured memory_bytes: 3064
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,x;
  cin >> n >> x;

  vi l(n);

  rep(i,n) cin >> l[i];

  int cnt = 0;
  int d = 0;

  for(int i = 1;i <= n; i++)
  {
    d = d + l[i - 1];
    // cout << d << endl;
    if(d <= x)
      cnt++;
  }

  cout << cnt + 1;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define distance(x, y) sqrt(pow(x, 2) + pow(y, 2))
main()
{
        int cx1, cx2, cy1, cy2, cr1, cr2;
        double len, rp, rm;
        scanf("%d %d %d", &cx1, &cy1, &cr1);
        scanf("%d %d %d", &cx2, &cy2, &cr2);
        len = distance(cx1 - cx2, cy1 - cy2);
        rp = abs(cr1 + cr2);
        rm = abs(cr1 - cr2);
        if(len > rp){
                printf("4\n");
        }else if(len == rp){
                printf("3\n");
        }else if(len > rm){
                printf("2\n");
        }else if(len == rm){
                printf("1\n");
        }else{
                printf("0\n");
        }
}

Measured memory_bytes: 1768
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll ans;
void gcd(ll p,ll q){
	if(p%q){
		ll d=p/q;
		ans+=2*q*d;
		gcd(q,p%q);
	}else{
		ll d=p/q;
		ans+=q*(2*d-1);
	}
}

int main(){
	ll n,x;
	scanf("%lld%lld",&n,&x);
	gcd(x,n-x);
	printf("%lld\n",ans+n);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {

  int w, h, x, y, r;
  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
  if ((x - r >= 0)  && (x + r <= w) && (y - r >= 0) && (y + r <= h))
    printf("Yes\n");
  else
    printf("No\n");

  return 0;

}

Measured memory_bytes: 584
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

class State implements Comparable<State>{
	int v, cost;
	public State(int V, int c) {
		v = V; cost = c;
	}
	public int compareTo(State s) {
		return cost - s.cost;
	}
}

class Edge implements Comparable<Edge>{
	int s, t, w;
	public Edge(int S, int T, int W) {
		s = S; t = T; w = W;
	}
	public int compareTo(Edge e) {
		return w - e.w;
	}
}

class Main{
	static int INF = Integer.MAX_VALUE/2; // INF 問題により変えよう
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		LinkedList<Edge>[] edges = new LinkedList[N];
		for(int i = 0; i < N; i++) edges[i] = new LinkedList<Edge>();
		for(int i = 0; i < M; i++) {
			int u = sc.nextInt(), v = sc.nextInt();
			edges[u - 1].add(new Edge(u - 1, v - 1, 1));
		}
		int S = sc.nextInt() - 1, T = sc.nextInt() - 1;

		int[][] d = new int[N][3]; // d[i][j]: 頂点iに到達する最短距離 condition: 最短距離を3で割った余りがjのとき
		for(int i = 0; i < N; i++) for(int j = 0; j < 3; j++) d[i][j] = INF;
		PriorityQueue<State> que = new PriorityQueue<State>();
		que.add(new State(S, 0));

		while(!que.isEmpty()){
			State now = que.poll();
			int point = now.v;
			if(d[point][now.cost % 3] != INF) continue;
			d[point][now.cost % 3] = now.cost;
			for(Edge edge : edges[point]) {
				if(d[edge.t][(now.cost + edge.w) % 3] == INF) {
					que.add(new State(edge.t, now.cost + edge.w));
				}
			}
		}
		System.out.println((d[T][0] == INF) ? -1 : d[T][0] / 3);

	}
}

Measured memory_bytes: 103484
import math
import collections
from operator import mul
from functools import reduce
import bisect
import string
import copy

def search(b,ind,n):
    sum=0
    while(ind*n<len(b)):
        sum+=b[ind*n]
        n+=1
    return sum%2

n=int(input())
a=[0]+list(map(int,input().split()))
b=[0]*len(a)
for i in range(len(a))[1:][::-1]:
    bi=search(b,i,2)
    if bi==a[i]:
        b[i]=0
    else: 
        b[i]=1

print(b.count(1))
for i in range(len(b)):
    if b[i]==1:
        print(i)


Measured memory_bytes: 70608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// // 整数の入力
		// int a = sc.nextInt();
		// // スペース区切りの整数の入力
		// int b = sc.nextInt();
		// int c = sc.nextInt();
		// // 文字列の入力
		// String s = sc.next();
		// // 出力
    // System.out.println((a+b+c) + " " + s);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    if (A + B > C + D) {
      System.out.println("Left");
    } else if (A + B < C + D) {
      System.out.println("Right");
    } else {
      System.out.println("Balanced");
    }
	}
}

Measured memory_bytes: 21972
N = int(input())
S = input()

def test(N, S):    
    if N==1:
        print('No')
        return
    
    T1 = S[:int(N/2)]
    T2 = S[int(N/2):]
    if(T1==T2):
        print('Yes')
    else:
        print('No')
    return
  
test(N, S)

Measured memory_bytes: 3060
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
mA, nA = [], []
for a in A:
    if a<0:
        mA.append(a)
    else:
        nA.append(a)
lnA = len(nA)
lmA = len(mA)

def F(idx):
    i, j = 0, lnA-1
    r = 0
    while i < lnA:
        while j >= 0 and nA[j]*nA[i] > idx:
            j -= 1
        r += j+1
        i += 1
    i, j = lmA-1, 0
    while i >= 0:
        while j < lmA and mA[j]*mA[i] > idx:
            j += 1
        r += lmA-j
        i -= 1
    i, j = 0, 0
    while i < lmA:
        while j < lnA and nA[j]*mA[i] > idx:
            j += 1
        r += 2*(lnA-j)
        i += 1
    for a in A:
        if a*a <= idx:
            r-=1
    return r//2

mx, mn = 2*10**18, -2*10**18
idx = (mx + mn)//2
target = K
while mx - mn > 1:
    if F(idx) < target:
        idx, mn = (idx + mx)//2, idx
    else:
        idx, mx = (idx + mn)//2, idx
print(idx+1)

Measured memory_bytes: 95188
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}
struct PrimeNumber {
    const ll MOD = 1000000007;  // 10**9 + 7
    ll add(ll a, ll b)
    {
        return (a + b) % MOD;
    }
    ll sub(ll a, ll b)
    {
        return (a + MOD - b) % MOD;
    }
    ll mul(ll a, ll b)
    {
        return ((a % MOD) * (b % MOD)) % MOD;
    }
    ll power(ll x, ll y)
    {
        if (y == 0) {
            return 1;
        }
        else if (y == 1) {
            return x % MOD;
        }
        else if (y % 2 == 0) {
            ll t = this->power(x, y / 2);
            return this->mul(t, t);
        }
        else {
            ll t = this->power(x, y / 2);
            return this->mul(this->mul(t, t), x);
        }
    }
    ll div(ll a, ll b)
    {
        return this->mul(a, this->power(b, MOD - 2));
    }

    #define FACTORIAL_MAX 1000000
    ll memo_factorial[FACTORIAL_MAX+1];
    void init_factorial(void)
    {
        this->memo_factorial[0] = 1;
        for (ll i = 1; i <= FACTORIAL_MAX; ++i) {
            this->memo_factorial[i] = this->mul(i, this->memo_factorial[i-1]);
        }
    }
    ll factorial(ll n)
    {
        return this->memo_factorial[n];
    }
    ll combination(ll n, ll r)
    {
        ll ret = this->factorial(n);
        ret = this->div(ret, this->factorial(r));
        ret = this->div(ret, this->factorial(n-r));
        return ret;
    }
};


void solve()
{
    PrimeNumber prime;
    prime.init_factorial();
    ll N,A,B,C;
    cin >> N >> A >> B >> C;
    ll p = prime.div(A,A+B);
    ll q = prime.div(B,A+B);
    ll pn = prime.power(p,N);
    ll qn = prime.power(q,N);

    // N : i
    ll qi = 1;
    ll ans = 0;
    for1(i,N) {
        ll a1 = prime.mul(N+i, prime.mul(pn,qi));
        a1 = prime.mul(a1, prime.combination(N-1+i,i));
        ans = prime.add(ans, a1);
        qi = prime.mul(qi,q);
    }
    // i : N
    ll pi = 1;
    for1(i,N) {
        ll a1 = prime.mul(N+i, prime.mul(qn,pi));
        a1 = prime.mul(a1, prime.combination(N-1+i,i));
        ans = prime.add(ans, a1);
        pi = prime.mul(pi,p);
    }
    ans = prime.mul(ans, prime.div(A+B+C,A+B));
    cout << ans << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


Measured memory_bytes: 8064
N=int(input())
l=[list(map(int,input().split())) for i in range(N)]

m=0

for i in range(N):
    for p in range(N):
        m+=((l[i][0]-l[p][0])**2+(l[i][1]-l[p][1])**2)**(1/2)
print(m/N)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}

ll sum[103][100003];
ll dp[103][100003];



int main() {

	// taskkill /IM "cp.exe" /F
	fast
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif

	ll n, k;
	cin >> n >> k;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}


	ll s = 0;
	ll m = 1e9 + 7;

	for (ll i = 0; i <= a[0]; i++) {
		dp[0][i] = 1;
	}
	for (ll i = 0; i <= k; i++) {
		s = (s + dp[0][i]) % m;
		sum[0][i] = s;
	}
	// print(dp[0], k);
	// print(sum[0], k);
	// cout << n << " " << k << endl;
	for (ll i = 1; i < n; i++) {

		ll p = a[i];
		for (ll j = 0; j <= k; j++) {
			ll l = j - p - 1;
			ll r = j;
			ll diff;
			if (l < 0) {
				diff = sum[i - 1][r];
			}
			else {
				diff = (sum[i - 1][r] - sum[i - 1][l] + m) % m;
			}
			dp[i][j] = diff;
			//cout << diff << endl;
		}

		s = 0;
		for (ll j = 0; j <= k; j++) {
			s = (s + dp[i][j]) % m;
			sum[i][j] = s;
		}
		// print(dp[i], k);
		// print(sum[i], k);
	}

	cout << dp[n - 1][k] << endl;



}

Measured memory_bytes: 160000
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> que;
  rep(i,n){
    int x;
    cin >> x;
    que.push(x);
  }
  rep(i,m){
    int now = que.top();
    que.pop();
    now /= 2;
    que.push(now);
  };
  ll ans = 0;
  while(!que.empty()){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    double n;
    for(;;) {
        cin >> n;
        if(n == 0) break;
        double s[1100], all =0;//<-
        rep(i, 1100) {
            s[i] = 0;
        }
        rep(i, n) {
            cin >> s[i];
            all += s[i];
        }
        double ave = all / n;
        double sum = 0;
        rep(i, n) {
            sum += (s[i] - ave) * (s[i] - ave);
        }
        double ans = sqrt(sum / n);
        cout << fixed << setprecision(10) << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <cstdio>
#include <memory>
#include <cmath>
#include <chrono>
#include <random>
#include <map>
#include <sstream>
#include <queue>
#include <cassert>
#include <cstdio>
#define x first
#define y second
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 998244353;

//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int n;
vector<int> v;

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

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

	cin >> n;

	int sum = 0;

	for(int i = 1; i <= n; ++i)
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;

	cout << sum << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (ll i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll n,m;
    cin >> n >> m;
    vll h(n),a(m),b(m),cnt(n);
    REP(i,n) cnt[i] = 1;
    REP(i,n) cin >> h[i];
    REP(i,m){
        cin >> a[i] >> b[i];
        ll x = h[a[i]-1];
        ll y = h[b[i]-1]; 
        if(x==y){
            cnt[a[i]-1] = 0;
            cnt[b[i]-1] = 0;
        }else if(x<y){
            cnt[a[i]-1] = 0;
        }else{
            cnt[b[i]-1] = 0;
        }
    }

    ll ans = 0;
    REP(i,n){
        if(cnt[i]==1) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int a,b,t;
  cin >> a >> b >> t;
  int ans = 0;
  int time = a;
  while(time<=t){
    ans += b;
    time += a;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VLL = vector <long long>;
using VB = vector <bool>;

int main() {
    int N;
    // A*B = N-C
    cin >> N;

    VLL ans(N+1);
    VB notPrime(N+1);

    long long res = 0;
    ans[1] = 1;

    for (int v = 2; v < N; ++v) {
        if (notPrime[v]) {
            continue;
        } else {
            ans[v] = 2;
        }

        for (int val = v*2; val < N; val += v) {
            int tmpv = val / v;
            int cnt = 1;
            notPrime[val] = true;

            while (tmpv%v == 0) {
                tmpv /= v;
                ++cnt;
            }

            ans[val] = ans[tmpv] * (1+cnt);
        }
    }

    for (int i = 1; i < N; ++i) {
        int rt = sqrt(i);

        res += ans[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 11224
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

// 最大公約数 greatest common diviser
template <typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

// 最小公倍数 least common multiple
template <typename T>
T lcm(T a, T b) {
    // return (a * b) / gcd(a, b); // overflow!
    return a / gcd(a, b) * b;
}
signed main() {
    int n;
    cin >> n;
    vector<int> as(n);
    rep(i, 0, n) {
        cin >> as[i];
    }

    vector<int> ls(n + 1), rs(n + 1);
    rep(i, 0, n - 1) {
        ls[i + 1] = gcd<int>(ls[i], as[i]);
    }
    for (int i = n - 1; i >= 0; i--) {
        rs[i] = gcd<int>(rs[i + 1], as[i]);
    }

    int ans = 0;
    rep(i, 0, n) {
        int l = ls[i];
        int r = rs[i + 1];
        chmax(ans, gcd(l, r));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
  double r=0,Ensyu=0,Menseki=0;

  scanf("%lf",&r);

  Menseki=r*r*3.141592653589;
  Ensyu=r*2*3.141592653589;

  printf("%f %f\n",Menseki,Ensyu);
  return 0;
}

Measured memory_bytes: 648
while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for _ in range(n):
		a,b,c=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
			l.append(a)
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in l:
			if d[k]>=1000000:
				print(k)

Measured memory_bytes: 6748
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;

bool is_leapyear(int y) {
    // if(y < 1000) return false; // ??
    if(y % 400 == 0) return true;
    if(y % 100 == 0) return false;
    return y % 4 == 0;
}

int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap[] = { 0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0};

int main() {
    int y1, m1, d1; cin >> y1 >> m1 >> d1;
    int y2, m2, d2; cin >> y2 >> m2 >> d2;
    m1--; m2--;

    char buf[128];
    sprintf(buf, "%04d%02d%02d", y1, m1, d1);
    string s1 = buf;
    sprintf(buf, "%04d%02d%02d", y2, m2, d2);
    string s2 = buf;

    if(s1 > s2) {
        swap(y1, y2);
        swap(m1, m2);
        swap(d1, d2);
    }

    bool valid = false;
    int age1 = -1, age2 = -1, cnt = 0;

    auto change_age = [&](int &age, int y, int m, int d,
                          int yc, int mc, int dc) {
        // 誕生日が 2/29
        if(m+1 == 2 and d == 29) {
            if(is_leapyear(yc)) {
                if(mc+1 == 2 and dc == 29) age++;
            }
            else {
                if(mc+1 == 3 and dc == 1) age++;
            }
        }
        else {
            if(m == mc and d == dc) age++;
        }
    };

    int ans = 0;
    for(int y=y1, m=m1, d=d1; cnt<200000; d++) {
        // change month
        if(d > days[m] + leap[m] * is_leapyear(y)) {
            m++;
            d = 1;
        }
        // change year
        if(m == 12) {
            y++;
            m = 0;
        }

        change_age(age1, y1, m1, d1, y, m, d);
        if(y == y2 and m == m2 and d == d2) valid = true;
        if(valid) {
            change_age(age2, y2, m2, d2, y, m, d);
            cnt++;
            ans = max(ans, age1 - age2);
        }
    }

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



Measured memory_bytes: 3340
#include <iostream>
#include<climits>
#include<cmath>
#include<vector>
using namespace std;

int function(vector<int> arr,int n,int k){
    vector<int> dp(n,INT_MAX);
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for(int i=2;i<n;i++){
        for(int j=i-1;j >= max(0,i-k);j--){
            if(dp[i] >= (abs(arr[i]-arr[j]) + dp[j])){
                dp[i] = (abs(arr[i]-arr[j]) + dp[j]);
            }
        }
    }
    return dp[n-1];
}

int main() {
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    cout<<function(arr,n,k)<<"\n";
}


Measured memory_bytes: 1408
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <queue>
#include <deque>
#include <functional>

template <class T>
using lp_queue=std::priority_queue<T, std::deque<T>, std::greater<T>>;

struct Edge {
  size_t src, dst;
  intmax_t cost;
  Edge(size_t src, size_t dst, intmax_t cost):
    src(src), dst(dst), cost(cost) {}
};

intmax_t mst(const std::vector<std::vector<Edge>> &g) {
  std::vector<bool> visited(g.size());
  lp_queue<std::pair<intmax_t, size_t>> q;
  q.emplace(0, 0);
  intmax_t res=0;
  while (!q.empty()) {
    std::pair<intmax_t, size_t> p=q.top();
    q.pop();
    intmax_t w=p.first;
    size_t v=p.second;
    if (visited[v]) continue;
    visited[v] = true;
    res += w;
    for (const Edge &e: g[v]) {
      q.emplace(e.cost, e.dst);
    }
  }
  return res;
}

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::pair<intmax_t, size_t>> x(N), y(N);
  for (size_t i=0; i<N; ++i) {
    scanf("%jd %jd", &x[i].first, &y[i].first);
    x[i].second = y[i].second = i;
  }

  std::sort(x.begin(), x.end());
  std::sort(y.begin(), y.end());

  std::vector<std::vector<Edge>> g(N);
  for (size_t i=1; i<N; ++i) {
    g[x[i].second].emplace_back(x[i].second, x[i-1].second, 
				x[i].first-x[i-1].first);
    g[x[i-1].second].emplace_back(x[i-1].second, x[i].second, 
				  x[i].first-x[i-1].first);
    g[y[i].second].emplace_back(y[i].second, y[i-1].second, 
				y[i].first-y[i-1].first);
    g[y[i-1].second].emplace_back(y[i-1].second, y[i].second, 
				  y[i].first-y[i-1].first);
  }

  printf("%jd\n", mst(g));
}


Measured memory_bytes: 20864
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 1000000007;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n, d;
int p[1000];

int main(){
    int cnt = 0;
    cin >> n >> d;
    rep(i,n) cin >> p[i];
    rep(i,n){
        if(p[i] > d){
            cnt += p[i]-d;
        }
    }
    if(cnt <= 0) cout << "kusoge" << endl;
    else cout << cnt << endl;
}

Measured memory_bytes: 1164
#include<algorithm>
#include<iostream>
#include<cstring>

using namespace std;

int D, N, T[200], A[200], B[200], C[200], M[200][101];

int f(int d, int c) {
  int i;

  if(d == D)
    return 0;
  if(M[d][c] >= 0)
    return M[d][c];

  int mx = 0;
  for(i = 0; i < N; ++i) {
    if(A[i] <= T[d] && T[d] <= B[i])
      mx = max(mx, abs(C[i] - c) + f(d + 1, C[i]));
  }

  return M[d][c] = mx;
}

int main() {
  int i;

  cin >> D >> N;
  for(i = 0; i < D; ++i)
    cin >> T[i];
  for(i = 0; i < N; ++i)
    cin >> A[i] >> B[i] >> C[i];

  memset(M, -1, sizeof(M));

  int mx = 0;
  for(i = 0; i < N; ++i) {
    if(A[i] <= T[0] && T[0] <= B[i])
      mx = max(mx, f(1, C[i]));
  }

  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 1260
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[200005];


void solve()
{
    scanf("%s", str);
    int n = strlen(str);
    int cntT = 0, cntS = 0;;
    int i;
    for (i = 0; i < n; i++) {
        if (str[i] == 'S') {
            cntS++;
        }
        else {
            if (cntS) cntS--;
            else cntT++;
        }
    }
    printf("%d\n", cntS + cntT);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

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

  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }

  int curMin = 1e9;
  int count = 0;
  rep(i, N) {
    curMin = min(curMin, P[i]);
    if (curMin == P[i]) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

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

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

    ll ans = 0;
    rep(i,n)
    {
        while(a[i]%2 == 0)
        {
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto A = RDR.ARR;
	A.sort();
	
	auto BC = new long[2][](M);
	foreach (i; 0..M)
	{
		BC[i] = [RD, RD];
	}
	BC.sort!((long[2] a, long[2] b) => a[1] > b[1])();
	
	debug writeln(A);
	long ans;
	long pos;
	long cnt;
	foreach (i; 0..N)
	{
		debug writeln(pos, " ", cnt, " ", ans);
		if (pos == M)
		{
			ans += A[i];
			continue;
		}

		if (cnt >= BC[pos][0])
		{
			++pos;
			cnt = 0;
			if (pos == M)
			{
				ans += A[i];
				continue;
			}
		}

		if (A[i] < BC[pos][1])
		{
			ans += BC[pos][1];
			++cnt;
		}
		else
		{
			ans += A[i];
			++pos;
			cnt = 0;
		}
	}
	debug writeln(ans);

	/*long ans;
	long lenMax;
	foreach_reverse (i; 0..M)
	{
		auto b = BC[i][0];
		auto c = BC[i][1];
		ans += c * max(0, b - lenMax);
		debug writeln(ans);
		lenMax = max(lenMax, b);
	}

	foreach (i; lenMax..N)
	{
		ans += A[i];
		debug writeln(ans);
	}*/

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 5428
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007

using namespace std;

int main() {
    ll N,A,B; cin >> N >> A >> B;
    ll ans = N/(A+B);
    ans = ans * A + min(N-ans*(A+B),A);
    cout << ans << endl;
}



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    sort(numbers.begin(), numbers.end());

    vector<P> build;

    queue<ll> plus, minus;
    rep(i, n) {
        if (i == 0) {
            minus.push(numbers[i]);
        } else if (i == n - 1) {
            plus.push(numbers[i]);
        } else {
            if (numbers[i] < 0) minus.push(numbers[i]);
            else plus.push(numbers[i]);
        }
    }

    while (plus.size() > 1) {
        ll pf = plus.front(), mf = minus.front();
        plus.pop();
        minus.pop();
        minus.push(mf - pf);
        build.emplace_back(mf, pf);
    }
    ll ans;
    while (!minus.empty()) {
        ll pf = plus.front(), mf = minus.front();
        plus.pop();
        minus.pop();
        ans = pf - mf;
        plus.push(ans);
        build.emplace_back(pf, mf);
    }
    cout << ans << endl;

    for (P p : build) {
        printf("%lld %lld\n", p.first, p.second);
    }
}


Measured memory_bytes: 5236
n, m = map(int, input().split())
s = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for num in range(1<<n):
	all = True
	for M in range(m):
		swt = 0
		for k in s[M][1:]:
			if num&(1<<(k-1)):
				swt += 1
		if swt % 2 != p[M]:
			all = False
			break
	if all:
		ans += 1
print(ans)		

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n;
double f[3010][3010],a[3010],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	f[1][0]=1-a[1];
	f[1][1]=a[1];
	for(int i=2;i<=n;i++)
		for(int j=0;j<=i;j++)
			f[i][j]+=f[i-1][j]*(1-a[i])+f[i-1][j-1]*a[i];
	for(int i=ceil(n/2.0);i<=n;i++)
		ans+=f[n][i];
	cout<<fixed<<setprecision(10)<<ans<<endl; 
	return 0;
}


Measured memory_bytes: 69120