akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
    // G.at(v).push_back((edge) {u, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  Dijkstra<long> D(N * 3);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    u *= 3, v *= 3;
    D.add(u, v + 1, 1);
    D.add(u + 1, v + 2, 1);
    D.add(u + 2, v, 1);
  }
  int S, T;
  cin >> S >> T;
  S--, T--;
  S *= 3, T *= 3;
  D.solve(S);
  long ans = D.dist.at(T);
  cout << ((ans == LONG_MAX) ? -1 : ans / 3) << "\n";
}

Measured memory_bytes: 18944
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////


int main(){
	int n,a[100005] = {},ans = 0,t = 0;
    cin >> n;
    
    rep(i,0,n)cin >> a[i];

    rep(i,1,n){

        if(t > 0){
            if(a[i] - a[i-1] < 0){
                ans ++;
                t = 0;
            }
        }else if(t < 0){
            if(a[i] - a[i-1] > 0){
                ans ++;
                t = 0;
            }
        }else{
            if(a[i] - a[i-1] > 0)t = 1;
            else if(a[i] - a[i-1] < 0)t = -1;
            else t = 0;
        }
    }
    cout << ans +1<< endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char O[64], E[64];

    scanf("%s%s", O, E);

    int leno = strlen(O);
    int lene = strlen(E);

    if(leno == lene){
        for(int i = 0; i < leno; i++){
            printf("%c", O[i]);
            printf("%c", E[i]);
        }
        printf("\n");
    }else{
        for(int i = 0; i < lene; i++){
            printf("%c", O[i]);
            printf("%c", E[i]);
        }
        printf("%c\n", O[leno-1]);
    }

    return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair

bool check(string a,string b){
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	ll i;
	for(i=0;i<a.size();++i){
		if(a[i]!=b[i])
			break;
	}
	if(i==a.size())
		return true;
	else
		return false;
}
int arr[26];
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	string a,b;
	set<char> sa,sb;
	cin>>b>>a;
	bool is=true;
	for(ll i=0;i<a.size();++i){
		if(arr[b[i]-'a']==0)
			arr[b[i]-'a']=a[i];
		else{
			if(arr[b[i]-'a']!=a[i]){
				is=false;
                                break;
			}
		}
	}
    string temp=a;
    a=b;
    b=temp;
    for(int i=0;i<26;++i)
        arr[i]=0;
    for(ll i=0;i<a.size();++i){
		if(arr[b[i]-'a']==0)
			arr[b[i]-'a']=a[i];
		else{
			if(arr[b[i]-'a']!=a[i]){
				is=false;
                                break;
			}
		}
	}
	if(is)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


Measured memory_bytes: 1160
// Manhattan Compass
// * frank_c1
// * 2017 / 12 / 26

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

inline int iabs(int x) {
	return x >= 0 ? x : -x;
}

const int maxn = (int)(2e5) + 5;
int q[maxn], tq[maxn];

struct node {
	int x, y, id;
} p[maxn], c[maxn];

struct Xcmp {
	bool operator () (node a, node b) {
		return a.x != b.x ? a.x < b.x : (a.y != b.y ? a.y < b.y : a.id < b.id);
	}
};

struct Ycmp {
	bool operator () (node a, node b) {
		return a.y != b.y ? a.y < b.y : (a.x != b.x ? a.x < b.x : a.id < b.id);
	}
};

set<node, Xcmp> X;
set<node, Ycmp> Y;

int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int l = 1, r = 0;
	for (int i = 1; i <= n; ++i) {
		int x, y; scanf("%d%d", &x, &y); 
		p[i] = (node){x + y, x - y, i}; 
		if (i == a || i == b) q[++r] = i;
		else X.insert(p[i]), Y.insert(p[i]);
	}
	int C = max(iabs(p[a].x - p[b].x), iabs(p[a].y - p[b].y));
	for (; l <= r; ) {
		int i = q[l++];
		{
			set<node, Xcmp>::iterator it;
			it = X.lower_bound((node){p[i].x - C, p[i].y - C, 0});
			for (; it != X.end(); ++it) {
				if ((*it).x > p[i].x - C || (*it).y > p[i].y + C) break; tq[++tq[0]] = (*it).id;
			}
			it = X.lower_bound((node){p[i].x + C, p[i].y - C, 0});
			for (; it != X.end(); ++it) {
				if ((*it).x > p[i].x + C || (*it).y > p[i].y + C) break; tq[++tq[0]] = (*it).id;
			}
		}
		while (tq[0]) {
			int v = tq[tq[0]]; 
			q[++r] = v; X.erase(p[v]); Y.erase(p[v]); --tq[0];
		}
		{
			set<node, Ycmp>::iterator it;
			it = Y.lower_bound((node){p[i].x - C, p[i].y - C, 0});
			for (; it != Y.end(); ++it) {
				if ((*it).y > p[i].y - C || (*it).x > p[i].x + C) break; tq[++tq[0]] = (*it).id;
			}
			it = Y.lower_bound((node){p[i].x - C, p[i].y + C, 0});
			for (; it != Y.end(); ++it) {
				if ((*it).y > p[i].y + C || (*it).x > p[i].x + C) break; tq[++tq[0]] = (*it).id;
			}
		}
		while (tq[0]) {
			int v = tq[tq[0]]; 
			q[++r] = v; X.erase(p[v]); Y.erase(p[v]); --tq[0];
		}
	}
	LL ret = 0;
	for (int i = 1; i <= n; ++i) c[i] = p[i]; sort(c + 1, c + n + 1, Xcmp());
	for (int i = 1; i <= r; ++i) {
		int k = q[i];
		ret += lower_bound(c + 1, c + n + 1, (node){p[k].x - C, p[k].y + C, n + 1}, Xcmp()) - c;
		ret -= lower_bound(c + 1, c + n + 1, (node){p[k].x - C, p[k].y - C,     0}, Xcmp()) - c;
		ret += lower_bound(c + 1, c + n + 1, (node){p[k].x + C, p[k].y + C, n + 1}, Xcmp()) - c;
		ret -= lower_bound(c + 1, c + n + 1, (node){p[k].x + C, p[k].y - C,     0}, Xcmp()) - c;
	}
	for (int i = 1; i <= n; ++i) c[i] = p[i]; sort(c + 1, c + n + 1, Ycmp());
	for (int i = 1; i <= r; ++i) {
		int k = q[i];
		ret += lower_bound(c + 1, c + n + 1, (node){p[k].x + C, p[k].y - C,     0}, Ycmp()) - c;
		ret -= lower_bound(c + 1, c + n + 1, (node){p[k].x - C, p[k].y - C, n + 1}, Ycmp()) - c;
		ret += lower_bound(c + 1, c + n + 1, (node){p[k].x + C, p[k].y + C,     0}, Ycmp()) - c;
		ret -= lower_bound(c + 1, c + n + 1, (node){p[k].x - C, p[k].y + C, n + 1}, Ycmp()) - c;
	}
	return printf("%lld\n", ret / 2), 0;
}

Measured memory_bytes: 18048
from collections import*
n,*s=open(0).read().split()

d=defaultdict(int)
#print(s)
ans=0
for i in s:
    ans+=i.count("AB")
    if i[0]=="B" or i[-1]=="A":
        d[(i[0]=="B",i[-1]=="A")]+=1
#print(d,ans)
if len(d.values())==0:
    print(ans)
    exit()
else:
    if d[(True,True)]>0 and d[(True,False)]>0 and d[(False,True)]>0:  #ABggfgAB
        ans+=d[(True,True)]+1
        d[(True,True)]=0
        d[(True,False)]-=1 
        d[(False,True)]-=1
#        print(d,ans)
    if d[(True,True)]>0 and d[(True,False)]>0:
#        print(d)
        ans+=d[(True,True)]
        d[(True,True)]=0
        d[(True,False)]-=1
    if d[(True,True)]>0 and d[(False,True)]>0:
#        print(d)
        ans+=d[(True,True)]
        d[(True,True)]=0
        d[(False,True)]-=1
    if d[(True,True)]>1:
        ans+=d[(True,True)]-1
    if d[(False,True)]>0 and d[(True,False)]>0:
#        print(d)
        ans+=min(d[(False,True)],d[(True,False)])
print(ans)

Measured memory_bytes: 4084
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int countDivisors(int n) { 
  int cnt = 0; 
  for (int i = 1; i * i <= n; i++) { 
    if (n % i == 0) {
      if (n / i == i) 
        cnt++; 

      else 
        cnt = cnt + 2; 
    } 
  } 
  return cnt; 
} 

vector<int> div(int n) {
  vector<int> dd;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      dd.pb(i);
      if ((n / i) != i) dd.pb(n / i);
    }
  }
  sort(dd.begin(), dd.end());
  return dd;
}

int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n;
  cin >> n;
  vector<int> vc = div(n);
  int c = 0;
  for (int i = 1; i < (int)vc.size(); i++) {
    int N = n;
    while (N % vc[i] == 0) {
      N /= vc[i];
    }
    if (N == 1) c++;
    else {
      if ((N - 1) % vc[i] == 0 and (n - 1) % vc[i] != 0) c++;
    }
  }
  c += countDivisors(n - 1);
  cout << c - 1 << endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0
temp = set(s)
for i in temp:
  if s.count(i) - t.count(i) > ans:
    ans = s.count(i) - t.count(i)

print(ans)

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		vector<int> first, second;
		bool a[2*n] = { };
		REP(i, n){
			int x;
			cin >> x;
			a[x-1] = true;
		}
		REP(i, 2*n){
			if(a[i]) first.pb(i+1);
			else second.pb(i+1);
		}
		int f = 0, t = 0;
		while(first.size()!=0 && second.size()!=0){
			if(t == 0){
				REP(i, first.size()){
					if(first[i] > f){
						f = first[i];
						first.erase(first.begin()+i);
						break;
					}
					if(i == first.size()-1) f = 0;
				}
			}
			else{
				REP(i, second.size()){
					if(second[i] > f){
						f = second[i];
						second.erase(second.begin()+i);
						break;
					}
					if(i == second.size()-1) f = 0; 
				}
			}
			t = 1-t;
		}
		cout << second.size() << endl << first.size() << endl;
	}
	return 0;
} 


Measured memory_bytes: 3104
using System;
using System.Linq;

namespace ConsoleApp2
{
    using static System.Console;
    using static System.Math;

    class Program
    {
        static void Main(string[] args)
        {
            N = int.Parse(ReadLine());
            W = ReadLine().Split().Select(int.Parse).ToArray();
            WriteLine(Solve());
        }

        static int N;
        static int[] W;

        static string Solve()
        {
            var l = 0;
            var r = W.Length - 1;
            var ls = 0;
            var rs = 0;
            var conti = true;
            while (conti)
            {
                conti = l != r;
                if (ls < rs)
                    ls += W[l++];
                else
                    rs += W[r--];
            }
            return Abs(ls - rs).ToString();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
const int64 INF = 1LL << 58;
 
template< typename T >
struct SegmentTree
{
  const T INF;
 
  vector< T > seg;
  int sz;
 
  SegmentTree(int n) : INF(numeric_limits< T >::max() / 10)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, INF);
  }
 
  T merge(T a, T b)
  {
    return (min(a, b));
  }
 
  void set(int k, int x)
  {
    seg[k + sz - 1] = x;
  }
 
  void build()
  {
    for(int k = sz - 2; k >= 0; k--) {
      seg[k] = merge(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }
 
  T rmq(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (INF);
    if(a <= l && r <= b) return (seg[k]);
    return (merge(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
                  rmq(a, b, 2 * k + 2, (l + r) >> 1, r)));
  }
 
  T rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, sz));
  }
 
  void update(int k, T x)
  {
    k += sz - 1;
    seg[k] = x;
    while(k > 0) {
      k = (k - 1) >> 1;
      seg[k] = merge(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }
};
 
 
int main()
{
  int64 N, T, E, X[200002];
 
  cin >> N >> T >> E;
  for(int i = 1; i <= N; i++) cin >> X[i];
 
  /*
  int64 dp[2002][2002]; // curr, pending
  fill_n(*dp, 2002 * 2002, INF);
  dp[1][0] = 0;
  dp[1][1] = E;
*/
  auto chmin = [](int64 &a, int64 b)
  {
    a = min(a, b);
  };
 
  /*
  for(int i = 2; i <= N; i++) {
    for(int j = 0; j < i; j++) {
      chmin(dp[i][j], dp[i - 1][j]);
      chmin(dp[i][i], dp[i - 1][j] + max(E, (X[i] - X[j + 1]) * 2));
    }
  }
  // dp[j]+(X[i]-X[j+1])*2 = dp[j]+X[i]*2-X[j+1]*2
   // dp2[j]=dp[j]-X[j+1]*2
  */
 
 
  int64 dp[200002];
  fill_n(dp, 200002, INF);
  SegmentTree< int64 > dp2(N + 1);
 
  dp[0] = 0;
  dp[1] = E;
  dp2.update(0, dp[0] - X[1] * 2);
  dp2.update(1, dp[1] - X[2] * 2);
 
  for(int i = 2; i <= N; i++) {
    int low = 0, high = i - 1;
    while(high - low > 0) {
      int mid = (low + high) >> 1;
      if((X[i] - X[mid + 1]) * 2 <= E) high = mid;
      else low = mid + 1;
    }
/*
    cout << (X[i] - X[low + 1]) * 2 << " " << E << endl;
 
    for(int k = low; k < i; k++) cout << dp[k] << " ";
    cout << endl;
*/
    dp[i] = min(dp[low] + E, X[i] * 2 + dp2.rmq(0, low));
    //cout << low << endl;
    dp2.update(i, dp[i] - X[i + 1] * 2);
  }
  cout << dp[N] + T << endl;
}

Measured memory_bytes: 5376
S = input()
n = len(S)
ans = 0
x = 0
for i in range(n):
    if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i] == "G":
        x += 1
        if x > ans:
            ans = x
    else:
        x = 0
print(ans)

Measured memory_bytes: 3060
def mysum(n):
    ans = 0
    for i in range(1,n + 1): 
        ans += i  / n
    return ans

n,k = map(int,input().split())
p = list(map(int,input().split()))
a2=[0]
Max = 0
for i in p:a2.append(a2[-1]+i)
lists = []
for i in range(n-k+1):
    lists.append(a2[i+k] - a2[i])
jud = max(lists)
for i in range(len(lists)):
    if lists[i] == jud:
        tmp = i
ans = p[tmp:tmp+k]
cnt = 0
for i in ans:
    cnt += mysum(i)
print(cnt)

Measured memory_bytes: 77576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  cout << (A^B^C) << endl;
  return 0;
}


Measured memory_bytes: 256
S = list(input().replace("BC", "X"))
N = len(S)
pos, ans = 0, 0
ca = 0

while pos<N:
    ca = 0
    if S[pos]=="A" or S[pos]=="X":
        while pos<N and (S[pos]=="A" or S[pos]=="X"):
            if S[pos]=="A":
                ca += 1
            else:
                ans += ca
            pos += 1
    else:
        pos += 1

print(ans)

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n;
  cin >> n;
  ll ans=0, s=0, m = 1000000009;
  int cnt=0;
  vector<ll> a(n);
  bool z = false;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]==0){
      ans += s;
      m = 1000000009;
      s = 0;
      cnt = 0;
      z = true;
      continue; 
    }
    if(a[i]<0) cnt++;
    s += abs(a[i]);
    m = min(m, abs(a[i]));
    if(i==n-1){
      if(z) ans += s;
      else if(cnt%2) ans += s - 2*m;
      else ans += s;
    }
  }
  cout << ans << endl;
  return 0;
}


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

 int main() {
   int n;
   cin >> n;
   vector<long int> a(n);
   long int maxv = 0;
   long int minv = 10000000000;
   for (int i = 0; i < n; i++) {
     cin >> a[i];
     if (maxv < a[i]) maxv = a[i];
     if (minv > a[i]) minv = a[i];
   }
   cout << maxv-minv << '\n';
 }


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1&&b==0&&c==0){
		printf("Close\n");
	}
	else if(a==0&&b==1&&c==0){
		printf("Close\n");
	}
	else if(a==1&&b==1&&c==0){
		printf("Open\n");
	}
	else if(a==0&&b==0&&c==1){
		printf("Open\n");
	}
	else if(a==0&&b==0&&c==0){
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2584
#include<cstdio>
int abs(int x) {return x>0?x:-x;}
int main()
{
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	if(abs(a-c)<=d||abs(b-c)<=d&&abs(a-b)<=d) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);
		int K = Int32.Parse(Console.ReadLine());

		Console.WriteLine((Math.Pow(2,K) - 1) * Math.Max(A, Math.Max(B,C)) + A + B + C);
	}
}





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

int main(void) {
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
        }
        if (k == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next().replaceAll("\\?", "."); //?はエスケープ文字なので\\をつける。
														//後々の処理の関係で任意の１文字を表す.に変換
		String t = sc.next();
		int ns = s.length();
		int nt = t.length();
		//sの後ろ側nt文字を持ってくるようiを初期化、iを減らしていけば、後ろから順に一致を確かめられ、
		//初めて一致したものが辞書順で最小のものになる
		for (int i = ns - nt; i >= 0; i--) {
			String regex = s.substring(i, i + nt); //sのi~i+nt-1番目の文字列を抜き出す
			//?をワイルドカード.に置き換えているので、そこは一致しなくてもfalseにならない
			if (t.matches(regex)) {
				System.out.println(
						//s.substring(0,i)を付けるのはこの部分にregexと同じ文字列が入っていてもtに変えないようにするため
						s.replaceFirst(s.substring(0, i) + regex, s.substring(0, i) + t).replaceAll("\\.", "a"));//	sの0~i-1番目はそのまま、regexのところをtに置き換え、残りのエスケープ文字.をaに置き換え。
				return;
			}
		}
		System.out.println("UNRESTORABLE");
		sc.close();
	}

}


Measured memory_bytes: 23764
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		100000									// 最大配列数

// 内部変数
static int si1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数
static long long llMin;											// 最小回数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 最小回数の更新
int
fUpMin(
	int piSign					// <I> 符号 [1]＋ [-1]－
)
{
	int i;

	long long llCnt = 0;
	long long llSum = 0;

	for (i = 0; i < siACnt; i++) {

		// 符号の反転
		piSign *= -1;

		// 値の加算
		llSum += si1Array[i];

		// 符号のチェック
		if (llSum * (long long)piSign > 0) {	// OK
			continue;
		}

		// 回数加算
		llCnt += llabs(llSum) + (long long)1;

		// 合計値更新
		llSum = piSign;
	}

	// 最小回数更新
	if (llMin > llCnt) {
		llMin = llCnt;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化
	llMin = LLONG_MAX;											// 最小回数

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 配列数取得
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列取得
	for (i = 0; i < siACnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &si1Array[i]);
#else
		fscanf(stdin, "%d", &si1Array[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 最小回数の更新
	fUpMin(1);
	fUpMin(-1);

	// 結果セット
	sprintf(lc1Out, "%lld\n", llMin);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
long long const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            // res = res*a;
            res = (res*a)%m;
        }
        a=(a*a)%m;
        // a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 5e5+5;
int const inf = 2e9;

void solve(){  
    int i,j;   
    int x;
    cin >> x;
    int mx = 1800;
    int cur = 1;
    while(x < mx){
        cur++;
        mx -= 200;
    }
    cout<<cur<<endl;
}        



int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;  
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*


*/

Measured memory_bytes: 3648
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        String s = new Scanner(System.in).nextLine();
        char ch = s.charAt(0);
        switch (s.charAt(0)) {
            case 'a':
            case 'i':
            case 'u':
            case 'e':
            case 'o':
                System.out.println("vowel");
                break;
            default:
                System.out.println("consonant");
                break;
        }
    }
}


Measured memory_bytes: 23252
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    def nCr(n,r):
        mod = 10 ** 9 + 7
        a = b = 1
        for i in range(r):
            a = (a * (n - i)) % mod
            b = (b * (r - i)) % mod
        return (a * pow(b,mod-2,mod))%mod

    N = int(input())
    mod = 10 ** 9 + 7
    ans = pow(10,N,mod) - pow(9,N,mod) - pow(9,N,mod) + pow(8,N,mod)
    ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9176
#define DBG 0 //submission 0
#if DBG==1
    #include <algorithm>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;

int main(){
    long long ans = 0;
    long long W,H,x,y; 
    int N,i,j,k;

    cin >> W >> H >> x >> y;

    cout << (W*H/2.0) << " " <<  (((x == W/2)&&(y == H/2)&&(W%2 == 0)&&(H%2 == 0))?1:0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
map<int, vector<pii> > v;
map<int, vector<pii> >::iterator its;
int main(){
    int n, x, d;
    scanf("%d%d%d", &n, &x, &d);   
    if(d == 0){
        if(x == 0) printf("1\n");
        else printf("%d\n", n+1);
        return 0;
    }
    if(d < 0) x = -x, d = -d;
    LL sum = 0, add = 0;
    v[sum].push_back(pii(0, 0));
    for(int i=1;i<=n;i++){
        sum += x%d;
        sum = (sum + d)%d;

        add += x;

        LL a1 = 0, an = i-1;
        LL L = (a1+an)*(an-a1+1)/2 + add/d;

        a1 = n-i, an = n-1;
        LL R = (a1+an)*(an-a1+1)/2 + add/d;

        v[sum].push_back(pii(L, R));
    }
    LL ans = 0;
    for(its = v.begin();its != v.end();its++){
        vector<pii> vec = its->second;
        sort(vec.begin(), vec.end());
        LL L = -1e18, R = -1e18;
        for(int i=0;i<vec.size();i++){
            LL l = vec[i].first, r = vec[i].second;
            if(R < l){
                if(L != -1e18) ans += R-L+1;
                L = l, R = r;
            }
            else{
                R = max(R, r);
            }
        }
        ans += R-L+1;
    }
    printf("%lld\n", ans);
}

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

int main() {
  int A,B,n=0;
  cin >> A >> B;
  for (int i=A; i<=B; i++){
    int j=i,k=0;
    for (int p=0; p<5; p++){
      k+=(j%10)*pow(10,4-p);
      j/=10;
    }
    if (i==k){
      n++;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		// ?????????????????°?????\???
		int gameCount = in.nextInt();
		// ??????????????????????????°????????\???
		int[] cardNum = new int[9];
		// ????????????????????????????????\???
		String[] cardColor = new String[9];
		// ??????????????????????´????????????????
		ArrayList<Integer> resultList = new ArrayList<>();

		for(int setCount = 0; setCount < gameCount; setCount++) {

			for(int cardCount = 0; cardCount < 9; cardCount++) {

				cardNum[cardCount] = in.nextInt();

			}

			for(int cardCount = 0; cardCount < 9; cardCount++) {

				cardColor[cardCount] = in.next();

			}


			Rummy rummy = new Rummy(cardNum, cardColor);

			int[][] hadCard = rummy.hasCardSet(cardNum, cardColor);

			int point = 0;

			point += rummy.sameNumberCheck(hadCard);

			point += rummy.continuousNumberCheck(hadCard);

			if(point == 3) {

				resultList.add(1);

			} else {

				resultList.add(0);

			}
		}

		for(int result: resultList) {

			System.out.println(result);

		}

	}
}

class Rummy{

	// ?????£?????????
	int[] cardNum;
	String[] cardColor;

	// ?????????????????????
	Rummy(int[] cardNum, String[] cardColor){

		this.cardNum = cardNum;
		this.cardColor = cardColor;

	}

	// ???????????????????????????????????£??????????????´?????????????????????
	int[][] hasCardSet(int[] cardNum, String[] cardColor) {

		int[][] hasCard = new int[3][9];

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

			for(int j = 1; j <= 9; j++) {

				if(cardNum[i] == j) {

					switch(cardColor[i]) {

					case "R":

						hasCard[0][j-1] += 1;

						break;

					case "G":

						hasCard[1][j-1] += 1;

						break;

					case "B":

						hasCard[2][j-1] += 1;

						break;

					}
					
					break;
					
				}
			}
		}

		return hasCard;

	}

	int sameNumberCheck(int[][] hasCard) {

		int point = 0;

		hasCardSet(cardNum, cardColor);

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

			for(int j = 0; j < 9; j++) {

				if(hasCard[i][j] >= 3) {

					point++;
					hasCard[i][j] -= 3;

				}
			}
		}

		return point;

	}

	int continuousNumberCheck(int[][] hasCard) {

		int point = 0;
		int continuousCount = 0;

		hasCardSet(cardNum, cardColor);

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

			for(int j = 0; j < 9; j++) {

				if(hasCard[i][j] != 0) {

					continuousCount++;

					if(continuousCount == 3) {

						point++;
						hasCard[i][j] -= 1;
						hasCard[i][j-1] -= 1;
						hasCard[i][j-2] -= 1;
						j = 0;
						continuousCount = 0;

					}

				} else {

					continuousCount = 0;

				}
			}
		}

		return point;

	}
}

Measured memory_bytes: 30004
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int *a = new int[n];
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                flag = false;
                break;
            }
        }
    }

    if (flag) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	arr := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Sort(sort.IntSlice(arr))
	min := 99999999999
	for i := 0; i+K-1 < N; i++ {
		w := arr[i+K-1] - arr[i]
		if w < min {
			min = w
		}
	}
	fmt.Println(min)

}

Measured memory_bytes: 5504
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main()
{
	int n,max,min,ans;
	int a[100];

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
		if (i == 0)
		{
			max = a[i];
			min = a[i];
		}
		else
		{
			if (max < a[i])
			{
				max = a[i];
			}
			if (min > a[i])
			{
				min = a[i];
			}
		}
	}
	ans = abs(max - min);
	printf("%d\n", ans);

	return 0;
}

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

int main(void)
{
    int count=0;
    string S,T;
    cin >> S;
    cin >> T;

    for(int i=0;i<(int)S.size();i++)
    {
        if(S[i]!=T[i]) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int h, n;	cin >> h >> n;
	vector<int> a(n);	rep(i,n) cin >> a.at(i);
	int sum = accumulate(a.begin(),a.end(),0);
  	if(sum >= h) cout << "Yes" << endl;
  	else cout << "No" << endl;
}


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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int n;
    while (cin >> n) {
        ivec d(n);
        cin >> d;

        int ans = 0;
        forn(i, n) {
            forr(j, i + 1, n) {
                ans += d[i] * d[j];
            }
        }
        cout << ans << endl;
    }
}


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

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

    map<int, int> nums;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        nums[(-1) * num]++;
    }

    for(int i = 0; i < m; i++){
        int cnt, num;
        cin >> cnt >> num;
        nums[(-1) * num] += cnt;
    }

    long long sum = 0, cnts = 0;

    for(auto num : nums){
        long long cnt = num.second;
        if(cnts + cnt > n) cnt = n - cnts;
        sum += cnt * num.first * (-1);
        cnts += cnt;
    }
    cout << sum << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    ll a,n,b;
    cin>>n>>a>>b;
    if(n%(a+b)==0)
    {
        ll t=n/(a+b);
        printf("%lld\n",t*a);
    }
    else
    {
        ll t=n/(a+b);
        ll x=n-t*(a+b);
        printf("%lld\n",t*a+min(a,x));
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string x, y;

	cin >> x >> y;

	if (x == y) {
		cout << "=" << endl;
	}
	else if (x > y) {
		cout << ">" << endl;
	}
	else {
		cout << "<" << endl;

	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxx=10010;
int pre[maxx];

int find(int x){
	if(pre[x]!=x) x=find(pre[x]);
	return x;
}

int main (){
	for(int i=0;i<maxx;i++) pre[i]=i;
	int n,m;
	cin>>n>>m;
	int com,x,y;
	while(m--){
		cin>>com>>x>>y;
		if(com==0) pre[find(x)]=find(y);
		else if(find(x)==find(y)) puts("1");
		else puts("0");
	}
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define Maxn 30
#define NIL -1
using namespace std;
typedef struct{
	int parent, left, right;
}Node;
Node T[Maxn];
int D[Maxn], H[Maxn];
char name[5][20] = {"root", "internal node", "leaf"};
void init(int n){
	for(int i = 0; i < n; i++) T[i].left = T[i].right = T[i].parent = NIL;
	memset(H, -1, sizeof(H));
}
void setDepth(int u, int p){
	D[u] = p;
	if(T[u].left != NIL) setDepth(T[u].left, p + 1);
	if(T[u].right != NIL) setDepth(T[u].right, p + 1);
}
int setHight(int u){
	if(u == NIL) return -1;
	if(H[u] == NIL) H[u] = max(setHight(T[u].left), setHight(T[u].right)) + 1;
	return H[u];
}
void print(int u){
	int p, sib, deg = 2, t = 1;
	p = T[u].parent;
	if(p == NIL){
		sib = -1; t = 0;
	} 
	else sib = (u == T[p].left) ? T[p].right : T[p].left;
	if(T[u].left == NIL) deg--;
	if(T[u].right == NIL) deg--;
	if(deg == 0 && t) t = 2;
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", u, p, sib, deg, D[u], H[u], name[t]);
}
int main(){
	int n, id, l, r;
	scanf("%d", &n);
	init(n);
	for(int i = 0; i < n; i++){
		scanf("%d%d%d", &id, &l, &r);
		T[id].left = l; T[id].right = r;
		if(l != NIL) T[l].parent = id;
		if(r != NIL) T[r].parent = id;
	}
	
	int root = 0;
	while(T[root].parent != NIL) root++;
	setDepth(root, 0);
	setHight(root);
	for(int i = 0; i < n; i++) print(i);
	return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

bool dp[81][81][30000];

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

  int H, W, A[80][80], B[80][80];
  cin >> H >> W;
  REP(i, H) REP(j, W) cin >> A[i][j];
  REP(i, H) REP(j, W) cin >> B[i][j];

  int dh[2] = {1, 0}, dw[2] = {0, 1};
  dp[0][0][15000+A[0][0]-B[0][0]] = 1;
  dp[0][0][15000-A[0][0]+B[0][0]] = 1;
  REP(i, H) REP(j, W) REP(bias, 30000){
    if(i == H-1 and j == W-1) continue;
    if(!dp[i][j][bias]) continue;
    REP(dir, 2){
      int nxh = i + dh[dir], nxw = j + dw[dir];
      int nxb_Ared = bias + A[nxh][nxw] - B[nxh][nxw];
      int nxb_Ablu = bias - A[nxh][nxw] + B[nxh][nxw];
      if(0 > nxb_Ared or nxb_Ared >= 30000) continue;
      if(0 > nxb_Ablu or nxb_Ablu >= 30000) continue;
      dp[nxh][nxw][nxb_Ared] |= dp[i][j][bias];
      dp[nxh][nxw][nxb_Ablu] |= dp[i][j][bias];
    }
  }
  int ans = BIG;
  REP(i, 30000){
    if(dp[H-1][W-1][i]) chmin(ans, abs(i-15000));
  }
  cout << ans << endl;
}

Measured memory_bytes: 190464
import sys
input = lambda: sys.stdin.readline().rstrip()

n, k = map(int, input().split())
a = list(map(int, input().split()))
# A = 0, 0, 0, ..., 0でも最小値は2^(N-1)で増える
# k > 50くらいでnを超えるのでそれくらいまで考えればよい
def print_ans(ans):
   ans = list(map(lambda x: str(x) if x <= n else str(n), ans))
   print(" ".join(ans))

all_max = [n] * n
if k > 50:
   print_ans(all_max)
   exit()

# k < 50の時はimos法でO(N*k)くらいで求まりそう

for _ in range(k):
   pre_a = a[:]
   imos = [0 for _ in range(n+1)]
   for i in range(n):
      l = max(0, i - pre_a[i])
      r = min(n, i + pre_a[i] + 1)
      imos[l] += 1
      imos[r] -= 1
   # process
   v = 0
   for i in range(n):
      v += imos[i]
      if v > n:
         v = n
      a[i] = v
print_ans(a)

Measured memory_bytes: 173752
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }


int main() {

    int n;
    cin >> n;

    ll a[n];
    rep(i, n) {
        cin >> a[i];
        if (a[i]%2==1) {
            print(0);
            return 0;
        }
    }

    ll ans = 0;

    bool flag = true;
    while(flag) {
        ans++;
        rep(i, n) {
            a[i] /= 2;
            if(a[i]%2==1) {
                flag = false;
                break;
            }
        }
    }

    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int MOD = 998244353;
ll dp[3005][3005];
int vis[3005][3005];
ll a[3005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= s; j++) {
      dp[i][j] = (dp[i - 1][j] * 2) % MOD;
      if (j - a[i] >= 0)
        dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % MOD;
    }
  }
  // for (int i = 1; i <= n; i++) {
  //   for (int j = 0; j <= s; j++) {
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  cout << dp[n][s] << endl;
}

Measured memory_bytes: 74108
N = int(input())
count = [1]*(N+1)
ans = 1
mod = 10**9+7

for i in range(2,N+1):
    wari = i
    for w in range(2,i+1):
        while wari % w == 0:
            count[w] += 1
            wari /= w

for i in range(N+1):
    ans *= count[i]

print(ans % mod)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B;
    cin >> A >> B;
    i64 s = 0;
    REP(i, 2) {
        if (A >= B) {
            s += A;
            A--;
        } else {
            s += B;
            B--;
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=t[1].split(" ").map(function(e){return Number(e)}),o=0,u=1;u<r-1;u++){var i=[n[u-1],n[u],n[u+1]],f=Math.max(...i),l=Math.min(...i);n[u]!=f&&n[u]!=l&&(o+=1)}console.log(o)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 7372
w,a,b=map(int,input().split())
if a<b:
  if a+w>b:
    print(0)
  else:
    print(b-a-w)
elif b<a:
  if b+w>a:
    print(0)
  else:
    print(a-b-w)
else:
  print(0)

Measured memory_bytes: 9124
n = int(input())
height = list(map(int, input().split()))
cost = [0] * (n + 1)
for i in range(2, n + 1):
    if i > 2:
        cost[i] = min(cost[i-1] + abs(height[i-1] - height[i-2]),
                      cost[i-2] + abs(height[i-1] - height[i - 3]))
    else:
        cost[i] = cost[i - 1] + abs(height[i - 1] - height[i-2])
print(cost[n])


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int a,b,c;
  long long int zero = 0;
  cin>>a>>b>>c;
  cout<<max(c - (a - b),zero)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100000;
int n,m;
typedef vector<vector<int> > Graph;
Graph G;
int input(){
  int x;scanf("%d",&x);
  return x;
}
bool visited[N]={};
vector<int> P;

int main(){
  n=input();
  m=input();
  G=Graph(n);
  for(int i=0;i<m;++i){
    int a=input();
    int b=input();
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  P.push_back(0);  
  visited[0]=true;
  int len=1;
  while(true){
    int s = P[len-1];
    bool f=false;
    for(int v:G[s]){
      if(!visited[v]){
	f=true;
	visited[v]=true;
	P.push_back(v);
	++len;
	break;
      }
    }
    if(!f)
      break;
  }
  
  reverse(P.begin(),P.end());
  
  while(true){
    int s = P[len-1];
    bool f=false;
    for(int v:G[s]){
      if(!visited[v]){
	f=true;
	visited[v]=true;
	P.push_back(v);
	++len;
	break;
      }
    }
    if(!f)
      break;
  }

  printf("%d\n",(int)(P.size()));
  for(int v:P)
    printf("%d ",v+1);
  printf("\n");
  return 0;
}


Measured memory_bytes: 6904
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f;
int n;
ll a,b,c;
int main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int i;
	cin>>a>>b>>c;
	ll y=a/b;
	if(y*b!=a) y++;
	cout<<c*y<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2);
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

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

  prt(a*(a-1)/2 + b*(b-1)/2);



}


Measured memory_bytes: 256