akhauriyash/Code-Regression huggingface dataset:
A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
# n, k = map(int, input().split())
# p = math.ceil(sum(X)/n)
for i in range(3):
    for j in range(3):
        for k in range(n):
            if A[i][j] == B[k]:
                A[i][j] = 0
ans = False
# 横軸を確認
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += A[i][j]
    if cnt == 0:
        ans = True
# 縦軸を確認
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += A[j][i]
    if cnt == 0:
        ans = True
# 斜めの確認
cnt = 0
for i in range(3):
    cnt += A[i][i]
if cnt == 0:
    ans = True

cnt_2 = 0
for i in range(3):
    cnt_2 += A[i][2-i]
if cnt_2 == 0:
    ans = True

print("Yes") if ans else print("No")


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!
N,C,K=map(int,input().split())



T=[]
for i in range(N):
   T.append(int(input()))

T.sort()

t_ride=0
n_ride=0
count=0
for t in T:
    if t_ride==0:
        t_ride=t
        n_ride+=1
        count+=1
    else:
        if t-t_ride>K or n_ride==C:
            t_ride=t
            n_ride=1
            count+=1
        else:
            n_ride+=1
            
print(count)

Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int N;
    cin >> N;
    P a[N], b[N];
    ll A, B;
    rep(i, N){
        cin >> A;
        a[i] = P(A, i);
    }
    rep(i, N){
        cin >> B;
        b[i] = P(B, i);
    }
    sort(a, a+N);
    sort(b, b+N);
    bool scarce = false, enough = false;
    rep(i, N) if(a[i].first > b[i].first) scarce = true;
    rep(i, N-1) if(b[i].first >= a[i+1].first) enough = true;
    if(scarce) cout << "No" << endl;
    else if(enough) cout << "Yes" << endl;
    else{
        int f[N];
        rep(i, N) f[a[i].second] = b[i].second;
        set<int> s;
        s.insert(0);
        int tmp = 0;
        while(true){
            tmp = f[tmp];
            if(tmp == 0) break;
            else s.insert(tmp);
        }
        if(s.size() == N) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int ans=0;

  int n; cin >> n;
  vector<int> v(n); REP(i, n) cin >> v[i];
  vector<int> c(n); REP(i, n) cin >> c[i];

  REP(i,n) {
    if(v[i]>c[i]) ans+=(v[i]-c[i]);
  }

  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main(){
    vector<int> vec(3);
    for (int i=0; i<3; i++){
        cin >> vec[i];
    }
    sort(begin(vec), end(vec));
    int ans=0;
    ans += (vec[1] - vec[0]) / 2;
    vec[0] += ans * 2;
    if (vec[0] != vec[1]){
        vec[2] += 1;
        ans += 1;
    } 
    ans += vec[2] - vec[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

long long power(long long n, long long p) {
	if (p == 0)
		return 1;
	long long res = 1;
	long long add = n;
	while (p > 0) {
		if (p & 1)
			res = (res * add);
		p >>= 1;
		add = add*add;
	}
	return res;
}

bool check(long long T, long long N, long long a) {
	// division
	long long div;
	if (a == 0)
		div = T;
	else
		div = T / a;

	if (div == 0)
		div = 1;

	IFOR(k, 1, div+10) {
		// mはT未満
		// rはk未満（T未満）
		long long m = (T - (k - 1)*a) / k;
		long long r = (T - (k - 1)*a) % k;
		if (m <= 0)
			continue;
		// (m+1)をr回、mをk-r回かける
		// でかすぎ注意
		double exper = pow(m, k - r) * pow(m + 1, r);
		if (exper > N) {
			return true;
		}
		// 最大限作れるクッキーの数
		long long res = power(m, k - r) * power(m + 1, r);
		if (res >= N)
			return true;
	}
	return false;

}


int main() {
	long long n, a;
	cin >> n >> a;

	long long lb = 0, ub = n;
	while (ub - lb > 1) {
		long long half = (lb + ub) / 2;
		if (check(half, n, a)) {
			ub = half;
		}
		else {
			lb = half;
		}
	}
	cout << ub << endl;
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};

const static double EPS = 1e-8;

vector<string> candidates;

int dfs(int pos,int used,const string& encrypted,string current){
  if(pos == encrypted.size()){
    candidates.push_back(current);
    return 1;
  }
  int res = 0;
  for(int offset = 0; offset <= 1; offset++){
    if(encrypted[pos] == 'z' && offset == 1) continue;
    if(offset == 0){
      if(encrypted[pos] != 'a' 
         && !(used & (1 << ((encrypted[pos] + offset) - 'a')))) continue;
      res += dfs(pos + 1,used,encrypted,current + (char)(encrypted[pos] + offset));
    }
    else if(offset == 1){
      if(used & (1 << ((encrypted[pos] + offset) - 'a'))) continue;
      res += dfs(pos + 1,used | (1 << ((encrypted[pos] + offset) - 'a')),encrypted,current + (char)(encrypted[pos] + offset));
    }
  }
  return res;
}

int main(){
  string str;
  while(cin >> str){
    if(str == "#") break;
    candidates.clear();
    printf("%d\n",dfs(0,0,str,""));
    sort(candidates.begin(),candidates.end());
    if(candidates.size() > 10){
      for(int i = 0; i < 5; i++){
        cout << candidates[i] << endl;
      }
      for(int i = candidates.size() - 5; i < candidates.size(); i++){
        cout << candidates[i] << endl;
      }
    }
    else{
      for(int i = 0; i < candidates.size(); i++){
        cout << candidates[i] << endl;
      }
    }
  }
}

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

ll dp[101][100001];
ll inf = 1e10;

int main(){
    int N,W;
    cin >> N >> W;
    rep(i, 100001) dp[0][i] = inf;
    dp[0][0] = 0;
    int vmax = 1000 * N;

    for (int i = 1; i <= N; i++) {
        int w, v;
        cin >> w >> v;
        for (int j = 0; j <= vmax; j++) {
            if (j >= v)
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    for (int i = vmax; i >= 0; i--) {
        if (dp[N][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 82540
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}

int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<0;
		return 0;
	}
	else
	cout<<a-b;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
dp = [float('Inf')] * (n + 1)
dp[0] = 0
for i in range(1, n + 1):
    j = 1
    while j <= i:
        dp[i] = min(dp[i], dp[i - j] + 1)
        j *= 6
    j = 1
    while j <= i:
        dp[i] = min(dp[i], dp[i - j] + 1)
        j *= 9
print(dp[n])

Measured memory_bytes: 44880
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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 int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin >> k;
    vector<vector<ll>> sum(10,vector<ll>(10,0));
    rep(i,10) sum[0][i] = 1;
    rep2(i,1,10) rep(j,10) {
        sum[i][j] = sum[i-1][j];
        if(j > 0) sum[i][j] += sum[i-1][j-1];
        if(j < 9) sum[i][j] += sum[i-1][j+1];
    }
//    rep(i,3) rep(j,10) cout << sum[i][j] << endl;
    ll nsum = 0;
    rep(i,10) {
        ll l = 0;
        rep2(j,1,10) l += sum[i][j];
        if(nsum+l < k) {
            nsum += l;
        } else {
            int d;
            k -= nsum;
//            cout << nsum << endl;
            rep2(j,1,10) {
                if(sum[i][j] >= k) {
                    d = j;
                    break;
                } else {
                    k -= sum[i][j];
                }
            }
            cout << d;
            int now = i-1;
            while(now >= 0) {
                if(d > 0) {
                    if(sum[now][d-1] >= k) {
                        d = d-1;
                        cout << d;
                        now--;
                        continue;
                    } else {
                        k -= sum[now][d-1];
                    }
                }
                if(sum[now][d] >= k) {
                    cout << d;
                    now--;
                    continue;
                } else {
                    k -= sum[now][d];
                }
                d = d+1;
                now--;
                cout << d;
            }
            break;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    int cnt2 = 0;
    int Cpoint = -1;
    int judge = 0;
    for(int i = 2 ; i < S.size() - 1; i++)
    {
        if(S.at(i) == 'C')
        {
            if(Cpoint != -1) // Cが既に出ている場合は
            {
                cnt2 = -1;
                Cpoint == -2; // Cpointに-2を代入しbreak
                break;
            }
            cnt2++;
            Cpoint = i;
        }
    }
    if(Cpoint != -2  && Cpoint != -1) //Cが一回出現した場合のみ実行
    {
        for(int i = 1; i < S.size(); i++)
        {
        
            if(isupper(S.at(i))) //Sのi番目が大文字なら実行
            {
                if(i == 1 || i == S.size() - 1 || S.at(i) !='C')  //Ｓが1番目か末尾で大文字ならWA、大文字がＣ以外でもWA
                {                                                 //ＳにＣが二つ以上ある場合や一回も出現していない場合は除外済み
                    judge = 1;           //judge = 1ならWAにする
                    break;
                }
            }
        }
    }
    if(S.at(0) == 'A' && cnt2 == 1 && judge == 0)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll ans = min(b - 1, n);
  cout << ll(a * ans / b) - a * ll(ans / b) << endl;
}

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

using namespace std;

using ll = long long;

bool IsSquare(int n) {
    for (int i = 1; i * i <= n; ++i)
        if (i * i == n) return true;
    return false;
}

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

    string a, b;
    cin >> a >> b;
    string c = a + b;
    if (IsSquare(stoi(c))) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll cnt[1010101];

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

    rep(i,n)if(s[i]=='M')++cnt[i];
    rep(i,n)cnt[n-i-1]+=cnt[n-i];

    int q;cin>>q;

    while(q--){
        int k;cin>>k;
        deque<pli> dq;
        ll sum=0,ans=0,sz=0;
        rep(i,n){
            if(s[i]=='D'){
                ++sz;
                sum+=cnt[i];
                dq.push_back({cnt[i],i});
            }
            else if(s[i]=='C'){
                while(sz&&dq.front().second<=i-k){
                    --sz;
                    sum-=dq.front().first;
                    dq.pop_front();
                }
                ans+=sum-cnt[i]*sz;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 25460
n = int(input())
lst = list(map(int,input().split()))
if n==1 or n==2:
    print(1)
else:
    cnt = 0
    num = lst[0]
    mode = 0
    for i in range(1,n):
        if mode==0:
            if lst[i]==num:
                continue            
            elif lst[i] > num:
                mode = 1
            elif lst[i] < num:
                mode = 2
        elif mode == 1:
            if lst[i] < num:
                cnt += 1
                mode = 0
        elif mode == 2:
            if lst[i] > num:
                cnt += 1
                mode = 0
        num = lst[i]
    print(cnt + 1)

Measured memory_bytes: 14436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll k;
void gen(vector<ll> &num,ll len, ll lastdig){
    if(k<=0){
        return;
    }
    if(num.size()==len){
        k--;
        if(k==0){
            for(auto x : num){
                cout << x;
            }
            cout <<  "\n";
        }
        return;
    }
    if(num.size()==0){
        for(ll dig=1; dig<=9; dig++){
            num.push_back(dig);
            gen(num, len, dig);
            num.pop_back();
        }
        return;
    }
    for(ll dig=max(0ll,lastdig-1); dig<=min(9*1ll, lastdig+1); dig++){
        num.push_back(dig);
        gen(num, len, dig);
        num.pop_back();
        if(k<=0){
            return;
        }
    }

}

void solve(){

    cin >> k;
    vector<ll> num;
    for(ll len=1; k>0; len++) gen(num, len, 0);

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 3640
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd
# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from queue import PriorityQueue as pq

# # from itertools import accumulate
# # from collections import deque
# import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    # eprint(l)
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    # eprint(l)
    l.sort()
    # eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.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 mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string s;
	while(getline(cin,s)){
		//cout<<s<<endl;
		vector<string>in;
		int b=0;
		rep(i,s.size()){
			if(s[i]==' '){
				in.pb(s.substr(b,i-b));
				b=i+1;
			}	
		}
		in.pb(s.substr(b));
		vector<double>out;
		rep(i,in.size()){
			if(in[i]=="+"||in[i]=="-"||in[i]=="*"||in[i]=="/"){
				double a=out[out.size()-2];
				double b=out[out.size()-1];
				out.pop_back();
				out.pop_back();
				//cout<<a<<" "<<b<<endl;
				if(in[i]=="+")a+=b;
				if(in[i]=="-")a-=b;
				if(in[i]=="*")a*=b;
				if(in[i]=="/")a/=b;
				out.pb(a);
				//rep(j,out.size())cout<<out[i]<<" ";
				//cout<<endl;
			}else out.pb(atoi(&in[i][0]));
			//rep(j,out.size())cout<<out[j]<<" ";
			//cout<<endl;
		}
		printf("%.9lf\n",out[0]);
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, r; cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main()
{
    std::string str;
    
    std::cin >> str;
    int sum = 0;
    for (int i = 0; i < str.size(); i++)
    {
        sum += str[i] - '0';
   }

    std::string ans = sum % 9 == 0 ? "Yes" : "No";
    std::cout << ans << std::endl;

    
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

const int MAX_N=1e5;
int N;
ll L;

ll gru(ll x){
	ll ret=1;
	while(x%ret==0){
		ret<<=1;
	}
	ret>>=1;
	return ret;
}

struct ver{
	ver *e[2];
	ll dep;
	ver(){
		REP(i,2)e[i]=0;
		dep=0;
	}
};

ver rot;

ll dfs(ver *v){
	ll ret=0,c=0;
	REP(i,2){
		if (v->e[i]!=0){
			ret^=dfs(v->e[i]);
			c++;
		}
	}
	if (c==1){
		ret^=gru(L-v->dep);
	}
	return ret;
}

void era(ver *v){
	REP(i,2){
		if (v->e[i]!=0){
			era(v->e[i]);
			delete v->e[i];
		}
	}
}

int main(){
	cin>>N>>L;
	REP(i,N){
		string s;
		cin>>s;
		ver *ite=&rot;
		for(auto c:s){
			int f=c-'0';
			if (ite->e[f]==0){
				ite->e[f]=new ver;
				ite->e[f]->dep=ite->dep+1;
			}
			ite=ite->e[f];
		}
	}
	cout<<(dfs(&rot) ? "Alice" : "Bob")<<endl;
	era(&rot);
	return 0;
}

Measured memory_bytes: 6656
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 305;

string st;
int K_mx;

short int dp[MAX_N][MAX_N][MAX_N];

int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    
    cin>>st>>K_mx;

    int n = (int) st.length();
    for (int i=0; i<n; i++)
        dp[i][i][0] = 1;

    for (int len=2; len<=n; len++)
        for (int i=0; i+len-1 < n; i++) {
            int j = i+len-1;
            for (int old_k = 0; old_k <= K_mx; old_k++) {
                dp[i][j][old_k] = max(dp[i][j][old_k], max(dp[i+1][j][old_k], dp[i][j-1][old_k]));
                if (st[i] == st[j])
                    dp[i][j][old_k] = max(dp[i][j][old_k], (short int) (dp[i+1][j-1][old_k] + 2));
                else if (old_k + 1 <= K_mx)
                    dp[i][j][old_k+1] = max(dp[i][j][old_k+1], (short int) (dp[i+1][j-1][old_k] + 2));
            }
        }

    short int ans = 0;
    for (int old_k=0; old_k<=K_mx; old_k++)
        ans = max(ans, dp[0][n-1][old_k]);
    cout<<ans;
   	return 0;
}

Measured memory_bytes: 55552
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n; cin >> n; vector<int> a(n);
  for(auto &x: a) cin >> x;
  int ans = 0;
  for(int i = 1; i < n - 1; i++) {
    int b[3] = {a[i - 1], a[i], a[i + 1]};
    sort(b, b + 3);
    if(b[1] == a[i]) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int x[101]={0};
  int n;
  while(cin>>n) x[n]++;
  int maxi=-INF;
  rep(i,101)if(maxi<x[i])maxi=x[i];
  rep(i,101)if(maxi==x[i])cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s; cin >> s;
    string a = "CODEFESTIVAL2016";


    ll ans = 0;

    rep(i,s.size()){
        if(s[i]!=a[i])ans++;
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int h, w, a[505][505], ans, b[505][505];
signed main() {
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> a[i][j], b[i][j] = a[i][j];
	rep(i, h)rep(j, w) {
		if (a[i][j] % 2) {
			if (j == w - 1 && i != h - 1) {
				ans++;
				a[i][j]--;
				a[i + 1][j]++;
			}
			else if (j != w - 1) {
				ans++;
				a[i][j]++;
				a[i][j + 1]++;
			}
		}
	}
	cout << ans << endl;
	rep(i, h)rep(j, w) {
		if (b[i][j] % 2) {
			if (j == w - 1 && i != h - 1) {
				b[i][j]--;
				b[i + 1][j]++;
				cout << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1 << endl;
			}
			else if (j != w - 1) {
				b[i][j]--;
				b[i][j + 1]++;
				cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
			}
		}
	}
	endre;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n, X;
  cin >> n >> X;
  vector<int> arr(n), L(n), R(n), order(n);
  vector<ll> val(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i] >> L[i] >> R[i];
    val[i] = (ll)arr[i] * L[i] + (ll)(X - arr[i]) * R[i];
    order[i] = i;
  }
  sort(order.begin(), order.end(), [&] (int x, int y) {
    return val[x] > val[y];
  });
  ll goal = 0;
  for (int i = 0; i < n; i++) {
    goal += (ll)arr[i] * L[i];
  }
  int idx = 0;
  while (idx < n && goal > val[order[idx]]) {
    goal -= val[order[idx]];
    idx++;
  }
  ll ans = X;
  for (int i = idx; i < n; i++) {
    if (goal <= (ll)arr[order[i]] * L[order[i]]) {
      ans = min(ans, (goal + L[order[i]] - 1) / L[order[i]]);
    } else {
      ans = min(ans, (goal - (ll)arr[order[i]] * L[order[i]] + R[order[i]] - 1) / R[order[i]] + arr[order[i]]);
    }
  }
  ans += (ll)X * idx;
  if (idx < n) {
    goal -= val[order[idx]];
    for (int i = 0; i < idx; i++) {
      goal += val[order[i]];
      if (goal <= (ll)arr[order[i]] * L[order[i]]) {
        ans = min(ans, (ll)X * idx + (goal + L[order[i]] - 1) / L[order[i]]);
      } else {
        ans = min(ans, (ll)X * idx + (goal - (ll)arr[order[i]] * L[order[i]] + R[order[i]] - 1) / R[order[i]] + arr[order[i]]);
      }
      goal -= val[order[i]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(b % a == 0 ? a + b : b - a);
	}
}


Measured memory_bytes: 35668
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
   int N=int.Parse(Console.ReadLine());
     string[] str1=Console.ReadLine().Split(' ');
      int[] time=str1.Select(int.Parse).ToArray();
      int M=int.Parse(Console.ReadLine());
      int[] newTime=new int[N];
      for(int i=0;i<M;i++){
        time.CopyTo(newTime,0);
        string[] str=Console.ReadLine().Split(' ');
        int P=int.Parse(str[0]);
        int X=int.Parse(str[1]);
        newTime[P-1]=X;
        Console.WriteLine(newTime.Sum());
        
      }
      
    }
    
  }

}


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

using namespace std;

int D[200000];
int L[200000];
int R[200000];

int main() {
    string line; cin >> line;
    int l, r;
    for(int i = 0; i < line.size(); ++i) {
        if(line[i] == 'R') r = i;
        R[i] = r;
    }
    
    for(int i = line.size() - 1; i > -1; --i) {
        if(line[i] == 'L') l = i;
        L[i] = l;
    }
    
    for(int i = 0; i < line.size(); ++i) {
        if(line[i] == 'L') {
            if((R[i] - i) & 1) D[R[i] + 1] += 1;
            else D[R[i]] += 1;
        } else {
            if((i - L[i]) & 1) D[L[i] - 1] += 1;
            else D[L[i]] += 1;
        }
    }
    
    for(int i = 0; i < line.size(); ++i)
        cout << D[i] << ' ';
    
    return 0;
}

Measured memory_bytes: 1792
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    ll a,b,c;
    s ss;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7){cout<<"YES";}
    else if(a==5&&b==7&&c==5){cout<<"YES";}
    else if(a==7&&b==5&&c==5){cout<<"YES";}
    else{cout<<"NO";}
return 0;}


Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
#endif
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <string>
using namespace std;
const int maxn = 1e4+5;
bitset<maxn>b[maxn];

int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	#endif
	int r, c;
	while(scanf("%d%d", &r, &c) && r){
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				int t;
				scanf("%d", &t);
				b[i][j] = t;
			}
		}
		int ans = 0;
		for(int i = 0; i < (1<<r); i++){
			for(int j = 0; j < r; j++){
				if(i & (1 << j)){
					b[j].flip();
				}
			}
			int sum = 0;
			for(int j = 0; j < c; j++){
				int t = 0;
				for(int k = 0; k < r; k++){
					if(b[k][j]) t++;
				}
				sum += min(t, r-t);
			}
			ans = max(ans, r*c-sum);
			for(int j = 0; j < r; j++){
				if(i & (1 << j)){
					b[j].flip();
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3152
/************************************************************
	> File Name: c.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 22 Dec 2019 10:15:00 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(void){
	IOS;
	ll a, b;
	cin >> a >> b;
	cout << lcm(a,b) << endl;
	return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())

# Xから0かNかどちらに行くのがコストが安いか。
a = 0
b = 0
A = list(map(int, input().split()))
for i in range(M):
    if A[i] < X:
        a += 1
    else:
        b += 1
print(min(a,b))

Measured memory_bytes: 3060
n = int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
    ans = 0
    for j in range(i,n-1):
       c,s,f = csf[j]
       ans = max(s,ans+abs(ans%-f))
       ans += c
    print(ans)
print(0)

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  reverse(h.begin(), h.end());
  rep(i, n-1) {
    if (h[i+1] - h[i] > 1) {
      cout << "No" << endl;
      return 0;
    }
    if (h[i+1] - h[i] == 1) {
      h[i+1]--;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, k; cin >> n >> k;
  int rt = sqrt(n);
  vi tmp;
  rep(i,rt) tmp.push_back(1);
  int div = n / rt - 1;
  int quot = rt;
  while (div > 0) {
    int nq = n / div;
    tmp.push_back(nq - quot);
    --div;
    quot = nq;
  }
  reverse(all(tmp));
  int sz = tmp.size();
  Graph dp(k, vi(sz));
  dp[0] = tmp;
  rep(i,k-1) {
    ll sum = 0;
    rep(j,sz) {
      sum += dp[i][sz-1-j];
      dp[i+1][j] = dp[0][j] * sum % MOD;
    }
  }
  int ans = accumulate(all(dp.back()), 0LL) % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  
  if(str.at(2)== str.at(3) && str.at(4) == str.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 768
#include <iostream>
#include<string>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;

    if(n>k)cout<<k*x+(n-k)*y<<endl;
    else cout<<n*x<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{

  int n, k;
  cin >> n >> k;

  int maxTimes = 0;
  int max = 1;
  while (true)
  {
    if (max >= k)
    {
      break;
    }

    maxTimes++;
    max = max << 1;
  }

  if (maxTimes == 0)
  {
    cout << 1;
  }
  else
  {
    long long allPattern = (1 << maxTimes) * n;
    long long winPattern = 0;

    vector<int> times(n+1, 0);
    for (int i = 1; i < n+1; i++)
    {

      int tmp = i;
      while (true)
      {
        if (tmp >= k)
        {
          break;
        }

        times[i]++;
        tmp = tmp << 1;
      }
    }

    for (int i = 1; i < n+1; i++)
    {
      winPattern += 1 << (maxTimes - times[i]);
    }

    cout << fixed << setprecision(12) << (double)winPattern / (double)allPattern;
  }

  return 0;
}

Measured memory_bytes: 3300
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <cstdio>
using namespace std;

typedef long long ll;
struct Right {
  ll val;
  int pos;
};
inline bool operator <(const Right &a, const Right &b) {
  if(a.val < b.val) return true;
  if(a.val > b.val) return false;
  return a.pos < b.pos;
}
inline bool operator >(const Right &a, const Right &b) {
  return b < a;
}

int myfind(vector<Right> &list, ll val, int pos) {
  int left = 0, right = list.size() - 1;
  while(true) {
    int mid = (left + right) / 2;
    if(val < list[mid].val) right = mid - 1;
    else if(val > list[mid].val) left = mid + 1;
    else {
      if(pos < list[mid].pos) right = mid - 1;
      else if(pos > list[mid].pos) left = mid + 1;
      return mid;
    }
  }
  return -1;
}
int main() {
  ll ans = - ( 1LL << 60);
  int n; scanf("%d", &n);
  const int N = n;
  vector<ll> a(3 * N);
  for(int i = 0; i < 3 * N; i++) {
    static int tmp; scanf("%d", &tmp);
    a[i] = tmp;
  }
  ll leftsum = 0;
  priority_queue<ll, vector<ll>, greater<ll> > lque;
  for(int i = 0; i < N; i++) {
    lque.push(a[i]);
    leftsum += a[i];
    //    cout << a[i] << " " << leftsum << " " << lque.top() << endl;
  }
  vector<Right> rlist(2 * N);
  for(int i = N; i < 3 * N; i++) {
    rlist[i - N] = (Right){a[i], i};
  }
  sort(rlist.begin(), rlist.end());
  //    for(int i = 0; i < rlist.size(); i++) {
  //      cout << rlist[i].val << " " << rlist[i].pos << endl;
  //    }
  ll rightsum = 0;
  for(int i = 0; i < N; i++) rightsum += rlist[i].val;
  ans = max(ans, leftsum - rightsum);
  //  cout << ans << " " << leftsum << " " << rightsum << endl;
  int rpos = N;
  for(int p = N; p < 2 * N; p++)  {
    lque.push(a[p]);
    leftsum += (a[p] - lque.top());
    lque.pop();
    int t = myfind(rlist, a[p], p);
    if(t < rpos) {
      rightsum -= a[p];
      while(true) {
        rpos++;
        if(rlist[rpos-1].pos > p) {
          rightsum += rlist[rpos-1].val; break;
        }
      }
    }
    ans = max(ans, leftsum - rightsum);
    //    cout << p << " " << ans << " " << leftsum << " " << rightsum << endl;
  }
  //  cout << "Answer=";
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a,b;
    double s;
    cin >> a >> b;

    s = (a+b)/2.0;
    if((s-(a+b)/2) > 0){
        s = (a+b)/2+1;
    }else{
        s = (a+b)/2;
    }

    cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void selection_sort(int* A, int n);
void print_line(int* A, int n);
void swap(int* a, int* b);

int main(void){
    int N;
    int A[100];
    int i;
    scanf("%d", &N);

    for(i = 0; i < N; ++i){
        scanf("%d", &A[i]);
    }
    selection_sort(A, N);
    return 0;
}

void selection_sort(int* A, int N){
    int i, j;
    int mini;
    int count = 0;
    for(i = 0; i <= N-1; ++i){
        mini = i;
        for(j=i; j <=N-1; ++j){
            if(A[j] < A[mini]) {
                mini = j;
            }
        }
        swap(&A[i], &A[mini]);
        if(i != mini) count++;
    }
    print_line(A, N);
    printf("%d\n", count);
}

void print_line(int *A, int N){
    int i;
    for(i = 0; i < N-1; ++i){
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
}

void swap(int* a, int* b){
    int tmp;
    tmp = *b;
    *b = *a;
    *a = tmp;
}


Measured memory_bytes: 1988
N = int(input())
pos_list = []
for _ in range(N):
    X, L = map(int, input().split())
    pos_list.append([X + L, X - L])
sorted_data = sorted(pos_list)
# print(pos_list)
ans = 0
current = -(10 ** 9)
for val in sorted_data:
    if current <= val[1]:
        ans += 1
        current = val[0]
print(ans)


Measured memory_bytes: 25172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int N, C;
int D[33][33], t[3][33];

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

    scanf("%d%d", &N, &C);
    rep(i, C) rep(j, C) scanf("%d", &D[i][j]);
    rep(i, N) rep(j, N){
        int x;
        scanf("%d", &x);
        t[(i+j)%3][x-1]++;
    }

    int res = 1<<30;
    rep(i, C) rep(j, C){
        if(i != j){
            rep(k, C){
                if(i != k && j != k){
                    int tt = 0;
                    rep(l, C) tt += D[l][i]*t[0][l];
                    rep(l, C) tt += D[l][j]*t[1][l];
                    rep(l, C) tt += D[l][k]*t[2][l];
                    if(tt < res) res = tt;
                }
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}

vector<ll> G[200050];//辺
vector<ll> stock(200050,0);
vector<bool> visited(200050);

void dfs(ll x){
    visited[x]=true;
    
    rep(i,sz(G[x])){
        if(!visited[G[x][i]]){
            stock[G[x][i]]+=stock[x];
            dfs(G[x][i]);
        }
    }
}

int main(){
    ll N,Q; cin>>N>>Q;
    rep(i,N-1){
        ll A,B; cin>>A>>B;
        G[A].pb(B);
        G[B].pb(A);
    }
    rep(i,Q){
        ll p,x; cin>>p>>x;
        stock[p]+=x;
    }
    dfs(1);
    rep1(i,N){
        cout<<stock[i]<<" ";
    }
}



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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int w, a, b;
  cin >> w >> a >> b;
  
  if (a < b) {
    cout << max(b - (a + w), 0) << "\n";
  } else {
    cout << max(a - (b + w), 0) << "\n";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    String s = stdIn.next();
    int ans = 0;

    if (s.equals("SUN")) {
      ans = 7;
    } else if (s.equals("MON")) {
      ans = 6;
    } else if (s.equals("TUE")) {
      ans = 5;
    } else if (s.equals("WED")) {
      ans = 4;
    } else if (s.equals("THU")) {
      ans = 3;
    } else if (s.equals("FRI")) {
      ans = 2;
    } else {
      ans = 1;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
package main

import "fmt"

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

	fmt.Println(lcm(a,b))

}

func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)

	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}


Measured memory_bytes: 512