akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int

using namespace std;
vector<vector<lli>>adj;
vector<lli>vis;
vector<lli>c;

void dfs(lli v)
{
    vis[v]=1;
    c[v]=1;
    for(lli u:adj[v])
    {
        if(!vis[u])
        {
            dfs(u);
            c[v]+=c[u];
            
        }
    }
    
    
}
int main() {
    lli n;
    cin>>n;
    lli a[n+1];
    lli f[n+1]={0};
    for(lli i=0;i<n-1;i++)
    {
        cin>>a[i];
        f[a[i]]++;
    }
    
    for(lli i=1;i<=n;i++)
    {
        cout<<f[i]<<endl;
    }
}

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

int main() {
	ll n,q;
	string s;
	cin >> n;
	cin >> q;
	cin >> s;
	ll l[110000];
	ll r[110000];
	ll ans[110000] = { 0 };
	rep(i, 0, q) cin >> l[i] >> r[i];
    ll p[110000]={0};
    rep(i,0,n-1){
        if(s[i]=='A'&&s[i+1]=='C')p[i+1]=p[i]+1;
        else p[i+1]=p[i];
    }
    rep(i,0,q){
        ll ans =p[r[i]-1]-p[l[i]-1];
       
        cout<<ans<<endl;
    }
   
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	int card[3];
	while (cin >> card[0] >> card[1] >> card[2]) {
		int safe = 0;

		REP2(i, 1, 11) {
			if (i == card[0] || i == card[1] || i == card[2]) {
				continue;
			} else if(card[0] + card[1] + i <= 20) {
				safe++;
			}
		}

		if (safe >= 4) {
			cout << "YES" << "\n";
		} else {
			cout << "NO" << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 2928
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<pair<string, int>>v(N);
	rep(i, N)
	{
		string s;
		int t;
		cin >> s >> t;
		v[i] = make_pair(s, t);
	}
	string X;
	cin >> X;
	int num;
	rep(i, N)if (v[i].first == X)num = i;
	int sum = 0;
	for (int i = num + 1; i < N; i++)sum += v[i].second;
	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(void){
  int n,m;
  int sum=0;
  
  cin>>n>>m;
  int a[n]={0};
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  
  sort(a, a+(sizeof(a)/sizeof(a[0])),std::greater<>());
  
  if(a[m-1]*4*m>=sum){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }

  return 0;
  
}

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

int main() {
	int n,i; cin >> n >> i;
	cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
/**
       ������������    ������������
		Author : Avi J Patel
		University : DA-IICT
       ������������    ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define mod 1000000007
#define large 10000000000000001
int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> a(m+1);
	int k;
	for(int i=1;i<=m;i++)
	{
		cin>>k;
		a[i].pb(k);
		int a1;
		for(int j=0;j<k;j++)
		{
			cin>>a1;
			a[i].pb(a1);
		}
		//cout<<k<<endl;
	}
	vector<int> p;
	for(int i=0;i<m;i++)
	{
		int a1;
		cin>>a1;
		p.pb(a1);
	}
	int ans=0;
	int r=pow(2,n);
	vector<int> cnt(m);
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				for(int k=1;k<m+1;k++)
				{
					int cnt1=0;
					for(int l=1;l<a[k].size();l++)
					{
						if(a[k][l]==j+1)
						{
							cnt1++;
						}
					}
					cnt[k-1]+=cnt1;
				}
				
			
			}
		}
		int temp=0;
		for(int k=0;k<m;k++)
		{
			if(cnt[k]%2!=p[k])
			{
				temp=1;
				break;
			}
		}
		if(temp==0)
		{
			ans++;
			//cout<<i<<endl;
			/*for(int k=0;k<m;k++)
				{
					cout<<cnt[k]<<" ";
				}
					cout<<endl;*/
		}
		for(int k=0;k<m;k++)
		{
			cnt[k]=0;
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
while True:
    n, x = list(map(int, input().split()))
    if n == 0 and x == 0:
        break
    
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)



Measured memory_bytes: 5592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>>g(n);
    rep(i,m){
        int s, t;
        cin >> s >> t;
        s--;t--;
        g[s].push_back(t);
    }
    double res = 1000000;
    for(int k = 0; k < n; k++){
        if(k != n - 1 and g[k].size() <= 1)continue;
        vector<double> dp(n, 0);
        for(int i = n - 2; i >= 0; i--){
            if(i != k){
                for(int x : g[i]){
                    dp[i] += dp[x];
                }
                dp[i]/=g[i].size();
            }else{
                double ma = 0;
                for(int x : g[i]){
                    dp[i] += dp[x];
                    ma = max(ma, dp[x]);
                }
                dp[i] -= ma;
                dp[i] /= (g[i].size() - 1);
            }
            dp[i]+=1;
        }
        res = min(res, dp[0]);
    }
    printf("%.10lf\n", res);
}


Measured memory_bytes: 1408
def partition(arr)
  r = arr.size - 1
  x = arr.last
  i = -1
  0.upto(r - 1) do |j|
    if arr[j] <= x
      i += 1
      arr[i], arr[j] = arr[j], arr[i]
    end
  end

  arr[i+1], arr[r] = arr[r], arr[i+1]

  i + 1
end

n = gets.to_s
a = gets.split.map(&:to_i)
pos =  partition(a)
puts a[0...pos].join("\s") + "\s[#{a[pos]}]\s" + a[(pos+1)...a.size].join("\s")

Measured memory_bytes: 17680
#include<bits/stdc++.h>
#define hell (int)(1e9+7)
#define int long long int
#define inf 1000000000000

using namespace std;

void solve(){
    int n,p,ans;
    cin>>n>>p;
    string s;
    cin>>s;
    ans=0;
    if(p==2||p==5){
        for(int i=0;i<n;i++){
            if((s[i]-'0')%p==0)
                ans+=i+1;
        }
        cout<<ans;
        return;
    }
    vector <int> a(n);
    int m=1;
    for(int i=n-1;i>=0;i--,m=(m*10)%p)
        a[i]=((s[i]-'0')*m)%p;
    unordered_map <int,int> mp;
    mp[0]=1;
    int csum=0;
    for(int i=0;i<n;i++){
        csum=(csum+a[i])%p;
        if(mp.count(csum))
            ans+=mp[csum];
        mp[csum]++;
    }
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,c;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(int, char**)
{
	ll p, q, r, a, m;
	cin >> p >> q >> r;
	a = p + q + r;
	m = max(p, max(q, r));

	cout << (a - m) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n;
  int mx;
  multiset<pair<int,int> > a;
  multiset<pair<int,int> >::iterator it;
  while(cin>>n&&n){
    a.clear();
    for(i=0;i<n;i++){
      int t,u,v,w,x,y;
      scanf("%d:%d:%d%d:%d:%d",&t,&u,&v,&w,&x,&y);
      a.insert(make_pair(t*3600+u*60+v,1));
      a.insert(make_pair(w*3600+x*60+y,0));
    }
    mx=0;
    i=0;
    for(it=a.begin();it!=a.end();it++){
      if((*it).second){
	i++;
	mx=max(mx,i);
      }else
	i--;
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 1580
object Main{
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt // 最初の数字を読み取る
        val list = Array.fill(n)(sc.nextInt) // nextIntがn回呼ばれる
        
        var max = list(1) - list(0)
        var min = list(0)
        for(i <- 1 to n -1){
            if(max < (list(i)-min)){
                max = (list(i)-min)
            }
            if(min > list(i)){
                min = list(i)
            }
        }
        println(max)
    }
}


Measured memory_bytes: 205360
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  ll x,y; cin>>x>>y;
  int ans=0;
  while(x<=y){
    ans++;
    x*=2;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int W, H, N; cin >> W >> H >> N;
    int x1 = 0, y1 = 0, x2 = W, y2 = H;

    for(int i=0; i<N; ++i){
        int x, y, a; cin >> x >> y >> a;

        if(a == 1) x1 = max(x1, x);
        if(a == 2) x2 = min(x2, x);
        if(a == 3) y1 = max(y1, y);
        if(a == 4) y2 = min(y2, y);
    }

    if(x2 <= x1 || y2 <= y1) cout << 0 << endl;
    else cout << (x2 - x1)*(y2 - y1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
using namespace std;
int n;
ll memo[3005][3005];
int arr[3005];
ll solve(int i, int j){
    if(i == j)
        return arr[i];
    ll &ans = memo[i][j];
    if(ans != -1)
        return ans;
    return ans = max(arr[i]-solve(i+1, j), arr[j]-solve(i, j-1));
}
int main(){
    IO;
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
    memset(memo, -1, sizeof memo);
    cout << solve(0, n-1);

    return 0;
}


Measured memory_bytes: 71040
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (20 + 2)

int a[MAX_N][MAX_N];
ll dp[MAX_N][1 << MAX_N];

ll rec(int m, int S, int n){
  if (m < 0){
    return 1;
  }

  if (dp[m][S] != -1){
    return dp[m][S];
  }

  ll result = 0;

  for (int i = 0; i < n; i++){
    int w = S & (1 << i);
    if (w == 0 && a[m][i]){
      result = (result + rec(m-1, S | (1 << i), n)) % MOD;
    }
  }

  // printf("dp[%d][%d] = %lld\n", m, S, result);
  return dp[m][S] = result;
}

void exec(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < MAX_N; i++){
    for (int j = 0; j < (1 << MAX_N); j++){
      dp[i][j] = -1;
    }
  }

  cout << rec(n-1, 0, n) << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 721152
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void) {

    ll X,Y; cin>>X>>Y;
    int cnt=0;
    for (ll i = X; i <= Y; ++i) {
        i+=(i-1);
        cnt++;
    }

    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;

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

    vector<int> a(N), b(N);
        
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        b[i] = i + 1;
    }

    map<vector<int>, int> d, h;
    int ans = N - 1;

    // from goal
    {
        h[b] = 0;
        queue<vector<int> > q;
        q.push(b);
        
        while (!q.empty()) {
            vector<int> v = q.front();
            int cost = h[v];
            q.pop();

            if (v == a) {
                ans = cost;
                break;
            }
            if (cost >= 4)
                break;

            for (int i = 0; i < N; i++) 
                for (int j = i + 1; j < N; j++) {
                    vector<int> next = v;
                    reverse(next.begin() + i, next.begin() + j + 1);
                    if (!h.count(next)) {
                        h[next] = cost + 1;
                        q.push(next);
                    }
                }
        }
    }

    // from start
    {
        d[a] = 0;
        queue<vector<int> > q;
        q.push(a);
        
        while (!q.empty()) {
            vector<int> v = q.front();
            int cost = d[v];
            q.pop();

            if (h.count(v)) {
                ans = cost + h[v];
                break;
            }

            if (cost >= 4)
                break;

            for (int i = 0; i < N; i++) 
                for (int j = i + 1; j < N; j++) {
                    vector<int> next = v;
                    reverse(next.begin() + i, next.begin() + j + 1);
                    if (!d.count(next)) {
                        d[next] = cost + 1;
                        q.push(next);
                    }
                }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const ll mod = 1e9+7;

int n,k,ans;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>k;
  while(n!=0){
    n/=k;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

len_S = len(S)
for i in range(1, len_S):
    if i % 2 == 0:
        tmp_S = S[:len_S - i]
        n_half = len(tmp_S) // 2
        S_l = tmp_S[:n_half]
        S_r = tmp_S[n_half:]
        if S_l == S_r:
            break
print(len(tmp_S))

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << "\n";
    else cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, D, A = LI()
    X_H = []
    for _ in range(N):
        x, h = LI()
        X_H.append((x, h))
    X_H = sorted(X_H, key=lambda x:x[0])
    X = [elem[0] for elem in X_H]
    kaihuku = [0 for _ in range(N)]
    cur_damage = 0
    n_attack = 0
    cnt = 0
    for i in range(N):
        x, tairyoku = X_H[i]
        cur_damage = cur_damage - kaihuku[i]
        tairyoku -= cur_damage
        tairyoku = max(tairyoku, 0)
        n_attack = tairyoku // A + (tairyoku % A > 0)

        cur_damage += n_attack * A
        ins_pos = bisect.bisect_right(X, x + 2*D)
        if ins_pos < N:
            kaihuku[ins_pos] += n_attack * A
        cnt += n_attack

    print(cnt)

main()



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

int main(){
    int n;
    cin >> n;
    vector<int > v;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    double ans=(double)(v[0]+v[1])/(double)(2);
    for(int i=2;i<n;i++){
        ans = (double)(ans+v[i])/(double)(2);
    }
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
    unsigned long long a,b,c, t;
    bool flag = false;

    scanf("%lld %lld %lld", &a, &b, &c);

    if(a+b >= c){
        flag = false;
    }else{
        t = c - a - b;
        if(4*a*b < t*t) flag = true;
    }
    
    if(flag) {
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> X(N);
	rep(i,N) cin >> X[i];
	vector<ll> acc(N-K+1);
	ll mini = 1e18;
	rep(i,N-K+1) {
		if(X[i+K-1] >= 0 && X[i] >= 0) acc[i] = X[i+K-1];
		else if(X[i+K-1] <= 0 && X[i] <= 0) acc[i] = abs(X[i]);
		else acc[i] = min(X[i+K-1] + X[i+K-1] - X[i], abs(X[i]) + abs(X[i] - X[i+K-1]));
		chmin(mini, acc[i]);
	}
	cout << mini << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  string S, T;
  cin >> S >> T;
  vector<string> v;
  bool flg2 = false;

  rep(i, S.size() - T.size() + 1) {
    string tmp = S;
    bool flg = true;

    rep(j, T.size()) {
      if (S[i + j] == T[j]) continue;
      if (S[i + j] == '?') continue;

      flg = false;
      break;
    }

    if (!flg) continue;
    flg2 = true;

    rep(k, S.size()) {
      if (S[k] != '?')
        tmp[k] = S[k];
      else if (k < i || i + T.size() <= k)
        tmp[k] = 'a';
      else
        tmp[k] = T[k - i];
    }

    v.push_back(tmp);
  }
  SORT(v);
  if (!flg2)
    cout << "UNRESTORABLE" << endl;
  else
    cout << v[0] << endl;
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            long[] values = ReadLongs();
            Console.WriteLine(Math.Abs(values[1] - values[0]) >= 2 ? "Alice" : "Brown");
        }
    }
}


Measured memory_bytes: 13140
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = int64_t;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 int n;
 cin>>n;
 vector<int> a(3*n);
 rep(i,3*n){
   cin>>a.at(i);
 }
 sort(all(a));
 ll sum=0;
 for(int i=n;i<3*n;i+=2){
   sum+=(ll)(a.at(i));
   //cout<<i<<endl;
 }
 cout<<sum<<endl;
}




Measured memory_bytes: 4236
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 200005;

/*******************************************************************/




int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n; cin >> n;
	vector<int> a(n);
	int sum = 0;
	map<int, int> m; m.clear();
	for (int i = 0; i < n; i++) cin >> a[i], m[a[i]]++, sum += a[i];
	int q; cin >> q;
	while (q--) {
		int x, y; cin >> x >> y;
		sum -= (x * m[x]);
		sum += (y * m[x]);
		if (m.count(y)) m[y] += m[x];
		else m[y] = m[x];
		m.erase(x);
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

int a, b, k;

int main() {
	
	cin >> a >> b >> k;
	
	for (int i = 0; i < k; i++) {
		int n, m;
		if (i % 2 == 0) {
			n = a;
			m = b;
		} else {
			n = b;
			m = a;
		}
		n = n/2;
		m += n;
		
		if (i % 2 == 0) {
			a = n;
			b = m;
		} else {
			b = n;
			a = m;
		}
	}
	cout << a << " " << b;
	
	return 0;
}



Measured memory_bytes: 256
num = int(input())
if 400 <= num < 2000:
  if 400 <= num < 600:
    print(8)
  elif 600 <= num < 800:
    print(7)
  elif 800 <= num < 1000:
    print(6)
  elif 1000 <= num < 1200:
    print(5)
  elif 1200 <= num < 1400:
    print(4)
  elif 1400 <= num < 1600:
    print(3)
  elif 1600 <= num < 1800:
    print(2)
  elif 1800 <= num < 2000:
    print(1)

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

int main(){
  int  n,k;
  cin>> n>>k;
  int l[55];
  for (int i=0; i<=n;++i) cin >> l[i];
  sort(l,l+n,greater<int>());
  int ans = 0;
  for(int i =0;i<k;i++) ans += l[i];
  cout << ans<< endl;
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	int a, b, c, d, e[300]= {}, f[300] = {},ans = 0;
	cin >> a >> b >> c >> d;
	f[a]++;
	f[b]--;
	f[c]++;
	f[d]--;
	REP(i, 300) {
		e[i + 1] +=e[i] + f[i];
		if (e[i] == 2) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a[4];
  std::cin >> a;
  if((a[1]==a[2]&&a[0]==a[1])||(a[1]==a[2]&&a[2]==a[3])){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
}


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

using namespace std;

typedef long long int ll;

int main(){
    int N,K;
    cin >> N >> K;

    int ans=0;

    for(int i=0;i<N;i++){
        int h;
        cin >> h;
        if(h>=K){
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long int N,D,r,i,s=0;
	cin>>N>>D;
	long long int X[N],Y[N];
	for(i=0;i<N;i++){
		cin>>X[i]>>Y[i];
		r=X[i]*X[i]+Y[i]*Y[i];
		if(r<=D*D){
			s++;
		}
	}
	cout<<s<<endl;
}
	

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

using namespace std;
// Problem https://atcoder.jp/contests/agc013/tasks/agc013_a
int main(void){
    int N;
    int answer=0;
    cin >> N;
    vector<long long> Ai(N);
    for(int j=0;j<N;j++){
        cin >> Ai.at(j);
    }
    int updown=0;// up 1 down -1 reset 0
    for(int j=1;j<N;j++){
        if(updown == 1 ){ // case in "up"
            if(Ai.at(j-1) > Ai.at(j)){
                // change down 
                answer = answer + 1;
                updown = 0;
            }
        }
        else{
            if(updown == -1){ // case in "down"
                if(Ai.at(j-1) < Ai.at(j)){
                    // change up
                    answer = answer + 1;
                    updown = 0;
                }
            }
            else{ // case in "initial"
                if(Ai.at(j-1)<Ai.at(j)){
                    updown = 1;
                }
                else{
                     if(Ai.at(j-1)>Ai.at(j)){
                         updown = -1;
                         }
                    else{
                        updown = 0;
                    }

                }
            }
        }
    }                 
    cout << answer+1 << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");


signed main(){
    FASTER;
    int n;cin>>n;
    vi v(n);cin>>v;

    int ans=0;

    for(int i=0;i<n-1;i++){
        int a=0;
        while(i+1<n && v[i]>=v[i+1]){
            a++;
            i++;
        }
        ans=max(ans,a);
    }
    cout<<ans;
}


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

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

    if(s.size() <= k)
    {
        cout << s;
    }
    else
    {
        string subs = s.substr(0, k);
        cout << subs << "...";
    }    



    return 0;
}

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

//
// Created by karayuu on 2018-12-22.
//

int main() {
    while (true) {
        int x, y;
        cin >> x >> y;

        if (x > y) {
            swap(x, y);
        }

        if (x == 0 && y == 0) {
            break;
        } else {
            cout << x << " " << y << endl;
        }
    }
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <iostream>


int main(void)
{
	char str1[2];
	char str2[2];
	std::cin >> str1 >> str2;
	if (str1[0] > str2[0]) {
		std::cout << ">";
	}else if (str1[0] == str2[0]) {
		std::cout << "=";
	}else{
		std::cout << "<";
	}
	return 0;
}

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

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

	char& a = A[0];
	char& b = B[0];
	char& c = C[0];

	cout << char(a - 32) << char(b - 32) << char(c - 32) << endl;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
nl=list(range(1,n+1))
dl=[]
al=[]
for i in range(k):
  d=int(input())
  dl.append(d)
  a = list(input().split())
  a = [int(i) for i in a]
  al.append(a)
  
for i in range(k):
  if len(nl) == 0:
    print(0)
    exit()
  for ii in al[i]:
    if ii in nl:
      nl.remove(ii)
print(len(nl))
    

Measured memory_bytes: 9136
divisors = []
divisorsc = []

a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

for n in range(int(c)):
    if c%(n + 1) == 0:
        divisorsc.append(n+1)

#if a == b:
    #if a in divisorsc:
       # divisors.append(a)
        
for i in range(1 + b - a):
    if i + a in divisorsc:
        divisors.append(i+a)
        
print(len(divisors))

Measured memory_bytes: 7640
D,G=map(int,input().split())
G=G//100
p=[]
c=[]
for i in range(D):
    pp,cc=map(int,input().split())
    p.append(pp)
    c.append(cc//100)

ans=float("INF")
for i in range(1<<D):
    cnt=0
    toku=0
    for j in range(D):
        if 1&i>>j:
            toku+=p[j]*(j+1)+c[j]
            cnt+=p[j]
    #print(i,toku,cnt)
    if toku>=G:
        ans=min(ans,cnt)
        #sprint(i,toku,cnt)
    else:
        for j in range(D-1,-1,-1):
            if 1&i>>j==False:
                for k in range(p[j]-1):
                    toku+=j+1
                    cnt+=1
                    if toku>=G:
                        ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 42096
#include<stdio.h>
int main(){
  int mm,m,n,k,a,t,y,p,i,max;
  long double r; 
  scanf("%d",&k);
  while(k--){
    scanf("%d %d %d",&mm,&y,&n);
    max=0;
    while(n--){
      m=mm;
      scanf("%d %Lf %d",&a,&r,&t);
      if(a){
	for(i=0;i<y;i++){//printf("%d"
	  p=(int)(m*r);
	  m+=p-t;//printf("%d %d\n",m,p);
	}
      }
      else{
	p=0;
	for(i=0;i<y;i++){
	  p+=(int)(m*r);
	  m-=t;//printf("%d %d\n",m,p);
	}
	m+=p;
      }
      if(max<m)max=m;
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
 
int N, M , Q;
int ans = 0;

void dfs(vector<int> an, vector<vector<int>> &q) {
  if (an.size()==N+1) {
    int now = 0;
    rep(i,Q) {
      if (an[q[i][1]]-an[q[i][0]]==q[i][2]) {
        now += q[i][3];
      }
    }
    ans = max(ans, now);
    return;
  }

  for (int j=an.back(); j<=M; j++) {
    an.push_back(j);
    dfs(an,q);
    an.pop_back();
  }
}
int main() {

  cin >> N >> M >> Q;
  vector<vector<int>> q(Q,vector<int>(4));

  rep(i,Q) {
    rep(j,4) {
      cin >> q[i][j];
    }
  }
  vector<int> an;
  an.push_back(1);
  dfs(an,q);
  cout << ans << endl;
}

Measured memory_bytes: 3632
import numpy as np


N = int(input())
P = np.array(input().split(), dtype=np.int32)
P_sort = np.sort(P)
diff_P = P != P_sort
diff_num = np.count_nonzero(diff_P)

if diff_num == 0:
    print('YES')
elif diff_num == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 22172
#include <iostream>
using namespace std;
int main()
{
	long long n,maxv=-1,total=0;
	cin>>n;
	long long a[n];
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (a[i]>=maxv)
		{
			maxv=a[i];
			total++;
		}
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;
int X;

void solve() {
    vector<bool> dp(100001,false);
    REP(i,6) dp[100 + i] = true;
    FOR(i,106,100001) {
        dp[i] = dp[i-100] || dp[i-101] || dp[i-102] || dp[i-103] || dp[i-104] || dp[i-105];
    };
    cin >> X;

    auto ans = dp[X] ? "1" : "0";
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<bool> zorome(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        zorome[i] = (x == y);
    }
    string ans = "No";
    for (int i = 0; i + 2 < n; i++) {
        if (zorome[i] && zorome[i + 1] && zorome[i + 2]) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int i,j,k,l,tmp;
  int a[10];

  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }

  for(j=0;j<9;j++){
    for(k=j+1;k<10;k++){
      if(a[j]<a[k]){
	tmp=a[j];
	a[j]=a[k];
	a[k]=tmp;
      }
    }
  }

  for(l=0;l<3;l++){
    printf("%d\n",a[l]);
  }

  return 0;
}

Measured memory_bytes: 600
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		if(n%2==1) {
			System.out.println(n/2+1);
		}else {
			System.out.println(n/2);
		}
		
	}
	
}





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

int main()
{
    uint_fast16_t n;
    std::cin >> n;

    std::vector<uint_fast16_t> ds(n);
    for(auto i = 0; i < n; i++)
    {
        std::cin >> ds[i];
    }

    std::sort(ds.begin(), ds.end());
    uint_fast16_t min = 0;
    uint_fast16_t count = 0;
    for (auto i = 0; i < n; i++)
    {
        if(ds[i] > min)
        {
            min = ds[i];
            count++;
        }
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 256
s = input()
_s = int(s, 2)
n = len(s)

mask_1 = int(('01' * (n//2+1))[:n], 2)
mask_2 = int(('10' * (n//2+1))[:n], 2)

ans = min(bin(_s ^ mask_1).count('1'), bin(_s ^ mask_2).count('1'))

print(ans)

Measured memory_bytes: 3316
#include <climits>
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int n; cin >> n;
  int min_v = INT_MAX, max_v = INT_MIN;
  long long sum_v = 0;
  for (int i = 0; i < n; i++) {
    int v; cin >> v;
    min_v = min(min_v, v);
    max_v = max(max_v, v);
    sum_v += v;
  }
  cout << min_v << ' ' << max_v << ' ' << sum_v << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;
const int N=100100;
vector<int>g[N];
int main()
{
	int n,k=0;
	int cnt=1;
	scanf("%d",&n);
	if(n==1)return printf("Yes\n2\n1 1\n1 1"),0;
	for(int i=1;i<=n;i++)
	{
		if(i*(i-1)/2==n)
		{
			k=i;
			break;
		}
	}
	if(k==0)return printf("No\n"),0;
	printf("Yes\n%d\n",k);
	for(int i=1;i<=k;i++)
	{
		if(cnt>n)break;
		for(int j=i+1;j<=k;j++)
		{
			if(cnt>n)break;
			g[i].push_back(cnt);
			g[j].push_back(cnt);
			cnt++;
		}
	}
	for(int i=1;i<=k;i++)
	{
		printf("%d ",g[i].size());
		for(int j=0;j<g[i].size();j++)
			printf("%d ",g[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;cin >> n;
  string S="APPROVED";
  for (int i=0;i<n;i++) {
    long long a;cin >> a;
	if (a%2==0 && (a%3)*(a%5)>0) S="DENIED";
  }
  cout << S << endl;
}


Measured memory_bytes: 256
s = input()
ans = 0
for i in range(2 ** (len(s) - 1)):
    tmp = ''
    for j in range(len(s)):
        tmp += s[j]
        if i >> j & 1 == 1:
            tmp += '+'
    else:
        ans += eval(tmp)
else:
    print(ans)

Measured memory_bytes: 3060
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;



int main()
{
	//fast
	int a,b;
	char ch;
	cin>>a>>ch>>b;
  	if(ch=='+')
  		cout<<a+b;
  	else
  		cout<<a-b;

	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int M, D;
	cin >> M >> D;
	int ans = 0;

	for (int i = 1; i <= M; ++i) {
		for (int d = 1; d <= D; ++d) {
			if (d / 10 >= 2 && d % 10 >= 2) {
				int k = (d % 10) * (d / 10);
				if (k == i) {
					++ans;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

struct BinaryIndexedTree{
    private:
    int n;
    vector<int> dat;
    public:
    BinaryIndexedTree(int n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n,0);
    }
    void add(int a,int w){
        for (int i=a;i<=n;i+=i&-i) dat[i]+=w;
    }
    int sum(int a){
        int res=0;
        for (int i=a;i>0;i-=i&-i) res+=dat[i];
        return res;
    }
    int binarysearch(int w){
        if (w<=0) return 0;
        int x=0;
        for (int k=n;k>0;k/=2){
            if (x+k<=n&&dat[x+k]<w){
                w-=dat[x+k];
                x+=k;
            }
        }
        return x;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    vector<Pii> range(N);
    BinaryIndexedTree BIT(M+10);
    rep(i,N){
        int l,r;
        cin >> l >> r;
        ++l,r+=2;
        BIT.add(l,1);
        BIT.add(r,-1);
        range[i]=Pii(r-l,l);
    }
    sort(range.begin(),range.end());
    reverse(range.begin(),range.end());
    int now=0;
    vector<int> ans(M);
    for (int i=M;i>0;--i){
        while(now<N&&range[now].first>=i){
            int l=range[now].second;
            int r=range[now].first+l;
            BIT.add(l,-1);
            BIT.add(r,1);
            ++now;
        }
        int cnt=now;
        for (int j=1;j<=M+1;j+=i) cnt+=BIT.sum(j);
        ans[i-1]=cnt;
    }
    rep(i,M) cout << ans[i] << endl;
}

Measured memory_bytes: 4224
MOD = 1000000007

L = input().strip()
length = len(L)

dp1 = [-1] * length
dp2 = [-1] * length

# L[0] = 1
dp1[0] = 1  # a, b = 0, 0
dp2[0] = 2  # a, b = 1, 0 or 0, 1

for i in range(1, length) :
    dp1[i] = dp1[i - 1] * 3 % MOD  # いずれのa,bでもL以下のまま

    if L[i] == '1' :
        dp1[i] += dp2[i - 1] % MOD  # a, b = 0, 0 のとき確定
        dp2[i] = (dp2[i - 1] * 2) % MOD  # a, b = 1, 0 or 0, 1 のときまだ不明
    else :
        dp2[i] = dp2[i - 1]

print((dp1[-1] + dp2[-1]) % MOD)

Measured memory_bytes: 11076
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

vector <int> Vl;

int dp[100050];

int main() {
	Vl.push_back(1);
	for (int i = 6; i <= 100000; i *= 6) Vl.push_back(i);
	for (int i = 9; i <= 100000; i *= 9) Vl.push_back(i);

	dp[0] = 0;
	for (int i = 1; i <= 100000; i++) {
		dp[i] = INF;
		for (auto it : Vl) if (it <= i) dp[i] = min(dp[i], dp[i - it] + 1);
	}
	
	int N;
	scanf("%d", &N);
	return !printf("%d\n", dp[N]);
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<int> a(3); cin>>a[0]>>a[1]>>a[2];
	sort (a.begin(),a.end());
	cout<<a.back()-a.front()<< endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    keyence2020c()
}

fun keyence2020c() {
    val (n, k, s) = readLine()!!.split(' ').map { it.toInt() }

    val answer = ((1..k).map { s } + (k until n).map { 123456789 })
        .joinToString(" ")

    println(answer)
}


Measured memory_bytes: 47596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// int mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,c,h,i,j,k,temp,temp2,n,m;
    string a,b,tem;
    cin >> t;
    unordered_set <ll> u;
    for(i=0;i<t;i++){
        cin >> temp;
        u.insert(temp);
    }
    if(u.size()<t) cout << "NO";
    else cout << "YES";
    
}

Measured memory_bytes: 8520
from itertools import product

n = int(input())
S = input()

numCnt = {str(i):[] for i in range(10)}
ps = [''.join(list(s)) for s in product('0123456789',repeat=3)]
#print(ps)

for i,s in enumerate(S):
    numCnt[s].append(i)

ans = 0
for k in ps:
    if not numCnt[k[0]] or not numCnt[k[2]] or numCnt[k[0]][0] > numCnt[k[2]][-1]: 
        continue
    
    l,r = numCnt[k[0]][0], numCnt[k[2]][-1]

    for i in numCnt[k[1]]:
        if l < i < r:
            ans += 1
            break
        
print(ans)

Measured memory_bytes: 4468
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;

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

    pair<int, int> stu[n];
    pair<int, int> che[m];

    int a, b;
    pair<int, int> p;
    for(int i = 0; i < n; i++){
        cin >> stu[i].first >> stu[i].second;
    }
    for(int i = 0; i < m; i++){
        cin >> che[i].first >> che[i].second;
    }

    pair<int, int> dis[n];
    for(int i = 0; i < n; i++){
        dis[i].first = 0;
        dis[i].second = (int)(10e9);
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            a = abs(stu[i].first - che[j].first) + abs(stu[i].second - che[j].second);
            if(dis[i].second > a){
                dis[i].second = a;
                dis[i].first = j + 1;
            }
        }
    }

    for(int i = 0; i < n; i++){
        cout << dis[i].first << endl;
    }
}

Measured memory_bytes: 256