akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const int INF = 1000000000;
const int mod = 1000000007;
struct BIT{
	const static int sz = 100005;
	int bit[sz];
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<sz;s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}kaede;
int n,q;
int main(){
	//if you don't use scanf / printf
	ios::sync_with_stdio(false);
	cin >> n >> q;
	rep(i,q){
		int id; cin >> id;
		if(id == 0){
			int x; ll val; cin >> x >> val;
			kaede.add(x,val);
		}
		else{
			int x,y; cin >> x >> y;
			cout << kaede.sum(y)-kaede.sum(x-1) << '\n';
		}
	}
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
double x1,x2,x3;
double pi=3.141592653589793;

int main(){
	cin>>x1>>x2>>x3;
	x3/=x1;
	double base=180.0/pi;
//	if(x3>=x1*x2) {
//		cout<<0<<endl;
//		return 0;
//	}
	if(x3>x1*x2/2) {
		x3-=2*x3-x1*x2;
		printf("%.10lf\n",atan(2*x3/(x1*x1))*base);
	}
	else {
		
		printf("%.10lf\n",atan(x2*x2/(2*x3))*base);
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;

ll wt[105] , Val[105];

int main()
{   
    int N ;
    ll W;
    cin >> N >> W;

    ll sum =0;
    for(int i=1; i<=N; i++)
    {
        cin >> wt[i] >> Val[i];
        sum += Val[i];
    } 

    ll dp[sum+1][N+1];

        for(int j=0; j<=N;j++)
    {
    for(ll i =0; i<=sum; i++)        {
            if(i==0) dp[i][j] = 0;
            else
            {
                dp[i][j] = 1000000000000LL;
                
            }
        }
    }
    
        for(int j=1; j<=N; j++)
        {
            for(ll s=sum; s>=0 ; s--)
    {
            if(s >=Val[j])
            {
                dp[s][j] = min(dp[s][j-1], dp[s-Val[j]][j-1]+wt[j]);
            }
            else
            {
                dp[s][j] = dp[s][j-1];
            }
            // cout<< dp[s][j]<< endl;
        }
        
    }
    // ll result;
    for(ll s=sum; s>0; s--){
        if(dp[s][N] <=W){
            cout << s <<endl;
            break;
        }
    }
    // cout << INT64_MAX;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 main()
{
    int N;
    cin >> N;
    vll a(N), s(N);
    rep(i, N)
    {
        cin >> a[i];
        if (i == 0)
            s[i] = a[i];
        else
            s[i] = s[i - 1] + a[i];
    }
    ll Min = LONG_LONG_MAX;
    rep(i, N - 1)
    {
        Min = min(abs(2 * s[i] - s[N - 1]), Min);
    }
    cout << Min;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void)
{
        int n,m,x,a[100],cos,coo;
        int i,j;
        scanf("%d%d%d",&n,&m,&x);

        for(i=1;i<=m;i++)
                scanf("%d",&a[i]);

        cos = 0;
        coo = 0;
        for(i=x;i>=0;i--){
                for(j=1;j<=m;j++)
                        if(i==a[j])
                                cos++;
        }
        for(i=x;i<=n;i++){
                for(j=1;j<=m;j++)
                        if(i==a[j])
                                coo++;
        }
        if(cos >= coo)
                printf("%d\n",coo);
        else
                printf("%d\n",cos);
        return 0;
}


Measured memory_bytes: 128
(let* ((n (cons (read) (read)))
       (m (1- (read))))
  (cond ((> (- (cdr n) m) (+ (car n) m))
         (loop :for k :from (car n) :upto (+ (car n) m) :do(format t "~A~%" k))
         (loop :for k :from (- (cdr n) m) :upto (cdr n) :do(format t "~A~%" k)))
        ((<= (- (cdr n) m) (+ (car n) m))
         (loop :for k :from (car n) :upto (cdr n) :do(format t "~A~%" k)))))

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 5");
            //0
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 5");
            //2
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5 5");
            //4
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("100000 2");
            //1
        }
        else if (InputPattern == "Input5") {
            WillReturn.Add("100000 100000");
            //50000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
        long H = wkArr[0];
        long W = wkArr[1];

        long AnswerKouho1 = Solve(H, W);
        long AnswerKouho2 = Solve(W, H);
        Console.WriteLine(Math.Min(AnswerKouho1, AnswerKouho2));
    }

    static long Solve(long pH, long pW)
    {
        long WillReturn = long.MaxValue;
        for (int LoopAW = 1; LoopAW <= pW - 1; LoopAW++) {
            long MensekiA = LoopAW * pH;

            long RestW = pW - LoopAW;

            //残りの取り方1
            long MensekiB = (RestW / 2) * pH;
            long MensekiC = Div2Kiriage(RestW) * pH;
            long wkMinMaxDiff = DeriveMinMaxDiff(MensekiA, MensekiB, MensekiC);
            if (WillReturn > wkMinMaxDiff)
                WillReturn = wkMinMaxDiff;

            //残りの取り方2
            MensekiB = RestW * (pH / 2);
            MensekiC = RestW * Div2Kiriage(pH);
            wkMinMaxDiff = DeriveMinMaxDiff(MensekiA, MensekiB, MensekiC);
            if (WillReturn > wkMinMaxDiff)
                WillReturn = wkMinMaxDiff;
        }
        return WillReturn;
    }

    //2で割って端数切り上げ
    static long Div2Kiriage(long pVal)
    {
        long WillReturn = pVal / 2;
        if (pVal % 2 > 0) WillReturn++;
        return WillReturn;
    }

    //最大面積と最小面積の差を返す
    static long DeriveMinMaxDiff(long pA, long pB, long pC)
    {
        long MinVal = Math.Min(Math.Min(pA, pB), pC);
        long MaxVal = Math.Max(Math.Max(pA, pB), pC);
        return MaxVal - MinVal;
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char s[105];
int a,b;
scanf("%d %d",&a,&b);
scanf("%s",s);
for(int i=0;s[i]!='\0';i++){
    if(i==a){
        if(s[i]!='-'){printf("No\n");return 0;}
    }
    else if(s[i]=='-'){printf("No\n");return 0;}
}
printf("Yes\n");
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int K=sc.nextInt();
    
    int i=0;
    while(i<K) {
    	System.out.print("ACL");
    	i++;
    }
  }
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<i;j++){
      if (s[i]==s[j]){
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int r = 0;
    int D = 0;
    int x2000 = 0;

    cin >> r >> D >> x2000;

    int xi = r * x2000 - D;
    cout << xi << "\n";

    for (int i=0; i<9; i++) {
        xi = r * xi - D;
        cout << xi << "\n";
    }

    return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    int alice = 0, bob = 0;

    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());

    rep(i, n){
        if(i%2) bob += a[i]; else alice += a[i];
    }
    out(alice-bob);
}

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

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

    for(int i=0;i<n;i++){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4372
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<List<Integer>> list = new ArrayList<>();
		int n = sc.nextInt();
		int q = sc.nextInt();
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < q; i++) {
			switch (sc.nextInt()) {
				case 0:
					list.get(sc.nextInt()).add(sc.nextInt());
					break;
				case 2:
					list.set(sc.nextInt(), new ArrayList<>());
					break;
				case 1:
					List<Integer> tmp = list.get(sc.nextInt());
					for (int j = 0; j < tmp.size(); j++) {
						System.out.print(tmp.get(j));
						if (j < tmp.size() - 1) {
							System.out.print(" ");
						}
					}
					System.out.println();
					break;
			}
		}
	}
}


Measured memory_bytes: 310456
#include<stdio.h>
#include<string.h>
struct N{N*l,*r;};
char*C(char*p,N*&n)
{
	n=new N;
	if(*p=='(')p=C(p+1,n->l);
	else n->l=0;
	if(*p==',')++p;
	if(*p=='(')p=C(p+1,n->r);
	else n->r=0;
	if(*p==')')++p;
	return p;
}
void I(N*&r,N*t1,N*t2)
{
	r=new N;
	if(t1->l&&t2->l)I(r->l,t1->l,t2->l);
	else r->l=0;
	if(t1->r&&t2->r)I(r->r,t1->r,t2->r);
	else r->r=0;
}
void U(N*&r,N*t1,N*t2)
{
	r=new N;
	if(t1&&t1->l || t2&&t2->l) U(r->l, t1?t1->l:0, t2?t2->l:0);
	else r->l=0;
	if(t1&&t1->r || t2&&t2->r) U(r->r, t1?t1->r:0, t2?t2->r:0);
	else r->r=0;
}
void P(N*t)
{
	putchar('(');
	if(t->l)P(t->l);
	putchar(',');
	if(t->r)P(t->r);
	putchar(')');
}
void D(N*t)
{
	if(t->l)D(t->l);
	if(t->r)D(t->r);
	delete t;
}
int main()
{
	char s[999],t1[999],t2[999],*p1,*p2,o;
	while(fgets(s,999,stdin))
	{
		o=s[0];
		p1=s+2;
		p2=strchr(p1,' ');
		*p2=0;
		strcpy(t1,p1);
		strcpy(t2,p2+1);

		N *n1=0,*n2=0,*r=0;
		C(t1+1,n1);
		C(t2+1,n2);
		if(o=='i')I(r,n1,n2);
		else U(r,n1,n2);
		P(r);
		puts("");
		D(n1);
		D(n2);
		D(r);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cassert>
#include<iomanip>
using namespace std;
typedef pair<double,double> P;
int p,n;
int d[] = {-2,-1,0,1,2};

int main()
{
  while(cin >> p >> n,p|n)
    {
      P a = P(0,1);
      P b = P(1200900,1);
      double np = sqrt(p);
      //cout << "np = " << np << endl;
      for(double v=1;v<=n;v++)
	{
	  for(int i=0;i<5;i++)
	    {
	      int ux = np*v+d[i];
	      if(ux > n)continue;
	      if(__gcd(ux,(int)v) != 1)continue;
	      //cout << ux << "/" << v << endl;
	      if(ux/v < np && np-a.first/a.second > np-ux/v)a = P(ux,v);
	      if(ux/v > np && b.first/b.second-np > ux/v-np)b = P(ux,v);
	}

    }

  cout << b.first << "/" << b.second << " " << a.first << "/" << a.second << endl;
}
return 0;
}

Measured memory_bytes: 1232
n,m=map(int,input().split())
ans_1=[]
ams_n=[]
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        ans_1.append(b)
    if b==n:
        ams_n.append(a)
ans_1=set(ans_1)
ams_n=set(ams_n)
if ans_1&ams_n!=set():
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 21052
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll d, c[26], s[365][26], sc[365], last[26];

void input() {
  cin >> d;
  rep(i, 26) { cin >> c[i]; }
  rep(i, d) {
    rep(j, 26) { cin >> s[i][j]; }
  }
}

// satisfactory decrease
ll satDec(ll date, ll con) {
  ll ans = 0;
  rep(i, 26) {
    if (i != con) { ans += c[i] * (date - last[i]); }
  }
  return ans;
}

// コンテストconを選んだときの満足度の変化を計算する
// 26回ループで求まる
ll satChange(ll date, ll con) { return s[date][con] - satDec(date, con); }

// 満足度を1日ごとに計算する
void calcSat() {
  ll s = 0;
  rep(i, d) {
    s += sc[i];
    cout << s << endl;
  }
}

void solve() {
  rep(i, 26) { last[i] = -1; }
  // 貪欲法
  rep(i, d) {
    // 終わったあとのことをシミュレーションしてみて，一番良くなるやつを選ぶ
    ll maxS, maxC;
    rep(j, 26) {
      ll sj = satChange(i, j);
      if (j == 0) {
        maxS = sj;
        maxC = 0;
        continue;
      }
      if (sj > maxS) {
        maxS = sj;
        maxC = j;
      }
    }

    // maxCを選ぶ
    cout << maxC + 1 << endl;
    last[maxC] = i;

    sc[i] = maxS; // satisfactory change
  }
  // calcSat();
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3728
N = int(input())
A = list(map(int, input().split()))

pa = 1
ch = 1
node = 0
flag = True
A_score = sum(A)

for d in range(N+1):
  pa = ch
  A_score -= A[d]
  if A_score >= (pa - A[d]) * 2:
    ch = (pa - A[d]) * 2
  elif (pa - A[d]) * 2 >= A_score:
    ch = A_score
  else:
    ch = pa - A[d]
  node += pa
  if ch < 0:
    flag = False

if flag:
  print(node)
else:
  print(-1)

Measured memory_bytes: 19996
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int ans = 0;
	ans += N / 500 * 1000;
	N %= 500;
	ans += N / 5 * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
	int num;
	double time;
}data;

void bsort(data *n,int N)
{
	int i,k,x;
	double w;

	for(k=0;k<N;k++){
		for(i=0;i<N-1;i++)
			if(n[i].time>n[i+1].time){
				x=n[i].num;
				n[i].num=n[i+1].num;
				n[i+1].num=x;
				w=n[i].time;
				n[i].time=n[i+1].time;
				n[i+1].time=w;
			}
	}

	return;
}

int main(void)
{
	int i,k,count=0;
	data n[3][8],judge[18];

	for(k=0;k<3;k++){
		for(i=0;i<8;i++){
			scanf("%d%lf",&n[k][i].num,&n[k][i].time);
		}
	}
	
	for(i=0;i<3;i++)bsort(n[i],8);

	for(i=0;i<3;i++)
		for(k=2;k<8;k++)
			judge[count++]=n[i][k];

	bsort(judge,18);

	for(i=0;i<3;i++)
		for(k=0;k<2;k++)
			printf("%d %.2f\n",n[i][k].num,n[i][k].time);

	for(i=0;i<2;i++)printf("%d %.2f\n",judge[i].num,judge[i].time);

	return 0;
}


	

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

using namespace std;

long long int tablica[2*262144];
long long int n,i,odp,naj;
long long int h[262144];
long long int a[262144];

long long int policz(long long int x, long long int y) {
  x += 262144;
  y += 262144;
  long long int maksimum = 0;
  while(x<=y){
    if(x%2==1){
        maksimum = max(maksimum, tablica[x++]);
    }
    if(y%2==0){
        maksimum = max(maksimum, tablica[y--]);
    }
    x/=2;
    y/=2;
  }
  return maksimum;
}

void dodaj(int k, long long int x) {
  tablica[k+=262144]=x;
  for(k/=2;k>=1;k/=2){
    tablica[k]=max(tablica[2*k], tablica[2*k+1]);
  }
}

int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  cin>>n;
  for(i=1;i<=n;i++){
    cin>>h[i];
  }
  for(i=1;i<=n;i++){
    cin>>a[i];
  }
  for(i=1;i<=n;i++){
    naj=policz(0, h[i]-1)+a[i];
    dodaj(h[i], naj);
    odp = max(odp, naj);
  }
  cout << odp << "\n";
}


Measured memory_bytes: 7936
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int K, N; cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  int vmax = K + A[0] - A[N-1];
  for (int i = 1; i < N; ++i) {
    vmax = max(vmax, A[i]-A[i-1]);
  }
  cout << K - vmax << endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli data[100100];
signed main(){

	lli n,m;
	cin>>n>>m;

	REP(i,0,m){
		lli l,r;
		cin>>l>>r;
		l--;
		data[l]++;
		data[r]--;
	}

	for(lli i=1;i<=n;i++){
		data[i] += data[i-1];
	}

	lli cnt=0;
	REP(i,0,n){
		if(data[i]==m)cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

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

int main() {
  ll a,b,n; cin >> a >> b >> n;
  if (a == 1 || b == 1) cout << 0;
  else {
    ll ans;
    if (n < b) ans = n;
    else if (n%b == 0) ans = n-1;
    else {
      ll m = n%b;
      ll x = n-m-1,y = n;
      cout << max(((a*x)/b-a*(x/b)), ((a*y)/b-a*(y/b)));
      return 0;
    }
    cout << (a*ans)/b - a*(ans/b);
  }
  return 0;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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


int main() {
	int N; cin >> N;
	int ans = 0;

	for (int i = 1; i <= N;i++) {
		int x = i;
		int cnt = 0;
		while (x) {
			cnt++;
			x = x / 10;
		}
		if (cnt % 2 != 0) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin>>s;
  
  int n=s.size();
  int cnt=0,max=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      cnt++;
      if(max<cnt) max=cnt;
    }
    else cnt=0;
  }
  
  cout<<max<<endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int A[10];
     for(int i=0;i<10;i++)
     cin >> A[i];
     sort(A,A+10);
     reverse(A,A+10);
     for(int i=0;i<3;i++)  cout << A[i] << endl;
     return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 2, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
  }
  
  int S = 0;
  for (int i = 1; i <= N + 1; i++) {
    S += abs(A.at(i) - A.at(i - 1));
  }
  
  for (int i = 1; i <= N; i++) {
    cout << S + abs(A.at(i + 1) - A.at(i - 1))
      - abs(A.at(i) - A.at(i - 1)) - abs(A.at(i + 1) - A.at(i)) << endl;
  }
}


Measured memory_bytes: 1664
#include <iostream>

int main()
{
	int x, y;
	while(std::cin >> x >> y)
	{
		if (x == 0 && y == 0) break;
		if (x < y) std::cout << x << " " << y << std::endl;
		else std::cout << y << " " << x << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

constexpr int MOD = 1e9 + 7;

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

    int N = S.size();
    std::vector<std::vector<long long>> dp(N + 1, std::vector<long long>(4, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++)
            if (S[i] != '?')
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            else
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 3) % MOD;

        if (S[i] == 'A' || S[i] == '?')
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0]) % MOD;
        if (S[i] == 'B' || S[i] == '?')
            dp[i + 1][2] = (dp[i + 1][2] + dp[i][1]) % MOD;
        if (S[i] == 'C' || S[i] == '?')
            dp[i + 1][3] = (dp[i + 1][3] + dp[i][2]) % MOD;
    }
    std::cout << dp[N][3] << std::endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll X, Y;
	cin >> X >> Y;

	if (X % Y == 0){
		cout << -1 << "\n";	
	} else {
		ll prod = 1;
		ll val = X;
		while (val <= 1e18) {
			if (val % Y != 0){
				cout << val << "\n";
				return 0;
			}
			prod++;
			val = X * prod;
		}
		cout << -1 << "\n";			
	}



	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in); 
    int N = sc.nextInt();
    String[] S = new String[N];
    int countAC=0;
    int countWA=0;
    int countTLE=0;
    int countRE=0;
    for (int i =0; i<N; i++) {
      String a = sc.next();
      if (a.equals("AC")) countAC++;
      if (a.equals("WA")) countWA++;
      if (a.equals("TLE")) countTLE++;
      if (a.equals("RE")) countRE++;
    }
    System.out.println("AC x " + countAC);
    System.out.println("WA x " + countWA);
    System.out.println("TLE x " + countTLE);
    System.out.println("RE x " + countRE);
  }
}


Measured memory_bytes: 58476
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t;

vector<int> v;

int main()
{
	fast;
	cin>>n>>m;
	n=n*2-1;
	if(m==1 || m==n)
		return cout<<"No",0;
	cout<<"Yes"<<endl;
	if(n==3)
	{
		for(int i=1;i<=n;i++)
			cout<<i<<endl;
		return 0;
	}
	int a=m-1;
	int b=m+1;
	int c=b+1;
	if(c>n)
	{
		swap(a,b);
		c=b-1;
	}
	for(int i=1;i<=n;i++)
		if(i!=a && i!=b && i!=c && i!=m)
			v.pb(i);
	for(int i=1;i<=(n+1)/2-3;i++)
	{
		cout<<v[v.size()-1]<<endl;
		v.ppb();
	}
	cout<<c<<endl<<a<<endl<<m<<endl<<b<<endl;
	for(int i=(n+1)/2+2;i<=n;i++)
	{

		cout<<v[v.size()-1]<<endl;
		v.ppb();
	}

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 2420
a, b, c, d = map(int, input().split())

i = 0

while a > 0 and c > 0:
    if i % 2 == 0:
        c -= b
    else:
        a -= d

    i += 1

if a <= 0:
    print('No')

if c <= 0:
    print('Yes')

Measured memory_bytes: 9176
#include <stdio.h>

int main(){

    int N = 0;
    int count = 0;

    scanf("%d", &N);

    char S[N];

    scanf("%s", S);

    if(N % 2 == 0){
        for(int i = 0; i < N / 2; i++){
            if(S[i] == S[i + N / 2]){
                count++;
            } else {
                printf("No\n");
                break;
            }
        }
    } else {
        printf("No\n");
    }
    if(count == N / 2 && N != 1){
       printf("Yes\n"); 
    }

    return 0;
}

Measured memory_bytes: 128
s = input()
L = []
for i in s:
  if i not in L:
    L.append(i)

Ans = 100
for i in L:
  cnt = 0
  ma = 0
  for j in s:
    if i != j:
      cnt += 1
    else:
      ma = max(ma, cnt)
      cnt = 0
  ma = max(ma, cnt)
  Ans = min(Ans, ma)

print(Ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

string aaa(string t) {
	string l = t; SORT(l); REVE(l);
	string s = t; SORT(s);
	int ans = stoi(l) - stoi(s);
	string sans = to_string(ans);
	string ret; ret.assign(4 - sz(sans), '0');
	ret += to_string(ans);
	return ret;
}

int main() {
	rep(i, 7) {
		int a, b; cin >> a >> b;
		cout << abs(a - b) << endl;
	}
}


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

const int MAX = 1e5 + 10;
int arr[MAX];

int main() {
  // 入力
  int N;
  cin >> N;
  int l[N], r[N];
  for (int i = 0; i < N; i++) cin >> l[i] >> r[i];

  for (int i = 0; i < N; i++) {
    arr[l[i]]++;
    arr[r[i]+1]--;
  }

  for (int i = 1; i < MAX; i++) arr[i] += arr[i-1];

  int ans = 0;
  for (int i = 0; i < MAX; i++) {
    if (arr[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
let input = readLine()!.split(separator: " ")
let N = Int(input[0])!
let M = Int(input[1])!
var K = Int(input[2])!

var A = readLine()!.split(separator: " ").map { Int($0)! }
var B = readLine()!.split(separator: " ").map { Int($0)! }

var a: [Int] = .init(repeating: 0, count: N + 1)
var b: [Int] = .init(repeating: 0, count: M + 1)

for i in 1...N {
  a[i] += A[i-1] + a[i-1]
}
for i in 1...M {
  b[i] += B[i-1] + b[i-1]
}
var maxSum = 0
var j = M
for i in 0...N {
  if a[i] > K {
    break
  }
  while a[i] + b[j] > K {
    j -= 1
  }
  maxSum = max(maxSum, i + j)
}
print(maxSum)


Measured memory_bytes: 26120
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace Contest166
{
  class Aziz
  {
    static void Main(string[] args)
    {
      var S = ReadLine();
      if (S == "ABC")
      {
        WriteLine("ARC");
      }
      else
      {
        WriteLine("ABC");
      }
    }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Measured memory_bytes: 25680
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;
int a[25][25];
int n,m;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int cnt=0;
			for(int k=0;k<m;k++){
				cnt+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
			}
			int p=sqrt(cnt+0.1);
			if(p*p==cnt){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))

a = list(map(lambda x: -x, a))
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, -((-heapq.heappop(a))//2))
print(-sum(a))

Measured memory_bytes: 20256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

map<char, int>mp;
map<int, char>revmp;
int main() {
	for (int i = 0; i < 26; ++i) {
		revmp[i] = 'a' + i;
		mp['a' + i] = i;
	}
	for (int i = 0; i < 26; ++i) {
		revmp[i+26] = 'A' + i;
		mp['A' + i] = i+26;
	}
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>backs;
		for (int i = 0; i < N; ++i) {
			int a; cin >> a; backs.emplace_back(a);
		}
		string st; cin >> st;
		int num = 0;
		for (int i = 0; i < st.size(); ++i) {
			int a(mp[st[i]]);
			a = a + 52 - backs[num];
			a %= 52;
			cout << revmp[a];
			num++;
			num %= N;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  int n=sz(s);
  int ans=0;
  
  rep(i,n){
    int count=0;
    srep(j,i,n){
      if(s[j]=='A' || s[j]=='C' || s[j]=='T' || s[j]=='G'){
          count ++;
      }
      else{
        
        break;
      }
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int a,b;
    cin >> a >> b;
    double pria,prib;
    for(int i = 0; i < 1100; i++) {
        pria = i*0.08;
        prib = i*0.10;
        if(a <= pria && pria < a+1) {
            if(b <= prib && prib < b+1) {
                cout << i;
                return 0;
            }
        }
    }
    cout << -1;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
int main(void) {
    char str[1001];
    char strc[1001];
    char p[1001];
    char o[10];
    char out[100000];
    int sl = 0;
    int l = 0;
    int a, b, q;
    int i, j;
     
    out[0] = 'a';
     
    scanf("%s", &str);
    scanf("%d", &q);
     
    for(j = 0; str[j] != '\0'; j++) {
        sl++;
    }
     
    for(i = 0; i < q; i++) {
        scanf("%s", &o);
         
        if(o[2] == 'i') {
            //print
            scanf("%d %d", &a, &b);
            for(j = 0; j < b-a+1; j++) {
                out[l+j] = str[j+a];
            }
            l+=b-a+1;
            out[l] = '\n';
            l++;
        } else if(o[2] == 'v') {
            //reverse
            scanf("%d %d", &a, &b);
            for(j = 0; j < sl; j++) {
                strc[j] = str[j];
            }
            for(j = 0; j < b-a+1; j++) {
                str[j+a] = strc[b-j];
            }
             
        } else if(o[2] == 'p') {
            //replace
            scanf("%d %d %s", &a, &b, p);
            for(j = 0; j < b-a+1; j++) {
                str[j+a] = p[j];
            }
        }
    }
    out[l] = '\0';
     
    printf("%s", out);
     
    return 0;
}
    

Measured memory_bytes: 608
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    int n,k;
    cin >> n >> k;
    vint a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,k){
        vint b(n+1, 0);
        int flag = 1;
        rep(i,n){
            int l = i - a[i];
            int r = i + a[i];
            if(l < 0) l = 0;
            if(r >= n) r = n-1;
            b[l]++;
            b[r+1]--;
        }
        int tmp=0;
        rep(i,n){
            tmp += b[i];
            a[i] = tmp;
            // cout << a[i] << " ";
            if(a[i] != n) flag = 0;
        }
        // cout << endl;
        if(flag) break;
    }
    rep(i,n) cout << a[i] << " "; cout << endl;
}



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


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007


static const ll MAX = pow(10, pow(10, 10));

int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        ll A, B;
        scanf("%lld %lld", &A, &B);
        ll C = sqrt(A * B);
        ll cnt = 0;

        if ( A > B) swap(A, B);

        if (C * (C + 1) < A * B)
        {
            cnt += C * 2; 
        }
        else
        {
            --C;
            cnt += C * 2 ;
            if ( (C + 1) * (C + 1) < A * B && (C + 1) != A)
            {
                cnt++;
            }

        }
        
        if ( C >= A ) cnt--;

        printf("%lld\n", cnt);
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

bool check(int n, int p[100005]){
    rep(i,n){
        if(p[i] == i + 1) return true;
    }
    return false;
}

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

    int p[100005];
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }

    int cnt = 0;
    rep(i,n){
        if(p[i] == i){
            if(i + 1 < n && p[i + 1] == i + 1){
                cnt++;
                i++;
                continue;
            }
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
 
long long max(long a,long b){
	if(a>b){
    	return a;
    }else{
    	return b;
    }
}
 
long long min(long a,long b){
	if(a<b){
    	return a;
    }else{
    	return b;
    }
}
 
int f(long a,long b){
  long c=max(a,b);
  int keta=1;
  for(int i=0;i<10;++i){
  	if(c/10>0){
    	keta++;
      	c/=10;
    }
  }
  return keta;
}
 
 
 
int main(void){
  
  long N;
  int minnum=11;
  scanf("%ld",&N);
  
  for(long a=1;a*a<=N;++a){
    long b=0;
  	if(N%a == 0){
      b=N/a;
      b=f(a,b);
      minnum=min(minnum,b);
    }
  }
  
  printf("%ld",minnum);
  
 
return 0;
}

Measured memory_bytes: 128
import math
N=int(input())

ans=[]
is_prime = [True] * (int(N**(0.5))+1)
is_prime[0] = False
for i in range(1,int(N**(0.5))+1):
    if not is_prime:
        continue
    if N%i==0:
        ans.append([i,N//i])
    else:
        for j in range(i,int(N**(0.5))+1,i):
            is_prime[j]=False

z=10
for A in ans:
    z=min(z,int(math.log10(A[1])))

print(z+1)


Measured memory_bytes: 74572
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	string buffer;

	while ( cin >> buffer )
	{
		for ( unsigned int i = 0; i < buffer.length(); i++ )
		{
			if ( buffer[i] == '@' )
			{
				int num = buffer[++i] - '0';
				char c = buffer[++i];

				for ( int i = 0; i < num; i++ )
				{
					cout << c;
				}
			}
			else
			{
				cout << buffer[i];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
    constexpr int p = 673;
    std::string s;
    std::cin >> s;
    const int n = s.size();

    std::reverse(s.begin(), s.end());

    std::vector<std::vector<int>> q(3, std::vector<int>(p));
    q[0][0]++;
    int t = 0, c = 0, co = 1;
    for (int i = 0; i < n; i++) {
        const int d = s[i] - '0';
        c = (c + co * d) % p;
        t = (t + d) % 3;
        co = co * 10 % p;
        q[t][c]++;
    }

    i64 ret = 0;
    for (const auto &w : q) {
        for (const i64 e : w) ret += e * (e - 1) / 2;
    }

    std::cout << ret << std::endl;

    return 0;
}


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

int mat[307][307][307];

int main() {
	int kmx, n, ans;
	string theo;

    cin >> theo >> kmx;
    n = theo.size();
    theo = "$" + theo;
	ans = 0;

    for (int i(1); i <= n; i++) {
    for (int j(1); i + j <= n; j++) {
    for (int k(0); k <= kmx; k++) {
    	if (theo[i] == theo[n - j + 1])
        	mat[i][j][k] = mat[i - 1][j - 1][k] + 1;
        if (k > 0)
        	mat[i][j][k] = max(mat[i][j][k], mat[i - 1][j - 1][k - 1] + 1);
        mat[i][j][k] = max(mat[i][j][k], mat[i - 1][j][k]);
        mat[i][j][k] = max(mat[i][j][k], mat[i][j - 1][k]); } } }

    for (int i(1); i <= n; i++)
    for (int j(0); j <= kmx; j++)
    	ans = max(ans, 2 * mat[i][n - i][j]);
    for (int i(1); i <= n; i++)
    for (int j(0); j <= kmx; j++)
        ans = max(ans, 2 * mat[i - 1][n - i][j] + 1);

    cout << ans << endl;

    return 0; }


Measured memory_bytes: 110464
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, K = il()

    k = []
    for n in range(1, A * B + 1):
        if A % n == 0 and B % n == 0:
            k.append(n)
    print(k[::-1][K-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 10168
#include <iostream>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    unordered_map<ll, ll> count;
    for(int i = 0; i < n; ++i){
        ll ai;
        cin >> ai;
        count[ai - 1] += 1;
        count[ai] += 1;
        count[ai + 1] += 1;
    }

    ll ans = 1;
    for(auto it = count.begin(); it != count.end(); ++it){
        ans = max(ans, it->second);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  long long n,d; cin>>n>>d;
  int ans=0;
  for (int i=0; i<n; i++){
    long long x,y; cin>>x>>y;
    if (x*x+y*y<=d*d) ans+=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
	int id;
	int score;
	int penalty;
} team_t;

int compTeam(const void* x,const void* y) {
	const team_t* a=(const team_t*)x;
	const team_t* b=(const team_t*)y;
	if((a->score)<(b->score))return 1;
	if((a->score)>(b->score))return -1;
	if((a->penalty)>(b->penalty))return 1;
	if((a->penalty)<(b->penalty))return -1;
	if((a->id)<(b->id))return 1;
	if((a->id)>(b->id))return -1;
	return 0;
}

team_t teams[50];
int solved[50][10];

int main(void) {
	int M,T,P,R;
	while(scanf("%d%d%d%d",&M,&T,&P,&R)==4 && (M|T|P|R)!=0) {
		int i,j;
		memset(teams,0,sizeof(teams));
		memset(solved,0,sizeof(solved));
		for(i=0;i<R;i++) {
			int m,t,p,jj;
			scanf("%d%d%d%d",&m,&t,&p,&jj);
			if(solved[t-1][p-1]<=0) {
				if(jj==0)solved[t-1][p-1]=-solved[t-1][p-1]*20+m+1;
				else solved[t-1][p-1]--;
			}
		}
		for(i=0;i<T;i++) {
			teams[i].id=i+1;
			for(j=0;j<P;j++) {
				if(solved[i][j]>0) {
					teams[i].score++;
					teams[i].penalty+=solved[i][j]-1;
				}
			}
		}
		qsort(teams,T,sizeof(team_t),compTeam);
		printf("%d",teams[0].id);
		for(i=1;i<T;i++) {
			if(teams[i-1].score==teams[i].score &&
			teams[i-1].penalty==teams[i].penalty) {
				putchar('=');
			} else {
				putchar(',');
			}
			printf("%d",teams[i].id);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#define N 200000


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

Measured memory_bytes: 1376
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            var sL = s.Length;
            if (sL == 1) { Console.WriteLine("Audrey wins."); goto end; }
            var st = 0;
            for (int j = 0; j < sL; j++)
                st += int.Parse(s[j].ToString());
            var ans = sL - 1 + (st - 1) / 9;
            Console.WriteLine(ans % 2 == 1 ? "Fabre wins." : "Audrey wins.");
            end:;
        }
    }
}


Measured memory_bytes: 8916