akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

# AOJ CGL_4_A "Convex Hull"

from operator import itemgetter

def scan(Points):
    Points.sort(key=itemgetter(1))
    Points.sort(key=itemgetter(0))

    k = 0
    Qs = []
    for x, y in Points:
        while len(Qs) > 1:
            x1, y1 = Qs[-1]
            x2, y2 = Qs[-2]
            if (y1-y)*(x-x2) > (y-y2)*(x1-x):
                Qs.pop()
            else:
                break
        Qs.append((x, y))
        
    t = len(Qs)
    Qs.pop()
    for x, y in reversed(Points):
        while len(Qs) > t:
            x1, y1 = Qs[-1]
            x2, y2 = Qs[-2]
            if (y1-y)*(x-x2) > (y-y2)*(x1-x):
                Qs.pop()
            else:
                break
        Qs.append((x, y))
    Qs.pop()

    return Qs

import math

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

def main():
    if N == 2:
        x1, y1 = XY[0]
        x2, y2 = XY[1]
        d = math.sqrt((x1-x2)**2+(y1-y2)**2)
        print(d/2)
        return
    outerpoints = scan(XY)

    min2 = 10**16
    for i in range(N-1):
        for j in range(i+1, N):
            x1, y1 = XY[i]
            x2, y2 = XY[j]
            px, py = (x1+x2)/2, (y1+y2)/2
            r = math.sqrt((px-x1)**2+(py-y1)**2)
            using = [(x1, y1), (x2, y2)]
            ok = True
            for ox, oy in outerpoints:
                if (ox, oy) in using:
                    continue
                if math.sqrt((ox-px)**2+(oy-py)**2) > r:
                    ok = False
                    break
            if ok:
                min2 = min(min2, r)
    
                
    min3 = 10**16
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                a, b = XY[i]
                c, d = XY[j]
                e, f = XY[k]
                if (2*(e-a)*(b-d)-2*(c-a)*(b-f)) == 0:
                    px = (max([a, c, e])+min([a, c, e]))/2
                    py = (max([b, d, f])+min([b, d, f]))/2
                else:
                    py = ((e-a)*(a**2+b**2-c**2-d**2) - (c-a)*(a**2+b**2-e**2-f**2)) / (2*(e-a)*(b-d)-2*(c-a)*(b-f))
                    if c != a:
                        px = (2*(b-d)*py-a**2-b**2+c**2+d**2)/(2*(c-a))
                    else:
                        px = (2*(b-f)*py-a**2-b**2+e**2+f**2)/(2*(e-a))
                r = math.sqrt((px-a)**2+(py-b)**2)
                using = [(a, b), (c, d), (e, f)]
                ok = True
                for ox, oy in outerpoints:
                    if (ox, oy) in using:
                        continue
                    if math.sqrt((ox-px)**2+(oy-py)**2) > r:
                        ok = False
                        break
                if ok:
                    min3 = min(min3, r)
    print(min(min2, min3))
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 48092
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int n;
	ll ans = 1;
	cin >> n;
	while (2 * ans <= n)ans *= 2;
	cout << ans << endl;
}



Measured memory_bytes: 256
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        var k = long.Parse(Console.ReadLine());
        if (s.Distinct().Count() == 1)
        {
            Console.WriteLine(s.Length * k / 2);
            return; 
        }
        bool isFirst = true;
        char firstChar = '*';
        int firstStreak = 0;
        long res = 0;
        char lastChar = s[0];
        int curStreak = 0;
        foreach (var c in s)
        {
            if (c != lastChar)
            {
                if (isFirst)
                {
                    firstChar = lastChar;
                    firstStreak = curStreak;
                    isFirst = false;
                }
                else res += curStreak / 2;
                curStreak = 0;
            }
            lastChar = c;
            curStreak++;
        }
        res *= k;
        if (firstChar != lastChar)
        {
            res += (firstStreak / 2) * k;
            res += (curStreak / 2) * k;
        }
        else
        {
            res += firstStreak / 2;
            res += curStreak / 2;
            res += ((firstStreak + curStreak) / 2) * (k - 1);
        }
        Console.WriteLine(res);
    }
}


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

using namespace std;

int freq[10];

string s;

int conv(char a)
{
	if( a == 'N' ) return 1;
	if( a == 'S' ) return 2;
	if( a == 'W' ) return 3;
	if( a == 'E' ) return 4;
}

int main()
{
	cin >> s;

	for(int i = 0 ; i < s.size() ; i++)
		freq[ conv( s[i] ) ]++;

	bool answer = true;

	if( freq[1] != 0 ) answer = answer && ( freq[2] > 0 );
	if( freq[2] != 0 ) answer = answer && ( freq[1] > 0 );

	if( freq[3] != 0 ) answer = answer && ( freq[4] > 0 );
	if( freq[4] != 0 ) answer = answer && ( freq[3] > 0 );

	if( answer ) printf("Yes\n");
	else printf("No\n");
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<vector<int>> d(N, vector<int>(N, INF));
    rep(i, N) d[i][i] = 0;

    vector<tuple<int, int, int>> edges;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = d[b][a] = c;
        edges.emplace_back(a, b, c);
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, M) {
        int a = get<0>(edges[i]), b = get<1>(edges[i]), c = get<2>(edges[i]);
        if (d[a][b] < c) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
if N>81:
    print("No")
else: 
    if N in (1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
vector<int> ind[255];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  cin >> s >> t;
  int p = 0;
  ll ans = 0;
  for (int i = 0; i < s.length(); i++) {
    ind[s[i] - 'a'].pb(i);
  }
  // for (int i = 0; i < 26; i++) {
  //   cout << i << ' ';
  //   for (int x : ind[i])
  //     cout << x << ' ';
  //   cout << endl;
  // }
  for (int j = 0; j < t.length(); j++) {
    // cout << t[j] - 'a' << endl;
    if (ind[t[j] - 'a'].empty()) {
      cout << -1 << endl;
      return 0;
    } else {
      auto i = lower_bound(ind[t[j] - 'a'].begin(), ind[t[j] - 'a'].end(), p);
      if (i == ind[t[j] - 'a'].end()) {
        ans += (s.length() - p);
        i = ind[t[j] - 'a'].begin();
        ans += (*i + 1);
        p = *i + 1;
      } else {
        ans += (*i - p + 1);
        p = (*i + 1) % s.length();
      }
      // cout << *i << ' ' << ans << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1228
#include <stdio.h>
int main(){
int h,w;
while(1){
scanf("%d",&h);scanf("%d",&w);
if(h==0&&w==0)break;

for(int i=0;i<h;i++)
{
for(int k=0;k<w;k++)
{
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MOD = 998244353;

int coef, coef1, coef2, res, i, n;

// rozwiązuje równanie ax=1(%MOD), gdy MOD pierwsze
int inverse(int a, int n = MOD - 2) {
    int r = 1;
    while (n) {
        if (n % 2) r = (r * 1LL * a) % MOD;
        a = (a * 1LL * a) % MOD;
        n >>= 1;
    }
    return r;
}

int main() {
scanf("%d", &n);
res = 1;
for (i=0;i<n;i++) res = (res * 3LL) % MOD;
coef1 = 1;
coef2 = 1;
for (i=n;i>n/2;i--) {
	coef = (coef1 * 1LL * coef2) % MOD;
	res = (res + MOD - coef) % MOD;
	res = (res + MOD - coef) % MOD;
	coef1 = (coef1 * 1LL * i) % MOD;
	coef1 = (coef1 * 1LL * inverse(n - i + 1)) % MOD;
	coef2 = (coef2 * 2LL) % MOD;
}
printf("%d\n", res);
}





Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var nm = Reads();
            var n = nm[0];
            var m = nm[1];
            var ans = new long[n];
            for (int i = 0; i < n; i++)
            {
                ans[i] = 10;
            }
            bool f = false;
            for (int i = 0; i < m; i++)
            {
                var sc = Reads();
                if (ans[sc[0] - 1] != 10 && (ans[sc[0] - 1] != sc[1])) f = true;
                else if (n!=1&&sc[0] == 1 && sc[1] == 0) f = true;
                else ans[sc[0] - 1] = sc[1];
            }


            if (f) WriteLine("-1");
            else
            {
                for (int i = 0; i < n; i++)
                {
                    if (i == 0)
                    {
                        if (n != 1 && ans[i] == 10)
                            Write(1);
                        else if (n == 1 && ans[i] == 10)
                            Write(0);
                        else
                            Write(ans[i]);
                    }
                    else
                    {
                        if (ans[i] != 10)
                            Write(ans[i]);
                        else
                            Write(0);
                    }
                }
                WriteLine();
            }












          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 18900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count=0;
  int flag=0;
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
      cin>>A.at(i);
  }
  while(flag==0){
      for(int i=0;i<N;i++){
          if(A.at(i)%2==1){
              flag=1;
              break;
          }
        A.at(i)=A.at(i)/2;
      }
    if(flag==0){
    count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,k,ans=0;
    string s;
    cin >> n >> k >> s;
    vector<int> v,u;//zero列の開始位置と終了位置
    if(n==1){
        cout << 1 << endl;
        return 0;
    }

    v.push_back(-1);
    u.push_back(-1);
    if(s.at(0)=='0'){
        v.push_back(0);
    }
    for(int i=1;i < n;i++)
    {
        if(s.at(i)=='0'&& s.at(i-1)=='1')
        {
            v.push_back(i);
        }
        if(s.at(i)=='1'&& s.at(i-1)=='0')
        {
            u.push_back(i-1);
        }
    }
    if(s.at(n-1)=='0'){
        u.push_back(n-1);
    }
    v.push_back(n);
    u.push_back(n);

    
    for(int i=1;i+k<v.size();i++)
    {
        ans = max(ans,v.at(i+k)-u.at(i-1)-1);
    }
    
    if(k>=v.size()-2){
        cout << n << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	long long int N,A,B;
    cin >> N >> A >> B;
    long long int Ans =0;
    long long int C =N/(A+B);
    Ans=A*C;
    if(N%(A+B)!=0){
        if(A<=N%(A+B))Ans+=A;
        else Ans+=N%(A+B);
    }
    cout << Ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll Q;
    cin>>Q;
    ll lc = 0;
    ll rc = 0;
    priority_queue<ll> lq;
    priority_queue<ll, vector<ll>, greater<ll>> rq;
    ll ga = 0;

    ll c0, a0, b0;
    cin>>c0>>a0>>b0;
    ll m = a0;
    ll bs = b0;

    rep(q, Q - 1) {
        ll c, a, b;
        cin>>c;
        if (c == 1) {
            cin>>a>>b;
            bs += b;
            if (a > m) {
                ga += a - m;
                if (rc - lc >= 1) {
                    lq.push(m);
                    lc++;
                    rq.push(a);
                    rc++;
                    ll d = rq.top() - m;
                    ga += lc * d - rc * d;
                    m = rq.top(); rq.pop();
                    rc--;
                }
                else {
                    rq.push(a);
                    rc++;
                }
            }
            else {
                ga += m - a;
                if (lc - rc >= 0) {
                    rq.push(m);
                    rc++;
                    lq.push(a);
                    lc++;
                    ll d = m - lq.top();
                    ga += rc * d - lc * d;
                    m = lq.top(); lq.pop();
                    lc--;
                }
                else {
                    lq.push(a);
                    lc++;
                }
            }
        }
        
        else {
            cout<<m<<" "<<ga + bs<<endl;
        }
    }
}

Measured memory_bytes: 3828
#include <cstdio>

#define abs(a) (a < 0 ? -(a) : a)
#define max(a, b) ((a) > (b) ? (a) : (b))

int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int d1 = abs(a - b);
  int d2 = abs(b - c);
  int d3 = abs(c - a);
  printf("%d\n", d1 + d2 + d3 - max(d1, max(d2, d3)));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
ll gcm(ll c,ll d){
  if(d==0) return c;
  else return gcm(d,c%d);
}
ll lcm(ll c,ll d){
  return c*d/gcm(c,d);
}
ll f(ll x,ll c,ll d){
  ll ans=x;
  ans-=x/c;
  ans-=x/d;
  ans+=x/lcm(c,d);
  return ans;
}
int main()	{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=f(b,c,d)-f(a-1,c,d);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int t;
int a[100010];
bool vis[100010];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int x;cin>>x;
	int minv=1000000000,ans=1000000000;
	int n;cin>>n;for(int i=0;i<n;i++){cin>>a[i];vis[a[i]]=1;}
	for(int i=0;i<10000000;i++)
	{
		if(!vis[x-i]){cout<<x-i;return 0;}
		if(!vis[x+i]){cout<<x+i;return 0;}
	}
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main(){
    long long n;
    cin >> n;
    if(n == 2) {
        cout << 1 << endl;
        return 0;
    }
    int cnt = 0;
    bool flag = true;
    while(1){
        if(flag == false || n == 3) {
            cnt++;
            break;
        }
        cnt++;
        vector<long long> vec;
        flag = false;
        rep(i,3) vec.push_back((n+i)/3);
        int num = 0;
        rep(i,vec.size()){
            if(vec[i] > num) num = vec[i];
            if(vec[i] > 2) flag = true;
        }
        if(flag == false || num == 3) {
            cnt++;
            break;
        }
        n = num;
    }
    cout << cnt << endl;
    return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

int n = 20, m, L;

vector <tuple<int, int, int>> e;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> L;
    fore(i, 2, n - 1)
    {
        e.eb(i, i + 1, 1 << (n - 1 - i));
        e.eb(i, i + 1, 0);
    }
    int cnt;
    if (L < (1 << (n - 1)))
    {
        cnt = 0;
    }
    else
    {
        L -= 1 << (n - 1);
        e.eb(1, 2, 1 << (n - 2));
        e.eb(1, 2, 0);
        cnt = 1 << (n - 1);
    }
    ford(i, n - 1)
    {
        if (L >> i & 1)
        {
            e.eb(1, n - i, cnt);
            cnt += 1 << i;
        }
    }
    m = e.size();
    cout << n << ' ' << m << '\n';
    for (auto &ed: e)
    {
        int u, v, w;
        tie(u, v, w) = ed;
        cout << u << ' ' << v << ' ' << w << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  int result = 0;
  if(A >= K){
    result = K;
  }else if((A + B) >= K){
    result = A;
  }else{
    result = A - (K - (A + B));
  }
  cout << result << endl;
}

Measured memory_bytes: 3592
"use strict";

function Main(stdin) {
    stdin=stdin.split("\n");
    var sum=0,ans="";
    for(var i=0;sum=0,i<stdin.length;i++){
        stdin[i].split(" ");
        if(stdin[i][0] === "0")
            break;
        for(var o=0;o<stdin[i].length;o++){
            sum+=parseInt(stdin[i][o]);
        }
        ans+=sum+"\n";
    }
    console.log(ans.trim());
}
    
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15736
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  
  int max = A[0];
  int sum=0;
  for(int i=1; i<N; i++){
  	sum += A[i];
  }
  if(max < sum) 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;
	multimap<string, int> m;
	using iterator = decltype(m)::iterator;
	rep(i, N)
	{
		int	a;
		string b;
		cin >> a >> b;
		if (a == 0)
		{
			int c;
			cin >> c;
			m.insert(make_pair(b, c));
			/* m[b] = c; */
		}
		else if (a == 1)
		{

			/* pair<iterator, iterator> p = m.equal_range(b); */
			/* for (iterator it = p.first; it != p.second; it++) */
			iterator x, y;
			x = m.lower_bound(b);
			y = m.upper_bound(b);
			for (iterator it = x; it != y; it++)
				cout << it->second << endl;
		}
		else if (a == 2)
			m.erase(b);
		else
		{
			string	c;
			cin >> c;
			/* for (map<string, int>::iterator it = m.lower_bound(b); it != m.upper_bound(c); it++) */
			for (auto it = m.lower_bound(b); it != m.upper_bound(c); it++)
				cout << it->first << ' ' << it->second << endl;
		}
	}
}



Measured memory_bytes: 24800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
ll ans=1,n;
ll pw(ll a, ll b)
{
    ll rez=1;
    while(b)
    {
        if(b%2)
            rez=(rez*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return rez;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        ans=(ans*10)%mod;
    ll nr=0;
    for(int i=1;i<=n;i++)
    {
        ll val=(pw(8,i-1)*pw(9,n-i))%mod;
        val=(val*2)%mod;
        nr=(nr+val)%mod;
    }
    nr=(nr+pw(8,n))%mod;
    ans-=nr;
    if(ans<0)
        ans+=mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
	public static char abc_ans(String str_a, String str_b, String str_c){
		char[] a = str_a.toCharArray();
		char[] b = str_b.toCharArray();
		char[] c = str_c.toCharArray();

		int a_count = a.length;
		int b_count = b.length;
		int c_count = c.length;

		int a_number = 0;
		int b_number = 0;
		int c_number = 0;

		char x = a[a_number];
		while(true){
			switch (x){
				case 'a':
					if(a_number >= a.length){
						return('A');
					}
					x = a[a_number];

					a_number ++;
					break;
				case 'b':
					if(b_number >= b.length){
						return('B');
					}
					x = b[b_number];
					b_number ++;
					break;
				case 'c':
					if(c_number >= c.length){
						return('C');
					}
					x = c[c_number];
					c_number ++;
					break;
			}
		}
	}

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String str_a = scan.next();
		String str_b = scan.next();
		String str_c = scan.next();

		System.out.println(abc_ans(str_a,str_b,str_c));
	}
}


Measured memory_bytes: 23636
#include<cstdio>
#include<cstring>
const int N=2e5+6;
typedef long long LL;
int ch[N][2],nod,n;LL L,g;
char s[N];
inline LL lbt(LL x){return x&-x;}
void dfs(int now,int dep){
	if(dep==L)return;
	if(ch[now][0])dfs(ch[now][0],dep+1);else g^=lbt(L-dep);
	if(ch[now][1])dfs(ch[now][1],dep+1);else g^=lbt(L-dep);
}
int main(){
	scanf("%d%lld",&n,&L);
	if(!n)return puts("Bob"),0;
	while(n--){
		scanf("%s",s);
		int nw=0;
		for(int i=0;s[i];++i){
			int c=s[i]&15;
			if(!ch[nw][c])ch[nw][c]=++nod;
			nw=ch[nw][c];
		}
	}
	dfs(0,0);
	puts(g?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=200'010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  invinit();
  int n;
  cin>>n;
  //コーナーケースこわい。とくにa[0]==a[n]の場合。
  if(n==1){
    cout<<1<<endl;
    cout<<1<<endl;
    return 0;
  }
  int a[n+1];
  map<int,int> mp;
  int fi=-1,si=-1;//2回出てくる要素の位置
  REP(i,n+1){
    cin>>a[i];
    mp[a[i]]++;
    if(mp[a[i]]==2){
      si=i;
    }
  }
  REP(i,n){
    if(a[i]==a[si]){
      fi=i;
      break;
    }
  }
  long long ans;
  long long sur=0;
  REPP(k,n+1){
    ans = comb((long long)n+1,(long long)k);
    sur = comb((long long)fi+(long long)n-(long long)si,(long long)k-1);
    ans = mod(ans - sur);
    cout<<ans<<endl;
    sur = 0;
  }
  return 0;
}


Measured memory_bytes: 11008
import sys
import numpy as np 

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
l1, l2 = I[1:].reshape(2, n)

def main():
    res = 0
    for i in range(n):
        res = max(res, np.sum(l1[:i+1]) + np.sum(l2[i:]))
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 20360
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct data{
    ll a;
    ll ed;
};

data ara[200009];

bool comp(data p,data q)
{
    return p.ed<q.ed;
}

bool check(ll n)
{
    ll st=0;
    for(ll i=0;i<n;i++)
    {
//        cout<<st<<"  "<<st+ara[i].a<<"  "<<ara[i].ed<<endl;
        if(st+ara[i].a>ara[i].ed)return false;
        st+=ara[i].a;

    }
    return 1;
}
int main()
{
    ll n;cin>>n;
    for(ll i=0;i<n;i++)cin>>ara[i].a>>ara[i].ed;

    sort(ara,ara+n,comp);
    if(check(n))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
//#include<unordered_map>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<sstream>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
#define PA pair<int,int>
#define asd signed QP;scanf("%d",&QP);while(QP--)
typedef pair<int,int> PI;
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;}
int lowbit(int x){return x&-x;}
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
//
const double eps=1e-6;
const int mod=1e9+7;
const int modd=mod-1;
//
const int maxm=1e5+5;


void solve(){
    map<string,int>a;
    int n=re;ff(i,n){
        str s;cin>>s;
        a[s]++;
    }
    pr(SZ(a));
}
signed main(){
//    while(1)
//    asd
        solve();
    return 0;
}
/*

*/


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


int main(){
  int n,m;
  cin >>n>>m;
  int sum = n*(n-1)/2+m*(m-1)/2;
  cout <<sum<<endl;

}


Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;


    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int lenS = S.Length;

            string[] str = new string[lenS];

            for(int i=0; i<lenS; i++){
                str[i] = "x";
            }

            string output = String.Join("", str);

            Console.WriteLine(output);
        }
    }

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

int main(){
  unsigned long long a, b, n; cin >> a >> b >> n;
  if (b > n)cout << (a * n)/b - a * (n / b) << endl;
  else cout << (a * (b - 1))/b - a * ((b - 1) / b) << endl;
  
  return 0;
}

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

int main(){
	int a;
  cin >> a;
  a = a%10;
  if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon";
  else if (a == 3) cout << "bon";
  else cout << "pon";
}


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
ll inv (ll b) { return po(b,MOD-2); }

ll ad(ll a, ll b) { return (a+b)%MOD; }
ll sub(ll a, ll b) { return (a-b+MOD)%MOD; }
ll mul(ll a, ll b) { return a*b%MOD; }

int N,K;
map<int,int> num;
vi divi;

ll solve() {
    ll ans = 0;
    for (int i: divi) {
        num[i] = po(K,(i+1)/2);
        for (int j: divi) if (i % j == 0 && j != i) num[i] = sub(num[i],num[j]); 
        if (i&1) ans = ad(ans,mul(i,num[i]));
        else ans = ad(ans,mul(i/2,num[i]));
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    for (int i = 1; i*i <= N; ++i) {
        if (N % i == 0) {
            divi.pb(i);
            divi.pb(N/i);
        }
    }
    sort(all(divi)); divi.erase(unique(all(divi)),divi.end());
    cout << solve();
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

double diff(double x,double y){
	return (x > y)?x-y:y-x;
}
int main(){
	int n,i;
	double p1=0.0,p2=0.0,p3=0.0,p_et=0.0;
	scanf("%d",&n);
	double x[1001]={},y[1001]={};
	for(i=0;i<n;i++)	scanf("%lf",&x[i]);
	for(i=0;i<n;i++)	scanf("%lf",&y[i]);
	for(i=0;i<n;i++){
		p1 += diff(x[i],y[i]);
		p2 += pow(diff(x[i],y[i]),2);

		p3 += pow(diff(x[i],y[i]),3);

		if (p_et < diff(x[i],y[i])) p_et = diff(x[i],y[i]);
	}
	p2 = sqrt(p2);
		p3 = pow(p3,1.0/3.0);
	printf("%f\n",p1);
	printf("%f\n",p2);
	printf("%f\n",p3);
	printf("%f\n",p_et);
	return 0;
}

Measured memory_bytes: 732
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ll ret=(ar+((br-ar))*moddiv(1,a,b)%b*a)%(a*b);
  return ret;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0)-1+val0*val1;
        ll ans1=garner2(val0,val1,0,1)-1+val0*val1;
        ans0%=val0*val1;
        ans1%=val0*val1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


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

Measured memory_bytes: 7052
#include<stdio.h>
#define N 100001

void Quicks(int p,int r);

int P(int p, int r);

struct Card{
  int num;
  char ch;
  int m;
};

struct Card A[N];
int main(){
  int i,j,n,f=0;
  char m1,m2,m3;
  scanf("%d%c",&n,&m1);
  for(i=1;i<=n;i++){
    scanf("%c%c%d%c",&A[i].ch,&m2,&A[i].num,&m3);
    A[i].m = i;
  }
  j = P(1,n);
  Quicks(1,n);
  for(i=1;i<n;i++){
    if((A[i].m > A[i+1].m) && (A[i].num == A[i+1].num)){
      f = 1;
      break;
    }
  }
  if(f == 1)
    printf("Not stable\n");
  else printf("Stable\n");
  for(i=1;i<=n;i++)
    printf("%c %d\n",A[i].ch,A[i].num);
  return 0;
} 
int P(int p, int r){
  int i,j;
  struct Card x,tmp1,tmp2;
  x.num = A[r].num;
  i = p -1;
  for(j = p; j <= r-1; j++){
    if(A[j].num <= x.num){
      i = i + 1;
      tmp1 = A[i];
      A[i] = A[j];
      A[j] = tmp1;
    }
  }
  tmp2 = A[i + 1];
  A[i+1] = A[r];
  A[r] = tmp2;
    
  return i + 1;
}
void Quicks(int p,int r){
  int q;
  if(p < r){
    q =  P(p,r);
    Quicks(p,q-1);
    Quicks(q+1,r);
  }
}



Measured memory_bytes: 2872
#include<iostream>
using namespace std;
int main(){
    string a;
    long long int result=0,B_num=0;
    cin>>a;
    for(int i=0;i<a.length();i++){
        if(a[i]=='B')B_num++;
    }
    for(int i=0;i<a.length();i++){
        if(a[i]=='B'){
            result+=(a.length()-B_num-i);
            B_num-=1;
        }
    }
    cout<<result<<endl;
}

Measured memory_bytes: 640
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

#define INF 100000

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for (int i = 0; i < N; i++)cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x = 1;
        for (int j = 1; i+j < N; j++) {
            if (a[i + j] - a[i] <= 2)x++;
            else break;
        }
        ans = max(ans, x);

        for (int j = 1; j + i < N; j++) {
            if (a[i] != a[i + j] || i + j + 1 == N) {
                i += j - 1;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{

  ll n;
  read(n);
  vt<ll>v(n),prefix(n,0);
  read(v);
 
  ll ans= 0;
  prefix[0] = v[0];
  rep(i,1,n)
  prefix[i] = (prefix[i-1]%mod + v[i]%mod)%mod;
 
  rep(i,0,n-1)
    ans=(ans%mod + (v[i]%mod*(prefix[n-1]-prefix[i]+mod)%mod)%mod)%mod;
  cout<<ans;
}


 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




Measured memory_bytes: 6336
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

var a = Int(split[0])!
let b = Int(split[1])!
var c = Int(split[2])!
let d = Int(split[3])!


var ans = "Yes"

var ta = 0

while ta >= 0 {
    a -= d
  if a <= 0 { break }
    ta += 1
}

var ao = 0

while ao >= 0 {
    c -= b
  if  c <= 0 { break }
    ao += 1
}

if ao > ta {
    ans = "No"
}


print(ans)

Measured memory_bytes: 14072
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> P(n);
    rep(i, n) {
        ll a;
        cin >> a;
        P[i] = (a + 1);
    }
    vector<ll> V(n + 1);
    V[0] = 0;
    rrep(i, n) {
        V[i] = P[i - 1] + V[i - 1];
    }
    ll ans = -1;
    for(int i = 0; i + k <= n; i++) {
        ll sum;
        sum = V[i + k] - V[i];
        ans = max(ans, sum);
    }
    cout << fixed << setprecision(10) << (double)ans / 2 << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,s=0;
pair<ll,ll>a[200000];
int32_t main(){
CODE_START;
cin>>n;
for(ll i=0;i<n;i++)
    cin>>a[i].s>>a[i].f;
sort(a,a+n);
for(ll i=0;i<n;i++)
{
    s=s+a[i].s;
    if(s>a[i].f){
        rc("No");
    }
}
cout<<"Yes";
return 0;}


Measured memory_bytes: 3328
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 305;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
vector<vector<vector<double>>> dp(N, vector<vector<double>>(N, vector<double>(N, 0.0)));
vector<vector<vector<ll>>> vis(N, vvl(N, vl(N)));
vl state(4, 0);
ll n;
double solve(ll i, ll j, ll k)
{
	if (i + j + k == 0)
		return 0.0;
	if (vis[i][j][k] == 1)
		return dp[i][j][k];
	vis[i][j][k] = 1;
	double E_x = n * 1.0 / (i + j + k);
	double res = 0.0;
	if (i > 0)
		res += solve(i - 1, j, k) * i / (i + j + k);
	if (j > 0)
		res += solve(i + 1, j - 1, k) * j / (i + j + k);
	if (k > 0)
		res += solve(i, j + 1, k - 1) * k / (i + j + k);
	res += E_x;
	return dp[i][j][k] = res;
}
signed main() {

	fast
	cin >> n;
	loop(i, n)
	{
		ll x;
		cin >> x;
		++state[x];
	}
	double ans = solve(state[1], state[2], state[3]);
	cout << fixed << setprecision(10) << ans << END;




	return 0;
}

Measured memory_bytes: 452860
// 2004à\IC Unit Fraction Partition

#include <iostream>
#include <cmath>

using namespace std;

const double EPS = 1e-12;

int p, q, a, n, c;
double d;

void solve(int s, int t, double sum, int m){
	if(m==n) return;
	for(int i=s;;i++){
		if(t*i>a) break;
		if(abs(d - (sum + 1.0/i)) < EPS) c++;
		if(d - (sum + 1.0/i) > EPS) solve(i,i*t,sum+1.0/i,m+1);
	}
}

int main(){
	while(cin >> p >> q >> a >> n){
		if(!p) break;
		d = (double)p/q;
		c = 0;
		solve(1,1,0.0,0);
		cout << c << endl;
	}
}

Measured memory_bytes: 868