akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int main()
{
    ll n , m;
    cin >> n >> m;
    ll tot = 0;
    rep(i, m) {
        int a;
        cin >> a;
        tot += a;
        if(tot > n){
            cout << -1 << endl;return 0;
        }
    }
    cout << n-tot << endl;

    return 0;
}

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

int main() {
    vector<vector<int>> a(3,vector<int> (3,0));
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3) rep(k,3) if(a[j][k] == b) a[j][k] = 0;
    }
    bool ans = false;
    rep(i,3){
        if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0) ans=true;
        if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0) ans=true;
    }
    if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0) ans = true;
    if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0) ans = true;    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

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


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;


int main(void) {
	int num = 0;
	int b = 0, f = 0, r = 0, v = 0;
	int situation[4][3][10] = {0};

	CI num;

	for (int i = 0; i < num; ++i) {
		CI b >> f >> r >> v;
		situation[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 10; ++k) {
				CO  " " << situation[i][j][k];
			}
			CO  endl;
		}
		if (i == 3)break;
		CO "####################" E
	}
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int cnt[2]{};
    for(int i=0;i<n;i++){
        if(i%2 == 0){
            if(s[i] == '1') cnt[0]++;
            if(s[i] == '0') cnt[1]++;
        }
        else{
            if(s[i] == '0') cnt[0]++;
            if(s[i] == '1') cnt[1]++;
        }
    }
    cout << min(cnt[0], cnt[1]) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if ((b - a) == (c - b)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if((a-b)%2==0){
    cout<<(a+b)/2<<endl;
  }
  else if((b-a)%2==0){
    cout<<(a+b)/2<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Store:
    def __init__(self,a,b):
        self.a=a
        self.b=b

    def __eq__(self, other):
        return (self.b+1)*other.a==self.a*(other.b+1)

    def __lt__(self, other):
        return (self.b+1)*other.a<self.a*(other.b+1)

    def __le__(self, other):
        return (self.b+1)*other.a<=self.a*(other.b+1)

    def __gt__(self, other):
        return (self.b+1)*other.a>self.a*(other.b+1)

    def __ge__(self, other):
        return (self.b+1)*other.a>=self.a*(other.b+1)

from itertools import accumulate
from bisect import bisect
def main():
    inf=10**9+7
    n,t=MI()
    ab=LLI(n)
    ss=[]
    a0=[]
    for a,b in ab:
        if a==0:a0.append(b+1)
        else:ss.append(Store(a,b))
    n=len(ss)
    ss.sort()
    dp=[[inf]*31 for _ in range(n+1)]
    dp[0][0]=0
    for i,s in enumerate(ss):
        a,b=s.a,s.b
        for j in range(30):
            pre=dp[i][j]
            if pre==inf:continue
            nt=a*(pre+1)+b+pre+1
            if nt<=t:dp[i+1][j+1]=min(dp[i+1][j+1],nt)
            dp[i+1][j]=min(dp[i+1][j],pre)
    a0.sort()
    a0=[b for b in accumulate(a0)]
    ans=0
    for j in range(30):
        val=dp[n][j]
        if val==inf:continue
        ans=max(ans,bisect(a0,t-dp[n][j])+j)
    print(ans)

main()

Measured memory_bytes: 137428
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

def rem(a):
    l = set([])
    c = set([])
    for i in range(len(a)):
        if ''.join(a[i]) == '.'*len(a[i]):
            l.add(i)
    for j in range(len(a[0])):
        col = ''.join([a[i][j] for i in range(len(a))])
        if col == '.'*len(a):
            c.add(j)
    if len(l) == 0 and len(c) == 0:
        return a
    else:
        a_new = []
        for i in range(len(a)):
            if i in l: continue
            line = []
            for j in range(len(a[0])):
                if j in c: continue
                line.append(a[i][j])
            a_new.append(line)
        return rem(a_new)
ans = rem(a)
for line in range(len(ans)):
    print(''.join(ans[line]))

Measured memory_bytes: 39152
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ll x;
	cin>>x;
	ll sum=100;
	if(x==100)
	cout<<0;
	else
	{
	for(int i=1;;i++)
	{
		sum+=sum*0.01;
		if(sum>=x)
		{
				cout<<i;
				break;	
		}
	}
	}
}

Measured memory_bytes: 3636
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fastIO ios_base::sync_with_stdio(0)
#define nul point(0, 0)
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; for (int i = 0; i < number; i++) solve()
#define solve_system_scanf int number; scanf("%d", &number); for (int i = 0; i < number; i++) solve()

//permanent constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const ll prost = 239;
const int two = 2;
const int th = 3;
const ll MOD = 1e9 + 7;
const ll MOD2 = MOD * MOD;
const int BIG = 1e9 + 239;
const int alf = 26;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int bt = 31;
const int fr = 4;

//easy functions
template< typename T >
inline T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_down(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }
ll power(ll a, int k)
{
    if (k == 0) return 1;
    ll t = power(a, k >> 1);
    t = (t * t) % MOD;
    if (k & 1) t = (t * a) % MOD;
    return t;
}

//random
mt19937 rnd(239);

//constants
const int M = 2 * 1e5 + 239;
const int N = 2 * 1e3 + 239;
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 210;

int n, a[X];

int main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fastIO;
    cin >> n;
    for (int i = 0; i < 2 * n; i++)
        cin >> a[i];
    sort(a, a + (2 * n));
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2)
        ans += a[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long n[10000];
	long qty;
	long i;
	long max = -1000001;
	long min = 1000001;
	long sum = 0;
	
	scanf("%ld\n",&qty);
	
	for(i=0;i<qty;i++)
	{
		scanf("%ld",&n[i]);
	}
	
	for(i=0;i<qty;i++)
	{
		if(max <= n[i])
		{
			max = n[i];
		}
	}
	
	for(i=0;i<qty;i++)
	{
		if(min >= n[i])
		{
			min = n[i];
		}
	}
	
	for(i=0;i<qty;i++)
	{
		sum += n[i];
	}
	
	printf("%ld %ld %ld\n",min,max,sum);
	
	return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;

string S;
ll N, M, ans;
map<int, int> mp;
int main() {
	cin >> N >> M;

	int left = 1, right = N;
	FOR(i, 0, M) {
		int a, b;
		cin >> a >> b;
		if (a > left)left = a;
		if (b < right)right = b;
	}

	cout << max(0,right - left + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	int n, ans;
	vi c, v;
	cin >> n;
	getv(v, n);
	getv(c, n);
	for(int i = 0; i < n; i++)
		ans += max(0ll, v[i] - c[i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ymd := strings.Split(s, "/")
	y, _ := strconv.Atoi(ymd[0])
	m, _ := strconv.Atoi(ymd[1])
	d, _ := strconv.Atoi(ymd[2])
	if y <= 2019 && m <= 4 && d <= 30 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 640
from collections import Counter
ans = []
while 1:
    s = list(str(input()))
    S = "".join(s)
    if S[0] == ".":
        break
    flag = 0
    stack = []
    for i in range(len(S)):
        if S[i] == "(":
            stack.append(S[i])
        if S[i] == "[":
            stack.append(S[i])
        if S[i] == ")":
            stack.append(S[i])
        if S[i] == "]":
            stack.append(S[i])
    c = Counter(stack)
    if c["{"] != c["}"]:
        print("no")
        flag = 2
    elif c["("] != c[")"]:
        print("no")
        flag = 2
    elif c["["] != c["]"]:
        print("no")
        flag = 2

    m = len(stack)
    if flag == 0:
        while len(stack) > 0:
            if flag == 1:
                break
            if stack[0] == ")" or stack[0] == "]":
                print("no")
                flag = 1
                break
            for i in range(1, m):
                if stack[i] == ")":
                    if stack[i - 1] == "(":
                        stack.pop(i)
                        stack.pop(i - 1)
                        m = len(stack)
                        break
                    else:
                        print("no")
                        flag = 1
                        break
                if stack[i] == "]":
                    if stack[i - 1] == "[":
                        stack.pop(i)
                        stack.pop(i - 1)
                        m = len(stack)
                        break
                    else:
                        print("no")
                        flag = 1
                        break
            if flag == 1:
                break
        if flag == 0:
            print("yes")



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

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

    int total;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        int a = x * 2;
        int b = (k - x) * 2;
        a < b ? total += a : total += b;
    }

    cout << total << endl;
}

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

int main(void) {
    string s, t;
    cin >> s >> t;
    queue<char> sq, tq;
    for (int i = 0; i < (int)s.size(); i++) {
        sq.push(s.at(i));
        tq.push(t.at(i));
    }
    for (int i = 0; i < (int)s.size(); i++) {
        sq.push(sq.front());
        sq.pop();
        if (sq == tq) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = 1e3 + 1;
const int M = 2e5 + 1;
const ll inf = (ll)1e18;

bitset<N> can[N];
int Max[N][N], Min[N][N], lab[N][N];
int n, m, u, v;
vector<int> adj[N];
pii e[M];

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> u >> v, adj[u].pb(v);
        e[i] = mp(u, v);
    }
    for(int i = 1; i <= n; ++i) {
        can[i].set(i);
        function<void(int)> dfs = [&](int u) {
            for(int v: adj[u]) if(!can[i][v]) {
                can[i].set(v);
                dfs(v);
            }
        };
        dfs(i);
    }
    for(int i = 1; i <= n; ++i) {
        fill(Min[i], Min[i] + n + 1, n + n);
        fill(Max[i], Max[i] + n + 1, -1);
        Min[i][i] = -1, Max[i][i] = n + n;
        for(int j = 0; j < sz(adj[i]); ++j) {
            function<void(int)> dfs = [&](int u) {
                if(Min[i][u] != n + n) return;
                Min[i][u] = min(Min[i][u], j);
                for(int v: adj[u])
                    if(Min[i][v] == n + n) dfs(v);
            };
            dfs(adj[i][j]); lab[i][adj[i][j]] = j;
        }
        for(int j = sz(adj[i]) - 1; j >= 0; --j) {
            function<void(int)> dfs = [&](int u) {
                if(Max[i][u] != -1) return;
                Max[i][u] = max(Max[i][u], j);
                for(int v: adj[u])
                    if(Max[i][v] == -1) dfs(v);
            };
            dfs(adj[i][j]);
        }
    }
    bool ans, res;
    for(int i = 1; i <= m; ++i) {
        tie(u, v) = e[i];
        ans = can[v][u];
        res = (Min[u][v] != lab[u][v]) | (Max[u][v] != lab[u][v]);
        if(ans == res) cout << "same\n";
        else cout << "diff\n";
    }
}


Measured memory_bytes: 16256
N, = list(map(int,input().split()))
a  = list(map(int,input().split()))
s = set()
c6=0
for ai in a:
    if ai>=3200:
        c6 += 1
    else:
        s |= set({ai//400})
print(max(1,len(s)),len(s)+c6)

Measured memory_bytes: 9136
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
  string s;
  cin>>s;
  int zeros=0,ones=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'){zeros++;}
    else{ones++;}
  }
  cout<<2*min(ones,zeros)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main (void)

{
	int S,s,m,h;
	scanf("%d",&S);
	h=S/3600;
	m=(S%3600)/60;
	s=(S%3600)%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2104
import java.util.*;
public class Main {
    public static void main(String[] args){
//        Scanner sc = new Scanner(System.in);
//        // 整数の入力
//        int a = sc.nextInt();
//        // スペース区切りの整数の入力
//        int b = sc.nextInt();
//        int c = sc.nextInt();
//        // 文字列の入力
//        String s = sc.next();
//        // 出力
//        System.out.println((a+b+c) + " " + s);

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        if((a*b)%2==0) {
            // 出力
            System.out.println("Even");
        } else {
            System.out.println("Odd");;
        }
    }
}


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

int main()
{
  while (true)
  {
    int m, n;
    cin >> m;
    if ( m == 0 ) break;
    cin >> n;
    
    int count = 0;
    for (int i=m; i<=n; i++)
    {
      int num = i;
      while ( num % 2 == 0 )
      {
        num /= 2;
      }
      while ( num % 3 == 0 )
      {
        num /= 3;
      }
      while ( num % 5 == 0 )
      {
        num /= 5;
      }
      if ( num == 1 )
      {
        count++;
      }
    }
    cout << count << endl;
  }
}

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



int main() 
{
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    rep(i,n)
    {
        cin >> x[i] >> y[i];
    }

    map<int , vector<int>> mp;
    vector<int> v(n);
    rep(i, n) v[i] = i + 1;
    int cnt = 0;
    do
    {
        mp[cnt] = v;
        cnt += 1;
    } while (next_permutation(v.begin(), v.end()));

    double ans = 0;
    for(auto i:mp)
    {
        vector<int> aa = i.second;
        for (int j = 0; j < n-1; j++)
        {
            ans += pow((x[aa[j]-1] - x[aa[j+1]-1]) * (x[aa[j]-1] - x[aa[j+1]-1]) + (y[aa[j]-1] - y[aa[j+1]-1]) *(y[aa[j]-1] - y[aa[j+1]-1]), 0.5);
        }
    }

    printf("%lf\n", ans / mp.size());

    return 0;
}

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

int main(void){

	int X;
	int i;
	int j;
	int p;
	int L[1000];

	/*printf("!1\n");*/

	for (i=0;i<1000;i++){
		L[i] = 0;
	}

	for (i=1;i<=100;i++){
		for (j=2;j<=10;j++){
			p = (int)pow((double)i,(double)j);

			if (p>1000) break;

			L[p] = 1;
			/*printf("!1\n");*/
		}
	}

	/*printf("!1\n");*/
	/*

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

	*/

	scanf("%d",&X);
	/*scanfの中に\nを入れてはいけないらしい*/

	while(L[X] == 0){
		X -= 1;
		/*printf("%d",X);*/
	}

	printf("%d\n",X);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;

/**
 * Created by Ayushi on 20 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int a = n;
        int ans = -1;
        for(int i = 1; true; i++) {
            if (a % 360 == 0) {
                ans = i;
                break;
            }
            else {
                a += n;
            }
        }
        System.out.println(ans);
        br.close();
    }
}


Measured memory_bytes: 32444
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define mod 1000000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	int a,b,c;
    cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

		
			



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
const int limit = 1e7 + 1;
const int inf = 1e7;
vector<int> v[limit];
int m[limit];
bool vis[limit];
int dp(int root)
{
    if (vis[root])
    {
        return m[root];
    }

    int ans = 0;
    for (int i = 0; i < v[root].size(); i++)
    {
        ans = max(ans, dp(v[root][i]));
    }
    if(v[root].size()){
        ans++;
    }
    m[root] = ans;
    vis[root] = true;
    return m[root];
}
int main()
{
    int nodes, edges, x, y;
    cin >> nodes >> edges;
    for (int i = 0; i < edges; i++)
    {
        cin >> x >> y;
        v[x].push_back(y);
    }

    for (int i = 1; i <= nodes; i++)
    {
        m[i] = dp(i);
    }
    
        cout<<*(max_element(m+1, m+nodes+1));
    return 0;
}

Measured memory_bytes: 243712
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
ll a[40], b[40], c[40];
ll dp[41][401][401];

int main(void) {
    ll N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    ll i;
    ll suma=0, sumb=0;
    ll ca, cb;
    
    for(i=0; i<N; i++) {
        cin >> a[i] >> b[i] >> c[i];
        suma+=a[i];
        sumb+=b[i];
    }
    
    for(i=0; i<=N; i++) {
        for(ca=0; ca<=suma; ca++) {
            for(cb=0; cb<=sumb; cb++) {
                dp[i][ca][cb]=INF;
            }
        }
    }
    
    dp[0][0][0]=0;
    
    for(i=0; i<N; i++) {
        for(ca=0; ca<=suma; ca++) {
            for(cb=0; cb<=sumb; cb++) {
                if(dp[i][ca][cb]==INF) continue;
                dp[i+1][ca][cb]=min(dp[i+1][ca][cb], dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i]);
            }
        }
    }
    
    ll ans=INF;
    for(ca=1; ca<=suma; ca++) {
        for(cb=1; cb<=sumb; cb++) {
            if(Ma*cb==Mb*ca)
                ans=min(ans, dp[N][ca][cb]);
        }
    }
    
    if(ans==INF) prin(-1);
    else prin(ans);
    
}

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

int main()
{
    int n; cin >> n;
    vector<int> x(n), l(n);
    rep(i,n) cin >> x[i] >> l[i];
    P ps[n];

    rep(i,n) {
        ps[i] = pair<int, int>(x[i] + l[i], x[i] - l[i]);
    }

    sort(ps, ps + n); // pairの左部分をsortしている

    int ans = 0;
    int a = ps[0].first;

    for (int i = 1; i < n; i++) {
        if (a <= ps[i].second) {
            ans++;
            a = ps[i].first;
        }
    }

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int t[5];
char ca[20];

int main(){
	LL n;
	LL i,j,k;
	LL s=0;
	int a,b,c;
	cin>>n;
	for(i=1;i*i<n;i++){
		if(n%i!=0)continue;
		if(i<n/i-1)s+=n/i-1;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
int a[500],i=0,n,b=1,c=1,code,aa=0;

while(1){
	
	scanf("%d %d",&b,&c);
	if (getchar() == EOF)break;
	a[i]=b+c;
	aa++;
	i++;
	
}

for(i=0;i<aa;i++){
	n=0;
	while(1){
		a[i]=a[i]/10;
		n++;
		if(a[i]<1)break;
		
	}
	printf("%d\n",n);
}
    return 0;
}

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

vector<string> bin;
void generateAllBinaryStrings(int n, int arr[], int i)
{ 
    string s = "";
	if (i == n) {
        for (int i = 0; i < n; i++) 
            s+=to_string(arr[i]); 
        bin.push_back(s);
		return;  
	} 
	arr[i] = 0; 
	generateAllBinaryStrings(n, arr, i + 1); 
	arr[i] = 1; 
	generateAllBinaryStrings(n, arr, i + 1); 
}

int compter(string s)
{
    int res = 0;
    for (int i=0; i<s.size(); i++)
        if (s[i] == '1') res++;
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> v(n);
    for (int i=0; i<n; i++)
    {
        int a;
        cin >> a;
        for (int j=0; j<a; j++)
        {
            int x,y;
            cin >> x >> y;
            v[i].push_back(make_pair(x,y));
        }
    }
    int N = n; 
    int arr[N];
    generateAllBinaryStrings(N, arr, 0);
    int ans = 0;
    for (int i=0; i<bin.size(); i++)
    {
        bool z = true;
        for (int j=0; j<bin[i].size(); j++)
        {
            for (int k=0; k<v[j].size(); k++)
            {
                int curr_person = j;
                int curr_person_state = bin[i][j] - '0';
                int other = v[j][k].first;
                int other_state = v[j][k].second;
                int curr_other_state = bin[i][other-1] - '0';
                if (curr_person_state && curr_other_state != other_state)
                    {
                        z = false;
                        break;
                    }   
            }
        }
        if (!z) continue;
        ans = max(ans, compter(bin[i]));
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int main()
{

    int a,b;

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

    if(a>12)
    {
        printf("%d\n",b);
    }
    else if(a>=6 && a<=12)
    {
        printf("%d\n", b/2);
    }

    else if(a<6)
    {
        printf("0\n");
    }









    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		sc.close();

		if(a <= x && x <= a+b) System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 23764
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int tot = 0;
		for(int i = 0; i < n; i++) {
			tot += sc.nextInt();
		}
		System.out.println(tot >= h ? "Yes":"No");
	}
	
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


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

using namespace std;

const int MOD = 1e9+7; 

vector<int> total[5005];

int solve(int k, int l) {
	if(k == 0) {
		if(l == 0) return 1;
		return 0;
	}
	if(total[k][l] != -1) return total[k][l]; 
	
	int curr = (solve(k-1, ((l > 0) ? (l-1) : l))+((2*solve(k-1, l+1)) % MOD)) % MOD;
	total[k][l] = curr;
	return curr;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, len;
	string s;
	
	cin >> n >> s;
	len = s.length();
	for(int i = 0; i <= n; i++) total[i].assign(len+n+1, -1);
	
	cout << solve(n, len);
} 

Measured memory_bytes: 196096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	int before_min = arr[0];
	int ret = 0;
	for(int i=0; i<n; i++){
		before_min = min(before_min,arr[i]);
		if(before_min>=arr[i]) ret++;
	}
	cout<<ret;
}

Measured memory_bytes: 3992
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int type[200005]={0};
vector<int> node[200005];
int acnt[200005]={0},bcnt[200005]={0};
bool used[200005];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    used[i]=false;
    char c;
    cin>>c;
    type[i]=(c=='A'?0:1);
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<node[i].size();j++){
      int con=node[i][j];
      if(type[con]==0) acnt[i]++;
      else bcnt[i]++;
    }
  }
  queue<int> que;
  int sz=n;
  for(int i=1;i<=n;i++){
    if((acnt[i]==0||bcnt[i]==0)&&!used[i]) {
      que.push(i);
      used[i]=true;
      sz--;
    }
  }
  while(!que.empty()){
    int pos=que.front();
    que.pop();
    for(int i=0;i<node[pos].size();i++){
      int con=node[pos][i];
      if(type[pos]==0) acnt[con]--;
      else bcnt[con]--;
      if((acnt[con]==0||bcnt[con]==0)&&!used[con]){
        que.push(con);
        used[con]=true;
        sz--;
      }
    }
  }
  cout<<(sz>0?"Yes":"No")<<endl;
}


Measured memory_bytes: 13184
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd_n(numbers):
    return reduce(gcd, numbers)


def main():
    N, *A = map(int, open(0).read().split())
    print(gcd_n(A))
    return


main()


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define in insert
#define mp(a, b) make_pair(a, b)
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n, m, x;
	cin>>n>>m>>x;
	vi c(n);
	int a[n][m];
	int min_cost = INF;
	forn(i, n){ cin>>c[i]; forn(j, m) cin>>a[i][j]; }
	forn(i, 1<<n){
		vi curr(m, 0); int cost = 0;
		forn(j, n){
			if(i>>j&1){
				cost += c[j];
				forn(k, m)
					curr[k] += a[j][k];
			}
		}
		bool isValid = true;
		forn(j, m)
			isValid = isValid && (curr[j]>=x);
		if(isValid)
			min_cost = min(min_cost, cost);
	}
	if(min_cost==INF)
		cout<<-1<<endl;
	else
		cout<<min_cost<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  ll sum = 0;
  rep (i, n) {
    sum += a[i];
  }
  ll snuke = 0;
  ll arai;
  ll ans = LLONG_MAX;
  FOR (i, 0, n-1) {
    snuke += a[i];
    arai = sum - snuke;
    ll diff = max(snuke, arai) - min(snuke, arai);
    ans = min(ans, diff);
  }
  printf("%lld\n", ans);
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

const ll MOD = 1e9 + 7;

void solve(){
	ll n, k;
	cin >> n>> k;
	vector< ll > arr(n);
	vector< ll > pos;
	vector< ll > neg;
	ll zero = 0;
	for( ll i =0; i < n; i++){
		cin >> arr[i];
		if(arr[i] > 0) pos.push_back(arr[i]);
		else if(arr[i] < 0) neg.push_back(abs(arr[i]));
		else zero++;
		arr[i]=abs(arr[i]);
	}
	ll szp = (ll)pos.size();
	ll szn = (ll)neg.size();
	sort(pos.begin(), pos.end(),greater<int>());
	sort(neg.begin(), neg.end(),greater<int>());
	ll ans = 1;
	if(szp + szn/2*2 >= k && (k%2 == 0 || szp > 0)){
		ll p_idx = 0;
		ll n_idx = 0;
		if(k  & 1){
			ans = pos[0];
			p_idx++;
			k--;
		}
		while(k){

			ll val1 = (szp - p_idx >= 2 ? pos[p_idx] * pos[p_idx + 1] : 0);
			ll val2 = (szn - n_idx >= 2 ? neg[n_idx] * neg[n_idx + 1] : 0);

			if(val1 >= val2){
				ans = (ans * (val1%MOD)) % MOD;
				p_idx += 2;
			}
			else{
				ans = (ans * (val2%MOD)) % MOD;
				n_idx += 2;
			}
			k-=2;	
		}
	}
	else if(zero > 0){
		ans = 0;
	}
	else{
		sort(arr.begin(), arr.end());
		for(int i = 0; i < k; i++){
			ans = (ans * arr[i]) % MOD;
		}
		ans = (MOD - ans) % MOD;
	}
	cout << ans % MOD << "\n";
	return ;
}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t = 1;

	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 6932
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin>>N;
    vector<double> v(N);

    for(int i=0; i<N; i++){
        cin>>v[i];
    }

    sort(v.begin(),v.end());
    double answer=v[0];

    for(int i=1; i<N; i++){
        answer=(answer+v[i])/2;
    }

    cout<<answer<<endl;

    return 0;
}

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

const long long MOD = 1000000007;
int main() {
    long long a, b, x;
    cin >> a >> b >> x;

    long long N = max(0LL, (x - b) / (a - b));
    x %= MOD;
    N %= MOD;
    b %= MOD;
    cout << (x + N * b) % MOD << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> L(N), R(N);
    REP(i, N) cin >> L[i];
    REP(i, N) R[i] = -L[i];
    sort(L.begin(), L.end());
    sort(R.begin(), R.end());
    int ans = 0;
    for (int i = 0; i < N - 2; ++i){
        int a = L[i];
        for (int j = i + 1; j < N - 1; ++j){
            // cout << "j=" << j << endl;
            int b = L[j];
            int min = abs(a-b);
            int max = - (a + b);
            auto Itermin = upper_bound(L.begin() + j + 1, L.end(), min);
            auto Itermax = upper_bound(R.begin(), R.end() - j - 1, max);
            int indmin = Itermin - L.begin();
            int indmax = N - 1 - (Itermax - R.begin());
            // cout << "indmin:" << indmin << endl;
            // cout << "indmax:" << indmax << endl;
            if (indmax - indmin + 1 < 0){
                continue;
            } else{
                ans += indmax - indmin + 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n, m, k; cin >> n >> m >> k;
    int a[n], b[m];
    sca(a, n); sca(b, m);
    int ai = 0;
    while (ai != n && a[ai] <= k) {
        k -= a[ai];
        ai++;
    }
    int bi = 0;
    while (bi != m && b[bi] <= k) {
        k -= b[bi];
        bi++;
    }
    int ans = ai+bi;
    bool bEnd = 0;
    for (int ain = ai-1; ain >= 0; ain--) {
        k += a[ain];
        if (bi == m) break;
        while (bi != m && b[bi] <= k) {
            k -= b[bi];
            bi++;
        }
        ans = max(ans, ain+bi);
    }
    cout << ans;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5112
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int c = 1;
	string str;
	cin>>str;
	for(int i = 0;i<3;i++)
	{
		if(str[i] == str[i+1])
		{
			c++;
			if(c==3)
			{
				cout<<"Yes";
				return 0;
			}
		}
		else if(i > 0)
		{
			cout<<"No";
			return 0;
		}
		
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);


    System.out.println((N+K-1)/K);
  }
}

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

int main() {
    
    int X;
    cin >> X;
    string ans;
    if(X == 7 || X == 5 || X == 3){
        ans = "YES";
    }else{
        ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
L = []
for i in range(min(x, k)):
  for j in range(min(y, k//(i+1))):
    for l in range(min(z, k//(i+1)//(j+1))):
      L.append(A[i]+B[j]+C[l])
print(*sorted(L)[::-1][:k], sep="\n")

Measured memory_bytes: 9996
N, Y = list(map(int,input().split()))
flag = 0
for i in range(N+1):
  for j in range(N+1-i):
    total = 10000 * i + 5000 * j + 1000 * (N-i-j)
    if Y == total:
      I = i
      J = j
      K = N - i - j
      flag += 1

if flag == 0:
  print(-1,-1,-1)
else:
  print(I,J,K)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int x,k;
    cin >> k >> x;
    for(int i=x-k+1;i<x+k;i++){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
M=99;main(n,i,j,k,a,b,c){
	float p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
		for(a=i=0;i<n;a=a>b?a:b,i++)for(b=k=0;k<M;b=b>c?b:c,k++)for(x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M),c=1,j=i+1;j<n;j++)
			if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-3)c++;
	}
exit(0);}

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

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

	int k ;cin >> k;
	int a,b; cin >> a >> b;
	if(a<b)swap(a,b);
	int t = (a/k)-((b-1)/k);
	if(t) cout << "OK";
	else cout << "NG";
	
	

}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
#define double long double
using namespace std; const int N=1000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int book[N];
signed main()
{
    int K=read(); int res=0;
    for(ri int i=1;;i++)
    {
        res=(res*10+7)%K;
        if(!res) { printf("%lld\n",i); break; }
        if(book[res]) { puts("-1"); break; }
        book[res]=1;
    }
    return 0;
}

Measured memory_bytes: 11576