akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = sorted(map(int, input().split()))

plus, minus = a[0], a[-1]
ans = []
for ai in a[1:-1]:
    if ai < 0:
        ans.append((minus, ai))
        minus -= ai
    elif ai >= 0:
        ans.append((plus, ai))
        plus -= ai
else:
    ans.append((minus, plus))

print(minus - plus)
for x, y in ans:
    print(x, y)


Measured memory_bytes: 94108
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	ll a;
	vector<ll> v;
	map<ll, int> cnt;
	for(int i=0; i<n; i++){
		cin >> a;
		if(cnt[a]==0) v.push_back(a);
		cnt[a]++;
	}

	if(n%3!=0){
		if(cnt[0]==n){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		return 0;
	}

	bool b=false;
	sort(v.begin(), v.end());
	if(v.size()==1){
		if(cnt[0]==n){
			b=true;
		}
	}else if(v.size()==2){
		if(cnt[0]==n/3 && cnt[v[1]]==2*n/3){
			b=true;
		}
	}else if(v.size()==3){
		if(cnt[v[0]]==n/3 && cnt[v[1]]==n/3 && cnt[v[2]]==n/3 && (v[0]^v[1]^v[2])==0){
			b=true;
		}
	}

	if(b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 5748
N = int(input())
T, A = map(int, input().split())
ans = [0]*N
H = list(map(int, input().split()))


for i in range(N):
    ans[i] = T-H[i]*0.006
    ans[i] = abs(ans[i]-A)
print(ans.index(min(ans))+1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

class program{

  static void Main(){
    string s=Console.ReadLine();
    int a=Convert.ToInt32(s[0].ToString()+s[1].ToString());
    int b=Convert.ToInt32(s[2].ToString()+s[3].ToString());
  
    string answ="";
  if(a<=0){
   if((b<=0)||(b>12)){
     answ="NA";
   }else{
     answ="YYMM";
   }
  }else if(a<=12){
    if((b<=12)&&(b>0)){
     answ="AMBIGUOUS";
    }else{
      answ="MMYY";
    }    
  }else if(a>12){
    if((b>12)||(b<=0)){
      answ="NA";
    }else{
      answ="YYMM";
    }
  }
    
    Console.WriteLine(answ);
}
}




Measured memory_bytes: 13268
/*---> 20 April 2020 <--- > 02:01:28 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int r;
	cin>>r;
	cout<<2*PI*r<<"\n";
return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    long long A[200000] = {};
    long long kind = 0;

    for (int i = 0; i < N; i++)
    {
        int num;
        cin >> num;
        if (A[num] == 0)
        {
            kind++;
        }
        A[num]++;
    }
    vector<ll> ball;
    rep(i, 200000)
    {
        if (A[i] != 0)
        {
            ball.push_back(A[i]);
        }
    }
    sort(ball.begin(), ball.end());
    if (kind > K)
    {
        int ans = 0;
        rep(i, kind - K) { ans += ball[i]; }
        cout << ans << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll inf = numeric_limits<ll>::max()/3;

ll s(ll n){
  ll res = 0;
  while(n > 0){
    res += n % 10;
    n /= 10;
  }
  return res;
}


void solve(ll k){
  ll diff = 1;
  ll now = 1;
  while(1){
    if(k == 0)return;
    printf("%lld\n",now);
    --k;
    ll next = now + diff;
    if(next > diff * s(next)){
      diff *= 10;
      next = now + diff;
    }
    now = next;
  }
}

int main(void){
  ll k;
  cin >> k;
  solve(k);
  return 0;
}



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

using namespace std;

int main(){

	int n;
	cin >> n;
	
	int c = 0;
	int cp = n;
	while(cp > 0){
		c++;
		cp -= 1000;
	}
	
	cout << 1000*c - n << endl;
	

}

Measured memory_bytes: 3592
package main
  
import (
    "fmt"
)

func main() {
    var a, b int
    fmt.Scan(&a, &b)
    if abs(a-b)%2 == 0 {
        t := abs(b-a) / 2
        if a > b {
            fmt.Println(abs(a - t))
        } else {
            fmt.Println(abs(b - t))
        }
    } else {
        fmt.Println("IMPOSSIBLE")
    }
}

func abs(a int) int {
    if a < 0 {
        return -a
    }
    return a
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int main()
{
    int r, D, x;
    cin >> r >> D >> x;

    rep(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    roots=[[]for i in range(n)]
    visit=[0]*n
    visit[0]=1
    q=deque([0])
    for i in range(m):
        a,b=INTM()
        roots[a-1].append(b-1)
        roots[b-1].append(a-1)
    while q:
        temp=q.popleft()
        for root in roots[temp]:
            if visit[root]!=0:
                continue
            else:
                q.append(root)
                visit[root]=temp+1
    
    print('Yes')
    for i in visit[1:]:
        print(i)
        

                
if __name__ == '__main__':
    do()

Measured memory_bytes: 37992
#include <bits/stdc++.h>
using namespace std;
	int main() {
		int a;
		cin>>a;
		int a4=a%10;
		int a3=((a-a4)/10)%10;
		int a2=((a-a3*10-a4)/100)%10;
		int a1=(a-(a%1000))/1000;
		if(a1+a2+a3+a4==7)
			cout<<a1<<'+'<<a2<<'+'<<a3<<'+'<<a4<<'='<<7;
			else if(a1+a2+a3-a4==7)
				cout<<a1<<'+'<<a2<<'+'<<a3<<'-'<<a4<<'='<<7;
				else if(a1+a2-a3+a4==7)
					cout<<a1<<'+'<<a2<<'-'<<a3<<'+'<<a4<<'='<<7;
					else if(a1+a2-a3-a4==7)
						cout<<a1<<'+'<<a2<<'-'<<a3<<'-'<<a4<<'='<<7;
						else if(a1-a2+a3+a4==7)
							cout<<a1<<'-'<<a2<<'+'<<a3<<'+'<<a4<<'='<<7;
							else if(a1-a2+a3-a4==7)
								cout<<a1<<'-'<<a2<<'+'<<a3<<'-'<<a4<<'='<<7;
								else if(a1-a2-a3+a4==7)
									cout<<a1<<'-'<<a2<<'-'<<a3<<'+'<<a4<<'='<<7;
									else if(a1-a2-a3-a4==7)
										cout<<a1<<'-'<<a2<<'-'<<a3<<'-'<<a4<<'='<<7;
								}

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

const int MAXN = 1e2 + 2, K = 1e5 + 5;
int a[MAXN];
bool dp[K];
int n, k;

void input();
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

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

void solve() {
	for (int i = 1; i <= k; i++)
		for (int j = 0; j < n; j++)
			if (a[j] <= i && dp[i - a[j]] == false)
				dp[i] = true;
	dp[k]? cout << "First" << endl: cout << "Second" << endl;
}


Measured memory_bytes: 3664
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[200000];
Pll a[200000], b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>vec;
vector<edge>ed;
vector<LL>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
vector<LL> dijkstra(vector<vector<Edge>>&g, int s) {
	vector<LL>dist(g.size());
	rep(i, g.size()) {
		dist[i] = INF;
	}
	priority_queue<Pll, vector<Pll>, greater<Pll>> q;
	dist[s] = 0;
	q.emplace(dist[s], s);
	while (!q.empty()) {
		LL cost;
		int idx;
		tie(cost, idx) = q.top();
		q.pop();
		if (dist[idx] < cost) continue;
		for (auto &e : g[idx]) {
			auto next = cost + e.cost;
			if (dist[e.to] <= next) continue;
			dist[e.to] = next;
			q.emplace(dist[e.to], e.to);
		}
	}
	return dist;
}

int main() {
	cin >> n;
	vec.resize(n);
	rep(i, n) {
		cin >> a[i].fir;
		a[i].sec= i;
	}
	rep(i, n) {
		cin >> b[i].fir;
		b[i].sec = i;
	}
	sort(a, a + n);
	sort(b, b + n);
	rep(i, n - 1) {
		vec[a[i].sec].push_back(Edge{ a[i + 1].sec, a[i + 1].fir - a[i].fir });
		vec[a[i+1].sec].push_back(Edge{ a[i].sec, a[i + 1].fir - a[i].fir });
		vec[b[i].sec].push_back(Edge{ b[i + 1].sec, b[i + 1].fir - b[i].fir });
		vec[b[i + 1].sec].push_back(Edge{ b[i ].sec, b[i + 1].fir - b[i].fir });
	}
	vector<LL>d=dijkstra(vec, 0);
	rep(i, n) {
		cout << d[i]<< endl;
	}
	return 0;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
long long a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    cin >> a >> b >> c >> x;
    repe(i, a)
    {
        repe(j, b)
        {
            repe(h, c)
            {
                if (i * 500 + j * 100 + h * 50 == x)
                {
                    ans++;
                }
            }
        }
    }
    pr(ans);
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main()
{
    int n,x,count =0;
    cin>>n;
    if(n>0)
    {
       int arr[n];
    for(int i=0 ;i<n;i++)
    {

        cin>>x;
        if(x<=100)
            arr[i]=x;
    }
     for(int i=0 ;i<n;i+=2)
    {
      if(arr[i] %2 !=0)
        count++;
    }
    cout<<count;
    }

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    ll res=0;
    rep(i,4){
        if(s[i]=='+') res++;
        else res--;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	
	ll n;cin>>n;
	ll f[n]={0};
	ll ans=1,ct=1,mul=1;
	ll a[n];rep(i,0,n){cin>>a[i];f[a[i]]++;}
	if(a[0]!=0)ans=0;
	sort(a,a+n);
	if(f[0]!=1)ans=0;
	rep(i,1,n){
		if(a[i]==a[i-1])ct++,ans=(ans*mul)%md;
		else{
			if(a[i]!=a[i-1]+1)ans=0;
			mul=ct;
			ans=(ans*mul)%md;
			ct=1;
		}
	}
	cout<<ans;
	
	
	return 0;
}



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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;

int main()
{		

    IOS
    
    string s;
    cin>>s;

    ll n=s.size();
    ll dp[n][13];
    memset(dp,0,sizeof(dp));
    
        if(s[0]!='?')
        {   
                dp[0][s[0]-'0']=1;
            
        }
        else
        {
            for(ll i=0;i<10;i++)
                dp[0][i]=1;
        }


        for(ll i=1;i<n;i++)
        {
            if(s[i]!='?')
            {
                for(ll j=0;j<13;j++)
                {
                    
                        dp[i][(j*10+(s[i]-'0'))%13]=dp[i-1][j];
                }
            }
            else {
                for(ll j=0;j<13;j++)
                {
                    for(ll k=0;k<10;k++)
                    {
                        dp[i][(j*10+k)%13]+=dp[i-1][j]%mod;
                        dp[i][(j*10+k)%13]%=mod;
                    }
                }
                
            }
        }


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

    
    



    
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,X,b[N],l[N],u[N],i,a[N];
ll ans=1ll<<60,val[N],su,zz,ov;
inline bool cmp(const int&x,const int&y){return val[x]>val[y];}
int main(){
	scanf("%d%d",&n,&X);
	for(i=1;i<=n;++i)scanf("%d%d%d",b+i,l+i,u+i),a[i]=i,su-=1ll*b[i]*l[i],
		val[i]=1ll*b[i]*l[i]+1ll*u[i]*(X-b[i]);
	sort(a+1,a+n+1,cmp);
	for(i=1;i<=n && su+val[a[i]]<=0;su+=val[a[i++]]);su*=-1;
	zz=1ll*X*(i-1);
	if(!su)return printf("%lld\n",zz),0;
	ov=val[a[i]];
	for(i=1;i<=n;++i){
		ll ss=val[i]>=ov?su+val[i]-ov:su;
		ans=min(ans,zz+(ss<=1ll*b[i]*l[i]?
			(ss+l[i]-1)/l[i]:(ss-1ll*b[i]*l[i]+u[i]-1)/u[i]+b[i]));
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    while(true){
        string s;
        getline(cin,s);
        if(s=="0")break;
        short n=0;
        for (int i = 0; i < s.size(); i++){
            n+=s[i]-'0';
        }
        cout<<n<<endl;
    }
}


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

using namespace std;
int dp[3002][3002];
int lon(string aa,string bb,int a,int b)
{for(int i=0;i<=a;i++)
dp[0][i]=0;

for(int i=1;i<=b;i++)
dp[i][0]=0;

for(int i=1;i<=b;i++)
{
	for(int j=1;j<=a;j++)
	{
		if(aa[j-1]!=bb[i-1])
		dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		
		else
		dp[i][j]=1+dp[i-1][j-1];
	}
}

int i=a,j=b;

string path="";

while(i>0&&j>0)
{
	if(aa[i-1]==bb[j-1])
	{path+=aa[i-1];
	i--;
	j--;
	}
	                                    	
	else if(dp[j][i-1]>=dp[j-1][i])
	i--;
	
	else
	j--;
}

reverse(path.begin(),path.end());
 cout<<path<<endl;
}


  int main()
{ string a,b;
  cin>>a>>b;
  lon(a,b,a.length(),b.length());
 return 0;
}




Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  vector<ll> A(n);
  for (auto& _a : A) cin >> _a;
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (A[i]==A[j]) continue;
      for (int k = j+1; k < n; ++k) {
        if (A[i]==A[k]) continue;
        if (A[j]==A[k]) continue;
        if (A[i]+A[j] > A[k]) ++ans;
      }
    }
  }
  cout << ans << endl;

}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A*B%2==0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int sum = 0;
    rep(i, N){
        int x = i+1;
        vector<int> nums(0);
        while(x > 0){
            nums.push_back(x % 10);
            x /= 10;
        }
        int tmp = 0;
        rep(j, nums.size()){
            tmp += nums.at(j);
        }
        if(tmp >= A && tmp <= B){
            sum += i+1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define ll long long
using namespace std;
const int N = 2e5 + 5;
int n, q, a[N], s0[N], s1[N], ans[N];
pair<int, int> b[N];
int c[N * 4]; 
void build(int k, int l, int r) {
	if (l == r) {
		c[k] = 1e9;
		if (l == 0) c[k] = 0;
		return;
	}
	int mid = l + r >> 1;
	build(k << 1, l, mid);
	build(k << 1 | 1, mid + 1, r);
	c[k] = min(c[k << 1], c[k << 1 | 1]);
}
int Query(int k, int l, int r, int p, int q) {
	if (l >= p && r <= q) return c[k];
	if (l > q || r < p) return 1e9;
	int mid = l + r >> 1;
	return min(Query(k << 1, l, mid, p, q), Query(k << 1 | 1, mid + 1, r, p, q));
}
void modify(int k, int l, int r, int p, int v) {
	if (l == r) {
		c[k] = min(c[k], v);
		return;
	}
	int mid = l + r >> 1;
	if (p <= mid) 
		modify(k << 1, l, mid, p, v);
	else 
		modify(k << 1 | 1, mid + 1, r, p, v);
	c[k] = min(c[k << 1], c[k << 1 | 1]);
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		s0[i] = s0[i - 1] + (a[i] == 0);
		s1[i] = s1[i - 1] + (a[i] == 1);
	}
	cin >> q;
	for (int i = 1; i <= q; i++) 
		scanf("%d %d", &b[i].first, &b[i].second);
	sort(b + 1, b + 1 + q);
	for (int i = 1; i <= n; i++) ans[i] = 1e9;
	build(1, 0, n);
	int p = 1;
	for (int i = 1; i <= n; i++) {
		while (p <= q && b[p].first == i) {
			int tmp = Query(1, 0, n, b[p].first - 1, b[p].second);
			tmp += s0[b[p].second];
			tmp -= s1[b[p].second];
			ans[b[p].second] = min(ans[b[p].second], tmp);
			modify(1, 0, n, b[p].second, tmp - s0[b[p].second] + s1[b[p].second]); 
			p++;
		}
		ans[i] = min(ans[i], ans[i - 1]);
		modify(1, 0, n, i, ans[i] - s0[i] + s1[i]);
	}
	cout << ans[n] + s1[n] << endl;
}


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

int N;
int Tnow, Anow;
int T, A;

signed main()
{
	cin >> N;
	cin >> Tnow >> Anow;
	rep(i,N-1) {
		//printf("Tnow = %lld, Anow = %lld\n", Tnow, Anow);
		cin >> T >> A;
		if (Tnow <= T && Anow <= A) {
			Tnow = T;
			Anow = A;
			continue;
		}
		//int kakeru = max(ceil(1.0 * Tnow / T), ceil(1.0 * Anow / A));
		int kakeru = max((Tnow + T - 1) / T, (Anow + A - 1) / A);
		T *= kakeru;
		A *= kakeru;
		Tnow = T;
		Anow = A;
	}
	cout << Tnow + Anow << endl;
}


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

Y //= 1000

for n1 in range(N+1):
    y = Y-n1
    n = N-n1

    if y%5 != 0:
        continue
    n10 = (y-5*n)//5
    n5 = n-n10

    if n10 < 0 or n5 < 0:
        continue

    if n1+n5*5+n10*10 == Y:
        n5 = n-n10
        break
else:
    n1,n5,n10 = -1,-1,-1

print(n10,n5,n1)

Measured memory_bytes: 9076
#include <iostream>
#include <cstdio>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;
int n,m,trace[100011],dp[100011];
const int vc=1000000000;
char s[100011];
int main(){
    scanf("%d%d%s",&n,&m,s);
    deque<int> q;
    q.pb(n);
    dp[n]=1;
    for (int i=n-1;i>=0;--i)
    if (s[i]=='0'){
        while(!q.empty()&&q.front()-i>m) q.pop_front();
        if (!q.empty()) dp[i]=dp[q.front()],trace[i]=q.front();
        if (!dp[i]) continue;
        ++dp[i];
        while(!q.empty()&&dp[i]<=dp[q.back()]) q.pop_back();
        q.pb(i);
    }
    int u,v;
    if (dp[0]==0) puts("-1");
    else{
        u=0;
        while(u!=n){
            v=trace[u];
            printf("%d ",v-u);
            u=v;
        }
    }
}


Measured memory_bytes: 1280
N = gets.to_i
cards = gets.split

suit, nums = cards.map{|x|x[0]}, cards.map{|x|x[1].to_i}
cards = suit.zip(nums)

#BubbleSort
array = Marshal.load(Marshal.dump(cards))
0.upto(N-1) do |i|
	(N-1).downto(i+1) do |j|
		#puts "i = #{i}, j = #{j}, j-1 = #{j-1}"
		if array[j][1] < array[j-1][1]
			array[j], array[j-1] = array[j-1], array[j]
			#puts array.map{|arr| arr[0] + arr[1].to_s}.join(" ")
		end
	end
end

puts array.map{|arr| arr[0] + arr[1].to_s}.join(" ")
puts "Stable"

#SelectionSort
array2 = Marshal.load(Marshal.dump(cards))
0.upto(N-1) do |i|
	minj = i
	i.upto(N-1) do |j|
		if array2[j][1] < array2[minj][1]
			minj = j
		end
	end
	array2[i], array2[minj] = array2[minj], array2[i] if i != minj
end

puts array2.map{|arr| arr[0] + arr[1].to_s}.join(" ")

if array == array2
	puts "Stable"
else
	puts "Not stable"
end

Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ( A+B > C+D )
    cout << "Left" << endl;
  else if ( A+B == C+D )
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
import java.util.*; 
import java.io.*;
 
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int k = in.readInt(); 
	    for(int x = 0; x<=n; x++) {
	    	for(int y = 0; y<=n; y++) {
	    		int z = n - (x+y); 
	    		if(z < 0) continue; 
	    		if(10000*x + 5000*y + 1000*z == k) {
	    				System.out.println(x + " " + y + " " + z); 
	    				return ;
	    			
	    		}
	    	}
	    }
	    System.out.println(-1 + " " + -1 + " " +  -1); 
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

typedef long long ll;

int a, b;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    if (a == 1 || b == 1) {
        if (a == 1 && b == 1)
            cout << "Draw" << endl;
        else if (a == 1)
            cout << "Alice" << endl;
        else
            cout << "Bob" << endl;
    } else {
        if (a > b)
            cout << "Alice" << endl;
        else if (a < b)
            cout << "Bob" << endl;
        else
            cout << "Draw" << endl;
    }

    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i];
	cout << (n - 2) / (k - 1) + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN

const int N=107;
int fr[N];

void solve(){
  int x,n; cin>>x>>n;
  int mi=1000,ma=0;
  for(int i=0 ; i<N ; i++) fr[i]=0;
  for(int i=0,a ; i<n ; i++) cin>>a,fr[a]++,mi=min(mi,a),ma=max(ma,a);
  if(fr[x]==0) {cout<<x;LOL return;}
  vector<int> v;
  for(int i=x-1 ; i>=mi-1 ; i--){
    if(!fr[i]){
      v.pb(i);
      break;
    }
  }
  for(int i=x+1 ; i<=ma+1 ; i++){
    if(!fr[i]){
      v.pb(i);
      break;
    }
  }
  if(sz(v)==1){
    cout<<v[0];LOL return;
  }
  sort(all(v));
  if(abs(x-v[0])<=abs(x-v[1])){
    cout<<v[0];LOL return;
  }
  else{
    cout<<v[1];LOL
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<std::string> S;
  tools::read(S, N);

  std::map<std::string, i64> map;
  for (const std::string& S_i : S) {
    ++map[S_i];
  }

  i64 max = 0;
  for (const std::pair<std::string, i64>& pair : map) {
    max = std::max(max, pair.second);
  }

  for (const std::pair<std::string, i64>& pair : map) {
    if (pair.second == max) {
      std::cout << pair.first << std::endl;
    }
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for (int &di: d) cin >> di;
    int ans = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) {
        ans += d[i] * d[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long t1 = rlong, t2 = rlong;
	long a1 = rlong, a2 = rlong;
	long b1 = rlong, b2 = rlong;

	long k1 = a1 - b1, k2 = a2 - b2;

	long y1 = t1 * k1;
	long y2 = y1 + t2 * k2;

	if(y1 > 0 && y2 > 0) 0.writeln;
	if(y1 < 0 && y2 < 0) 0.writeln;
	if(y2 == 0) "infinity".writeln;
	if(y1 > 0 && y2 < 0){
		if(y1 % -y2 == 0) ((y1 / -y2) * 2).writeln;
		else ((y1 / -y2) * 2 + 1).writeln;
	}
	if(y1 < 0 && y2 > 0){
		if(-y1 % y2 == 0) ((-y1 / y2) * 2).writeln;
		else ((-y1 / y2) * 2 + 1).writeln;
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
    ll a,b;cin>>a>>b;
    if(a*b<=0)puts("Zero");
    else {
        if(a>0){
            puts("Positive");
        }
        else {
           if(abs(a-b)%2==1) puts("Positive");
            else puts("Negative");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int max_pro(int [],int);
int main(){
  int number;
  int list[200000];
  int i;
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%d",&list[i]);
  }
  printf("%d\n",max_pro(list,number));
  return 0;
}
int max_pro(int l[],int n){
int i;
int min=l[0];
int max=l[1];
int dif=max-min;
for(i=1;i<n;i++){
  if(min>l[i]){
    min=l[i];
    max=l[i];
  }
  else if(max<=l[i]){
    max=l[i];
    if(dif<max-min)dif=max-min;
}
}
  return dif;
}



Measured memory_bytes: 2632
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int tcs;cin>>tcs;while(tcs--)
const int N=200007;
const int MOD=1e9+7;
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
int a[N],b[N];
vector<int> v(N);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define printclock cerr<<"Time : "<<1000*(int)clock()/(int)CLOCKS_PER_SEC<<"ms\n"


int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/


int a,b,c;
cin>>a>>b>>c;
int count=0;
for(int i=a;i<=b;i++)
{
	if(i%c==0)
	count++;
}
cout<<count;


cout<<endl;
printclock;
}



Measured memory_bytes: 4688
//#define judge
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int ninf = 0xcfcfcfcf;
const double pi = acos(-1.0);
int n;

int main() {
  cin >> n;
  int tag = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if ((a % 2 == 0 && (a % 3 == 0 || a % 5 == 0)) || a % 2) {
      continue;
    } else {
      tag = 1;
      break;
    }
  }
  if (tag) {
    puts("DENIED");
  } else {
    puts("APPROVED");
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()

	if b < a {
		a, b = b, a
	}
	for i := 0; i < b; i++ {
		fmt.Printf("%+v", a) // output for debug
	}
	fmt.Printf("\n") // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5;
int n,a[100],b[100],sum;
int main() {
	cin>>n;
	for(int i=1;i<n;i++)
	cin>>b[i];
	a[1]=b[1];	a[n]=b[n-1];
	sum=a[1]+a[n];
	for(int i=2;i<n;i++)
	{
		a[i]=min(b[i-1],b[i]);
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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 ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    rep(i, (1<<3)) {
        int ans = s[0] - '0';
        vector<char> res;
        res.push_back(s[0]);
        rep(j, 3) {
            if(i & (1<<j)) {
                ans += s[j+1] - '0';
                res.push_back('+');
            }
            else {
                ans -= s[j+1] - '0';
                res.push_back('-');
            }
            res.push_back(s[j+1]);
        }
        if(ans == 7) {
            for(char i : res) cout << i;
            cout << "=7" << endl;
            return 0;
        }
    }
    cout << "does not exist" << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    ll N, Q;
    cin >> N >> Q;
    atcoder::fenwick_tree<ll> bit(N);
    REP(i, N) {
        ll a;
        cin >> a;
        bit.add(i, a);
    }

    REP(_, Q) {
        ll t, a, b;
        cin >> t >> a >> b;
        if (t == 0) {
            bit.add(a, b);
        }
        else {
            cout << bit.sum(a, b) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8236
#include <bits/stdc++.h>
#define ll long long 
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define dd double
const int INF = INT_MAX;
#define all(x) x.begin(),x.end()
#define mod 1000000007
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int s,w;
  cin>>s>>w;
  if(w>=s)
  {
    cout<<"unsafe"<<endl;
  }
  else
  {
    cout<<"safe"<<endl;
  }
  
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1; 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    string s;
    cin >> s;
    cout << ((s[1] == s[2] and (s[0] == s[1] or s[2] == s[3]))?"Yes":"No") << "\n";
}



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

int main()
{
	int a, b, count = 0;
	int ans[100];
	while (cin >> a >> b) {
		if (a == 0)
			break;
		if (a == 1 || a == 4 || a == 7) {
			ans[count] = (b % 7 + 3)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 9 || a == 12) {
			ans[count] = (b % 7 + 2)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 2 || a == 8) {
			ans[count] = (b % 7 + 6)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 3 || a == 11) {
			ans[count] = b % 7;
			if (ans[count] % 7 == 0)
				ans[count]=+7;
		}
		else if (a == 5) {
			ans[count] = (b % 7 + 5)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 6) {
			ans[count] = (b % 7 + 1)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 10) {
			ans[count] = (b % 7 + 4)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		count++;
	}
	for (int i = 0; i < count; i++) {
		if (ans[i] == 1)
			cout << "Monday" << endl;
		else if (ans[i] == 2)
			cout << "Tuesday" << endl;
		else if (ans[i] == 3)
			cout << "Wednesday" << endl;
		else if (ans[i] == 4)
			cout << "Thursday" << endl;
		else if (ans[i] == 5)
			cout << "Friday" << endl;
		else if (ans[i] == 6)
			cout << "Saturday" << endl;
		else if (ans[i] == 7)
			cout << "Sunday" << endl;
	}
}

Measured memory_bytes: 3012
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  PRN((b-1)/a+1);
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////



	
int main() {
	ll a, b, x;
	cin >> a >> b >> x;

	if (x >= a && x <= a + b) { cout << "YES"; }
	else { cout << "NO"; }

	system("PAUSE");
}

Measured memory_bytes: 504
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,t,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<fixed<<setprecision(12);
	cin>>n>>k>>t;
	cout<<(n+k-1)/k*t;
}

Measured memory_bytes: 3652