akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

ll dp[55][5000];
const int GETA = 2500;


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

    memset(dp, 0, sizeof(dp));
    dp[0][GETA] = 1;

    // 総和が0のときを s=2500としている。
    for(int i=0; i<N; i++) {
        for(int s=0; s+X[i]<=5000; s++) {
            if(dp[i][s] == 0) continue;
            dp[i+1][s] += dp[i][s];
            dp[i+1][s+X[i]] += dp[i][s];
        }
    }

    //何も選ばないを除く
    cout << dp[N][GETA] - 1 << endl;
}

Measured memory_bytes: 5728
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,loop;
  cin >> N;
  string S;
  cin >> S;
  long long ans,K;
  if(S[0]=='W'){
    ans=0;
  }else{
    ans=1;
    K=1;
    for(loop=1;loop<N*2;loop++){
      if(K%2){	
        if(S[loop]=='W'){
          K++;
        }else{
          ans=(ans*K)%1000000007;
          K--;
          if(K<0){
            ans=0;
            break;
          }
        }
      }else{
        if(S[loop]=='B'){
          K++;
        }else{
          ans=(ans*K)%1000000007;
          K--;
          if(K<0){
            ans=0;
            break;
          }
        }
      }
    }
  }
  if(K){
    ans=0;
  }else{
    for(loop=N;loop>1;loop--){
      ans=(ans*loop)%1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, a[200005];
LL ans;
int pres[200005], prex[200005];

int main()
{
	scanf("%d", &n);
	rep1(i, n) scanf("%d", &a[i]);
	rep1(i, n) {
		pres[i] = pres[i - 1] + a[i];
		prex[i] = prex[i - 1] ^ a[i];
	}
	rep1(i, n) {
		int l = i, r = n + 1;
		while(l < r) {
			int mid = (l + r) >> 1;
			if(pres[mid] - pres[i - 1] == (prex[mid] ^ prex[i - 1])) l = mid + 1;
			else r = mid;
		}
		ans += r - i;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000000;

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x) {
        seg[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    void update(int k, const Monoid &x) {
        k += sz;
        seg[k] = x;
        while(k >>= 1) {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b) {
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = f(L, seg[a++]);
            if(b & 1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k + sz];
    }

    int find_subtree(int a, int low, Monoid &M, bool type) {
        while(a < sz) {
            Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
            if(nxt <= low) a = 2 * a + type;
            else M = nxt, a = 2 * a + 1 - type;
        }
        return a - sz;
    }

    int find_last(int b, int low) {
        Monoid R = M1;
        if(b >= sz) {
            if(f(seg[1], R) <= low) return find_subtree(1, low, R, true);
            return -1;
        }
        int a = sz;
        for(b += sz; a < b; a >>= 1, b >>= 1) {
            if(b & 1) {
                Monoid nxt = f(seg[--b], R);
                if(nxt <= low) return find_subtree(b, low, R, true);
                R = nxt;
            }
        }
        return -1;
    }
};

ll e[500005];
ll p[500005];
bool f[500005];

int main()
{
    ll n, d;
    cin >> n >> d;
    SegmentTree<ll> seg(n, [](ll a, ll b){return min(a, b);}, INF);
    for(int i = 0; i < n; i++){
        cin >> e[i];
        seg.set(i, e[i]);
    }
    seg.build();
    ll low = 1;
    int l = n;
    vector<int> v;
    v.push_back(n);
    p[n] = 0;
    while(true){
        int r = seg.find_last(l, low * 2 - 1);
        if(r == -1) break;
        l = r;
        v.push_back(l);
        low += seg[l];
        p[l] = low - 1;
    }
    reverse(v.begin(), v.end());
    int j = 0;
    for(int i = 0; i < n; i++){
        while(v[j] <= i) j++;
        if(d > p[v[j]]) f[i] = true;
        else f[i] = false;
        d = min(d, abs(d - e[i]));
    }
    int q;
    cin >> q;
    while(q--){
        int t;
        cin >> t;
        t--;
        if(f[t]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 19572
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll,ll> pll;
 
#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);
 
void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
 
 
signed main(){
	IOS
	int a,b;	cin >> a >> b;
	int a1 = a+1, b1 = b+1;
	int amin = ceil(a/0.08), amax = a1 /0.08;
	int bmin = ceil(b/0.1), bmax = b1 / 0.1;
	if(amax * 0.08 != a)	amax--;
	if(bmax * 0.1 != a)		bmax--;;

	if(bmax < amin || amax < bmin)	cout << -1 << endl;
	else	cout << max(amin, bmin) << endl;
}

Measured memory_bytes: 384
N=int(input())
dp=[0]*3
flag=0
for _ in range(N):
    a=list(map(int,input().split()))
    if flag==0:
        dp[0]=a[0]
        dp[1]=a[1]
        dp[2]=a[2]
        flag=1
    else:
        a0=dp[0]
        a1=dp[1]
        a2=dp[2]
        dp[0]=max(a[0]+a1,a[0]+a2)
        dp[1]=max(a[1]+a0,a[1]+a2)
        dp[2]=max(a[2]+a0,a[2]+a1)
print(max(dp))

Measured memory_bytes: 47704
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>
#include <deque>

using namespace std;

int main(){

    int K;
    cin >> K;

    int A[100] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << A[K-1] << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include<iostream>
using namespace std;

int main(){

	int a,b,c,d;
	d=0;

	while(1){
		cin>>a>>b>>c;
		if(c%a==0){
			d=d+1;
		}
		a=a+1;
		if(a>b)
			break;

	}
	cout<<d<<endl;
	return 0;
}







Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m=0,tn;
  cin>>n;
  tn=n;
  for(int i=0;i<9;i++){
    m+=tn%10;
    tn/=10;
  }
  cout<<(n%m==0?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    vector<int> b(n);
    for (int i=0; i<n; i++) {
        cin >> b.at(i);
    }
    vector<int> c(n-1);
    for (int i=0; i<n-1; i++) {
        cin >> c.at(i);
    }
    int ans = b.at(a.at(0)-1);
    for (int i=1; i<n; i++) {
        ans += b.at(a.at(i)-1);
        if (a.at(i) == a.at(i-1) + 1) {
            ans += c.at(a.at(i-1)-1);
        }
    }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
MOD = 998244353


def modinv(a):
    return pow(a, MOD - 2, MOD)


def make_tables(N):
    fac = [1, 1]
    inv = [1, 1]
    for i in range(2, N + 1):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(modinv(fac[i]))
    return fac, inv


def ncr(n, r):
    return int(fac[n] * inv[r] * inv[n - r]) % MOD


if __name__ == '__main__':

    N, M, K = map(int, input().split())

    fac, inv = make_tables(N)

    ans = 0
    for k in range(K + 1):
        ans += (ncr(N - 1, k) * M * pow(M - 1, N - 1 - k, MOD)) % MOD

    print(ans % MOD)


Measured memory_bytes: 99160
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


void gg(int n){
	vector<int> a(n); iota(ALL(a),1);
	do{
		set<int> u;
		bool ok = 1;
		for(int i=0,k=0;k<n-2;i+=2,k+=2){
			int x = abs(a[i]-a[i+1]);
			int y = n - x;
			if(u.count(x)) ok = false;
			u.insert(x);
			if(u.count(y)) ok = false;
			u.insert(y);
		}
		if(ok){
			for(int x : a) cout<<x<<' '; cout<<endl; 
			break;
		}
	}while(next_permutation(ALL(a)));
}

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	
	
	int n,m;
	cin>>n>>m;
	
	if(m==0) while((m+1)*2+1<=n) ++m;
	
	vector<int> u(n);
	for(int l=1,r=n%2 ? n-1:(n%4==0 ? n-1:n), i=0; i<m; ++l,--r, ++i) {
		int x = abs(l-r);
		int y = n-x;
		if(x==y) --r;
		cout<<l<<' '<<r;
		//cout<<": "<<abs(l-r)<<' '<<n-abs(r-l);
		cout<<'\n';
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 3964
import numpy as np
from itertools import permutations


n, c = map(int, input().split())

dd = [list(map(int, input().split())) for _ in range(c)]
cc = [list(map(int, input().split())) for _ in range(n)]

dd = np.array(dd)
cc = np.array(cc)

mod_list = np.zeros((3, c), dtype=np.int)

for i in range(n):
  for j in range(n):
    mod_list[(i+j)%3, cc[i,j]-1] += 1

iwakan_list = mod_list.dot(dd)
  
x = float('inf')
for i, j, k in permutations(range(c), 3):
  x = min(x, iwakan_list[0, i] + iwakan_list[1, j] + iwakan_list[2, k])
print(x)

Measured memory_bytes: 16912
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>
#include <tuple>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////
#define MOD 998244353
#define NMax 303030 
int N;
int p[NMax];

void no(){
    printf("No");
    exit(0);
}

int main(){
    scanf("%d",&N);
   
    for(i=1;i<=N;i++){
        scanf("%d",&p[i]);   
        p[i]=p[i]-i;
        if(p[i]%2)no();
    }

    int check[2]={0,0};
    int v1=0;
    for(i=1;i<=N;i++){
        if(check[i&1]!=0&&p[i]==0)no();
        check[i&1]+=p[i];
        if(check[0]*check[1]!=0)no();
        if(p[i]<0){
            if(p[i]+i<v1)no();
            v1=p[i]+i;
        }
        if(check[0]+check[1]==0)v1=0;
    }
    v1=N+1;
    for(i=N;i>=1;i--){
        if(p[i]>0){
            if(p[i]+i>v1)no();
            v1=p[i]+i;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <math.h>
  
int main(){
 
double a,b,c,rad,S,L,h;

scanf("%lf%lf%lf",&a,&b,&rad);

rad = 2*M_PI * rad /360.0;

c = sqrt(a*a + b*b - 2*a*b*cos(rad));

S = a * b * sin(rad) / 2.0;
L = a + b + c;
h = b * sin(rad);
  
printf("%8f\n%8f\n%8f\n",S,L,h);
return 0;
}

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

const int64_t INF = 300 * (int64_t)1e9;
const int INF2 = 300;

struct Edge
{
    int to, c;
    Edge(int to, int c) : to(to), c(c){};
};

int main()
{
    int N, M, L;
    cin >> N >> M >> L;
    vector<int> A(M), B(M), C(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A.at(i) >> B.at(i) >> C.at(i);
    }
    int Q;
    cin >> Q;
    vector<int> s(Q), t(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> s.at(i) >> t.at(i);
    }

    vector<vector<Edge>> graph(N);
    for (int i = 0; i < M; i++)
    {
        graph.at(A.at(i) - 1).push_back(Edge(B.at(i) - 1, C.at(i)));
        graph.at(B.at(i) - 1).push_back(Edge(A.at(i) - 1, C.at(i)));
    }

    vector<vector<int64_t>> dist(N, vector<int64_t>(N, INF));
    for (int i = 0; i < N; i++)
    {
        dist.at(i).at(i) = 0;
        for (auto e : graph.at(i))
        {
            dist.at(i).at(e.to) = e.c;
        }
    }
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (dist.at(i).at(k) + dist.at(k).at(j) < dist.at(i).at(j))
                    dist.at(i).at(j) = dist.at(i).at(k) + dist.at(k).at(j);
            }
        }
    }

    vector<vector<int>> graph2(N);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
                continue;
            if (dist.at(i).at(j) <= L)
                graph2.at(i).push_back(j);
        }
    }

    vector<vector<int>> res(N, vector<int>(N, INF2));
    for (int i = 0; i < N; i++)
    {
        res.at(i).at(i) = 0;
        for (auto j : graph2.at(i))
        {
            res.at(i).at(j) = 1;
        }
    }
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (res.at(i).at(k) + res.at(k).at(j) < res.at(i).at(j))
                    res.at(i).at(j) = res.at(i).at(k) + res.at(k).at(j);
            }
        }
    }

    for (int i = 0; i < Q; i++)
    {
        int si = s.at(i) - 1, ti = t.at(i) - 1;
        cout << ((res.at(si).at(ti) == INF2) ? -1 : res.at(si).at(ti) - 1) << endl;
    }

    return 0;
}


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

using namespace std;

int main(){

    int N;
    cin >> N;
    int h[N];

    for(int i = 0; i < N; i++){

        cin>>h[i];
    }

    int* table = new int[N];

    table[0] = 0;
	
	table[1] = abs(h[0] - h[1]);
	table[2] = min(table[1] + abs(h[1] - h[2]), abs(h[0] - h[2]));
    for(int i = 3; i < N; i++){

        table[i] = min(table[i-1] + abs(h[i-1] - h[i]),
                    table[i-2] + abs(h[i-2] - h[i]));
    }

    cout<<table[N-1]<<"\n";

    return 0;
}


Measured memory_bytes: 1024
//Author Name - Mohammad Shehar Yaar Tausif
#include <bits/stdc++.h>    
using namespace std;

typedef long long int lld;
vector<int>DP;
vector<int>arr[100001];

int processDP(int source){
	if(DP[source]!=-1){
		return DP[source];
	}else{
		int answer=0;
		for(int i=0;i<arr[source].size();i++){
			answer = max(answer,processDP(arr[source][i])+1);
		}
		DP[source] = answer;
		return DP[source];
	}
	
}

int main(){
	lld n,m,i,x,y;
	cin>>n>>m;
	DP.assign(n+1,-1);
	for(i=0;i<m;i++){
		cin>>x>>y;
		arr[x].push_back(y);
	}
	int ans=0;
	for(i=1;i<=n;i++){
		ans = max(ans,processDP(i));
	}
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    string T;
    cin >> S >> T;
    if(string(T.begin(), T.begin() + S.size()) == S) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define N 500005
#define INF 0x3f3f3f3f
#define LL long long
int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f*x;
}
priority_queue<int,vector<int>,greater<int> > Q;//小根堆 保证字典序最小 
int n,k,m;
int ind[N];
vector<int>G[N];
int q[N],ans[N];
int tree[N<<2];
//权值线段树 维护区间最小值(因为是从右到左 就是离他最近 
void PushUp(int i)
{
	tree[i]=min(tree[i<<1],tree[i<<1|1]);
}
void Update(int i,int l,int r,int pos,int val)
{
	if(l==r)
	{
		tree[i]=val;
		return ;
	}
	int mid=(l+r)>>1;
	if(pos<=mid) Update(i<<1,l,mid,pos,val);
	else Update(i<<1|1,mid+1,r,pos,val);
	PushUp(i);
}
int Query(int i,int l,int r,int ql,int qr)
{
	if(r<ql||qr<l) return INF;
	if(ql<=l&&qr>=r) return tree[i];
	int mid=(l+r)>>1;
	return min(Query(i<<1,l,mid,ql,qr),Query(i<<1|1,mid+1,r,ql,qr));
} 
void Topo()
{
	for(int i=1;i<=n;i++)
		if(!ind[i]) Q.push(i);
	while(!Q.empty())
	{
		int u=Q.top(); Q.pop();
		q[++m]=u;
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i];
			ind[v]--;
			if(!ind[v]) Q.push(v);
		}
	}
}
int main()
{
	memset(tree,INF,sizeof(tree));
	n=rd(),k=rd();
	for(int i=1;i<=n;i++)
		q[rd()]=i;
	for(int i=n;i>=1;i--)
	{
		int j=Query(1,1,n,q[i]+1,q[i]+k-1);//q[j]-q[i]<k
		if(j!=INF) ind[q[j]]++,G[q[i]].push_back(q[j]);
		j=Query(1,1,n,q[i]-k+1,q[i]-1);//q[i]-q[j]<k
		if(j!=INF) ind[q[j]]++,G[q[i]].push_back(q[j]);
		Update(1,1,n,q[i],i);
	}
	Topo();
	for(int i=1;i<=n;i++)
		ans[q[i]]=i;
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 44964
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int k, n;
	cin >> k >> n;
	int a[n];
	cina(a, n);
	int ans = k - a[n-1] + a[0];
	for (int i = 1; i < n; ++i) {
		ans = max(a[i] - a[i-1], ans);
	}
	cout << k - ans;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        int c = 0;
        for (int i = l ; i <= r ; i++) {
            if (i % d == 0) {
                c++;
            }
        }
        System.out.println(c);

    }

}


Measured memory_bytes: 35724
res=1
maxT=0
for i in range(1,int(input())+1):
  c=i
  t=0
  while c!=1:
    if c%2==0:
      t+=1
    else:
      break
    c//=2
  if t>maxT:
    res=i
    maxT=t
print(res)

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

int main() {
	int i, temp, answer, first_array_size, second_array_size;
	scanf("%d", &first_array_size);

	int* first_array = (int*)malloc(sizeof(int) * first_array_size);
	for (i = 0; i != first_array_size; i++) {
		scanf("%d", &first_array[i]);
	}

	answer = 0;
	scanf("%d", &second_array_size);

	int minimum, maximum, middle;
	while (second_array_size--) {
		scanf("%d", &temp);

		minimum = 0;
		maximum = first_array_size - 1;

		while (minimum <= maximum) {
			middle = (minimum + maximum) / 2;

			if (first_array[middle] == temp) {
				answer++;
				break;
			}

			else if (first_array[middle] > temp) {
				maximum = middle - 1;
			}

			else if (first_array[middle] < temp) {
				minimum = middle + 1;
			}
		}
	}

	printf("%d\n", answer);

	free(first_array);
}



Measured memory_bytes: 2096
#include<stdio.h>
int main(){
  int n,i,m=1,d;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d);
    if(d==m)m++;
  }
  printf("%d\n",m-1?n-m+1:-1);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#define N 601000
typedef long long ll; 
template<typename T> inline void read(T &x) { 
  x = 0; char  c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
}
using namespace std;
const int P = 924844033;
const int G = 5;
int Gi; 
inline ll quickpow(ll x, int k) {
  ll res = 1;
  while (k) {
    if (k & 1)  res = res * x % P;  
    x = x *x  % P;
    k >>= 1;
  }
  return res;
}
int n;
struct edge{
  int nxt, to; 
}e[N << 1]; 
int head[N], ecnt;
inline void addedge(int from, int to) {
  e[++ecnt] = (edge){head[from], to};
  head[from] = ecnt;
}

int siz[N], dep[N], fa[N];
void dfs_son(int cur, int faa) {
  siz[cur] = 1, fa[cur] = faa;
  for (int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to; if (to == faa)  continue;
    dfs_son(to, cur);
    siz[cur] += siz[to];
  }
}

int cnt[N];
ll f[N], g[N], A[N], ans[N];
int limi, L, r[N];
inline void ntt(ll *a, int type) {
  for (int i = 1; i < limi; ++i)
    if (i < r[i]) swap(a[i], a[r[i]]);
  for (int i = 1; i < limi; i <<= 1) {
    ll T = quickpow(type == 1 ? G : Gi, (P - 1) / (i << 1));
    for (int j = 0; j < limi; j += (i << 1)) {
      ll t = 1;
      for (int k = 0; k < i; ++k, t = t * T % P) {
        ll nx = a[j + k], ny = t * a[j + k + i] % P;
        a[j + k] = (nx + ny) % P;
        a[j + k + i] = (nx - ny + P) % P;
      }   
    }   
  }
  if (type == -1) {
    ll inv = quickpow(limi, P - 2); 
    for (int i = 0; i < limi; ++i)  a[i] = a[i] * inv % P;
  }
}

ll jie[N], jieni[N];
inline ll get_c(int n, int m) {
  if (n < 0 || m < 0 || n - m < 0)  return 0;
  return jie[n] * jieni[m] % P * jieni[n - m] % P;
}
inline void work() {
  limi = 1;
  while (limi <= n + n + 2) limi <<= 1, ++L;
  for (int i = 0; i <= limi; ++i)
    r[i] = (r[i >> 1] >> 1) | ((i & 1) << (L - 1));
  ntt(f, 1), ntt(g, 1); 
  for (int i = 0; i < limi; ++i)  A[i] = f[i] * g[i] % P;
  ntt(A, -1);
  for (int k = 1; k <= n; ++k) {
    ll ans = (1ll * n * get_c(n, k) % P - jieni[k] * A[n - k] % P) % P;
    printf("%lld\n", (ans % P + P) % P); 
  }
}

inline void init() {
  jie[0] = jieni[0] = 1;
  int up = n + 10; 
  for (int i = 1; i <= up; ++i) jie[i] = jie[i - 1] * i % P;
  jieni[up] = quickpow(jie[up], P - 2); 
  for (int i = up - 1; i; --i)  jieni[i] = jieni[i + 1] * (i + 1) % P;
  Gi = quickpow(G, P - 2); 
}

int main() {
  read(n); init();
  for (int i = 1; i < n; ++i) {
    int u, v; read(u), read(v); addedge(u, v), addedge(v, u); 
  }
  dfs_son(1, 0); 
  for (int i = 2; i <= n; ++i) {
    ++cnt[siz[i]], ++cnt[n - siz[i]];
  }
  for (int i = 0; i <= n; ++i)  f[i] = 1ll * cnt[n - i] * jie[n - i] % P;
  for (int i = 0; i <= n; ++i)  g[i] = jieni[i];
  work();
  return 0;
}

/*
3
1 2
2 3
//3 7 3
*/

Measured memory_bytes: 34640
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

// #define MOD 1000000007
#define MOD 998244353
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

const int N = 303030;

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll inv(ll x) { return mod_pow(x, MOD - 2); }

ll fact[N + 1];
ll fact_inv[N + 1];

void init_fact() {
  fact[0] = fact_inv[0] = 1;
  REP(i, N) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int main() {
  init_fact();
  int n;
  ll a, b, k;
  cin >> n >> a >> b >> k;
  ll ans = 0;
  for (int i = 0; i <= n; ++i) {
    // a * i + b * j = k
    // j = (k - (a * i)) / b
    if ((k - (a * i)) % b != 0) continue;
    int j = (k - (a * i)) / b;
    if (j < 0 || n < j) continue;
    ll res = nCr(n, i) * nCr(n, j);
    res %= MOD;
    ans += res;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const char sigma[]={"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"};
const int L=128;
int len,cnt[70];

int query(const string &s){
    cout<<"? "<<s<<endl; 
    int ans;
    cin>>ans;
    return ans;
}

bool check(const string &s){
    return query(s)==len-s.size();
}

string merge(int l,int r){
    if(l==r) return string(cnt[l],sigma[l]);
    int mid=(l+r)/2;
    string a=merge(l,mid),b=merge(mid+1,r),res;
    int i=0,j=0;
    while(i<a.size()&&j<b.size()){
        if(check(res+a[i]+b.substr(j))) res+=a[i++];
        else res+=b[j++];
    }
    while(i<a.size()) res+=a[i++];
    while(j<b.size()) res+=b[j++];
    return res;
}
int main()
{
    for(int i=0;i<62;i++) cnt[i]=L-query(string(L,sigma[i])),len+=cnt[i];
    string ans=merge(0,62);
    cout<<"! "<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3748
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
//#define ll long long
#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 2000000;
int mod = 1e9 + 7;
int used[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    if (n < k + k - 1){
        cout << -1;
        return 0;
    }
        set < int > q;
    for (int i = 2 * n + k; i < 3 * n + k; i++) q.insert(i);

    int dl = +1;
    int dr = -2;
    int t = n / 2;
    for (int i = 1; i <= n; i++){
        if (i % 2){
            int s = k + n - 1 + i + k - 1 + 2 * t + 1 - i / 2 - (n + 1) % 2;
            if (used[s] || s < 2 * n + k) s = *q.lower_bound(s);
            q.erase(s);
            used[s] = 1;
            used[k + n - 1 + i] = 1;
            used[ k - 1 + 2 * t + 1 - i / 2] = 1;
            cout << k + n - 1 + i << " " << k - 1 + 2 * t + 1 - i / 2 - (n + 1) % 2 << " " << s << endl;
        } else{
            int s = k - 1 +  t + 1 - i / 2 + k + n - 1 + i;
            if (used[s] || s < 2 * n + k) s = *q.lower_bound(s);
            q.erase(s);
            used[s] = 1;
            used[k + n - 1 + i] = 1;
            used[k - 1 + t + 1 - i / 2] = 1;
            cout << k + n - 1 + i << " " << k - 1 +  t + 1 - i / 2 << " " <<  s << endl;
        }
    }
}


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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll r;

    cin >> r;

    cout << setprecision(20) << r*r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int num[100],j = 0;
  char string[401];
  fgets(string,sizeof(string),stdin);

  for(int i = 0; i < 100; i++)num[i] = 0;

  for(int i = 0; string[i] != '\n'; i++){
    if(string[i] >= '0' && string[i] <= '9'){
      if(string[i - 1] == ' ')j++;
      num[j] *= 10;
      num[j] += string[i] - '0';
    }

    else if(string[i] == '+'){
      num[j - 1] += num[j];
      num[j] = 0; j--;
    }
    else if(string[i] == '-'){
      num[j - 1] -= num[j];
      num[j] = 0; j--;
    }
    else if(string[i] == '*'){
      num[j - 1] *= num[j];
      num[j] = 0; j--;
    }
  }
  printf("%d\n",num[0]);
  return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>          // printf(), scanf()

#define MAX_N 200000
#define min(a, b) ((a) < (b) ? a : b)
#define max(a, b) ((a) > (b) ? a : b)

int
main(int argc, char** argv)
{
	int r[MAX_N];
	int n, i;

	int maxv = -1000000000;
	int minv = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &r[i]);

	minv = r[0];
	for (i = 1; i < n; ++i)
	{
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}

	printf("%d\n", maxv);
	return 0;
}

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

int main(){
  
 int a,b;
  
  cin >> a >> b;
  
  if(a<b){
    for(int i=0;i<b;i++){
   cout << a; 
    }
  }
  
  else{
    for(int i=0;i<a;i++){
   cout << b; 
    }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    string s(a, '0' + b), t(b, '0' + a);
    cout << (s < t ? s : t) << endl;
    return 0;
}


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


int main() {
	int N;
	cin >> N;
	vector<int> ans(N);
	rep(i, N - 1) {
		int a;
		cin >> a;
		a--;
		ans[a]++;
	}
	rep(i, N) cout << ans[i] << endl;
}

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

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

int N;
int A[100];

int main() {
  scanf("%d", &N);
  REP(i,N) scanf("%d", &A[i]);

  sort(A, A+N, greater<int>());
  int a = 0, b = 0;
  REP(i,N) {
    if (i % 2 == 0) a += A[i];
    else b += A[i];
  }

  printf("%d\n", a - b);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    vector <int> A(N);
    ll total = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        total+=(A[i]%1000000007);
        total%=1000000007;
    }
    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += (total - A[i] % 1000000007 + 1000000007) % 1000000007 * A[i] % 1000000007;
        total = (total - (A[i] % 1000000007) + 1000000007) % 1000000007;
    }
    cout << ans % 1000000007 << endl;
}


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


// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};


// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int min_cost = 0;

    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};




int main()
{
  Graph g;
  cin>>g.n;

  int x[g.n],y[g.n];
  pair<pair<int,int>,int> P[g.n],Q[g.n];
  rep(i,g.n){
      cin>>x[i]>>y[i];
      P[i].first.first=x[i];
      P[i].first.second=y[i];
      P[i].second=i;
      Q[i].first.first=y[i];
      Q[i].first.second=x[i];
      Q[i].second=i;
  }
  sort(P,P+g.n);
  sort(Q,Q+g.n);


  for(int i=0;i<g.n-1;i++){
    int X=abs(P[i].first.first-P[i+1].first.first);
    int Y=abs(P[i].first.second-P[i+1].first.second);
    Edge e;
    e.a=P[i].second;
    e.b=P[i+1].second;
    e.cost=min(X,Y);
    g.es.push_back(e); 
  }  
  for(int i=0;i<g.n-1;i++){
    int X=abs(Q[i].first.first-Q[i+1].first.first);
    int Y=abs(Q[i].first.second-Q[i+1].first.second);
    Edge e;
    e.a=Q[i].second;
    e.b=Q[i+1].second;
    e.cost=min(X,Y);
    g.es.push_back(e); 
  } 


    cout<<g.kruskal()<<endl;

}

Measured memory_bytes: 7668
#include<stdio.h>
using namespace std;

int main(){
    int n,m,l;
    scanf("%d%d%d",&n,&m,&l);
    long long int a[100][100],b[100][100];
    long long int c[100][100]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if (j<l-1){
                printf("%lld ",c[i][j]);
            }else{
                printf("%lld",c[i][j]);
            }
        }printf("\n");
    }
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (k >= s.size()) cout << s << en;
    else cout << s.substr(0, k) << "..." << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N; scanf("%d", &N);
	int H,W; scanf("%d %d", &H, &W);

	int ans = 0;
	REP(i,N){
		int leftdown = i+H;
		REP(j,N){
			int right = j+W; 
			if(leftdown <= N && right <= N) ans++;
		}
	}

	printf("%d\n", ans);

	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;

lint calc(lint a,lint b){
    if(b == 0) return 1;
    if(b % 2 ==0){
        lint c = calc(a,b/2);
        return (c * c) % MOD;
    }else{
        return (a * calc(a,b - 1)) % MOD;
    }
}
int main(){
    int x,y;
    cin >> x >> y;
    if((x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    int n = (2 * x - y) / 3;
    int m = (2 * y - x) / 3;
    if(n < 0 || m < 0){
        cout << 0 << endl;
        return 0;
    }
    lint a = 1;
    lint b = 1;
    REP(i, n){
        a =  (a * (n - i)) % MOD;
        b =  (b * (m + n - i)) % MOD;
    }
    lint wal = calc(a,MOD - 2);
    cout << (b * wal) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
# import math
# from itertools import permutations as permus
# from fractions import gcd

# import numpy as np
# import scipy as scp

# 入力の受け取り
a,b,k = map(int,input().split())

takahasi = a
aoki = b

if k >= takahasi:
    k = k - takahasi
    takahasi = 0
else:
    takahasi -= k
    k = 0

if k >= aoki:
    aoki = 0
else:
    aoki -= k

print(takahasi,aoki)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

vector<int> d;
struct SegmentTree {
	int n;
	SegmentTree(int m, int v = 0) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, v);
	}
	void update(int i, int x) {
		d[n + i] = x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)
			d[j] = min(d[j * 2], d[j * 2 + 1]);
	}
	// [l, r)
	int query(int l, int r) {
		assert(l < r);
		int mini = get(l);
		for (; l && l + (l&-l) <= r; l += l&-l)
			mini = min(mini, d[(n + l) / (l&-l)]);
		for (; l < r; r -= r&-r)
			mini = min(mini, d[(n + r) / (r&-r) - 1]);
		return mini;
	}
	int get(int i) { return d[n + i]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree st(n, INT_MAX);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		dump(com, x, y);
		if (com == 0) {
			st.update(x, y);
		}
		else {
			cout << st.query(x, y + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var count = 0L;
        for(int i = 1; i < n; i++)
        {
            count += (n - 1) / i;
        }
        WriteLine(count);
    }
}


Measured memory_bytes: 17648
n=int(input())
s=n**0.5
d=[]
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    d.append(i)
    if i!=n//i:
      d.append(n//i)
d.sort()
import bisect as bi
b=bi.bisect_left(d,s)
print(min(n//d[b-1]+d[b-1]-2,n//d[b]+d[b]-2))

Measured memory_bytes: 3296
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
using namespace std;

/*
const int MAX=1000;
vector<vector<int> > memo(MAX,vector<int>(MAX));
vector<vector<int> > done(MAX,vector<int>(MAX));
int dfs(vector<vector<int> > vi,int i,int j,int sum);

int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int m,n;
	while(cin>>m>>n&&m!=0&&n!=0){
		vector<vector<int> > ice(m,vector<int>(n));
		int ans=0;
		for(int i=0; i<MAX; ++i){
			for(int j=0; j<MAX; ++j){
				memo[i][j]=0;
				done[i][j]=0;
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				cin >> ice[j][i];
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				if(ice[i][j]==1) {
					ans=max(ans,dfs(ice,i,j,0));
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

int dfs(vector<vector<int> > vi,int i,int j,int sum){
	if(done[i][j]==1) return memo[i][j];
	if(i+1>=vi.size()&&j+1>=vi[i].size()&&i-1<0&&j-1<0&&vi[i+1][j]==0&&vi[i][j+1]==0&&vi[i-1][j]==0&&vi[i][j-1]==0) return sum;
	done[i][j]=1;
	++sum;
	if(i+1<vi.size()) memo[i][j]=dfs(vi,i+1,j,sum+1);
	if(j+1<vi[i].size()) memo[i][j]=dfs(vi,i,j+1,sum+1);
	if(i-1>=0) memo[i][j]=dfs(vi,i-1,j,sum+1);
	if(j-1>=0) memo[i][j]=dfs(vi,i,j-1,sum+1);
	return memo[i][j]; 
}
*/

int main(){
	vector<int> n(3);
	vector<int> cnt(4);
	while(cin>> n[0] >> n[1] >> n[2]){
		int MAX;
		if(n[0]>=n[1]&&n[0]>=n[2]) {
			MAX=n[0];
			if(MAX>=n[1]+n[2]) break;
			if(MAX*MAX==n[1]*n[1]+n[2]*n[2]) ++cnt[1];
			if(MAX*MAX<n[1]*n[1]+n[2]*n[2]) ++cnt[2];
			if(MAX*MAX>n[1]*n[1]+n[2]*n[2]) ++cnt[3];
		}
		else if(n[1]>=n[0]&&n[1]>=n[2]) {
			MAX=n[1];
			if(MAX>=n[0]+n[2]) break;
			if(MAX*MAX==n[0]*n[0]+n[2]*n[2]) ++cnt[1];
			if(MAX*MAX<n[0]*n[0]+n[2]*n[2]) ++cnt[2];
			if(MAX*MAX>n[0]*n[0]+n[2]*n[2]) ++cnt[3];
		}
		else if(n[2]>=n[0]&&n[2]>=n[1]) {
			MAX=n[2];
			if(MAX>=n[0]+n[1]) break;
			if(MAX*MAX==n[1]*n[1]+n[0]*n[0]) ++cnt[1];
			if(MAX*MAX<n[1]*n[1]+n[0]*n[0]) ++cnt[2];
			if(MAX*MAX>n[1]*n[1]+n[0]*n[0]) ++cnt[3];
		}
		++cnt[0];
	}
	for(int i=0; i<4; ++i){
		cout << cnt[i];
		if(i!=3) cout << " ";
	}
	cout << "\n";
	return 0;
}

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

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

    int a1[n];
    int a2[n];
    for (int i = 0; i < n; i++) {
        cin >> a1[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a2[i];
    }

    for (int i = 1; i < n; i++) {
        a1[i] += a1[i-1];
    }

    for (int i = n-2; i >= 0; i--) {
        a2[i] += a2[i+1];
    }

    int maxi = 0;
    for (int i = 0; i < n; i++) {
        maxi = max(maxi, a1[i]+a2[i]);
    }

    cout << maxi << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C = list(map(int, input().split()))

if A == B and B == C:
  if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print("0")
  else:
    print("-1")
  exit()

for i in range(100000):
  if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    Ans = i
    break
  a = A // 2
  b = B // 2
  c = C // 2
  A = b + c
  B = c + a
  C = a + b

print(Ans)


Measured memory_bytes: 3064
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
    int n,x;
    cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int c=1,su=0;
    for(int i=0;i<n;i++){
        su+=a[i];
        if(su>x)
        break;
        c++;
    }
    cout<<c;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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

int main(){
  	int a,b,c;
  
  	cin >> a >> b >>c;
  
  	rep(i,1,101){
      if(a*i % b == c){
        cout << "YES" << endl;
        return 0;
      }
    }
  	
  	cout << "NO" << endl;
  	return 0;
}

Measured memory_bytes: 256