akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            long K = in.nextInt();
            int logs[] = CPUtils.readIntArray(N, in);

            long low = 1, high = 1_000_000_000 + 10;
            long answer = 0;
            while (low < high)
            {
                long mid = low + ((high - low) / 2);
                if (isOK(logs, K, mid))
                {
                    answer = high = mid;
                } else
                {
                    low = mid + 1;
                }
            }
            out.print(answer);
        }

        private boolean isOK(int[] logs, long k, long size)
        {
            long totalCuts = 0;
            for (int log : logs)
            {
                if (log > size)
                {
                    totalCuts += (log / size);
                }
            }
            return totalCuts <= k;
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 49396
n = int(input())
h = list(map(int, input().split())) + [0]

ans,cnt = 0, sum(h)
while cnt > 0:
    l, r = -1, n
    for num, i in enumerate(h):
        if (l == -1) and (i > 0):
            l = num
        if (l > -1) and (i == 0):
            r = num
            ans += 1
            cnt -= r - l
            for i in range(l, r):
                h[i] -= 1
            break
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

int n, k;
int h[N];

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i)
        scanf("%d", &h[i]);
    sort(h, h + n);
    long long ans = 0;
    for (int i = 0; i < n - k; ++i)
        ans += h[i];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

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

void north(int &f, int &s, int &u) {
    int t = f;
    f = 7 - u;
    u = t;
}

void east(int &f, int &s, int &u) {
    int t = u;
    u = 7 - s;
    s = t;
}

void west(int &f, int &s, int &u) {
    int t = s;
    s = 7 - u;
    u = t;
}

void south(int &f, int &s, int &u) {
    int t = u;
    u = 7 - f;
    f = t;
}

void right(int &f, int &s, int &u) {
    int t = s;
    s = 7 - f;
    f = t;
}

void left(int &f, int &s, int &u) {
    int t = f;
    f = 7 - s;
    s = t;
}

void solve2(int N) {
    int a[3];
    a[0] = 2; a[1] = 3; a[2] = 1;
    
    int u = 1;
    REP(i, N) {
        string s;
        cin >> s;
        if (s == "North") {north(a[0], a[1], a[2]); u += a[2];}
        if (s == "East") {east(a[0], a[1], a[2]); u += a[2];}
        if (s == "West") {west(a[0], a[1], a[2]); u += a[2];}
        if (s == "South") {south(a[0], a[1], a[2]); u += a[2];}
        if (s == "Right") {right(a[0], a[1], a[2]); u += a[2];}
        if (s == "Left") {left(a[0], a[1], a[2]); u += a[2];}
    }
    cout << u << endl;
}

int main() {
    int N;
    while(cin >> N, N) {
        solve2(N);
    }
    return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<ll> que;
  ll cnt = 0;
  vector<ll> p(A), q(B), r(C);
  FOR(i, A) cin >> p[i];
  FOR(i, B) cin >> q[i];
  FOR(i, C) cin >> r[i];
  sort(all(p), greater<ll>());
  sort(all(q), greater<ll>());
  sort(all(r), greater<ll>());
  FOR(i, X) que.push(p[i]);
  FOR(i, Y) que.push(q[i]);
  FOR(i, C) que.push(r[i]);
  ll ans = 0;
  FOR(i, X + Y) {
    ans += que.top();
    que.pop();
  }

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

Measured memory_bytes: 8560
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 1e6;
const int N = 1e3 + 5, M = 35;
const ll INF = 1e15;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;

#define pi acos(-1)

int a[4][4];
int vis[N];
int v[N][N];

int main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int x;
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    while (n--)
    {
        int x;
        cin >> x;
        vis[x] = 1;
    }
    for (int i = 0; i < 3; i++)
    {
        vector<int> v;
        for (int j = 0; j < 3; j++)
        {
            v.push_back(a[i][j]);
        }
        int flag = 1;
        for (int j : v)
        {
            if (!vis[j])
                flag = 0;
        }
        if (flag)
        {
            puts("Yes");
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        vector<int> v;
        for (int j = 0; j < 3; j++)
        {
            v.push_back(a[j][i]);
        }
        int flag = 1;
        for (int j : v)
        {
            if (!vis[j])
                flag = 0;
        }
        if (flag)
        {
            puts("Yes");
            return 0;
        }
    }
    vector<int> v;
    for (int i = 0; i < 3; i++)
        v.push_back(a[i][i]);
    int flag = 1;
    for (int i : v)
    {
        if (!vis[i])
            flag = 0;
    }
    if (flag)
    {
        puts("Yes");
        return 0;
    }
    flag = 1;
    v.clear();
    for (int i = 0; i < 3; i++)
        v.push_back(a[i][3 - 1 - i]);
    for (int i : v)
    {
        if (!vis[i])
            flag = 0;
    }
    if (flag)
    {
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
alphabet = "abcdefghijklmnopqrstuvwxyz"
dic_all = {x: 51 for x in alphabet}

N = int(input())

for i in range(N):
    input_str = input()
    dic = {x: 0 for x in alphabet}
    for x in input_str:
        dic[x] = dic[x] + 1
    for a in dic:
        dic_all[a] = min(dic_all[a], dic[a])

result = ""
for x in alphabet:
    if(dic_all[x] <= 50):
        result = result + x * dic_all[x]

print(result)


Measured memory_bytes: 3064
package main

import "fmt"

type combo struct {
	S, T byte
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	combos := make([]combo, 0, 26)

	for i := 0; i < len(s); i++ {
		currentS, currentT := s[i], t[i]
		isAppearedCombo := false
		for j := range combos {
			tmpS, tmpT := s[j], t[j]
			switch {
			case tmpS == currentS && tmpT == currentT:
				isAppearedCombo = true
				break
			case tmpS != currentS && tmpT != currentT:
				continue
			default:
				fmt.Println("No")
				return
			}
		}
		if isAppearedCombo == true {
			continue
		}
		combos = append(combos, combo{S: currentS, T: currentT})
	}

	fmt.Println("Yes")
}


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

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

const int maxn = 200005;

int n, a[maxn], pmax[maxn], suf[maxn], res[maxn];
int len[2], p[2][maxn], Pmax[2][maxn], sum[2];

int rt[2][maxn], lch[maxn * 60], rch[maxn * 60], Max[maxn * 60], tot;

#define mid ((l + r) >> 1)

void insert(int &s, int l, int r, int p, int v)
{
	++tot;
	lch[tot] = lch[s]; rch[tot] = rch[s]; Max[tot] = Max[s];
	s = tot;
	if (l == r) return Max[s] = v, void();
	if (p <= mid) insert(lch[s], l, mid, p, v);
	else insert(rch[s], mid + 1, r, p, v);
	Max[s] = max(Max[lch[s]], Max[rch[s]]);
}

int query(int s, int l, int r, int ql, int qr)
{
	if (ql <= l && r <= qr) return Max[s];
	int res = 0;
	if (ql <= mid) res = max(res, query(lch[s], l, mid, ql, qr));
	if (qr >= mid + 1) res = max(res, query(rch[s], mid + 1, r, ql, qr));
	return res;
}

inline int check(int Id, int pos)
{
	int tmp = sum[Id] - sum[Id ^ 1] + suf[pos];
	if (tmp < 0) return 0;
	int res = query(rt[tmp & 1][pos], 1, n, Pmax[Id ^ 1][len[Id ^ 1]] + 1, n);
	return res >= tmp;
}

int main()
{	
	n = gi();
	for (int i = 1; i <= n; ++i) a[i] = gi(), pmax[i] = max(pmax[i - 1], a[i]);
	for (int i = n; i >= 1; --i) suf[i] = suf[i + 1] + (pmax[i] == a[i]);

	for (int i = n; i >= 1; --i) {
		int g0 = query(rt[0][i + 1], 1, n, a[i] + 1, n), g1 = query(rt[1][i + 1], 1, n, a[i] + 1, n);
		//printf("%d %d\n", g0, g1);
		if (pmax[i] == a[i]) {
			insert(rt[0][i] = rt[0][i + 1], 1, n, a[i], g0 + 2);
			if (g1) insert(rt[1][i] = rt[1][i + 1], 1, n, a[i], g1 + 2); else rt[1][i] = rt[1][i + 1];
		} else {
			insert(rt[1][i] = rt[1][i + 1], 1, n, a[i], g0 + 1);
			if (g1) insert(rt[0][i] = rt[0][i + 1], 1, n, a[i], g1 + 1); else rt[0][i] = rt[0][i + 1];
		}
	}

	fill(res + 1, res + n + 1, -1);
	for (int i = 1; i <= n; ++i) {
		for (int d = 0; d < 2; ++d) {
			p[d][++len[d]] = a[i];
			Pmax[d][len[d]] = max(Pmax[d][len[d] - 1], a[i]);
			sum[d] += Pmax[d][len[d]] == p[d][len[d]];

			if (check(0, i + 1)) {res[i] = d; break;}
			if (check(1, i + 1)) {res[i] = d; break;}

			sum[d] -= Pmax[d][len[d]] == p[d][len[d]];
			--len[d];
		}
		if (!~res[i]) return puts("-1"), 0;
	}

	for (int i = 1; i <= n; ++i) printf("%d", res[i]);
	
	return 0;
}


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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int l = 0, r = 0;
	rep(i, n) {
		if(s[i] == '(') {
			if(r == 0) {
				l++;
			} else {
				l++;
			}
		} else {
			if(l == 0) {
				r++;
			} else {
				l--;
			}
		}
	}
	rep(i, r) cout << '(';
	cout << s;
	rep(i, l) cout << ')';
	cout << endl;
	return 0;
}

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

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n  ;i++) 
    cin >> a[i];

    ll dp[n];
    dp[0] = 0;
    
    for(ll i = 1; i <n ; i++)
    {
        ll mini = 1e18;
        if(i-1 >= 0)
        mini = min(mini , dp[i-1]+abs(a[i]-a[i-1]));
        if(i-2 >= 0)
        mini = min(mini , dp[i-2]+abs(a[i-2]-a[i]));

        dp[i] = mini;
        
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1792
// AtCoder 第一回日本最強プログラマー学生選手権-予選-
	// A - Takahashi Calendar
    // 2019.9.9 bal4u
     
    #include <stdio.h>
     
    int main()
    {
    	int i, j, M, D, d1, d10, ans;
    	
		scanf("%d%d", &M, &D);
		ans = 0;
		for (i = 4; i <= M; i++) {
			for (j = 22; j <= D; j++) {
				d1 = j % 10, d10 = j / 10;
				if (d1 >= 2 && d10 >= 2 && d1*d10 == i) ans++;
			}
		}
		printf("%d\n", ans);
    	return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int jc[100005];
int ext_gcd(int a,int b,int &x,int &y){
    if(b==0){x=1;y=0;return a;}
    int q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;
    x=y; y=z;
    return g;
}
int inv(int a){
    int x,y;
    ext_gcd(a,mo_num,x,y);
    return (x+mo_num)%mo_num;
}
void init(int *x, int len){
    x[0]=1;
    for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%mo_num;
}

int C(int r,int n){
    if(n<0 or n<r or r<0)return 0;
    return (jc[n]*inv(jc[r])%mo_num)*inv(jc[n-r])%mo_num;
}

int32_t main(){
    cin>>n>>m;
    init(jc,2001);
    fum(i)out(C(i,n-m+1)*C(i-1,m-1)%mo_num)
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//




int dp[100010];
int main(){
        dp[0] = 0;
        for(int n = 1; n <= 100000; n++){
                dp[n] = 1e9;
                int power = 1;
                while(power <= n){
                        dp[n] = min(dp[n], dp[n-power]+1);
                        power *= 6;
                }
                power = 1;
                while(power <= n){
                        dp[n] = min(dp[n], dp[n-power]+1);
                        power *= 9;
                }
        }

        int n;
        cin >> n;

        cout << dp[n] << endl;
        return 0;
}






































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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int R, C, K;
  cin >> R >> C >> K;
  vll2(item, R+1, C+1, -1);
  rep(i,K){
    int a, b;
    ll v;
    cin >> a >> b >> v;
    item[a][b] = v;
  }

  vector<vector<vector<ll>>> dp(3010, vector<vector<ll>>(3010, vector<ll>(8, 0)));

  REP(i,1,R+1){
    REP(j,1,C+1){
      ll tmp=0;
      rep(k,4){chmax(tmp, dp[i-1][j][k]);}
      chmax(dp[i][j][0], tmp);
      if(item[i][j]>0) chmax(dp[i][j][1], tmp+item[i][j]);

      rep(k,4){
        chmax(dp[i][j][k], dp[i][j-1][k]);
        if(k!=0 && item[i][j]>0){
          chmax(dp[i][j][k], dp[i][j-1][k-1]+item[i][j]);
        }
      }
    }
  }

  ll ans=0;
  rep(i,4){
    chmax(ans, dp[R][C][i]);
  }
  prt(ans);
}


Measured memory_bytes: 994104
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define all(c) (c).begin(),(c).end()

using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  Real norm(){return sqr(x*x+y*y);}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に点tを角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}

  Line tangent(Real theta){
    Point a(r*cos(theta),r*sin(theta));
    Point b(a.y,-a.x);
    return Line(p+a,p+a+b);
  }
  
  vector<Line> commonTangent(Circle x){
    vector<Line>res;
    x.p=x.p-p;
    Real a=x.p.arg();
    Real b[2]={(r-x.r),(r+x.r)};
    for(int i=0;i<2;i++){
      b[i]/=x.p.norm();
      if(sgn(b[i],-1.0)<0 || sgn(b[i],1.0)>0)return res;
      Real c=asin(b[i])-asin(1.0);
      res.push_back(tangent(a-c));
      res.push_back(tangent(a+c));
    }
    return res;
  }
  
};

int n;
vector<Circle>c;
vector<Real>m;

vector<Line> enumerate(){
  vector<Line>res;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      vector<Line>tmp=c[i].commonTangent(c[j]);
      for(int k=0;k<tmp.size();k++){
	res.push_back(tmp[k]);
      }
      c[i].r+=m[i];
      tmp=c[i].commonTangent(c[j]);
      for(int k=0;k<tmp.size();k++){
	res.push_back(tmp[k]);
      }
      c[i].r-=m[i];
    }
  }
  return res;
}

int count(Line l){
  int cnt=0;
  for(int i=0;i<n;i++){
    Real d=l.dist(c[i].p)-c[i].r;
    cnt+=(sgn(d)>=0 && sgn(d,m[i])<=0);
  }
  return cnt;
}

int main(void){

  while(cin >> n,n){
    c.resize(n);
    m.resize(n);

    for(int i=0;i<n;i++)
      cin >> c[i].p.x >> c[i].p.y >> c[i].r >> m[i];
    
    vector<Line>res=enumerate();
    
    int cnt=0;
    for(int i=0;i<res.size();i++){
      cnt=max(cnt,count(res[i]));
    }
    cout << max(1,cnt) << endl;
  }
  return 0;
}

Measured memory_bytes: 2824
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	static int[] vx = new int[]{0,1,0,-1};
	static int[] vy = new int[]{1,0,-1,0};
	static int[] Y  = new int[]{0,0,0,1,1,1,2,2,2};
	static int[] X  = new int[]{0,1,2,0,1,2,0,1,2};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			char s = sc.next().charAt(0);
			int S = s - 'A';
			char t = sc.next().charAt(0);
			int T = t - 'A';
			char b = sc.next().charAt(0);
			int B = b - 'A';
			int[][][] dp = new int[n+1][3][3];
			dp[0][Y[S]][X[S]] = 1;
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < 3; j++) {
					for(int k = 0; k < 3; k++) {
						for(int l = 0; l < 4; l++) {
							int ty = j + vy[l];
							int tx = k + vx[l];
							if(ty < 0 || tx < 0 || tx >= 3 || ty >= 3 || (ty == Y[B] && tx == X[B])) {
								ty = j;
								tx = k;
							}
							dp[i+1][ty][tx] += dp[i][j][k];
						}
					}
				}
			}
			int sum = 0;
			for(int i = 0; i < 3; i++) {
				for(int j = 0; j < 3; j++) {
					sum += dp[n][i][j];
				}
			}
			System.out.printf("%.25f\n",dp[n][Y[T]][X[T]] / (double)sum);
			
		}
	}
 }

Measured memory_bytes: 27672
let split_ints str =
  Str.split (Str.regexp " ") str
  |> List.map int_of_string


let println_int i =
  print_int i;
  print_newline ()


let n, m =
  match read_line () |> split_ints with
  | [a; b] -> (a, b)
  | _ -> raise (Failure "more than 2 elements in a line.")

let _ = n * m |> print_int
let _ = print_char ' '
let _ = (n + m) * 2 |> println_int

Measured memory_bytes: 2164
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,i=0;
  cin >> n;
  vector<int> a(n);
  for(;i<n;i++){
    cin >> a[i];
  }
  int t=0;
  for(i=0;i<n;i++){
    if(a[t]==2) break;  
    t=a[t]-1;
  }
  if(i==n) cout << -1 <<endl;
  else cout << i+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<ll> loop;
  set<ll> see;
  ll now = x;
  while (true) {
    if (see.count(now)) {
      break;
    } else {
      see.insert(now);
      loop.push_back(now);
      now = (now * now) % m;
    }
  }
  if (loop.size() >= n) {
    ll ans = 0;
    for (int i = 0; i < n; i++) {
      ans += loop[i];
    }
    cout << ans << endl;
  } else {
    int idx = -1;
    ll ans = 0;
    ll loopsum = 0;
    ll loopcnt = 0;
    for (int i = 0; i < loop.size(); i++) {
      if (loop[i] == now) {
        idx = i;
      }
      if (idx == -1) {
        ans += loop[i];
      } else {
        loopsum += loop[i];
        loopcnt += 1;
      }
    }
    ans += (n - idx) / loopcnt * loopsum;
    for (int i = 0; i < (n - idx) % loopcnt; i++) {
      ans += loop[i + idx];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 5992
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;

  int Ans = 0;
  for (int key = 0; key < 1000; key++) {
    int tmp = key;
    int d = tmp % 10;
    int col = 0;
    bool flag = false;
    for (int i = N - 1; i >= 0; i--) {
      if (d == (S[i] - '0')) {
        tmp /= 10;
        d = tmp % 10;
        col++;
        if (col == 3) {
          flag = true;
          Ans++;
          break;
        }
      }
    }
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int zh[100005];
int fu[100005];
int x[100005];
int y[100005];
int z,f,xx,yy;

int main()
{
    int n,a,ans = 0;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> a;
        if(a >= 0)zh[z++] = a;
        else fu[f++] = a;
    }
    sort(zh,zh+z);
    sort(fu,fu+f);
    if(z == 0 || f == 0){
        if(n == 2){
            if(z == 0){
                cout << fu[1] - fu[0] << endl;
                cout << fu[1] << " " << fu[0] << endl;
            }else{
                cout << zh[1] - zh[0] << endl;
                cout << zh[1] << " " << zh[0] << endl;
            }
            return 0;
        }
        if(f == 0){
            x[xx++] = zh[0];
            y[yy++] = zh[z-1];
            for(int i = 1;i < z;i++)
                zh[i - 1] = zh[i];
            z -= 2;
            fu[f++] = x[xx-1] - y[yy-1];
        }else{
            x[xx++] = fu[f-1];
            y[yy++] = fu[0];
            for(int i = 1;i < f;i++)
                fu[i - 1] = fu[i];
            f -= 2;
            zh[z++] = x[xx-1] - y[yy-1];
        }
    }
    while(z > 1)
    {
        x[xx++] = fu[f-1];
        y[yy++] = zh[z-1];
        fu[f-1] = fu[f-1] - zh[z-1];
        z--;
    }
    while(f > 1)
    {
        x[xx++] = zh[z-1];
        y[yy++] = fu[f-1];
        zh[z-1] = zh[z-1] - fu[f-1];
        f--;
    }
    x[xx++] = zh[0];
    y[yy++] = fu[0];
    cout << zh[0] - fu[0] << endl;
    for(int i = 0;i < xx;i++)
        cout << x[i] << " " << y[i] << endl;
    /*if(z == f){
        for(int i = 0;i < z;i++)
            ans += zh[i];
        for(int i = 0;i < f;i++)
            ans += fu[i];
    }else{
        /*while(z > f)//1 2 3
        {           //-1 -2 -3
            fu[f++] = zh[z-1] - zh[z-2];
            x[xx++] = zh[--z];
            y[yy++] = zh[--z];
        }*/
    return 0;
}


Measured memory_bytes: 3072
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdlib>
using namespace std;
const long long int mod = 1000000007;
char ch[4][100];
int n;
int main(){
    scanf("%d%s%s",&n,ch[1],ch[2]);
    int rem = 0;
    long long int ans = 0;
    int i = 0;
    if(ch[1][0] == ch[2][0]){
        rem = 1;
        ans = 3;
        i ++;
    }
    else{
        rem = 2;
        ans = 6;
        i += 2;
    }
    for( ; i < n; i ++){
        if(ch[1][i] != ch[2][i]){
            if(rem == 1)
                ans *= 2;
            else
                ans *= 3;
            i ++;
            rem = 2;
        }
        else{
            if(rem == 1)
                ans *= 2;
            rem = 1;
        }
        ans %= mod;
    }
    printf("%lld",ans);
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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

int N;
string S;

void solve()
{
    cin >> N >> S;
    int x = 0;
    int m = 0;
    REP(i, S.length())
    {
        if(S[i] == 'I') x++;
        else x--;
        m = max(m, x);
    }
    cout << m << endl;
}

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;

    if(13 <= A){
        cout << B << endl;
    }
    else if(A <= 5){
        cout << 0 << endl;
    }
    else{
        cout << B / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
steps=list(map(int,input().split()))
dp=[True]*(k+1)
dp[0]=False
for stone in range(1,k+1):
  for s in steps:
    if s<=stone:
      dp[stone]=dp[stone]and dp[stone-s]
    else:
      break
  dp[stone]=not dp[stone]
#print(dp)
if dp[k]:
  print('First')
else:
  print('Second')
  

Measured memory_bytes: 74172
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int k;
	cin>>k;
	int ans=0;
	for(int a=1;a<=k;a++)
	{
		for(int b=1;b<=k;b++)
		{
			for(int c=1;c<=k;c++)
			{
				ans+=__gcd(a,__gcd(b,c));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var p int
	var q int
	var r int
	fmt.Scan(&p)
	fmt.Scan(&q)
	fmt.Scan(&r)

	min := p + q

	if p+r < min {
		min = p + r
	}
	if r+q < min {
		min = r + q
	}

	fmt.Println(min)
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int array[6]={},sum=0;
  for(int i=A;i<=B;i++) {
    int num=i;
    for(int j=0;j<5;j++){
      array[j]=num%10;
      num/=10;
      //cout << array[j] << endl;
    }
    if(array[0]==array[4] && array[1]==array[3]) sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] params = in.nextLine().split(" " );

        int k = Integer.parseInt( params[0] );
        int x = Integer.parseInt( params[1] );

        System.out.println( k * 500 >= x ? "Yes" : "No" );

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int cnt = 0;
  string T = "CODEFESTIVAL2016";
  for (int i = 0; i < T.size(); i++) {
    if (S.at(i) != T.at(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;
int main(){
	int N,s[101]={};
	int answer=0,Min=1000;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> s[i] ;
		answer+=s[i];
	}
	Min=answer;
	for(int i=0;i<N;i++){
		if(s[i]%10!=0){
			Min=min(Min,s[i]);
		}
	}
	
	if(answer%10==0){
		cout << answer - Min << endl;
	}else{
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		// 入力
		final String n;		// 1≦N<10000
		final int k;	// 1≦K<10
		final String[] d;	// 0≦D1<D2<…<DK≦9  {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
		try(Scanner scan = new Scanner(System.in)) {
			n = scan.next();				// 繰り上がり用に先頭に0を挿入。
			k = scan.nextInt();
			d = new String[k];
			for (int i = 0; i < k; i++) {
				d[i] = scan.next();
			}
		}
		
		// n < 10000 より総当り
		int result = IntStream.range(Integer.parseInt(n), 99999)
		.filter(i -> Arrays.stream(d).noneMatch(s -> String.valueOf(i).indexOf(s) != -1))
		.findFirst().getAsInt();

		// 出力
		out.println(result);
		out.flush();
	}
}

Measured memory_bytes: 22992
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    long MOD = (long)Math.pow(10, 9) + 7;
    long ans = 0;
    for(long i = k; i <= (n + 1); i++) {
      long t1 = (i * (i - 1)) / 2;
      t1 = (t1 % MOD);
      long t2 = (i * (2 * n - i + 1)) / 2;
      t2 = (t2 % MOD);
      ans = (ans + t2 + MOD - t1 + 1) % MOD;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	int N; cin >> N;
	vi v(N); rep(i,N) v[i] = i + 1;
	vi P(N), Q(N); rep(i,N) cin >> P[i]; rep(i,N) cin >> Q[i];
	int a = 0, b = 0;
	int ansa, ansb;
	do {
		if(v != P) a++;
		if(v == P) ansa = a;
		if(v != Q) b++;
		if(v == Q) ansb = b;
	}while(next_permutation(all(v))); 
	cout << abs(ansa - ansb) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x=0;
    cin>>a>>b;
    int c[a];
    for(int i=0;i<a;i++) cin>>c[i];
    sort(c,c+a);
    for(int i=a-1;i>a-b-1;i--) x+=c[i];
    cout<<x<<endl;
}

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

using namespace std;

const int N = 77777;
const long long mod = 1e9 + 7;

typedef struct pt{
  int t, x, y;
  pt(int _t, int _x, int _y): t(_t), x(_x), y(_y){}
}pt;

int distance(pt a, pt b){
   return abs(a.x - b.x) + abs(a.y  - b.y);
}
int main(){
  int n; cin >> n;

  vector<pt> v;
  v.push_back(pt(0, 0, 0));  
  for(int i = 0; i < n; i++){
    int t, x, y;
    cin >> t >> x >> y;
    v.push_back(pt(t, x, y));
  }
  int time = 0;
  for(int i = 1; i <= n; i++){
    int dist = distance(v[i], v[i - 1]);
    if(dist > v[i].t - time || (v[i].t - time) % 2 != dist % 2){
      cout << "No" << endl;
      return 0;
    }
    time = v[i].t;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1912
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2140
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		int sam[] = {0,0};
		for(int i = 0; i < 2 ; i++){
			for(int j = 0 ; j < 4 ; j++){
				sam[i] += scan.nextInt();
			}
		}
		if(sam[0] >= sam[1]){
			System.out.println(sam[0]);
		}else{
			System.out.println(sam[1]);
		}
	}
}

Measured memory_bytes: 26128
#include <iostream>

using namespace std;

int main(){
        int A[101][101] = {};
        int B[101] = {};
        int n,m;
        int c = 0;

        cin >> n >> m;

        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        cin >> A[i][j];
                }
        }

        
        for(int i = 1; i <= m; i++){
                cin >> B[i];
        }


        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        c += (A[i][j] * B[j]);
                }       
                cout << c << "\n";
                c = 0;
        }

        return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  vector<ll> A(n);
  vector<ll> sum(n+1), odd(n+1), even(n+1);
  rep(i, n) {
    cin >> A[i];
    odd[i+1] = odd[i];
    even[i+1] = even[i];
    sum[i+1] = sum[i] + A[i];
    if(i%2) odd[i+1] += A[i];
    else even[i+1] += A[i];
  }
  vector<int> B;
  rep(i, n) {
    int m = n-i;
    B.push_back((A[i]+A[i+m/2])/2+1);
  }
  vector<ll> X(q);
  rep(i, q) {
    cin >> X[i];
    int ret = upper_bound(all(B), X[i]) - B.begin();
    ll ans = 0;
    if(n%2) ans += odd[ret];
    else    ans += even[ret];
    ans += sum[ret+(n-ret)/2]-sum[ret];
    cout << sum[n]-ans << endk;
  }
  return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];

  vector<Int> r(n+1);
  for(Int i=0;i<n;i++) r[a[i]]=i;

  set<Int> s;
  for(Int i=0;i<n;i++) s.emplace(b[i]);
  if((Int)s.size()==n){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  Int p=1;
  while(s.count(p)) p++;

  cout<<"No"<<endl;
  
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==r[p]) cout<<1;
    else cout<<i+1;
  }
  cout<<endl;
  
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==r[p]) cout<<2;
    else cout<<i+1;
  }
  cout<<endl;
  
  return 0;
}



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


const long long MOD = 998244353;

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

    map<long long unsigned int,pair<long long unsigned int,long long unsigned int > > cycleDetection;

    long long unsigned N,X,M;
    cin>>N>>X>>M;

    long long unsigned res = 0;
    bool already = false;
    for(long long unsigned c = 0; c < N; c++) {
        if(!already && cycleDetection.find(X) != cycleDetection.end()) {
            already = true;
            long long unsigned c2 = cycleDetection[X].first;
            long long unsigned previousRes = cycleDetection[X].second;
            long long unsigned delta = res - previousRes;
            long long unsigned length = (c - c2);
            long long unsigned z = (N-c) / length;
            res += delta * z;
            c += z*length;
            c--;
        } else {
            cycleDetection[X] = make_pair(c,res);
            res += X;
            X = (X*X)%M;
        }
    }
    cout<<res;
}


Measured memory_bytes: 6684
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9')
		cout << "Yes" << endl;
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<ll> yakusu(ll n){
  vector<ll> ret;
  for(ll p = 1; p*p <= n; p++){
    if(n%p == 0){
      ret.push_back(p);
      if(p*p != n){
        ret.push_back(n/p);
      }
    }
  }
  sort(all(ret));
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,k;cin>>n>>k;
  vector<ll> yaku = yakusu(n);
  map<ll,ll> mp;
  ll ans = 0;
  rep(i,yaku.size()){
    ll p = yaku[i];
    ll num = (p+1) / 2;
    ll val = mpow(k, num);
    vector<ll> ko = yakusu(p);
    ko.pop_back();
    rep(j,ko.size()){
      ll q = ko[j];
      assert(mp.count(q) > 0);
      val -= mp[q];
      val += MOD;
      val %= MOD;
    }
    mp[p] = val;
    //cout<<p<<" "<<mp[p]<<endl;
    ans += val * p / (p%2 == 0 ? 2 : 1) % MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int x,y,z;cin>>x>>y>>z;
  
  int sum=x+y+z;
  
  if(sum<22){
    cout<<"win"<<endl;
  }
  else{
    cout<<"bust"<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())

cnt = 0
def primes(num):
  arr = []
  for i in range(1,int(num*(0.5))+1):
    if num%i == 0 and i not in arr:
      arr.append(i)
      if num//i not in arr:
        arr.append(num//i)
  return arr
      
for i in range(1,n+1,2):
  if len(primes(i))==8:
    cnt += 1
print(cnt)

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S, T;
    cin >> S >> T;

    string ans = "";
    rep (i, N) {
        ans += S[i];
        ans += T[i];
    }

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

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

int main(){
  string s;
  long long int k;
  cin>>s>>k;
  long long int A=0,first=1,last=1;
  int n=s.size();
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)){
      first++;
    }
    else{
      break;
    }
  }
  for(int i=n-1;i>0;i--){
    if(s.at(i)==s.at(i-1)){
      last++;
    }
    else{
      break;
    }
  }
  if(first==n){
    A=n*k/2;
  }
  else if(s.at(0)==s.at(n-1)){
    A+=((first+last)/2)*(k-1);
    A+=first/2;
    A+=last/2;
    for(int i=first-1;i<n-1-last;i++){
      int p;
      p=1;
      for(int j=i;j<n-1-last;j++){
        if(s.at(j)==s.at(j+1)){
          p++;
        }
        else{
          break;
        }
      }
      A+=(p/2)*k;
      i+=p-1;
    }
  }
  else{
    for(int i=0;i<n-1;i++){
      int p;
      p=1;
      for(int j=i;j<n-1;j++){
        if(s.at(j)==s.at(j+1)){
          p++;
        }
        else{
          break;
        }
      }
      A+=(p/2)*k;
      i+=p-1;
    }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
cin>>n;
vector<long long int>vec;
for(int i=1; i<=sqrt(n); ++i)
{
if(n%i==0)
{
if(n/i==i)
vec.push_back(i);
else
{
vec.push_back(i);
vec.push_back(n/i);
}
}
}
sort(vec.begin(),vec.end());
long long int ans(1000000000001);
for(int i=0; i<vec.size(); ++i)
ans=min(ans,(long long)(vec[i]-1+(n/vec[i])-1));
cout<<ans;
}


Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

int n;
vector<int> a;

void solve() {
  int b = 1, c = 2, d = 3;
  int ans = INF;
  while (c < a.size() - 1) {
    int diff = INF;
    while (b < c) {
      int diff_now = (a[c] - a[b]) - (a[b] - a[0]);
      int diff_next = (a[c] - a[b + 1]) - (a[b + 1] - a[0]);
      if (abs(diff_now) > abs(diff_next)) {
        b++;
      } else {
        break;
      }
    }

    int B = a[b] - a[0];
    int C = a[c] - a[b];

    while (d < a.size()) {
      int diff_now = (a.back() - a[d]) - (a[d] - a[c]);
      int diff_next = (a.back() - a[d + 1]) - (a[d + 1] - a[c]);
      if (abs(diff_now) > abs(diff_next)) {
        d++;
      } else {
        break;
      }
    }

    int D = a[d] - a[c];
    int E = a.back() - a[d];

    int mn = min(B, min(C, min(D, E)));
    int mx = max(B, max(C, max(D, E)));

    ans = min(ans, mx - mn);

    c++;
  }

  cout << ans << endl;
}

signed main() {
  cin >> n;

  a.reserve(n + 1);
  a.push_back(0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(a.back() + x);
  }
  solve();
  return 0;
}


Measured memory_bytes: 1792