akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;
int main(void){
    long long int n,a[1000],color[10]={},sum=0,cou=0,b[1000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        if(a[i]%10!=0){b[cou]=a[i];cou++;}
    }
    if(cou==0){cout<<0;return 0;}
    
    if(sum%10!=0){cout<<sum;return 0;}
    sort(b,b+cou);
    cout<<sum-b[0];
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define read(x) int x; cin>>x;
#define print(x) for(int i=0; i<(int) x.size(); i++) cout<<x[i]<<" "; cout<<endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;

const ll INFLL = (ll) 1e16;
const int INF = (int) 1e8;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	read(n)
	vi nums(n);
	for(auto &it: nums) cin>>it;
	
	if(n==2) {
		cout<<max(nums[0], nums[1])<<endl;
		return 0;
	}
	vi left(n);
	left[0] = nums[0];
	
	for(int i=1; i<n; i++) {
		left[i] = __gcd(left[i-1], nums[i]);
	}
	vi right(n);
	right[n-1] = nums[n-1];
	for(int i=n-2; i>=0; i--) {
		right[i] = __gcd(right[i+1], nums[i]);
	}
	
	int answer = max(right[1], left[n-2]);
	for(int i=1; i<n-1; i++) {
		answer = max(answer, __gcd(left[i-1], right[i+1]));
	}
	cout<<answer<<endl;
	return 0;
}


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

int get_keta(int k)
{
	int keta = 0;
	while(k > 0){
		k /= 10;
		++keta;
	}
	return keta;
}

int main(void)
{
	int n;
	cin >> n;
	
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		if(get_keta(i) % 2 == 1){
			++ans;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}

int main(){
	//input
	ll N; cin>>N;
	vector<ll> A(N+1);
    vector<ll> B(N+1);
    vector<ll> C(N);
    rep1(i,N) cin>>A[i];
    rep1(i,N) cin>>B[i];
    rep1(i,N-1) cin>>C[i];

	//solve
    ll ans=0;
	rep1(i,N){
        ans+=B[A[i]];
        if(i<=N-1 && A[i+1]==A[i]+1) ans+=C[A[i]];
    }


	//output
	cout<<ans;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        _n: usize,
        s: String,
        k: usize1
    }
    let expect = s.chars().skip(k).next().unwrap();
    let result: String = s.chars().map(|c| if c == expect { c } else { '*' }).collect();
    println!("{}",result);
}


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

using namespace std;

int main(){
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long cnt = 0;
    for(long long i = 1; i < s.length() - 1; ++i){
        if(s[i - 1] == 'A' && s[i] == 'B' && s[i + 1] == 'C'){
            cnt++;
        }
    }
    cout << cnt;

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main(){
    rep(i,5){
        int x;cin>>x;
        if (x==0){
            cout<<i+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3572
import numpy as np
import pdb

def main():
    N = int(raw_input())
    Cs = np.zeros(N-1).astype(int)
    Ss = np.zeros(N-1).astype(int)
    Fs = np.zeros(N-1).astype(int)

    for k in range(N-1):
        CSF = np.array(raw_input().split(' ')).astype(int)
        Cs[k] = CSF[0]
        Ss[k] = CSF[1]
        Fs[k] = CSF[2]

    schedule = train(Cs, Ss, Fs)
    for m in range(len(schedule)):
        print schedule[m]

def train(Cs, Ss, Fs):
    N = len(Cs)
    finaltimes = np.zeros(len(Cs) + 1).astype(int)
    arrivaltimes = 0
    destination = N - 1
    for k in range(N):
        currentloc = k
        arrivaltimes = Ss[k]
        for j in range(k, N):
            bestarrivaltimes = np.max([arrivaltimes, Ss[j]])
            arrivaltimes = np.ceil(bestarrivaltimes/ Fs[j]) * Fs[j] + Cs[j]
        finaltimes[k] = int(arrivaltimes)

    return finaltimes



if __name__ == '__main__':
    main()


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

int main()
{
    long int a,b,c;
    long int k;
    cin>>a>>b>>c>>k;
    if((a+b+c) > 2000000000 || k>(a+b+c))
        return 0;
    long int sum;
    if(k >= (a+b))
        sum = 2*a+b-k;
    else if(k<a)
        sum = k;
    else
        sum = a;
    cout<<sum;       
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    char A,B,C,D,E,F;
    
    cin >> A >> B >> C >> D >> E >> F;
    
    string Y = "YES", N = "NO", ans;
    
    if((A == F) && (B == E) && (C ==D )) ans = Y;
    else ans = N;
    
    cout << ans << endl;
    
    return 0;
}

    


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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;
const int mod=1e9+7;
int a[N];


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1) {
        puts("Brown");
    }
    else puts("Alice");
    return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll k;
    string s;
    cin>>s>>k;

    for(int i=0; i<s.size(); i++)
    {
        if(s[i] != '1' || i == k-1)
        {
            cout<<s[i]<<endl;

            return 0;
        }
    }
    cout<<1<<endl;

    return 0;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

template<typename T>
void max_self(T& a, T b)
{
	a = max(a, b);
}
int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	string s;
	cin >> s;
	if (s == "SUN")
	{
		cout << 7;
		return 0;
	}
	vector<string> a = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
	for (int i = 0; i < sz(a); i++)
		if (a[i] == s)
		{
			cout << sz(a) - i - 1;
			break;
		}
	return 0;
}

Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll a, b;
	ll cnt = 0;

	FOR(i, a, b + 1)
	{
		auto s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3])
			cnt++;
	}

	return OUT(cnt);
}


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

bool compare_second(pair<int, int> a, pair<int, int> b) {
	if (a.second == b.second) return a.first < b.first;
	return a.second < b.second;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int,int>> v(m);
	for (int i = 0; i < m; i++) {
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end(), compare_second);
	int ans = 0, b = 0;
	for (int i = 0; i < m; i++) {
		if (v[i].first < b) continue;
		b = v[i].second;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){

  double l;
  double r;

  int l_a = 0;
  int l_b = 0;
  int l_c = 0;
  int l_d = 0;
  int r_a = 0;
  int r_b = 0;
  int r_c = 0;
  int r_d = 0;
  
  while(cin >> l >> r){
	if(l >= 1.1)
	  l_a++;
	else if(l >= 0.6 && l < 1.1)
	  l_b++;
	else if(l >= 0.2 && l < 0.6)
	  l_c++;
	else if(l < 0.2)
	  l_d++;

	if(r >= 1.1)
	  r_a++;
	else if(r >= 0.6 && r < 1.1)
	  r_b++;
	else if(r >= 0.2 && r < 0.6)
	  r_c++;
	else if(r < 0.2)
	  r_d++;
	
  }

  cout << l_a << " " << r_a << endl;
  cout << l_b << " " << r_b << endl;
  cout << l_c << " " << r_c << endl;
  cout << l_d << " " << r_d << endl;
  
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std; 
int main(){
long long   n;
cin>>n;
 long long  c =sqrtl(n);
long long  pos=-99;long long  m=100000000;
for(long long  i=c;i>=1;i--){
    if(n%i==0){
       cout<<i-1+(n/i)-1<<" ";
       break;
       }
    }
}//cout<<pos;



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

class unionfind{ // 0-indexed
public:
	vector<int> parent;
	vector<size_t> size;
	size_t num_of_disjointsets;
	unionfind(size_t n){
		parent.resize(n, -1);
		size.resize(n, 1);
		num_of_disjointsets = n;
	}

	size_t find(size_t x){
		if(parent[x] == -1) return x;
		return parent[x] = find(parent[x]);
	}

	size_t unite(size_t x, size_t y){
		x = find(x);
		y = find(y);
		if(x == y) return -1;
		if(size[x] < size[y]){
			parent[x] = y;
			size[y] += size[x];
			size[x] = 0;
			--num_of_disjointsets;
			return y;
		}else{
			parent[y] = x;
			size[x] += size[y];
			size[y] = 0;
			return x;
			--num_of_disjointsets;
		}
	}

	bool united(size_t x, size_t y){
		return find(x) == find(y);
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, m; cin >> n >> m;
	unionfind uf(2*n);
	for(Int i=0; i<m; ++i){
		Int a, b; cin >> a >> b; --a; --b;
		uf.unite(2*a, 2*b+1);
		uf.unite(2*b, 2*a+1);
	}
	bool f = true;
	for(Int i=0; i<n; ++i)
		if(uf.united(2*i, 2*i+1)){
			f = false;
			break;
		}
	if(!f){
		cout << n * (n-1) / 2 - m << "\n";
	}else{
		Int a = 1;
		for(Int i=1; i<n; ++i)
			if(uf.united(0, 2*i))
				++a;
		cerr << a << " " << n-a << "\n";
		cout << a * (n-a) - m << "\n";
	}
}

Measured memory_bytes: 2560
def s():
 n=int(input())-1
 A=list(map(int,input().split()))
 i=0
 for j in range(n):
  if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1
 A[i],A[n]=A[n],A[i]
 print(" ".join(map(str,A[:i]))+" ["+str(A[i])+"] "+" ".join(map(str,A[i+1:])))
if'__main__'==__name__:s()


Measured memory_bytes: 16392
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#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;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int k=0,v=0;
    rep(i,2*n){
        if(i%2==0){
            cout<<s[k];
            k++;
        }else{
            cout<<t[v];
            v++;
        }

    }
    cout<<endl;
    
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((H-h)*(W-w));
    }
}


Measured memory_bytes: 22996
n = gets.to_i
v = gets.split.map(&:to_i)
v1, v2 = Hash.new(0), Hash.new(0)

v.each_slice(2) do |a, b|
    v1[a] += 1
    v2[b] += 1
end

a1, a2 = v1.sort_by(&:last).reverse.take(2)
b1, b2 = v2.sort_by(&:last).reverse.take(2)

if a1[0] == b1[0] then
    puts n - [a1[1] + (b2 ? b2[1] : 0), (a2 ? a2[1] : 0) + b1[1]].max
else
    puts n - a1[1] - b1[1]
end

Measured memory_bytes: 20464
#include <stdio.h>
int main(void)
{
    int x,y,z,a,b;
  
    scanf("%d%d%d",&x,&y,&z);
  
    a=y+z;
    b=x/a;
    if(x%a<z) b=b-1;
  
    printf("%d\n",b);
  
    return 0;
}

Measured memory_bytes: 128
using System;

namespace ABC124_B
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();
            int[] ryokan = new int[n];
            for (int i = 0; i < n; i++)
                ryokan[i] = int.Parse(input[i]);

            int oceanCount = 1;
            for(int i = 1; i < n; i++) {
                bool oceanSee = true;
                for(int j = 0; j < i; j++) {
                    if(ryokan[j] > ryokan[i]) {
                        oceanSee = false;
                        break;
                    }
                }

                if (oceanSee) oceanCount++;
            }

            Console.WriteLine(oceanCount);
        }
    }
}

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

// 插入此處

int main() {
    LL n;
    cin >> n;
    LL ans = 0;
    for (LL i = 1; i <= n; i++) {
        ans += i * (n - i + 1);
    }
    for (int i = 0; i < n - 1; i++) {
        LL u, v;
        cin >> u >> v;
        LL l = min(u, v);
        LL r = max(u, v);
        ans -= l * (n - r + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<queue>

using namespace std;

priority_queue<int> a;
int main()
{
    int n,m;
    long long sum = 0;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        a.push(t);
    }
    while(m--){
        int t = a.top();
        a.pop();
        a.push(t / 2);
    }
    while(n--){
        sum += a.top();
        a.pop();
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 892
import math
n,d=map(int,input().split())
d_list=[]
ans=0
for i in range(n):
    d_list.append(list(map(int,input().split())))
for i in range(n-1):
    for j in range(i+1,n):
        kyori=0
        #print(i,j)
        for k in range(d):
            kyori+=(d_list[i][k]-d_list[j][k])**2
        #print(kyori)
        if int(math.sqrt(kyori))**2==kyori:
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    bool a=true;
    if(s.size()+1!=t.size()) a=false;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)) a=false;
    }
    if(a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int a , b ;	
	cin >> a >> b ;
	int c = a + b;
	if(c >= 10) cout <<"error"<< endl;
	else cout << c << endl;
}


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

using namespace std;

int a,b,c,d,e,f;
vector<int>water;
vector<int>suger;

int main() {
  cin >> a >> b >> c >> d >> e >> f;

  for(int i = 0; i * 100 <= f; i++) {
    for(int j = 0; j * 100 <= f; j++) {
      int w = 100 * a * i + 100 * b * j;
      if(w > f) continue;
      water.push_back(w);
    }
  }

  for(int i = 0; i <= f; i++) {
    for(int j = 0; j <= f; j++) {
      int s = c * i + d * j;
      if(s > f) continue;
      suger.push_back(s);
    }
  }

  double ans = -1;
  double a_w,a_s;
  
  for(int i = 0; i < water.size(); i++) {
    int w =  water[i];
    if(w > f) continue;
    for(int j = 0; j < suger.size(); j++) {
      int s = suger[j];      
      if(w + s > f || s > e * w / 100.0)continue;
      double tmp = 100.0 * s / (double)(w + s);
      if(ans < tmp) {
	ans = tmp;
	a_w = w;
	a_s = s;
      }
    }
  }

  cout << a_w + a_s <<" "<< a_s << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	vector<int> a(n);
	for(auto &c:a){
		cin>>c;
	}
	sort(a.begin(), a.end());
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]!=a[j] && a[j]!=a[k] && a[i]+a[j]>a[k]) cnt++;
			}
		}
	}
	cout<<cnt<<'\n';
	return 0;
}

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;

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

  int i = 1;
  int result = 1;
  while (true) {
    i = i << 1;
    if (i > N) {
      cout << result << endl;
      return 0;
    } else {
      result = i;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String a = br.readLine();
            String b = br.readLine();
          	Main app = new Main();
            int k = Integer.parseInt(a.split(" ")[1]);
            String[] split = b.split(" ");
            int[] A = new int[split.length];
            for (int i = 0; i < split.length; i++) {
               A[i] = Integer.parseInt(split[i]); 
            }
            boolean[] dp = new boolean[k + 1];
            for (int stones = 0; stones <= k; stones++) {
                for (int x: A) {
                    if (stones >= x && !dp[stones - x]) {
                        dp[stones] = true;
                    }
                }
            }
            System.out.println(dp[k] ? "First" : "Second");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 22612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Mehvix
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATherefore solver = new ATherefore();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATherefore {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            int ones = fin.nextInt() % 10;
            if (ones == 3) fout.println("bon");
            else if (ones == 0 || ones == 1 || ones == 6 || ones == 8) fout.println("pon");
            else fout.println("hon");
        }

    }
}



Measured memory_bytes: 35836
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int a[100005];
int main(void)
{
    int n;
    while(cin>>n)
    {
        int cot=0;
        for(int i=1;i<=n;i++)
            cin>>a[i];
        for(int i=1;i<=n;i++)
        {
            if(a[i]==i)
            {
                if(i==n)
                {
                    swap(a[i],a[i-1]);
                    cot++;
                }
                else
                {
                    swap(a[i],a[i+1]);
                    cot++;
                }
            }
        }
        cout<<cot<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
// Title: All Green
// URL: https://atcoder.jp/contests/abc104/tasks/abc104_c
#pragma region Library

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

using ll = long long int; // int_fast64_t;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;

constexpr int INF = 1 << 30;  // 1073741824 2倍すると-2147483648
constexpr ll INFL = 1l << 62; // 4611686018427387904 2倍すると-0.9*10^18
constexpr int dx4[] = {0, 1, 0, -1};
constexpr int dy4[] = {1, 0, -1, 0};
constexpr int dx8[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy8[] = {0, -1, 0, 1, -1, -1, 1, 1};
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define RANGE(i, a, b) for (int i = (a); i <= (b); i++)
#define RANGER(i, a, b) for (int i = (b); i >= (a); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, 0, (n))

#pragma endregion

inline int div_ceil(int a, int b) { return (a + b - 1) / b; }

int main() {
  // Read
  int D, G;
  vi P = vi(10), C = vi(10);
  cin >> D >> G;
  REP(i, D) scanf("%d %d", &P[i], &C[i]);
  // Solve
  /*
  Note: P,C は、0-based index で格納されているが、問題分では1-based
  方針:
  Perfectなやつを全探索、一問あたりのスコアが一番高いやつを必要問題数解く。
  Order: O(2^D*D) ACが狙える
  */
  int ans = INF;
  REP(bitmap, 1 << D) { // 完全解答のやつのマップ
    int score = 0, count = 0;
    REP(i, D) {
      if (bitmap >> i & 1) { // 完全解答する
        score += (i + 1) * 100 * P[i] + C[i];
        count += P[i];
      }
    }
    if (ans <= count)
      continue; // とりあえずの枝狩り
    if (score >= G) {
      ans = min(ans, count);
      continue;
    }
    REPR(i, D) {
      if (not(bitmap >> i & 1)) {
        int required = div_ceil(G - score, (i + 1) * 100);
        if (required > P[i])
          break;
        count += required;
        ans = min(ans, count);
        break;
      }
    }
  }
  // Output
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
		} catch (IOException e) {
		}
		int n = Integer.parseInt(input);
		for (int i = 1; i <= n; i++) {
			int x = 10 * n;
			if (i % 3 == 0 || i % 10 == 3 || i / 10 % 10 == 3 || i / 100 % 10 == 3 || i / 1000 % 10 == 3) {
				System.out.print(" " + i);
			}
		}
		System.out.println("");
	}
}


Measured memory_bytes: 26972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int size = s.size();
    int pos = 0;
    vector<int> ans;
    while(pos < size-1)
    {
        int cand = m;
        if(pos + cand >= size)
        {
            ans.push_back(size-pos-1);
            break;
        }
        while(cand > 0 && s[pos+cand] == '1') cand--;
        if(cand == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        pos += cand;
        ans.push_back(cand);
    }
    reverse(ans.begin(), ans.end());
    for(int nx : ans)
    {
        cout << nx << " ";
    }
}


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

using namespace std;

int main(void){
	int N;
	cin >> N;
	vector<int> b(N+1);
	vector<int> ans;
	for(int i=0;i<N;i++)cin >> b[i+1];
	
	for(int i=N;i>=1;i--){
		for(int j=i;j>=1;j--){
			if(b[j]==j){
				ans.push_back(j);
				b.erase(b.begin()+j);
				break;
			}
		}
	}
	if(b.size()==1){
		reverse(ans.begin(),ans.end());
		for(auto x:ans)cout << x << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class DBrickBreak {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi A(n);
        in >> A;
        int next = 1;
        trav(x, A) {
            if (x == next) {
                next++;
            }
        }
        int res = n - next + 1;
        if (res == n) {
            res = -1;
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    DBrickBreak solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3992
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for i in range(q):
    print(t[lr[i][1]-1] - t[lr[i][0]-1])

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF =  1e9;
const ll LINF = 1e18;
const ll MOD = 1e9+7;
const int SIZE = 100;

template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}

template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
 
ll fac[SIZE], inv[SIZE], facinv[SIZE];
void make() {
	fac[0] = fac[1] = 1; inv[1] = 1; facinv[0] = facinv[1] = 1;
	for (ll i = 2; i < SIZE; i++) {
		fac[i] = (fac[i-1] * i) % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		facinv[i] = facinv[i-1] * inv[i] % MOD;
	}
}
ll combi(ll a, ll b) {
	if (a < b) return 0;
	return fac[a] * (facinv[b] * facinv[a-b] % MOD) % MOD;
}

int main() {
	ll n;
	scanf ("%lld",&n);
	vector<ll> a(n);
	ll asum = 0;
	for (ll i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		asum += a[i];
	}
	ll x = a[0]; ll y = asum - a[0];
	ll ans = abs(x-y);
	for (ll i = 1; i < n-1; i++) {
		x += a[i]; y -= a[i];
		ans = min(ans, abs(x-y));
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import sys

n=input()
num = n.split()
a=int(num[0])
b=int(num[1])

def checkMultiNum(base, dst):
	num=0
	while True:
		if base >= dst:
			break;
		num+=1
		base = base * 2
		if base >= dst:
			break;
	return num

prob=1/a
res=0
for v in range(a):
	num = checkMultiNum(v+1, b)
	tmp = prob * 0.5**num
	res += tmp

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

vector<int> g[100005];

int dfs(int m, int d, int from){
  vector<int> ch;
  for(auto to : g[d]) if(to!=from){
    int r = dfs(m, to ,d);
    if(r > m) return INF;
    ch.pb(r);
  }
  // dbg(m,d,ch);
  int sz = ch.size();
  if(sz==0) return 1;
  if(sz==1) return ch[0]+1;

  sort(all(ch));
  auto check = [&](int mid){
    int l = 0, r = sz-1;
    while(l<r){
      if(l==mid) l++;
      if(r==mid) r--;
      if(l>=r) break;
      if(ch[l]+ch[r] > m) return false;
      l++;
      r--;
    }
    return true;
  };
  if(sz%2==0){
    if(check(-1)) return 1;
    else sz--;
  }

  if(check(0)) return ch[0]+1;
  if(!check(sz-1)) return INF;
  int l = 0, r = sz-1;
  while(r-l>1){
    int mid = (l+r)/2;
    if(check(mid)) r = mid;
    else l = mid;
  }
  return ch[r]+1;
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  int a = 1;
  rep(i,n) a += (g[i].size()-1)/2;

  int d = 0;
  while(g[d].size()!=1) d++;

  int l = 0, r = n;
  while(r-l>1){
    int m = (r+l)/2;
    if(dfs(m, d, -1) <= m+1) r = m;
    else l = m;
  }

  cout << a << " " << r << endl;

  return 0;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)

#define MAX_V 100000
struct edge {int to,cost;};
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];
void dijkstra(int start){
	priority_queue<P,vector<P>,greater<P>> Q;
	fill(d,d+V,INF);
	d[start]=0;
	Q.push(make_pair(0,start));
	while(!Q.empty()){
		P p=Q.top();
		Q.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		FORVEC(i,G[v]){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				Q.push(make_pair(d[e.to],e.to));
			}
		}
	}
}

int main(){
	cin>>V>>E;
	int r;
	int s,t,D;
	cin>>r;
	REP(i,E){
		cin>>s>>t>>D;
		G[s].push_back((edge){t,D});
	}

	dijkstra(r);
	REP(i,V){
		if(d[i]==INF)cout<<"INF\n";
		else cout<<d[i]<<"\n";
	}

	return 0;
}

Measured memory_bytes: 12964
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = []
    for _ in range(n):
        tmp = ni()
        d.append(tmp)

    dp = [INF for _ in range(n + 1)]

    for di in d:
        idx = bisect.bisect_left(dp, di)
        dp[idx] = di

    for i in range(n, -1, -1):
        if dp[i] != INF:
            print(i + 1)
            break


if __name__ == '__main__':
    main()



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

#define ll long long
const int MAXN=2e5+1;
ll a[MAXN],b[MAXN];

int main(){
	ll n;
	cin>>n;
	for(ll i=0; i<n; i++) cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	if (n%2==1){
		ll x=a[(n+1)/2-1],y=b[(n+1)/2-1];
		cout<<y-x+1<<endl;
	}
	else{
		ll x=a[n/2-1]+a[n/2],y=b[n/2-1]+b[n/2];
		cout<<y-x+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6728
import math
N,K=map(int,input().split())
pro=0
if N==1 and K==1:
    print(1)
elif N>=K:
    pro+=(N-K+1)/N
    for k in range(1, K):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)

else:
    for k in range(1, N+1):
        r = math.ceil(math.log(K / k,2))
        pro += 0.5**r / N
    print(pro)



Measured memory_bytes: 65216
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;


int main(){

  int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> b(n);
  for(int i=0; i<n; i++) cin >> a[i] >> b[i];

  long long int ans = 0;
  for(int i=n-1; i>=0; i--){
    a[i] += ans;
    
    if( a[i] % b[i] == 0 ) continue;

    if( a[i] < b[i] ){
      ans += b[i] - a[i];
    }else{
      ans += b[i] - (a[i]%b[i]);
    }

  }
  cout << ans << endl;

  return 0;
}








// EOF


Measured memory_bytes: 1792
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
    if(m == 0) return 1;
    if(i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main(){
    int q, M, i;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d", &M);
        if(solve(0, M)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 2608
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n; cin>>n;
  vector<ll> a(n);
  for(int i = 0 ; i < n ; i++)
    cin>>a[i];
  sort(a.begin(), a.end());
  // for(ll x : a)
  //   cout<<x<<" ";
  // cout<<endl;

  ll ans = 0;
  for(int i = 1; i < n-1; i++)
  {
    for(int j = i+1; j < n ; j++)
    {
      vector<ll>::iterator it = upper_bound(a.begin(), a.end(), a[j]-a[i]);
       ll pos = it - a.begin();
      if(pos < i)
      {
     
    //  cout<<"at "<<i<<" "<<j<<" "<<a[pos]<<" ";
      if(a[pos] == a[j]-a[i])
      {
       // cout<<(i-pos)<<endl;
        ans+=(i-pos);
      }
      else
      {
      //  cout<<(i-pos)<<endl;
        ans+=(i-pos);
      }
    }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(sc.nextInt());
        }
        boolean plus = false;
        boolean minus = false;
        int cnt = 1;
        for (int i = 0; i < n - 1; i++) {
            if (a.get(i + 1) - a.get(i) > 0) {
                if (minus) {
                    cnt++;
                    plus = false;
                    minus = false;
                    continue;
                }
                plus = true;
            } else if (a.get(i + 1) - a.get(i) < 0) {
                if (plus) {
                    cnt++;
                    plus = false;
                    minus = false;
                    continue;
                }
                minus = true;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 60548
#include <stdio.h>

int main(void){
    long long int A[200000];
    long long int sum;
    long long int tmp, tmp2;
    int N;
    int i,j;

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

    sum = 0;
    tmp = 0;
    tmp2 = 0;
    for (i=0;i<N;++i) {
        sum += A[i]; 
        tmp = A[i] * A[i];
        tmp = tmp % 1000000007;
        tmp2 += tmp;
        tmp2 = tmp2 % 1000000007;
    }
    sum = sum % 1000000007;
    sum = (sum*sum) % 1000000007;
    // printf("%lld\n%lld\n%lld\n", sum, tmp2, sum - tmp2);
    if ( sum > tmp2 ) {
        sum = (sum - tmp2);
        if (sum % 2 == 0) {
            sum /= 2;
        } else {
            sum += 1000000007;
            sum /= 2;
            sum %= 1000000007;
        }
    } else {
        // printf("else\n%lld\n%lld\n", 1000000007 + sum, tmp2);
        sum = ((1000000007 + sum) - tmp2);
        if (sum % 2 == 0) {
            sum /= 2;
        } else {
            sum += 1000000007;
            sum /= 2;
            sum %= 1000000007;
        }
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 3296
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	vector<pair<int,int>> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;
	sort(v.begin(),v.end());
	vector<int> best(7000);
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=k-1;j>=0;j--){
			best[j+v[i].first]=max(best[j+v[i].first],best[j]+v[i].second);
			ans=max(ans,best[j+v[i].first]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
ll a[100009];
ll xx[100009];

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

    cin >> n;

    ll sum = 0;

    rep(i, n + 1) {
        cin >> a[i];
        sum += a[i];
    }

    memset(xx, 63, sizeof(xx));

    ll x = 1;
    rep(i, n + 1) {
        if(x > inf) break;
        xx[i] = x;
        if(a[i] > x) {
            cout << -1 << endl;
            return 0;
        }
        x -= a[i];
        x *= 2;
    }

    ll ans = 0;

    rep(i, n + 1) {
        ll k = sum;
        chmin(k, xx[i]);
        ans += k;
        sum -= a[i];
    }

    cout << ans << endl;

    return 0;
}

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

  int main()
  { 
    ios::sync_with_stdio(!cin.tie(0));
  long  int x;
    cin>>x;
    int a,b;
    for(a=-118;a<=119;a++)
      for( b=-118;b<=119;b++)
         if(pow(a,5)-pow(b,5)== x) 
         return cout<<a<<" "<<b,0;
   
    return 0;
  }


Measured memory_bytes: 4028
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char s[200001];
char t[200001];

int main()
{
	while (scanf("%s%s", &s, &t) != EOF) {
		int i;
		int slen;
		int cnt;
		slen = strlen(s);
		cnt = 0;
		for (i = 0; i < slen; i ++) {
			if (s[i] != t[i]) {
				cnt ++;
			}
		}
		printf("%d\n", cnt);
	}
	return (0);
}


Measured memory_bytes: 2056
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<n; i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<vec.size(); i++) cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,k;
  cin>>a>>b>>c>>k;
 for(int i=0;i<k;i++){
 	if(b<=a) b=b*2;
    else if(c<=b) c=c*2;
    if(c>b&&b>a) {
      cout<<"Yes";
      return 0;
    }
 }  
  cout<<"No";
}

Measured memory_bytes: 3632