akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

using ld = double;
using Point =  complex<ld>;
const ld eps = 1e-9;
const ld pi = acos(-1.0);

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

bool cmp(Point x,Point y){
	if(eq(x.real(),y.real()))return x.imag()<y.imag();
	return x.real()<y.real();
}

bool eqq(Point x,Point y){
	return eq(x.real(),y.real())&&eq(x.imag(),y.imag());
}
//内積
ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
//外積
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}


//線分
//直線にするなら十分通い２点を端点とすればよい
class Line {
public:
	Point a, b;
};
//点から直線への垂線の足
Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}
//直線と直線の交点
//平行な２直線に対しては使うな！！！！
Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a; Point tv = t.b - t.a;
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}


Line calc(Line p,Line q){
    if(abs(p.a-p.b)>eps){
        if(abs(q.a-q.b)>eps){
            auto ret=is_ll(p,q);
            return {ret,ret};
        }
        else {
            auto ret = 2.0*proj(p,q.a)-q.a;
            return {ret,ret};
        }
    }
    else {
        if(abs(q.a-q.b)>eps){
            auto ret = 2.0*proj(q,p.a)-p.a;
            return {ret,ret};
        }
        else {
            return {p.a,q.a};
        }
    }
}
int read(string &s,int& i){
    int sgn=0;
    if(s[i]=='-'){
        ++i;
        sgn=1;
    }
    int ret=0;
    while('0'<=s[i]&&s[i]<='9'){
        ret=10*ret+(s[i]-'0');
        ++i;
    }
    return sgn?-ret:ret;
}
Line f(string&s ,int& i);
Line f2(string&s ,int& i);

Line f(string&s ,int& i){
    Line p=f2(s,i);
    while(i!=s.size()&&s[i]=='@'){
        ++i;
        Line q=f2(s,i);
        p=calc(p,q);
    }
    return p;
}
Line f2(string& s,int& i){
    if(s[i]=='('){
        ++i;
        auto ret=f(s,i);
        ++i;
        return ret;
    }
    else {
        int x=read(s,i);
        ++i;
        int y=read(s,i);
        auto p=Point(x,y);
        return {p,p};
    }
}


int main(){
    cout<<fixed<<setprecision(12);
    string s;
    while(cin>>s,s!="#"){
        int i=0;
        auto ret=f(s,i);
        cout<<ret.a.real()<<" "<<ret.a.imag()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3284
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	string S;
	cin >> S;
	int zero = 0;
	int one = 0;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '0')zero++;
		else one++;
	}
	int key = min(zero, one);
	cout << key * 2 << endl;
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli> 
#define vi vector<lli> 
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

lli solve()
{
    //start from here
    lli n;
    cin>>n;
    lli ans = 0;
    lli maxa = 0;
    rep(i,0,n)
    {
        lli a;
        cin>>a;
        if(!i)
        {
            maxa = a;
        }
        else
        {
            maxa = max(maxa,a);
        }
        ans += maxa - a;
    }
    cout<<ans;
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/

Measured memory_bytes: 3652
#include <stdio.h>
 void call(int n){
	int i = 1;
	for(i=1;i<=n;i++){
 		int x = i;
 		if ( x % 3 == 0 ){
 			printf(" %d", i);
 			continue;
 		}
 		for(;x;){
 			if ( x % 10 == 3 ){
 			printf(" %d", i);
			 break;
			 }
			 else x /= 10;
 		}
	 }
 printf("\n");
 }


int main (void){
 int n;
 scanf("%d", &n);
 call(n);
 return (0);
 }


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

ll L,R;
const ll MOD = 2019;
vector<ll> arr;

void solve(){ 
    cin>>L>>R;

    for(ll i=L,j=1;i<=R && j<=5000;i++,j++){
        arr.push_back((i%MOD));
    }

    ll ans = 1e8;

    for(ll i=0;i<arr.size();i++){
        for(ll j=i+1;j<arr.size();j++){
            ll temp = (arr[i]*arr[j])%MOD;
            ans = min(ans,temp);
        }
    }
    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    ll t;
    t = 1; 
   // cin>>t;
    FOR(i,1,t){
        // cout<<"Case "<<i<<":\n";
        solve();
    }
}


Measured memory_bytes: 384
# int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
n = input()
if n[-1] == '3':
    print('bon')
elif n[-1] in frozenset(['0', '1', '6', '8']):
    print('pon')
else:
    print('hon')

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define PI 3.141592653589793
#define maxarr(A,n) *max_element(A,A+n) 
#define minarr(A,n) *min_element(A,A+n);

int main()
{
	fastio();
	int N,M,val;
	ll ans=0;
	cin>>N>>M;
	while(M)
	{
		cin>>val;
		ans+=val;
		M--;
	}
	if(N-ans>=0)
		cout<<N-ans<<endl;
	else
		cout<<-1<<endl;
	return 0;   
}   


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   int N;
   cin>>N;
   vector<int>h(N);
   for(int i=0;i<N;i++)cin>>h[i];

   ll ans = 0;
   while(true){
      bool ok = true;
      for(int i=0;i<N;i++)if(h[i]!=0)ok=false;
      if(ok)break;

      for(int i=0;i<N;i++){
         if(h[i]>0){
            int r=N;
            for(int j=i+1;j<N;j++){
               if(h[j]==0){
                  r=j;
                  break;
               }
            }
            for(int j=i;j<r;j++){
               h[j]--;
            }
            ans++;
            break;
         }
      }

   }

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


Measured memory_bytes: 256
def joint(i):
    cnt = 0
    for node in line_dict[i]:
        if cnt_list[node] == -1:
            cnt += joint(node)



if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    c = input()[0]
    import string
    for i, a in enumerate(string.ascii_lowercase):
        if a == c:
            print(string.ascii_lowercase[i+1])


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

int n, a, c[200005];
int main() {
	int i;
	cin >> n;
	for(i=2; i<=n; i++) {
		cin >> a;
		c[a]++;
	}
	for(i=1; i<=n; i++) printf("%d\n", c[i]);
	return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0)
    {
        c -= b;
        if(c <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
typedef long long ll;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

typedef vector<int> vi;

int main() {
    int M,N;
    while(cin>>M>>N && M){
        vi P(M),C(N),E(N);
        rep(i,M)cin>>P[i];
        rep(i,N)cin>>C[i]>>E[i];
        sort(all(P));
        P.insert(P.begin(), 0);
        vi sum(M+1);
        rep(i,M) sum[i+1]=sum[i]+P[i+1];
        static int dp[555][11111];
        // memset(dp,0,sizeof(dp));
        rep(j,N){
            rep(i,M){
                dp[j+1][i] = max(dp[j+1][i], dp[j][i]);
                int x = min<int>(i + C[j], M);
                dp[j+1][x] = max(dp[j+1][x], dp[j][i] + sum[x] - sum[i] - E[j]);
            }
        }
        int ans=0;
        rep(i,555)rep(j,11111)ans=max(ans,dp[i][j]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 23756
import collections
import numpy as np

h, w, m = map(int, input().split())
lst_ = []
h_lst = [0]*h
w_lst = [0]*w
for i in range(m):
    h_, w_ = map(int, input().split())
    lst_.append([h_, w_])
    h_lst[h_-1] += 1
    w_lst[w_-1] += 1

h_count = max(h_lst)
w_count = max(w_lst)
h_cand = set([i+1 for i, h_ in enumerate(h_lst) if h_ == h_count])
w_cand = set([i+1 for i, w_ in enumerate(w_lst) if w_ == w_count])
#print(h_cand, w_cand)

count = 0
for bomb in lst_:
    if bomb[0] in h_cand and bomb[1] in w_cand:
        count += 1

ans = max(h_lst) + max(w_lst)
if count < len(h_cand)*len(w_cand):
    print(ans)
else:
    print(ans-1)





Measured memory_bytes: 122168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int h = 0;
		int m = 0;
		int s = 0;

		try(Scanner scan = new Scanner(System.in)) {
			int second = scan.nextInt();
			h = second / 3600;
			m = (second % 3600) / 60;
			s = (second % 3600) % 60;

			System.out.println(h + ":" + m + ":" + s);
		}
	}

}

Measured memory_bytes: 26220
//解法分かったのに実装しなかったカス
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
	int n , k ;
	cin >>  n >> k ;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());

	combination c(n+5);

	mint ans = 0 ;
	rep(ri,2){
		rep(i,n){
			mint now = c(i,k-1);
			if(ri == 1 ) now = -now;
			ans += now*a[i];
		}
		reverse(a.begin(),a.end());
	}
	cout << ans.x << endl;
}



Measured memory_bytes: 2176
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		List<Integer> wList = new ArrayList<Integer>();
		List<Integer> kList = new ArrayList<Integer>();
		for(int i = 0; i < 10; ++i)
		{
			int a = stdIn.nextInt();
			wList.add(a);
		}
		for(int i = 0; i < 10; ++i)
		{
			int a = stdIn.nextInt();
			kList.add(a);
		}
		Collections.sort(wList);
		Collections.sort(kList);
		System.out.println((wList.get(wList.size() - 1) + wList.get(wList.size() - 2) + wList.get(wList.size() - 3)) + " " + (kList.get(kList.size() - 1) + kList.get(kList.size() - 2) + kList.get(kList.size() - 3)));
	}
}

Measured memory_bytes: 12000
N = int(input())
W = list(map(int,input().split()))
m = sum(W)

for j in range(N-1):
    W1 = W[:j+1]
    W2 = W[j+1:N]
    s = abs(sum(W1) - sum(W2))
    m = min(m, s)

print(m)


Measured memory_bytes: 9048
a, b, c = map(int, input().split())
count = 0
if a % 2 == 0 and a == b == c:
    print(-1)
    exit()

while a % 2 == 0 | b % 2 == 0 | c % 2 == 0:
    A = int((b + c) / 2)
    B = int((c + a) / 2)
    C = int((a + b) / 2)
    a = A
    b = B
    c = C
    count += 1
print(count)

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

int main(){
  long long N,X=0;
  cin >> N;
  for(long long i=1; i<=N; i++){
    if(i%3 != 0 && i%5 != 0){
      X += i;
    }
  }
  cout << X << endl;
}


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

using ll=long long;
using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}

int n;
string s;
int cnt=0;

void solve(){
    cin>>n;
    cin>>s;
    for(int i=1; i<n; i++){
        if(s[i]!=s[i-1]){
            cnt++;
        }
    }
    cnt+=1;
    cout<<cnt<<endl;
}

signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 512
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N, K = li_input()
    S = input()

    print(S[:K-1] + S[K-1].lower() + S[K:])

main()


Measured memory_bytes: 5236
import sys

def get_n(a,b,n,s):
  if n == 0:
    return s
  else:
    i = int(((a/b)-(a//b))*10)
    s += i
    return get_n(a*10,b,n-1,s)

for line in sys.stdin:
  a,b,n = list(map(int,line.split()))
  s = get_n(a,b,n,0)
  print(s)

Measured memory_bytes: 7664
// C - Digits in Multiplication
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll ans = 11;
	ll s = sqrt(N);
	for(ll a=1; a<=s; a++){
		ll b = N/a;
		if(a*b==N){
			ll la = log10(a)+1;
			ll lb = log10(b)+1;
			ans = min(ans, max(la, lb));
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 512
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<int, int> P;

vector<int> B { 399, 799, 1199, 1599, 1999, 2399, 2799, 3199 };

int main() {
  int n; cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  set<int> S;
  int cnt = 0;
  loop(i,0,n) {
    int idx = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
    if (idx == B.size()) {
      cnt++;
      continue;
    }
    S.insert(idx);
  }
  cout << max(1, (int)S.size()) << " " << cnt + S.size() << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

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

	int N;
	ll X;

	cin >> N >> X;

	ll ok = 0;
	ll ng = 1;
	ll pt = 1;
	for(int i = 1; i <= N; i++){
		ng = ng * 2 + 3;
		pt = pt * 2 + 1;
	}

	ll ans = 0;
	while(ng - ok > 0){

		ll mid = (ng + ok - 1) / 2;
		pt = (pt-1)/2;

		if(mid < X) {
			ok = mid + 1;
			ans += pt + 1;
			ng--;
		} else {
			ng = mid; 
			ok++;
		}

	}
	cout << ans << endl;

	Never To return 0;
}


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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    int a;cin>>a;vec[i]=a-i;
  }
  sort(vec.begin(), vec.end());
  int avg = vec[n/2];
  ll sum=0;
  for(int i=0;i<n;i++){sum+=(ll)abs(vec[i]-avg);}
  cout<<sum<<endl;
}


Measured memory_bytes: 1024
import bisect
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
 
n = int(input())
l = [int(item) for item in input().split()]
l.sort()
 
ans = 0
for i, a in enumerate(l):
    for j in range(i+1, n):
        b = l[j]
        lower = max(a-b, b-a)
        upper = a + b
        d = bisect.bisect_right(l, lower)
        u = bisect.bisect_left(l, upper)
        double = 0
        if d <= i < u:
            double += 1
        if d <= j < u:
            double += 1
        ans += max(0, u - d - double)
 
print(ans // 3)

Measured memory_bytes: 51288
/**
 *      purpose : ABC 114 A
 *      author  : kyomukyomupurin
 *      created : 2018-12-02 21:00:19
**/

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second
#define print(x) cout << (x) << '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    int x; cin >> x;
    if (x == 3 || x == 5 || x == 7) print("YES");
    else print("NO");
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	int n; cin>>n;
	ll a[n],b[n];
	vector<pair<ll,ll>> vec;
	rep(i,0,n) {
		ll ai,bi;
		cin>>ai>>bi;
		vec.push_back(make_pair(ai,bi));
	}

	sort(all(vec));
	ll l=vec.size();

	ll ans=vec[n-1].first + vec[n-1].second;
	cout << ans <<endl;


	
}


Measured memory_bytes: 2420
use proconio::input;

fn main() {
    input!(mut a: i32, b: i32, mut c: i32, d: i32);

    let mut turn = false;

    while a > 0 && c > 0 {
        if turn == true {
            a -= d;
        } else {
            c -= b;
        }

        turn = !turn;
    }

    let ans = if c <= 0 { "Yes" } else { "No" };

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


Measured memory_bytes: 2140
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
typedef long long LL;
using namespace std;

LL n;

int dfs(LL num, int num_three, int num_five, int num_seven){
    int ans;
    int tmp_num_three;
    int tmp_num_five;
    int tmp_num_seven;
    if(num > n){
        return 0;
    }
    if(num_three!=0 && num_five!=0 && num_seven!=0){
        ans = 1;
    }else{
        ans = 0;
    }
    for(int i=3; i<=7; i+=2){
        tmp_num_three = num_three;
        tmp_num_five = num_five;
        tmp_num_seven = num_seven;
        if(i==3){
            tmp_num_three++;
        }else if(i==5){
            tmp_num_five++;
        }else{
            tmp_num_seven++;
        }
        ans += dfs(num*10+i, tmp_num_three, tmp_num_five, tmp_num_seven);
    }
    return ans;
}

int main() {
    int ans;
    cin >> n;
    ans = dfs(0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[] r = new int[n];
			Point2D.Double[] p = new Point2D.Double[n];
			for(int i=0;i<n;i++){
				p[i] = new Point2D.Double(sc.nextInt(),sc.nextInt());
				r[i] = sc.nextInt();
			}
			
			int m = sc.nextInt();
			
			Point2D.Double t, s;
			Line2D.Double b;
			boolean flag;
			for(int i=0;i<m;i++){
				t = new Point2D.Double(sc.nextInt(),sc.nextInt());
				s = new Point2D.Double(sc.nextInt(),sc.nextInt());
				b = new Line2D.Double(s,t);
				flag = false;
				for(int j=0;j<n;j++){
					if((s.distance(p[j])<r[j] && t.distance(p[j])<r[j]) || b.ptSegDist(p[j])>r[j]);
					else{
						flag = true;
						break;
					}
				}
				if(flag==false) System.out.println("Danger");
				else System.out.println("Safe");
			}
		}	
	}	
}

Measured memory_bytes: 26792
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

vector<vector<int>>dp(30,vector<int>(500,0));

signed main(){
  int N,M;
  while(true){
    cin>>N>>M;
    if(N==0&&M==0)break;
    vector<int> C(M),Y(N);
    REP(i,0,M)cin>>C[i];
    REP(i,0,N)cin>>Y[i];
    vector<vector<int>> dp(256,vector<int>(N+1,INF));
    dp[128][0]=0;
    REP(i,0,N){
      REP(j,0,256){
        REP(k,0,M){
          int idx=C[k];
          idx=max(0LL,min(idx+j,255LL));
          dp[idx][i+1]=min(dp[idx][i+1],(Y[i]-idx)*(Y[i]-idx)+dp[j][i]);
        }
      }
    }
    int ans=INF+1;
    REP(i,0,256)ans=min(ans,dp[i][N]);
    print(ans)
  }

}



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

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  int a, b;
  if (m & 1)
    a = m, b = m + 1;
  else
    a = m + 1, b = m;

  for (int i = 1, j = a; i < j; i++, j--)
    printf("%d %d\n", i, j);
  for (int i = 1, j = b; i < j; i++, j--)
    printf("%d %d\n", a + i, a + j);

  return 0;
}

Measured memory_bytes: 3824
H, W, M = map(int, input().split())
h = [0] * (H+1)
w = [0] * (W+1)
l = set()
for i in range(M):
  x, y = map(int, input().split())
  h[x] += 1
  w[y] += 1
  l.add((x, y))
  
c = max(h)
d = max(w)
a = [i for i, x in enumerate(h) if x == c]
b = [i for i, x in enumerate(w) if x == d]

flag = False
for s in a:
  for t in b:
    if (s, t) not in l:
      flag = True
      break
  if flag:
    break
ans = c+d
if not flag:
  ans -= 1
print(ans)


Measured memory_bytes: 83412
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,ans=0;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    rep(i,N) A[i]--;
    rep(i,N) if(A[A[i]]==i) ans++;
    cout << ans/2 << endl;
}

Measured memory_bytes: 640
n = int(input())
w = []
for i in range(n):
    w.append(input())
if len(list(set(w))) != len(w):
    print('No')
    exit()
else:
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            print('No')
            exit()
print('Yes')

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

int main() {
  int N;
  cin >> N;
  int x=0;

  for (int i =0; i<N; i++){
    int a,b;
    cin >> a>>b;

    x+=b-a+1;
  }
  cout <<x<<endl;
    
  
}


Measured memory_bytes: 3592
#include<stdio.h>
#define INFTY 999999
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];
int color[MAX],d[MAX],f[MAX],p;

void dfs1(void);
void dfs2(int );

void dfs1(){
  int i,u;
  
  for(i=0;i<n;i++)color[i]=WHITE;
  p=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs2(u);

  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  
}

void dfs2(int u){
  int v;

  color[u]=GRAY;
  p++;
  d[u]=p;

  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE)dfs2(v);
  }
  color[u]=BLACK;
  f[u]=++p;
}

int main(){
  int i,j;
  int u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
	}
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
	}
  }

  dfs1();
  return 0;
}



Measured memory_bytes: 2048
#include<cmath>
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cctype>
#include<cstring>
using namespace std;



int main() {
	char x;
	int cnt[26] = {},n;
	for (; cin >> x&&x!='$';) {
		if (isalpha(x)) {
			if (isupper(x))x = tolower(x);
			n = x - 'a';
			cnt[n]++;

		}
	}
	char a = 'a';
	for (int i = 0; i < 26; i++) {
		cout << (char)(a + i) << " : " << cnt[i] << endl;
		//if (i != 25)cout << endl;
		
	}
	return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	cout << lcm(a, b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long n,f[100005],k,a[100005];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for (long i=1;i<=n;i++) cin>>a[i];
    f[1]=0;
    for (long i=2;i<=n;i++)
    {
        f[i]=1e9;
        for (long j=i-1;j>=i-k;j--)
        {
            if (j<=0) break;
            //cout<<f[i]<<endl;
            f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
        }
    }
    cout<<f[n];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
ll a,b;
cin>>a>>b;
if((a+b)%2==0)
    cout<<(a+b)/2<<endl;
else
    cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
//debug
#include<iostream>
#include<cstring>
#define FOR(i,n) for(int i=0;i<n;i++)

using namespace std;

bool result=true;
int main()
{
    string S;
    cin>>S;
    FOR(i,S.size())
    {
        if((i+1)%2!=0){
            if(S[i]=='R'||S[i]=='U'||S[i]=='D')
                continue;
            else{
                result=false;
                break;
            }
        }
        else{
            if(S[i]=='L'||S[i]=='U'||S[i]=='D')
                continue;
            else{
                  result=false;
                  break;
            }
        }
    }
    if(result)
        cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    std::cin.get();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#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;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int main(){
	int n, x, y, px, py;
	scanf("%d%d%d%d%d", &x, &y, &n, &px, &py);
	int ans = 0, tx, ty;n--;
	while(n--){
		scanf("%d%d", &x, &y);
		tx = x-px;ty = y-py;
		px = x;py = y;
		if((tx > 0 && ty > 0) || (tx < 0 && ty < 0)){
			ans += max(abs(tx), abs(ty));
		}else{
			ans += abs(tx)+abs(ty);
		}
		//printf("%d %d %d\n", tx, ty, ans);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3176
#include<stdio.h>

int AddA(int* a_aiA);

int main(void) {
	int aiA[3];
	int i;
	//3個の整数を入力
	for (i = 0;i < 3;i++) {
		scanf("%d", &aiA[i]);
	}
	//3個の整数を合計し、合計値によって結果を出力
	if (AddA(aiA) <= 21) {
		printf("win\n");
	}
	else {
		printf("bust\n");
	}
	return 0;
}

/********
*	3個の整数の和を求める関数
*	*a_aiA	入力された3個の整数
*/
int AddA(int* a_aiA) {
	return(a_aiA[0] + a_aiA[1] + a_aiA[2]);
}

Measured memory_bytes: 1660
# AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u

cin = [[''] for r in range(1002)]
dp =  [[0 for c in range(1002)] for r in range(1002)]
while 1:
	n = int(input())
	if n == 0: break
	for r in range(n): cin[r] = input()
	ans = 0
	for r in range(n):
		for c in range(n):
			if cin[r][c] == '*': dp[r][c] = 0
			else :
				t = dp[r-1][c-1]
				if dp[r  ][c-1] < t: t = dp[r  ][c-1];
				if dp[r-1][c  ] < t: t = dp[r-1][c  ];
				t += 1
				dp[r][c] = t
				if t > ans: ans = t
	print(ans)



Measured memory_bytes: 33064
x = int(input())
d = []
for i in range(1000):
	d.append( [i,i ** 5] )
	d.append( [ -i, (-i) ** 5 ] )
import sys
for i in d:
	for j in d:
		if i[1] - j[1] == x:
			print(i[0],j[0])
			exit(0)


Measured memory_bytes: 9284
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	var n, s, e, w bool
	for _, c := range S {
		switch c {
		case 'E':
			e = true
		case 'W':
			w = true
		case 'S':
			s = true
		case 'N':
			n = true
		}
	}
	if n != s || w != e {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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


int main(){

    
    int n, k, i;

    int a = 1;


    cin >> n >> k;


    for( i = 1 ; i <= n ; i = i + 1 ){

         a = min( 2 * a, a + k );

         }


    cout << a << endl;


    return 0;

    }


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  int i,j,n;
  double h,r,l,m,s[3];

  while(scanf("%lf%lf%lf",&s[0],&s[1],&s[2]),s[0]!=0 && s[1]!=0 && s[2]!=0){
    for(i=0;i<2;i++)
      for(j=1;j<3;j++)
        if(s[i]>s[j]){ h=s[i];s[i]=s[j];s[j]=h;}
    h=hypot(s[0],s[1]);
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%lf",&r);
      if(r*2.0>h) printf("OK\n"); else printf("NA\n");
    }
  }
  return 0;
}

Measured memory_bytes: 624
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    x, y, z = map(int, input().split())
    x, y = y, x
    x, z = z, x
    print(x,y,z)
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 27076
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int mod=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	string s,t;
	cin>>s>>t;
	ll ans=0;
	vi index[30];
	//1-index.
	rep(i,0,s.size())
		index[s[i]-'a'].push_back(i+1);
	int pre=-1;
	rep(i,0,t.size()){
		if(index[t[i]-'a'].empty()){
			print(-1);
			return 0;
		}
		int tmp=pre;
		auto itr=upper_bound(ALL(index[t[i]-'a']),pre);
		if(itr!=index[t[i]-'a'].end()&&pre<*itr)
			pre=*itr;
//cout<<pre<<" # ";
		if(tmp==pre){
			pre=index[t[i]-'a'][0];
			ans+=s.size();
		}
//cout<<pre<<endl;

	}
	print(ans+pre);
}


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

typedef long long ll;
const ll N=2e5 + 5;
const ll mod=1e9 + 7;
#define debug(x) cerr<<#x<<" is "<<x<<endl;

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

    ll a,b;
    cin>>a>>b;

    if(a>=1 && a<=9 && b>=1 && b<=9)
        cout<<a*b;
    else
        cout<<"-1";

}


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

long long sum(vector<long long>A,int mm){
long long sum=0;
 for(int i=0;i<mm;i++) sum+=A[i];
return sum;
}

long long maxl(long long a,long long b){
return b-a>0 ? b : a ;
}
long long minl(long long a,long long b){
return a-b>0 ? b : a ;
}

int main(){

 int N;
 cin>>N;
unsigned long a,b;
vector<long long>A,B,CA,CB;

 for(int i=0;i<N+1;i++){
 cin>>a;
A.push_back(a);
 }

 for(int i=0;i<N;i++){
 cin>>b;
B.push_back(b);
 }

long long l;
CA.push_back(minl(B[0],A[0]));
l=maxl(B[0]-CA[0],0);
CB.push_back(minl(l,A[1]));


for(int i=1;i<N;i++){

CA.push_back(minl(B[i],A[i]-CB[i-1]));
l=maxl(B[i]-CA[i],0);
CB.push_back(minl(l,A[i+1]));

 }

cout<<sum(CA,N)+sum(CB,N)<<endl;

 return 0;
}

Measured memory_bytes: 5020
n=int(input())
b=list(map(int,input().split()))
i=0
c=[]
while len(b)>0 and i<len(b):
  if b[len(b)-i-1]==len(b)-i:
    c.append(len(b)-i)
    b.remove(b[len(b)-i-1])
    i=0
  else:
    i+=1
if len(b)==0:
  for i in range(n):
    print(c[n-i-1])
else:
  print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define neko 310
#define pb push_back
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
using namespace std;
typedef pair<int,int>pi;
vector<pi>vec[neko];
int n,m,dp[neko][neko][neko],ans,mod=1e9+7;
inline int cmax(int a,int b){return a>b?a:b;}
int ADD(int x,int y){return ((x+=y)>=mod)?x-mod:x;}
inline bool check(int r,int g,int b)
{
	int x=cmax(r,cmax(g,b)),len,l;len=vec[x].size()-1;
	f(i,0,len)
	{
		l=vec[x][i].fi;
		if(((r>=l)+(g>=l)+(b>=l))^vec[x][i].se)return 0;
	}return 1;
}
int main()
{
	int x,y,z;
	scanf("%d%d",&n,&m);
	f(i,1,m)scanf("%d%d%d",&x,&y,&z),vec[y].pb(pi(x,z));
	dp[0][0][0]=1;
	f(r,0,n)
	 f(g,0,n)
	  f(b,0,n)
	  {
		if(!dp[r][g][b])continue; 
		x=cmax(r,cmax(g,b))+1;
		if(!check(r,g,b))continue;
		if(x==n+1)ans=ADD(ans,dp[r][g][b]);
		dp[x][g][b]=ADD(dp[x][g][b],dp[r][g][b]);
		dp[r][x][b]=ADD(dp[r][x][b],dp[r][g][b]);
		dp[r][g][x]=ADD(dp[r][g][x],dp[r][g][b]);
	  }
	printf("%d\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 114944
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>

using namespace std;

double ab;   //module
double ac;
double ad;
double bc;
double bd;
double cd;

bool Solution()
{
    double sq1 = 0.0;
    double sq2 = 0.0;
    
    double S;
    double f;
    
    /*sq1*/
    f = (ab + ac + bc) * 0.5;   //judge formula
    S = sqrt(f * (f - ab) * (f - ac) * (f - bc));
    sq1 += S;
    
    f = (ac + ad + cd) * 0.5;
    S = sqrt(f * (f - ac) * (f - ad) * (f - cd));
    sq1 += S;
    
    /*sq2*/
    f = (ab + ad + bd) * 0.5;
    S = sqrt(f * (f - ab) * (f - ad) * (f - bd));
    sq2 += S;
    
    f = (bc + bd + cd) * 0.5;
    S = sqrt(f * (f - bc) * (f - bd) * (f - cd));
    sq2 += S;
    
    if (fabs(sq1 - sq2) <= 0.01)
    {
        return true;
    }
    else
    {
        return false;
    }

}

int main()
{
    double xa, ya;
    double xb, yb;
    double xc, yc;
    double xd, yd;
    
    char comma;
    
    while(cin>>xa>>comma>>ya>>comma>>xb>>comma>>yb>>comma>>xc>>comma>>yc>>comma>>xd>>comma>>yd)
    {
        
        ab = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
        ac = sqrt((xa - xc) * (xa - xc) + (ya - yc) * (ya - yc));
        ad = sqrt((xa - xd) * (xa - xd) + (ya - yd) * (ya - yd));
        bc = sqrt((xb - xc) * (xb - xc) + (yb - yc) * (yb - yc));
        bd = sqrt((xb - xd) * (xb - xd) + (yb - yd) * (yb - yd));
        cd = sqrt((xc - xd) * (xc - xd) + (yc - yd) * (yc - yd));
        
        if (Solution())
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
     int H,W;
     cin >> H >> W;
     for (int k=0; k<W+2; k++) cout <<"#";
     cout << endl;
     for (int i=0;i<H;i++){       
       cout << "#";
       string str;
       cin >> str;
       for (int j=0;j<W;j++){
         cout << str.at(j);
       }
       cout << "#" <<endl;
     }
     for (int k=0; k<W+2; k++) cout <<"#";
     cout << endl;
    }

       

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll N,A[100010];

ll merge_count(vector<ll> &a){
	ll n = a.size();
	if(n<=1) return 0;
	ll cnt = 0;
	vector<ll> b(a.begin(),a.begin() + n/2);
	vector<ll> c(a.begin() + n/2, a.end());
	cnt += merge_count(b);
	cnt += merge_count(c);
	ll ai = 0,bi = 0,ci = 0;
	while(ai<n){
		if(bi<b.size() && (ci == c.size() || b[bi] <= c[ci])){
			a[ai++] = b[bi++];
		}else{
			cnt += n/2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}

ll median(ll x){
	vector<ll> B(N+1,0);
	for(int i=1;i<=N;i++){
		if(A[i-1]>=x) B[i] = 1;
		else B[i] = -1;
		B[i] += B[i-1];
	}
	return N*(N+1)/2-merge_count(B);
}

int main(){
	cin >> N;
	ll ma = 0,mi = 1e9+1;
	for(int i=0;i<N;i++){
		cin >> A[i];
/*		ma = max(ma,A[i]);
		mi = min(mi,A[i]);*/
	}
/*	if(N==1){
		cout << A[0] << endl;
		return 0;
	}*/
	ll l = 0,r = 1e9+1;
	while(l+1<r){
		ll m = (l+r)/2;
		if(median(m)>=(N*(N+1)/2+1)/2) l = m;
		else r = m;
	}
/*	if(l<mi) cout << mi << endl;
	else if(l>ma) cout << ma << endl;*/
	cout << l << endl;
}

Measured memory_bytes: 3424
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<=n;i++)
typedef int long long ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    ll a=sqrt(n);
    cout<<a*a<<endl;
  
    
return 0;
}


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

typedef long long LL;

const int N=2000,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m;

void into(){
  scanf("%d%d",&m,&n);
}

int pw[N+9];

void Get_pw(){
  pw[0]=1;
  for (int i=1;i<=m;++i) pw[i]=mul(pw[i-1],2);
}

int inv[N*2+9],fac[N*2+9],ifac[N*2+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2;i<=n+m;++i){
	inv[i]=mul(mod-mod/i,inv[mod%i]);
	fac[i]=mul(fac[i-1],i);
	ifac[i]=mul(ifac[i-1],inv[i]);
  }
}

int Get_c(int n,int m){return n<m||m<0?0:mul(fac[n],mul(ifac[m],ifac[n-m]));}

int Get_ans(int n,int a,int b){
  int res=0;
  for (int i=0;i<=b;++i){
	sadd(res,mul(Get_c(n+a-1,i+a-1),mul(Get_c(b,i),pw[i])));
  }
  return res;
}

int ans[N*2+9];

void Get_ans(){
  for (int i=2;i<=m+1;++i){
	int t=i-1>>1;
	ans[i]=i&1?Get_ans(n,m-2*t,t):add(Get_ans(n,m-1-2*t,t),Get_ans(n-1,m-1-2*t,t));
  }
  for (int i=m+2;i<=m<<1;++i) ans[i]=ans[2*m+2-i];
}

void work(){
  Get_pw();
  Get_inv();
  Get_ans();
}

void outo(){
  for (int i=2;i<=m<<1;++i)
	printf("%d\n",ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 384
/*
 * B.cpp
 *
 *  Created on: 2020/07/25
 *      Author: 17k1028
 */



#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define REPD(i,n) for(ll i=n-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=a; i<=ll(b); i++)
#define FORD(i,a,b) for(ll i=a; i>=ll(b); i--)

bool bai(int a, int b, int c, int  n, int k){
	if(n==k){
		if(a<b && b<c){
			return true;
		}else return false;
	}else{
		n++;
		bool resa, resb, resc;
		resa = bai(a*2,b,c,n,k);
		resb = bai(a,b*2,c,n,k);
		resc = bai(a,b,c*2,n,k);
		if(resa or resb or resc){
			return true;
		}else return false;
	}
}


int main(){
	int A,B,C,K;
	cin >> A >> B >> C;
	cin >> K;
	bool res;
	res = bai(A,B,C,0,K);
	if(res){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}





Measured memory_bytes: 3572