akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
	int K;
	std::string str;
	char *p = NULL;
	char buf[102] = {0};

	cin >> K;
	cin >> str;
	p = (char*) str.c_str();

	if(strlen(p)<=K){
		printf("%s\n", p);
	}
	else{
		strncpy(buf, p, K);
		buf[K] = '.';
		buf[K+1] = '.';
		buf[K+2] = '.';
		printf("%s\n", buf);
	}
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
    int N,R,disp;
    scanf("%d%d", &N, &R);

    if (N >= 10)
    {
        disp = R;
    }
    else 
    {
        disp = R + (100 * (10-N));
    }
    printf("%d", disp);
    return 0;
}

Measured memory_bytes: 1692
B = [0,0,0]
S = str(input())
n = len(S)
for i in range(2**(n-1)):
    A = int(S[0])
    total = A
    B_str = S[0]
    for j in range(n-1):
        if(i>>j)&1:
            B[j] = -int(S[j+1])
            B_str+= "-"+S[j+1]
        else:
            B[j] = int(S[j+1])
            B_str += "+" + S[j + 1]
        total += B[j]
#        print(total,B)
    if total == 7:
        B_str+="=7"
        print(B_str)
        exit()
    total = 0

Measured memory_bytes: 3316
L, R = map(int, input().split())

diff = R - L

if diff < 2019:
    ans = 10 ** 10
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, i * j % 2019)
else:
    ans = 0

print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        
        int[] data = new int[n+1];
        for(int i = 1; i < n+1; i ++){
            data[i] = Integer.parseInt(br.readLine());
        }
        
        int[] light = new int[n+1];
        int[] pushed = new int[n+1];
        light[1] = 1;
        pushed[1] = 0;
        for(int i = 2; i <= n ; i++){
            light[i] = 0;
            pushed[i] = 0;
        }
        
        int count = 0;
        boolean achieve = false;
        //光っているボタンを探す
        int next = 1;
        while(true){
            boolean breakFlag = false;
            
            
            //System.out.println("count = "+count);
            for(int i = next; i <= n; i++){
                //System.out.println("i = "+i);
                if(light[i] == 1){
                    //System.out.println(i + " was pushed next is "+data[i]);
                    light[i] = 0;
                    light[data[i]] = 1;
                    next = data[i];
                    pushed[i] = 1;
                    count++;
                    
                    if(data[i] == 2){
                        //System.out.println("clear");
                        achieve = true;
                        breakFlag = true;
                    }
                    
                    else if(pushed[data[i]] == 1){
                        breakFlag = true;
                    }
                    
                    break;
                }
                /*
                else if(light[i] > 1 && count > 1){
                    //System.out.println("i = "+i+" failed");
                    breakFlag = true;
                }*/
            }
            
            //System.out.println(breakFlag);
            if(breakFlag){
                break;
            }
        }
        
        if(achieve){
            System.out.println(count);
        }
        else {
            System.out.println(-1);
        }
        
    }
}


Measured memory_bytes: 32684
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli a, b, c, k, ans = 0;
	cin >> a >> b >> c >> k;
	if(k < a){
		ans = k;
	}else if(a+b >= k){
		ans = a;
	}else if(a+b < k){
		ans = a - (k-(a+b));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
import Numeric
showF :: RealFloat a => a -> String
showF = flip (showFFloat Nothing) ""

areaAndCirc :: Floating a => a -> [a]
areaAndCirc r = [r * r * pi, 2 * r * pi]
main = putStrLn . unwords . map showF . areaAndCirc =<< readLn

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	ll ans = 1;
	ll prev;

	cin >> n;

	REP(i, n) {
		if (ans > n) {
			break;
		}

		prev = ans;
		ans = (i + 1)*(i + 1);
	}

	cout << prev << endl;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll N;
	cin >> N;
	VL A(N);
	REP(i, N) cin >> A[i];
	sort(ALL(A));

	VL cnt(1000 * 1000 + 5, 0);
	for (auto one : A) {
		cnt[one]++;
	}
	for (auto one : A) {
		if (cnt[one] == INF) continue;
		ll add = one + one;
		while (add <= A.back()) {
			if (cnt[add]) {
				cnt[add] = INF;
			}
			add += one;
		}
	}

	ll ans = 0;
	for (auto one : cnt) {
		if (one == 1) ans++;
	}
	cout << ans << endl;

}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 12704
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int h, w; cin >> h >> w;

    string mat[h];
    rep(i, h){
        cin >> mat[i];
    }

    int a[h][w];
    queue<P> que;
    rep(i, h){
        rep(j, w){
            if(mat[i][j] == '.') a[i][j] = -1;
            else{
                a[i][j] = 0;
                que.push({i, j});
            }
        }
    }

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

    while(!que.empty()){
        int inow = que.front().first;
        int jnow = que.front().second;
        que.pop();

        rep(dir, 4){
            int inext = inow + dx[dir];
            int jnext = jnow + dy[dir];

            if(inext < 0 || inext >= h) continue;
            if(jnext < 0 || jnext >= w) continue;
            if(a[inext][jnext] != -1)   continue;

            a[inext][jnext] = a[inow][jnow] + 1;
            que.push({inext, jnext});
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w){
            ans = max(ans, a[i][j]);
        }
    }

    cout << ans << endl;

    

    return 0;
}

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

int main() {
	int n,a,b,sum;
	cin >> n;
	int t = n;
	sum = 0;
	for (int i = 0; i < 8; i++) {
		a = t % 10;
		sum += a;
		t = t / 10;
	}
	if (n % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}
 
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
 
int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}
 
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
long –2147483648 ～ 2147483647
 
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
int main() {
    // 入力
    long A, B, C, K;
    cin >> A >> B >> C >> K;
 
    //出力
    if (K % 2 == 1) cout << - (A - B) << endl;
    else cout << (A - B) << endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n; cin >> n;
    vector<int> a(n, 0);
    for(int i = 1; i < n; ++i){
        int x; cin >> x;
        a[x-1]++;
    }
    for(int x : a){
        cout << x << '\n';
    }


    
    return 0;
}


Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> x(m), y(m);
	for(int i = 0; i < m; ++i) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
	}
	
	vector<bool> ok(n, false);
	vector<int> box(n, 1);
	
	ok[0] = true;
	for(int i = 0; i < m; ++i) {
		if( ok[x[i]] ) {
			ok[y[i]] = true;
		}
		
		box[x[i]]--;
		box[y[i]]++;
		
		if( box[x[i]] == 0 ) {
			ok[x[i]] = false;
		}
	}
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if( ok[i] ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4460
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#define int long long
using namespace std;
const int INF=3e5+5;
struct _node_data {int x,y;} aa[INF],bb[INF];
int h,w,m,cntx[INF],cnty[INF],ans;
map <int,map <int,bool> > Map;
bool cmp1(_node_data xx,_node_data yy) {
        return xx.x>yy.x;
}
int fzx_max(int x,int y) {
        return x<y ? y : x;
}
signed main()
{
        scanf("%lld %lld %lld",&h,&w,&m);
        for (int i=1; i<=m; i++) {
                int x=0,y=0; scanf("%lld %lld",&x,&y);
                Map[x][y]=1; cntx[x]++; cnty[y]++;
        }
        for (int i=1; i<=h; i++) {aa[i].x=cntx[i]; aa[i].y=i;}
        for (int i=1; i<=w; i++) {bb[i].x=cnty[i]; bb[i].y=i;}
        sort(aa+1,aa+1+h,cmp1); sort(bb+1,bb+1+w,cmp1);
        for (int i=1; i<=h; i++) {
                bool flag=true;
                for (int j=1; j<=w; j++) {
                        if (aa[i].x+bb[j].x<=ans) break; flag=false;
                        ans=fzx_max(ans,aa[i].x+bb[j].x-Map[aa[i].y][bb[j].y]);
                }
                if (flag) break;
        }
        cout<<ans<<"\n";
        return 0;
}


Measured memory_bytes: 64616
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='yes'
    flag=False
    for i in range(len(s)-1):
        for j in range(i+1,len(s)):
            if s[i]==s[j]:
                ans='no'
                flag=True
                break
        if flag:
            break
    print(ans)
resolve()

Measured memory_bytes: 3060
n=int(input())
S1=input()
S2=input()

mod=1000000007
if n==1:
  ans=3
else:
  if S1[0]==S2[0]:
    ans,i=3,1
  else:
    ans,i=6,2
  while i<n:
    if S1[i]==S2[i]:
      ans *= 2%mod if S1[i-1]==S2[i-1] else 1%mod
      i+=1
    else:
      ans *= 2%mod if S1[i-1]==S2[i-1] else 3%mod
      i+=2
print(ans%(mod))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	for (int i = 1; i <= 3; ++i){
		if (A*B*i % 2){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
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.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            String t = "keyence";

            for (int i = 0; i < t.length(); i++) {
                if (s.startsWith(t.substring(0, i)) && s.endsWith(t.substring(i))) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 23380
#include <stdio.h>
int main(void){
  int i,l=0,ha=0,ta=0;
  char s[101],h[8]="keyence";
  scanf("%s",s);
  while (s[l]) l++;
  for (i=0;i<7;i++){
    if (s[i]!=h[i]) break;
    ha++;
  }
  for (i=0;i<7;i++){
    if (s[l-1-i]!=h[6-i]) break;
    ta++;
  }
  printf("%s\n",(ha+ta>=7)? "YES":"NO");
  return 0;
}

Measured memory_bytes: 128
n = gets.to_i
possibles_6 = []
possibles_9 = []

1.upto(10) do |index|
  tmp = 6 ** index
  tmp <= 100000 ? possibles_6.unshift(tmp) : break
end

1.upto(10) do |index|
  tmp = 9 ** index
  tmp <= 100000 ? possibles_9.unshift(tmp) : break
end

que = [[n, 0]]
until que.empty?
  rest, count = que.shift
  if rest == 0
    ans = count
    break
  end
  if rest >= 9
    que << [rest - possibles_9.bsearch { |item| item <= rest }, count + 1]
  end
  if rest >= 6
    que << [rest - possibles_6.bsearch { |item| item <= rest }, count + 1]
  end
  if rest < 6
    que << [rest - 1, count + 1]
  end
end
puts ans

Measured memory_bytes: 4348
R, G, B, N = map(int,input().split())

cnt = 0
for i in range(0, N+1, R):
  for j in range(0, N+1, G):
    k = N - i - j
    if k >= 0:
      if k%B == 0:
        cnt += 1
    else:
      break
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int bubbleSort(int N, int A[]){
  int sw = 0;
  for(int j = 0; N > j; j++){
    for(int i = N - 1; i > j; i--){
      if(A[i] < A[i - 1]){
        swap(A[i], A[i - 1]);
        sw++;
      }
    }
  }
  for(int i = 0; N > i; i++){
    cout << A[i];
    if(N != i + 1){
      cout << " ";
    }
  }
  cout << endl;
  cout << sw << endl;
}
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; N > i; i++) cin >> A[i];
  bubbleSort(N,A);
}


Measured memory_bytes: 3120
S = input()

AA = int(S[:2])
BB = int(S[2:])

YYMM = True
MMYY = True

if AA > 12 or AA <= 0:
    MMYY = False

if BB > 12 or BB <= 0:
    YYMM = False

if MMYY and YYMM:
    print('AMBIGUOUS')
elif MMYY:
    print('MMYY')
elif YYMM:
    print('YYMM')
else:
    print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
bool dig[10];
bool gen(int n)
{
    while(n)
    {
        if(dig[n%10]) return 0;
        n/=10;
    }
    return 1;
}

int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	int k; cin>>k;
	
	for(int i=0;i<k;i++)
	{
	    int p; cin>>p; dig[p]=1;
	}
	int ans=n;
	while(gen(ans)==0) ans++;
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

	if (min(B, D) - max(A, C) > 0) {
		cout << min(B, D) - max(A, C);
	}
	else {
		cout << 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
 
int *mth, *spj, a2[100], a1[100]; 
 
inline int read() {
    char c=getchar(); int f=1,ret=0;
    while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
    while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
    return ret * f;
}
 
LL DFS(LL res, LL l, LL r) {
    if (l <= r) {
        if (res == 0) {
            return l == r? 10: 1;
        } else {
            return 0;
        }
    } else {
        LL ret = 0, cur = l - r;
        l /= 10; r *= 10;
        for (int i = -9; i <= 9; i++) {
            if (abs(res - i * cur) < l * 11) {
                ret += mth[i] * DFS(res - i * cur, l, r);               
            }
        }
        return ret;
    }
}
 
int main() {
    mth = a1 + 50;
    spj = a2 + 50;
    for (int i = 0; i <= 9; i++) {
        for (int j = -9; j <= 0; j++) {
            mth[i + j]++;
        }
    }
    for (int i = 1; i <= 9; i++) {
        for (int j = -9; j <= 0; j++) {
            spj[i + j]++;
        }
    }
    LL ans = 0, D = -read();
    for (LL mx = 1e18; mx >= 10; mx /= 10) {
        LL delta = mx - 1;
        for (int i = -8; i <= 9; i++) {
            ans += spj[i] * DFS(D - i * delta, mx / 10, 10);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        d: [i32; n],
    }
    let mut ans: i64 = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            ans += (d[i] * d[j]) as i64;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2112
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

bool is_prefix(string const & a, string const & b) {
    return a.compare(0, b.length(), b);
}
int main() {
    while (true) {
        // input
        int n, edges, start, goal; cin >> n >> edges >> start >> goal;
        if (n == 0) break;
        auto label = vectors(n, n, vector<string>());
        vector<vector<int> > g(n);
        int label_length_max = 0;
        repeat (i, edges) {
            int x, y; string s; cin >> x >> y >> s;
            label[x][y].push_back(s);
            setmax<int>(label_length_max, s.length());
            g[x].push_back(y);
        }
        repeat (x, n) {
            whole(sort, g[x]);
            g[x].erase(whole(unique, g[x]), g[x].end());
        }
        // solve
        string result;
        vector<bool> saturated(n);
        vector<string> dist(n);
        reversed_priority_queue<tuple<string, int, int> > que;
        dist[start] = "";
        que.emplace(dist[start], -1, start);
        while (not que.empty()) {
            string dist_x; int z, x; tie(dist_x, z, x) = que.top(); que.pop();
            if (saturated[x]) continue;
            if (z != -1 and dist[x] + "\xff" < dist_x) continue;
            if (z != -1 and not is_prefix(dist[x], dist_x)) continue;
            if (x == goal) {
                if (result.empty()) {
                    result = dist_x;
                } else if (dist_x < result) {
                    result = "NO";
                    break;
                } else {
                    continue;
                }
            }
            dist[x] = dist_x;
            if (label_length_max * (n + 3) < dist[x].length()) saturated[x] = true;
            for (int y : g[x]) {
                for (string delta : label[x][y]) {
                    if (dist[x] + delta < dist[y] + "\xff") {
                        que.emplace(dist[x] + delta, x, y);
                    }
                }
            }
        }
        // output
        if (dist[goal].empty() or label_length_max * n < dist[goal].length()) {
            dist[goal] = "NO";
        }
        cout << dist[goal] << endl;
    }
    return 0;
}

Measured memory_bytes: 7128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll cnt[4][123456];

ll rwpw(ll x, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,x);
		}
		mul_mod(x,x);
		p /= 2;
	}
	return ret;
}

int main(void){
	int n,i,j;
	ll ans=0ll,l,r,t;
	string s,c="ABC?";
	cin >> s;
	n = s.l_ength();
	for(j=0; j<4; ++j){
		cnt[j][0] = 0ll;
	}
	for(i=0; i<n; ++i){
		for(j=0; j<4; ++j){
			cnt[j][i+1] = cnt[j][i];
			if(s[i] == c[j]){
				++cnt[j][i+1];
			}
		}
	}
	for(i=0; i<n; ++i){
		if(s[i] == 'A' or s[i] == 'C'){
			continue;
		}
		l = cnt[0][i];
		t = cnt[3][i];
		mul_mod(l,rwpw(3ll,t));
		if(t){
			mul_mod(t,rwpw(3ll,t-1));
		}
		add_mod(l,t);
		r = cnt[2][n] - cnt[2][i+1];
		t = cnt[3][n]-cnt[3][i+1];
		mul_mod(r,rwpw(3ll,t));
		if(t){
			mul_mod(t,rwpw(3ll,t-1));
		}
		add_mod(r,t);
		t = l;
		mul_mod(t,r);
		add_mod(ans,t);
	}
	cout << ans << endl;
	return 0;
}


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

//--------------some #defines-------------------------
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define get1(x) int x; cin>>x
#define get2(x,y) int x,y; cin>>x>>y
#define min2(x,y) (x<y?x:y)
#define max2(x,y) (x>y?x:y)

#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rev(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define endl '\n'

#define vi vector<int>

#define matrix(x,n,m) vector<vector<int> > x(n,vi (m))
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define ff first
#define ss second
#define vpii vector<pair<int,int> >
#define ll long long


//#define gcd(x,y) __gcd(x,y)
//#define lcm(x,y) (x)*(y)/__gcd(x,y)

//-------------------------------------------------------------

int main()
{
    boost;
    get2(a,b);
    cout<<a*b;



    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
int main(){
    int n, m, ans = 0;
    sc(n), sc(m);
    vector<int> x(m), y;
    for (int i = 0; i < m; i++) sc(x[i]);
    sort(x.begin(), x.end());
    for (int i = 0; i < m-1; i++) y.push_back(x[i+1] - x[i]);
    if (y.size() > 0) sort(y.begin(), y.end());
    int len = y.size();
    for (int i = 0; i < len-n+1; i++) ans += y[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  vector<int> hates;
  int hate;
  int n, k;
  int i;
  int cnt;
  int a, b, c, d, s;
  a = b = c = d = s = 0;
  bool can;
  
  cin >> n >> k;
  
  for (i = 0; i < k; i++) {
    cin >> hate;
    hates.push_back(hate);
  }
  
  for (cnt = n; cnt < 99999; cnt++) {
    can = true;
    
    d = cnt % 10;
    c = (cnt % 100 - d) / 10;
    b = (cnt % 1000 - c - d) / 100;
    a = (cnt % 10000 - b - c - d) / 1000;
    s = cnt / 10000;
    
    if (find(hates.begin(), hates.end(), d) != hates.end()) {
        can = false;
      	continue;
    } else if (cnt > 9 && find(hates.begin(), hates.end(), c) != hates.end()) {
      can = false;
      continue;
    } else if (cnt > 99 && find(hates.begin(), hates.end(), b) != hates.end()) {
      can = false;
      continue;
    } else if (cnt > 999 && find(hates.begin(), hates.end(), a) != hates.end()) {
      can = false;
      continue;
    } else if (cnt > 9999 && find(hates.begin(), hates.end(), s) != hates.end()) {
      can= false;
      continue;
    }
    
    if (can) break;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
sum=0
list=[0]*N
list2=[0]*N

for a in A:
  list[a-1] +=1
  

for n in range(N):
  sum += list[n]*(list[n]-1)//2
  

for n in range(N):
  if list[n]>0:
  	list2[n]=sum-list[n]*(list[n]-1)//2+(list[n]-1)*(list[n]-2)//2
  
for a in A:
  print(list2[a-1])
  
  


    


Measured memory_bytes: 26140
#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;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll h, w, m, col[300005], ans;
pi arr[300005];
vi v[300005];
multiset<ll> ms;

int main() {
	fastio; cin >> h >> w >> m;
	FOR(i, 1, m) {
		cin >> arr[i].f >> arr[i].s;
		v[arr[i].f].pb(arr[i].s);
		col[arr[i].s]++;
	}
	FOR(i, 1, w) if (col[i] != 0) ms.insert(col[i]);
	FOR(i, 1, h) {
		for (auto it:v[i]) {
			ms.erase(ms.find(col[it]));
			ms.insert(col[it]-1);
		}
		ans = max(ans, (ll) v[i].size() + *(--ms.end()));
		for (auto it:v[i]) {
			ms.erase(ms.find(col[it]-1));
			ms.insert(col[it]);
		}
	}
	cout << ans;
}


Measured memory_bytes: 41116
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    ll n; cin >> n;
    int res = 0;
    for (ll i = 2; i * i <= n; i++) {
        int times = 0;
        while (n % i == 0) {
            n /= i;
            times++;
        }
        for (int j = 1;; j++) {
            if (times - j < 0) {
                break;
            }
            res++;
            times -= j;
        }
    }
    cout << res + (n > 1);
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    int n,i,a,b,c;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,X; cin>>N>>X;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a));
    int ans=0;
    REP(i,N){
        if(X>=a[i]){
            X-=a[i];
            ans++;
        }
    }
    if(X>0 and ans==N) ans--;
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b,c = list(map(int,input().split(" ")))
string = input()

for i in string:
  if i == "9":
    print("Yes")
    quit()
print("No")

Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n, k := readInt(), readInt()

	i := 0
	t := 1
	for {
		i++
		t *= k
		if t > n {
			fmt.Println(i)
			return
		}
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t,n,s,f;
  while(cin >> t && t){
    cin >> n;
    rep(i,n){
      cin >> s >> f;
      t -= f-s;
    }
    if(t <= 0)cout <<"OK"<<endl;
    else cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 3108
#include<algorithm>
#include<iostream>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
using namespace std;

int main()
{
	vector<int>a(50);
	vector<int>b(50);
	vector<int>c(50);
	int x = 0;
	for (int i = 0;; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		if (a[i] == -1 && b[i] == -1 && c[i] == -1)
		{
			x = i;
			break;
		}
	}
	for (int i = 0; i < x; i++)
	{
		if (a[i] == -1 || b[i] == -1)cout << "F" << endl;
		else if (a[i] + b[i] >= 80)cout << "A" << endl;
		else if (a[i] + b[i] >= 65)cout << "B" << endl;
		else if (a[i] + b[i] >= 50)cout << "C" << endl;
		else if (a[i] + b[i] >= 30 && c[i] >= 50)cout << "C" << endl;
		else if (a[i] + b[i] >= 30)cout << "D" << endl;
		else cout << "F" << endl;
	}
	return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#define INF 2000000 
int p = 0, q[INF];
 
int maxnumber(int x, int y){
  if(q[x]>q[y]){
    return x;
  }
  else{
    return y;
  }
}
 
void insert(int k){
    int i, j, temp;
    p++;
    q[p] = k;
    i = p;
    while(q[i]>q[i/2] && i>1){
        temp = q[i];
        q[i] = q[i/2];
        q[i/2] = temp;
        i = i/2;
    }
}
 
int extract(){
    int i, temp, max, a;
    a = q[1];
    q[1] = q[p];
    p--;
    i = 1;
    while(i*2<=p){
      if(i*2+1<=p) {
	max = maxnumber(i*2, i*2+1);
      }
      else{
	max =i*2;
      }
        if(maxnumber(max, i)==max){
            temp = q[max];
            q[max] = q[i];
            q[i] = temp;
            i = max;
        }
        else{
	  break;
	}
    }
    return a;
}
 
int main(){
    int i, j, k;
    char com[10];
    while(1){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&k);
            insert(k);
        }
        if(com[0]=='e' && com[1]=='x')  printf("%d\n",extract());
        if(com[0]=='e' && com[1]=='n')  break;
    }
    return 0;
}



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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var nd = ReadLongArray();
		var n = nd[0];
		var d = nd[1];
		var cnt = 0;
		for (var i = 0; i < n; i++) {
			var xy = ReadLongArray();
			if (xy[0] * xy[0] + xy[1] * xy[1] <= d * d) cnt++;
		}
		Console.WriteLine(cnt);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 40476
#include<bits/stdc++.h>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld  double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("birch.in");ofstream cout("birch.out");
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
const ll N=1e6;
const ll R=1e4;
const ll to[7]={1,2,3,1,3,2,1};
signed main(){
    fast_io;
    ll k,n;
    cin>>k>>n;
    vector<ll>a(n);
    vector<ll>ans(n);
    for(auto &z : a) cin>>z;
    for(ll i=1;i<n;i++){
        ans[0]+=a[i]-a[i-1];
    }
    ll to=ans[0];
    for(ll i=1;i<n;i++){
        ans[i]=ans[0];
        ans[i]-=a[i]-a[i-1];
        ans[i]+=(a[0]+k)-a[n-1];
        to=min(to,ans[i]);
    }
    cout<<to;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int n;
vi a;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n;
	a.resize(n);
	REP(i, n) cin >> a[i];
	int mn = 2;
	ll ans = a[0] - 1;
	FOR(i, 1, n)
	{
		if (a[i] == mn)
		{
			mn = a[i] + 1;
		}
		else
		{
			ans += (a[i] - 1) / mn;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void){
	int a[4], b[4];
	int hit = 0, blow = 0;
	int i, j;
	
	while(scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		if(scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]) == EOF) break;
		hit = blow = 0;
		for(i = 0; i < 4; i++){
			if(a[i] == b[i]) hit++;
		}
		
		for(i = 0; i < 4; i++){
			for(j = 0; j < 4; j++){
				if(i == j) continue;
				if(a[i] == b[j]) blow++;
			}
		}
		printf("%d %d\n", hit, blow);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>

int main() {
        long long N, dN;
        scanf("%lld", &N);

        dN = sqrtf(N);

        for(long long i = dN ; i >= 1 ; i--) {
                if(N % i == 0) {
                        printf("%lld", (i - 1) + (N / i - 1));
                        return 0;
                }
        }

        printf("%lld", N);
}

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

using namespace std;
typedef long long ll;

int main(){
    int n;
    string S;
    cin >> n;
    cin >> S;
    if(n<3)
    {
        cout << 0 << endl;
        return 0;
    }
    ll r, g, b;
    r = b = g = 0;
    for (int i = 0; i < n; i++)
    {
        if(S[i]=='R')
        {
            r++;    
        }
        else if (S[i]=='G')
        {
            g++;
        }
        else if (S[i]=='B')
        {
            b++;
        }
    }
    ll all = r * g * b;

    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i+1; j < n - 1; j++)
        {
            if (S[i] != S[j])
            {
                int a = j - i;
                int k = i + 2 * a;
                if (k < n)
                {
                    if (S[j] != S[k] && S[k] != S[i])
                    {
                        all--;
                    }
                }
                else
                {
                    continue;
                }
            }
        }
        
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 3600
#include "iostream"
using namespace std;
int main(){
  int a; int b;int t;
  cin>>a>>b>>t;
  int k=b;
  int w=a;
  if(a>t){
    cout<<0<<endl;

  }
  else if(a==t){
    cout<<a*b<<endl;
  }
  else{
    while(a<=t){
      a+=w;
      b+=k;
    }
    cout<<b-k<<endl;
  }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
using lint=long long;
const int INF=1e9;

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

   string s; cin>>s;
   reverse(s.begin(),s.end());
   s+='0';
   int N=s.size();
   vector<vector<int>> dp(N+1,vector<int>(2,INF));
   dp[0][0]=0;
   for(int i=0;i<N;i++){
      int cur=s[i]-'0';
      for(int d=0;d<10;d++){
         if(d>=cur){
            dp[i+1][0]=min(dp[i+1][0],dp[i][0]+d+(d-cur));
         }else{
            dp[i+1][1]=min(dp[i+1][1],dp[i][0]+d+(d+10-cur));
         }
         if(d==0){
            dp[i+1][1]=min(dp[i+1][1],dp[i][1]+0+(9-cur));
         }else{
            int nd=d-1;
            if(nd>=cur){
               dp[i+1][0]=min(dp[i+1][0],dp[i][1]+d+(nd-cur));
            }else{
               dp[i+1][1]=min(dp[i+1][1],dp[i][1]+d+(nd+10-cur));
            }
         }
      }
   }
   cout<<dp[N][0]<<endl;
   return 0;
}


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

int main() {
	// your code goes here
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
		int n,k,t;
		cin>>n>>k>>t;
		int q=n/k;
		if(n%k!=0)
			q++;
		int ans=q*t;
		cout<<ans<<endl;
		
		
	}
	return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var xn = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var s = Console.ReadLine();
        if (s.Length == 0) s = "11111111";
        Console.WriteLine(Enumerable.Range(-150, 300).Except(s.Split().Select(int.Parse)).OrderBy(x => Abs(xn[0] - x)).ThenBy(x => x).First());
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
    	c -= b;
    	if (c <= 0) {
	    	cout << "Yes" << endl;
    		break;
    	}
    	a -= d;
    	if (a <= 0) {
	    	cout << "No" << endl;
	    	break;
	}
    }
    return 0;
}

Measured memory_bytes: 3564
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

ll n, w;
ll a[123], b[123];
ll dp[123456][123];

ll memo(int W, int idx) {
	if(W < 0) return -1e18;
	if(w == 0) return 0;
	if(idx == n) return 0;
	if(dp[W][idx] != -1) return dp[W][idx];
	ll res = memo(W, idx+1);
	res = max(res, memo(W - a[idx], idx+1) + b[idx]);
	return dp[W][idx] = res;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> w;
	for(int i=0; i<n; i++) cin >> a[i] >> b[i];
	memset(dp, -1, sizeof dp);
	cout << memo(w, 0) << endl;
	return 0;
}

Measured memory_bytes: 118912
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c, k;
    long long sum = 0;

    cin >> a >> b >> c >> k;

    if (a >= k)
    {
        sum += k;
    }
    else if (a == 0 && b >= k)
    {
        sum = 0;
    }
    else if (a == 0 && b == 0 && c >= k)
    {
        sum -= k;
    }
    else
    {
        sum = a - (k - a - b);
    }

    /*
    while(true){
        f(a>0)
        {
            sum += k - a;
            if(a)
        }else if(a==0 && b > 0)
        {
            b--;
        }
        else if(b == 0 && c > 0)
        {
            sum--;
            c--;
        }
    }*/

    cout << sum << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 100;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n;
ll a[60];
int id;

bool g() {
    id = 0;
    ll v = a[0];
    for (int i = 1; i < n; ++i) {
        if (a[i] > v) {
            id = i;
            v = a[i];
        }
    }
    return v >= n;
}

int main() {
    int i, j;
    cin >> n;
    for (i = 0; i < n; ++i)
        cin >> a[i];
    ll ans = 0;
    while (g()) {
        ll t = a[id] / (ll)n;
        for (i = 0; i < n; ++i) {
            if (i == id)
                a[i] %= (ll)n;
            else
                a[i] += t;
        }
        ans += t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256