akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int ara[200002];
vector<int>adj[200002];
queue<int>q;

int bfs()
{
    int cnt,a;
    cnt=1;
    while(!q.empty())
    {
        a=q.front();
        q.pop();
        for(int i=0;i<adj[a].size();i++)
        {
            if(ara[adj[a][i]]==0)
            {
                cnt++;
                ara[adj[a][i]]=ara[a];
                q.push(adj[a][i]);
            }
        }
    }
    return cnt;
}

int main()
{
    int n,m,i,a,b;
    scanf("%d %d",&n,&m);
    for(i=0; i<m; i++)
    {
        scanf("%d %d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    a=0;
    for(i=1; i<=n; i++)
    {
        if(ara[i]==0)
        {
            q.push(i);
            ara[i]=i;
            b=bfs();
            a=max(a,b);
        }
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 15636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr= input.trim().split("\n");
var n=arr.shift()-0;
var [a,d]=arr.shift().split(" ").map(Number);
var obj={};
var m=arr.shift()-0;
for(var i=0;i<m;i++){
   var [x,y,z] = arr.shift().split(" ");
   if(obj.hasOwnProperty(y)==false)obj[y]=y;
   if(obj.hasOwnProperty(z)==false)obj[z]=z;
   if(x=="0")[obj[y],obj[z]]=[obj[z],obj[y]]
   else obj[y]=obj[z];
}
var k=arr.shift()-0;
if(obj.hasOwnProperty(k+""))k=obj[k]-0;
console.log(a+((k-1)*d));


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, sum = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 1; i < n - 1; ++i){
        if(a[i] > a[i + 1] && a[i] < a[i - 1]) sum++;
        else if(a[i] < a[i + 1] && a[i] > a[i - 1]) sum++;
    }
    cout << sum;
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			auto it = lower_bound(arr,arr+n,arr[i]+arr[j])-arr;
			ans += it-1-j;
		}
	}
	cout << ans <<"\n";
}


Measured memory_bytes: 256
inline long long in() {
  long long n = 0;
  char c = getchar_unlocked();
  while ('0' <= c && c <= '9') {
    n = n * 10 + (c - '0');
    c = getchar_unlocked();
  }
  return n;
}

int main() {
  long long I = in(), O = in(), T = in(), J = in(), L = in();
  long long n = (I&1?I-1:I) + (J&1?J-1:J) + (L&1?L-1:L);
  if (I && J && L) {
    long m = (I&1?I-1:I-2) + (J&1?J-1:J-2) + (L&1?L-1:L-2) + 3;
    printf("%lld", (n<m?m:n) + O);
  } else {
    printf("%lld", n + O);
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n, a, b, c = 0;
    cin>>n;
    while(n--)
    {
        cin>>a>>b;
        if(a == b) c++;
        else if(c < 3) c = 0;
    }
    if(c >= 3)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3600
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int a, b; cin>>a>>b;
    if(a % 2 != b % 2){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << (a + b) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long

using namespace std;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
int M;

priority_queue<int> que;

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

  ll int ans = 0;

  Rep(i, N) {
    int tmp;
    scanf("%d", &tmp);
    que.push(tmp);
    ans += tmp;
  }

  Rep(i, M) {
    int top = que.top(); 
    que.pop();

    int tmp = top / 2;
    ans -= (top - tmp);
    que.push(tmp);
  }

  printf("%lld\n", ans);
  
}

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

int comparator(const void *p, const void *q)
{
    int l = *(const int *)p;
    int r = *(const int *)q;
    return (r-l);
}

int main()
{
    int n, i, sa = 0, sb = 0;
    scanf("%d", &n);
    int *v = calloc(n, sizeof(int));
    for(i = 0; i < n; i ++)
        scanf("%d", v + i);
    qsort(v, n, sizeof(int), comparator);
    for(i = 0; i < n; i += 2)
        sa += v[i];
    for(i = 1; i < n; i += 2)
        sb += v[i];
    printf("%d", sa-sb);
    free(v);
    return 0;
}

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

void showeq(vector<int> &v, string op, int ans) {
    for (int i = 0; i < v.size() - 1; i++) {
        cout << v.at(i) << op.at(i);
    }
    cout << v.at(v.size() - 1) << "=" << ans << endl;
}

string calc(vector<int> &v, int i, int ans, string op) {
    if (i == v.size()) {
        // showeq(v, op, ans);
        if (ans == 7)
            return op;
        else
            return "";
    }

    string op1 = calc(v, i + 1, ans + v.at(i), op + '+');
    if (op1 != "") return op1;

    string op2 = calc(v, i + 1, ans - v.at(i), op + '-');
    if (op2 != "") return op2;

    return "";
}

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

    vector<int> v;
    for (size_t i = 0; i < s.size(); i++) {
        v.push_back(s.at(i) - '0');
    }

    string op;
    op = calc(v, 1, v.at(0), "");

    if (op != "") showeq(v, op, 7);
}

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

int A, B;

int main() {
    cin >> A >> B;

    string ans = "Yay!";
    if (A > 8 || B > 8) {
        ans = ":(";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
K = int(input())
N = len(S)

bef = ""
start = 0
l = []
for i, s in enumerate(S):
    if bef=="":
        start = i
    elif bef!=s:
        l.append(i-start)
        start = i
    bef = s
l.append(i-start+1)

if len(set(S))==1:
    print((N*K)//2)
else:
    if S[0]==S[-1]:
        ans = (l[0]//2)+(l[-1]//2)+((l[0]+l[-1])//2)*(K-1)
    else:
        ans = (l[0]//2)*K+(l[-1]//2)*K
    for i in l[1:-1]:
        ans += (i//2)*K
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
vector<bool> func(string a, string b, string c) {
  vector<bool> ab;
  int na = a.size(), nb = b.size(), nc = c.size();
  rep(i,nc+1) ab.push_back(1);
  for(int d = nb-1; d >= 0; --d) {
    bool f = true;
    rep(i,min(nb - d, na)) {
      if(a[i] != b[i+d] && a[i] != '?' && b[i+d] != '?') f = false;
    }
    ab.push_back(f);
  }

  for(int d = 1; d < na; ++d) {
    bool f = true;
    rep(i,min(na - d, nb)) {
      if(a[i+d] != b[i] && a[i+d] != '?' && b[i] != '?') f = false;
    }
    ab.push_back(f);    
  }
  rep(i,nc+1) ab.push_back(1);  
  return ab;
}

int main()
{
  string a,b,c; cin >> a >> b >> c;
  int na = a.size(), nb = b.size(), nc = c.size();
  
  vector<bool> ab = func(a, b, c);
  vector<bool> bc = func(b, c, a);
  vector<bool> ac = func(a, c, b);

  int res = 1e+9;
  rep(i,ab.size()) {
    rep(j,ac.size()) {
      int aloc = 0;
      int bloc = i - nb - nc;
      int cloc = j - nb - nc;
      bool fbc = (0 <= j - i + na + nc && j - i + na + nc < bc.size() ? bc[j - i + na + nc] : 1);
      if(ab[i] && ac[j] && fbc) {
	if(bloc < aloc) {
	  if(cloc < aloc) {
	    //	    if(i == 5 && j == 2) cout << bloc << ":" << cloc << "\n";	    
	    int tmp = -min(bloc, cloc) + max({na, bloc + nb, cloc + nc});
	    chmax(tmp, max({na, nb, nc}));
	    chmin(res, tmp);
	  }
	  else {
	    int tmp = -bloc + max(cloc + nc, na);
	    chmax(tmp, max({na, nb, nc}));
	    chmin(res, tmp);
	  }
	}
	else {
	  if(cloc < aloc) {
	    int tmp = -cloc + max(bloc + nb, na);
	    chmax(tmp, max({na, nb, nc}));	    
	    chmin(res, tmp);
	  }
	  else {

	    int tmp = max(bloc + nb, cloc + nc);
	    chmax(tmp, max({na, nb, nc}));	    	    
	    chmin(res, tmp);
	  }	  
	}
      }
      //      if(res == 5) cout << i << ":" << j << "\n";
    }
  }

  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <cstdio>

using namespace std;

int N, M;

int main() {

    cin >> N;
    map<int, int> mp;
    int p;
    for (int i = 0; i < N; i++) {
        scanf("%d", &p);
        mp[p]++;
    }
    
    cin >> M;
    int q;
    for (int i = 0; i < M; i++) {
        scanf("%d", &q);
        mp[q]--;
    }
    
    bool can = true;
    for (auto it : mp) {
        if (it.second < 0) can = false;
    }
    if (can) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 9600
def cmb1(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


n, a, b, k = map(int, input().split())
mod = 998244353

ans = 0
for i in range(n+1):
    if k - a*i >= 0 and (k - a*i)%b == 0:
        j = (k - a*i)//b
        ans += cmb1(n, i, mod)*cmb1(n, j, mod)
        ans %= mod

print(ans)

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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var M = sc.ReadInt();
        var py = new Tuple<int, int, int>[M];
        for (int i = 0; i < M; i++)
        {
            py[i] = Tuple.Create(sc.ReadInt(), sc.ReadInt(), i);
        }
        py = py.OrderBy(x => x.Item1).ThenBy(x => x.Item2).ToArray();
        var counts = new int[(int)1e5 + 1];
        var ans = new string[M];
        for (int i = 0; i < M; i++)
        {
            counts[py[i].Item1]++;
            var l = py[i].Item1.ToString().PadLeft(6, '0');
            var r = counts[py[i].Item1].ToString().PadLeft(6, '0');

            ans[py[i].Item3] = l + r;
        }
        for (int i = 0; i < M; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 33196
n,m = map(int,input().split())
l = list(map(int,input().split()))
sl = sum(l) * (1 / (4 * m))
ok = 0

for i in range(len(l)):
  if l[i] >= sl:
    ok += 1
if ok >= m:
  print('Yes')
else:
  print('No')


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

using namespace std;

int main() {
  int n;cin>>n;
  for(int i=n;i<1000;i++){
    if(i%111==0){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

constexpr int MAX = 3000000;
int main() {
	int n; cin >> n;
	int64_t a[n]; rep(i,n) cin >> a[i];
	map<int64_t, int64_t> dp;
	dp[0] = 1000;
	for(int i = 0; i < n; ++i) {
		map<int64_t, int64_t> nxt;
		for(auto& e : dp) {
			nxt[e.first] = max(nxt[e.first], e.second);
			nxt[0] = max(nxt[0], e.second + e.first * a[i]);
			int64_t cnt = e.second / a[i];
			nxt[e.first + cnt] = max(nxt[e.first + cnt], e.second % a[i]);
		}
		dp = nxt;
	}
	cout << dp[0] << '\n';
	return 0;
}


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

#define int long long

vector<int> basis;

bool ok(int x){
	for(int i = 0 ; i < 60 ; i++){
		if((x & 1LL << i) == 0) continue ;
		if(basis[i] == 0){
			return  false;
		}
		x ^= basis[i] ;
	}
	return  true;
}

void insert(int x){
	for(int i = 0 ; i < 60 ; i++){
		if((x & 1LL << i) == 0) continue ;
		if(basis[i] == 0){
			basis[i] = x ;
			return  ;
		}
		x ^= basis[i] ;
	}
	return  ;
}

int32_t main(){
	int t ;
	cin >> t ;
	while(t--){
		basis.clear() ;
		basis.resize(60) ;
		int n ; 
		cin >> n ;
		int a[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		string s ; 
		cin >> s ;
		bool found = true ;
		for(int i = n - 1 ; i >= 0 ; i--){
			if(s[i] == '0') insert(a[i]) ;
			else{
				found &= ok(a[i]) ;
			}
		}
		cout << 1 - found << '\n' ;
	}
	return 0 ;
}



Measured memory_bytes: 3556
// https://atcoder.jp/contests/abc129/tasks/abc129_b

#include <stdio.h>
#include <stdlib.h>
#define forn(i,L,R) for (int i = L; i < R; i++)
#define wez(n) int (n); scanf("%d",&(n))
#define getInt(a) scanf("%d", &a)

int main(){
    wez(n);
    int arr[n], sum = 0;
    forn(i, 0, n)
        getInt(arr[i]);
    forn(i, 0, n)
        sum += arr[i];
    int diff = sum;
    int temSum = 0;
    forn(i, 0, n){
        temSum += arr[i];
        int x = sum - temSum - temSum;
        if (abs(x) < diff)
            diff = abs(x);
    }
    
    printf("%d\n", diff);
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[114], m = 101, res;

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	reps(i,1,n) if (a[i]==a[i-1]) a[i] = m++, res++;
	cout << res << ln;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    ll ans = 0;
    while (n > 0){
        ans++;
        n /= k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,K;cin >> n >> K;
  vector<ll> x(n),y(n);
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  ll ans=5e18;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        for(int l=0;l<n;l++){
          ll u=x[i],v=x[j],w=y[k],z=y[l];
          int cnt=0;
          for(int m=0;m<n;m++){
            if(min(u,v)<=x[m]&&x[m]<=max(u,v)&&min(w,z)<=y[m]&&y[m]<=max(w,z)){
              cnt++;
            }
          }
          if(cnt>=K){
            ans=min(ans,abs(v-u)*abs(z-w));
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<ll,ll>m;
ll a[222222];
ll n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)a[i]=(a[i-1]+a[i]-1)%k;
	ll ans=0;
	m[0]++;
	for(int l=0,r=1;r<=n;r++){
		if(r-l==k)m[a[l++]]--;
		ans+=m[a[r]];
		m[a[r]]++;
	}cout<<ans<<endl;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n, a[maxn];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
cin>>n;
  for (int i=0; i<n; i++) cin>>a[i];
  int x=0;
  while (1) {
    bool ok=true;
    for (int i=0; i<n; i++) {
      if (a[i]%2) ok=false;
    }
    if (!ok) out(x);
    x++;
    for (int i=0; i<n; i++) { a[i]=a[i]/2; }
  }
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int A[n+1],B[n+1],C[n+1],prev;
  for(int i=1;i<=n;i++)
     cin>>A[i];
   for(int i=1;i<=n;i++)
     cin>>B[i];
   for(int i=1;i<n;i++)
     cin>>C[i];
  int ans=0;
  for(int i=1;i<=n;i++){
      if(i==1){
        ans+=B[A[i]];
        prev=A[i];
      }else{
        ans+=B[A[i]];
        if(prev+1==A[i])
          ans+=C[A[i]-1];
        prev=A[i];
      }
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 256
//In the name of God
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 410 , MOD = 1e9 + 7;
int n , c , a[N] , b[N] , dp[N][N] , f[N][N];
int powmod(int x , int y){int ret = 1; for(; y ; y >>= 1){if(y&1) {ret = ret * x % MOD;} x = x * x % MOD;} return ret;}

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n >> c;
        for(int i=1 ; i <= n ; i++)
                cin >> a[i];
        for(int i=1 ; i <= n ; i++)
                cin >> b[i];
        for(int j=0 ; j < N ; j++)
                for(int i=1 ; i < N ; i++)
                        f[i][j] = (f[i-1][j] + powmod(i , j)) % MOD;
        dp[0][0] = 1;
        for(int i=1 ; i <= n ; i++)
                for(int j=0 ; j <= c ; j++)
                        for(int k=0 ; k <= j ; k++){
                                int x = (f[b[i]][k] - f[a[i]-1][k] + MOD) % MOD;
                                dp[i][j] += (dp[i-1][j-k] * x) % MOD;
                                dp[i][j] %= MOD;
                        }
        cout << dp[n][c];
        return 0;
}       


Measured memory_bytes: 2816
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, T = map(int, readline().split())
m = map(int, read().split())
AB = sorted(zip(m, m))

dp = np.zeros(T, np.int64)

ans = 0
table = np.zeros(T, int)
for a, b in AB:
    ans = max(ans, max(table) + b)
    np.maximum(table[:-a] + b, table[a:], out=table[a:])
print(ans)


Measured memory_bytes: 12620
def main():
    s = input()
    flag1, flag2, flag3 = False, False, False
    len_s = len(s)
    cnt2, cnt3 = 0, 0

    if s[0] == "A":
        flag1 = True

    for i in range(1, len_s):
        if 2 <= i <= len_s - 2 and s[i] == "C":
            cnt2 += 1
        if s[i].islower():
            cnt3 += 1

    if cnt2 == 1:
        flag2 = True

    if cnt3 == len_s - 2:
        flag3 = True

    if flag1 and flag2 and flag3:
        print("AC")
    else:
        print("WA")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61960
#include <iostream>
#include <cstring>
 
using namespace std;
 
int main()
{
	string N; // 2-10 or 2-1000
 
	cin >> N;
 
	if (strstr(N.c_str(), "7"))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>

using namespace std;

vector<int> adjacency_list[101010];
long long int mod = 10000007;
vector<int> visited;

void dfs(int cur, int pre) {
  visited[cur] = 1;
  for (auto&& next: adjacency_list[cur]) {
    if (next != pre && visited[next] != 1) {
      dfs(next, cur);
    }
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  visited = vector<int>(n);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    adjacency_list[x].push_back(y);
    adjacency_list[y].push_back(x);
  }

  int c = 0;
  for (int i = 0; i < n; ++i) {
    if (visited[i] == 1) continue;
    dfs(i, -1); 
    c++;
  }
  cout << c << endl;
}

int main() {
  solve();
}


Measured memory_bytes: 10752
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        String s=in.nextLine();
        String p=in.nextLine();
        s=s+s;
        if(s.indexOf(p)!=-1){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 26292
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){
    ll A, B;
    cin >> A >> B;
    Say(A + B < 10, to_string(A + B), "error");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int s = 0;
    for(int i=1;i<n;i++){
        int d = n/i;
        if(n%i==0) d--;
        s+=d;
    }
    printf("%d\n",s);

}
/*n = 5
ab+c
1 9
2 4
3 3
4 2
5 2
6 1
7 1
8 1
9 1*/





Measured memory_bytes: 3820
#include <iostream>
using namespace std;
using ll = long long;

const ll MOD = 998244353;

int A[3000];
ll dp[3001][3001][3];
int main()
{
    int N, S;
    cin >> N >> S;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++)
    {
        for (int s = 0; s < S + 1; s++)
        {
            dp[i + 1][s][0] = dp[i][s][0];
            if (s - A[i] >= 0)
            {
                dp[i + 1][s][1] = (dp[i][s][1] + dp[i][s][0] + dp[i][s - A[i]][1] + dp[i][s - A[i]][0]) % MOD;
                dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0] + dp[i][s - A[i]][1] + dp[i][s - A[i]][0]) % MOD;
            }
            else
            {
                dp[i + 1][s][1] = (dp[i][s][1] + dp[i][s][0]) % MOD;
                dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0]) % MOD;
            }
        }
    }

    cout << dp[N][S][2] << endl;
}


Measured memory_bytes: 211328
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	double p[n];
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	double dp[n+1][n+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[0][i]=dp[0][i-1]*(1-p[i-1]);
		dp[i][0]=0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i>j)
			{
				dp[i][j]==0;
				continue;
			}
			dp[i][j]=p[j-1]*dp[i-1][j-1]+(1-p[j-1])*dp[i][j-1];
		}
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++)
	{
		ans+=dp[i][n];
	}
	cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 74072
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct s_t{
  ll s,t,x;
};

bool asc(s_t left,s_t right) {
  return left.x < right.x;
}

int main(){
  ll n,q;
  cin>>n>>q;
  vector<s_t>v;
  s_t z;
  for(ll i=0;i<n;i++){
    cin>>z.s>>z.t>>z.x;
    v.push_back(z);
    // vv[min(max(s-x,0),n)]++;
    // vv[min(max(t-x,0),n)]--;
  }
  sort(v.begin(),v.end(),asc);
  set<ll>st;
  vector<ll>vv(q,0);
  for(ll i=0;i<q;i++){
    cin>>vv[i];
    st.insert(vv[i]);
  }
  map<ll,ll>mp;
  for(ll i=0;i<n;i++){
    ll a=max(v[i].s-v[i].x,(ll)0);
    ll b=max(v[i].t-v[i].x,(ll)0);
    auto it1=st.lower_bound(a);
    auto it2=st.lower_bound(b);
    for(auto itr = it1; itr != it2;itr++) {
      mp[*itr]=v[i].x+1;
    }
    st.erase(it1,it2);
  }
  for(ll i=0;i<q;i++){
    ll ans=mp[vv[i]]-1;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 30948
#include <iostream>
#include <cstring>
using namespace std;
int d[101][4];
long gcd(long a,long b){
  long c;
  while(b){
    c=a;a=b;b=c%b;
  }
  return a;
}
long f(long m){
  long w,r,l;
  if(!m) w=1;
  else{
    r=f(d[m][2]);l=f(d[m][3]);
    w=r*l*d[m][0]*d[m][1]/(gcd(r*d[m][0],l*d[m][1]));
    w=w/d[m][0]+w/d[m][1];
  }
  return w;
}
int main(){
  int n,t;
  bool fl[101];
  while(cin>>n,n){
    memset(fl,0,sizeof(fl));
    for(int i=1;i<=n;++i){
      cin>>d[i][0]>>d[i][1]>>d[i][2]>>d[i][3];
      fl[d[i][2]]=fl[d[i][3]]=true;
    }
    for(int i=1;i<=n;++i){
      if(!fl[i]){
	t=i;break;
      }
    }
    cout<<f(t)<<endl;
  }
  return 0;
}

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

int main(){
	string s;
	while( cin >> s ){
		if( s[0] == '#' ) break;
		int w=0;
		for(int i = 0 ; s[i] != '/' &&  i < s.size() ; i++ ){
			if(s[i] == 'b') w++;
			else{
				w += s[i] - '0';
			}
		}
		
		int h=1;
		
		for( int i = 0 ; i < s.size() ; i++ ){
			if( s[i] == '/' ) h++;
		}

		//cout << h << " " << w << endl;
		
		vector<vector<bool>> f(h,vector<bool> (w)); 
		
		int i = 0 , j=0;
		for( int k = 0 ; k < s.size() ; k++ ){
			//cout << "k:" << k << " i:" << i << " j:" << j << " s:" << s[k] <<  endl;
			if(s[k] == 'b'){
				f[i][j]=1;
				j++;
			}
			else if( s[k] == '/' ){
				i++;
				j=0;
			}
			else{
				j += s[k]-'0';
			}
		}
	
		/*
		for(int i = 0 ; i < h ; i++ ){
			for(int j = 0 ; j < w ; j++ ){
				cout << f[i][j];
			}
			cout << endl;
		}
		*/
		

		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		f[a][b]=0; f[c][d]=1;
		
		
		/*
		for(int i = 0 ; i < h ; i++ ){
			for(int j = 0 ; j < w ; j++ ){
				cout << f[i][j];
			}
			cout << endl;
		}
		*/


		int cnt = 0;
		for(int i = 0 ; i < h ; i++ ){
			for(int j = 0; j < w ; j++ ){
				if( !f[i][j] ) cnt++;
				else{
					if( cnt ){
						cout << cnt;
						cnt = 0;
					}
					
					cout << "b";
				}
			}
			
			if( cnt ){
				cout << cnt;
				cnt = 0;
			}

			if( i < h-1 )
				cout << '/';
		}
		cout << endl;

	}
}


Measured memory_bytes: 3200
#include <iostream>
#define rep(i,a) for(i = 0; i < a; i++)

using namespace std;

int main(void) {

  int i, j, count = 0, N, save, mini;

  cin >> N;

  int A[N];

  rep(i,N) {
    cin >> A[i];
  }

  rep(i,N) {
    mini = i;
    for(j = i ; j < N; j++) {
      if (A[j] < A[mini]) {
	mini = j;
      }
    }
    swap(A[i],A[mini]);
    if(A[mini] != A[i]) {
      count++;
    }
  }

  rep(i,N) {
    cout << A[i];
    if(i == N-1) break;
    cout << " ";
  }

  cout << endl;
  cout << count << endl;

  return 0;

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int from,to,cost;};

signed main() {
int n,m;
cin>>n>>m;
edge es[m];

for(int i=0;i<m;i++){
    cin>>es[i].from>>es[i].to>>es[i].cost;
    (es[i].from)--;(es[i].to)--;
}
int d[n]={};for(int i=1;i<n;i++)d[i]=-1*MOD*MOD;
bool used[n]={};
used[n-1]=true;
bool update=true;
while(update){
    update=false;
    for(int i=0;i<m;i++)if(used[es[i].to]&&(!used[es[i].from])){
        used[es[i].from]=true;
        update=true;
    }
}
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if(used[es[j].to]&&d[es[j].to]<d[es[j].from]+es[j].cost){
            d[es[j].to]=d[es[j].from]+es[j].cost;
            if(i==n-1){
                cout<<"inf";
                return 0;
            }
        }
    }
}

cout<<d[n-1];



return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  vector<ll> X(N);
  for(auto& x : X) cin >> x;
  vector<ll> Y{X.begin(), X.end()};

  boost::sort(Y, std::greater<ll>());
  auto B0 = Y.at((N / 2) - 1);
  auto B1 = Y.at(N / 2);
  for(const auto& x : X){
    if(x >= B0){
      cout << B1 << CRLF;
    }
    else{
      cout << B0 << CRLF;
    }
  }

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int n;
  cin >> n;
  int x4 = 0;
  int x2 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      x4++;
    else if (a % 2 == 0)
      x2++;
  }
  int ok = x4 + (x2 / 2);
  if (n / 2 <= ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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


a1 = a/0.08
a2 = (a+1)/0.08
b1 = b/0.1
b2 = (b+1)/0.1
c = 0

for i in range(1001):
    if a1<= i <a2 and b1<= i <b2:
        print(i)
        c = 1
        break
        
if c==0:
    print('-1')

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

int x, y;

signed main()
{
    cin >> x >> y;

    if(x == y) {
        printf("0\n");
    }
    else if(x != y && abs(x) == abs(y)) {
        printf("1\n");
    }
    else if(x == 0 && y > 0) {
        printf("%lld\n", y);
    }
    else if(x == 0 && y < 0) {
        printf("%lld\n", abs(y) + 1);
    }
    else if(x > 0 && y == 0) {
        printf("%lld\n", x + 1);
    }
    else if(x < 0 && y == 0) {
        printf("%lld\n", abs(x));
    }
    else if(x > 0 && y > 0) {
        if(x > y) {
            // - にしてから減らして戻す
            printf("%lld\n", (x - y) + 2);
        } else {
            printf("%lld\n", y - x);
        }
    }
    else if(x < 0 && y < 0) {
        if(abs(x) > abs(y)) {
            printf("%lld\n", abs(x) - abs(y));
        } else {
            // + にして増やしてから戻す
            printf("%lld\n", abs(y) - abs(x) + 2);
        }
    }
    else if(x > 0 && y < 0) {
        if(x > abs(y)) {
            // - にしてから減らす
            printf("%lld\n", (x - abs(y)) + 1);
        } else {
            // 増やしてから - にする
            printf("%lld\n", (abs(y) - x) + 1);
        }
    }
    else if(x < 0 && y > 0) {
        if(abs(x) > y) {
            // 減らしてから + にする
            printf("%lld\n", (abs(x) - y) + 1);
        } else {
            // + にしてから増やす
            printf("%lld\n", (y - abs(x)) + 1);
        }
    }
    else {
        assert(false);
    }
    return 0;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll A, B, X; cin >> A >> B >> X;
	if (B < X - A || A >X)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(110);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> ans;
	for (int i = 0; i < n; i++) {
		int o = 1000000007;
		for (int j = 0; j < n; j++) {
			if (j == a[j] - 1) {
				o = j;
			}
		}
		if (o == 1000000007) {
			cout << "-1" << endl;
			return 0;
		}
		ans.emplace_back(o + 1);
		a.erase(a.begin()+o);
	}
	for (int i = ans.size()-1; i >= 0; i--) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll L, A, B, M;
ll cnt[19];
ll sum[19];
ll p10[19];

#define MAT_S 3

vector<vector<ll>> mul (vector<vector<ll>> x, vector<vector<ll>> y) {
    vector<vector<ll>> ret(MAT_S, vector<ll>(MAT_S, 0));
    rep(i,MAT_S) rep(j,MAT_S) rep(k,MAT_S) {
        ret[i][j] = (ret[i][j] + x[i][k]*y[k][j]) % M;
    }
    return ret;
}

ll mat_pow (ll x, ll y, ll st) {
    vector<vector<ll>> b(MAT_S, vector<ll>(MAT_S, 0));
    b[0][0] = p10[x]; b[0][1] = 1; b[0][2] = 0;
    b[1][0] = 0;      b[1][1] = 1; b[1][2] = B%M;
    b[2][0] = 0;      b[2][1] = 0; b[2][2] = 1;
    vector<vector<ll>> r(MAT_S, vector<ll>(MAT_S, 0));
    r[0][0] = 1; r[0][1] = 0; r[0][2] = 0;
    r[1][0] = 0; r[1][1] = 1; r[1][2] = 0;
    r[2][0] = 0; r[2][1] = 0; r[2][2] = 1;
    while (y) {
        if (y&1) r = mul(r, b);
        b = mul(b,b);
        y /= 2;
    }
    return (r[0][1] * st + r[0][2]) % M;
}

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret * x % M;
        x = x * x % M;
        y /= 2;
    }
    return ret;
}

int main() {
    cin >> L >> A >> B >> M;
    ll t = 1;
    p10[0] = 1;
    for (int i = 1; i < 19; i++) p10[i] = p10[i-1] * 10 % M;
    rep(i,18) {
        t *= 10;
        cnt[i+1] = (t-1>=A) + max(0LL,(t-1-A))/B - sum[i];
        sum[i+1] = sum[i] + cnt[i+1];
        if (sum[i+1] > L) {
            cnt[i+1] -= sum[i+1]-L;
            sum[i+1] = L;
        }
    }
    rep(i,19) { sum[i] %= M; }
    ll ans = 0;
    for (int i = 1; i <= 18; i++) {
        if (cnt[i] == 0) continue;
        ll tmp = 1;
        for (int j = i+1; j < 19; j++) rep(_,j) tmp = tmp * mod_pow(10,cnt[j]) % M;
        tmp = tmp * mat_pow(i, cnt[i], (A+(B%M)*sum[i-1])%M) % M;
        ans = (ans + tmp) % M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    let s: String = read();
    let t: String = read();

    println!(
        "{:?}",
        s.chars().zip(t.chars()).filter(|&(a, b)| a != b).count()
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    lli n;
    cin >> n;
    lli s;
    s = n*(n-1)/2;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
a = [int(i) for i in input().split()]

avg = sum(a) / N
mk, mv = 0, float('inf')
for i in range(N) :
    if abs(a[i]-avg) < mv :
        mk, mv = i, abs(a[i]-avg)
print(mk)

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

using namespace std;

typedef long long ll;

const int NMAX = 100005;

int n;
ll a[NMAX], b[NMAX], c[NMAX], da[NMAX], db[NMAX], dc[NMAX];

int main(){
    //freopen("VACATION.INP", "r", stdin);

    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    da[1] = a[1];
    db[1] = b[1];
    dc[1] = c[1];
    for (int i = 2; i <= n; i++){
        da[i] = max(db[i - 1], dc[i - 1]) + a[i];
        db[i] = max(da[i - 1], dc[i - 1]) + b[i];
        dc[i] = max(da[i - 1], db[i - 1]) + c[i];
    }

    cout << max(da[n], max(db[n], dc[n]));

    return 0;
}



Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

LL a, b, n;
int main() {
	cin >> a >> b >> n;
	LL x;
	if (n >= b) {
		x = b - 1;
	}
	else {
		x = n;
	}
	LL res = a * (x % b) - (a * x) % b;
	res = res / b;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int N = 2e5 + 5;
double dis(int x, int y) {
    return sqrt(pow(x,2)+pow(y,2));
}
int main() {
    int n;
    double x, y, k;
    int cnt = 0;
    scanf("%d%lf",&n,&k);
    for(int i = 1; i <= n; ++i) {
        scanf("%lf%lf",&x,&y);
        if(dis(x,y) <= k) ++cnt;
    }
    printf("%d\n",cnt);
return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    rep(x, 1000) {
        int keta = 1;
        int nx = x/10;
        vector<int> d(1, x%10);
        while (nx) {
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if (keta != n) continue;
        reverse(all(d));
        bool ok = true;
        rep(i, m) {
            if(d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    } 
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		BigInteger a,b,c;
		while(n--!=0){
			a=sc.nextBigInteger();
			b=sc.nextBigInteger();
			c=a.add(b);
			if(c.toString().length()>80){
				System.out.println("overflow");
			}
			else{
				System.out.println(c);
			}
		}
	}
}

Measured memory_bytes: 12000
N,K=map(int,input().strip().split())
A=list(map(int,input().strip().split()))

d={}

for n in range(N):
    if d.get(A[n])==None:
        d[A[n]]=1
    else:
        d[A[n]]+=1

dn=sorted(d.items(),key=lambda x:x[1])

if K>=len(d):
    print(0)
else:
    cnt=0
    ans=0
    for n in range(len(dn)):
        ans+=dn[n][1]
        cnt+=1
        if cnt==len(d)-K:
            break
    print(ans)
    

Measured memory_bytes: 42856
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    string S;
    vector<string> a;
    string tmp;
    cin >> S;
    stringstream ss(S);

    while(getline(ss, tmp, '/')){
        if (!tmp.empty()){
            a.push_back(tmp);
        }
    }
    char* e;
    if (4 < strtol(&(a[1][0]), &e, 10)){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }

    return 0;
}

Measured memory_bytes: 256