akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a){
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};

mint factorial(int n){
    mint res = 1;
    for(int i=1;i<=n;i++){
        res *= i;
    }
    return res;
}
 
int main(void){
    int n, m;
    cin>>n>>m;
    mint ans;
    int big=max(n, m);
    int small=min(n, m);
    if(big==small){
        ans = factorial(n)*factorial(m);
        ans*=2;
    }
    else if(big == small+1){
        ans = factorial(n)*factorial(m);
    }
    else ans = 0;
    cout<<ans.x<<endl;
    return 0;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/


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

    int n, c, k;
    cin>>n>>c>>k;
    vector<int> t(n);
    for (int i = 0; i<n; i++) cin>>t[i];
    sort(t.begin(), t.end());

    int ans = 0;
    int cur = 0;
    while (cur<n)
    {
        int T = t[cur] + k;
        ans++;
        int take = 0;
        while (take<c && cur<n && t[cur]<=T) {take++; cur++;}
    }
    cout<<ans;



}



Measured memory_bytes: 640
N = int(input())
L = [str(input()) for i in range(N)]
M = []

for l in L:
    m = ''.join(sorted(l))
    M.append(m)

import collections
c = collections.Counter(M)
d = list(c.values())
e = []
for i in range(len(d)):
    e.append(sum(range(1,d[i])))

print(sum(e))

Measured memory_bytes: 26960
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k,l;
	int n;
	sd(n);
	int t=0,x=0,y=0;
	for(i=1;i<=n;i++)
	{
		sd(j);
		sd(k);
		sd(l);
		if(abs(k-x)+abs(l-y)>j-t||(j-t-(abs(k-x)+abs(l-y)))%2)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i == 0){
            printf("\n");
        }else{
            printf(" ");
        }
    }
    return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
   int a, b;
   cin >> a >> b;
   int total = 0;
   if(a >= b){
       total += a;
       if(a-1 > b){
           total += a-1;
       }else{
           total += b;
       }
   }else{
       total += b;
       if(b-1 > a){
           total += b-1;
       }else{
           total += a;
       }
   }
   cout << total << endl;
}

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

vector<bool> Prime;
void initPrime(long num) {
	Prime = vector<bool>(num + 1, true);
	Prime[1] = Prime[0] = false;
	long sq_num = sqrt((double)num);
	for (long i = 2; i < sq_num; i++) {
		if (Prime[i]) {
			for (long j = i + i; j <= num; j += i) {
				Prime[j] = false;
			}
		}
	}
}

int main(void) {
	initPrime(1000000);
	int a, d, n;
	while (cin >> a >> d >> n, a) {
		long res = a;
		for (int i = 0; i < n; i++) {
			while (!Prime[res]) {
				res += d;
			}
			if (i != n - 1) {
				res += d;
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    vector<double> X(3);
    vector<double> Y(3);
    for(int i=0; i<3; i++){
        cin >> X[i] >> Y[i];
    }
    
    
    vector<double> E(3);
    E[0] = sqrt((Y[1]-Y[0])*(Y[1]-Y[0]) + (X[1]-X[0])*(X[1]-X[0]));
    E[1] = sqrt((Y[2]-Y[1])*(Y[2]-Y[1]) + (X[2]-X[1])*(X[2]-X[1]));
    E[2] = sqrt((Y[0]-Y[2])*(Y[0]-Y[2]) + (X[0]-X[2])*(X[0]-X[2]));
    
    double mx = *max_element(E.begin(), E.end());
    double s = (E[0]+E[1]+E[2])/2;
    double area = sqrt(s*(s-E[0])*(s-E[1])*(s-E[2]));
    double r = 2 * area / (E[0]+E[1]+E[2]);

    cout << fixed << setprecision(20) << r*mx / (2*r + mx) << endl;
    
    
    
    return 0;
}


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

int main() {
  int a, b, ans;
  string op;
  while (true) {
    cin >> a >> op >> b;
    if (op == "?") break;
    if (op == "+") ans = a + b;
    else if (op == "-") ans = a - b;
    else if (op == "*") ans = a * b;
    else if (op == "/") ans = a / b;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3168
n = int(input())
a=[]
for i in range(n):
  tmp = input()
  a.append(tmp)
  
dic = {i:0 for i in set(a)}

for i in range(n):
  dic[a[i]] = dic[a[i]]+1  

max_v = 0
for k in dic:
  if dic[k]>max_v:
    max_v = dic[k]

max_items = []
for k in dic:
  if dic[k]==max_v:
    max_items.append(k)

max_items.sort()
for item in max_items:
  print(item)

Measured memory_bytes: 49424
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

void Main() {
    // input
    string S, T;
    cin >> S;
    cin >> T;


    // process
    int l = 1001;
    for (u_int16_t i = 0; i <= S.length() - T.length(); i++) {
        int tmp = 0;
        for (u_int64_t j = 0; j < T.length(); j++) {
            if (S[i+j] != T[j]) {
                tmp++;
            }
        }
        l = min(l, tmp);
    }


    // output
    cout << l << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main(){
    ll n; cin >> n;
    ll a[n]; rep(i,0,n) cin >> a[i];

    // 因数に2を含むなら、隣の因数は2じゃないと4の倍数にならない
    // 因数に4を含むなら、隣の因数は1でも4の倍数になる
    // 各a[i]の因数をチェック
    // 因数に2も4も含まないのがn/2より多くある = 構成不可能
    //                     n/2より少ない = それをkとすると4の因数を持つものもk必要
    //実は、nが奇数ならinsu[0]の条件は緩和される
    //n=3のとき、insu[0]は2まで許容されるし、insu[2]はinsu[0]-1まで許容される
    ll insu[3] = {0,0,0}; //因数に2も4も含まない、2は含む、4も含むa[i]の数
    rep(i,0,n){
        if(a[i] % 4 == 0) insu[2]++;
        else if(a[i] % 2 == 0) insu[1]++;
        else insu[0]++;
    }
    if(insu[1] != 0) insu[0]++;
    if(insu[0] <= insu[2] + 1) cout << "Yes" << ednl;
  	else cout << "No" << endl;
}


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

int main() {
  int N,K,x,a=0;
  cin >> N >> K;
  while(N--){
    cin >> x;
    if(x < (K-x))
      a += x*2;
    else
      a += (K-x)*2;
  }
  cout << a << endl;
}


Measured memory_bytes: 3572
#include<stdio.h>
#include<stdbool.h>
#define MAX 1000
#define VMAX 10000

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

void sort(int A[])
{
	int temp;
	
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++)
		{
			if(A[i] > A[j])
			{
				temp = A[i];
				A[i] = A[j];
				A[j] = temp;
			}
		}
	}
}

int min(int a, int b)
{
	if(a < b) return a;
	else return b;
}

int solve(){
	int ans = 0;
	
	bool V[MAX];
	for(int i = 0; i < n; i++)
	{
		B[i] = A[i];
		V[i] = false;
	}
	sort(B);
	for(int i = 0 ; i < n; i++)
	{
		T[B[i]] = i;
	}
	for(int i = 0; i < n; i++)
	{
		if(V[i]) continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while(1)
		{
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if(V[cur]) break;
		}
		ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
	}
	return ans;
}


int main(void)
{
	scanf("%d", &n);
	s = VMAX;
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
		s = min(s, A[i]);
	}
	int ans = solve();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll sq(ll x){
	return x * x % MOD;
}

ll mod_pow(ll x,ll p){
	if(p == 0)return 1;
	return ((p&1?x:1LL) * sq(mod_pow(x,p/2))) % MOD;
}

ll eval(ll n){
	return (n * n * (n + 1)/2 - n * (n + 1) * (2*n +1)/6) % MOD;
}

int main(){
	fast_io();
	ll n,m,k;
	cin >> n >> m >> k;
	vector<ll> frac(200005),inv(200005);
	frac[0] = 1;	
	inv[0] = 1;	
	fu(i,1,m*n){
		frac[i] = frac[i-1] * i % MOD;
		inv[i] = mod_pow(frac[i], MOD - 2);
	}
	ll sum = sq(m) * eval(n) + sq(n) * eval(m);
	sum %= MOD;
	ll comb = frac[n*m - 2] * inv[n*m - k] % MOD;
	comb = comb * inv[k - 2] % MOD;
	sum *= comb;
	sum %= MOD;
	cout << sum << '\n';
}


Measured memory_bytes: 3328
import os, sys, re, math

N,M = list(map(int,input().split(' ')))
ary = list(map(int,input().split(' ')))

s = [0 for i in range(N+1)]
for i in range(N):
    s[i+1] = (ary[i] + s[i]) % M

m_map = {}

for j in range(0,N+1):
    if s[j] in m_map:
        m_map[s[j]] += 1
    else:
        m_map[s[j]] = 1

ret = 0
for i,v in m_map.items():
    if v >= 2:
        ret += v * (v-1) // 2
print(ret)


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

int main() {
	long long a, b;
	cin >> a >> b;
	if (a*b > 0) {
		if (a > 0) {
			cout << "Positive" << endl;
			return 0;
		}
		else if (b < 0) {
			if ((b - a + 1) % 2 == 0) {
				cout << "Positive" << endl;
			}
			else {
				cout << "Negative" << endl;
			}
		}
	}
	else {
		cout << "Zero" << endl;
		return 0;
	}
}

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

using namespace std;

long f(long x) {
	if (x % 4 == 1) return 1;
	if (x % 4 == 3) return 0;
	return x + 1 ^ f(x + 1);
}
int main() {
	long a, b;
	cin >> a >> b;
	if (a) a--;
	cout << (f(a) ^ f(b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+3;
typedef long long ll;
int n;
int main(){
	scanf("%d",&n);
	ll sum=0;
	for(int i=1;i<=n;i++)
	sum+=1ll*(1+n/i)*(n/i)/2*i;
	cout<<sum<<endl;
	
	
}

Measured memory_bytes: 3744
package main

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

func main() {
	nextReader = NewScanner()
	line1 := nextInt()
	line2 := nextInt()

	// 全てのマス
	all := line1[0] * line1[1]

	//黒
	count1 := line1[1]*line2[0] + line2[1]*line1[0] - (line2[0] * line2[1])

	fmt.Println(all - count1)
}

// ------ Mathライブラリ ---------------------------------//
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ------ Mathライブラリ ---------------------------------//

// ----- 標準入力用の関数 ----------------------------------//
var nextReader func() []string

func NewScanner() func() []string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	return func() []string {
		r.Scan()
		return strings.Fields(r.Text())
	}
}

func nextString() []string {
	return nextReader()
}

func nextInt() []int {
	var intArray []int
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.Atoi(v)
		intArray = append(intArray, i)
	}
	return intArray
}

func nextFloat64() []float64 {
	var floatArray []float64
	strArray := nextReader()
	for _, v := range strArray {
		f, _ := strconv.ParseFloat(v, 64)
		floatArray = append(floatArray, f)
	}
	return floatArray
}

// ------ 標準入力用の関数 ---------------------------------//

// ------ あまり使わない -----------------------------------//
func nextInt64() []int64 {
	var int64Array []int64
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.ParseInt(v, 10, 64)
		int64Array = append(int64Array, i)
	}
	return int64Array
}

// ------ あまり使わない -----------------------------------//


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

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int N = 2000;

int A[20];
int n;

bool ExhaustiveSearch(int m, int i)
{
    if (m == 0)
    {
        return true;
    }
    if (m < 0 || i >= n)
    {
        return false;
    }

    return ExhaustiveSearch(m - A[i], i + 1) || ExhaustiveSearch(m, i + 1);
}

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

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    int k;
    cin >> k;
    for (int i = 0; i < k; i++)
    {
        int tmp;
        cin >> tmp;
        if (ExhaustiveSearch(tmp, 0))
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3212
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

int n, a, b;
int h[100010];

bool enough(ll t) {
	ll times = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] - b * t < 0)continue;
		times += ((h[i] - b * t) + (a - b - 1)) / (a - b);
	}
	return times <= t;
}

int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> h[i];

	ll left = 0, right = INF;
	while (right - left > 1) {
		ll mid = (left + right) / 2;
		if (!enough(mid))left = mid;
		else right = mid;
	}

	cout << right << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N;
    vec minus(N), plus(N);
    rep(i,N){
        cin>>A>>B;
        minus[i] = A - B;
        plus[i] = A + B;
    }
    ll res = max(*max_element(ALL(minus)) - *min_element(ALL(minus)), *max_element(ALL(plus)) - *min_element(ALL(plus)));
    cout<<res<<endl;
}

Measured memory_bytes: 6432
#include "bits/stdc++.h"
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  long long int n;
  while(cin>>n){
    for(int i=n-1;i>1;i--){
      if(IsPrime(i)){
        cout<<i<<" ";
        break;
      }
    }
    for(int i=n+1;;i++){
      if(IsPrime(i)){
        cout<<i<<endl;
        break;
      }
    }
  }
}



Measured memory_bytes: 3012
N = int(input())
happiness = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(3)] for _ in range(N+1)]

dp[0] = happiness[0]

for i in range(1, N):
    for j in range(3):
        for k in range(3):
            dp[i][j] = max(dp[i][j], (dp[i-1][k]+happiness[i][j])*(j != k))

print(max(dp[N-1]))




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

int main() {
	int n, x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i];
	for (int i = 0; i < n; i++)cin >> y[i];

	double d[4];
	for (int i = 0; i < 4; i++)d[i] = 0.0;

	for (int p = 1; p <= 3; p++) {
		for (int i = 0; i < n; i++) {
			d[p] += pow(fabs(x[i] - y[i]), p);
		}
		d[p] = pow(d[p], 1.0 / p);
	}
	for (int i = 0; i < n; i++) {
		d[0] = (d[0] < fabs(x[i] - y[i]) ? fabs(x[i] - y[i]) : d[0]);
	}
	printf("%1f\n",d[1]);
	printf("%1f\n",d[2]);
	printf("%1f\n",d[3]);
	printf("%1f\n",d[0]);

	return 0;
}

Measured memory_bytes: 3336
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
dp = [float('inf')]*n
for i in range(n):
  c = a[n-i-1]
  b = bisect.bisect_right(dp,c)
  if dp[b] > c:
    dp[b] = c
print(bisect.bisect_right(dp,10**9+1))

Measured memory_bytes: 7840
import java.io.BufferedReader
import java.io.InputStreamReader

var cnt = 0

fun insertionSort(a: IntArray, g: Int) {
    for (i in g until a.size) {
        val pivotVal = a[i]
        var pivotIdx = i-g
        while (pivotIdx >= 0 && a[pivotIdx] > pivotVal) {
            a[pivotIdx+g] = a[pivotIdx]
            pivotIdx -= g
            cnt++
        }
        a[pivotIdx+g] = pivotVal
    }
}

fun shellSort(a: IntArray): List<Int> {
    val gs = generateSequence(seed = 1, nextFunction = { 3 * it + 1 })
            .takeWhile { it <= a.size }
            .toList()

    for (i in gs.size-1 downTo 0) {
        insertionSort(a, gs[i])
    }

    return gs
}

fun main(args: Array<String>) {
    val a = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())
            .drop(n = 1)
            .map { it.toInt() }
            .toIntArray()

    val gs = shellSort(a)
    println(gs.size)
    println(gs.reversed().joinToString(" "))
    println(cnt)
    println(a.joinToString("\n"))
}


Measured memory_bytes: 277820
#include<bits/stdc++.h>
using namespace std;
int a[100005],flag,n,m;
int main (void){
    while(cin>>n && n){
        int sum=0,num=0;
        for(int i=1;i<=n;i++){
            cin>>m;
            if(m%2==0)a[i]=m/2;
            else a[i]=0;
            if(m%4==0)sum++;
        }
        for(int i=1;i<=n;i++){
            if(a[i]%2!=0)num++;
        }
        if((sum+num/2)>=n/2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
  {int A, B, C, D; cin >> A >> B >> C >> D;
  while (true)
    {C -= B; if (C <= 0) {puts("Yes"); return 0;}
    A -= D; if (A <= 0) {puts("No"); return 0;}}}

Measured memory_bytes: 3672
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        cout << "3C";
        cout << setw(2) << setfill('0') << right;
        if(n % 39)
            cout << n % 39 << endl;
        else
            cout << 39 << endl;
    }
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

#define FOR(i, a, b) for(int i=a; i<b; i++)
#define FOR1(i, a, b, flag) for(int i=a; i<b && flag; i++)
// #define comb(a, b) (fact(a)*power(b, c-2)*power(a-b, c-2))
typedef long long ll;

int c=1000000007;

// int power(int &x, int r){
//     if(x==0)
//         return 1;
//     if(r&1)
//         return ((ll)x*power(x, r-1))%c;
//     int y=power(x, r/2);
//     return ((ll)y*y)%c;
// }

// vector<int> mem;
// int fact(int x){
//     if(x==0)
//         return 1;
//     if(mem.size()>=x){
//         return mem[x-1];
//     }
//     mem.push_back(((ll)x*fact(x-1))%c);
// }

// int ways(int l, int r, string &s){
//     if(l>r)
//         return 1;
//     int ans=0;
//     FOR(i1, l, r){
//         if(s[l]=='<' && s[r]=='>'){
//             ans=(ans+()((ll)ways(l, i1-1)*ways(i1+1, r))%c)%c;
//         }
//     }
//     if(s[l]=='>'){
//         ans=(ans+ways(l+1, r))%c;
//     }
//     if(s[r]=='<'){
//         ans=(ans+ways(l, r-1))%c;
//     }
// }

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    getline(cin, s);
    getline(cin, s);
    
    int dp[n]={0};
    dp[0]=1;
    FOR(i1, 0, n-1){
        if(s[i1]=='>'){
            // int temp=0;
            for(int i2=i1; i2>=0; i2--){
                // swap(dp[i2], temp);
                dp[i2]+=dp[i2+1];
                dp[i2]%=c;
            }
            dp[i1+1]=0;
        }
        else{
            int temp=0;
            FOR(i2, 1, i1+2){
                swap(dp[i2], temp);
                dp[i2]+=dp[i2-1];
                dp[i2]%=c;
            }
            dp[0]=0;
        }
    }
    int ans=0;
    FOR(i1, 0, n){
        ans+=dp[i1];
        ans%=c;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const ll maxn=1100ll;
const ll mod=(ll)1e9+7ll;

ll H,W;
char s[maxn][maxn];
ll dp[maxn][maxn];

void solve(){
    dp[0][1]=1ll;
    for(ll i=1;i<=H;i++){
        for(ll j=1;j<=W;j++){
            if(s[i][j]=='.'){
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    printf("%lld\n",dp[H][W]);
}

int main(void){
    scanf("%lld %lld",&H,&W);
    for(ll i=1;i<=H;i++){
        scanf("%s",s[i]+1);
    }
    solve();
    return 0;
}

Measured memory_bytes: 10752
H1, M1, H2, M2, K = map(int, input().split())
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

#K = int(input())
#S = input()

if (H2*60+M2>=H1*60+M2):
    print((H2*60+M2)-(H1*60+M1)-K)
else:
    print((H2*60+M2)+(24*60)-(H1*60+M2)-K)

Measured memory_bytes: 9176
import java.util.*;
import java.util.regex.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt(),n = sc.nextInt(),a,b,z;
    int[] amida = new int[w];
    for(int i=0;i<w;i++)amida[i]=i+1;
    for(int i=0;i<n;i++){
      String s = sc.next();
      Pattern pattern = Pattern.compile("\\D");
      String[] splitStr = pattern.split(s);
      a = Integer.parseInt(splitStr[0]);
      b = Integer.parseInt(splitStr[1]);
      z = amida[a-1];
      amida[a-1] = amida[b-1];
      amida[b-1] = z;
    }
    for(int i=0;i<w;i++)System.out.println(amida[i]);
    sc.close();
  }
}


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

int main(){
    int n;
    cin>>n;
    int x,y;
    x=800*n;
    y=200*(n/15);
    cout<<x-y<<endl;
    return 0;
}

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())
#define retunr return

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.txt", "rt", stdin);

	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
		
	sort(v.begin(), v.end());
	bool stop = false;
	for(int i = 1; i < n && stop == false; i++) {
		if(v[i-1] == v[i])
			stop = true;
	}
	
	if(stop == false)
		cout << "YES";
	else
		cout << "NO";

	return 0;
}


Measured memory_bytes: 1024
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let mut acc = vec![0; N + 1];
    for i in 0..N {
        acc[i + 1] = acc[i] + A[i];
    }

    // dp[l][r] : 区間 l..r を1個のスライムにするときにかかる最小のコスト
    let mut dp = vec![vec![std::i64::MAX; N + 1]; N + 1];

    // dp[l][l + 1] = 0
    // dp[l][r] = dp[l][m] + dp[m][r] + acc[r] - acc[l]

    for h in 1..N + 1 {
        for l in 0..N {
            let r = l + h;
            if r > N {
                continue;
            }

            if h == 1 {
                dp[l][r] = 0;
                continue;
            }

            for m in l + 1..r {
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r] + acc[r] - acc[l])
            }
        }
    }

    debug!(acc, dp);

    println!("{}", dp[0][N])
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N;
  int digit = 0;
  int count= 0;
  int i;
   scanf("%d", &N);
  
if(N<10){
  digit = N;
}else if (N <100){
  digit  =9;
}else if(N < 1000){
  digit = 9 + (N -99); 
}else if(N < 10000){
  digit = 909;
}else if(N < 100000){
  digit = 909 + (N - 9999);
}else if(N == 100000){
  digit = 90909;
}
printf("%d", digit);
return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void BubbleSort(int, int);
void SelectionSort(int, int);

struct Card{
    char pic, val;
};

void swap(Card* a, Card* b){
    Card tmp = *a;
    *a = *b;
    *b = tmp;
}

void printResult(Card* Seq, int n){
    for(int i=0; i<n; i++){
        if(i != n-1){
            cout << Seq[i].pic << Seq[i].val << " ";
        }else{
            cout << Seq[i].pic << Seq[i].val << endl;
        }
    }
}

void BubbleSort(Card* Seq, int n){
    for(int i=0; i<n; i++){
        for(int j=n-1; j>i; j--){
            if(Seq[j].val < Seq[j-1].val){
                swap(&Seq[j], &Seq[j-1]);
            }
        }
    }
}

void SelectionSort(Card* Seq, int n){
    int mini;
    for(int i=0; i<n; i++){
       mini = i;
       for(int j=i; j<n; j++){
           if(Seq[j].val < Seq[mini].val){
               mini = j;
           }
       }
       swap(&Seq[i], &Seq[mini]);
    }
}

bool checkstable(Card* c1, Card* c2, int n){
    for(int i=0; i<n; i++){
        if(c1[i].val == c2[i].val && c1[i].pic != c2[i].pic) return false;
    }
    return true;
}

int main(){

    int n; 
    cin >> n;

    auto c1 = new Card[n];
    auto c2 = new Card[n];
    for(int i=0; i<n; i++){
        cin >> c1[i].pic >> c1[i].val;
        c2[i] = c1[i];
    }

    BubbleSort(c1, n);
    printResult(c1, n);
    cout << "Stable" << endl;

    SelectionSort(c2, n);
    printResult(c2, n);
    if( checkstable(c1, c2, n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
n, m = map(int, input().split())

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)


Measured memory_bytes: 6012
loop do
  x = gets.split(" ")
  a  = x[0].to_i
  op = x[1]
  b  = x[2].to_i

  case op
    when "?" then
      break
    when "+" then
      puts a + b
    when "-" then
      puts a - b
    when "*" then
      puts a * b
    when "/" then
      puts a / b
  end

end


Measured memory_bytes: 6872
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll A, B;
    cin >> A >> B;


    if(A == B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
        cout << s[i][j];
      } else {
        int sum = 0;
        for (int k = -1; k <= 1; k++) {
          for (int l = -1; l <= 1; l++) {
            if (i + k >= 0 && i + k < H) {
              if (j + l >= 0 && j + l < W) {
                if (s[i + k][j + l] == '#') {
                  sum++;
                }
              }
            }
          }
        }
        cout << sum;
      }
    }
    cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<ll> mp(1000005);
    ll ans = 0;
    rep(i, n){
        if(mp[a[i]] != 0){
            mp[a[i]] = 2;
            continue;
        }
        for(int j = a[i]; j <= 1000000; j += a[i]){
            mp[j]++;
        }
    }
    rep(i, n){
        if(mp[a[i]] == 1) ans++;
    }
    print(ans);

}



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

int main() {
	string N;
	int c = 0;
	cin >> N;

	rep(i,4)
		c += (N.at(i)=='2');
	cout << c << endl;
}

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

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

    bool L[10][10];
    memset(L, false, 100);
    bool M[10][10][10];
    memset(M, false, 1000);

    bool prev[10];
    memset(prev, false, 10);

    prev[S[0] - '0'] = true;
    prev[S[1] - '0'] = true;
    L[S[0] - '0'][S[1] - '0'] = true;

    for (int i = 2; i < N; ++i) {
        int c = S[i] - '0';
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                if (prev[k] && L[k][j]) M[k][j][c] = true;
            }
        }
        for (int j = 0; j < 10; ++j) {
            if (i < N - 1 && prev[j]) L[j][c] = true;
        }
        if (i < N - 2) prev[c] = true;
    }

    int ans = 0;

    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                if (M[i][j][k]) ++ans;
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
int main()
{
  int i,j,k=0,a,l;
  int A[MAX];

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

  for(i=0;i<l;i++){
    for(j=l-1;j>i;j--){
      a=A[j-1];
      if(a>A[j]){
        A[j-1]=A[j];
	A[j]=a;
        k++;
      }
    }
    printf("%d",A[i]);
    if(i != l-1){
      printf(" ");
    }
  }
  printf("\n%d\n",k);

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
int main()
{
    int N, R;
    cin >> N >> R;
    if(N>=10){
        cout << R << endl;
    }
    else{
        cout << R+100*(10-N) <<endl;
    }
}

Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;


ll n,m,x;
ll c[15];
ll a[15][15];
ll t[15];

ll ret(ll bi){
    rep(i,15) t[i]=0;
    ll sum = 0;
    rep(i,n){
        if(bi & (1<<i)){
            rep(j,m){
                t[j] += a[i][j];
            }
            sum += c[i];
        }
    }
    bool f = true;
    rep(i,m){
        if(t[i]<x){
            f= false;
            break;
        }
    }
    // printf("i: %lld  sum:%lld\n ",bi,sum);
    if(f) return sum;
    else return -3;
}

signed main(){
    cin>>n>>m>>x;
    rep(i,n){
        cin>>c[i];
        rep(j,m) cin>>a[i][j];
    }
    ll ans = mod9;
    ll tans = mod9;
    rep(i,(int)pow(2,n)){
        tans = ret(i);
        if(tans>=0) ans = min(tans,ans);
    }
    if(ans==mod9) ans = -1;
    cout<<ans<<endl;
}


Measured memory_bytes: 4100
s = input()
count = 0
ans = 0

for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
        count += 1
    else:
        ans = max(count,ans)
        count = 0

ans = max(count,ans)
count = 0

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;



int MOD=1000000007;
int main(void){
	long long N,cnt=0;
	cin >> N;
	string S;
	cin >> S;
	for(int i=0; i<=N-3; i++){
		if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
			cnt+=1;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n;
    cin >> n;
    string s;
    map <char,int> m[n];
    for (int i=0;i<n;i++){
        cin>>s;
        int l=sz(s);
        for (int j=0;j<l;j++){
            m[i][s[j]]++;
        }
    }
    vector<int> ans(26,0);
    
    for (char c='a',j=0;c<='z';c++,j++){
        int cnt=1000;
        for (int i=0;i<n;i++){
            cnt = min(m[i][c],cnt);
        }
        ans[j]=cnt;
    }
    for (int i=0;i<26;i++){
        for (int j=0;j<ans[i];j++){
          cout << (char) (i+'a');
        }
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, m;
  cin >> n >> m;
  V<int> a(m);
  REP(i, m) cin >> a[i];

  int ret = 0;
  REP(i, m) if(a[i] > m) ret++;
  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 3212
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)
	sum := 0
	for bit := 0; bit < (1 << uint(n-1)); bit++ { // 仕切りのパターンを全列挙する(仕切の数は文字列の長さ-1)
		l := 0                   // 仕切の左側の位置
		for r := 0; r < n; r++ { // 仕切の右側の位置をずらしていく
			if (bit & (1 << uint(r))) != 0 { // 位置rのbitが立っている
				v, _ := strconv.Atoi(s[l : r+1]) // s[l:r+1]を取り出す
				sum += v
				l = r + 1 // lの位置を進める
			}
		}
		v, _ := strconv.Atoi(s[l:n]) // 残りを全部足す
		sum += v
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
"""
A,B=map(int, input().split())

print(B if A >= 13 else 0 if A <= 5 else int(B/2))
"""
r,D,x2000=map(int, input().split())
xNext=x2000*r-D
for i in range(10):
  print(xNext)
  xNext=xNext*r-D

Measured memory_bytes: 2940