akhauriyash/Code-Regression huggingface dataset:
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modularExponentiation(ll x,ll n,ll M);
void dsp(vector<ll> &V);
void dsp2(vector<pair<ll,ll>>&V);
void dsp3(map<ll,ll>&M);
double fact(double n);
ll nPr(ll n,ll r);
ll nCr(ll n,ll r);
ll r[40001];
ll c[40001];
void solve()
{
   ll n,a,b;cin>>n>>a>>b;
   ll cnt=0;
   cnt=(n/(a+b))*a;
   if(n%(a+b)<=a)
   cnt+=(n%(a+b));
   else
   {
       cnt+=a;
   }
   cout<<cnt<<"\n";
}
int main()
{
   fastio
    solve();
  return 0;
}
ll gcd(ll a,ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
          
} 
ll lcm(ll a,ll b)  
{  
    return (a*b)/gcd(a, b);  
}  
ll modularExponentiation(ll x,ll n,ll M)
{   
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
        result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
        return result;
}
void dsp(vector<ll> &V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j]<<" ";
    }
    cout<<endl;
}
void dsp2(vector<pair<ll,ll>>&V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j].first<<" "<<V[j].second<<" ";
    }
    cout<<endl;
}
void dsp3(map<ll,ll>&M)
{
      map<ll,ll>::iterator it=M.begin();
      while(it!=M.end())
      {
        cout<<it->first<<" "<<it->second<<endl;
        it++;
      }
}
double fact(double n)
{
    double i=1;
    double res=1;
    
    if(n==0)
        return 1.00;
    
    while(i<=n)
    {
        res*=i;
        i++;
    }
    
    return res;
}
ll nPr(ll n,ll r)
{
    return (fact(n)/fact(n-r));
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>

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

using namespace std;
typedef long long ll;
int main(){
	int n,w;
	cin>>n>>w;
	int a[n],wi[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>wi[i];}
	ll dp[n+1][w+1];
	for(int i=0;i<w+1;i++)
		dp[0][i]=0;
	for(int i=1;i<n+1;i++)
		dp[i][0]=0;
	for(int i=1;i<n+1;i++){
		for(int j=1;j<w+1;j++){
			if(j-a[i-1]>=0)
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1]]+wi[i-1]);
			else 
				dp[i][j]=dp[i-1][j];
		}
	}
	/*for(int i=0;i<n+1;i++){
		for(int j=0;j<w+1;j++){
			cout<<dp[i][j]<<" ";}
		cout<<endl;
	}*/
	cout<<dp[n][w]<<endl;
	
	
	}
	

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cassert>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int N;
string S;

int main()
{
  cin >> N >> S;
  int min_cnt = 1e8;

  vector<pair<int,int> > v;
  // kより左のWの数 l
  // kより右のEの数 r
  int r0 = 0;
  REP(i,1,N) if(S[i] == 'E') ++r0;
  v.push_back(make_pair(0,r0));
  // ↑ Case k = 0

  // Case k > 0
  REP(k,1,N) {
    int l, r;
    tie(l,r) = v[k - 1];
    if (S[k - 1] == 'W') ++l;
    if (S[k] == 'E') --r;
    v.push_back(make_pair(l,r));
  }

  REP(k,0,N) {
    //k-th をリーダーに
    int l, r;
    tie(l,r) = v[k];

    min_cnt = min(min_cnt, l + r);
  }

  cout << min_cnt << endl;

  return 0;
}


Measured memory_bytes: 6776
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 110000
ll MOD=1e9+7;

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

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

class Cube{
public:
  int f[6]; //??????????????°???
  Cube(){} //?????????????????????
  void roll_z(){ roll(1, 2, 4, 3);} //????????????????????§??????????????????????????°???????????¨????????????
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }

  void move(char ch){
    if (ch == 'E') for ( int i = 0; i < 3; i++) roll_y(); //3?????\??????????????°????????¢??¨?????????
    if (ch == 'W') roll_y();
    if (ch == 'N') roll_x();
    if (ch == 'S') for ( int i = 0; i < 3; i++) roll_x();
  }
};

int main(){
  Cube c;
  string com;
  for ( int i = 0; i < 6; i++) cin >> c.f[i];
  cin >> com;

  for (int i = 0; i < com.size(); i++) c.move(com[i]);

  cout << c .f[0] << endl;


return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<string,int> dic;
    int n;
    cin >> n;
    queue<int> ans;
    rep(i,n){
        string op,s;
        cin >> op >> s;
        if(op=="insert") dic[s]++;
        if(op=="find")  ans.push(dic[s]);
    }
    while(!ans.empty()){
        cout <<( ans.front() ? "yes" : "no")<<endl;
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 49260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        
        vector<vector<int>> S(M,vector<int>(1300));
        
        int R;cin>>R;
        
        for(int i=0;i<R;i++){
            int a,b,c,d;cin>>a>>b>>c>>d;
            c--;
            if(d==1){
                S[c][a+1]++;
            }else{
                S[c][a+1]--;
            }
        }
        
        for(int i=0;i<M;i++){
            for(int j=1;j<1300;j++){
                S[i][j]+=S[i][j-1];
            }
        }
        
        int Q;cin>>Q;
        
        while(Q--){
            int a,b,c;cin>>a>>b>>c;
            c--;
            int sum=0;
            
            for(int i=a+1;i<=b;i++){
                if(S[c][i]) sum++;
            }
            
            cout<<sum<<endl;
        }
    }
    
}



Measured memory_bytes: 52552
#include<stdio.h>

int main()

{
    int a,b;

    scanf("%d%d",&a,&b);

    if(a==1&&b==2){

        printf("3");
    }

    else if(a==2&&b==1){

        printf("3");
    }

    else if(a==1&&b==3){

        printf("2");
    }

    else if(a==3&&b==1){

        printf("2");
    }

    else if(a==2&&b==3){

        printf("1");

    }

    else if(a==3&&b==2){

        printf("1");
    }

    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second



int main(){
    ll n,k;
    cin >> n >> k;
    ll v[n] = {};
    rep(i,0,n) cin >> v[i];

    ll ans = 0;
    rep(i,1,min(k,n)+1){ // いくつ宝石を取るか
        rep(j,0,i+1){ //いくつ左から取るか
            vector<ll> vec;
            rep(l,0,n){
                if(l < j || n-1-(i-j) < l) vec.push_back(v[l]);
            }
            sort(vec.begin(),vec.end());
            ll sum = 0,cnt = 0;
            rep(l,0,vec.size()){
                if(cnt < (k-i) && vec[l] < 0){
                    cnt++;
                }
                else{
                    sum += vec[l];
                }
            }
            ans = max(sum,ans);
        }
    }
    cout << ans << endl;
}




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

int main(){
  vector<long> x(2);
  vector<long> y(2);
  long long max;
  
  cin >> x[0];
  cin >> x[1];
  cin >> y[0];
  cin >> y[1];
  
  max = x[0] * y[0];
  if(x[0] * y[1] > max)max = x[0] * y[1];
  if(x[1] * y[0] > max)max = x[1] * y[0];
  if(x[1] * y[1] > max)max = x[1] * y[1];
  
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 3624
from queue import Queue as q

N,K = map(int,input().split())

S = input()

C = q()

one = True
subK = 0
c = 0
ans = 0
Mans = 0
for s in S:
    if s=="1":
        if one:
            c += 1
        else:
            one = True
            C.put(c)
            c = 1
    else:
        if one:
            one = False
            subK += 1
            C.put(c)
            c = 1
        else:
            c += 1
    ans += 1
    if subK>K:
        subK -= 1
        ans -= (C.get()+C.get())
    #print(ans)
    if ans > Mans:
        Mans = ans
    
print(Mans)

Measured memory_bytes: 4464
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int[] a = new int[n];
        long ans = 0;
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            ans += (long) a[i];
        }



        List<Integer> list = new ArrayList<>();
        for (int i = 0 ; i < n ; i++) {
            while (a[i] > 0) {
                list.add(a[i] - a[i]/2);
                a[i] /= 2;
            }
        }

        Collections.sort(list);

        long sum = 0;
        for (int i = 0 ; i < m ; i++) {
            if (i < list.size()) {
                sum += (long) list.get(list.size() - 1 - i);
            }

        }

        System.out.println(ans - sum);

    }

}

Measured memory_bytes: 157108
#!/usr/bin/ruby
n=gets.to_i
s=gets.chomp
[?S,?W].repeated_permutation(2).find{|_|
	a=_.dup
	2.upto(n+1){|i|
		#a[i]=a[i-2]^((a[i-1]==87)^(s[~-i%n]==?x) ? 4 : 0)
		a[i]=(a[i-1]==?W)^(a[i-2]==?W)^(s[(i-1)%n]==?o) ? ?S : ?W
	}
	$><<a[0..-3].map(&:chr)*''if a[0]==a[n]&&a[1]==a[n+1]
}||(p -1)

Measured memory_bytes: 19236
import numpy as np

input_N = input().split()
N = int(input_N[0])

input_xyh = [input().split() for i in range(N)]

xyh = np.array(input_xyh)
xyh = xyh.astype(np.int64)
xyh = xyh.T
x = xyh[0]
y = xyh[1]
h = xyh[2]

# [0, 100]に座標があるのでMAXを定義する
coord_max = 101

for pos_y in range(coord_max):
    for pos_x in range(coord_max):
        # 頂上がどれくらいの高さであってほしいか
        # -1はまだよくわからないとき、0以上は確定
        # -2はダメ
        needH = -1

        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        if needH == -2:
            continue

        for i in range(N):
            # 高さが0の場合に矛盾してないか調べる
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH > dist:
                    needH = -2
                    break

        if needH == -2:
            continue

        # 見つけられたら答えをそのまま返す
        print(str(pos_x) + " " + str(pos_y) + " " + str(needH))


Measured memory_bytes: 12484
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 1000000000000000
for i in range(M):
    x,y,c = map(int,input().split())
    ans = min(ans,a[x-1]+b[y-1]-c)
ans = min(ans,min(a)+min(b))
print(ans)


Measured memory_bytes: 18612
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	long long n,i,sum,mn;
	scanf("%lld",&n);
	mn=n+1;
	for(i=2;i*i<=n;i++)	{
		if(n%i==0)	{
			sum=n/i+i;
			mn=min(mn,sum);
		}
	}	
	printf("%lld\n",mn-2);
	return 0;
}

Measured memory_bytes: 128
def solve(n):
	if n<=9:
		return n
	q = [0]
	for i in range(1,10):
		q.append(i)
	now = 1
	cnt = 9
	while 1:
		u = q[now]
		now += 1
		if u%10!=0:
			t = u*10 + u%10 - 1
			cnt += 1
			if cnt==n:
				return t
			q.append(t)
		t = u*10 + u%10
		cnt += 1
		if cnt==n:
			return t
		q.append(t)
		if u%10 !=9:
			t = u*10 + u%10 + 1
			cnt += 1
			if cnt==n:
				return t
			q.append(t)

print(solve(int(input())))

Measured memory_bytes: 7212
#include<iostream>
using namespace std;
int main(){
	int n,k;
	while(1){
		int sum=0,s=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>k;
			if(k>=1){
				s++;
			}
			sum+=k;
		}
		if(s==sum){
			cout<<"NA"<<endl;
		}else{
			cout<<s+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    ll ans = 0;
    ll cnt[3] = {};
    rep(i,0,t.size()){
        if(i >= k){
            if(t[i-k] == t[i]) t[i] = 'X';
            else{
                switch(t[i]){
                case 'r':
                    ans += p; 
                    break;
                case 's':
                    ans += r;
                    break;
                case 'p':
                    ans += s;
                    break;
                }
            }
        }
        else{
            switch(t[i]){
                case 'r':
                    ans += p; 
                    break;
                case 's':
                    ans += r;
                    break;
                case 'p':
                    ans += s;
                    break;
            }
        }
    }

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

Measured memory_bytes: 512
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> dist;

void WarshallFloyd(ll V){
	rep(k, V) rep(i, V) rep(j, V) chmin(dist[i][j], dist[i][k]+dist[k][j]);
}

int main(void){
	ll n, m;
	cin >> n >> m;
	dist.resize(n);
	rep(i, n) dist[i].assign(n, LINF);
	rep(i, n) dist[i][i] = 0;
	Vec a(m), b(m), c(m);
	rep(i, m){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	WarshallFloyd(n);

	ll ans = 0;
	rep(i, m) if(dist[a[i]][b[i]] != c[i]) ans++;
	co(ans);


	return 0;
}


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

using namespace std;

const int N = 55;

int x[N], y[N];

int main() {
  int n;
  scanf("%d", &n);
  map<pair<int, int>, int> cnt;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", x+i, y+i);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      ++cnt[make_pair(x[i]-x[j], y[i]-y[j])];
    }
  }
  int ans = n;
  for (auto it : cnt) {
    ans = min(ans, n - it.second);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
import math

a,b,x = map(int,input().split())
if 2*x>a*a*b:
    c = b-x/(a*a)
    ans = math.atan2(2*c,a)
else:
    d = 2*x/(b*a)
    ans = math.atan2(b,d)
print(math.degrees(ans))

Measured memory_bytes: 3188
""" Atcoder """

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H.sort()

min_h = 1000000000

for i in range(N - K + 1):
    if H[i+K-1] - H[i] < min_h:
        min_h = H[i+K-1] - H[i]
print(min_h)


Measured memory_bytes: 7384
x, k, d = map(int, input().split())
x = abs(x)
if k*d <= x:
    ans = x-k*d
else:
    # 残り移動回数
    count = k - x//d

    if count%2 == 0:
        ans = x%d
    else:
        ans = min(abs(x%d - d), abs(x%d + d))
print(ans)


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

int arr[100010] = {};
int main(void){
    
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    
    int res = 1;
    int f = 0;
    
    for(int i = 0; i < n-2; i++){
        
        if(arr[i] == arr[i+1] && arr[i+1] == arr[i+2] ){
        }else if(arr[i] >= arr[i+1] && arr[i+1] >= arr[i+2] && (f == 0 || f == 1) ){
            f = 1;
        }else if(arr[i] <= arr[i+1] && arr[i+1] <= arr[i+2] && (f == 0 || f == 2) ){
            f = 2;
        }else{
            f = 0;
            i++;
            res++;
        }
        
    }
    
    cout << res << endl;
    
    
    
}


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

int p[6] = {1,5,10,50,100,500};
int c[6];

int main() {
	int s = 0;
	
	for(int i=0;i<6;++i) {
		int c;
		cin >> c;
		s += c*p[i];
	}
	
	cout << (s >= 1000 ? 1 : 0)<< endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ljh ioi_aker
#define yxy tourist
#define wlj ugly_and_slow
#define pmh legendary_grandmaster
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define pb push_back
#define fr first 
#define se second
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
#define dbg cout << "---------------------------------\n"
cs int base = 233;
cs int ff = 2e6+1;
cs int mod = 998244353;
cs int inf = 1e17+1;
int fir[ff], nex[ff], to[ff], tot;
void add(int x, int y)
{
	if( x == y ) return;
	nex[++tot] = fir[x];
	fir[x] = tot;
	to[tot] = y;
}
int n, k, b[ff], pe, c[ff];
int cxk(int now, int &ans)
{
	int top = 0;
	while(now)
		b[++top] = now % 10, now /= 10;
//	reverse(b+1, b+1+top);
//	cout << " fuck " << top << endl;
//	rep(i, 2, top)
//		cout << b[i] << " "; cout << endl;
//	cout << b[1] << " " << b[2] << endl;
	rep(i, 2, top)
		if( abs( b[i] - b[i-1] ) > 1 ) 
			if( b[i] < b[i-1] ) { ans = ans + c[i] - ans % c[i]; return 1; }
			else { ans = ans + c[i-1] - ans % c[i-1]; return 1; }
	return 0;
}
void init()
{
	c[0] = 1; c[1] = 1;
	rep(i, 2, 18) c[i] = c[i-1] * 10;
	cin >> k; 
	if( k < 10 ) cout << k, exit(0);
	int ans = 0;
	rep(i, 1, k)
	{ans++;
		while( cxk(ans, ans) );// cout << ans << " ";
	//	cout << ans << endl;
	}cout << ans;
}
signed main()
{
	int T = 1;
//	cin >> T;
	while(T--) 
		init();
} 

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a; cin >> a;
  cout << a + a * a + a * a * a << endl;


}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
int main()
{
    LL prime[1005]={};
    int a;
while(cin>>a){
        int mod=1000000007;
    for(int i=2;i<=a;i++){
        int t=i;
        int y=2;
        while(1){
            while(t%y==0){
                prime[y]++;
                t/=y;
            }
        y++;
        if(t==1)
            bk;
        }
    }
    LL ans=1;
for(int i=2;i<=1000;i++){
    ans=ans*(prime[i]+1);
    ans%=mod;
}
cout<<ans<<endl;
}
    return 0;
}


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

main()
{
    int n; cin>>n;
    while(n--)
    {
        int a; cin>>a;
        if(a&1) continue;
        if(a%3 and a%5)
        {
            cout << "DENIED" << "\n";
            return 0;
        }
    }
    cout << "APPROVED" << "\n";
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let b: Vec<usize> = (0..n).map(|_| read()).collect();
    let c: Vec<usize> = (0..n - 1).map(|_| read()).collect();

    let mut ans = 0;
    let mut last = 100;  // 十分大きい数
    for i in a {
        ans += b[i - 1];
        if i == last + 1 {
            ans += c[last - 1];
        }
        last = i;
    }

    println!("{}", ans);
}

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

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

    //出力するテキスト
    string outtext;

    //最初の文字、最後の文字
    string first, last;
    first = text.at(0);
    last = text.at(text.size() - 1);
    outtext = first + to_string((text.size() - 2)) + last;

    cout << outtext << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int a[200];
int main() {
	int n;
	cin >> n;
	ll ans = inf;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = -200; j <= 200; j++) {
		ll kai = 0;
		for (int i = 0; i < n; i++) {
			kai += pow((a[i] - j), 2);
		}
		ans = min(ans, kai);
	}
	cout << ans << endl;
	return 0;
}


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

signed main() {
    int n,m,x;
    cin>>n>>m>>x;
    int c[n];
    vector<vector<int>> v(n,vector<int>(m));
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>v[i][j];
        }
    }
    int ans=INT_MAX;
    int all = 1<<n;
    for(int i=0;i<all;i++)
    {
        vector<int> lev(m,0);
        int cost=0;
        for(int j=0;j<n;j++)
        {
            if((i>>j) & 1)
            {
                cost += c[j];
                for(int j1=0;j1<m;j1++)
                {
                    lev[j1] += v[j][j1];
                }
            }
        }
        bool flag=1;
        for(int i1=0;i1<m;i1++)
        {
            if(lev[i1]<x)
            {
                flag=0;
            }
        }
        if(flag)
        {
            ans = min(ans,cost);
        }

    }
    if(ans==INT_MAX)
    cout<<-1;
    else
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3632
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

//macro_rules! debug {
//  ($($a:expr),* $(,)*) => {
//      #[cfg(debug_assertions)]
//      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
//  };
//}

#[fastout]
fn main() {
  input! {
     N:usize,
     XYP:[(i64,i64,i64);N]
  }
  let N: usize = N;
  let mut XYP: Vec<(i64, i64, i64)> = XYP;
  let inf = std::i64::MAX;
  let mut xkyori = vec![vec![0; N]; 2usize.pow(N as u32)];
  let mut ykyori = vec![vec![0; N]; 2usize.pow(N as u32)];

  for pat_i in 0..2usize.pow(N as u32) {
    for i in 0..N {
      if pat_i >> i & 1 != 1 {
        // 都市 i に鉄道が引かれている場合は0なので省略。
        // すべての路線への距離の最小値を求める。
        let (x, y, p) = XYP[i];
        xkyori[pat_i][i] = x.abs();
        ykyori[pat_i][i] = y.abs();
        for j in 0..N {
          if pat_i >> j & 1 == 1 {
            xkyori[pat_i][i] = min(xkyori[pat_i][i], (x - XYP[j].0).abs());
            ykyori[pat_i][i] = min(ykyori[pat_i][i], (y - XYP[j].1).abs());
          }
        }
        xkyori[pat_i][i] *= p;
        ykyori[pat_i][i] *= p;
      }
      //debug!(pat_i, i, xkyori[pat_i]);
    }
  }
  //debug!(xkyori);
  //debug!(ykyori);
  // ここまでで前処理。xkyoriとykyoriが計算できた。
  let mut ans = vec![inf; N + 1];
  // 3進数を計算。0=線路なし,1=X路線, 2=Y路線
  for pat_i in 0..3usize.pow(N as u32) {
    // pat_xとpat_yの作成
    let mut k = N;
    let mut pat = pat_i;
    let mut pat_x = 0;
    let mut pat_y = 0;
    for i in 0..N {
      match pat % 3 {
        1 => pat_x += 2usize.pow(i as u32),
        2 => pat_y += 2usize.pow(i as u32),
        _ => k -= 1,
      }
      pat /= 3;
    }
    let mut t_ans = 0;
    for i in 0..N {
      t_ans += min(xkyori[pat_x][i], ykyori[pat_y][i]);
    }
    ans[k] = min(ans[k], t_ans);
  }
  for a in ans {
    println!("{}", a);
  }
}


Measured memory_bytes: 11764
#include <iostream>
using namespace std;
const int MAX = 100;

void Print(int* A, int N) {
  for (int i = 0; i < N - 1; i++)
    cout << A[i] << " ";
  cout << A[N - 1] << endl;
}

int BubbleSort(int* A, int N) {
  int flag = 1;
  int num_swap = 0;
  while (flag) {
    flag = 0;
    for (int j = N - 1; j >= 1; j--) {
      if (A[j] < A[j - 1]) {
        int v = A[j];
        A[j] = A[j - 1];
        A[j - 1] = v;
        flag = 1;
        num_swap++;
      }
    }
  }
  return num_swap;
}

int main() {
  int N, A[MAX];
  cin >> N;
  for (int i = 0 ; i < N; i++)
    cin >> A[i];

  int num_swap = BubbleSort(A, N);
  Print(A, N);
  cout << num_swap << endl;

  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcnt(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 500005

int n, a[maxn];

int main()
{
//	freopen("in.txt", "r", stdin);

	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	For(i, 1, n) cin >> a[i];
	vector<int> res;
	for(int i = n; i > 0; i -= 2) res.pb(a[i]);
	int st = 1;
	if(n & 1) st = 2;
	for(int i = st; i < n; i += 2) res.pb(a[i]);
	Rep(i, sz(res)) cout << res[i] << " ";

	return 0;
}


Measured memory_bytes: 3956
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

struct SegTree {
    struct Node {
        int value = 0;
        int left, right;
    };
    static vector<Node> nodes; // 1-indexed
    SegTree(int size){
        int msb = 0, s = size;
        while(s >>= 1){ msb++; }
        msb += (size != 1 << msb) + 1;
        nodes.resize(1 << msb);
        init(1, size);
    }
    void init(int st, int lt, int idx = 1){
        nodes[idx].left = st; nodes[idx].right = lt;
        if(st != lt){
            int piv = st + (lt - st) / 2;
            init(st, piv, idx << 1 | 0);
            init(piv + 1, lt, idx << 1 | 1);
        }
    }
    double getSum(int st, int lt, int idx = 1){
        auto& node = nodes[idx];
        if(node.right < st || lt < node.left){ return 0; }
        if(st <= node.left && node.right <= lt){ return node.value; }
        return getSum(st, lt, idx << 1 | 0) + getSum(st, lt, idx << 1 | 1);
    }
    void add(int pos, int val, int idx = 1){
        auto& node = nodes[idx];
        if(node.right < pos || pos < node.left){ return; }
        node.value += val;
        if(node.left != node.right){
            add(pos, val, idx << 1 | 0);
            add(pos, val, idx << 1 | 1);
        }
    }
};
vector<SegTree::Node> SegTree::nodes;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<pair<int, int>> lrs(m), pqs(q);
    cin >> lrs >> pqs;
    sort(lrs.begin(), lrs.end());
    vector<int> anss(q), qis(q);
    iota(qis.begin(), qis.end(), 0);
    sort(qis.begin(), qis.end(), [&](int i, int j){ return pqs[i] > pqs[j]; });
    SegTree st(n + 1);
    int idx = m - 1;
    for(auto qi : qis){
        while(idx >= 0 && pqs[qi].first <= lrs[idx].first){
            st.add(lrs[idx].second, 1);
            idx--;
        }
        anss[qi] = st.getSum(pqs[qi].first, pqs[qi].second);
    }
    for(int i = 0; i < q; i++){
        cout << anss[i] << '\n';
    }
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  
  
  vector<string>S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    if (S.at(i) == "AC"){
      AC++;
    }
    else if (S.at(i) == "WA"){
      WA++;
    }
    else if (S.at(i) == "TLE"){
      TLE++;
    }
    else if (S.at(i) == "RE"){
      RE++;
    }
  }

  cout << "AC" << ' ' << 'x' << ' ' << AC << endl;
  cout << "WA" << ' ' << 'x' << ' ' << WA << endl;
  cout << "TLE" << ' ' << 'x' << ' ' << TLE << endl;
  cout << "RE" << ' ' << 'x' << ' ' << RE << endl;
}
  
  

Measured memory_bytes: 6424
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;cin>>h>>w>>k;
    vector<string> m(h);
    rep(i,0,h){
        string x;cin>>x;
        m[i] = x;
    }
    int ans = 10000000;
    rep(i,0,pow(2,h-1)){
        vector<int> a(h);
        int num = 0;
        int ans1 = 0;
        rep(j,0,h-1){
            if (i & (1<<j)){
                a[j] = 1;
                num++;
            } 
        }
        ans1 += num;
        vector<int> b(num+1);
        int f2 = 0;
        rep(j,0,w){
            int n1 = 0;
            int f1 = 0;
            rep(s,0,h){
                if (m[s][j]=='1'){
                    b[n1]++;
                    if (b[n1]>k){
                        ans1++;
                        f1 = 1;
                        break;
                    }
                }
                if (a[s]==1) n1++;
            }
            if (f1){
                n1 = 0;
                b[n1] = 0;
                rep(s,0,h){
                    if (m[s][j]=='1'){
                        b[n1]++;
                        if (b[n1]>k){
                            f2 = 1;
                            break;
                        }
                    }
                    if (a[s]==1){
                        n1++;
                        b[n1] = 0;
                    }
                }
            }
        }
        if (f2) continue;
        ans = min(ans,ans1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4076
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] A = new int[(N+1)/2];
        long count = 1;
        for(int i=0;i<N/2;i++){
            count = count * 2 % Define.mod;
        }
        bool b = true;
        for(int i=0;i<N;i++){
            int a = int.Parse(str[i]);
            if(a%2 == N%2 || a/2 >= (N+1)/2){
                b = false;
                break;
            }
            else if(a == 0){
                A[0]++;
                if(A[0] == 2){
                    b = false;
                    break;
                }
            }
            else{
                A[a/2]++;
                if(A[a/2] == 3){
                    b = false;
                    break;
                }
            }
        }        
        sb.Append((b ? count : 0)+"\n");
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 9560
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>
#include <stack>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli mod197 = 1000000007LL;
constexpr lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}



int main(void) {

	string s;
	cin >> s;

	map<char, int> m;

	for (int i = 0; i < s.size(); i++) {
		m[s[i]]++;
	}
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if (itr->second % 2 == 1) {
			COUT("No");
			return 0;
		}
	}
	COUT("Yes");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S, U; int ok, p; char T[11] = "0123456789";
int main() {
	while (cin >> S) {
		ok = 0; U = ""; p = 1;
		for (int i = 0; i < S.size(); i++) {
			if (ok == 1) {
				for (int j = 0; j < 10; j++) {
					if (T[j] == S[i]) {
						p = j;
					}
				}
				ok = 0;
			}
			else if (S[i] == '@') {
				ok = 1;
			}
			else {
				for (int j = 0; j < p; j++) {
					U += S[i];
				}
				p = 1;
			}
		}
		cout << U << endl;
	}
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

struct tapi {
    int k,l,r;
    bool operator<(const tapi& a) const {
        return k < a.k;
    }
};

int main() {
    int q;
    cin >> q;
    while (q--) {
        int n,j = 0;
        cin >> n;
        vector<tapi> a(n);
        for (int i = 0;i < n;++i) cin >> a[i].k >> a[i].l >> a[i].r;
        ll ans = 0;
        sort(a.begin(),a.end());
        for (int i = 0;i < n;++i) ans += min(a[i].l,a[i].r);
        priority_queue<P> l,r;
        for (int i = 1;i < n+1;++i) {
            if (!r.empty()) {
                ans += r.top().first;
                r.pop();
            }
            while (j < n && a[j].k <= i) {
                if (a[j].l < a[j].r) r.push({a[j].r-a[j].l,j});
                j++;
            }
        }
        reverse(a.begin(),a.end());
        j = 0;
        for (int i = n;i > 0;--i) {
            while (j < n && a[j].k >= i) {
                if (a[j].l > a[j].r) l.push({a[j].l-a[j].r,j});
                j++;
            }
            if (!l.empty()) {
                ans += l.top().first;
                l.pop();
            }
        }
        cout << ans << newl;
    }
}

Measured memory_bytes: 6260
#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() {
    int n;
    scanf("%d",&n);
    ll ans = 0;
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        ans += a[i];
    }
    sort(a,a+n);

    if(ans%10==0){
        int flag = 0;
        rep(i,n){
            if(a[i]%10!=0){
                ans -= a[i];
                flag = 1;
                break;
            }
        }
        if(flag==0)ans=0;
    }

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


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

int N, M;
vector<vector<int>> G;
vector<int> depth;
vector<int> deg;
using P = pair<int, int>;
vector<P> ans;

void dfs(int cur, int pre) {
    for(auto to : G[cur]) {
        if(depth[to] == -1) {
            depth[to] = depth[cur] + 1;
            dfs(to, cur);
        } else {
            if(depth[to] > depth[cur]) {
                ans.emplace_back(cur, to);
                deg[cur]++;
            }
        }
    }
    if(pre != -1) {
        if(deg[cur] % 2) {
            ans.emplace_back(cur, pre);
            deg[cur]++;
        } else {
            ans.emplace_back(pre, cur);
            deg[pre]++;
        }
    }
}

void solve() {
    depth.assign(N, -1);
    deg.resize(N);
    depth[0] = 0;
    dfs(0, -1);
    for(auto p : ans) cout << p.first + 1 << " " << p.second + 1 << '\n';
}

int main() {
    cin >> N >> M;
    G.resize(N);
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    if(M % 2) cout << -1 << endl;
    else solve();
    return 0;
}


Measured memory_bytes: 14836
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
ll gcd(ll a,ll b){
  ll r = a%b;
  while(r > 0){
a = b;
    b = r;
    r  =a%b;
  }
  return b;
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a;cin>>a;
  cout<<lcm(360,a)/a<<endl;
  return 0;
}


Measured memory_bytes: 3596
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){



	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n;
	cin >> n;

	vector<long long> a(n);
	map<long long, long long> m;
	for(long long i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
	}

	long long res = 0;
	for(auto x : m) {
		res += (x.second * (x.second - 1)) / 2;
	}

	for(long long i = 0; i < n; i++) {
		res -= (m[a[i]] * (m[a[i]] - 1) / 2);
		m[a[i]]--;
		res += (m[a[i]] * (m[a[i]] - 1) / 2);
		cout << res << '\n';
		res -= (m[a[i]] * (m[a[i]] - 1) / 2);
		m[a[i]]++;
		res += (m[a[i]] * (m[a[i]] - 1) / 2);
	}

}

Measured memory_bytes: 11136
// atcoder/abc122/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    int mx = 0;
    for (int i = 0; i < s.size(); ++i) {
      string t;
      for (int j = i; j < s.size(); ++j) {
        t += s[j];
        if (t.back() == 'A' || t.back() == 'C' || t.back() == 'G' || t.back() == 'T') {
          setmax(mx, (int)t.size());
        } else {
          break;
        }
      }
    }
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,c0,c1,c2,c3,c4,c5,c6,c7,cany;
int main(){
  cin>>n;
  int a;
  for(int i=-1;++i-n;){
    cin>>a;
    a/=400;
    switch(a){
      case 0:
        c0|=1;
        break;
      case 1:
        c1|=1;
        break;
      case 2:
        c2|=1;
        break;
      case 3:
        c3|=1;
        break;
      case 4:
        c4|=1;
        break;
      case 5:
        c5|=1;
        break;
      case 6:
        c6|=1;
        break;
      case 7:
        c7|=1;
        break;
      default:
        ++cany;
        break;
    }
  }
  n=c0+c1+c2+c3+c4+c5+c6+c7;
  
  cout<<(n?n:1)<<' '<<(n+cany)<<endl;
}

Measured memory_bytes: 256