akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		NavigableMap<Integer, Integer> s = new TreeMap();

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (s.isEmpty()) {
				s.put(a, 1);
				continue;
			}
			if (s.firstEntry().getKey() >= a) {
				s.put(a, s.getOrDefault(a, 0) + 1);
			} else {
				int v = s.lowerEntry(a).getValue();
				if (v > 1) {
					s.put(s.lowerEntry(a).getKey(), v - 1);
				} else {
					s.remove(s.lowerEntry(a).getKey());
				}
				if (s.containsKey(a)) {
					s.put(a, s.get(a) + 1);
				} else {
					s.put(a, 1);
				}
			}
		}

		int count = 0;
		for (Map.Entry<Integer, Integer> i : s.entrySet()) {
			count += i.getValue();
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 63280
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
#define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for (int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef vector<vector<vector<ll>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// vector<long long> v(n), c(n);
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)

// ll dp[1005][3] = {99999999};

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];
    vector<ll> dp(n + 1, INF);
    dp[0] = 0;
    rep(i, 0, n) {
        if (i + 1 < n) {
            chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        }
        if (i + 2 < n) {
            chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
        }
    }
    cout << dp[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 4752
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

//0-indexed
template<class T = int>
struct CumulativeSum1D
{
	bool builded;
	vector<T> data;
	CumulativeSum1D(int N) { builded = false; data.resize(N + 1, 0); }
	inline void add(int i, T x)
	{
		data[i + 1] = x;
	}

	void build()
	{
		int n = data.size();
		for (int i = 1; i < n; i++) {
			data[i] += data[i - 1];
		}
		builded = true;
	}

	inline T query(int l, int r) { assert(builded); return data[r + 1] - data[l]; }
};

int main(void) {
	int N;
	string S;
	cin >> N >> S;
	CumulativeSum1D<int> csE(N), csW(N);
	REP(i, N) {
		if (S[i] == 'E')csE.add(i, 1);
		else csW.add(i, 1);
	}
	csE.build();
	csW.build();
	int ans = N;
	REP(i, N) {
		int l = (i == 0) ? 0 : csW.query(0, i - 1);
		int r = (i == N - 1) ? 0 : csE.query(i + 1, N - 1);
		ans = min(ans, l + r);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2964
n = int(input())
x = [int(i) for i in input().split()]
p = 10000000
for i in range(100):
    pi = 0
    for j in range(n):
        pi += (x[j] - (i + 1))**2
    if pi < p:
        p = pi
    else:
        break
        # p[i] += (x[j]-(i+1))**2
print(p)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
long a,b,c,d;
long M=1e9+7;
long p(long a,int b)
{
	long ans=1;
	while(b)
	{
		if(b&1)ans*=a,ans%=M;
		a*=a;
		a%=M;
		b>>=1;
	}
	return ans;
}
long P(int n,int m)
{
	long ans=1LL;
	for(int i=m-1;i>=0;i--)ans*=n-i,ans%=M;
	return ans;
}
long dp[1001][1001];
long e[1001];
long PC[1001][1001];
long PW[1001][1001];
main()
{
	long n;
	cin>>n>>a>>b>>c>>d;
	for(int i=0;i<=n;i++)dp[i][0]=1;
	e[0]=1;
	for(int i=1;i<=n;i++)e[i]=e[i-1]*i%M;
	for(int i=0;i<=n;i++)
	{
		for(int j=i;j>=0;j--)
		{
			PC[i][j]=e[i]*p(e[i-j],M-2)%M;
		}
	}
	for(int i=0;i<=n;i++)e[i]=p(e[i],M-2);
	for(int i=a;i<=b;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=dp[i-1][j];
			for(int k=c;k<=d&&j-i*k>=0;k++)
			{
				(dp[i][j]+=dp[i-1][j-i*k]*PC[n-j+i*k][i*k]%M*p(e[i],k)%M*e[k]%M)%=M;
			}
		}
	}
	cout<<dp[b][n]<<endl;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    string s;
    cin >> s;
    int res = INF;
    rep(i, s.size()) {
        string t = s.substr(i,3);
        int hoge = stoi(t);
        if (abs(753-hoge) < res) {
            res = abs(753-hoge);
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
W,H,N = map(int, raw_input().split())

l,r,t,b = 0,W,0,H
for _ in range(N):
  x,y,a = map(int, raw_input().split())
  if a==1:
    l = max(l, x)
  if a==2:
    r = min(r, x)
  if a==3:
    t = max(t, y)
  if a==4:
    b = min(b, y)
print max(r-l, 0)*max(b-t, 0)


Measured memory_bytes: 2568
#define _CRT_SECURE_NO_WARNINGS
//                  Allah_Almost3aan       
//      *{ربى..  كنْ لىِ خيرَ مدبر فإنى لا احسنُ التدبير}*
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
using ll = long long;
ll mod = 1e9 + 7;
const ll  OO = 1e18;
#define ed "\n"
#define ff first
#define ss second
#define sz(a) a.size()
#define INF 1e9
#define SZ 1000007
#define RT(v) return cout<<v<<ed,0
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stpr(n) fixed<<setprecision(n)
#define pi 3.14159265358979323846
int di[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
int dj[8] = { 0, -1, 0, 1, 1, 1, -1, -1 };
const int N = 1.5 * 10000000 + 16;
string ys = "Yes", no = "No";
void fast() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}
int main() {
	fast();
	int n; cin >> n; 
   string s,t1,t2; cin>>s;
   t1=s.substr(0,n/2);
   t2=s.substr(n/2);
   //cout<<t1<<" "<<t2<<ed;
   cout<<(t1==t2?ys:no)<<ed;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,a,b,A;
  a=0;
  b=0;
  cin >> A;
  vector<int> vec(A);
  for (int i = 0; i < A; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(i=0;i<A;i+=2){
    a += vec.at(A-1-i);
    if(i+1 < A){
      b += vec.at(A-2-i);
    }
  }
  cout << (a - b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000
#define EPS 1e-6

using namespace std;

typedef complex<double> P;
typedef long long int LL;
vector<P> in;

void read(int &n) {
    in.resize(n);
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        in[i] = P(x, y);
    }
}

int solve(int &n) {
    int mx = 1;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            P c[2];
            double v, w;
            v = abs(in[i] - in[j]);
            if (v > 2.0) continue;
            w = sqrt(1.0 - v * v / 4.0);
            // cout << w << endl;
            P un1 = ((in[i] - in[j]) * P(0, 1)) / v;
            P un2 = ((in[i] - in[j]) * P(0, -1)) / v;
            // cout << real(un2) << " " << imag(un2) << endl;
            c[0] = un1 * w + (in[i] + in[j]) / 2.0;
            c[1] = un2 * w + (in[i] + in[j]) / 2.0;
            // cout << real((in[i] + in[j]) / 2.0) << " " << imag((in[i] + in[j]) / 2.0) << endl;
            // cout << real(c[0]) << " " << imag(c[0]) << endl;

            for (int k = 0; k < 2; k++) {
                // cout << real(c[k]) << " " << imag(c[k]) << endl;
                int cnt = 0;
                for (int l = 0; l < n; l++) {
                    // cout << i << " " << j << " " << l << " " << abs(c[k] - in[l]) << endl;
                    if (abs(c[k] - in[l]) <= 1.0 + EPS) {
                        cnt++;
                    }
                }
                mx = max(mx, cnt);
            }
        }
    }

    return mx;
}

int main() {
    int n;
    while (cin >> n, n) {
        read(n);
        cout << solve(n) << endl;
        in.clear();
    }
    return 0;
}

Measured memory_bytes: 3132
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=5e5+5;
int n,t,opt,tree[maxn<<2],pos,x,y;
char s[maxn],ch;
int judge(int x){
    int cnt=0;
    while(x){
        if(x&1){
            cnt++;
        }
        x=x>>1;
    }
    return cnt;
}
void build(int node,int l,int r){
    if(l==r){
        tree[node]=1<<(s[l]-'a');
        return ;
    }
    int mid=(l+r)>>1;
    build(node<<1,l,mid);
    build(node<<1|1,mid+1,r);
    tree[node]=tree[node<<1]|tree[node<<1|1];
}
void change(int node,int l,int r,int pos){
    if(l==r&&l==pos){
        tree[node]=1<<(ch-'a');
        return ;
    }
    int mid=(l+r)>>1;
    if(mid>=pos)    change(node<<1,l,mid,pos);
    else            change(node<<1|1,mid+1,r,pos);
    tree[node]=tree[node<<1]|tree[node<<1|1];
}
int query(int node,int L,int R,int l,int r){
    if(L<=l&&R>=r){
        return tree[node];
    }
    int mid=(l+r)/2,ans=0;
    if(mid>=L) ans=ans|query(node<<1,L,R,l,mid);
    if(mid<R)  ans=ans|query(node<<1|1,L,R,mid+1,r);
    return ans;
}
int main(){
    scanf("%d %s %d",&n,s+1,&t);
    build(1,1,n);
    while(t--){
        scanf("%d",&opt);
        if(opt==1){
            scanf("%d %c",&pos,&ch);
            if(s[pos]!=ch){
                change(1,1,n,pos);
                s[pos]=ch;//改变
            }
        }else{
            scanf("%d %d",&x,&y);
            printf("%d\n",judge(query(1,x,y,1,n)));
        }
    }
    return 0;
}
//__builtin_popcount()


Measured memory_bytes: 6400
import sys,math,copy,queue,itertools
sys.setrecursionlimit(10**7)
#input = sys.stdin.readline
def LI(): return [int(x) for x in input().split()]
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
S = input()
for i in range(len(S)//2):
    if S[i] != S[len(S)-i-1]:
        print ('No')
        exit (0)

for i in range((len(S)//2)//2):
    if S[i] != S[len(S)//2-i-1]:
        print ('No')
        exit (0)
    if S[(len(S)+3)//2+i-1] != S[len(S)-i-1]:
        print ('No')
        exit (0)
print ('Yes')

Measured memory_bytes: 40568
#include <iostream>
 
int main() {
    int x, h, m, s;
    std::cin >> x;
    h = x / 3600;
    m = (x % 3600) / 60;
    s = (x % 3600) % 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define int long long 
#define MOD 1000000007
using namespace std;

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

  if (a>b) swap(a,b);

  if (a==1 && b==2) cout<<3;
  else if (a==1 && b==3) cout<<2;
  else if (a==2 && b==3) cout<<1;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] p = new int[n];
	foreach(i; 0..n) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	int[] a;
	bool prev = true;
	int s = 0;
	bool judge(int[] a) {
		//writeln(a);
		int n = a.length.to!int;
		if (n == 0) return true;
		if (n%2 == 0) {
			n--;
			a = a[0..n];
		}
		foreach (i; 0..n) {
			if (i%2 == 0) {
				if (a[i] < 0 || a[i] >= n) return false;
				if (a[i]%2 == 1) return false;
			} else {
				if (a[i] != i) return false;
			}
		}
		int l = -1, r = -1;
		foreach (i; 0..n) {
			if (i%2) continue;
			if (a[i] < i) {
				if (a[i] < l) return false;
				l = a[i];
			} else {
				if (a[i] < r) return false;
				r = a[i];
			}
		}
		return true;
	}
	foreach (i; 0..n) {
		if (p[i] == i) {
			if (prev) {
				if (!judge(a)) {
					writeln("No");
					return;
				}
				a = new int[0];
				s = i+1;
			} else {
				a ~= p[i]-s;
			}
			prev = true;
		} else {
			if (!prev) {
				if (!judge(a)) {
					writeln("No");
					return;
				}
				a = new int[0];
				s = i;
				a ~= p[i]-i;
			} else {
				a ~= p[i]-s;
			}
			prev = false;
		}
	}
	if (!judge(a)) {
		writeln("No");
	} else {
		writeln("Yes");
	}
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,i,ans;
int main(){
	cin>>n;
	for(i=sqrt(n);i>=1;i--)
	{
		if(n%i==0)  break;
	}
	b=n/i;
	while(b)
	{
	    b=b/10;
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	
	long long int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	long long int r = 0;
	r = x * 2 * c;
	if (y > x)r += (y - x)*b;

	long long int t = 0;
	t = y * 2 * c;
	if (x > y)t += (x - y)*a;

	t = min(t, a*x + b*y);
	cout << min(r, t) << endl;

	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n, m, x;
	cin >> n >> m >> x;
	vi a(m);
	rep(i, m) cin >> a[i];
	int c = lower_bound(a.begin(), a.end(), x) - a.begin();
	cout << min(c, m - c) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define x first
#define y second
typedef long long ll;

using namespace std;


int main()
{_
    string input;

    cin >> input;
    for(int i=0; i<input.length(); i++)
        if(i == 3 && input[i]!='8')
            cout << "8";
        else
            cout << input[i];

    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
cnt = collections.Counter(a)
if n%2 == 0:
    ans = 1
    for i in range(1,n, 2):
        if cnt[i] == 2:
            ans = ans*2%MOD
        else:
            print(0)
            exit()
else:
    ans = 1
    for i in range(2,n, 2):
        if cnt[i] == 2:
            ans = ans*2%MOD
        else:
            print(0)
            exit()
    if cnt[0] != 1:
        print(0)
        exit()
print(ans)

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

int main(void){
 
  int x,A,B;
  cin >> x >> A >> B;
  
  if(abs(x-A) < abs(x-B)){
      cout << 'A' <<endl; 
  }
  else{
      cout << 'B' <<endl;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int;

int main(){
    std::vector<std::string> num;
    std::vector<int> keta;

    while(true){
        std::string _num;
        int _keta;
        std::cin >> _num >> _keta;

        if(_num == "0" && _keta == 0) break;
        for(int i=_num.size();i<_keta;i++){
            _num+='0';
        }
        num.emplace_back(_num);
        keta.emplace_back(_keta);
    }

    for(int i=0;i<num.size();i++){
        int _diff;
        int diff = std::stoi(num[i]);
        int cnt=1;

        std::vector<int> ans(1000000,0);

        ans[diff]=cnt;

        while(true){
            std::string max_s = std::to_string(diff);
            std::string min_s = std::to_string(diff);

            for(int j=max_s.size();j<keta[i];j++){
                max_s+='0';
                min_s+='0';
            }

            std::sort(max_s.begin(),max_s.end(),std::greater<int>());
            std::sort(min_s.begin(),min_s.end());
            int max = std::stoi(max_s);
            int min = std::stoi(min_s);

            _diff = max-min;
            //std::cout << "diff " << _diff << std::endl;
            cnt++;
            if(ans[_diff]!=0) break;
            else ans[_diff]=cnt;
            diff = _diff;
        }

        std::cout << ans[_diff]-1 << " " << _diff << " " << cnt-ans[_diff] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 7104
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;

int main() {
#ifdef LOCAL
    freopen("c.in", "r", stdin);
#endif

    int n;
    cin >> n;
    map<int, int> a;
    forn(i, n) {
        int x;
        cin >> x;
        ++a[x];
    }

    int mx = 0;
    for (auto kv: a) {
        int s = 0;
        for (int x: {kv.fi-1, kv.fi, kv.fi+1}) {
            if (a.count(x)) s += a[x];
        }
        mx = max(mx, s);

    }
    cout << mx << endl;


#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3200
using System;
namespace aizu
{
    class No0007
    {
        public static void Main()
        {
            int n;
            int money = 100000;
            string[] input = Console.ReadLine().Split();
            n = int.Parse(input[0]);
            for(int i=1;i <= n;++i){
                money = (int)(money * 1.05);
                if(money % 1000 != 0){
                    money = (money / 1000 + 1) * 1000;
                }
            }
            Console.WriteLine(money.ToString());
        }
    }
}

Measured memory_bytes: 5612
#!/usr/bin/env python3
#ABC133 D

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]

n = int(input())
a = LI()

ans = [0]*n
ans[0] = sum(a) - 2*(sum([a[i] for i in range(n) if i % 2 == 1]))

for i in range(n-1):
    ans[i+1] = 2*a[i]-ans[i]

print(' '.join(map(str,ans)))


Measured memory_bytes: 80740
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
typedef long double ld;
pll a[3009];
ll dp[3009][8009];
ll ans, n, t;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> t;
    for(int i = 1; i <= n; ++i)
        cin >> a[i].ff >> a[i].ss;
    sort(a+1, a+n+1);
    for(int i = 1; i <= n; ++i)
        for(int j = 0; j < t; ++j){
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            dp[i][j + a[i].ff] = max(dp[i][j + a[i].ff], dp[i-1][j] + a[i].ss);
            ans = max(ans, dp[i][j + a[i].ff]);
        }
    cout << ans << "\n";
}

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

#define DIV 1000000007

long long N;
long long A[200005];
long long B[200005];

long gcd(long a,long b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	//a, b -> count
	map<pair<long long, long long>, long long> memo;
	long long azero = 0;
	long long bzero = 0;
	long long abzero = 0;
	for(long long i = 0; i < N; i++) {
		long long a = A[i];
		long long b = B[i];
		if(a < 0 && b < 0) {
			a = -a;
			b = -b;
		}
		long long g = gcd(a, b);
		if(a == 0 && b == 0) {
			abzero++;
			continue;
		} else if(a == 0) {
			azero++;
			continue;
		} else if(b == 0) {
			bzero++;
			continue;
		}
		a/=g;
		b/=g;

		memo[make_pair(a, b)]++;
	}
	long long ans = 1;

	//azeroからerabu もしくは bzeroから選ぶ
	ans *= (modpow(2, azero) - 1) + (modpow(2, bzero) - 1) + 1;
	ans = (ans + DIV)%DIV;

	set<pair<long long, long long> > done;
	for(auto item: memo) {
		long long a = item.first.first;
		long long b = item.first.second;
		long long num = item.second;

		if(done.count(make_pair(a, b)) > 0) {
			continue;
		}
		done.insert(make_pair(a, b));

		long long tmpans = 0;

		long long okpair = num;
		if(memo.count(make_pair(-a, -b)) > 0) {
			okpair += memo[make_pair(-a, -b)];
			done.insert(make_pair(-a, -b));
		}
		tmpans += modpow(2, okpair) - 1;

		long long ngpair = 0;
		if(memo.count(make_pair(-b, a)) > 0) {
			ngpair += memo[make_pair(-b, a)];
			done.insert(make_pair(-b, a));
		}
		if(memo.count(make_pair(b, -a)) > 0) {
			ngpair += memo[make_pair(b, -a)];
			done.insert(make_pair(b, -a));
		}
		tmpans += modpow(2, ngpair) - 1;

		ans *= (tmpans + 1);
		ans = (ans + DIV)%DIV;
	}

	ans--;
	ans = (ans + DIV)%DIV;
	ans += abzero;
	ans = (ans + DIV)%DIV;
	cout << ans << endl;
}



Measured memory_bytes: 31680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int n,allgcd=-1,cnt[1000010];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        cnt[a]++;
        if(i==0)allgcd=a;
        else allgcd=gcd(allgcd,a);
    }
    bool f=true;
    for(int i=2;i<=1000000;i++){
        int sum=0;
        for(int j=i;j<=1000000;j+=i){
            sum+=cnt[j];
        }
        if(sum>=2){
            f=false;
            break;
        }
    }
    if(f){
        puts("pairwise coprime");
    }
    else if(allgcd==1){
        puts("setwise coprime");
    }
    else puts("not coprime");
    return 0;
}

Measured memory_bytes: 7540
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int main()
  {
  ios_base::sync_with_stdio(0); 
  string s;
  cin >> s;
  s[0] = s.back();
  if(s[0] == '3')cout << "bon" << endl;
  else if(s[0] == '0' || s[0] == '1' || s[0] == '6' || s[0] == '8')cout << "pon" << endl;
  else cout << "hon" << endl;
  }


Measured memory_bytes: 3648
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
const int maxn =1e5+10;
using namespace std;
int n;
int a[maxn];
int b[maxn]={0};
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]=i;
	}
	sort(a,a+n);
	
	for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<" ";
	}
} 

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
int l[200005],r[200005],mk[200005];
int n,k,c;
string s;
int rec(int i){
	if(i>n)return 0;
	if(l[i]!=-1)return l[i];
	if(s[i-1]=='o')l[i]=1+rec(i+1+c);
	else l[i]=rec(i+1);
	return l[i];
}
int rec1(int i){
	if(i<1)return 0;
	if(r[i]!=-1)return r[i];
	if(s[i-1]=='o')r[i]=1+rec1(i-1-c);
	else r[i]=rec1(i-1);
	return r[i];
}
void solve(){
	cin>>n>>k>>c;
	cin>>s;
	rep(i,n){
		l[i+1]=r[i+1]=-1;
	}
	for(int i=1;i<=n;i++){
		if(l[i]!=-1)continue;
		rec(i);
	}
	for(int i=n;i;i--){
		if(r[i]!=-1)continue;
		rec1(i);
	}
	for(int i=1;i<=n;i++){
		int x=r[i-1]+l[i+1];
		if(x>=k)mk[i]=1;
	}
	for(int i=1;i<=n;i++)if(mk[i]==0&&s[i-1]!='x')cout<<i<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 9620
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }


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


	bool ans = true;
	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				ans = false;

			}
		}
	}

	if (ans == true) {
		cout << "APPROVED" << endl;
		return 0;
	}
	cout << "DENIED" << endl;

}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <sstream>
#include <iostream>
#include <cstring>
#define REP(i,x,v)for(int i=x;i<=v;i++)
#define REPD(i,x,v)for(int i=x;i>=v;i--)
#define FOR(i,v)for(int i=0;i<v;i++)
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define IN(x,y) ((y).find((x))!=(y).end())
#define LOLDBG
#ifdef LOLDBG
#define DBG(vari) cout<<#vari<<" = "<<vari<<endl;
#define DBG2(v1,v2) cout<<(v1)<<" - "<<(v2)<<endl;
#else
#define DBG(vari)
#define DBG2(v1,v2)
#endif
#define CZ(x) scanf("%d",&(x));
#define CZ2(x,y) scanf("%d%d",&(x),&(y));
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
template<typename T,typename TT> ostream &operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream &operator<<(ostream &s,vector<T> t){s<<"{";FOR(i,t.size())s<<t[i]<<(i==t.size()-1?"":",");return s<<"}"<<endl; }



int main()
{
    ios_base::sync_with_stdio(0);
    int n,k,s;cin>>n>>k>>s;
    int mx=1e9,mn=1;
    if (s<mx)
    {
        FOR(j,k) cout<<s<<" ";
        FOR(j,n-k) cout<<mx<<" ";
    }
    else
    {
        FOR(j,k) cout<<mx<<" ";
        FOR(j,n-k) cout<<mn<<" ";
    }

    return 0;
}


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

int main(){
  int N,A,B;
  int sum1=0,sum2=0,sum3=0;
  cin>>N>>A>>B;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
    if(P.at(i)<=A)sum1++;
    if(P.at(i)>A&&P.at(i)<=B)sum2++;
    if(P.at(i)>B)sum3++;
  }
  cout<<min(min(sum1,sum2),sum3)<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <stdio.h>
  
  int main()
    {
    	int H,W;
      	int N;
        int ans_int;
        double ans_re;
      	scanf("%d",&H);
        scanf("%d",&W);
        scanf("%d",&N);
    
        if(H > W){
            ans_re = (double)N/(double)H;
            ans_int = N/H;
            if(ans_re > ans_int){
                ans_int = ans_int +1;
            }
            else{
            }
            printf("%d",ans_int);
        }
        else{
            ans_re = (double)N/(double)W;
            ans_int = N/W;
            if(ans_re > ans_int){
                ans_int = ans_int +1;
            }
            else{
            }
            printf("%d",ans_int);
        }

    return 0;
    }

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();

        int[][] Mat = new int[n][n];

        int u, k, v;
        for (int i = 0; i < n; i++) {
            u = sc.nextInt();
            k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                v = sc.nextInt();
                Mat[u - 1][v - 1] = 1;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(Mat[i][j]);
                if (j != n - 1) {
                    System.out.print(" ");
                }
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 34608
x = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if x == 1:
    print(2)
    exit()
i = 0
while True:
    a = prime_factorize(x + i)
    if len(a) == 1:
        print(x + i)
        exit()
    i += 1

Measured memory_bytes: 38512
n = int(input())
A = list(map(int, input().split()))
x4, x2, x = 0, 0, 0
for a in A:
    if a % 4 == 0:
        x4 += 1
    else:
        if a % 2 == 0:
            x2 = 1
        else:
            x += 1
print('Yes' if x2 + x - 1 <= x4 else 'No')

Measured memory_bytes: 14252
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
ll mod = 1000000007;
int main(void)
{
    ll n,k;
    cin>>n>>k;
    double pans=0;
    for(int i=1;i<=n;i++)
    {
        //i points
        ll a =0;
        while(1)
        {   
            if(i*pow(2,a)>=k) break;
            else a ++;


        }
        double p = pow(0.5,a);
        pans+=p;
    }

    pans/=n;

    cout<<setprecision(14)<<pans<<endl;

}

Measured memory_bytes: 3340
#include<iostream>
 
using namespace std ;
 
int main()
{
  int d;
  cin>>d;
  if(d==22)
  {
    cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
  }
  else if(d==23)
  {
    cout<<"Christmas Eve Eve"<<endl;
    return 0;
  }
  else if(d==24)
  {
    cout<<"Christmas Eve"<<endl;
    return 0;
  }
  else if(d==25)
  {
    cout<<"Christmas"<<endl;
    return 0;
  }
 return 0;
}

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

int main()
{
  int64_t N, M, ans = 1;
  cin >> N >> M;
  for (int64_t n = 1; n <= sqrt(M); n++)
  {
    if (M % n != 0)
      continue;
    int64_t m = M / n;
    if (m >= N)
      ans = max(ans, n);
    if (n >= N)
      ans = max(ans, m);
  }
  cout << ans << endl;
}

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

int main(){
	int N;
    double ans=0;
    cin >> N;
    for(int i=0;i<N;i++){
      double a;
      string s;
      cin >> a >> s;
      if(s=="JPY")
        ans += a;
      else
        ans += a*380000;
    }
  cout << fixed << setprecision(5) << ans << endl;
}

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

N = int(input())
rates = [tuple(map(int, input().split())) for _ in range(N)]

a, b = 1, 1
n = 1
for i in range(N):
    n = max(-((-a) // rates[i][0]), -((-b) // rates[i][1]))
    a = rates[i][0] * n
    b = rates[i][1] * n
print(a + b)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	i64* a = new i64[n];
	i64* b = new i64[n];
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];
	
	i64 ac = 0;
	i64 bc = 0;
	rep(i, 0, n) {
		if (a[i] > b[i]) bc += a[i] - b[i];
		else ac += (b[i] - a[i]) / 2;
	}
	if (ac >= bc) cout << "Yes";
	else cout << "No";
  	delete[] a;
	delete[] b;
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <cstdint>

uint32_t dig_sum(uint32_t a) {
	uint32_t ans = 0;
	while (a) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}

int main() {
	uint32_t n;
	std::cin >> n;
	uint32_t ans = 100000;
	for (uint32_t i = 1;i < n;i++) {
		uint32_t cur = dig_sum(i) + dig_sum(n - i);
		ans = std::min(cur, ans);
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 256
def dprint(*args):
  if debug:
    if len(args)==1:
      print(args[0])
    else:
      print(args)

debug = False
if debug:
  N=6
  H=[30,10,60,10,60,50]
else:
  N = int(input())
  H = list(map(int,input().split()))

# print(N,H)
  
C=[99999]*N

for i in range(N):
  if i==0:
    C[0]=0
    continue
  elif i==1:
    C[1]=abs(H[1]-H[0])    
    continue
  else:
    dprint(i,C[i], C[i-1]+abs(H[i]-H[i-1]), C[i-2]+abs(H[i]-H[i-2]))
    C[i] = min(C[i-1]+abs(H[i]-H[i-1]), C[i-2]+abs(H[i]-H[i-2]))    
    # C[i] = min(C[i], C[i-1]+abs(H[i]-H[i-1]), C[i-2]+abs(H[i]-H[i-2]))

dprint(H)    
print(C[-1])


Measured memory_bytes: 13924
#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<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).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"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#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; }

ll f(ll n){
    while(n > 9) n /= 10;
    return n;
}

ll d(ll n){
    ll res = 0;
    while(n){
        res++;
        n /= 10;
    }
    return res;
}

ll s(ll n){
    ll res = 0;
    while(n){
        res += n%10;
        n /= 10;
    }
    return res;
}

int main(void){
    ll N; cin >> N;
    ll digit = d(N), l = f(N);
    if(N == (l+1)*(ll)pow(10,digit-1)-1){
        cout << s(N) << en;
    }
    else{
        cout << s(l*(ll)pow(10,digit-1)-1) << en;
    }
    return 0;
}

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

using namespace std;

// #define MOD 1000000007;


long long modpow(long long a, long long n,long long mod);

int main(void)
{
  long long N;
  long long ans,mod;
  mod = 1000000007;
  cin >> N;
  ans = (modpow(10,N,mod) + modpow(8,N,mod))%mod - (2*modpow(9,N,mod)) % mod;
  ans = ans % mod;
  while(ans < 0) ans += mod;

  cout << ans << endl;

  return 0;
}


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


Measured memory_bytes: 3628
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, k = li()

ans = 0
for i in range(k+1, n+1):
    ans += (n+1)//i * (i-k)
    ans += max(0, (n+1)%i - k)

if k == 0:
    ans -= n

print(ans)

Measured memory_bytes: 3064
S = list(map(int, list(input())))

mod = 2019
ctr = [0] * mod
t = 0
for i, v in enumerate(reversed(S)):
    t = (t + int(v) * pow(10, i, mod)) % mod
    ctr[t] += 1

ans = ctr[0]
for v in ctr:
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 86684
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ string s;
cin>>s;
if(s[2]==s[3]&&s[4]==s[5])
cout<<"Yes";
else cout<<"No";





return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;


/*
Aを(y-x)回押す。
Aたくさん  x<yのときok。y-x回かかる。
Aたくさん→B -x>=yのときok。1+(-x-y)回かかる。
B→Aたくさん -x<=yのときok。1+(y+x)回かかる。
B→Aたくさん→B x>yのときok。2+(x-y)回かかる。
*/
int main() {
	int x, y;
	int ans;
	ans = 2000000002;
	scanf("%d %d", &x, &y);

	if (x < y) { if (ans > (y - x))ans = y - x; }
	if (-x >= y) { if (ans >(1+(-x-y)))ans = (1 + (-x - y)); }
	if (-x <= y) { if (ans >(1 + (x +y)))ans = (1 + (x + y)); }
	if (x > y) { if (ans >(2 + (x - y)))ans = (2 + (x - y)); }
	printf("%d", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;
map<char,int>alp;
int main() {
	cin >> S;
	for (int i = 0; i < 4; ++i) {
		++alp[S[i]];
	}
	if (alp.size() == 2 && alp.begin()->second == 2) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int h = ni(), w = ni();
        String[] a = nsa(h);

        char[][] ansR = new char[h][w];
        char[][] ansB = new char[h][w];

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i == 0 || i < h - 1 && j % 2 == 0) {
                    ansR[i][j] = '#';
                    ansB[i][j] = '.';
                } else {
                    ansR[i][j] = '.';
                    ansB[i][j] = '#';
                }
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (a[i].charAt(j) == '#') {
                    ansR[i][j] = '#';
                    ansB[i][j] = '#';
                }
            }
        }

        for (int i = 0; i < h; i++) {
            out.println(String.valueOf(ansR[i]));
        }
        out.println();
        for (int i = 0; i < h; i++) {
            out.println(String.valueOf(ansB[i]));
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    class INA {
        int[][] a;

        INA(int n, int m) throws IOException {
            this(n, m, -1);
        }

        INA(int n, int m, int t) throws IOException {
            a = new int[m][n];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[j][i] = ni() + t;
                }
            }
        }

        int[] get(int i) {
            return a[i - 1];
        }
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007
#define _SPLIT " "

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T,class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << setprecision(12) << a << endl;}
template<class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << _SPLIT; write(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    string s;
    read(s);
    string res;
    rep(i,s.size()){
        if(s[i]!='B')res+=s[i];
        else if(res.size()>0)res.pop_back();
    }
    write(res);
    return 0;
}

Measured memory_bytes: 256