akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;
double dot(P a, P b){return real(conj(a)*b);}
double cross(P a, P b){return imag(conj(a)*b);}

int ccw(P a, P b, P c) {
  b-=a;c-=a;
  if(cross(b,c)>EPS)return +1;
  if(cross(b,c)<-EPS)return -1;
  if(dot(b,c)<-EPS)return +2;
  if(norm(b)<norm(c))return -2;
  return 0;
}

P projection(const L &l, const P &p) {
  double t=dot(p-l.F,l.F-l.S)/norm(l.F-l.S);
  return l.F+t*(l.F-l.S);
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s.F,s.S,t.F)*ccw(s.F,s.S,t.S)<=0&&
    ccw(t.F,t.S,s.F)*ccw(t.F,t.S,s.S)<=0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s.F-p)+abs(s.S-p)-abs(s.S-s.F)<EPS;
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if(intersectSP(s,r)) return abs(r-p);
  return min(abs(s.F-p),abs(s.S-p));
}
double distanceSS(const L &s, const L &t) {
  if(intersectSS(s,t))return 0;
  return min(min(distanceSP(s,t.F),distanceSP(s,t.S)),
             min(distanceSP(t,s.F),distanceSP(t,s.S)));
}

void Main() {
  int n;
  while(R n && n) {
    double sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    L b=L(P(sx,sy),P(tx,ty));
    vector<L> v[n];
    int h[n];
    bool f=1;
    rep(i,n) {
      double x1,y1,x2,y2;
      cin >> x1 >> y1 >> x2 >> y2 >> h[i];
      v[i].pb(L(P(x1,y1),P(x1,y2)));
      v[i].pb(L(P(x2,y1),P(x2,y2)));
      v[i].pb(L(P(x1,y1),P(x2,y1)));
      v[i].pb(L(P(x1,y2),P(x2,y2)));
      if((x1<=sx&&sx<=x2&&y1<=sy&&sy<=y2)||(x1<=tx&&tx<=x2&&y1<=ty&&ty<=y2))f=0;
    }
    if(!f) {
      pd(0);
      continue;
    }
    double l=0,r=1000;
    rep(t,100) {
      double m=(l+r)/2;
      f=1;
      rep(i,n) {
        rep(j,4) {
          double d=distanceSS(b,v[i][j]);
          if(m>h[i]) {
            double c=m-h[i];
            d=sqrt(d*d+c*c);
          }
          if(d<m) f=0;
        }
      }
      if(f) l=m;
      else r=m;
    }
    pd(l);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1304
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 200002;
const int L = 100000000;
const double PI = 3.141592653589793238462643383279;

struct Point
{
    int x, y;
    int ny;
};

bool cmpx (const Point &a, const Point &b)
{
    return a.x < b.x;
}

bool cmpy (const Point &a, const Point &b)
{
    return a.y < b.y;
}

Point a, b;

int n;

Point f[N_MAX];

int dp[N_MAX];

int BIT[N_MAX];

void update (int pos, int val)
{
    for(int i = pos; i <= n; i += i & -i)
        BIT[i] = max(BIT[i], val);
}

int query (int pos)
{
    int ans = 0;
    for(int i = pos; i >= 1; i -= i & -i)
        ans = max(ans, BIT[i]);
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a.x >> a.y >> b.x >> b.y;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> f[i].x >> f[i].y;
    if(a.x > b.x)
        swap(a, b);
    if(a.y > b.y)
    {
        a.y = L - 1 - a.y;
        b.y = L - 1 - b.y;
        for(int i = 1; i <= n; i++)
            f[i].y = L - 1 - f[i].y;
    }
    if(a.x == b.x)
    {
        double ans = (b.y - a.y) * 100.0;
        for(int i = 1; i <= n; i++)
            if(f[i].x == a.x && a.y <= f[i].y && f[i].y <= b.y)
            {
                ans -= 20.0;
                ans += 10.0 * PI;
                break;
            }
        cout << fixed << setprecision(17) << ans << "\n";
        return 0;
    }
    if(a.y == b.y)
    {
        double ans = (b.x - a.x) * 100.0;
        for(int i = 1; i <= n; i++)
            if(f[i].y == a.y && a.x <= f[i].x && f[i].x <= b.x)
            {
                ans -= 20.0;
                ans += 10 * PI;
                break;
            }
        cout << fixed << setprecision(17) << ans << "\n";
        return 0;
    }
    sort(f + 1, f + n + 1, cmpy);
    for(int i = 1; i <= n; i++)
        f[i].ny = i;
    sort(f + 1, f + n + 1, cmpx);
    int mx = 0;
    for(int i = 1; i <= n; i++)
        if(a.y <= f[i].y && f[i].y <= b.y && a.x <= f[i].x && f[i].x <= b.x)
        {
            dp[i] = query(f[i].ny) + 1;
            mx = max(mx, dp[i]);
            update(f[i].ny, dp[i]);
        }
    double ans = (b.x - a.x) * 100.0 + (b.y - a.y) * 100.0;
    ans -= 20.0 * mx;
    ans += 5.0 * PI * mx;
    if(mx == min(b.y - a.y + 1, b.x - a.x + 1))
        ans += 5.0 * PI;
    cout << fixed << setprecision(17) << ans << "\n";
    return 0;
}


Measured memory_bytes: 7724
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] in = sc.next().toCharArray();
		int max = 0;
		int jsum = 0;
		int osum = 0;
		int isum = 0;
		for(int i = 0; i < in.length; i++) {
			if(i != 0 && in[i] == 'J' && in[i-1] != 'J') jsum = 0;
			if(i != 0 && in[i] == 'O' && in[i-1] == 'I') {
				jsum = 0;
				osum = 0;
				isum = 0;
			}
			if(i != 0 && in[i] == 'I' && in[i-1] == 'J') {
				jsum = 0;
				osum = 0;
				isum = 0;
			}
			if(in[i] == 'J') {
				jsum++;
				osum = 0;
				isum = 0;
			}
			if(in[i] == 'O') {
				osum++;
				isum = 0;
			}
			if(in[i] == 'I') {
				isum++;
			}
			
			if(jsum >= osum && isum >= osum) max = Math.max(osum, max);
			
		}
		System.out.println(max);
	}

	
}

Measured memory_bytes: 32280
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
typedef pair<int, int> pii;
typedef long long ll;
 
int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> p(n), q(m);
    vector<pii> a;
    for (int i = 0; i < n; ++ i) {
        cin >> p[i];
        a.emplace_back(pii(p[i], 1));
    }
    for (int i = 0; i < m; ++ i) {
        cin >> q[i];
        a.emplace_back(pii(q[i], 0));
    }
 
    sort(begin(a), end(a));
 
    ll ans = 0;
    int rows = n + 1, cols = m + 1;
    for (int i = 0; i < n + m; ++ i) {
        if (a[i].second == 1) {
            if (rows == 1) continue;
            ans += cols * (ll)a[i].first;
            -- rows;
        } else {
            if (cols == 1) continue;
            ans += rows * (ll)a[i].first;
            -- cols;
        }
        if (rows == 1 && cols == 1) break;
    //    cout << rows << ' ' << cols << ' ' << ans << endl;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)
#define REP(i, r) for(int i = (int)0; i < (int)r; ++i)
#define FORD(i, l, r) for(int i = (int)l; i >= (int)r; --i)
#define REPD(i, r) for(int i = (int)r - 1; i >= 0; --i)
#define X first
#define Y second
#define debug(x) {cerr << #x << " = " << x << '\n';}
#define pr(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define pr0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int a, b, c, x, y;

int main() {
    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c) {
        cout << a * x + b * y;
    } else {
        cout << min(min(x, y) * 2 * c + (x > y ? a * (x - y) : b * (y - x)), max(x, y) * 2 * c);
    }
}


Measured memory_bytes: 256
from math import radians, cos

a, b, h, m = map(int, input().split())
s = 30 * h + (1 / 2) * m
l = 6 * m
theta = radians(abs(s - l))
ans = (a ** 2 + b ** 2 - (2 * a * b * cos(theta))) ** (1 / 2)
print(ans)

Measured memory_bytes: 9516
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  vector<int64> dp(n);
  for (int i = 1; i < n; ++i) {
    for (int j = i; j < n; j += i) {
      dp[j] += 1;
    }
  }
  int64 ret = 0;
  for (int c = 1; c < n; ++c) {
    ret += dp[n - c];
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 10680
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    int n;
    int ans=-1;
    cin >> n;
    vector<vector<P> > x(n);
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            P p;
            cin >> p.first >> p.second;
            p.first--;
            x[i].push_back(p);
        }
    }
    for(int bit=0;bit<(1<<n);bit++){
        bool flg=true;
        vector<int> t(n, 0);
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                t[i]=1;
            }
        }
        for(int i=0;i<n;i++){
            if(!(bit&(1<<i)))continue;
            for(auto p:x[i]) {
                if (t[p.first] == (1 - p.second)) {
                    flg=false;
                    break;
                } else {
                    t[p.first] = p.second;
                }
            }
            if(!flg) break;
        }
        if(flg){
            int sum=0;
            for(int i=0;i<n;i++){
                if(bit&(1<<i)){
                    sum++;
                }
            }
            chmax(ans,sum);
        }
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3608
//A First Grader
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    ll dp[N - 1][21];
    for(int i = 0; i < N - 1; i++) for(int j = 0; j < 21; j++)
            dp[i][j] = 0;
    dp[0][A[0]]++;
    for(int i = 1; i < N - 1; i++) {
        for(int j = 0; j < 21; j++) {
            if(dp[i - 1][j] == 0) continue;
            int ans = j + A[i];
            if(ans <= 20) dp[i][ans] += dp[i - 1][j];
            ans = j - A[i];
            if(ans >= 0) dp[i][ans] += dp[i - 1][j];
        }
    }

    cout << dp[N - 2][A[N - 1]] << endl;

    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main(){
     int n,i,j,a[100],k,m,b=0;
     cin>>n>>k;
     for(i=1;i<=n;i++)cin>>a[i];
     for(i=1;i<n;i++)
     for(j=i+1;j<=n;j++)
     	if(a[i]<a[j]){
     		m=a[i];a[i]=a[j];a[j]=m;
		 }
	 for(i=1;i<=k;i++)b=b+a[i];
	 cout<<b<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
const int maxN = 2e5+10;
const int INF = 999999999;

ll n,p;
ll a[maxN];
ll q[maxN];
struct node
{
	ll x,t;
};

ll tot = 0ll;
ll power(ll x,ll t)
{
	if(t == 0)
		return 1;
	ll y = power(x,t/2);
	y = y*y;
	if(t%2 == 1)
		y = y*x;
	return y;
}
bool check(ll x)
{
	if(p % (power(x,n)) == 0)
		return true;
	else 
		return false;
}
int main() {
	scanf("%lld%lld",&n,&p);
	if(n == 1)
	{
		printf("%lld\n",p);
		return 0;
	}
	ll ans = 0;
	for(ll i=1;n*log(i)<=log(p)+1;i++)
	{
		if(p % (power(i,n)) == 0)
			ans = max(ans,i);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    long long d = c - a - b;
    if (d > 0 && 4 * a * b < d * d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).size() % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diverta2019_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int abCount = 0;
            bool falseFindFlag = false;
            int firstCount = 0;
            int lastCount = 0;

            for (int i = 0; i < n; ++i)
            {
                string str = Console.ReadLine();
                abCount += CountOf(str, "AB");

                bool firstFlag = (str[0] == 'B');
                bool lastFlag = (str[str.Length-1] == 'A');

                if (lastFlag) { ++lastCount; }
                if (firstFlag) { ++firstCount; }
                if (!falseFindFlag && ((lastFlag && !firstFlag) || (!lastFlag && firstFlag))) { falseFindFlag = true; }
            }

            int addCount = (firstCount < lastCount) ? firstCount : lastCount;
            abCount += addCount;
            if (!falseFindFlag && addCount != 0) { --abCount; }

            Console.WriteLine("{0}", abCount);
        }

        public static int CountOf(string target, params string[] strArray)
        {
            int count = 0;

            foreach (string str in strArray)
            {
                int index = target.IndexOf(str, 0);
                while (index != -1)
                {
                    count++;
                    index = target.IndexOf(str, index + str.Length);
                }
            }

            return count;
        }
    }
}


Measured memory_bytes: 13408
#include<stdio.h>
#include<stdlib.h>

int main() {

	int n,m;
	int *s,*t;
	int i,j,k=0;
	int sums,sumt;
	int as,at;
	int answers[100],answert[100];

	for(;;) {

		sums=0;
		sumt=0;
		as=101;
		at=101;

		scanf("%d %d",&n,&m);
		if(n==0&&m==0)
			break;
		s=(int *)malloc(n * sizeof(int));
		t=(int *)malloc(m * sizeof(int));

		for(i=0;i<n;i++) {
			scanf("%d",&s[i]);
			sums+=s[i];
		}
		for(i=0;i<m;i++) {
			scanf("%d",&t[i]);
			sumt+=t[i];
		}

		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				if(sums-s[i]+t[j]==sumt-t[j]+s[i]) {
					if(as+at>s[i]+t[j]) {
						as=s[i];
						at=t[j];
					}
				}
			}
		}
		if(as!=101) {
			answers[k]=as;
			answert[k]=at;
		}
		else
			answers[k]=-1;
		k++;
		free(s);
		free(t);
	}

	for(i=0;i<k;i++) {
		if(answers[i]>=0)
			printf("%d %d\n",answers[i],answert[i]);
		else
			printf("%d\n",answers[i]);
	}

	return 0;
}

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

ll n[200001], h[200001];
ll A[200001], B[200001];


int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int N; cin >> N;
    for (int i = 1; i <= N; i++) {
        n[i] = i;
        cin >> h[i];
        A[i] = n[i] - h[i];
        B[i] = n[i] + h[i];
    }

    /*
    for (int i = 1; i <= N; i++) {
        cout << A[i] << ' ';
    }
    cout << '\n';
    for (int i = 1; i <= N; i++) {
        cout << B[i] << ' ';
    }
    cout << '\n'; */

    ll ans = 0;
    sort(B + 1, B + N + 1);
    for (int i = 1; i <= N; i++) {
        ans += upper_bound(B + 1, B + N + 1, A[i]) - lower_bound(B + 1, B + N + 1, A[i]);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 9864
$#q=$N=<>;
/ /,push@{$`},$' for<>;
map$q[$_]+=$q[$i]/@$i,@{$i=$_}for++$q[1]..$N;
while(--$N){$s=$m=0;$m=($~=$e[$_])>$m?$~:$m,$s+=$~for@$N;$e[$N]=1+$s/@$N;
$a<($t=$q[$N]*=$#$N&&($s-$m)/$#$N-$s/@$N)or$a=$t}
print"@e"+$a

Measured memory_bytes: 42368
#include <iostream>

#include <sstream>
#include <string>

#include <vector>
#include <array>

#include <list>
#include <queue>

#include <map>
#include <set>

#include <algorithm>
#include <memory>

#define PI 3.141592653589793238462643383279
#define For(v,i) for (int v = 0;v < (i);v++)

using namespace std;

int main() {

	string str;
	cin >> str;

	int c = -1;
	int f = -1;
	int count = 0;
	for (const auto& ch : str)
	{
		if (ch == 'C' && c == -1)
			c = count;
		if (c != -1 && ch == 'F' && f == -1)
			f = count;
		count++;
	}

	if (c != -1 && f != -1 && c < f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
int main(void) {
	int N, C[499], S[499], F[499], ans[499], i, j;
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++) {
		if (i != N - 1) scanf("%d %d %d", &C[i], &S[i], &F[i]);
		ans[i] = S[i] + C[i];
	}
	for (i = 0; i < N - 2; i++) {
		for (j = i + 1; j < N - 1; j++) {
			if (ans[i] >= S[j]) {
				if (ans[i] % F[j] == 0) ans[i] += C[j];
				else ans[i] += F[j] - (ans[i] % F[j]) + C[j];
			}
			else ans[i] = S[j] + C[j];
		}
	}
	for (i = 0; i < N - 1; i++) {
		printf("%d\n", ans[i]);
	}
	printf("0");


	return 0;
}

Measured memory_bytes: 128
import bisect
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        ind = bisect.bisect_right(L,num - 1)
        if ind > j - 1:
            ans += ind - j - 1
print(ans)

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

K.sort(key=lambda x:x[0])

tmp=set(K[0][1:])
for A in K[1:]:
  tmp=tmp&set(A[1:])
  
print(len(tmp))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


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

  int ans = 0;
  for(int i=0;i<4;i++) ans += s[i] == '+' ? 1 : -1;

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


Measured memory_bytes: 256
import java.util.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun bsIdxLte(A: LongArray, X: Long, includeEqual:Boolean = false): Int {
    val N = A.size
    if (N == 0) return -1
    val xLess: (Long)->Boolean = if (includeEqual) {
        { Y:Long -> X < Y }
    } else {
        { Y:Long -> X <= Y }
    }
    if (xLess(A[0])) return -1
    var l = 0; var r = N
    while (l < r - 1) {
        val m = (l + r) / 2
        if (xLess(A[m])) {
            r = m
        } else {
            l = m
        }
    }
    return l
}


fun solve(L: IntArray): Int {
    val N = L.size
    var res = 0

    val ln = L.sorted().map { it.toLong() }.toLongArray()

    for (i in 0 until N-2) {
        for (j in i+1 until N-1) {
            val sum = ln[i] + ln[j]
            val k = bsIdxLte(ln, sum)
            res += k - j
        }
    }

    return res
}


fun main(args: Array<String>) {
    val N = readInt()
    val L = readIntArray()

    val ans = solve(L)

    println(ans)
}


Measured memory_bytes: 40556
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

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

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $h, $p);
$waza_s = fgets(STDIN);
$exploded_waza_s = explode(' ', $waza_s);
rsort($exploded_waza_s);

foreach ($exploded_waza_s as $waza) {
  $h = $h - $waza;
  if ($h <= 0) {
    echo "Yes";
    exit;
  }
}
echo "No";

Measured memory_bytes: 12792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BFrog2 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni(), k = in.ni();
            int[] ar = new int[n];
            for (int i = 0; i < n; ++i) {
                ar[i] = in.ni();
            }
            int[] dp = new int[n];
            for (int i = 1; i < n; ++i) {
                int ans = Integer.MAX_VALUE;
                for (int j = Math.max(0, i - k); j < i; ++j) {
                    ans = Math.min(ans, dp[j] + Math.abs(ar[j] - ar[i]));
                }
                dp[i] = ans;
            }
            out.print(dp[n - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33972
#include<stdio.h>

int main(void){
	int n,a,b,c,d;
	
	while(scanf("%d",&n) != EOF){
		int count = 0;
		for(a = 0; a <= 9; a++){
			for(b = 0; b <= 9; b++){
				for(c = 0; c <= 9; c++){
					for(d = 0; d <= 9; d++){
						if(n == (a + b + c + d)){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}

Measured memory_bytes: 596
N = int(input())
A_lis = list(map(int, input().split()))
X_lis = []
S = sum(A_lis)
x0 = S - sum(map(lambda x:A_lis[x], list(range(1,len(A_lis),2))))*2
X_lis.append(x0)

for i in range(1,N):
	xi = 2*A_lis[i-1] - X_lis[i-1]
	X_lis.append(xi)
print(" ".join(map(str,X_lis)))


Measured memory_bytes: 19144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

bool check(int r, vint &a, int upper) {
    vint v;
    int n = a.size();
    rep(i,n) v.push_back(a[i] % r);
    sort(all(v));
    vll sum_l(n + 1, 0), sum_r(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        sum_l[i] += sum_l[i-1] + v[i-1];
        sum_r[i] += sum_r[i-1] + (r - v[n-i]);
    }
    bool res = false;
    for (int i = 1; i <= n; i++) {
        if (max(sum_l[i], sum_r[n-i]) <= upper) res = true;

    }
    return res;
}

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) sum += a[i];
    int ans = 0;
    for (int i = 1; i * i <= sum; i++) {
        if (sum % i != 0) continue;
        if (check(i, a, k)) chmax(ans, i);
        if (check(sum / i, a, k)) chmax(ans, sum / i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
N = int(input())
S = 0
s_list = []

input_list = list(map(int, input().split()))
allS = sum(input_list)

for n in input_list[:-1]:
  S += n
  s_list.append(abs(allS - 2 * S))
  
print(min(s_list))
  
  

Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int y, m;
  string s;

  cin >> s;

  y = ((s[0] - '0') * 10) + (s[1] - '0');
  m = ((s[2] - '0') * 10) + (s[3] - '0');
  
  if(1 <= y && y <= 12){
    if(1 <= m && m <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else{
    if(1 <= m && m <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}



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

using namespace std;
const int N = 100010;
int _w;

int n, k, a[N], ans;

namespace Tree {
	int head[N], nxt[N], to[N], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
	}
}

int dfs( int u, int fa ) {
	using namespace Tree;
	int d = 0;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( v == fa ) continue;
		d = max(d, dfs(v, u) + 1);
	}
	if( d == k-1 ) {
		ans += fa != 1 && fa != 0;
		return -1;
	} else {
		return d;
	}
}

int main() {
	_w = scanf( "%d%d", &n, &k );
	Tree::init();
	for( int i = 1; i <= n; ++i ) {
		_w = scanf( "%d", a+i );
		if( i != 1 ) Tree::link( a[i], i );
	}
	if( a[1] != 1 ) ++ans;
	dfs(1, 0);
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N,i,j,on;
  cin >> N;
  vector<int> out(N);
  vector<int> used(N);
  for (i=0;i<N;i++) {
    cin >> out.at(i);
  }
  for (i=0;i<N;i++) {
    on = out.at(on) -1;
    used.at(on)++;
    if (on == 1) {
      cout << i + 1 << endl;
      break;
    }
    else if (used.at(on) >= 2) {
      cout << -1 <<endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
    long long n;
    cin >> n;
    
    long long ans = 0;
    long long cnt = 1;
    while((n / cnt) - 1 > cnt) {
        if(n % cnt == 0) {
            ans += (n / cnt) - 1;
        }
        cnt++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 9000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	double r;
	cin>>r;
	r*=(double)6.28318530717958623200;
	cout.precision(10);
	cout1(r);
}
int main(){
    int t=1;
	//scanf("%d",&t);
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <array>
#include <numeric>
#include <vector>
#include <functional>

using namespace std;
const int maxn = 1e5 + 6;
using ll = long long;
array<int, maxn> fa;
int n, m;
using pii = pair<int, int>;
array<pii, maxn> sx, sy;

int find_root(int x) { return x == fa[x] ? fa[x] : fa[x] = find_root(fa[x]); }

struct Node {
    int u, v, w;

    Node() {}

    Node(int u, int v, int w) : u(u), v(v), w(w) {}

    bool operator<(const Node &v) const {
        return w < v.w;
    }
};

vector<Node> edge;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    iota(fa.begin() + 1, fa.begin() + 1 + n, 1);
    for (int i = 1; i <= n; ++i) {
        cin >> sx[i].first >> sy[i].first;
        sx[i].second = sy[i].second = i;
    }
    auto cmp = [&](pii a, pii b) -> bool { return a.first < b.first; };
    sort(sx.begin() + 1, sx.begin() + 1 + n, cmp);
    sort(sy.begin() + 1, sy.begin() + 1 + n, cmp);
    for (int i = 1; i < n; ++i) {
        edge.emplace_back(sx[i].second, sx[i + 1].second, sx[i + 1].first - sx[i].first);
        edge.emplace_back(sy[i].second, sy[i + 1].second, sy[i + 1].first - sy[i].first);
    }
    sort(edge.begin(), edge.end());
    ll ans = 0;
    auto size = static_cast<int>(edge.size());
    for (int i = 0; i < size; ++i) {
        if (find_root(edge[i].u) != find_root(edge[i].v)) {
            ans += edge[i].w;
            fa[find_root(edge[i].u)] = find_root(edge[i].v);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

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

    #ifndef ONLINE_JUDGE
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
        string s="ACL";
        int k;cin>>k;
        forn(i,k)cout<<s;
    }
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi a(m);
    rep(i,m){
        cin>>a[i];
    }
    int ans=0;
    rep(i,m){
        if(a[i]>m)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int n,m,l[100005];
long long ans;
struct node{int a,b;}c[100005];
int L(int x){
	if(x==l[x])return l[x];
	return l[x]=L(l[x]);
}
int cmp(node x,node y){
	return x.b>y.b;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=m;i++)l[i]=i;
	for(int i=1;i<=n;i++)scanf("%d%d",&c[i].a,&c[i].b);
	sort(c+1,c+n+1,cmp);
	for(int i=1;i<=n;i++){
		int j=m-c[i].a+1;
		if(j<1)continue;
		l[j]=L(l[j]);j=l[j];
		if(j>0){ans+=c[i].b;l[j]--;}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

const int N = 2e5+5;
int n, ar[N], prfx[N], ans = inf;

int f(int pos, int i, int j){
	if (!pos || pos>=i || i>=j || j==n) return inf;
	int x1 = prfx[pos], x2 = prfx[i]-prfx[pos], x3 = prfx[j]-prfx[i], x4 = prfx[n]-prfx[j];
	return (max(max(x1, x2), max(x3, x4)) - min(min(x1, x2), min(x3, x4)));
}

signed main(){
	cin >> n;
	for (int i=1; i<=n; i++){
		cin >> ar[i];
		prfx[i] = prfx[i-1]+ar[i];
	}
	for (int i=2; i<=n-2; ++i){
		auto l = upper_bound(prfx, prfx+n+1, prfx[i]/2) - prfx;
	    auto r = upper_bound(prfx, prfx+n+1, prfx[i]+(prfx[n]-prfx[i])/2) - prfx;
		for (int pos=l-1; pos<=l; ++pos){
			for (int j=r-1; j<=r; ++j){
				ans = min(ans, f(pos, i, j));
			}
		}
	}
	cout << ans;
}



Measured memory_bytes: 6720
#include<cstdio>
int main()
{
	int a,b;
	scanf("%d",&a);
	for(int i=1;;i++)
	{
		b=a%10;
		if(b==9||a==9)
			break;
		else
		{
			if(b<10&&a<10&&a!=9)
			{
				printf("No");
				return 0;
			}
			else
				a=a/10;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 128
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define act(a,b) (abs((a)-(b))>360?720-abs((a)-(b)):abs((a)-(b)))
using namespace std;
int main(){
  int i;
  int n;
  vector<int> h,m;
  cin>>n;
  h.reserve(n);
  m.reserve(n);
  for(i=0;i<n;i++)
    scanf("%d:%d",&h[i],&m[i]);
  for(i=0;i<n;i++){
    if(act(h[i]%12*60+m[i],m[i]*12)<60)
      puts("alert");
    else if(act(h[i]%12*60+m[i],m[i]*12)<180)
      puts("warning");
    else
      puts("safe");
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll k;
    cin>>k;
   ll t=0;
    for(int i=1;i<=(1e7);i++)
    {
        t=(t*10+7)%k;
        if(t==0)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;

}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};

int main(){
	int n;
	cin >>n;
	VI a(n);
	deque<int> dq;
	rep(i,n) cin >>a[i];
	sort(all(a));
	
	dq.push_back(a[0]);
	int l=1, r=n-1;
	rep(i, n){
		if(r<l) break;
		if(i%2==0){
			if(r>=l) dq.push_back(a[r--]);
			if(r>=l) dq.push_front(a[r--]);
		}else{
			if(r>=l) dq.push_back(a[l++]);
			if(r>=l) dq.push_front(a[l++]);
		
		}
	}
	//for(auto x :dq) printf("%d, ",x); puts("");
	ll sm =0;
	rep(i,n-1) sm += abs(dq[i] - dq[i+1]);
	
	dq.clear();
	dq.push_back(a.back());
	l=0, r=n-2;
	rep(i, n){
		if(r<l) break;
		if(i%2==1){
			if(r>=l) dq.push_back(a[r--]);
			if(r>=l) dq.push_front(a[r--]);
		}else{
			if(r>=l) dq.push_back(a[l++]);
			if(r>=l) dq.push_front(a[l++]);
		
		}
	}
	//for(auto x :dq) printf("%d, ",x); puts("");
	ll sm2 =0;
	rep(i,n-1) sm2 += abs(dq[i] - dq[i+1]);
	
	//dbg(sm ,sm2);
	
	cout << max(sm, sm2) <<"\n";
}



Measured memory_bytes: 1024
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
int main()
{
    int n, tm, c, t, ans = INT_MAX;
    cin >> n >> tm;
    for(int i = 0; i < n; i++){
        cin >> c >> t;
        if(t <= tm){
            ans = min(ans, c);
        }
    }
    if(ans == INT_MAX) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
AB = [LIST() for _ in range(N)]

X = -sum([x[1] for x in AB])

for i, (A, B) in enumerate(sorted(AB, key=lambda x:x[0]+x[1], reverse = True)):
	if i%2 == 0:
		X += A+B
print(X)

Measured memory_bytes: 34160
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL,LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

const LL M1 = 1e+9+9, M2 = 1e9+7;
const LL X = 1e+6+3;

PLL f(string& s){
  PLL pll(0,0);
  REP(i,SZ(s)){
	pll.first = (pll.first * X + s[i]) % M1;
	pll.second = (pll.second * X + s[i]) % M2;
  }
  return pll;
}

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

  int N; cin >> N;
  set<PLL> s;
  while(N--){
	string q, str;
	cin >> q >> str;
	if(q == "insert"){
	  s.insert(f(str));
	}
	else{
	  if(s.count(f(str)))
		cout << "yes" << endl;
	  else
		cout << "no" << endl;
	}
  }
  
  return 0;
}

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

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

    int x = 1;
    for (int i = 0; i < n; ++i) {
        x = min(x * 2, x + k);
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256