akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)

typedef long long ll;
ll const Inf = 1LL<<60;

int N;

int main() {
  cin >> N;
  deque<long double> radius(N);
  rep(i, N) {
    cin >> radius[i];
  }

  if(N == 1) {
    printf("%.10Lf\n", radius[0] * 2.0);
    exit(0);
  }

  vector<long double> positions;
  vector<int> lasts;
//  vector<long double> starts;
  long double start = 0.0;
  rep(i, N) {
    long double x = 0.0;
    rep(j, i) {
      long double px = positions[j];
      long double s = radius[i] + radius[j]; s *= s;
      long double h = abs(radius[i] - radius[j]); h *= h;
      long double w = sqrt(s - h);
      if(x < px + w) {
        x = px + w;
      }
    }
    positions.push_back(x);
    lasts.push_back(i);
    minimize(start, x - radius[i]);
//    starts.push_back(min(-radius[0], x - radius[i]));
  }

//  rep(i, radius.size()) { cout << radius[i]; }; cout << endl << radius[0] << endl;
//  cout << "-----------------\n";rep(i, positions.size()) { printf("%.10Lf %.5Lf\n", positions[i], radius[lasts[i]]); } cout << "-----------------\n";

  long double ret = 0.0;
  rep(i, positions.size()) {
    maximize(ret, positions[i] - start + radius[lasts[i]]);
  }
  printf("%.10Lf\n", ret);

  return 0;
}

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

int main() {
    //入力
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    //処理
    ll ans = 0;
    ll mae = a[0];
    for (int i=1;i<n;++i) {
        if (a[i] < mae) {
            ans += mae - a[i];
        }
        else {
            mae = a[i];
        }
    }

    //出力
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4796
from bisect import bisect_left,bisect_right
N=int(input())
A=list(map(int, input().split()))
A.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        a,b=A[i],A[j]
        B=A[j+1:]
        l=abs(a-b)
        r=a+b
        # print(bisect_left(B,r)-bisect_right(B,l))
        ans+=bisect_left(B,r)-bisect_right(B,l)
print(ans)

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

int main(){
	int n;
	cin >> n;
	char s[100000];
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	//cout << s[5] << endl;
	char tmp = s[0];
	//if(tmp != s[0])cout << s[0] << endl;
	int ans = 0;
	for(int i = 0; i < n; i++){
		//cout << s[i] << " " << tmp << endl;
		if(tmp != s[i]){
			ans = ans + 1;
			tmp = s[i];
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 384
//Name: Clock Short Hand and Long Hand
//Level: 2
//Category: 数学
//Note: 

/**
 * 2PI = 1としてから全体を720倍すると、整数のみで計算できる。
 */
#include <iostream>
#include <algorithm>

using namespace std;

bool solve(bool first) {
    int H, M;
    cin >> H;
    cin.ignore();
    cin >> M;

    //const double ha = 2*PI * (H/12 + M/12/60);
    //const double ma = 2*PI * M/60;
    const int ha = 60*H + M;
    const int hb = 12*M;
    const int diff = min(abs(ha-hb), abs(720-abs(ha-hb)));
    if(diff < 60) {
        cout << "alert" << endl;
    } else if(diff >= 180) {
        cout << "safe" << endl;
    } else {
        cout << "warning" << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    int N;
    cin >> N;
    while(N-- && solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1188
N=int(input())
A=list(map(int,input().strip().split()))

INF=1000000000000000000
if 0 in A:
    print(0)
else:
    ans=1
    for n in range(N):
        ans*=A[n]
        if ans>INF:
            break

    if ans>INF:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 21792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

ll dp[110][5][2];
void solve() {
	string S; cin >> S;
	vector<int>X;
	int K; cin >> K;
	int N = S.size();
	REP(i, N) {
		X.push_back(S[i] - '0');
	}
	//print("now");
	dp[0][0][0] = 1;
	REP(i, N) {
		REP(c, K + 1) {
			REP(f, 2) {
				if (f) {
					dp[i + 1][c][1] += dp[i][c][f];
					dp[i + 1][c+1][1] += dp[i][c][f] * 9;
				}
				else {
					REP(num, 10) {
						if (num > X[i])continue;
						if (num == X[i]) {
							if (num == 0)dp[i + 1][c][f] += dp[i][c][f];
							else dp[i + 1][c + 1][f] += dp[i][c][f];
						}
						else if(num<X[i]) {
							if (num == 0)dp[i + 1][c][1] += dp[i][c][f];
							else dp[i + 1][c + 1][1] += dp[i][c][f];
						}
					}
				}
			}
		}
	}
	print(dp[N][K][0] + dp[N][K][1]);
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  long long N = S.size();
  long long A = stoll(S);
  long long ans = -1;
  long long diff = 0;
  vector<int> p(10);
  for (int i = 0; i < 10; i++){
    p[i] = i;
  }
  long long MAX = 1;
  for (int i = 0; i < N; i++){
    MAX *= 10;
  }
  while (1){
    long long B = 0;
    for (int i = 0; i < N; i++){
      B = B * 10 + p[i];
    }
    long long d = min(abs(A - B), MAX - abs(A - B));
    if (d > diff || d == diff && ans > B){
      diff = d;
      ans = B;
    }
    if (!next_permutation(p.begin(), p.end())){
      break;
    }
  }
  string T = to_string(ans);
  while (T.size() < N){
    T = '0' + T;
  }
  cout << T << endl;
}


Measured memory_bytes: 3284
fun solve(N: Int, M: Int) {
    var ans = 0
    ans += N * (N - 1) / 2
    ans += M * (M - 1) / 2
    println(ans)
}

fun main() {
//    val S = readLine()!!
//    val N = readLine()!!.toInt()
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(N, M)
}

Measured memory_bytes: 36452
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
void solve(){
	int n;
	cin>>n;
	if(n>=400&&n<600)cout<<8<<"\n";
	else if(n>=600&&n<800)cout<<"7\n";
	else if(n>=800&&n<1000)cout<<"6\n";
	else if(n>=1000&&n<1200)cout<<"5\n";
	else if(n>=1200&&n<1400)cout<<"4\n";
	else if(n>=1400&&n<1600)cout<<"3\n";
	else if(n>=1600&&n<1800)cout<<"2\n";
	else cout<<"1\n";
}
int main(){
	FASTIO
//	int t;
//	cin>>t;
//	while(t--)solve();
	solve();
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    string s;ll k;cin >> s >> k;
    rep(i,s.size()){
       if(s[i]=='a')continue;
       ll t=26-(s[i]-'a');
       if(t<=k){
           s[i]='a';
           k-=t;
        }
    }
    ll x=s[s.size()-1]-'a';
    x+=k;
    x%=26;
    s[s.size()-1]='a'+x;
    cout << s <<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define make_pair(a, b) mp(a, b)
typedef pair<int, int> pii; 
typedef long long ll;
const int maxn = 2e5 + 10;
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	if(s[n] == 's')
	{
		s[n + 1] = 'e';
		s[n + 2] = 's';
	}
	else
		s[n + 1] = 's';
	puts(s + 1);
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b))
    cout << "A" << endl;
  else
    cout << "B" << endl;
}


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
cnt=0
flag1=False
flag2='x'
for i in range(n-1):
  if arr[i]<arr[i+1]:
    if flag1==False:
      flag1=True
      flag2='p'
    if flag2=='n':
      flag1=False
      flag2='x'
      cnt+=1
  if arr[i]>arr[i+1]:
    if flag1==False:
      flag1=True
      flag2='n'
    if flag2=='p':
      flag1=False
      flag2='x'
      cnt+=1
print(cnt+1)

Measured memory_bytes: 14224
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b=mp()
print(min(n*a,b))

Measured memory_bytes: 10400
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>n>>m;
    in(ha,n);
    map<int,list<int>> g;

    while(m--)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    c=0;
    for(auto p:g)
    {   int h=ha[p.ff-1];
        int f=1;
        for(auto x:p.ss)
        {
            if(h<=ha[x-1])f=0;
        }
        c+=f;
    }
    
    
    cout<< c+n-g.size() <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 18212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll knapsack(int wt[] , int val[] , int w , int n) {
	ll dp[n + 1][w + 1] = {0}; // dp[i][j] represent the max value we can take upto ith object and having max weight of j .
	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < w + 1; j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
			}
			else if (wt[i - 1] > j) {
				dp[i][j] = dp[i - 1][j];
			}
			else if (wt[i - 1] <= j ) {
				dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]] , dp[i - 1][j]);
			}
		}
	}

	return dp[n][w];
}

int main() {
	int n;
	cin >> n;
	int wt[n];
	int val[n];
	int w;
	cin >> w;
	for (int i = 0; i < n; i++) {
		cin >> wt[i] >> val[i];
	}
	cout << knapsack(wt, val, w, n) << endl;;
}

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

static const int MAX=210;

int N;
char S[MAX][MAX];

bool used[MAX];
int d[MAX];

int solve(int s){
    memset(d,-1,sizeof(d));
    memset(used,0,sizeof(used));
    queue<int> que;
    que.push(s);
    d[s]=0;
    used[s]=true;
    while(!que.empty()){
        int u=que.front(); que.pop();
        for(int v=0;v<N;v++){
            if(S[u][v]=='1'){
                if(used[v]){
                    int tmp=abs(d[v]-d[u]);
                    if(tmp!=1){
                        return -1;
                    }
                }else{
                    d[v]=d[u]+1;
                    used[v]=true;
                    que.push(v);
                }
                
            }
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans=max(ans,d[i]);
    }
    return ans;
}


int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> S[i][j];
        }
    }
    int ans=-1;
    for(int i=0;i<N;i++){
        if(solve(i)==-1){
            continue;
        }else{
            ans=max(ans,solve(i));
        }
    }
    if(ans==-1){
        cout << -1 << endl;
    }else{
        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
    char a[30];
    char b[30];
    gets(a);
    int count = 0;
    for (int i=0; a[i]; i++)
    {
        count ++;
    }
    int i;
    for (i=0; count != 0; i++)
    {
        b[i] = a[--count];
    }
    b[i] = '\0';
    puts(b);
    return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

class Graph{

public:
  vector<vector<int>> graphs;
  vector<bool> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  vector<int> par;

  Graph(int n){
    graphs.resize(n);
    init(n);
  }
  ~Graph(){}

  void addedge(int u, int v){
    u--; v--;
    graphs[u].push_back(v);
    graphs[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.resize(n, false);
    dist.resize(n, -1);
    par.resize(n,-1);
  }

  void dfs(int v)
  {
    check[v] = true;

    for(auto next_v : graphs[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v)//----------------------
  {
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graphs[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        par[next_v] = cur_v;
        q.push(next_v);
      }
    }
  }//-----------------------

};

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

  Graph g(n);


  rep(i,m){
    int a, b;
    cin >> a >> b;
    g.addedge(a,b);
  }

  g.bfs(0);

  rep(i,n){
    if(g.dist[i]<0){
      prt("No");
      return 0;
    }
  }

  prt("Yes");
  REP(i,1,n){
    prt(g.par[i]+1);
  }


}


Measured memory_bytes: 11120
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
using namespace std;
typedef long long LL;
const LL MaxN = 3000;
const LL Inf = 1 << 30;

int main()
{
	LL n;
	cin >> n;
	LL a, ans = 0;
	while(n--)
	{
		scanf("%lld", &a);
		a--;
		ans += a;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

signed main()
{
    int n; cin >> n;
    ll sum = 0L;

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

    cout << sum << endl;

    return 0;
}


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

template<typename dtype, dtype initValue/*範囲外のときに返す値*/>
class RMQ{
public:
  int n,n_;
  vector<dtype> dat;
  int toMax;

  //初期化
  RMQ(){n=-1;}
  RMQ(int n_,int toMax = 0):n_(n_),toMax(toMax){
    n=1;
    while(n<n_)n*=2;
    dat.resize(2*n-1,initValue);
  }

  inline dtype merge(dtype a,dtype b){return toMax? max(a, b):min(a, b); }

  //k番目の値をaに変更
  void update(int k,dtype a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=merge(dat[k*2+1],dat[k*2+2]);
    }
  }
  
  dtype dfs(int a,int b,int k,int l,int r){
    if(r<=a||b<=l)return initValue;
    if(a<=l&&r<=b)return dat[k];
    dtype vl = dfs(a,b,k*2+1,l,(l+r)/2);
    dtype vr = dfs(a,b,k*2+2,(l+r)/2,r);
    return merge(vl,vr);
  }
  
  //[a,b)の最小値を求める
  dtype get(int a,int b){
    assert(a <= b), assert(a <= n_ && b <= n_), assert(a >= 0 && a >= 0);
    return dfs(a,b,0,0,n);
  }
};

int main(){
  int n,q;
  cin>>n>>q;
  typedef long long ll;
  RMQ <ll, INT_MAX> A(n,0);
  
  while(q--){
    int com,x,y;
    cin>>com>>x>>y;
    if(com == 0) A.update(x,y);
    if(com == 1) cout<<A.get(x,y+1)<<endl;
  }

  return 0;
}



Measured memory_bytes: 4928
#include<bits/stdc++.h>
using namespace std;
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; 
typedef pair<int, int> pii; 
typedef vector<pair<int, int> > vpii; 
typedef long long ll;
template<typename T, typename U> static void amin(T &x, U &y) {if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U &y) {if (y > x) x = y; }
#define rep(i, n) for (int (i)=0; (i)<(n); (i)++)
#define rer(i, l, u) for (int (i)=(int)(l); (i)<=(int)(u); (i)++)
#define reu(i, l, u) for (int (i)=(int)(l); (i)<(int)(u); (i)++)
int main () {
	int sx, sy, tx, ty;
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	int x = tx-sx, y = ty-sy;
	rep(i, y) cout << "U";
	rep(i, x) cout << "R";
	rep(i, y) cout << "D";
	rep(i, x) cout << "L";
	cout << "L";
	rer(i, 0, y) cout << "U";
	rer(i, 0, x) cout << "R";
	cout << "D";
	cout << "R";
	rer(i, 0, y) cout << "D";
	rer(i, 0, x) cout << "L";
	cout << "U";
	return 0;
}

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


signed main(){
    int t;
    cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> l;
        int pre = 0;
        for(int i = 0;i < n;i++){
            int x;
            cin >> x;
            if(i != 0) l.push_back(x-pre);
            pre = x;
        }
        sort(begin(l), end(l), greater<int>());
        cout << accumulate(begin(l)+min(k, n)-1, end(l), 0LL) << endl;
    }
    return 0;
}


Measured memory_bytes: 4724
import math
#nCr()組み合わせ総数)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#nPr(順列総数)
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 10**9+7
N, K = map(int, input().split())
for i in range(1,K+1):
    if i > N-K+1:
        print(0)
    else:
        if i > K:
            print(0)
        else:
            ans = (combinations_count(N-K+1, i)*combinations_count(K-1, i-1))%mod
            print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    ll n, k;   cin >> n >> k;
    ll res=0;
    if(k==0) res = n*n;
    else
        FOR(i, 1, n+1){
            res += n/i*(max(0LL, i-k))+max(n%i-k+1, 0LL);
        }
    cout << res << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
L=[0]*(N+1)

ans=0

for i in range(K):
    _d=int(input())
    _a=list(input().split())
    for _ in _a:
        L[int(_)]+=1

for j in range(1,N+1):
    if L[j]==0:
        ans+=1
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    string st;
    getline(cin, st);
    int cnt = 0;
    bool first = true;

    rep(i, st.length()) {
        char c = st[i];
        if (c == ' ' || c == '.' || c == ',') {
            if (cnt >= 3 && cnt <= 6) {
                if (first) {
                    first = false;
                }
                else {
                    cout << " ";
                }
                for (int j = i - cnt; j < i; j++) {
                    cout << st[j];
                }
            }
            cnt = 0;
        }
        else {
            cnt++;
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3084
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
x_list=list(map(int,input().split()))
l=b//a
ans=0
for i in range(1,n):
    d=x_list[i]-x_list[i-1]
    if d>l:
        ans+=b
    else:
        ans+=d*a
print(ans)



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

int main() {

	int h, w; cin >> h >> w;

	vector<vector<char>> a(h + 2, vector<char>(w + 2, 'e'));

	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> a[i][j];
	
	int ans = 0;
	for (int sy = 1; sy <= h; sy++) {
	for (int sx = 1; sx <= w; sx++) {
		if (a[sy][sx] == '#') continue;
	for (int gy = 1; gy <= h; gy++) {
	for (int gx = 1; gx <= w; gx++) {
		if (a[gy][gx] == '#') continue;

			// BFS のためのデータ構造
			vector<vector<int>> dist(h + 2, vector<int>(w + 2, -1)); // 全頂点を「未訪問」に初期化
			queue<pair<int, int>> que;

			// 初期条件
			dist[sy][sx] = 0;
			que.push({ sy,sx });

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

			// BFS 開始 (キューが空になるまで探索を行う)
			while (!que.empty()) {

				pair<int, int> p = que.front(); // キューから先頭頂点を取り出す
				que.pop();

				// p から辿れるマスをすべて調べる
				for (int i = 0; i < 4; i++) {

					int y_next = p.first + dy[i];
					int x_next = p.second + dx[i];

					if (dist[y_next][x_next] != -1) continue;
					if (a[y_next][x_next] == 'e' || a[y_next][x_next] == '#') continue;

					// 新たなマス { y_next, x_next } について距離情報を更新してキューに追加する
					dist[y_next][x_next] = dist[p.first][p.second] + 1;
					que.push({ y_next, x_next });

				}

			}

			ans = max(ans, dist[gy][gx]);
	}
	}
	}
	}

	cout << ans << endl;
	return 0;

}

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

int main(){
    int n,a,col[MX],ans=0;
    cin>>n>>a;
    fill(col,col+n,1);
    col[0]=-a;
    rep(i,n-1){
        cin>>a;
        *upper_bound(col,col+n,-a)=-a;
    }
    ans=lower_bound(col,col+n,1)-col;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
n = int(input())
d = defaultdict(int)
t = 0
for _ in range(n):
    s = input()
    d[s] += 1
    t = max(t, d[s])
res = []
for i in d:
    if d[i] == t:
        res.append(i)
res.sort()
for i in res:
    print(i)

Measured memory_bytes: 32460
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

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

  int mx = 0, cnt = 0, mn = 1e9+10;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;

    mn = min(mn, A);
    int diff = A - mn;
    if (diff > mx) {
      mx = diff;
      cnt = 1;
    } else if (diff == mx) {
      ++cnt;
    }
  }
  
  cout << cnt << endl;
  return 0;
}


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

import sys
import os
import math


N = int(input())
cost = 100000

for i in range(N):
    cost *= 1.05
    cost = round(cost)

    if cost % 1000 > 0:
        cost = (cost // 1000) * 1000 + 1000
print(cost)

Measured memory_bytes: 7688
# agc035_a.py
'''
両隣の数のXORが自身と等しい状態にできる場合Yes、そうでない場合No
例：
N = 3
Ai = 1, 2, 3
1, 2, 3 -> 1, 2, 3 にすることで
2 XOR 3  = 1, 2 XOR 1 = 3, 3 XOR 1 = 1 となるので Yes
XOR の性質は
a XOR a = 0
a XOR 0 = a
a XOR b >= a + b
などがある。
'''
import collections
N = int(input())

L = list(map(int,input().split()))
C = collections.Counter(L)
flg = False
if len(C)>3:
    print('No')
    exit()

if len(C)==3:
    ans = 0
    cnt = []
    for i,v in C.items():
        ans ^= i
        cnt.append(v)
    if ans == 0 and max(cnt) == min(cnt):
        print('Yes')
        exit()
    else:
        print('No')
if len(C) == 2:
    if C[0] == 0:
        print('No')
        exit()
    x = 0
    y = 0
    for i,v in C.items():
        if i == 0 :
            x = v
        else:
            y = v
    if 2 * x == y:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
if len(C) == 1:
    if C[0]>0:
        print('Yes')
        exit()
    else:
        print('No')


Measured memory_bytes: 20892
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Console.WriteLine(n[0]+1- n[1]);

	} 
}

Measured memory_bytes: 13268
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()

def main():
    N = I()
    l = []
    for i in range(N+1):
        if i % 3 == 0: pass
        elif i % 5 == 0: pass
        else: l.append(i)
    print(sum(l))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 30268
A,B = map(int,input().split())
S = input()
ans = "Yes"
flag1 = 0
flag2 = 0
if S[A] != "-":
    ans = "No"
else:
    for i in range(A):
        if S[i] == "-":
            ans = "No"
            flag1 = 1
            break
    for j in range(A+1,A+B+1):
        if S[j] == "-":
            ans = "No"
            flag2 = 1
            break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int K,N,ans=10000000,sum=0;
    cin>>K>>N;
    int a[N+1],dis[N+1];
    for(int i=1;i<=N;i++)cin>>a[i];
    dis[0]=(K-a[N])+a[1];
    for(int i=1;i<N;i++){
        dis[i]=a[i+1]-a[i];
    }
    for(int i=0;i<N;i++){
        sum+=dis[i];
    }
    for(int i=0;i<N;i++){
        sum-=dis[i];
        if(sum<ans)ans=sum;
        sum+=dis[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

long long power(long long b, long long e){
    long long answer=1;
    for(int i=1; i<=e; i++){
        answer*=b;
    }
    return answer;
}
int main(){
    long long n, k;
    cin>>n>>k;
    cout<<k*power(k-1, n-1);
    return 0;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())
a, b, c, d = map(int, input().split())

l = lcm(c, d)
ans = (b - b//c - b//d + b//l) - (a - 1 - (a - 1)//c - (a - 1)//d + (a - 1)//l)
print(ans)

Measured memory_bytes: 5052
def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = 0
    max_list = [0]
    for i in range(n - 1):
        if h[i] >= h[i + 1]:
            ans += 1
            max_list.append(ans)
        else:
            ans = 0
    print(max(max_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include<stdio.h>
int main (void){
    int a,b,c,d;
    double e;
    scanf("%d%d",&a,&b);
    c=a/b;
    d=a%b;
    e=1.0*a/b;
    printf("%d %d %lf\n",c,d,e);
    return 0;
}


Measured memory_bytes: 2104
N,K = map(int,input().split())
H = list(map(int,input().split()))
def min_sum(N,K):
  dp=[float("inf")]*(N)
  for i in range(N):
    if i==0:
      dp[i]=0
    else:
      for j in range(1,K+1):
        if i-j>=0:
          dp[i]=min(dp[i],dp[i-j]+abs(H[i]-H[i-j]))
    
  return dp[N-1]

print(min_sum(N,K))

Measured memory_bytes: 55264
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[0]+v[1] << endl;
    return 0;
}

Measured memory_bytes: 256
def typing(s, ans):
    for i in range(len(s)):
        if s[i] == 'B' and len(ans) == 0:
            continue
        else:
            if s[i] == '0':
                ans.append('0')
            elif s[i] == '1':
                ans.append('1')
            elif s[i] == 'B':
                ans.pop()

    print(''.join(ans))

S = str(input())
ANS = []
typing(S, ANS)

Measured memory_bytes: 38256
from itertools import accumulate
from bisect import bisect_left,bisect_right
n,m,k=map(int,input().split())
a=list(accumulate(map(int,input().split()),initial=0))
b=list(accumulate(map(int,input().split()),initial=0))
ans=[0]
for i in range(n+1):
    c=bisect_right(b,k-a[i])-1
    if c!=-1:
        ans.append(c+i)
print(max(ans))


Measured memory_bytes: 45844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps DBL_EPSILON
#define moder 10007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,a;
multiset<int> st;
int func(int x){
	int s=1;
	while(s<=x)s*=2;
	return s;
}
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a;
		st.insert(a);
	}
	int ans=0;
	while(st.size()>1){
		auto x=*st.rbegin();
		st.erase(--st.end());
		auto it=st.find(func(x)-x);
		if(it!=st.end()){
			st.erase(it);
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

const int N = 105; 

int n, a[N], s, mx_a, v[N];
int main(int argc,char *argv[]){
	//freopen("d.in", "r", stdin); 
	cin >> n;
	vector<int> ans, cur_left(n); 
	lop(i, 0, n) {
		cin >> cur_left[i]; 
		s += cur_left[i]; 
		cmax(mx_a, cur_left[i]); 
	}
	lop(i, 0, n) if (mx_a > cur_left[i]*2) {
		cout << -1 << endl;
		return 0; 
	}
	while (ans.size() < s) {
		int m = ans.size();
		vector<int> best_left, best_add;
		rep(len, 1, n) {
			if (m+len < n || m+len > s) continue;
			auto left = cur_left; 
			lop(i, 0, n) v[i] = 1;
			lop(i, m-(n-len), m) 
				v[ans[i]] = 0;	
			lop(i, 0, n) if (v[i]) --left[i]; 
			int mn = left[0], mx = left[0];
			lop(i, 1, n) {
				cmin(mn, left[i]); 
				cmax(mx, left[i]); 
			}
			int mn_idx = n, mx_idx = -1, fail = 0, mx_r;
			lop(i, m-(n-len), m) {
				if (left[ans[i]] == mn) cmin(mn_idx, i-(m-(n-len))); 
				if (left[ans[i]] == mx) cmax(mx_idx, i-(m-(n-len))); 
			}
			if (mx <= mn*2) ;
			else if (mx == mn*2+1) {
				fail |= mn_idx < mx_idx; 
			} else fail = 1;
			if (fail) continue;
			vector<int> add;
			if (mx == mn*2+1){
				lop(i, 0, n) if (v[i] && left[i] == mx) mx_r = i;
				vector<int> z;
				lop(i, 0, n) if (v[i]) {
					if ((i > mx_r) || (left[i] > mn)) add.pb(i); 
					else z.pb(i); 
					if (i == mx_r) {
						add.insert(add.end(), z.begin(), z.end()); 
					}
				}	
			} else {
				lop(i, 0, n) if (v[i]) add.pb(i); 
			}
			if (best_add.empty() || add < best_add) best_add = add, best_left = left;
		}
		cur_left = best_left; 
		ans.insert(ans.end(), best_add.begin(), best_add.end()); 
	}
	for (int x : ans) cout << x+1 << " "; 
	cout << endl;
	return 0; 
}


Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
ll mod = 1e9+7;

int main() { 
  
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	sort(a,a+n);
	if(n==2) cout<<a[n-1];
	else if(n==3) cout<<a[n-1]+a[n-2];
	else {
		map<ll,ll> mp;
		mp[0] = a[n-1];
		mp[100000] = a[n-2];
		mp[200000] = a[n-3];
		mp[400000] = a[n-1];
	
		ll ans = a[n-1]+ a[n-2];
		vector<pair<ll,ll>> s;
		int f = n-4;
		while(f>=0) {
			s.clear();
			auto fri = mp.end();
			fri--;
		for(auto i = mp.begin(); i!=fri; i++) {
			auto r = i;
			r++;
			//cout<<i->second<<" "<<r->second<<"  ";
			ans += min(i->second,r->second);
			s.push_back(make_pair((ll)((i->first + r->first)/2),a[f]));
			f--;
			if(f<0) break;
		}
		for(auto ir = s.begin(); ir!=s.end(); ir++) {
			mp[ir->first] = ir->second;
		}
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 18716
import std;

// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line = readln.split;
foreach (i,T;TList){T val=line[i].to!(T);Args[i]=val;}}
void dprint(TList...)(TList Args){debug{auto s=new string[](TList.length);
static foreach(i,a;Args) s[i]=text(a);s.map!(text).join(' ').writeln;}}
alias sread=()=>readln.chomp();enum MOD =10^^9+7;
alias PQueue(T,alias less="a<b") = BinaryHeap!(Array!T,less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto H = aryread();
    auto G = new long[][](N);
    foreach (i; 0 .. M)
    {
        long a, b;
        scan(a, b);
        a--, b--;
        G[a] ~= b;
        G[b] ~= a;
    }
    long ans;
    o: foreach (i; 0 .. N)
    {
        foreach (g; G[i])
            if (H[i] <= H[g])
            {
                continue o;
            }
        ans++;
    }
    writeln(ans);
}


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

int main(){
    vector<vector<int>> A (3, vector<int>(3, 0));
    for(int i = 0; i < 3; i++){
        cin >> A.at(i).at(0) >> A.at(i).at(1) >> A.at(i).at(2);
    }
    int N;
    cin >> N;
    vector<int> b(N, 0);
    for(int i = 0; i < N; i++){
        cin >> b.at(i);
        for(int j = 0; j < 3; j++){
            if(A.at(j).at(0) == b.at(i)) A.at(j).at(0) = -1;
            if(A.at(j).at(1) == b.at(i)) A.at(j).at(1) = -1;
            if(A.at(j).at(2) == b.at(i)) A.at(j).at(2) = -1;
        }
    }
    string ans = "No";
    for(int i = 0; i < 3; i++){
        if(A.at(i).at(0) == -1 && A.at(i).at(1) == -1 && A.at(i).at(2) == -1) ans = "Yes";
        if(A.at(0).at(i) == -1 && A.at(1).at(i) == -1 && A.at(2).at(i) == -1) ans = "Yes";
    }
    if(A.at(0).at(0) == -1 && A.at(1).at(1) == -1 && A.at(2).at(2) == -1) ans = "Yes";
    if(A.at(0).at(2) == -1 && A.at(1).at(1) == -1 && A.at(2).at(0) == -1) ans = "Yes";

    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll N, M, a, b, price = 0, cnt = 0;
  cin >> N >> M;
  vector<pair<ll, ll>> shop(N);
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    shop[i] = make_pair(a, b);
  }
  sort(shop.begin(), shop.end());
  for (auto s : shop) {
    if (get<1>(s) >= M - cnt) {
      price += (M - cnt) * get<0>(s);
      cout << price << endl;
      return 0;
    } else {
      price += get<1>(s) * get<0>(s);
      cnt += get<1>(s);
    }
  }
}


Measured memory_bytes: 4468
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var items = new SortedSet<Item>();
        for (int i = 0; i < seqA.Length; ++i)
        {
            items.Add(new Item(seqA[i], i));
        }
        while (m > 0)
        {
            var item = items.Max;
            items.Remove(item);
            item.ApplyTicket();
            items.Add(item);
            --m;
        }
        
        Console.WriteLine(items.Sum(x => (long)x.Price));
    }

    class Item : IComparable<Item>
    {
        public int Price { get; private set; }
        public int Index { get; private set; }

        public Item(int price, int index)
        {
            Price = price;
            Index = index;
        }

        public void ApplyTicket() => Price /= 2;

        int IComparable<Item>.CompareTo(Item other) => this.Price != other.Price ? this.Price.CompareTo(other.Price) : this.Index.CompareTo(other.Index);

        public override string ToString() => Price.ToString();
    }
}


Measured memory_bytes: 36440
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int h,n;
    cin>>h>>n;
    
    vector<int> a(n);
    rep(i, n) cin>>a.at(i);
    int sum=accumulate(all(a),  0);
    if(h<=sum) dunk("Yes");
    else dunk("No");
}



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

const bool White = false;
const bool Black = true;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<bool>> mapVec(h, vector<bool>(w, White));
    vector<vector<long long>> colorFlipCellNumMatrixVec(h, vector<long long>(w, 0));

    for (int line = 0; line < h; ++line)
    {
        for (int row = 0; row < w; ++row)
        {

            char input;
            cin >> input;

            bool inputColor = ((input == '.') ? White : Black);

            mapVec.at(line).at(row) = inputColor;

            if (line == 0 && row == 0)
            {
                colorFlipCellNumMatrixVec.at(line).at(row) += (inputColor == White ? 0 : 1);
            }
            else
            {
                if (line == 0)
                {
                    colorFlipCellNumMatrixVec.at(line).at(row) += colorFlipCellNumMatrixVec.at(line).at(row - 1);

                    if (inputColor != mapVec.at(line).at(row - 1))
                    {
                        colorFlipCellNumMatrixVec.at(line).at(row) += (inputColor == White ? 0 : 1);
                    }
                }
                else if (row == 0)
                {
                    colorFlipCellNumMatrixVec.at(line).at(row) += colorFlipCellNumMatrixVec.at(line - 1).at(row);

                    if (inputColor != mapVec.at(line - 1).at(row))
                    {
                        colorFlipCellNumMatrixVec.at(line).at(row) += (inputColor == White ? 0 : 1);
                    }
                }
                else
                {
                    long long topFlipNum = colorFlipCellNumMatrixVec.at(line - 1).at(row), leftFlipNum = colorFlipCellNumMatrixVec.at(line).at(row - 1);

                    if (inputColor != mapVec.at(line - 1).at(row))
                    {
                        topFlipNum += (inputColor == White ? 0 : 1);
                    }

                    if (inputColor != mapVec.at(line).at(row - 1))
                    {
                        leftFlipNum += (inputColor == White ? 0 : 1);
                    }

                    colorFlipCellNumMatrixVec.at(line).at(row) += min(topFlipNum, leftFlipNum);
                }
            }
        }
    }

    // for (int l = 0; l < h; ++l)
    // {
    //     for (int r = 0; r < w; ++r)
    //     {
    //         cout << colorFlipCellNumMatrixVec.at(l).at(r) << " ";
    //     }
    //     cout << endl;
    // }

    cout << colorFlipCellNumMatrixVec.at(h - 1).at(w - 1) << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
using namespace std;
int main(void)
{
	char mo[10][6]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	char buf[1025];
	int le[10]={0,5,3,3,3,3,3,4,3,4};
	int i,j,wk,x,px,py,n,len;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%s",buf);
		len=strlen(buf);
		py=0;	px=-1;
		for(j=0;j<len;j++)	{
			x=buf[j]-'0';
			if(x==0)	{
				if(py!=0)	{
					printf("%c",mo[py][px]);
					py=0;	px=-1;
				}
			}
			else {
				py=x;
				px++;
				px=px%le[py];
			}
//			printf("py=%d px=%d\n",py,px);
		}
		printf("\n");
	}
		
	return 0;
}


Measured memory_bytes: 1000
#include <stdio.h>

int main( void ) {

	int d, h, area;

	while (	scanf( "%d", &d ) != EOF ) {

		area = 0;

		for ( h = d; h < 600; h += d ) {
			
			area += h * h * d;

		}

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

	}

	return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

int inf = 1000000000;
int dp[1000010][2];

int main() {
  iostream_init();
  string s;
  cin >> s;
  reverse(all(s));
  s += '0';
  int n = len(s);
  rep(i,0,n+1) rep(j,0,2) dp[i][j] = inf;
  dp[0][0] = 0;
  rep(i,0,n) rep(j,0,2) {
    int d = s[i]-'0';
    d += j;
    if (d < 10) dp[i+1][0] = min(dp[i+1][0], dp[i][j]+d);
    if (d > 0) dp[i+1][1] = min(dp[i+1][1], dp[i][j]+10-d);
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12208