akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mll map<long long,long long>
#define qi queue<int>
#define pb push_back
#define mod %
#define pow ^
#define pnode struct node
#define pair_int pair<int,int>
#define pair_ll pair<long,long>
#define pq priority_queue

#define N 100001

ll c[401][401];
ll sum[401];

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

   int n;
   cin >> n;
   ll a[n+1];

   for(int i=1;i<=n;i++)
      cin >> a[i];
   
   for(int i=1;i<=n;i++)
      sum[i]=sum[i-1]+a[i];

   for(int l = 2;l<=n;l++)
   {
      for(int i=1;i+l-1<=n;i++)
      {
         ll val = (ll)1e18;
         for(int j=i;j<i+l-1;j++)
         {
            ll tmp = 0;
            int len = j-i+1;
            tmp+=c[i][len];
            tmp+=c[j+1][l-len];
            tmp+=sum[i+l-1] - sum[i-1];
            val = min(val, tmp);
         }
         c[i][l] = val;
      }
   }
   cout << c[1][n] << "\n";
   return 0;
}


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


#include<bits/stdc++.h>

using namespace std;

#include <iostream>


#define ll   long long

void __print(int x) { cout << x; }

void __print(long x) { cout << x; }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cout << '{';
    __print(x.first);
    cout << ',';
    __print(x.second);
    cout << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cout << '{';
    for (auto &i: x) cout << (f++ ? "," : ""), __print(i);
    cout << "}";
}

void _print() { cout << "]\n"; }

template<typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cout << ", ";
    _print(v...);
}


#ifdef LOCAL
#else
#define dbg(x...)
#endif


class CAXBC {
public:

    void solve2(std::istream &cin, std::ostream &cout) {
        ll ans = 0, n;
        cin >> n;
        for (ll i = 1; i <= n; i++)
            if (n % i)
                ans += n / i;
            else
                ans += (n - 1) / i;

        cout << ans;
    }

    void solve(std::istream &cin, std::ostream &cout) {
        ll t = 1;
//            cin >> t;
        while (t--) {
            solve2(cin, cout);
        }
    }

};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    CAXBC solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
  int i;
  int num = 0;
  int counter = 0;
  int ok_counter = 0;
  cin >> num;
  int numbers[num];
  
  /* 取り込み */
  for(i=0; i<num; i++){
    cin >> numbers[i];
  }
  
  for(i=0; i<num-2; i++){
    counter = 0;
    if(numbers[i+1] < numbers[i]) counter++;
    if(numbers[i+1] < numbers[i+2]) counter++;
    if(counter == 1) ok_counter ++;
  }
  cout << ok_counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    string s;
    cin >> s;
    int tot = 0;
    for(auto it:s){
    	tot += it - '0';
    }
    if(tot % 9 == 0){
    	show("Yes");
    }
    else{
    	show("No");
    }
    return 0;
}

Measured memory_bytes: 3776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_170
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            List<int>[] dividers = new List<int>[n];
            int[] all = new int[1500000];
            for (int i = 0; i < n; i++)
            {
                dividers[i] = new List<int>();
                for (int j = 1; j * j <= array[i]; j++)
                {
                    if (array[i] % j == 0)
                    {
                        dividers[i].Add(j);
                        if (array[i] / j != j)
                        {
                            dividers[i].Add(array[i] / j);
                        }
                    }
                }
                all[array[i]]++;
            }

            int res = 0;
            for(int i = 0; i < n; i++)
            {
                bool ok = true;
                for(int j = 0; j < dividers[i].Count; j++)
                {
                    if (dividers[i][j] == array[i])
                    {
                        if (all[dividers[i][j]] > 1)
                        {
                            ok = false;
                            break;
                        }
                    }
                    else
                    {
                        if (all[dividers[i][j]] > 0)
                        {
                            ok = false;
                            break;
                        }
                    }
                }
                if (ok)
                {
                    res++;
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    int max_a = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        A[i] = a;
        max_a = max(max_a, a);
    }

    int mid_a = 0, min_diff = 1000000000;
    for (int i = 0; i < n; i++) {
        int diff = abs(A[i] - max_a / 2);
        if (diff < min_diff && A[i] != max_a) {
            mid_a = A[i];
            min_diff = diff;
        }
    }

    cout << max_a << " " << mid_a << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    cout << a[n / 2] - a[n / 2 - 1] << endl;
}


Measured memory_bytes: 640
#include <iostream>

int memo[7][7] = {-1};
int x[3][5] = {{1,2,6,5,1}, {1,3,6,4,1}, {2,3,5,4,2}};
int sides[3][2] = {{4, 3}, {2, 5}, {6, 1}};


int detect_right_side_index(int *dice, int top, int front) {
  int top_index, front_index;
  bool top_flag = false, front_flag = false;

  for (int i = 1; i <= 6; i ++) {
    if (!top_flag && dice[i] == top) top_index = i, top_flag = true;
    if (!front_flag && dice[i] == front) front_index = i, front_flag = true;
  }
  return memo[top_index][front_index];
}


int main() {
  int dice[7];
  int top, front, q;
  char command;

  for (int j = 0; j < 3; j ++) {
    for (int i = 1; i < 5; i ++) {

      memo[x[j][i]][x[j][i-1]] = sides[j][0]; 
      memo[x[j][i-1]][x[j][i]] = sides[j][1]; 
    }
  }
  for (int i = 1; i < 7; i ++) 
    std::cin >> dice[i];
  std::cin >> q;
  for (int i = 0; i < q; i ++) {
    std::cin >> top >> front;
    std::cout << dice[detect_right_side_index(dice, top, front)] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )


typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;


// Order Statistic Tree

/* Special functions:

        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

typedef tree<
PII,
null_type,
less<PII>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

/*end of header*/


int main()
{
    //freopen("input_file_name.in","r",stdin);
    //freopen("output_file_name.out","w",stdout);
    LL n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    if(a>b)swap(a,b);

    REPL(i,0,n-1)
    {
        LL tp=a+d*i-c*(n-1-i);
        if(tp<b)continue;
        if(tp-b<=(n-1)*(d-c))
        {
            print("YES");
            return 0;
        }
    }
    print("NO");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,inp,ans[200001];

int main(){
    cin >> N;
    for(int i=2;i<N+1;i++){
        cin >> inp;
        ans[inp]++;
    }
    for(int i=1;i<N+1;i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4360
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
mat g;

lli u,k,v;

queue<lli> q;
queue<lli> d;
vbl vis;
vll ans;


int main(){
    cin >> n;
    g = mat(n+1);
    vis = vbl(n+1);
    ans = vll(n+1,-1);
    for(lli i = 0;i < n;i++){
        cin >> u >> k;
        for(lli j = 0;j < k;j++){
            cin >> v;
            g[u].push_back(v);
        }
    }
    q.push(1);
    d.push(0);
    while(!q.empty()){
        lli p = q.front();
        lli r = d.front();
        q.pop();
        d.pop();
        if(vis[p]) continue;
        vis[p] = true;
        ans[p] = r;
        for(lli i = 0;i < g[p].size();i++){
            if(!vis[g[p][i]]) q.push(g[p][i]),d.push(r+1);
        }
    }
    for(lli i = 1;i <= n;i++) cout << i << " " << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3164
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    R = list(accumulate(A))
    res = 0
    for i in range(n):
        res += (A[i] * (R[-1] - R[i])) % mod
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31424
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, x;
    cin >> n >> x;
    vi a(n);
    rep(i,n) cin >> a[i];
    int ans = 0; 
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++) {
        x -= a[i];
        if(x < 0) {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
    if(x != 0) ans--;
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

ll solve() {
	ll n, f = 5, ans = 0;
	cin >> n;
	if(n % 2 != 0)
		return 0;
	else
	{		
		while(f <= n){
			ans += (n/f) / 2;
			f *= 5;
		}
		return ans;
	}	
}

int main() {
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string AC , WA, TLE, RE;
    string x;
    int n;
    cin>>n;
    int cnt1=0;
    int cnt2=0;
    int cnt3=0;
    int cnt4=0;
    for (int i = 0; i <n ; ++i) {
        cin>>x;
        if(x== "AC"){++cnt1;}
        if(x== "WA"){++cnt2;}
        if(x== "TLE"){++cnt3;}
        if(x== "RE"){++cnt4;}
    }
    cout<<"AC"<<" "<<"x"<<" "<<cnt1<<endl;
    cout<<"WA"<<" "<<"x"<<" "<< cnt2<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<< cnt3<<endl;
    cout<<"RE"<<" "<<"x"<<" "<< cnt4<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,c,q,d=0;
	map<long long int, long long int>m;
	cin>>n;
	for(i=2;i*i<n;i++){
		c=0;
		while(n%i==0){
			c++;
			n=n/i;
		}
		m[i]=c;
		if(c>0){
			q=2*m[i];
			d+=(-1+pow((1+4*q),0.5))/2;
		}
	}
	if(n!=1)
	{
		m[n]=1;
		d++;	
	}
	cout<<d;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int m = 100000;
  for (int i = 0; i < n; i++){
    int k;
    scanf("%d", &k);
    int count = 0;
    while (true){
      if (k % 2 == 0){
        count++;
        k /= 2;
      } else break;
    }
    m = min(m, count);
  }
  cout << m << "\n";
  return 0;
}

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

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

int gcd(int a, int b) {
  return ((b == 0) ? a : gcd (b, a % b));
}

int gcd(int a, int b, int c) {
  return gcd(gcd(a, b), c);
}

vector<int> divisors(int n) {
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      ans.push_back(i);
    }
  }
  return ans;
}

int main() {
  int n, g;
  cin >> n;
  if (n == 2) {
    int a, b;
    cin >> a >> b;
    g = gcd(a, b);
  } else {
    int a, b, c;
    cin >> a >> b >> c;
    g = gcd(a, b, c);
  }
  vector<int> gs = divisors(g);
  REP(i, gs.size()) {
    cout << gs[i] << endl;
  }
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n,k;
	static ll a[100010];
	scanf("%d%d",&n,&k);
	rep1(i,n)scanf("%lld",&a[i]);
	
	static ll sum = 0, ret = 1000000000000000000;
	static ll s[100010],t[100010];
	s[0] = 0; t[0] = 0;
	rep1(i,n){
		sum += max( (ll)0 , a[i] );
		s[i] = s[i-1] + max( (ll)0 , a[i] );
		if(i > k)s[i] -= max( (ll)0 , a[i-k] );
		t[i] = t[i-1] - min( (ll)0 , a[i] );
		if(i > k)t[i] += min( (ll)0 , a[i-k] );
	}
	for(int i = k ; i <= n ; i ++){
		ret = min( ret , min( s[i] , t[i] ) );
	}
	cout << sum-ret << endl;
}


Measured memory_bytes: 2560
S = input().strip()

ans = [""]
prev = ""
for i, s in enumerate(S):
    prev += s
    if ans[-1] != prev:
        ans.append(prev)
        prev = ""
    else:
        if i == len(S) - 1:
            ans.append(prev)

result = len(ans) - 1
if ans[-1] == ans[-2]:
    result -= 1

print(result)




Measured memory_bytes: 8068
#include <iostream>
#include <algorithm>
int main(void)
{
	int n, s[300000];
	long sum = 0;
	std::cin >> n;
	for(int i = 0; i < 3 * n; i++) std::cin >> s[i];
	std::sort(s, s + 3 * n, std::greater<int>());
	for(int i = 0; i < n; i++) sum += s[i * 2 + 1];
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  if(n*a > b){
    printf("%d\n",b);
  }else{
    printf("%d\n",n*a);
  }
  
  return 0;
}


Measured memory_bytes: 128
A = input()
B = input()
C = input()
X = input()

c = 0
for i in range(A + 1):
	for j in range(B + 1):
		for k in range(C + 1):
			if 500 * i + 100 * j + 50 * k == X:
				c += 1
print c


Measured memory_bytes: 2568
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		int x = in.nextInt(), ans = 0;
		int cur = 0;
		
		while (true) {
			++ans;
			cur += ans;
			if (cur >= x)
				break;
		}
		
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 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());
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int en = 0, add = 0;
    rep(i, n){
        en += b[a[i] - 1];
        if(add != 0 && a[i - 1] + 1 == a[i]){
            en += add;
        }
        if(a[i] - 1 != n - 1){
            add = c[a[i] - 1];
        }
    }
    cout <<  en << endl;;
    return 0;
}

Measured memory_bytes: 256
x=int(input())
if x<=11:
    if x<=6:
        print(1)
    else:
        print(2)
else:
    if x%11==0:
        print(2*(x//11))
    elif x-11*(x//11)<=6:
        print(2*(x//11)+1)
    else:
        print(2*(x//11)+2)

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

using namespace std;

int f[400001];
int n;
void add(int x) {
	for (; x <= 3 * n; x += (x & -x)) f[x] ++;
}

int query(int x) {
	int sum = 0;
	for (; x; x -= (x & -x)) sum += f[x];
	return sum;
}

int sum[400001], e[400001], c[400001];
int a[400001], b[400001];
bool check(int x) {
	for (int i = 1; i <= n; i ++) {
		if (a[i] >= x) c[i] = 1;
		else c[i] = 0;
		sum[i] = sum[i - 1] + c[i];
		e[i] = 2 * sum[i] - i;
	}
	long long ans = 0;
	for (int i = 1; i <= 3 * n; i ++) f[i] = 0;
	for (int i = 1; i <= n; i ++) {
		add(e[i - 1] + n + 1);
		ans += query(e[i] + n + 1);
	}
	return 2 * ans >= 1LL * n * (n + 1) / 2;
}

int main( ) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + 1 + n);
	int m = (int )(unique(b + 1, b + 1 + n) - b) - 1;
	int l = 1, r = m;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(b[mid])) l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", b[r]);
	return 0;
}


Measured memory_bytes: 7936
n,m=map(int,input().split())
l=[]
for _ in range(n):
    x,y=map(int,input().split())
    l.append([x,y])
l.sort(key=lambda x:x[0])
cnt=0
cost=0
for i in range(n):
    if cnt+l[i][1]>=m:
        diff=m-cnt
        cost+=diff*l[i][0]
        cnt+=diff
        break
    else:
        cnt+=l[i][1]
        cost+=l[i][0]*l[i][1]
print(cost)



Measured memory_bytes: 21216
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = n[0] * 100 + n[1] * 10 + n[2];
        if (a % 4 == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

void DebugPrint(double a[], int n)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, n); ++i) {
		cout << a[i] << ",";
	}
	cout << endl;
#endif
}

long long int memo[3000][3000];
bool valid[3000][3000];

long long int Comp(int n, vector<int> &a, int head, int tail)
{
	if (valid[head][tail]) {
		return memo[head][tail];
	}

	if (head == tail) {
		return a[head];
	}
	long long int score1 = a[head] - Comp(n, a, head + 1, tail);
	long long int score2 = a[tail] - Comp(n, a, head, tail - 1);
	long long int max_score = max(score1, score2);
	//cout << head << " " << tail << " " << max_score << endl;

	memo[head][tail] = max_score;
	valid[head][tail] = true;

	return max_score;
}


int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	int n;
	cin >> n;

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

	int head = 0;
	int tail = n - 1;
	long long int score = Comp(n, a, head, tail);

	cout << score << endl;

	return 0;
}


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

int main(void){
int sec;
int h,m,s;
scanf("%d",&sec);

h=sec/pow(60,2);
m=(sec-(h*pow(60,2)))/60;
s=sec%60;

printf("%d:%d:%d\n",h,m,s);

return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  reverse(ALL(s));

  string t[4] = {"dream", "dreamer", "erase", "eraser"};
  REP(i, 4) reverse(ALL(t[i]));

  REP(i, s.size()){
    if(s.substr(i, 7) == t[1]) i += 6;
    else if(s.substr(i, 6) == t[3]) i += 5;
    else if(s.substr(i, 5) == t[0]) i += 4;
    else if(s.substr(i, 5) == t[2]) i += 4;
    else{
      NO;
      return 0;
    }
  }

  YES;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int a[100010];

int main(void){
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        a[x]=i;
    }
    for(int i=1;i<=n;i++){
        if(i==n)cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    return 0;
}

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

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	vector<int> d(n);

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

	sort(d.begin(), d.end());
	cout << d[n / 2] - d[n / 2 - 1] << endl;

	return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main{
    static String[] A,B;
    static int N,M;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        M = sc.nextInt();
        A = new String[N];
        B = new String[M];
        for(int i = 0; i < N; i++)
            A[i] = sc.next();
        for(int i = 0; i < M; i++)
            B[i] = sc.next();
        sc.close();

        for(int i = 0; i < N-M+1; i++){
            for(int j = 0; j < N-M+1; j++){
                if(include(i, j)){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }

    static boolean include(int x, int y){
       for(int i = 0; i < M; i++){
            for(int j = 0; j < M; j++){
                if(A[i+x].charAt(j+y) != B[i].charAt(j))
                    return false;
            }
       }
       return true;
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

class Comb{
    // テーブルを作るのに O(NlogN)
    // 計算は O(1)
    int N;
    vector<long long> fact_num, fact_den;
    long long bipow(long long n, long long m) {
        if (m == 0) return 1;
        if (m % 2 == 0) {
            n = (n * n) % MOD;
            return bipow(n, m / 2) % MOD;
        } else
            return (n * bipow(n, m - 1)) % MOD;
    }
    void set_table(){
        fact_num.resize(N+1, 0);
        fact_den.resize(N+1, 0);
        vector<long long> fact_denpow(N+1, 0);

        fact_num[0] = 1;
        for(int i=1; i<=N; i++) fact_num[i] = (fact_num[i-1] * i) % MOD;
        for(int i=0; i<=N; i++) fact_denpow[i] = bipow(i, MOD-2);
        fact_den[0] = 1;
        for(int i=1; i<=N; i++) fact_den[i] = (fact_den[i-1] * fact_denpow[i]) % MOD;
    }
public:
    Comb(int N): N(N) { set_table(); }
    // nCk
    long long calc(long long n, long long k){
        if(k > n) return 0;
        return ((fact_num[n] * fact_den[k]) % MOD * fact_den[n-k]) % MOD;
    }
};

long long bipow(long long n, long long m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

int main(){
    int K;
    string S;
    cin >> K >> S;
    int N = S.size();
    Comb comb(2222222);

    long long ans = 0;
    for(int i=0; i<=K; i++){
        long long tmp = comb.calc(N+K, i);
        tmp *= bipow(25, i);
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 56424
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n, a[100005]; 
int dp[100005]; 

int func(int ind) {
	if(ind==(n-1)) return 0; 
	if(ind>=n) return INT_MAX; 

	if(dp[ind]!=-1) return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + func(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + func(ind+2); 
	}

	return dp[ind] = min(left, right); 
}
signed main() {
	
	cin >> n;

	memset(dp, -1, sizeof dp); 
	
	for(int i = 0;i<n;i++) {
		cin >> a[i]; 
	}

	cout << func(0); 
}


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

int main() {
	int h, a;
	cin >> h >> a;
	int count = 0;
	while (1) {
		h -= a;
		count++;
		if (h <= 0)break;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
    int a,b,C;
    double rad;
    double c;
    double S,L,h;
    scanf("%d %d %d",&a,&b,&C);
    rad=C*3.14159265359/180;
     
    S=(a*b*sin(rad))/2;
    h=b*sin(rad);
    c=sqrt(a*a+b*b-2*a*b*cos(rad));
    L=a+b+c;
    printf("%lf\n",S);
    printf("%lf\n",L);
    printf("%lf\n",h); 
     
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int X, Y, S;

int f(int x){
    int64_t lb = 0, ub = x + 1;

    while(std::abs(ub - lb) > 1){
        int64_t mid = (lb + ub) / 2;

        if(mid * (100 + X) / 100 <= x){
            lb = mid;
        }else{
            ub = mid;
        }
    }

    if(lb * (100 + X) / 100 != x){
        return -10000;
    }
    return lb;
}

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

    while(true){
        std::cin >> X >> Y >> S;
        if(!X && !Y && !S){break;}

        int res = 0;
        for(int a=1;a<S;++a){
            int b = S - a;
            int a2 = f(a), b2 = f(b);
            // std::cout << a2 << ", " << b2 << std::endl;

            res = max(res, (a2 * (100 + Y) / 100) + (b2 * (100 + Y) / 100));
        }

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3104
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



char iremono[12001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N;
	scanf("%d ", &N);
	char* S = iremono + 4000;
	fread(S, 1, N, stdin);

	int R[4010], G[4010], B[4010];
	int r = 0, g = 0, b = 0;
	rep(i, N) {
		if (S[i] == 'R') R[r++] = i;
		if (S[i] == 'G') G[g++] = i;
		if (S[i] == 'B') B[b++] = i;
	}

	ll kotae = ll(r) * g * b;

	if (b >= g && b >= r) {
		for (auto i = R; i - R < r; i++) for (auto j = G; j - G < g; j++) {
			kotae -= (S[*i * 2 - *j] == 'B');
			kotae -= (S[*j * 2 - *i] == 'B');
			kotae -= (!(*i + *j & 1) && S[*i + *j >> 1] == 'B');
		}
	}
	else if (g >= r && g >= b) {
		for (auto i = R; i - R < r; i++) for (auto j = B; j - B < b; j++) {
			kotae -= (S[*i * 2 - *j] == 'G');
			kotae -= (S[*j * 2 - *i] == 'G');
			kotae -= (!(*i + *j & 1) && S[*i + *j >> 1] == 'G');
		}
	}
	else {
		for (auto i = G; i - G < g; i++) for (auto j = B; j - B < b; j++) {
			kotae -= (S[*i * 2 - *j] == 'R');
			kotae -= (S[*j * 2 - *i] == 'R');
			kotae -= (!(*i + *j & 1) && S[*i + *j >> 1] == 'R');
		}
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Srep(i,a,n) for(int i = (a); i < (n); i++)
#define ll long long
#define P pair<int, int>
using namespace std;

int main(){
  string n;
  cin >> n;
  rep(i,3){
    if(n.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main()
{
	ll N, x;
	cin >> N >> x;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<vector<ll>> dp(N, vector<ll>(N));
	for (int i = 0; i < N; i++) {
		dp[0][i] = a[i];
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = min(dp[i - 1][j], a[(i + j) % N]);
		}
	}
	ll res = INF;
	for (int i = 0; i < N; i++) {
		ll val = x * i;
		for (int j = 0; j < N; j++) {
			val += dp[i][j];
		}
		res = min(res, val);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 31616
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,f=0,mini=INF;
    ll sum=0,maxi=0;
    string str,sub;
    ll h,w;
    ll m,k,d;
    ll x;
    cin>>n;
    vector<ll> v(n);
    rep(i,n)cin>>v[i];
    sum=v[0];
    rep(i,n-1){
        if(v[i+1]>v[i]) sum+=v[i+1]-v[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const int MX = 3000;
Long memo[MX + 2][MX + 2][4];
Long A[MX + 2][MX + 2];
int n, m;
Long dp(Long i, Long j, Long cnt) {
  if (memo[i][j][cnt] != -1) return memo[i][j][cnt];
  Long &ans = memo[i][j][cnt] = 0;
  if (i + 1 < n) {
    ans = max(ans, dp(i + 1, j, 0));
    ans = max(ans, dp(i + 1, j, 1) + A[i + 1][j]);
  }
  if (j + 1 < m) {
    ans = max(ans, dp(i, j + 1, cnt));
    if (cnt < 3) {
      ans = max(ans, dp(i, j + 1, cnt + 1) + A[i][j + 1]);
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int k;
  cin >> n >> m >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    Long val;
    cin >> val;
    A[a][b] = val;
  }
  //fore(i, 0, n) fore(j, 0, m) cout << A[i][j] << (char)(j + 1 == m ? 10 : 32);
  memset(memo, -1, sizeof memo);
  cout << max(dp(0, 0, 0), dp(0, 0, 1) + A[0][0]) << '\n';

  return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, a[nsz + 5], l[nsz + 5], r[nsz + 5];
num ans;
int sz, s[nsz + 5];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    cont (i, n) {
        cin >> a[i];
    }
    cont (i, n) {
        int cur = a[i];
        for (; sz && a[s[sz]] >= cur; --sz);
        l[i] = s[sz] + 1;
        s[++sz] = i;
    }
    for (; sz; l[s[sz]] = s[sz - 1] + 1, --sz);
    s[0] = n + 1;
    sz = 0;
    for (int i = n; i >= 1; --i) {
        int cur = a[i];
        for (; sz && a[s[sz]] >= cur; --sz);
        r[i] = s[sz] - 1;
        s[++sz] = i;
    }
    for (; sz; r[s[sz]] = s[sz - 1] - 1, --sz);
    cont (i, n) {
        ans += (num) (i - l[i] + 1) * (r[i] - i + 1) * a[i];
    }
    cout << ans << ln;
}

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

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

int main(){
    ll K; cin >> K;
    ll ans = 0;
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            for (int k = 1; k <= K; k++)
            {
                ans += __gcd(__gcd(i,j), k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,D;

signed main(){
	cin>>N>>D;
	cout<<ceil2(N,D*2+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include<cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>

using namespace std;
const int mod=1000000007;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int t,n,m,k,q,d,x,l,a,b,c;
    cin>>a>>b>>c;
    if (a+b>c) {
        cout<<"No\n";
        return 0;
    }
    if (2*c*(a+b)<c*c+(a-b)*(a-b)) {
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
        
    return 0;
}


Measured memory_bytes: 256
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
int main(void){
    int n,x;
    scanf("%d%d",&n,&x);
    int i;
    if(x==1 || x==2*n-1) printf("No\n");
    else{
		printf("Yes\n");
		for(i=0;i<2*n-1;i++){
			int b=x-n+i;
			b=(b+2*n-1)%(2*n-1);
			b++;
			printf("%d\n",b);
		}
	}
    return 0;
}


Measured memory_bytes: 1536
N = int(input())
S = input()

dic = {"R":0, "G":0, "B":0}
for color in S:
    dic[color] += 1
count = dic["R"] * dic["G"] * dic["B"]

for step in range(1, (N - 1) // 2 + 1):
    for st in range(N - 2 * step):
        a, b, c = S[st], S[st + step], S[st + step * 2]
        if a != b and b != c and a != c:
            count -= 1
print(count)

Measured memory_bytes: 9212
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let h: usize = s.next().unwrap().parse().unwrap();
	let w: usize = s.next().unwrap().parse().unwrap();
	let k: i32 = s.next().unwrap().parse().unwrap();
	let sy = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let sx = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let gy = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let gx = s.next().unwrap().parse::<usize>().unwrap() - 1;
	let field: Vec<Vec<_>> = s.take(h).map(|s| s.chars().collect()).collect();

	let mut dist = vec![vec![[std::i32::MAX; 4]; w]; h];
	use std::cmp::Reverse;
	let mut q = std::collections::BinaryHeap::new();
	q.push((Reverse(0), sy, sx, 4));
	while let Some((Reverse(cost), y, x, d)) = q.pop() {
		if d != 4 && cost > dist[y][x][d] {
			continue;
		}
		for &(ny, nx, nd) in [
			(y, x + 1, 0),
			(y.wrapping_sub(1), x, 1),
			(y, x.wrapping_sub(1), 2),
			(y + 1, x, 3),
		]
		.iter()
		.filter(|&&(ny, nx, _)| (y, x) != (ny, nx) && ny < h && nx < w && field[ny][nx] == '.')
		{
			if d == nd {
				if cost + 1 < dist[ny][nx][nd] {
					dist[ny][nx][d] = cost + 1;
					q.push((Reverse(cost + 1), ny, nx, d));
				}
			} else {
				let nc = 1 + (cost + k - 1) / k * k;
				if nc < dist[ny][nx][nd] {
					dist[ny][nx][nd] = nc;
					q.push((Reverse(nc), ny, nx, nd));
				}
			}
		}
	}
	let ans = dist[gy][gx]
		.iter()
		.map(|&d| {
			if d == std::i32::MAX {
				std::i32::MAX
			} else {
				(d + k - 1) / k
			}
		})
		.min()
		.unwrap();
	if ans == std::i32::MAX {
		println!("-1");
	} else {
		println!("{}", ans);
	}
}


Measured memory_bytes: 31176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,L;
    cin >> N >> L;
    int sum = 0;
    rep(i,0,N)sum += i + L;
    int ans = 0, difmin = INF;
    rep(i,0,N){
        int num = sum - (i + L);
        if(abs(num - sum) < difmin){
            ans = num;
            difmin = abs(num - sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for( int &i : p ) cin >> i;
	sort( p.begin(), p.end(), greater<int>() );
	cout << accumulate( p.begin(), p.end(), 0 ) - p[0]/2 << endl;
	return 0;
}

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

int main()
{
	vector<int> data(6);
	cin >> data[0] >> data[1] >> data[2] >> data[3] >> data[4] >> data[5];

	if (data[4] - data[0] <= data[5])
	{
		cout << "Yay!\n"
			 << endl;
	}
	else
	{
		cout << ":(\n"
			 << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	dn := make([]int, N)
	ans := 1
	for i := range dn {
		dn[i] = nextInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(dn)))
	for i := 0; i < N-1; i++ {
		if dn[i+1] < dn[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#!python3.8
# -*- coding: utf-8 -*-
# abc168/abc168_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2s()
    if N[-1] in ('2', '4', '5', '7', '9'):
        print('hon')
    elif N[-1] in ('0', '1', '6', '8'):
        print('pon')
    else:
        print('bon')
    return

main()


Measured memory_bytes: 9096