akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

vector<bool> dp(101,false);

void rec(int n){
  
  if(n > 100){
    return;
  }
  
  dp[n] = true;
  
  rec(n+4);
  rec(n+7);
}

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

  rec(0);
  
  if(dp[n]) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string x;
	cin >> x;
	if (s == x) {
		--a;
	} else {
		--b;
	}
	cout << a << ' ' << b << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <queue>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;
int main() {
    string S;
    cin >> S;
    for (int i = 0; i < (1 << S.size()-1); i++) {
        int a = S[0] - '0';
        string ans = "";
        ans += S[0];
        for (int j = 0; j < S.size()-1; j++) {
            int num = S[j + 1] - '0';
            if (i & (1 << j)) {
                a += num;
                ans += "+" + to_string(num);
            } else {
                a -= num;
                ans += "-" + to_string(num);
            }

        }

        ans += "=7";

        if (a == 7) {
            cout << ans << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

int main(void)
{

    int n;
    cin >>n;

    vector<pair<int, int> > town;
    for(int i = 0; i < n; i++){
        int x,y;
        cin >>x >>y;
        town.push_back(make_pair(x, y));
    }

    double sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j){
                continue;
            }
            sum += sqrt( pow(town[i].first - town[j].first, 2) + pow(town[i].second - town[j].second, 2) );
        }
    }

    printf("%lf\n", sum / n);


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
using itn = int;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  itn n,m;
  cin >>n;
  vec<string> s(n);
  REP(i,n) cin >>s[i];
  cin >>m;
  vec<string> t(m);
  REP(i,m) cin >>t[i];

  int money=0;
  map<string,int> blue,red;
  REP(i,n) ++blue[s[i]];
  REP(i,m) ++red[t[i]];
  REP(i,n) money = max(money,blue[s[i]]-red[s[i]]);

  cout <<money <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N, K;
    string s;
    ll answer = 0;
    
    cin >> N >> K >> s;
    ll r = 0;
    ll l = 0;
    ll cnt = 0;

    while(r < N){
        while(s[r] == '1' && r < N) r++;
        while(s[r] == '0' && r < N) r++;
        while(s[r] == '1' && r < N) r++;
        cnt ++;
        if (cnt > K){
            while(s[l] == '1' && l < N) l++;
            while(s[l] == '0' && l < N) l++;
        } 

        answer = max(answer, r - l);
    }

        
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    char c[110];
    rep(i, 0, h) {
        cin >> c;
        puts(c);
        puts(c);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <cassert>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, s;
};

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

	str = '0' + str;

	if (str[1] == '0') {
		printf("-1");
		return 0;
	}
	int len = str.length();
	string r, l;
	
	l = str.substr(0,(len + 1)/2);
	r = str.substr(len/2, (len + 1) / 2);

	reverse(ALL(r));
	if(r != l) {
		printf("-1");
		return 0;
	}


	int cn = 1;
	int cz = len-1;

	for (int i = (1 + len) / 2 - 1; i >= 0; i--) {
		if (l[i] == '0') continue;

		REP(j, cz - i - 1) {
			printf("%d %d\n", cn, cn + j + 1);
		}
		printf("%d %d\n", cn, cn + cz-i);
		cn += cz - i;
		cz = i;
	}


	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Read();
            if (a == a.ToUpper())
                WriteLine("A");
            else
                WriteLine("a");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        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: 26028
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.141592653589793238
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld x,lld mod){return (x%mod+mod)%mod;}
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];
// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

// void dfs(int arr[][],int i,int j){
//     if(i<0 || j<0){
//         return;
//     }
//     else{
//         if()
//     }
// }
void test_case(){
    int n;
    cin>>n;
    vector<long long> v(n);
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    long long curr=1000;
    long long stocks=0;
    for(int i=0;i<n-1;++i){
        if(v[i]<v[i+1]){
            stocks=curr/v[i];
            curr+=(v[i+1]-v[i])*stocks;
        }
    }
    cout<<curr;
}

int main(){
    fastio;
    file();
    // pre();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}

Measured memory_bytes: 3656
N, A, B, C = map(int, input().split())
vars = {"A": A, "B": B, "C": C}
sum_ABC = A+B+C
S = [input() for _ in range(N)]
Ans = []
for s, s_next in zip(S, S[1:]):
    if vars[s[0]] > vars[s[1]] or (vars[s[0]]==vars[s[1]] and s[1] in s_next):
        Ans.append(s[1])
        vars[s[1]] += 1
        vars[s[0]] -= 1
    else:# vars[s[0]] < vars[s[1]]:
        Ans.append(s[0])
        vars[s[0]] += 1
        vars[s[1]] -= 1
    if vars[s[0]] < 0 or vars[s[1]] < 0:
        print("No")
        exit()
s = S[-1]
if vars[s[0]] > vars[s[1]]:
    Ans.append(s[1])
    vars[s[1]] += 1
    vars[s[0]] -= 1
else:
    Ans.append(s[0])
    vars[s[0]] += 1
    vars[s[1]] -= 1
if vars[s[0]] < 0 or vars[s[1]] < 0:
    print("No")
    exit()
print("Yes")
print("\n".join(Ans))


Measured memory_bytes: 17680
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#define INF 100000001
using namespace std;
typedef long long ll;
string s, t,ss;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	bool qq = false;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		bool flag = true;
		for (int j = 0; j < s.size(); j++) {

			int mm = i + j;
			if (s.size() < mm+1) {
				mm = mm- s.size();
			}
			if (s[mm] != t[j]) {
				flag = false;
			}
		}
		if (flag) {
			qq = true;
		}
	}
	if (qq) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt =0
for i in range(N-1):
    if x<A[i]:
        break
    else:
        x = x-A[i]
        cnt += 1

if x == A[N-1]:
    cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;
typedef long long llong;

void solve_test()
{
	char a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c) cout << "Yes\n";
	else if (a == c && a != b) cout << "Yes\n";
	else if (b == c && b != a) cout << "Yes\n";
	else cout << "No\n";
}

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

	int tests = 1;
	//cin >> tests;
	while (tests--)
		solve_test();

	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
 
const int N = 1e6 + 5;
const int SQRT_NUM = 1000 + 5; // sqrt{max a_i}

int n;

int cnt[N];
 
int gcd(int x, int y) { return x % y == 0 ? y : gcd(y, x % y); }
 
int main() {
	std::scanf("%d", &n);
	int gcd_all = 0;
	for(int i = 1; i <= n; i++) {
		int x;
		std::scanf("%d", &x);
		cnt[x]++;
		gcd_all = gcd(gcd_all, x);
	}
	if(gcd_all != 1) { std::puts("not coprime"); return 0; }
	for(int i = 2; i < N; i++) {
		int tot = 0;
		for(int j = i; j < N; j += i) tot += cnt[j];
		if(tot > 1) { std::printf("setwise coprime"); return 0; }
	}
	std::puts("pairwise coprime");
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 076_abc_d / Link: https://abc076.contest.atcoder.jp/tasks/abc076_d?lang=en ----- */
/* ------問題------

2168年、AtCoder 社は成長し、ついに "AtCoder特急" という鉄道を建設することを決めた。
さて、社長の高橋君は、"AtCoder特急" の列車を以下のように運行することを計画した。
列車の走行時間は、(t1+t2+t3+…+tN) 秒である。
最初の t1 秒間は、列車は速度 v1 m/s 以内で走っていなければならない。また、次の t2 秒間は、列車は速度 v2 m/s 以内で走っていなければならない。 次の t3 秒間、またそれ以降についても同様である。
最後の tN 秒間は、列車は速度 vN m/s 以内で走っていなければならない。
ただし、列車の性能上、加速度は ±1m⁄s2 以内でなければならない。また、走行開始時と走行終了時には列車は止まっていなければならない。

列車が発車してから停車するまでに走れる最大の距離を求めなさい。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

double ans = 0LL;

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

	cin >> N;
	VI t(N);
	vector<double> v(N);
	vector<double> mx(N + 1, 0);
	FOR(i, 0, N) {
		cin >> t[i];
	}
	double now = 0;
	FOR(i, 0, N) {
		cin >> v[i];
		now = min(now + t[i], v[i]);
		mx[i + 1] = now;
	}
	mx[N] = 0;
	now = 0;
	FORR(i, N - 1, 0 - 1) {
		now = min(now + t[i], v[i]);
		mx[i] = min(mx[i], now);
	}

	FOR(i, 0, N) {
		double top = max(mx[i], mx[i + 1]) + (double)(t[i] - abs(mx[i] - mx[i + 1]) ) / 2.0;
		double S = (mx[i] + top)*(top - mx[i]) / 2.0 + (mx[i + 1] + top)*(top - mx[i + 1]) / 2.0;
		if (top < v[i])ans += S;
		else {
			ans += S;
			ans -= (top - v[i])*(top - v[i]);
		}
	}


	cout << fixed << setprecision(10) << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
char s[8192];
char ans[8192];
char s2[8192];
char ans2[8192];
int n,k;
void sol()
{
	if(k==0)
	{
		for(int i=0;i<n;i++)
		{
			ans2[i]=s2[i];
		}
		return;
	}
	int numa=0;
	for(int i=n-1;i>=0;i--)
	{
		if(s2[i]==s2[n-1])
		{
			numa++;
		}
		else
		{
			break;
		}
	}
	int numa2=numa;
	for(int i=0;i<k;i++)
	{
		numa2<<=1;
		if(numa2>n)
		{
			break;
		}
	}
	if(numa2>n)
	{
		numa2=n;
	}
	for(int i=0;i<numa2;i++)
	{
		ans2[i]=s2[n-1];
	}
	for(int i=0;i<n-numa2;i++)
	{
		ans2[numa2+i]=s2[n-numa-1-i];
	}
}
bool cmp()
{
	for(int i=0;i<n;i++)
	{
		if(ans2[i]!=ans[i])
		{
			return ans2[i]<ans[i];
		}
	}
	return false;
}
int main()
{
	scanf("%d%d",&n,&k);
	k--;
	scanf("%s",s);
	for(int i=0;i<n;i++)
	{
		ans[i]='z';
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i+j<n)
			{
				s2[j]=s[i+j];
			}
			else
			{
				s2[j]=s[n+n-1-i-j];
			}
		}
		sol();
		if(cmp())
		{
			for(int j=0;j<n;j++)
			{
				ans[j]=ans2[j];
			}
		}
	}
	printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::max;
use std::io;

fn main() {
    let input = input_number();
    let _n = input[0] as usize;
    let ai = input_number();

    if let Some(_) = ai.iter().find(|x| **x == 0) {
        println!("0");
        return;
    }

    let mut result = 1u64;
    let checker = 1000000000000000000u64;
    for value in ai {
        if result > checker {
            println!("-1");
            return;
        }
        if checker / result < value {
            println!("-1");
            return;
        }
        result = result * value;
    }
    println!("{}", result);
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn input_number() -> Vec<u64> {
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<u64> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap_or(0))
        .collect();
    vec
}

#[allow(dead_code)]
fn input() -> (char, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: char = iter.next().unwrap().chars().nth(0).unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    (c, n)
}


Measured memory_bytes: 4800
N = int( input())
D = []
for i in range(N):
    D.append(int(input()))
D = sorted(D)
ans = 1
d_now = D[0]
for i in range(1,N):
    if d_now < D[i]:
        ans += 1
        d_now = D[i]
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int weight[11],n,co[11],a=0;
    for(int i=0;i<11;i++)weight[i]=exp2(i);
    while(cin>>n){
        for(int i=0;i<11;i++)co[i]=0;
        for(int i=10;i>=0;i--){
            if(n>=weight[i]){
                co[i]=1;
                n-=weight[i];
            }
        }
        for(int i=0;i<11;i++){
            if(co[i]==1&&a==0){
                cout<<weight[i];
                a=1;
            }
            else if(co[i]==1)cout<<" "<<weight[i];
        }
        cout<<endl;
        a=0;
    }
}

Measured memory_bytes: 1180
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

int main(void){
  string s;
  int k;
  cin>>s>>k;
  for(int i=0;i<s.size();i++){
    if(s[i]=='a') continue;
    if(s[i]+k>'z'){
      k-='z'+1-s[i];
      s[i]='a';
    }
  }
  if(k>0){
    int t=s[s.size()-1];
    t-='a';
    t+=k;
    t%='z'-'a'+1;
    s[s.size()-1]='a'+t;
  }
  cout<<s<<endl;
  return 0;
}


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

int main(void)
{
	double x, h, area;

	while (1){
		scanf("%lf", &x);
		scanf("%lf", &h);
		if (x == 0 && h == 0){
			break;
		}

		area = x * x + 2 * x * sqrt(x * x / 4 + h * h);

		printf("%f\n", area);
	}
	return (0);
}

Measured memory_bytes: 644
function main(input){
  input = input.split('\n');
  const [H, W, K] = input[0].split(' ').map(Number);
  const c = input.splice(1, 1+H).map(row => row.replace(/#/g, '1').replace(/\./g, '0').split('').map(Number));

  let sum = 0;
  for(let maskR=0; maskR<= (1<<H)-1; maskR++){
    for(let maskC=0; maskC<= (1<<W)-1; maskC++){
      let black = 0;
      c.forEach((r, i)=>{
        r.forEach((_, j)=>{
          if(c[i][j] === 1){
            if(((maskR >> i) & 1) === 0 && ((maskC >> j) & 1) === 0)
              black++;
          }
        });
      });
      if(black === K){
        sum++;
      }
    }
  }

  console.log(sum);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

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

int main() {
    int n;
    int max = INT_MIN;
    int min = INT_MAX;
    int a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a >= max) max = a;
        if (a <= min) min = a;
    }
    cout << max-min << endl;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const ll mod = 1e9 + 7;


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

    string s;
    cin >> s;
    if(s == "SAT"){
        cout << 1 << endl;
    }
    if(s == "SUN"){
        cout << 7 << endl;
    }
    if(s == "MON"){
        cout << 6 << endl;
    }
    if(s == "TUE"){
        cout << 5 << endl;
    }
    if(s == "WED"){
        cout << 4 << endl;
    }
    if(s == "THU"){
        cout << 3 << endl;
    }
    if(s == "FRI"){
        cout << 2 << endl;
    }




    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
    void solve (){
        int n;
        long totalp, totalj;
        long[] P;
        long[] J;
        Scanner sc = new Scanner(System.in);
        while(true){
            n = sc.nextInt();
            if ( n == 0 ) break;
            P = new long[n];
            J = new long[n];
            totalp = 0;
            for ( int i = 0; i < n; i++ ) {
                P[i] = sc.nextLong();
                totalp += P[i];
            }
            for ( int i = 0; i < n-1; i++ ) {
                J[i] = sc.nextLong();
            }

            long maxv = 0;
            Arrays.sort(J);
            totalj = 0;
            for ( int j = 0, t = n; t >= 1; t--, j++ ){
                long v = t*(totalj + totalp);
                totalj += J[n-1-j];
                maxv = Math.max(v, maxv);
            }
            System.out.println(maxv);
        }
    }

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



Measured memory_bytes: 102344
#include<iostream>
#include<array>
#include<vector>

int main(){

    std::array<std::array<size_t, 3>, 3> a;

    for(size_t i = 0; i < 3; i++){
        for(size_t j = 0; j < 3; j++){
            std::cin >> a[i][j];
        }
    }

    size_t n;
    std::cin >> n;

    for(size_t i = 0; i < n; i++){
        size_t tmp;
        std::cin >> tmp;

        for(auto&& v : a){
            for(auto&& e : v){
                if(e == tmp) e = 0;
            }
        }
    }

    bool flag = false;

    for(size_t i = 0; i < 3; i++){
        if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) flag = true;
        if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) flag = true;
    }

    if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) flag = true;
    if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) flag = true;

    if(flag){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

long long solve(int n, const std::vector<long long> & a, const std::vector<long long> & b, const std::vector<long long> & c) {
    long long res { 0LL };
    
    for (int i = 0; i < n; ++i) {
        const long long m { b[i] };
        const long long an { std::distance(a.begin(), std::lower_bound(a.begin(), a.end(), m)) };
        const long long cn { std::distance(c.begin(), std::upper_bound(c.begin(), c.end(), m)) };
        res += (an * (n - cn));
    }
    return res;
}

int main(int argc, const char * argv[]) {
    int n;
    std::cin >> n;
    
    std::vector<long long> a;
    for (int i = 0; i < n; ++i) {
        long long ai;
        std::cin >> ai;
        a.push_back(ai);
    }
    std::sort(a.begin(), a.end());
    
    std::vector<long long> b;
    for (int i = 0; i < n; ++i) {
        long long bi;
        std::cin >> bi;
        b.push_back(bi);
    }
    std::sort(b.begin(), b.end());

    std::vector<long long> c;
    for (int i = 0; i < n; ++i) {
        long long ci;
        std::cin >> ci;
        c.push_back(ci);
    }
    std::sort(c.begin(), c.end());
    
    std::cout << solve(n, a, b, c) << std::endl;
    
    return 0;
}


Measured memory_bytes: 6384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            long N = Long.valueOf(args.get(0));
            long m = N - 1;
            long ans = 0;
            while (m > 0) {
                long q = N / m;
                long r = N % m;
                if (q == r) {
                    ans += m;
                }
                if (r >= q) {
                    m = N / (q + 1);
                } else {
                    m--;
                }
            }
            System.out.println(ans);
        };
    }

}


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

int main(){
    int n, max = 0, min = 9999999999;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n;i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < n;i++) {
        if (max < A.at(i)){
            max = A.at(i);
        }
    }
    for (int i = 0; i < n; i++) {
        if (min > A.at(i)) {
            min = A.at(i);
        }
    }
    int answer = abs(max - min);
    cout << answer;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void)
{
  char s[20]={'\0'};
  int i;
  
  scanf("%s",s);
  for(i=19;i>=0;i--){
    if(s[i]=='\0')
	  continue;
	printf("%c",s[i]);
  }
  putchar('\n');
  
  return 0;
}

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

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

    vector<int> food(m,0);

    for(int i=0; i<n; i++){
        int k; cin>>k;
        for(int i=0; i<k; i++){
            int a; cin>>a;
            food[a-1]++;
        }
    }

    int count =0;

    for(int i=0; i<m; i++){
        if(food[i] == n) count++;
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[31],sub;
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		sub=d[b];
		d[b]=d[a];
		d[a]=sub;
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<ll, ll>;
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;}
const long long LLINF = 1LL << 60;
using namespace std;

int main()
{
    string S;
    cin >> S;

    if (S[0] == '0' or S.back() == '1') {
        cout << -1 << endl;
        return 0;
    }

    int sz = S.size();
    bool ok = true;

    for (int i=1; i<sz; ++i) {
        int j = sz-i;
        if (S[i-1] != S[j-1]) ok = false;
    }
    if (!ok) {
        cout << -1 << endl;
        return 0;
    }

    vector<P> res;
    int prev = 1;
    for (int i = 2; i <= sz; ++i) {
        if (S[i-1] == '1') {
            for (; prev < i; ++prev) res.emplace_back(i, prev);
        }
    }
    res.emplace_back(sz, sz-1);
    for (auto tmp : res) {
        cout << tmp.first << ' ' << tmp.second << endl;
    }

    return 0;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define maxn 1000009
using namespace std;
int main(){
    int n;
    cin>>n;
    int cnt=0,sum=0;
    for(int i=1;i<=n;i++){
        sum+=i;
        cnt++;
        if(sum>=n)
            break;
    }
    if(sum==n){
        for(int i=1;i<=cnt;i++)
            cout<<i<<endl;
    }
    else{
        sum-=cnt;
        cnt--;
        int t=n-sum;
        for(int i=1;i<=cnt;i++){
            if(i==cnt+1-t){
                continue;
            }
            cout<<i<<endl;
        }
        cout<<cnt+1<<endl;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define si scanf
#define so printf
#define N 
#define M 
#define INF  
template<typename TP>inline bool rd(TP& r)
{
	r=0;
	char tmp=getchar();
	while(tmp<'0'||tmp>'9')
	{
		if(tmp==EOF)
			return 0;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		r=(r<<3)+(r<<1)+tmp-'0';
		tmp=getchar();
	}
	return 1;
	
} 
int n,a,b; 
int main()
{
	rd(n),rd(a),rd(b);
	if((a-b-1)&1)
		so("Alice\n");
	else
		so("Borys\n");
	return 0;
} 

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

for i in range(N+1):
  for j in range(N+1):
    a = i
    b = j
    c = N-i-j
    if c < 0:
      continue
    else:
      price = a*1000+b*5000+c*10000
      if price == Y:
        print(c,b,a)
        exit()
print(-1,-1,-1)

Measured memory_bytes: 66640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++) if(s[i] == ',') s[i] = ' ';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

double dp[3333][3333];

main(){
	int n;cin>>n;
	double p[n];rep(i,n)cin>>p[i];
	dp[0][0]=1.0;
	rep(i,n){
		rep(j,n){
			if(i+j>=n)continue;
			dp[i+1][j]+=dp[i][j]*p[i+j];
			dp[i][j+1]+=dp[i][j]*(1-p[i+j]);
		}
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++){
		ans+=dp[i][n-i];
	}
	printf("%.10f\n",ans);
}






Measured memory_bytes: 80128
//#define _GLIBCXX_DEBUG

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a,x;
    cin >> x >> a;
    if(x < a)cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(c==1||d==1){
        cout << 0 << endl;
        return 0;
    }
    ll numC=b/c-a/c;
    if(a%c==0) numC++;
    ll numD=b/d-a/d;
    if(a%d==0) numD++;
    ll numlcm=b/lcm(c,d)-a/lcm(c,d);
    if(a%lcm(c,d)==0) numlcm++;
    cout << b-a+1-numC-numD+numlcm << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d,x,y;

	while(scanf("%d",&x)!=EOF){
		y=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==x)y++;
					}
				}
			}
		}
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

struct subarray{
    ll low;
    ll high;
    ll mid;
    ll midval;
    ll id;
    ll deftero;
    bool operator <(const subarray &a)const
    {
        if(deftero == a.deftero)
            return midval > a.midval;

        return deftero<a.deftero;
    }

};

ll n,k,ar[N];
pi seg[4*N][2];
vector < pi > res;

void build(ll low,ll high,ll pos)
{
    if(low == high)
    {
        seg[pos][low%2].first = ar[low];
        seg[pos][(low+1)%2].first = n+1;
        seg[pos][0].second = seg[pos][1].second = low;
        return;
    }

    ll mid = (low+high)/2;

    build(low,mid,pos*2+1);
    build(mid+1,high,pos*2+2);

    seg[pos][0] = min(seg[pos*2+1][0],seg[pos*2+2][0]);
    seg[pos][1] = min(seg[pos*2+1][1],seg[pos*2+2][1]);
    return;
}

pi query(ll low,ll high,ll pos,ll slow,ll shigh,ll id)
{
    if(slow>shigh)
        return mp(n+1,n+1);
    if(low >= slow && high <= shigh)
    {
        return seg[pos][id];
    }
    if(low > shigh || high < slow)
        return mp(n+1,n+1);

    ll mid = (low+high)/2;

    return min(query(low,mid,pos*2+1,slow,shigh,id),query(mid+1,high,pos*2+2,slow,shigh,id));
}

void solve()
{
    priority_queue < subarray > pq;
    subarray init = {0,n-1,query(0,n-1,0,0,n-1,0).second,query(0,n-1,0,0,n-1,0).first,0,0};

    pq.push(init);

    while(!pq.empty())
    {
        subarray cur = pq.top();
        pq.pop();

        cout << cur.midval << " ";
        //cout << cur.low << " " << cur.high << " " << cur.mid << " " << cur.id << endl;

        subarray neo = cur;
        neo.high = neo.mid-1;
        neo.mid = query(0,n-1,0,neo.low,neo.high,neo.id).second;
        neo.midval = query(0,n-1,0,neo.low,neo.high,neo.id).first;
        neo.deftero = 0;

        if(neo.high>=neo.low)
            pq.push(neo);

        neo = cur;
        neo.low = neo.mid+1;
        neo.id = !neo.id;
        neo.mid = query(0,n-1,0,neo.low,neo.high,neo.id).second;
        neo.midval = query(0,n-1,0,neo.low,neo.high,neo.id).first;
        neo.deftero = !neo.deftero;

        if(neo.high>=neo.low)
            pq.push(neo);
    }

    return;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;

    rep(i,0,n)
    {
        cin >> ar[i];
    }

    build(0,n-1,0);
    solve();

    return 0;
}


Measured memory_bytes: 25716
/*
 * aoj/dsl_3_c/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N, Q;
vector<ll> A;
ll X;
void solve() {
  cin >> N >> Q;
  ll a;
  loop(n,0,N) cin >> a, A.push_back(a);
  loop(q,0,Q) {
    cin >> X;
    // 区間[l:r)の和がX以下となるl, rの組み合わせの数を求める
    ll total = 0;
    ll sum = 0;
    int r = 0;
    loop(l,0,N) {
      while (r < N and sum + A[r] <= X) sum += A[r++];
      total += r-l;
      if (r==l) r++;
      else sum -= A[l];
    }
    cout << total << endl;
  }
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}



Measured memory_bytes: 3840
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, m: usize, ab:[[usize; 2]; n]};
    let mut ab: Vec<Vec<usize>> = ab;

    ab.sort();

    let mut sum = 0;
    let mut m = m;

    for i in ab.iter() {
        if i[1] < m {
            m -= i[1];
            sum += i[0] * i[1];
        } else {
            sum += i[0] * m;
            break;
        }
    }

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


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

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

//#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define endl "\n"
#define f first
#define s second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (c/b + bool(c%b) <= a/d + bool(a%d))
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3616
from collections import deque
s=deque(list(input()))
q=int(input())
REVERSE=False
for _ in range(q):
  Input=input().split()
  if len(Input)==1:
    REVERSE = not REVERSE
  else:
    f=int(Input[1])
    c=Input[2]
    if not REVERSE:
      if f==1:
        s.appendleft(c)
      else:
        s.append(c)
    else:
      if f==1:
        s.append(c)
      else:
        s.appendleft(c)
if not REVERSE:
  print("".join(s))
else:
  print("".join(reversed(s)))

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int M, N;
vector<string> A;
vector<string> B;

bool match(int sy, int sx) {

    bool result = true;
    for (int y = sy; y < sy + M; ++y) {
        for (int x = sx; x < sx + M; ++x) {
            if (A[y][x] != B[y - sy][x - sx]) {
                result = false;
                break;
            }
        }
    }
    return result;
}

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

    A.resize(N);
    rep(i, N) {
        cin >> A[i];
    }

    B.resize(M);
    rep(i, M) {
        cin >> B[i];
    }

    bool ans = false;
    for (int y = 0; y < N - (M - 1); ++y) {
        for (int x = 0; x < N - (M - 1); ++x) {
            if (match(y, x)) {
                ans = true;
                break;
            }
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X.at(i);

    int cost, min_cost=2147483647;
    rep(i, 100) {
        cost=0;
        rep(j, N) {
            cost += pow((X.at(j) - (i+1)), 2);
            if(cost >= min_cost) {
                break;
            }
        }
        if(cost<min_cost){
            min_cost=cost;
        }
    }

    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$vertices = array_merge(input_array('intval'), array_merge(input_array('intval'), input_array('intval')));
$counts = array_values(array_count_values($vertices));
sort($counts);

if ($counts === [1, 1, 2, 2]) {
    echo "YES\n";
} else {
    echo "NO\n";
}

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

int main(){

	char A,B,C;
	int a=0,b=0,c=0;
	cin>>A>>B>>C;
	int ans=0;
	if(A=='a')a++;
	if(A=='b')b++;
	if(A=='c')c++;
	if(B=='a')a++;
	if(B=='b')b++;
	if(B=='c')c++;
	if(C=='a')a++;
	if(C=='b')b++;
	if(C=='c')c++;


	a==1 && b==1 && c==1 ? cout<<"Yes"<<endl : cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Sn = new List<char>[N];
            for (var i = 0; i < N; ++i)
                Sn[i] = new List<char>(ReadLine().ToCharArray());
            var choku = Sn[0].Intersect(Sn[0]);
            for (var i = 2; i < N; ++i)
                choku = choku.Intersect(Sn[i]);
            if (choku.Count() == 0)
            {
                WriteLine();
                return;
            }
            var moji = choku.ToList();
            moji.Sort();

            foreach (var m in moji)
            {
                var min = 50;
                for (var i = 0; i < N; ++i)
                    min = Min(min, Sn[i].Count(s => s == m));
                Write(new string(m, min));
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13524