akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> X(N), L(N);
    REP(i, N) { cin >> X.at(i) >> L.at(i); }

    vector<pair<int, int>> p(N);
    REP(i, N) {
        p[i].first = X[i] + L[i];
        p[i].second = X[i] - L[i];
    }

    sort(ALL(p));

    int ans = 1;
    int t = p[0].first;
    FOR(i, 1, N) {
        if (t <= p[i].second) {
            ans++;
            t = p[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//
ll a[100001],b[100001];
ll n;
int main(){
        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }
        for(int i=0; i<n; i++) {
                b[a[i]]+=1;
        }
        for(int i=0; i<100001; i++) {
                if(b[i]%2==0 && b[i]!=0) {
                        b[i]=2;
                }else if(b[i]%2!=0 && b[i]!=0) {
                        b[i]=1;
                }
        }
        ll sum=0;
        ll sum2=0;
        for(int i=0; i<100001; i++) {
                if(b[i]!=0) sum++;
                if(b[i]==2) {
                        sum2+=1;
                }
        }
        if(sum2%2==0) {
                cout<<sum<<endl;
        }else{
                cout<<sum-1<<endl;
        }
}


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

const int maxn = 1e5 + 5;

bool visited[maxn];
int dist[maxn];
vector<int> g[maxn];
int indegree[maxn];

void dfs(int a){
    assert(1);
    visited[a] = true;
    for(auto b : g[a]){
        dist[b] = max(dist[b] , 1 + dist[a]);
        --indegree[b];
        if(indegree[b] == 0 && !visited[ b])
            dfs(b);
    }
}

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

    for(int u=0;u<m;u++){
        int a,b;
        cin>>a>>b;

        g[a].push_back(b);
        indegree[b]++;
    }

    for(int i=1;i<=n;i++){
        if(!visited[i] && indegree[i] == 0)
            dfs(i);
    }

    cout<<*max_element(dist,dist+maxn);
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;

    ld prob = n >= k ? (ld)(n - k + 1) / n : 0;
    int prev = k;
    ll pcoinInv = 1;
    while (k > 0) {
        k = (k + 1) /2;
        if (prev == k) {
            break;
        }
        pcoinInv *= 2;
        if (n >= k) {
            ld p1 = (ld)(min(prev, n+1) - k) / n;
            prob += p1 / pcoinInv;
//            cout << n << "|" <<  k << " " <<  p1 << "/" << pcoin << endl;
        }
        prev = k;
    }

    printf("%.12Lf\n", prob);

    return 0;
}

Measured memory_bytes: 3664
import numpy as np


n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]

g = [np.array([0 for j in range(m+1)]) for i in range(2**n)]
min_c = 10**9

for i in range(2**n):
    tmp = list(bin(i))[2:]
    tmp.reverse()

    add_list = (np.array(tmp) == "1")
    for num, t in enumerate(add_list):
        if (t):
            g[i] += l[num]

for i in range(2**n):
    if (np.all(g[i][1:] >= x)):
        c = g[i][0]
        min_c = c if (c < min_c) else min_c

if min_c == 10**9:
    print(-1, end="")
else:
    print(min_c, end="")


Measured memory_bytes: 27928
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n;
	std::vector<int> aList;
	std::vector<int> status;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	std::vector<int> aList_;
	aList_.push_back(aList[0]);

	for(int i=1; i<n; i++){
		if(aList[i]!=aList[i-1])
			aList_.push_back(aList[i]);
	}
	int n_ = aList_.size();
	status.resize(n_, 0);

	if(aList_[0]< aList_[1])
		status[0]= -1;

	if(aList_[n_-1]> aList_[n_-2])
		status[n_-1]= 1;

	for(int i=1; i<n_; i++){
		if(aList_[i-1] < aList_[i] && aList_[i+1] < aList_[i])
			status[i]= 1;

		if(aList_[i-1] > aList_[i] && aList_[i+1] > aList_[i])
			status[i]= -1;
	}

	for(int i = n_-1; i>=0; i--){
		if(status[i]==1)
			break;

		status[i]=0;
	}

	long long asset= 1000;
	long long stock= 0;

	for(int i=0; i< n_; i++){
		if(status[i]==1){
			asset+= stock * aList_[i];
			stock= 0;
		}

		else if(status[i]==-1){
			long long tmp= asset/ aList_[i];
			asset -= tmp * aList_[i];
			stock += tmp;
		}

	}

	std::cout<<asset<<std::endl;

	return 0;	
}

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

int main()
{
	int n,m;
	cin>>n>>m;
	int ans,a[n],b[n],c[m],d[m];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		cin>>b[i];
	}
	for(int j=0; j<m; j++)
	{
		cin>>c[j];
		cin>>d[j];
	}
	for(int p=0; p<n; p++)
	{
		int min=INT_MAX;
		for(int q=0; q<m; q++)
		{
			int dist=abs(a[p]-c[q])+abs(b[p]-d[q]);
			if(dist<min)
			{
				min=dist;
				ans=q;
			}
		}
		cout<<ans+1<<endl;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
int main() {
	cin >> k;
	cout << a[k-1];
	return 0;
}


Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 n,i,j,with;
        cin>>n;
        int64 fix[n+1][n+1];
        for(i=1;i<=n;i++)
            for(j=1;j<n;j++)
                cin>>fix[i][j];
        int64 days[n+1]={0};
        int64 ans=1;
        int64 ttl=0;
        for(i=1;i<=(n*(n-1))/2;i++)
        {
            int done[n+1]={0};
            for(j=1;j<=n;j++)
            {
                if(days[j]>=n-1||done[j]==1)
                    continue;
                with=fix[j][days[j]+1];
                if(days[with]>=n-1||done[with]==1)
                    continue;
                if(fix[with][days[with]+1]==j)
                {
                    done[j]=done[with]=1;
                    days[with]++;
                    days[j]++;
                    ttl++;
                }
                    
            }
            if(ttl>=((n-1)*n)/2)
                break;
        }
        if(ttl>=((n-1)*n)/2)
        cout<<i;
        else
            cout<<-1;
    }

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define N (17) 
using namespace std;
int m,n;
double neko[N][N];
double mem[N][1<<N];
int used[N][1<<N];

double dfs(int pos,int bit){
  if(pos==n) return 1;
  if(used[pos][bit]++) return mem[pos][bit];

  double res=0;
  for(int i=0;i<m;i++){
    if(bit&(1<<i))continue;
    double r=0,t=1;
    for(int j=pos;j<=n;j++){
      r+=t*(1-neko[i][j])*dfs(j,bit|(1<<i));
      t*=neko[i][j];
    }
    res = max(res,r);
  }
  return mem[pos][bit] = res;
}

int main(){

  cin>>m>>n;
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++)cin>>neko[i][j];
    neko[i][n] = 0;
  }

  printf("%.10f\n",dfs(0,0));
  return 0;
}

Measured memory_bytes: 15624
def compute():
  from sys import stdin
  N = int(stdin.readline().strip())
  MOD = int(1e9)+7

  dp = {}
  prohibited = ('AGC', 'ACG', 'GAC')

  def flt(a,b,c,d):
    if (b is None) or (c is None) or (d is None):
      return True
    if (b+c+d) in prohibited:
      return False
    if (a is not None) and (((a+c+d)=='AGC') or ((a+b+d)=='AGC')):
      return False
    return True

  def f(prev3, prev2, prev1, n):
    if n==0:
      return 1

    k = (prev3, prev2, prev1, n)
    if k in dp:
      return dp[k]

    nexlis = ('A', 'C', 'G', 'T')
    ret = sum(map(
      lambda nex: f(prev2, prev1, nex, n-1),
      filter(
        lambda nex: flt(prev3, prev2, prev1, nex),
        nexlis
      )
    )) % MOD

    dp[k] = ret
    return ret

  print( f(None, None, None, N) )


if __name__ == "__main__":
  compute()


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

using i64 = int64_t;

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    i64 ans = 0;
    for(int i=0;i<min(n, k);++i){
        if(t[i] == 'r')ans += p;
        else if(t[i] == 's')ans += r;
        else ans += s;
        int cnt = 0;
        for(int j=i+k;j<n;j+=k){
            if(t[j] == t[j-k]){
                cnt++;
                if(cnt%2 == 0){
                    if(t[j] == 'r')ans += p;
                    else if(t[j] == 's')ans += r;
                    else ans += s;
                }
            }else{
                cnt = 0;
                if(t[j] == 'r')ans += p;
                else if(t[j] == 's')ans += r;
                else ans += s;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    string str;
    int n,k;
    cin>>n>>k;getchar();
    getline(cin,str);
    str[k-1]=tolower(str[k-1]);
    cout<<str<<endl;
    return 0;
}


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

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { 1, 0, -1, 0};
const int dy[4] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================
LL m, n;
const LL MOD = 1000000007;

LL solve() {
	LL r = 1;

	for (; n > 0; n >>= 1) {
		if (n & 1) r = (r * m) % MOD;
		m = (m * m) % MOD;
	}

	return r;
}

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

	cin >> m >> n;
	cout << solve() << "\n";
	return 0;
}

Measured memory_bytes: 3184
N = int(input())
a = sorted(list(map(int, input().split())))
nyu = []
ma = a[-1]
mi = a[0]
i=0
while i!=N-2:
    if a[i+1]>=0:
        nyu.append([mi, a[i+1]])
        mi -= a[i+1]
    else:
        nyu.append([ma, a[i+1]])
        ma -= a[i+1]
    i += 1
nyu.append([ma, mi])
print(nyu[N-2][0]-nyu[N-2][1])
for i in range(N-1):
    print(nyu[i][0], nyu[i][1])

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

using namespace std;

int N, M, V, P, A[200009];
long long s[200009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d %d", &N, &M, &V, &P);
for (int i=1; i<=N; i++)
    scanf ("%d", &A[i]);
sort (A + 1, A + N + 1), reverse (A + 1, A + N + 1);
if (P >= V)
{
    int ans = 0;
    for (int i=1; i<=N; i++)
        if (A[i] + M >= A[P])
            ans ++;
    printf ("%d\n", ans);
    return 0;
}
int ans = P;
for (int i=1; i<=N; i++)
    s[i] = s[i - 1] + A[i];
for (int q=P + 1; q<=N; q++)
if (A[q] + M >= A[P])
{
    long long curr = 1LL * M * (N - q) + (1LL * (A[q] + M) * (q - P) - (s[q - 1] - s[P - 1]));
    if (curr >= 1LL * M * (V - P))
        ans ++;
}
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl '\n'
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    ll now=0;
    ll count=0;
    for(ll i=1;;++i){
        count++;
        now+=i;
        if(now>=X)break;
    }
    prt(count)fl

    return 0;
}


Measured memory_bytes: 256
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ull unsigned long long
#define endl '\n'

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5+1;
const ll P = 31;
const double PI =  acos(-1.0);

int main() {
//  freopen(    "angle2.in", "r", stdin);
//  freopen("angle2.out", "w", stdout);
    IOS
    char c;
    cin >> c;
    char ans = (c >= 'A' && c <= 'Z') ? 'A' : 'a';
    cout << ans << endl;
    return 0;
}
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <random>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ 1e9 + 7 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-8;
long double pi = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream in("input.txt");
ofstream out("output.txt");

int h, w;
vector<string> f;
bool good(int x, int y)
{
	return 0 <= x && 0 <= y && x < h && y < w && f[x][y] == '.';
}

vector<vector<char>> used;

int dx1[4] = { 1, 0, -1, 0 };
int dy1[4] = { 0, 1, 0, -1 };

void solve()
{
	cin >> h >> w;
	int cx, cy;
	int dx, dy;
	cin >> cx >> cy >> dx >> dy;
	priority_queue<pair<int, pair<int, int>>> q;
	f.resize(h);
	used.resize(h);
	for (int i = 0; i < h; i++)
	{
		cin >> f[i];
		used[i].assign(w, 0);
	}
	q.push({ 0, {cx - 1, cy - 1 } });
	while (q.size())
	{
		int dist = q.top().first;
		int x = q.top().second.first;
		int y = q.top().second.second;
		if (x == dx - 1 && y == dy - 1)
		{
			cout << -dist;
			return;
		}
		q.pop();
		if (used[x][y]) continue;
		used[x][y] = 1;
		for (int i = 0; i < 4; i++)
		{
			int x1 = x + dx1[i];
			int y1 = y + dy1[i];
			if (good(x1, y1)) q.push({ dist, {x1, y1} });
		}
		for (int i = -2; i <= 2; i++)
		{
			for (int j = -2; j <= 2; j++)
			{
				if (i == 0 && j == 0) continue;
				if (good(x + i, y + j)) q.push({ dist - 1, {x + i, y + j} });
			}
		}
	}
	cout << -1;
}

int main()
{
	cout << setprecision(20) << fixed;
	cin.tie();
	cout.tie();
	clock_t t1 = clock();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
		//test();
	}
	//cout << (clock() - t1) * 1.0 / CLOCKS_PER_SEC;
	gg;
}

Measured memory_bytes: 9296
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var k = Number(lines[0]);
 var ab = lines[1].split(' ');
 var ab = ab.map(function(str) { return Number(str)});
 var a = ab[0];
 var b = ab[1];
 var count = 0;
 for(i=a; i<=b; i++){
   if(i % k == 0){
     console.log("OK");
     count++;
     break;
   }
 }

 if(count==0){
   console.log('NG');
 }
});

Measured memory_bytes: 30056
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, H, W = [int(sys.stdin.readline()) for _ in range(3)]
print((N - H+1) * (N - W+1))


Measured memory_bytes: 13620
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "map"

using namespace std;
const long long int MOD = 1000000007;

int N,M;
char letter[2][100][100];
int ans;
bool flag;


int main() {
	cin >> N>>M;
	for (int i = 0; i < N; i++) {
		cin >> letter[0][i];
	}
	for (int j = 0; j < M; j++) {
		cin >> letter[1][j];
	}
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			flag = true;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (letter[0][i+k][j+l] != letter[1][k][l]) {
						flag = false;
					}
				}
			}
			if (flag)ans++;
		}
	}
	if (ans)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
N = int(input())

X = list(map(int, input().split()))

SQ_total = 0
total = 0

for i in X:
  total += i
  SQ_total += i**2
  
ans = 100 * 100 * 2

for P in range(1,101):
  temp = N * P * P - 2 * P * total # -2(total)P + N*P^2
  ans = min(ans, temp)
  
print(SQ_total + ans)

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

using namespace std;

void solve()
{
	long n,m,a,b;
	cin >> n >> m;
	vector<pair<long, long>> ps(n);
	for (int i = 0; i < n; i++)
	{
		cin >> ps[i].first >> ps[i].second;
	}
	sort(ps.begin(), ps.end());
	long ans = 0;
	for (auto p : ps)
	{
		a = p.first, b = p.second;
		if (b > m) b = m;
		ans += a*b;
		m -= b;
		if (m == 0) break;
	}

	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        string s;
        cin >> s;
        int n = s.length();
        int ans = n;
        for (int i = 1; i < n; i++) {
            if (s[i] == s[i - 1]) {
                ans--;
                //dbg3(s[i], s[i - 1], i);
                //dbg2(i, ans);
                i += 2;
                //dbg(i);
            }
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

n, k = map(int, input().split())
s = map(int, input().split())
d = {}

for i in s:
    d.setdefault(i, 0)
    d[i] = d[i] + 1

if k >= len(d):
    print(0)
else:
    c = len(d) - k
    t = list(d.values())
    t.sort()
    print(sum(t[0:c]))


Measured memory_bytes: 41216
n,k = list(map(int, input().split()))
mod = int(1e9+7)



def init_cmb(Nmax):
    #mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] # 逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, Nmax + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    return g1, g2

g1,g2 = init_cmb(n+10)

def cmb(n, r, modn=mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % modn
  
# ci = 0 である個数が m となるような数列の数は、 nCm ×n−m Hm = nCm * n-1Cn-m-1
# 0 <= m < n で足算する

ans = 0
for i in range(min(k+1,n)):
  wk = cmb(n,i) * cmb(n-1, n-i-1) % mod
  ans = (ans + wk ) % mod
  
print(ans)

Measured memory_bytes: 33176
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            int ret = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i])
                {
                    ret++;
                }
            }

            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 27240
n,m=map(int,input().split())
edges=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    edges[a-1]+=[b-1]
    edges[b-1]+=[a-1]
vis=[1]+[0]*(n-1)

def dfs(v):
    if vis==[1]*n:
        return 1
    count=0
    for i in edges[v]:
        if vis[i]==0:
            vis[i]=1
            count+=dfs(i)
            vis[i]=0
    else: return count
print(dfs(0))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int main()
{
	string s;
	while(getline(cin, s), s != "END OF INPUT")
	{
		int i, d = 0;
		
		REP(i, 0, s.size())
		{
			if( s[i] == ' ')
			{
				cout << i-d;
				d = i+1;
			}
		}
		
		cout << i-d << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  sort(H.begin(),H.end());
  long long ans=0;
  for(int i=0;i<N-K;i++){
    if(N<K)continue;
    ans+=H.at(i);
  }
  cout<<ans<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, C;
	cin >> A >> B >> C;
	if(B>C) swap(B, C);
	if(A>B) swap(A, B);
	if(B>C) swap(B, C);
	cout << abs(A-B) + abs(B-C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((b*10+c)%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}










Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstdlib>
using namespace std;

typedef vector<int> vint;

map<string,vint> units;
map<vint,string> ref;
map<string,vint> vars;
const char *ptr;
char buf[32];

vint expr();
vint term();
vint factor();

vint expr(){
	vint ret = term();
	while(*ptr == '+' || *ptr == '-'){
		++ptr;
		vint r = term();
		if(ret != r){ throw 0; }
	}
	return ret;
}

vint term(){
	vint ret = factor();
	while(*ptr == '*' || *ptr == '/'){
		char ch = *ptr++;
		vint f = factor();
		if(ch == '/'){
			for(int i = 0; i < f.size(); ++i){
				f[i] = -f[i];
			}
		}

		for(int i = 0; i < f.size(); ++i){
			ret[i] += f[i];
		}
	}
	return ret;
}

vint factor(){
	if(*ptr == '('){
		++ptr;
		vint ret = expr();
		++ptr;
		return ret;
	}

	int d = 0;
	sscanf(ptr, "%[a-zA-Z]%n", buf, &d);
	ptr += d;
	return vars[buf];
}

int main(){
	int n, m, p;
	string str, str2, str3;
	char ch;
	while(cin >> n >> m >> p, n){
		units.clear();
		ref.clear();
		vars.clear();
		
		vint d(n);
		for(int i = 0; i < m; ++i){
			cin >> str;
			for(int j = 0; j < n; ++j){
				cin >> d[j];
			}
			units[str] = d;
			ref[d] = str;
		}
		
		cin >> str;
		for(int i = 0; i < p; ++i){
			cin >> str2 >> str3;
			vars[str2] = units[str3];
		}
		
		ptr = str.c_str();
		try{
			map<vint,string>::iterator it;
			it = ref.find(expr());
			if(it == ref.end()){
				cout << "undefined\n";
			}
			else{
				cout << it->second << '\n';
			}
		}catch(...){
			cout << "error\n";
		}
	}
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,w,k;
  cin>>h>>w>>k;
  vector<string>a(h);
  for(int i=0;i<h;i++)
  {
    cin>>a[i];
  }
  int ans=(h-1)+(w-1);
  for(int i=0;i<pow(2,h-1);i++)
  {
    vector<int>sq(h);
    int p=0;
    int t=0;
    int flag=0;
    int prev=0;
    vector<int>hl;
    while(t<w)
    {
      	p=0;
    	for(int j=0;j<h;j++)
    	{
      		if(a[j][t]=='1')
            {
              	sq[p]++;
          		if(sq[p]>k)
            	{
              		if(t==prev)
                    {
                      flag=1;
                      break;
                    }
              		else 
              		{
                		hl.push_back(t);
                		prev=t;
                		p=0;
                      	t--;
                      	sq.clear();
                      	sq.resize(h);
                		break;
              		}
            	}
            }
          /*if(i==2)
          {
            for(auto x:sq)cout<<x<<" ";
          	cout<<endl;
          }*/
          if(i&(1<<j))p++;  	
        }
      if(flag)break;
      t++;
    }
    int r=hl.size()+__builtin_popcount(i);
    if(r<ans && flag==0)ans=r;
    //cout<<r<<" "<<"flag : "<<flag<<endl;
  }
  cout<<ans<<endl;
  return 0;
}
    
      
      
      

Measured memory_bytes: 4076
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
using namespace std;


int main() {
  int N;
  string S;
  cin >> N >> S;
  vector <int> l(N + 2, 0);
  vector <int> r(N + 2, 0);
  for (int i = 0; i < N; i++) {
	  if (S[i] == 'W') {
		  l[i + 1]++;
		} else {
		  r[i + 1]++;
		}
	}
  for (int i = 0; i <= N; i++) {
	  l[i + 1]  += l[i];
	  r[N  - i] += r[N + 1 - i];
	}
  int ans = 1e9;
  for (int i = 1; i <= N; i++) {
	  ans = min(ans, l[i - 1] + r[i + 1]);
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int q; cin >> q;
  while(q > 0) {
    q--;
    ll a, b; cin >> a >> b;
    if(a > b) swap(a, b);
    ll sqt = static_cast<ll>(floor((ld)sqrt(a * b) - eps));
    bool near = sqt * (sqt+1) >= a * b;
    if(a == b) {
      cout << 2 * a - 2 << endl;
    } else if(b - a == 1) {
      cout << 2 * a - 2 << endl;
    } else if(near) {
      cout << sqt * 2 - 2 << endl;
    } else {
      cout << sqt * 2 - 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long n,a,b,c,d,count;
    while(cin>>n){
    count=0;
    for(a=0;a<=9;a++){
   for(b=0;b<=9;b++){
    for(c=0;c<=9;c++){
    for(d=0;d<=9;d++){
    if(a+b+c+d==n)
	count++;
                }
                }
            }
        }
    cout<<count<<endl;
    }
}

Measured memory_bytes: 1160
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
ev,od=[],[]
for i in range(n):
    if i%2==0:
        ev.append(lis[i])
    else:
        od.append(lis[i])
c=Counter(ev)
d=Counter(od)
#print(c.most_common()[0][1])
#-c.most_common()[0]-d.most_common()[0]
if c.most_common()[0][0]==d.most_common()[0][0]:
    if c.most_common()[0][1]==n//2:
        ans=n//2
    elif c.most_common()[1][1]>=d.most_common()[1][1]:
        ans=len(od)-d.most_common()[0][1]+len(ev)-c.most_common()[1][1]
    elif c.most_common()[1][1]<d.most_common()[1][1]:
        ans=len(od)-c.most_common()[0][1]+len(ev)-d.most_common()[1][1]
else:
    ans=len(ev)+len(od)-c.most_common()[0][1]-d.most_common()[0][1]
print(ans)

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

int main()
{
	ll t1,t2,a1,a2,b1,b2;
	scanf("%lld %lld",&t1,&t2);
	scanf("%lld %lld",&a1,&a2);
	scanf("%lld %lld",&b1,&b2);
	ll a=a1-b1,b=a2-b2;
	if(a<0)
	{
		a=-a,b=-b;
	}
	ll sum=a*t1+b*t2;
	if(sum==0)
	{
		puts("infinity");
		return 0;
	}
	if(sum>0)
	{
		puts("0");
		return 0;
	}
	ll ret=a*t1/(-sum)+(-b)*t2/(-sum);
	if((-b)*t2%(-sum)==0) ret--;
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    elif op == "?":
        break


Measured memory_bytes: 5596
#include<stdio.h>

int main() {
	int x[5], k;
	for(int i = 0; i < 5; i++) {
		scanf("%d", &x[i]);
	}
	scanf("%d", &k);
	if (x[4] - x[0] > k) {
		printf(":(");
	}
	else {
		printf("Yay!");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
string a,b="CF"; 
int al,bl;
int main()
{
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
    {
        if(a[i]==b[bl])
        { 
            bl++;
            if(bl==2)  
            {
                break;
            }
        }
    }
    if(bl==2) 
    {
        cout<<"Yes"; 
    }
    else 
    {
        cout<<"No";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main()
{
	int i,j;
	cin >> i >> j;
  /*
  int i;
	cin >> i;
	*/
   
	cout << i/j << " " <<  i%j << " ";
	cout << fixed << setprecision(5) << i/(double)j << endl;
}




Measured memory_bytes: 3276
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int t,x,y;
}a[101010];
int n;
bool cmp(node u,node w)
{
	return u.t<w.t;
}
int main()
{
	a[0].t=0; a[0].x=0; a[0].y=0;
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%d%d%d",&a[i].t,&a[i].x,&a[i].y);
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;++i)
	{
		int x=abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y);
		if (x>a[i].t-a[i-1].t)
		{
			printf("No\n");
			return 0;
		}
		if ((x-(a[i].t-a[i-1].t))%2)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<LL>> dp(h+1,vector<LL> (w,0));
    dp[0][0]=1;
    for (int i = 0; i < h; i++) {
        for (int j = 1; j < 1<<(w-1); j++) {
            bool t=true;
            for (int s = 0; s < w-1; s++) {
                if((j>>s&1)&&(j>>(s+1)&1)){
                    t=false;
                    break;
                }
            }
            if(t){
                vector<bool> c(w,false);
                for (int s = 0; s < w-1; s++) {
                    if(j>>s&1){
                        (dp[i+1][s+1]+=dp[i][s])%=mod;
                        (dp[i+1][s]+=dp[i][s+1])%=mod;
                        c[s]=c[s+1]=true;
                    }
                }
                for (int s = 0; s < w; s++) {
                    if(!c[s]) (dp[i+1][s]+=dp[i][s])%=mod;
                }
            }
        }
        for (int j = 0; j < w; j++) {
            (dp[i+1][j]+=dp[i][j])%=mod;
        }
    }
    cout << dp[h][k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int ln,rn;
vpint nodel,noder;

void fl(string str,int n){
	nodel.PB(MP(-1,-1));
	if(sz(str)<4)return;
	int c=0;
	int i;
	rep0(i,sz(str)){
		if(str[i]=='(')++c;
		if(str[i]==')')--c;
		if(str[i]==','&&c==1)break;
	}
	string left,right;
	left=str.substr(1,i-1);
	right=str.substr(i+1,sz(str)-i-2);
	if(sz(left)>0){
		nodel[n].first=sz(nodel);
		fl(left,sz(nodel));
	}
	if(sz(right)>0){
		nodel[n].second=sz(nodel);
		fl(right,sz(nodel));
	}
	return;
}

void fr(string str,int n){
	noder.PB(MP(-1,-1));
	if(sz(str)<4)return;
	int c=0;
	int i;
	rep0(i,sz(str)){
		if(str[i]=='(')++c;
		if(str[i]==')')--c;
		if(str[i]==','&&c==1)break;
	}
	string left,right;
	left=str.substr(1,i-1);
	right=str.substr(i+1,sz(str)-i-2);
	if(sz(left)>0){
		noder[n].first=sz(noder);
		fr(left,sz(noder));
	}
	if(sz(right)>0){
		noder[n].second=sz(noder);
		fr(right,sz(noder));
	}
	return;
}

void intersect(int l,int r){
	cout<<"(";
	if(nodel[l].first!=-1&&noder[r].first!=-1){
		intersect(nodel[l].first,noder[r].first);
	}
	cout<<",";
	if(nodel[l].second!=-1&&noder[r].second!=-1){
		intersect(nodel[l].second,noder[r].second);
	}
	cout<<")";
}

void uni(int l,int r){
	if(l==-1&&r==-1)return;
	cout<<"(";
	uni(l!=-1?nodel[l].first:-1,r!=-1?noder[r].first:-1);
	cout<<",";
	uni(l!=-1?nodel[l].second:-1,r!=-1?noder[r].second:-1);
	cout<<")";
}

int main() {
	string a,str1,str2;
	while(cin>>a>>str1>>str2){
		ln=rn=0;
		nodel.clear();
		noder.clear();
		fl(str1,0);fr(str2,0);
		if(a=="i")intersect(0,0);
		else uni(0,0);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a,b,c,d,e]
ans = 0
maxtime = []
remain = []
for i in dish:
    maxtime.append((i+9) // 10 * 10)
for i in range(5):
    remain.append(maxtime[i] - dish[i])
ans = sum(maxtime) - max(remain)
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> heights = new List<int>();

            while (true)
            {
                string input = Console.ReadLine();

                if (string.IsNullOrEmpty(input)) break;

                heights.Add(int.Parse(input));
            }

            var query = heights.OrderByDescending(a => a).Take(3);

            foreach (var h in query)
            {
                Console.WriteLine(h);
            }
        }
    }
}

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

int main()
{
  string s;
  cin >> s;
  vector<char> odd = {'R', 'U', 'D'};
  vector<char> even = {'L', 'U', 'D'};

  int ans = 1;
  for (int i = 0; i < s.length(); i++)
  {
    if (i % 2 == 0)
    {
      if (find(odd.begin(), odd.end(), s[i]) == odd.end())
      {
        ans = 0;
      }
    }
    else
    {
      if (find(even.begin(), even.end(), s[i]) == even.end())
      {
        ans = 0;
      }
    }
  }
  if (ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;

random_device rd;
mt19937 rnd(rd());
#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define ok cerr << "ok" << endl;
#define endl '\n'
#define int long long
#define ld long double

signed main()
{
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	int s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    map<string, ll> list1, list2;
    cin >> n;
    rep(i, n){
        cin >> s;
        list1[s]++;
    }
    cin >> m;
    rep(i, m){
        cin >> s;
        list2[s]++;
    }
    for(auto i = list1.begin(); i != list1.end(); i++){
        mx = max(mx, list1[i -> first] - list2[i -> first]);
    }
    cout << mx << endl;
}



Measured memory_bytes: 256
a,b,c = map(int,input().split())

s = 0
def c2(a,b,c):
    d = 1
    if a%2!=0 or b%2!=0 or c%2!=0:
        d = 0
    elif a == b and a== c:d=-1
    return (b+c)/2, (a+c)/2 ,(a+b)/2,d

while 1:
    a,b,c,d = c2(a,b,c)
    if d == 1:
        s+=1
    elif d== -1:
        s=-1
        break
    else:
        break
print(s)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  	int a,b,x;
  	cin>>a>>b>>x;
  	if(a+b<x || a>x)
  		cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
   ll n,h;cin >>n>>h;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c;
   ll mx=-1;
    for (int i = 0; i < n; ++i) {
        cin >>a[i]>>b[i];
        mx=max(mx,a[i]);
        c.push_back(a[i]);
        c.push_back(b[i]);
    }
    sort(all(c));
    reverse(all(c));
    ll j=0;
    ll ans=0;
    while(1){
        if(c[j]>mx){
            h-=c[j];
            ans++;
            j++;
        }
        else break;
        if(h<=0)break;
    }
    if(h>0){
        ans+=(h-1)/mx+1;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 6920
#include<iostream>
using namespace std;
int main()
{
    int N,flag=0;
    cin>>N;
    while (N!=0)
    {
        if(N%10==7)
        {
            flag=1;
            break;
        }
        else
        {
            flag=0;
            N=N/10;
        }
    }
    if(flag==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
        return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
const int mod = 1000000007;

int main() {
    ll Q,H,S,D;
    cin >> Q>>H>>S>>D;
    ll m = min(8*Q,min(4*H,min(2*S,D)));
    ll N;
    cin>> N;
    if(N%2==0){
        cout << m*(N/2) <<endl;
        return 0;
    }
    ll r = min(4*Q,min(2*H,S));
    cout << m*(N/2)+r <<endl;
    
}

Measured memory_bytes: 256