akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define mii map<int,int>


using namespace std;

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

    vi a(n),dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	
    }

    for(int i=0;i<=n-2;i++){
    	dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
    	dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
    }


    // for(int i=1;i<n;i++){
    // 	for(int j=0;j<k;j++){

    // 	}
    // 	dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
    // 	dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    // }0


    cout<<dp[n-1]<<endl;
}

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

int main(){
  int n;
  int p[8], q[8];
  int countp=0, countq=0;
  cin >> n;
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n;i++)cin>>q[i];
  
  for(int i=0;i<n-1;i++){
    int tmp=p[i];
    for(int j=n-1-i;j>=1;j--)tmp*=j;
    //cout << "tmp" << tmp;
    countp+=tmp;
    for(int j=i+1;j<n;j++){
      if(p[i]<p[j])p[j]--;
    }
  }
  //cout << "p=" << countp <<endl;
  
  for(int i=0;i<n-1;i++){
    int tmp=q[i];
    for(int j=n-1-i;j>=1;j--)tmp*=j;
    //cout << "tmp" << tmp;
    countq+=tmp;
    for(int j=i+1;j<n;j++){
      if(q[i]<q[j])q[j]--;
    }
  }
  //cout << "q=" << countq <<endl;
  cout << abs(countp-countq) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, ans;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) FOR(j, 1, n) FOR(k, 1, n) {
		ans += gcd(i, gcd(j, k));
	}
	cout << ans;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;

int n;
ll a[maxn];
ll ans[maxn];

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> n;
   for(int i = 0; i < n; i++) cin >> a[i], a[i] *= 2;
   ll y = 0;
   for(int i = 0; i < n; i++){
     if(i % 2 == 0) y += a[i];
     else y -= a[i];
   }
   if(n % 2) ans[0] = y / 2;
   else ans[0] = y;
   for(int i = 1; i < n; i++)
     ans[i] = a[i-1] - ans[i - 1];
   for(int i = 0; i < n; i++)
    cout << ans[i] << " ";
   return 0;

}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;

typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n;
string s;
vector<int> blue(5000), green(5000), red(5000);

int calc(int i, int j){
    int ret;
    if(s[i] == 'R' and s[j] == 'G'){
        ret = blue[j];
        if(s[j + (j-i)] == 'B')ret--;
    }
    else if(s[i] == 'R' and s[j] == 'B'){
        ret = green[j];
        if(s[j + (j-i)] == 'G')ret--;
    }
    else if(s[i] == 'G' and s[j] == 'B'){
        ret = red[j];
        if(s[j + (j-i)] == 'R')ret--;
    }
    else if(s[i] == 'G' and s[j] == 'R'){
        ret = blue[j];
        if(s[j + (j-i)] == 'B')ret--;
    }
    else if(s[i] == 'B' and s[j] == 'R'){
        ret = green[j];
        if(s[j + (j-i)] == 'G')ret--;
    }
    else if(s[i] == 'B' and s[j] == 'G'){
        ret = red[j];
        if(s[j + (j-i)] == 'R')ret--;
    }
    return ret;
    

}


int main(){
    cin >> n;
    cin >> s;
    ll ans = 0;
    
    blue[n] = 0;
    green[n] = 0;
    red[n] = 0;
    per(i, 1, n){
        if(s[i] == 'R'){
            red[i-1] += red[i] + 1;
            blue[i-1] += blue[i];
            green[i-1] += green[i];
        }else if (s[i] == 'G'){
            red[i-1] += red[i];
            blue[i-1] += blue[i];
            green[i-1] += green[i]+1;
        } else {
            red[i-1] += red[i];
            blue[i-1] += blue[i] + 1;
            green[i-1] += green[i];
        }
    }
    // for(int i = 0; i < n+1; i++)cout << red[i] << " ";
    // cout << endl;
    // for(int i = 0; i < n+1; i++)cout << blue[i] << " ";
    // cout << endl;
    // for(int i = 0; i < n+1; i++)cout << green[i] << " ";
    // cout << endl;
    for(int i = 0; i < n - 2; i++){
        for(int j = i+1; j < n - 1; j++ ){
            if(s[i] == s[j])continue;
            // cout << i << " " << j << endl;
            ans += calc(i,j);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
long long read()
{
    long long f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}
int a[2019];
int main()
{
    int c,d,n,ans=0;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    for(int j=1;j<i;j++)
    {
        c=a[i]+a[j];
        ans+=lower_bound(a+1,a+1+n,c)-a-i-1;
    }
    cout<<ans<<endl;
    return 0;
}


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

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

using namespace std;

string LCS(const string &s,const string &t){
	const int LMAX=300;
	static int dp[LMAX+1][LMAX+1],from[LMAX+1][LMAX+1];
	int slen=s.length(),tlen=t.length();

	rep(i,slen+1)	dp[i][0]=0,from[i][0]=-1;
	rep(j,tlen+1)	dp[0][j]=0,from[0][j]=-1;

	for(int i=1;i<=slen;i++)for(int j=1;j<=tlen;j++){
		dp[i][j]=0;
		int a[]={dp[i][j-1],dp[i-1][j],dp[i-1][j-1]+(s[i-1]==t[j-1])};
		rep(k,3)if(dp[i][j]<a[k]){ dp[i][j]=a[k]; from[i][j]=k; }
	}

	int l=dp[slen][tlen];
	string ans(l,'@');
	for(int x=tlen,y=slen;~from[y][x];){
		switch(from[y][x]){
			case 0: x--; break;
			case 1: y--; break;
			case 2: x--; y--; ans[--l]=s[y]; break;
		}
	}

	return ans;
}

int main(){
	for(string s;cin>>s,s!="#END";){
		int len=s.length();
		string ans;
		for(int i=1;i<len;i++){
			string tmp=LCS(s.substr(0,i),s.substr(i));
			if(ans.length()<tmp.length())	ans=tmp;
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int d, t, s;
  cin >> d >> t >> s;
  if (d/s + (d%s > 0) <= t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-

# input
N = int(input())
W = list()
for i in range(N):
    W.append(input())

# solve
ans = True
if len(set(W)) != N:
    ans = False
else:
    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            ans = False

# output
print('Yes' if ans else 'No')


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication33
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int x = 0, y = 0;
                string a = Console.ReadLine();
                if (a == null) break;
                string[] b = a.Split();
                string c = Console.ReadLine();
                if (c == null) break;
                string[] d = c.Split();
                for (int e = 0; e < 4; e++)
                {
                    if (b[e] == d[e])
                    {
                        x++;
                        for (int u = e; u < 4; u++)
                        {
                            try { b[u] = b[u+ 1]; }
                            catch { b[u] = "b"; }
                            try { d[u] = d[u + 1]; }
                            catch { d[u] ="a"; }
                        }e = -1;
                    }
                }
                string[] k = new string[4 - x];
                for(int r = 0; r < 4 - x; r++)
                {
                    k[r] = b[r];
                }
                string[] q = new string[4 - x];
                for (int o = 0; o < 4 - x; o++)
                {
                    q[o] = d[o];
                }
                 for(int h = 0; h < 4 - x; h++)
                 {
                     for(int w = 0; w < 4 - x; w++)
                     {
                         if (k[h] == q[w]) y++;
                     }
                 }
                 Console.WriteLine(x+" "+y);
            }
        }
    }
}

Measured memory_bytes: 9068
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
const int MAX_N = 1e5;


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

    int N, M;
    cin >> N >> M;
    vector<int> elev(N + 1);
    for (int i = 1; i <= N; ++i)
    {
        cin >> elev[i];
    }

    vector<int> max_adj_of(N + 1);
    while (M--)
    {
        int i, j;
        cin >> i >> j;

        max_adj_of[i] = max(max_adj_of[i], elev[j]);
        max_adj_of[j] = max(max_adj_of[j], elev[i]);
    }

    int ans = 0;
    for (int obs = 1; obs <= N; ++obs)
    {
        ans += elev[obs] > max_adj_of[obs];
    }

    cout << ans;
}


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

int main(){
    int n,m;cin>>n>>m;
    int ans=0;
    vector<int>l(m);
    vector<int>r(m);
    rep(i,m)cin>>l[i]>>r[i];
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());

    for(int i=l[m-1];i<=r[0];i++){
        ans++;
    }
   
    cout<<ans;

}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
string s1, t;
vector < string > pool;
int main() {
    cin >> s1 >> t;
    if (t.size() > s1.size()) {
        cout << "UNRESTORABLE";
        return 0;
    }
    for (int i = 0; i <= s1.size() - t.size(); i++) {
        bool mark = true;
        for (int j = 0; j < t.size(); j++) {
            if (s1[i + j] == '?') continue;
            if (s1[i + j] != t[j]) {
                mark = false;
                break;
            }
        }
        string x;
        if (mark) {
            for (int k = 0; k < i; k++) {
                if (s1[k] == '?') {
                    x += 'a';
                }
                else x += s1[k];
            }
            x += t;
            for (int k = i + t.size(); k < s1.size(); k++) {
                if (s1[k] == '?') {
                    x += 'a';
                }
                else x += s1[k];
            }
            pool.push_back(x);
        }
    }
    if (pool.size() == 0) {
        cout << "UNRESTORABLE";
        return 0;
    }
    string curmin = pool[0];
    for (int i = 0; i < pool.size(); i++) {
        if (curmin > pool[i]) {
            curmin = pool[i];
        }
    }
    cout << curmin;
    return 0;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, x, y;
bool a[1 << 9];
vector<pair<int, int>> res;

void move(int tx, int ty) {
  while (x > tx)
    x--, res.push_back({x, y});
  while (x < tx)
    x++, res.push_back({x, y});
  while (y > ty)
    y--, res.push_back({x, y});
  while (y < ty)
    y++, res.push_back({x, y});
}

void solve(vector<int> p, bool d = false) {
  if (sz(p) == 1) {
    move(p[0] + d, 0);
    move(p[0] + d, 1);
    move(p[0] + !d, 1);
    move(p[0] + !d, 0);
    return;
  }
  vector<int> c;
  c.push_back(p.back());
  p.pop_back();
  if (!d) {
    solve(c, d);
    solve(p, d);
    solve(c, !d);
    solve(p, !d);
  } else {
    solve(p, !d);
    solve(c, !d);
    solve(p, d);
    solve(c, d);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  char c;
  bool p = true;
  for (int i = 0; i < 1 << n; i++) {
    cin >> c, a[i] = c == '1';
    if (a[i])
      for (int j = 1 << n; j >= 0; j--)
        p &= a[i & j];
  }
  p &= a[0];
  if (!p) {
    cout << "Impossible\n";
    return 0;
  }
  for (int i = 0; i < 1 << n; i++) {
    p = !a[i];
    for (int j = 1 << n; j >= 0; j--)
      if ((i & j) != i)
        p &= a[i & j];
    if (p) {
      vector<int> pos;
      for (int j = n - 1; j >= 0; j--)
        if ((i >> j) & 1)
          pos.push_back(j);
      solve(pos);
    }
  }
  move(0, 0);
  cout << "Possible\n";
  cout << sz(res) << "\n";
  cout << "0 0\n";
  for (auto pos : res)
    cout << pos.first << " " << pos.second << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,k;
  cin >> a >> b >> k;
  if(k>=a){
    cout << 0 << " ";
    ll res = max(0LL,b-(k-a));
    cout << res << "\n";    
  }
  else{
    cout << a-k << " ";
    cout << b << "\n";    
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void) {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
count = 0
dic = {}
ans = [0 for i in range(len(S))]
ind = []
for i in range(len(S)-1):
  if S[i]=='R' and S[i+1]=='L':
    ind += [i]
j = 0
k = 0
for i in range(len(S)):
  s = S[i]
  if s=='R':
    while i>ind[j]:
      j+=1
    if (ind[j]-i)%2==0:
      ans[ind[j]]+=1
    else:
      ans[ind[j]+1]+=1
  if s=='L':
    while ind[k]<i:
      k +=1
      if k==len(ind):
        break
    k -= 1
    if (ind[k]-i)%2==0:
      ans[ind[k]]+=1
    else:
      ans[ind[k]+1]+=1
A = [str(i) for i in  ans]
print(' '.join(A))


Measured memory_bytes: 50996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a,b,c,count=0;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		for(int i = a; i<=b;i++){
			if(c%i==0)
				count++;
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26356
#include<stdio.h>
 int main(){
  int W,H,x,y,r;
   scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(x-r<0||y-r<0||x+r>W||y+r>H) printf("No\n");
    else printf("Yes\n");
  return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define MOD 998244353

using namespace std;

using ll = long long;

template <class T, T M>
class modulo {
public:
    T data;

    modulo(T data = 0) : data(data % M) {
    }

    modulo operator+(const modulo &x) const {
        return modulo(data + x.data);
    }

    modulo operator-(const modulo &x) const {
        return modulo(data + (M - x.data));
    }

    modulo operator*(const modulo &x) const {
        return modulo(data * x.data);
    }

    modulo operator/(const modulo &x) const {
        return modulo(data * x.inv().data);
    }

    modulo operator+=(const modulo &x) {
        return data = (data + x.data) % M;
    }

    modulo operator-=(const modulo &x) {
        return data = (data + (M - x.data)) % M;
    }

    modulo operator*=(const modulo &x) {
        return data = (data * x.data) % M;
    }

    modulo operator/=(const modulo &x) {
        return data = (data * x.inv().data) % M;
    }

    modulo inv() const {
        return _pow(M - 2);
    }

    template <class Integer>
    modulo operator^(Integer n) const {
        if (n >= 0) {
            return _pow(n);
        } else {
            return _pow(M - 1 - (-n) % (M - 1));
        }
    }

    friend std::ostream& operator<<(std::ostream &os, const modulo &x) {
        os << x.data;
        return os;
    }

private:
    template <class NonNegativeInteger>
    modulo _pow(NonNegativeInteger n) const {
        modulo result(1);
        modulo x(*this);
        while (n) {
            if (n & 1) {
                result *= x;
            }
            x *= x;
            n >>= 1;
        }
        return result;
    }
};

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    using Mod = modulo<ll, MOD>;

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    vector<vector<Mod>> T0(C + 1, vector<Mod>(D + 1, 0));
    vector<vector<Mod>> T1(C + 1, vector<Mod>(D + 1, 0));
    vector<vector<Mod>> T2(C + 1, vector<Mod>(D + 1, 0));

    T0[A][B] = 1;
    FOR(i, A + 1, C + 1) {
        T0[i][B] = T0[i - 1][B] * B;
    }
    FOR(j, B + 1, D + 1) {
        T0[A][j] = T0[A][j - 1] * A;
    }

    FOR(i, A + 1, C + 1) FOR(j, B + 1, D + 1) {
        T0[i][j] = (T0[i - 1][j - 1] + T1[i - 1][j - 1] + T2[i - 1][j - 1]) * (i - 1) * (j - 1);
        T1[i][j] = T1[i][j - 1] * i + T0[i][j - 1] + T2[i][j - 1];
        T2[i][j] = T2[i - 1][j] * j + T0[i - 1][j] + T1[i - 1][j];
    }

    Mod result = T0[C][D] + T1[C][D] + T2[C][D];

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 214516
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <unordered_map>
using namespace std;

int main() {

int n;
cin>>n;

vector<int> x;
vector<int> y;
int a,b;

for(int i=0; i<n;i++){
  cin>>a>>b;
  x.push_back(a+b);
  y.push_back(a-b);
}

a = *max_element(x.begin(),x.end()) - *min_element(x.begin(),x.end());
b = *max_element(y.begin(),y.end()) - *min_element(y.begin(),y.end());

cout<<max(a,b)<<endl;



return 0;
}


Measured memory_bytes: 5060
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int N = r.i();
        int[] a = r.ii();
        Arrays.sort(a);
        int ans = 0;
        for(int i = 0; i < N; ){
            int j = a[i];
            int count = 0;
            while(i < N && a[i] == j){
                count++;
                i++;
            }
            if(j <= count)
                ans += count-j;
            else
                ans += count;
        }
        println(ans);
    }
    static class EdgeList{
        int id;
        ArrayList<int[]> list = new ArrayList<>();
        int d;
        EdgeList(int n){
            id = n;
        }
        void add(int[] a){
            list.add(a);
        }
        int size(){
            return list.size();
        }
        void setD(int d){
            this.d = d;
        }
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 42452
#include <stdio.h>
int main(void){
    int h, w, i, j;
    
    while(1){
    
        scanf("%d %d",&h,&w);
        if(h == 0 && w == 0){
           break;
        }
        else{
            for(i = 0; i < h; i++){
                for(j = 0; j < w; j++){
                    if(j != 0 && j != (w-1) && i != 0 && i != (h-1)){
                        printf(".");
                    }
                    else{
                        printf("#");
                    }
                }printf("\n");
            }
        printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2140
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] A = new long[M];
		long sum = 0;
		for (int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		sc.close();

		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println(N - sum);
		}
	}
}


Measured memory_bytes: 46628
import math
n = int(input())
min_digits = len(str(n))
sq_n = math.ceil(math.sqrt(n))
for i in range(1, sq_n+1):
    if not n % i:
        digit = max(len(str(i)),len(str(int(n/i))))
        min_digits = digit if digit<min_digits else min_digits
print(min_digits)


Measured memory_bytes: 3060
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 1;

#include <unistd.h>

bool test(int64_t tgt, vector<int64_t>& A, int64_t K) {
  int64_t c_tgt = tgt;
  auto gt_idx = A.begin();
  while (K >= 0) {
    gt_idx = upper_bound(gt_idx, A.end(), c_tgt);
    int64_t gt_tgt = A.end() - gt_idx;
    //cout << tgt << "," << gt_tgt << "," << K << "," << c_tgt << endl;
    if (gt_tgt == 0) break;
    K -= gt_tgt;
    c_tgt += tgt;
  }
  if (K >= 0) return true;
  else return false;
}

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

  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (auto& a : A) {
    cin >> a;
  }
  sort(A.begin(), A.end());
  int64_t tgt_min = 0;
  int64_t tgt_max = A[N-1];
  int64_t tgt_mid = tgt_max;
  int64_t res = tgt_mid;
  while (tgt_min < tgt_mid) {
    if (test(tgt_mid, A, K)) {
      res = min(res, tgt_mid);
      tgt_max = tgt_mid;
      //cout << tgt_mid << " is ok " << endl;
    } else {
      //cout << tgt_mid << " is NG " << endl;
      tgt_min = tgt_mid;
    }
    tgt_mid = (tgt_max + tgt_min) / 2;
  }
  
  cout << res << endl;

  return 0;
}


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

int main(){
    int s,w;
    cin >> s >> w;
    
    
    if(s > w){
        cout << "safe" << endl;
    }else{
        cout << "unsafe" << endl;
    }
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
    
I = arr.count(3)
J = arr.count(2)
K = arr.count(1)
    
dp = [[[0 for _ in range(I+J+K+1)] for __ in range(I+J+1)]
        for ___ in range(I+1)]
    
for i in range(I+1):
    for j in range(I+J+1-i):
        for k in range(I+J+K+1-i-j):
            if i + j + k == 0:
                continue
            tmp = 0
            if k > 0:
                tmp += (k/n)*dp[i][j][k-1]
            if j > 0:
                tmp += (j/n)*dp[i][j-1][k+1]
            if i > 0:
                tmp += (i/n)*dp[i-1][j+1][k]
            dp[i][j][k] += (n/(i+j+k))*(1 + tmp)
    
print(dp[I][J][K])

Measured memory_bytes: 520816
/*************************************
 * problem:      ABC127 problem C.
 * user name:    hkxadpall.
 * time:         2019-05-25.
 * language:     C++.
 * upload place: AtCoder.
*************************************/ 

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

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}  

int n, m;
int l, r;
int rl, rr;

int main()
{
    n = read<int>();
    m = read<int>();
    l = 1;
    r = n;
    for (int i = 1; i <= m; i++) {
        rl = read<int>();
        rr = read<int>();
        if (rl > l) l = rl;
        if (rr < r) r = rr;
        if (l > r) {
            puts("0");
            return 0;
        }
    }
    write(r - l + 1);
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 1<<29;


int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  bool loop = true;
  while (loop){
    int maxv = -1;
    rep(i, n) maxv = max(maxv, h[i]);
    if (maxv == 0){
      cout << ans << endl;
      loop = false;
      return 0;
    }

    bool ok = false;
    rep(i, n) {
      if (!ok && h[i] == maxv) {
        h[i]--;
        ok = true;
      } else if (ok && h[i] == maxv){
        h[i]--;
      } else if (ok && h[i] != maxv){
        ans++;
        ok = false;
      }
    }
    if (ok) ans++;
  }

  return 0;
}

Measured memory_bytes: 256
from itertools import permutations, product

def main():
    N, C = map(int, input().split())
    Dc = [tuple(map(int, input().split())) for _ in [0] * C]
    Cn = [tuple(map(int, input().split())) for _ in [0] * N]

    sum_ = [[0] * C for _ in [0] * 3]
    for i, j in product(range(N), repeat=2):
        c = Cn[i][j] - 1
        n = (i + j) % 3
        for k in range(C):
            sum_[n][k] += Dc[c][k]

    cost = float('inf')
    for i, j, k in permutations(range(C), 3):
        cost = min(cost, sum_[0][i] + sum_[1][j] + sum_[2][k])
    print(cost)

main()


Measured memory_bytes: 5108
def perm(n, r):
    rtn = 1
    for i in range(r):
        rtn *= n-i
    return rtn

def cmb(n, r):
    return perm(n, r) // perm(r, r)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnts = [0]*(2*10**5 + 1)
    for v in a:
        cnts[v] += 1
    buf = 0
    for i in range(2*10**5 + 1):
        if cnts[i] > 0:
            buf += cmb(cnts[i], 2)
    for i in range(n):
        x = a[i]
        if cnts[x] <= 1:
            print(buf)
        else:
            ans = buf
            ans -= cmb(cnts[x], 2)
            print(ans + cmb(cnts[x]-1, 2))

if __name__ == "__main__":
    main()

Measured memory_bytes: 26140
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a == b && a == c) { cout << 1 << endl; }
	else if ((a==b && c!=a) || (a==c && a!=b) || (c==b && a!=b)) { cout << 2 << endl; }
	else { cout << 3 << 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, gcd
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 heapq import heappush, heappop
from functools import reduce, lru_cache
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 TUPLE(): return tuple(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 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, X, T = MAP()
print(-(-N//X)*T)

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

int main(){
  string S;
  cin >> S;
  
  string former = S.substr(0,(int)S.size()/2);
  string later = S.substr((int)S.size()/2+1, (int)S.size()/2);
  string rformer = former;
  string rlater = later;
  string rS = S;
  reverse(rS.begin(),rS.end());
  reverse(rformer.begin(),rformer.end());
  reverse(rlater.begin(),rlater.end());
  
  if(0 == S.compare(rS) &&
     0 == former.compare(rformer) &&
     0 == later.compare(rlater)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n;
string s[200005];
map<string, int> c;
vector<string> ans;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    c[s[i]]++;
  }

  ll m = 0;
  for (auto i = c.begin(); i != c.end(); i++) {
    if ((*i).second > m) {
      ans.erase(ans.begin(), ans.end());
      ans.push_back((*i).first);
      m = (*i).second;
    } else if ((*i).second == m) {
      ans.push_back((*i).first);
    }
  }

  sort(ans.begin(), ans.end());

  for (auto i = ans.begin(); i != ans.end(); i++) {
    cout << *i << endl;
  }
}

Measured memory_bytes: 33452
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
int N;


int main() {
    crap;
    cin >> N;

    vi A(N+1), B(N+1), C(N+1);
    vector<vi> dp(N+1, vi(3,INT_MIN));
    // 0 -> A
    // 1 -> B
    // 2 -> C

    forin(i, 1, N+1) {
        cin >> A[i] >> B[i] >> C[i];
    }

    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;

    forin(i,0,N) {
        forin(j, 0, 3) {
            if(j==0) {
                dp[i+1][j] = max(dp[i][1] + A[i+1], dp[i][2] + A[i+1]);
            } else if(j==1) {
                dp[i+1][j] = max(dp[i][0] + B[i+1], dp[i][2] + B[i+1]);
            } else {
                dp[i+1][j] = max(dp[i][0] + C[i+1], dp[i][1] + C[i+1]);
            }
        }
    }
    int ans = INT_MIN;

    // forn(i, N+1) {
    //     forn(j,3) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    forn(i,3) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;

}

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

template<typename T> T in() { abort(); return T(); }
template<> std::string in() { std::string str; std::cin >> str; return str; }
template<> int in() { int x; scanf("%d", &x); return x; }

template<typename T> void out(T x) { abort(); }
template<> void out(const char* x) { printf("%s\n", x); }
template<> void out(std::string x) { std::cout << x << std::endl; }
template<> void out(int x) { printf("%d\n", x); }
template<> void out(long x) { printf("%ld\n", x); }

std::string str;

int main() {
  std::cin >> str;
  int n = str.size();

  int left = -1, right = -1;
   
  // step 1 oo
  for(int i = 1; i < n; ++i) {
    if( str[i-1] == str[i] ) {
      left  = i - 1;
      right = i;
      break;
    }
  }
  if( left != -1 ) {
    printf("%d %d\n", left + 1, right + 1);
    return 0;
  }

  // step 2 oxo
  for(int i = 2; i < n; ++i) {
    if( str[i-2] == str[i] ) {
      left  = i - 2;
      right = i;
      break;
    }
  }
  if( left != - 1 ) {
    printf("%d %d\n", left + 1, right + 1);
    return 0;
  }

  // step 3 fail
  printf("%d %d\n", left, right);
        
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

struct Node
{
	int to,w;
};

int n,m;
vector<Node> G[100010];
int Indegree[100010];
int dis[100010];
int ans;

void Topsort()
{
	queue<int> q;
	for(int i=1;i<=n;i++)
	{ 
		if(Indegree[i]==0)
		{
			q.push(i);
			dis[i]=0;
		}
	}
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].to;
			dis[v]=max(dis[v],dis[u]+1);
			ans=max(ans,dis[v]);
			Indegree[v]--;
			if(Indegree[v]==0)
			{
				q.push(v);
			}
		}
	}
} 

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u;
		Node tmp;
		scanf("%d%d",&u,&tmp.to);
		tmp.w=1;
		Indegree[tmp.to]++;
		G[u].push_back(tmp);
	}
	Topsort();
	printf("%d",ans);
	return 0;
}











Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
 
int idx,size;
bool found;
map<string,int> mp;
 
int getNum(const string &s){
    int res = 0, w = 1;
    string str;
    while(isdigit(s[idx])){
	str += s[idx];
	idx++;
    }
    for(int i = str.size()-1 ; i >= 0 ; i--){
	res += (str[i]-'0')*w;
	w *= 10;
    }
    return res;
}
 
int parse(const string &s){
    if(idx >= size) return 0;
    int num = 1;
    if(s[idx] == '('){
	idx++;
	int n = parse(s),a = 0;
	idx++;
	if(idx < size){
	    if(isdigit(s[idx])){
		num = getNum(s);
	    }
	}
	if(idx < size && s[idx] != ')'){
	    a = parse(s);
	}
	return n*num + a;
    }else if(isalpha(s[idx])){
	int res = 0;
	string str;
	while(idx < size && isalpha(s[idx])){
	    int f = -1;
	    str += s[idx++];
	    if(idx < size && !islower(s[idx])){
		if(mp.find(str) != mp.end()){
		    f = mp[str];
		    str = "";
		}else{
		    found = false;
		}
	    }
	    if(f != -1 && idx < size && isdigit(s[idx])){
		f *= getNum(s);
	    }
	    if(f != -1) res += f;
	}
	if(!str.empty()){
	    int f = -1;
	    if(mp.find(str) != mp.end()){
		f = mp[str];
	    }else{
		found = false;
	    }
	    if(f != -1 && idx + 1 < size && isdigit(s[idx+1])){
		idx++;
		f *= getNum(s);
	    }
	    if(f != -1) res += f;
	}
	if(!found) return -1;
	int a = 0;
	if(idx < size && s[idx] != ')'){
	    a = parse(s);
	}
	return res + a;
    }
}
 
int main(){
    string s;
    int num;
    while(cin >> s, s != "END_OF_FIRST_PART"){
	cin >> num;
	mp[s] = num;
    }
    while(cin >> s, s != "0"){
	idx = 0;
	found = true;
	size = s.size();
	int ans = parse(s);
	if(found){
	    cout << ans << endl;
	}else{
	    cout << "UNKNOWN" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3208
// atcoder/abc159/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> a(n);
    cin >> a;

    map<int, lli> m;
    each (i, a) ++m[i];

    lli z = 0;
    each (i, m) {
      z += (i.second - 1) * i.second / 2;
    }

    each (i, a) {
      lli x = (m[i] - 1) * m[i] / 2;
      lli y = (m[i] - 2) * (m[i] - 1) / 2;
      setmax(i, 0);
      cout << z - x + y << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;
typedef complex<double> com;

double tri(com a, com b) //triangle size
{
	return(conj(a)*b).imag() / 2;
}

queue<com> N; //node
double x, y, xo, yo;
double S = 0;
int n;
com a;

int main()
{
	cout.setf(ios::fixed);
	cin >> n;
	cin >> xo >> yo;
	for (int i = 1; i<n; i++)
	{
		cin >> x >> y;
		N.push(com(x - xo, y - yo));
	}
	while (!N.empty())
	{
		a = N.front();
		N.pop();
		if (N.empty()) break;
		S += tri(a, N.front());
	}
	cout << setprecision(1) << S << endl;
	return 0;
}


Measured memory_bytes: 3272
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] ints = new int[101];
		int max = Integer.MIN_VALUE;
		while (sc.hasNext()) {
			int temp = sc.nextInt();
			ints[temp]++;
			max = Math.max(max,ints[temp]);
		}
		for (int i=1; i<101; i++) {
			if (ints[i]==max) {System.out.println(i);}
		}
	}
}	


Measured memory_bytes: 26344
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

int cDiv(int x, int y) { return y == 0 ? INF : (x+y-1)/y; }


int main() {
  ll n, m; cin >> n >> m;

  V ans(m+2);
  rep(i, n) {
    int l, r; cin >> l >> r;
    int d = 1;
    while (d <= l) {
      int a = cDiv(l, d);
      int x = r/a+1;
      if (a > 1) chmin(x, cDiv(l, a-1));
      ++ans[d];
      --ans[x];
      // d = cDiv(l, a-1);
      if ((l-1)/d == 0) d = INF;
      else d = (l-1) / ((l-1)/d) + 1;
    }
  }

  rep(i, m) ans[i+1] += ans[i];
  rep(i, m) cout << ans[i+1] << '\n';
  return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	string s;
	cin >> s;

	if(s.find("a") != string::npos
		&& s.find("b") != string::npos
		&& s.find("c") != string::npos){
		println("Yes")
	}else{
		println("No")
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   20010

using namespace std;


string ss[sz];
string sx[sz];
map<string,ll>mp;
map<string,ll>mp2;

set<string>st;
set<string> :: iterator it;

int main()
{


    ll n,m,i,j,a,b,p;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>ss[i];
        mp2[ss[i]]++;
        st.insert(ss[i]);
    }


    cin>>m;

    for(i=1;i<=m;i++)
    {
        cin>>sx[i];
        mp[sx[i]]++;
        st.insert(sx[i]);
    }

    ll c=0;


    for(it=st.begin();it!=st.end();it++)
    {
        string s=*it;
        a=mp[s];
        b=mp2[s];
        ll x=(b-a);
        c=max(c,x);
    }

    cout<<c<<endl;

    return 0;
}



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

int main(){
    string a,s,c;
    cin >> a >> s >> c;
    cout << 'A' << s[0] << 'C' << endl;

    return 0;
}


Measured memory_bytes: 256
table = []
for i in range(3):
    table.append(list(map(int, input().split())))

diffs = [table[0][i] - table[1][i] for i in range(3)]
if diffs[0] != diffs[1] or diffs[1] != diffs[2]:
    print("No")
    exit()

diffs = [table[1][i] - table[2][i] for i in range(3)]
if diffs[0] != diffs[1] or diffs[1] != diffs[2]:
    print("No")
    exit()

diffs = [table[0][i] - table[2][i] for i in range(3)]
if diffs[0] != diffs[1] or diffs[1] != diffs[2]:
    print("No")
    exit()

print("Yes")


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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a+b)%2){
        cout << (int)((a+b)/2.0)+1 << endl;
    } else {
        cout << (a+b)/2 << endl;
    }
    return 0;
}


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

int main(){
  int N; cin >> N;
  vector<long long> e(N,0);
  int a; cin >> a;
  int maxlen=0;
  if(a>0){
    cout << 0 << endl;
    return 0;
  }
  e[a]++;
  for(int i=1; i<N; i++){
    cin >> a;
    e[a]++;
    maxlen=max(maxlen,a);
  }
  if(e[0]>1){
    cout << 0 << endl;
    return 0;
  }
  long long result=1;
  for(int i=1; i<=maxlen; i++){
    if(e[i]==0){
      cout << 0 << endl;
      return 0;
    }
    int c=e[i];
    while(c--){
      result*=e[i-1];
      result%=998244353;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    a, b, c, k = LI()
    if k < a:
        print(k)
    else:
        k -= a
        if k < b:
            print(a)
        else:
            k -= b
            print(a- k)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76780
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    int a = max(-1000000, x - k + 1);
    int b = min(+1000000, x + k - 1);

    for (int i=a; i <= b; ++i ) {
        if (i!=a) cout << ' ';
        cout << i;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                          
using namespace std;    
int n,a,b,c; 
int main(){	
	cin>>n;
	a=n%10;
	n/=10;
	b=n%10;
	c=n/10;
	if(c==9) cout<<1;
	else cout<<9;
	if(b==9) cout<<1;
	else cout<<9;
	if(a==9) cout<<1;
	else cout<<9;
	return 0;
}

Measured memory_bytes: 256