akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
const int MOD = 1e9+7;
const ll INF =1e18;
ll dp[100010];

int main(){
    ll n,m;cin >> n >> m;
    vector<vp> x(n);
    fr(i,m){
        ll l,r,d;cin >>l >>r>>d;
        l--;
        r--;
        x[l].pb(mp(r,d));
        x[r].pb(mp(l,-d));
    }
    fr(i,n) dp[i] = INF;
    fr(i,n){
        if(dp[i]==INF){
            queue<int> que;
            que.push(i);
            dp[i]=0;
            while(!que.empty()){
                int v=que.front();que.pop();
                fr(j,x[v].size()){
                    P p=x[v][j];
                    int to=p.first,c=p.second;
                    if(dp[to]==INF){
                        dp[to] = dp[v] + c;
                        que.push(to);
                    }
                    else if(dp[to]!=dp[v]+ c){
                        cout << "No" << endl;
                        return 0;
                    }
                }
                }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 13824
#include<cstdio>

long long abs(long long u){ return u>0?u:-u; }

int main(){
	long long a,b,v,w,t;
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	long long dis = abs(a-b);
	long long diff = (v-w)*t;
	if(dis==0 || diff>=dis) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{

    string s, t;
    cin >> s >> t;
    sort(ALL(s));
    sort(ALL(t), greater<char>());
    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define swap(a, b, type) do {type t = a; a = b; b = t;} while(0)
struct node {
  int id;
  struct node *next;
};

struct node **list;
int **parent, *depth;

void Insert(int a, int b);
void dfs(int v, int p, int d);
void init(int logv, int vsize);
int lca(int u, int v, int logv);
int main(void)
{
  int i, j, n, k, c, q, n2 = 1, logn = 0;
  scanf("%d", &n);
  do {
    n2 *= 2;
    logn++;
  } while (n > n2);
  list = (struct node**)malloc(sizeof(struct node*) * n);
  parent = (int**)malloc(sizeof(int*) * logn);
  depth = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < logn; i++) parent[i] = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    list[i] = NULL;
    scanf("%d", &k);
    if (!k) continue;
    for (j = 0; j < k; j++) {
      scanf("%d", &c);
      Insert(i, c);
    }
  }
  init(logn, n);
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    printf("%d\n", lca(u, v, logn));
  }
  for (i = 0; i < n; i++) free(list[i]);
  for (i = 0; i < logn; i++) free(parent[i]);
  free(list);
  free(parent);
  free(depth);
}

void Insert(int a, int b)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->next = list[a];
  list[a] = p;
}

void dfs(int v, int p, int d)
{
  struct node *n;
  parent[0][v] = p;
  depth[v] = d;
  for (n = list[v]; n != NULL; n = n->next) {
    if (n->id != p) dfs(n->id, v, d + 1);
  }
}

void init(int logv, int vsize)
{
  int i, j;
  dfs(0, -1, 0);
  for (i = 0; i + 1 < logv; i++) {
    for (j = 0; j < vsize; j++) {
      if (parent[i][j] < 0) parent[i+1][j] = -1;
      else parent[i+1][j] = parent[i][parent[i][j]];
    }
  }
}

int lca(int u, int v, int logv)
{
  int i;
  if (depth[u] > depth[v]) swap(u, v, int);
  for (i = 0; i < logv; i++) {
    if ((depth[v] - depth[u]) >> i & 1) v = parent[i][v];
  }
  if (u == v) return u;
  for (i = logv - 1; i >= 0; i--) {
    if (parent[i][u] != parent[i][v]) {
      u = parent[i][u];
      v = parent[i][v];
    }
  }
  return parent[0][u];
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int n,dp[1009][10009];
pair <pair<int,int>,int> v[1009];
int f(int i,int c){
	if(i==n)return 0;
	if(dp[i][c]!=-1)
		return dp[i][c];
	dp[i][c]=f(i+1,c);
	if(v[i].f.f<=c)
		dp[i][c]=max(dp[i][c],v[i].s+f(i+1,min(c-v[i].f.f,v[i].f.s)));
	return dp[i][c];
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> v[i].f.f >> v[i].f.s >> v[i].s;
		v[i].f.f+=v[i].f.s;
	}
	sort(v,v+n);
	reverse(v,v+n);
	for(int i=0;i<n;i++)
		v[i].f.f-=v[i].f.s;
	memset(dp,-1,sizeof(dp));
	int m=0;
	for(int i=0;i<n;i++)
		m=max(v[i].s+f(i+1,v[i].f.s),m);
	cout << m << endl;
}


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

using namespace std;

int main() {
	int n, k;

	cin >> n >> k;

	vector <int> a(n);

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

	vector <long long int> pref(n+1, 0);

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

	for (int i = k+1; i <= n; i++) {
		long long int prev = pref[i-1] - pref[i-1-k];
		long long int curr = pref[i] - pref[i-k];
		
		// cout << prev << " " << curr << "\n";

		if (prev < curr) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}

	return 0;
}

Measured memory_bytes: 5632
/*
 * atcoder/abc134/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <set>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
vector<int> A;
void solve() {
  cin >> N;
  A.resize(N);
  multiset<int> S;

  loop(n,0,N) cin >> A[n];

  for (auto&&a: A) {
    auto iter = S.lower_bound(a);
    if (iter != S.begin()) S.erase(--iter);
    S.insert(a);
  }
  cout << S.size() << endl;

}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 5376
from bisect import bisect_right

def bisectsearch_right(L,a):
    i=bisect_right(L,a)
    return(i)

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

Asum=[0]*N
Bsum=[0]*M
Asum[0]=A[0]
Bsum[0]=B[0]
for i in range(1,N):
    Asum[i]=Asum[i-1]+A[i]
for j in range(1,M):
    Bsum[j]=Bsum[j-1]+B[j]
# print(Asum)
# print(Bsum)
ans=[0]*(N+1)
ans[0]=bisectsearch_right(Bsum,K)
# print(ans[0])
for i in range(1,N+1):
    if Asum[i-1]>K:
        continue
    j=bisectsearch_right(Bsum,K-Asum[i-1])
    # print(j)
    ans[i]=i+j
# print(ans)
print(max(ans))


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

void dfs(vector<int>* g,int n, int* vis,int* dp,int s)
{
    vis[s]=1;

    for(int i=0;i<g[s].size();i++)
    {
        if(vis[g[s][i]]==0)
        dfs(g,n,vis,dp,g[s][i]);
    }

    for(int i=0;i<g[s].size();i++)
    {
        dp[s]=max(dp[s],dp[g[s][i]]+1);
    }
    
}

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>g[n+1];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
    }
    int vis[n+1]={0};
    int dp[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
        dfs(g,n,vis,dp,i);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    ans=max(ans,dp[i]);
    cout<<ans;

}

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

int main() {
  int a,b,ab,a_n,b_n;
  cin >> a >> b >> ab >> a_n >> b_n;
  int sum;
  for (int i=0; a_n-i>=0 || b_n-i>=0 ; i++) {
    if (i==0) {
      sum = a_n*a+b_n*b;
    }
    else {
      sum = min(sum, max(a_n-i,0)*a+max(b_n-i,0)*b + i*ab*2);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{

ll n,m,a,i,b,c,r,k;
cin>>n>>m;
ll dp[n+1]={0};
dp[0]=1;
ll arr[n+1]={0};
for(i=0;i<m;i++)
{
    cin>>a;
    arr[a]=-1;
}
  for(i=1;i<=n;i++)
  {
      if(i==1 && arr[i]!=-1)
      {
        dp[i]=1;
      }
     else
     {
         if((arr[i-1]==-1 && arr[i-2]==-1))
                      break;
         else if(arr[i]==-1)
            continue;
          else
            dp[i]=(dp[i-1]+dp[i-2])%mod;

     }
  }
  cout<<dp[n]<<endl;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

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

}



Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    int count=0;
    for(int i=1;i<n-1;i++){
        vector<int> s{p.at(i-1),p.at(i),p.at(i+1)};
        //cout<<s.at(0)<<" "<<s.at(1)<<" "<<s.at(2)<<endl;
        vector<int> copy=s;
        sort(s.begin(),s.end());
        if(s.at(1)==copy.at(1))count++;
    }
    cout<<count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cout<<"# "<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=6005;
int l[N],r[N],id[N],n,cnt,ia,ib;
string f[N],g[N];
char s[N];

string calc(int l,int r){
	if(s[l]=='a'){
		string res;
		int flag=0;
		rep(i,l,r)
			if(s[i]=='a'){
				if(!flag)flag=id[i];
			}
			else if(s[i]=='b'&&flag&&flag==id[i]){
				res+="ab";
				flag=0;
			}
		return res;
	}
	string best,now;
	rep(i,l,r)
		if(s[i]=='b'){
			now="";
			rep(j,i,r)
				if(id[j]>=id[i])
					now+=s[j];
			best=max(best,now);
		}
	return best;
}

int main(){
	read(n);
	scanf("%s",s+1);
	int t=0,las=0;
	rep(i,1,n*2){
		if(s[i]=='a'){
			t++;
			id[i]=++ia;
		}
		else{
			t--;
			id[i]=++ib;
		}
		if(t==0){
			l[++cnt]=las+1;
			r[cnt]=i;
			las=i;
		}
	}
	rep(i,1,cnt){
		g[i]=calc(l[i],r[i]);
	}
	per(i,cnt,1){
		f[i]=max(f[i+1],g[i]+f[i+1]);
	}
	cout<<f[1]<<endl;
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N=200005;
int n,rt,a[N],o[N];
vector<int>e[N];
void dfs(int u,int fa){
	if(e[u].size()==1){o[u]=a[u];return;}
	int mx=0,sum=0;
	for(int i=0,v;i<e[u].size();++i)
		if((v=e[u][i])!=fa)
			dfs(v,u),sum+=o[v],mx=max(mx,o[v]);
	o[u]=2*a[u]-sum;
	if(o[u]<0||o[u]>a[u]||a[u]<mx)puts("NO"),exit(0);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	if(n==2)puts(a[1]==a[2]?"YES":"NO"),exit(0);
	for(int i=1,u,v;i<n;++i)
		scanf("%d%d",&u,&v),
		e[u].push_back(v),e[v].push_back(u);
	for(int i=1;i<=n;++i)
		if(e[i].size()>1)rt=i;
	dfs(rt,0),puts(o[rt]?"NO":"YES");
	return 0;
}

Measured memory_bytes: 16640
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 2e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,k,a[maxn],lg[maxn],fx[maxn][20],fn[maxn][20],ans,c,cnt;

inline int q(int l,int r,int opt)
{
	int x=lg[r-l+1];
	if(opt==0) return max(fx[l][x],fx[r-(1<<x)+1][x]);
	else return min(fn[l][x],fn[r-(1<<x)+1][x]);
}

int main()
{
	n=read(); k=read(); lg[0]=-1;
	for(int i=1;i<=n;i++) a[i]=read(),fx[i][0]=a[i],fn[i][0]=a[i]; a[n+1]=inf;
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i+1]) c++; else c=0;
		if(c==k-1) cnt++;
	}
	for(int i=1;i<=n;i++) lg[i]=lg[i>>1]+1;
	for(int i=1;i<=17;i++) for(int j=1;j+(1<<i)-1<=n;j++)
		fx[j][i]=max(fx[j][i-1],fx[j+(1<<i-1)][i-1]),fn[j][i]=min(fn[j][i-1],fn[j+(1<<i-1)][i-1]);
	for(int l=2;l+k-1<=n;l++)
	{
		int r=l+k-1,mx=q(l,r,0),mn=q(l,r,1);
		if(mn>=a[l-1]&&mx<=a[r]) ans++;
	}
	cout<<n-k+1-ans-max(0,cnt-1)<<endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  int A[N];
  vector<vector<int>> C; C.push_back(vector<int>(20, 0));
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    C.push_back(vector<int>(C[i]));
    for (int b = 0; b < 20; b++) {
      C[i+1][b] += ((A[i]>>b) & 1);
    }
  }
  long num = 0;
  for (int i = 0; i < N; i++) {
    auto end_it = C.begin();
    advance(end_it, i+1);
    auto it = lower_bound(C.begin(), end_it, C[i+1],
                          [](auto &c, auto &d) {
      for (int b = 0; b < 20; b++) {
        if (c[b] < d[b]-1) return true;
      }
      return false;
    });
    num += distance(it, end_it);
  }
  cout << num << endl;
}

Measured memory_bytes: 25900
n = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i

m = [a, b, c, d, e].min

f = n%m == 0 ? (n/m) : (n/m+1)

puts f + 4

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

//BEGIN CUT HERE
//重み付きUnion_find
//typename Tには重みの型を入力する
template <typename T>
class Potential_UF{
public:
    explicit Potential_UF(int n):size(n){
        Rank.resize(static_cast<unsigned long>(n), 0);
        parent.resize(static_cast<unsigned long>(n));
        weight.resize(n,unity);
        cont.resize(static_cast<unsigned long>(n), 1);
        for(int i=0;i<size;i++){parent[i]=i;}
    }

    //xの属しているグループの番号を返します
    int find(int x) {
        if (parent[x] == x)return x;
        else {
            int r = find(parent[x]);
            weight[x] += weight[parent[x]];
            return parent[x] = r;
        }
    }

    //xにつけられている重みを返します
    T get_weight(int x){
        find(x);
        return weight[x];
    }

    //xとyの重みの差を返します
    //weight(y)-weight(x)
    T diff(int x,int y){
        return get_weight(y)-get_weight(x);
    }

    //xとyが同じグループかどうかの判定をします
    bool same(int x,int y){
        return find(x)==find(y);
    }

    //xとyを同じグループにします
    //既に同じなら何もしません
    //weight(y)-weight(x)==wとなるように構成します
    void Unite(int x,int y,T w){
        w+=get_weight(x);
        w-=get_weight(y);
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(Rank[x]>Rank[y]){
            parent[y]=x;
            weight[y]=w;
            cont[x]+=cont[y];
            cont[y]=0;
        }else{
            parent[x]=y;
            if(Rank[x]==Rank[y])Rank[y]++;
            weight[x]=-w;
            cont[y]+=cont[x];
            cont[x]=0;
        }
    }

    //xが属するグループの要素数を返します
    int group_size(int x){
        return cont[find(x)];
    }

    //デバッグ用
    void visual(){
        for(int i=0;i<size;i++)find(i);
        for(int i=0;i<size;i++){
            cout<<"   par["<<i<<"]="<<parent[i]<<",";
        }
        cout<<endl;
        for(int i=0;i<size;i++){
            cout<<"weight["<<i<<"]="<<weight[i]<<",";
        }
        cout<<endl;
        for(int i=0;i<size;i++){
            cout<<"cont["<<i<<"]="<<cont[i]<<",";
        }
        cout<<endl;
    }
private:
    int size;
    const T unity=0;//型Tの単位元
    vector<int> parent;//親
    vector<int> Rank;
    vector<int> cont;//グループに属する要素の個数
    vector<T> weight;//ポテンシャル
};


int main(){
	int n,m;
	while(cin>>n>>m,n){
		Potential_UF<ll> uf(n);
		for(int i=0;i<m;i++){
			char a;cin>>a;
			if(a=='!'){
				int b,c;
				ll d;
				cin>>b>>c>>d;
				b--;c--;
				uf.Unite(b,c,d);
			}else{
				int b,c;cin>>b>>c;
				b--;c--;
				if(!uf.same(b,c)){
					cout<<"UNKNOWN"<<endl;
				}else{
					cout<<uf.diff(b,c)<<endl;
				}
			}
		}
	}
}


Measured memory_bytes: 4732
number = gets.split(' ')
count=0
k=number[0].to_i
s=number[1].to_i
for x in 0..k do
  for y in 0..k do
    z=s-x-y 
    if z<=k and z>=0 then
     count=count+1
     end
  end
end 
puts count

Measured memory_bytes: 14220
<?php

$in = trim(fgets(STDIN));
$words = preg_split("/[\s,\. ]+/", $in);

$cnt = count($words);
for ($i=0; $i < $cnt; $i++) {
    $num = strlen($words[$i]);
    if ($num < 3 or 6 < $num) {
        unset($words[$i]);
    }
}
array_values($words);
echo implode(" ", $words) . "\n";

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

vector<int> makeTable(vector<int> s) {
  int n = s.size();
  vector<int> ret(n+1);
  ret[0] = -1;
  int j = -1;
  rep(i,0,n) {
    while(j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i+1] = ++j;
  }
  return ret;
}

vector<int> kmp(vector<int> s, vector<int> w) {
  vector<int> table = makeTable(w), ret;
  int m = 0, i = 0, n = s.size();
  while(m+i < n) {
    if (w[i] == s[m+i]) {
      if (++i == (int)(w.size())) {
        ret.push_back(m);
        m = m+i-table[i];
        i = table[i];
      }
    } else {
      m = m+i-table[i];
      if (i > 0) i = table[i];
    }
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n), B(n);
  rep(i,0,n) cin >> A[i];
  rep(i,0,n) cin >> B[i];
  vector<int> a(2*n-1), b(n);
  rep(i,0,n) {
    a[i] = A[i] ^ A[(i+1)%n];
    if (i < n-1) {
      a[i+n] = a[i];
    }
    b[i] = B[i] ^ B[(i+1)%n];
  }
  vector<int> ans = kmp(a,b);
  rep(i,0,(int)ans.size()) {
    int x = B[0] ^ A[ans[i]];
    cout << ans[i] << " " << x << endl;
  }
  return 0;
}


Measured memory_bytes: 12012
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int m; cin >> m;
	cout << (24 - m) + 24 << endl;
	return;
}

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_N = 1000005;
// const ll MAX_N = 200;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  vector<ll> table(205); // table[n] .. n(n+1)(n+2)/6
  rep(i,205) {
    table[i] = i*(i+1)*(i+2)/6;
  }
  // dp[i] .. min count to represent i.
  vector<ll> dp(MAX_N, INF);
  dp[0] = 0;
  dp[1] = 1;
  rep(i,MAX_N) {
    rep(j,205) {
      if (table[j] > i) { break; }
      assert(i-table[j] >= 0);
      chmin(dp[i], dp[i-table[j]] + 1);
    }
  }
  // printvec(dp);

  // dp2[i] .. min count to represent i when using only odd.
  vector<ll> dp2(MAX_N, INF);
  dp2[0] = 0;
  rep(i,MAX_N) {
    rep(j,205) {
      if (table[j] > i) { break; }
      assert(i-table[j] >= 0);
      if (table[j]%2 == 0) { continue; } // even
      chmin(dp2[i], dp2[i-table[j]] + 1);
      // cout << "j:" << j << endl;
      // cout << "table[j]:" << table[j] << endl;
      // cout << "i:" << i << endl;
      // cout << "dp2[i]:" << dp2[i] << endl;
      // cout << "dp2[i-table[i]]:" << dp2[i-table[j]] << endl;
    }
  }

  while (true) {
    ll n;
    cin >> n;
    if (n == 0) { break; }
    cout << dp[n] << " " << dp2[n] << endl;
  }
}



Measured memory_bytes: 18248
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader stdReader =
        new BufferedReader(new InputStreamReader(System.in));
      String line;
      while ((line = stdReader.readLine()) != null) { 
    	  int x = Integer.parseInt(line);
        System.out.println(x*x*x);
      }
      stdReader.close();
    } catch (Exception e) {
      e.getStackTrace();
      /*?????´??????0??????*/
      System.exit(0); 
    }
  }
}

Measured memory_bytes: 24236
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
int main()
{
	veci v(3);
	rep(i, 3)
	{
		cin >> v[i];
	}
	sort(all(v));
	ll ans = 0;
	rep(i, 2)
	{
		ans += (v[i + 1] - v[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s;
  
  while (1) {
    cin >> s;
    if (s[0] == '0') break;
    
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
      sum += s[i] - '0';
    }
    cout << sum << endl;
  }
}



Measured memory_bytes: 3172
using System;
class c
{
    static void Main()
    {
        var a = int.Parse(Console.ReadLine());
        Console.ReadLine();
        Console.ReadLine();
        Console.ReadLine();
        var e = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());
        Console.WriteLine(e-a<=k?"Yay!":":(");
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define SENTINEL 2000000000
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n);
    rep(i, n) {
        if (a[i] == b[n - 1])
            cout << b[n - 2] << endl;
        else
            cout << b[n - 1] << endl;
    }
}

Measured memory_bytes: 3200
# A問題
S = input() 
if((not S in "AKIHABARA") and (not S in "AKIHBARA") and (not S in "AKIHBRA") and (not S in "AKIHABRA")):
	print("NO")
	exit(0)


string =  ""
count = 0

for i in S:
	if i != 'A':
		string += i


if string == "KIHBR":
	print("YES")

else:
	print("NO")


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

int main() 
{
  int k, x;
  cin >> k >> x;

  int start_point = x - k + 1;
  int end_point = x + k - 1;
  for (int i = start_point; i <= end_point; i++) {
    cout << i << ' ';
  }

  cout << endl;

}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  int K;
  cin >> S >> K;
  int N = (int)S.size();
  vector<vector<vector<int>>> dp(N + 1,
                                 vector<vector<int>>(2, vector<int>(K + 2, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    int c = S[i] - '0';
    for (int j = 0; j < 2; j++) {
      for (int nc = 0; nc < 10; nc++) {
        if (nc > c && j == 0) continue;
        for (int k = 0; k < K + 1; k++) {
          int nj = j;
          if (nc < c) nj = 1;
          int nk = k;
          if (nc != 0) nk++;
          dp[i + 1][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[N][0][K] + dp[N][1][K] << '\n';
  return 0;
}


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

rad = min(abs(6*m - 30*h - 0.5*m), 360-abs(6*m -30*h - 0.5*m))

cosc = math.cos(math.radians(rad))


ans = (a*a + b*b - 2*a*b*cosc) ** 0.5
print(ans)

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

int main()
{
	int w, a, b;
	scanf("%d%d%d", &w, &a, &b);
	if (a + w <= b) printf("%d\n", b - a - w);
	else if (a < b + w) printf("0\n");
	else printf("%d\n", a - b - w);

	return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, m;cin >> n >> m;
	char a[50][50],b[50][50];bool h = false;
	rep(i, n) rep(j,n) cin >> a[i][j];
	rep(j, m) rep(i,m) cin >> b[j][i];
	for (int i = 0; i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (i + m - 1 >= n || j + m - 1>= n) continue;
			bool ch = true;
			rep(k, m) {
				rep(l, m) {
					if (a[i + k][l + j] != b[k][l]) ch = false;
				}
			}
			if (ch) h = true;
		}
	}
	if (h) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
　　　　　　 「＾ヽ,ry'＾i 　))　
　　　((　 　 ゝ"´ ⌒｀ヽ. 　 　 /[] 　
　　　　　　 くi Lﾉﾉハﾉ)」 　　/　[]]　　　～ 少 女 祈 祷 中 ～
　　　　　 　 λ.[i ﾟ ヮﾟﾉi! 　 /　[] []
　　　　((　 ⊂ﾚ',ﾍ.i｀ﾑ'」つ/　[] [][]
　　　　　　　,メ-"ｲ-i/つ　　))
　　　　　　　 ﾞ'ｰl_7''"^ 

*/
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		int l = sc.nextInt();
		String a[]= new String[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.next();
		}
		Arrays.sort(a);
		for(String b : a) {
			System.out.print(b);
		}
	}
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


void solve(long long N, long long A, long long B){
  ll ans=0;
  ll a=A+B;
  ll b=N/a;
    ans=b*A;
    if(N-a*b>=A){
    ans+=A;
    }
    else{
      ans+=N-a*b;
    }
  cout<<ans<<endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
      cout << fixed << setprecision(6);
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

# L+i-1の絶対値ができるだけ小さなものを選べば良い？
# L+i-1==0 -> i = 1-L and i=1 to N

i = min(max(1, 1-L), N)
total = N*(L-1) + int(N*(N+1)/2)
result = total - (L+i-1)
print(result)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int32_t main(void) {
    int n;
    cin>>n;
    int pop=0,wyn=0;
    f0(i,n) {
        int a;
        cin>>a;
        if(pop==a) a=0,wyn++;
        pop=a;
    }
    cout<<wyn<<endl;
}


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

int main()
{
	int a[5];
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < 5; i++)
	{
		int x,y;
		x = i;
		y = a[i];
		for (int I = i+1; I < 5; I++)
		{
			if (a[I] > y)
			{
				y = a[I];
				x = I;
			}
		}
		int s=a[i];
		a[i] = a[x];
		a[x] = s;
	}
	for (int i = 0; i < 5; i++)
	{
		cout << a[i];
		if (i != 4)cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
struct poi{
	int a,b;
}a[101000];
inline bool cmp(poi a,poi b){
	return a.a<b.a;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].a);
		a[i].b=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		printf("%d ",a[i].b);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

ll x[200001];
int main(void){
  ll n;
  scanf("%lld",&n);
  ll a[n];
  FOR(i,n){
    scanf("%lld",&a[i]);
    x[a[i]]++;
  }
  ll ans=0;
  FOR(i,200001)ans+=x[i]*(x[i]-1)/2;
  FOR(i,n)PRL(ans-x[a[i]]+1);
  return 0;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//-1で初期化
  int root(int x) {
    if (d[x] < 0) return x;//rootを負になるようにする（構成node数x(-1))
    //xがrootならd[x]<0、その場合rootのnode番号を返す、root以外は親の番号
    return d[x] = root(d[x]);
    //return(root(d[x]))とするとメモできないが上の書き方だとメモができる
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    //swapすることで小さい方を大きい方につけられ計算量減らせる
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  vector <int> f(n,0);
  vector <vector<int>> bl(n);
  UnionFind uf(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    f[a]++;
    f[b]++;
    uf.unite(a,b);
  }
  rep(i,k){
    int c,d;

    cin>>c>>d;
    c--;d--;
    bl[c].emplace_back(d);
    bl[d].emplace_back(c);
  }
  rep(i,n){
    int ans=0;
    ans=uf.size(i)-1-f[i];
    rep(j,bl[i].size()){
      int temp=bl[i][j];
      if (uf.same(temp,i))ans--;
    }
    cout<<ans<<' ';

  }


}


Measured memory_bytes: 6784
#include <iostream>

using namespace std;

int N, L;
int a[100005];

int main(void)
{
	cin >> N >> L;
	for(int i = 1; i <= N; i++) cin >> a[i];
	
	int ans = -1;
	for(int i = 1; i <= N-1; i++){
		if(a[i] + a[i+1] >= L){
			ans = i;
			break;
		}
	}
	
	if(ans == -1){
		cout << "Impossible" << endl;
		return 0;
	}
	
	cout << "Possible" << endl;
	for(int i = 1; i < ans; i++) cout << i << endl;
	for(int i = N-1; i > ans; i--) cout << i << endl;
	cout << ans << endl;
	
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long W, std::vector<std::string> s) {
    vector<pair<ll, ll>> dir{pair<ll, ll>(-1, 0), pair<ll, ll>(1, 0), pair<ll, ll>(0, -1), pair<ll, ll>(0, 1)};
    rep(i, H) {
        rep(j, W) {
            if (s[i][j] == '#') {
                bool ok = false;
                rep(k, 4) {
                    ll tmpi = i + dir[k].first;
                    ll tmpj = j + dir[k].second;
                    if (!(tmpi < 0 || tmpi > H - 1 || tmpj < 0 || tmpj > W - 1)) {
                        if (s[tmpi][tmpj] == '#') {
                            ok = true;
                        }
                    }
                }
                if (!ok) {
                    cout << "No" << endl;
                    return;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return;
}

int main() {
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    std::vector<std::string> s(H);
    for (int i = 0; i < H; i++) {
        std::cin >> s[i];
    }
    solve(H, W, std::move(s));
    return 0;
}


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

int main() {
  unsigned long N;
  std::cin >> N;

  std::vector<long> x(N), y(N);
  std::vector<long> h(N);
  for (unsigned long i = 0; i < N; i++) {
    std::cin >> x.at(i) >> y.at(i) >> h.at(i);
  }

  long H = 0;
  for (long cx = 0; cx <= 100; cx++) {
    for (long cy = 0; cy <= 100; cy++) {

      for (unsigned long i = 0; i < N; i++) {
        if (h.at(i) >= 1) {
          H = h.at(i) + std::abs(x.at(i) - cx) + std::abs(y.at(i) - cy);
          break;
        }
      }

      bool r = true;
      for (unsigned long i = 0; i < N; i++) {
        if (h.at(i) == 0) {
          if (H > std::abs(x.at(i) - cx) + std::abs(y.at(i) - cy)) {
            r = false;
            break;
          }
          continue;
        }

        long H_ = h.at(i) + std::abs(x.at(i) - cx) + std::abs(y.at(i) - cy);
        if (H_ != H) {
          r = false;
          break;
        }
      }
      if (r) {
        std::cout << cx << ' ' << cy << ' ' << H << std::endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int n,s[N],res=1e9,a[N];char S[N];
int qz[N];
bool ck(int mid){
	memcpy(a,s,4*(n+2));a[n]+=mid*10;a[n-1]-=mid;
	per(i,n-1,1){
		if(a[i]<0){
			int t=(-a[i]-1)/10+1;a[i]+=t*10;a[i-1]-=t;
		}
		int mx=min(max((a[i+1]-a[i])/10,0),qz[i-1]-(s[i-1]-a[i-1]));
		if(mx>0)a[i]+=mx*10,a[i-1]-=mx;
	}
	rep(i,0,n)if(a[i]<0)return 0;
	rep(i,1,n-1)if(a[i]>a[i+1])return 0;
	return 1;
}
int main() {
	scanf("%s",S+1);n=strlen(S+1);
	rep(i,1,n)s[i]=S[i]-'0',qz[i]=min(qz[i-1]*10+s[i],100000000);
	int l=0,r=n+1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(ck(mid))r=mid-1,res=(s[n]+10*mid-1)/9+1;else l=mid+1;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
string s;
int main() {
    DAU
    cin >> s;
    if (s == "SUN")
        cout << 7;
    else if (s == "MON")
        cout << 6;
    else if (s == "TUE")
        cout << 5;
    else if (s == "WED")
        cout << 4;
    else if (s == "THU")
        cout << 3;
    else if (s == "FRI")
        cout << 2;
    else cout << 1;
    PLEC
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s;
  cin >> n >> s;
  rep(k, 4) {
    vl x(n + 1), y(n + 1);
    x[0] = k & 1;
    y[0] = k >> 1 & 1;
    rep(i, n) {
      x[i + 1] = y[i];
      y[i + 1] = x[i] ^ y[i];
      if(s[i] == 'x') y[i + 1] = !y[i + 1];
    }
    if(x[0] != x[n] || y[0] != y[n]) continue;
    rep(i, n) cout << (y[i] ? 'W' : 'S');
    cout << endl;
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 2116
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <numeric>// deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;



int main() {

	int D, N;
	cin >> D >> N;
	N += N / 100;
	rep(i, D) { N *= 100; }
	cout << N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
const int M = 1000000007;
long double A[3001];
int n, t;
vector<vector<long double>>dp(3001, vector<long double>(3001, 1.000000000));
int main()
{
	cin >> n;
	
	loop(i, 1, n + 1)
	{
		cin >> A[i];
		A[i] *= 1000000000;
		A[i] /= 1000000000;
	}
	t = n / 2;
	loop(i, 1, n+1)
	{
		dp[i][0] = dp[i - 1][0] * A[i];
		dp[i][i] = dp[i - 1][i - 1] * (1 - A[i]);
		loop(j, 1, i)
		{
			dp[i][j] = dp[i - 1][j] * A[i] + dp[i - 1][j - 1] * (1 - A[i]);
		}
	}
	loop(i, 0, t + 1)
	{
		A[0] += dp[n][i];
		//cout << dp[n][i] << " ";
	}
	//cout << endl;

	cout <<fixed << setprecision(12) << A[0];
}


Measured memory_bytes: 141184
fun main(args: Array<String>) {
    abc154a()
}

fun abc154a() {
    val (s, t) = readLine()!!.split(' ')
    val (a, b) = readLine()!!.split(' ').map { it.toInt() }
    val u = readLine()!!

    val answer = if (u == s) "${a - 1} $b" else "$a ${b - 1}"

    return println(answer)
}


Measured memory_bytes: 36392
#include <iostream>
#include <cstddef>
#include <vector>

using namespace std;

// Sieve of Eratosthenes
// eratosthenes : O(N loglog N)

template <typename OutputIt>
OutputIt eratosthenes(OutputIt it, std::size_t n) {
  for (std::size_t i = 0; i < n; ++i) it[i] = true;
  if (n > 0) it[0] = false;
  if (n > 1) it[1] = false;

  for (std::size_t i = 2; i * i < n; ++i) {
    if (!it[i]) continue;
    for (std::size_t j = i * i; j < n; j += i) it[j] = false;
  }

  return it + n;
}

int a, d, n;

int main() {
  vector<int> v(1000000);
  eratosthenes(v.begin(), 1000000);
  while (true) {
    cin >> a >> d >> n;
    if (a == 0 && d == 0 && n == 0) return 0;
    
    int cnt = 0;
    while (true) {
      cnt += v[a];
      if (cnt == n) break;
      a += d;
    }
    cout << a << endl;
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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 T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];

    b = a;
    sort(a.rbegin(), a.rend());
    sort(b.begin(),b.end());

    ll ans;

    if(n%2){
        ll tmp1 = 0ll, tmp2 = 0ll;
        for(int i = 0; i < (n-1)/2; ++i){
            tmp1 += 2*a[i];
            tmp2 -= 2*b[i];
        }
        tmp1 -= a[(n-1)/2]+a[(n-1)/2+1];
        tmp2 += b[(n-1)/2]+b[(n-1)/2+1];
        for(int i = (n-1)/2+2; i < n; ++i){
            tmp1 -= 2*a[i];
            tmp2 += 2*b[i];
        }
        ans = max(tmp1, tmp2);
    }
    else{
        ll tmp1 = 0ll, tmp2 = 0ll;
        for(int i = 0; i < (n-1)/2; ++i){
            tmp1 += 2*a[i];
            tmp2 -= 2*b[i];
        }
        tmp1 += a[(n-1)/2]-a[(n-1)/2+1];
        tmp2 += b[(n-1)/2]-b[(n-1)/2+1];
        for(int i = (n-1)/2+2; i < n; ++i){
            tmp1 -= 2*a[i];
            tmp2 += 2*b[i];
        }
        ans = max(tmp1, tmp2);
    }

    ppp(ans);


    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define N 100
 
int main(){
 
  int    i, j, n, min, minj, total=0;
  int A[N][N], flag[N], t[N];
 
  scanf("%d", &n);
 
  for(i = 0; i < n ; i++){
    flag[i] = 0;
    t[i] = 2001;
  }
  t[0] = 0;
 
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
    }
  }
 
  for(i = 0; i < n - 1; i++){
    min = 2001;
    for(j = 0; j < n; j++){
      if(t[j] < min && flag[j] == 0){
    min = t[j];
    minj = j;
      }
    }
    flag[minj] = 1;
 
    for(j = 0; j < n; j++){
      if(A[minj][j] != -1 && A[minj][j] < t[j] && flag[j]==0){
	t[j] = A[minj][j];
      }
    }
  }
 
  for(i = 0; i < n; i++){
    total += t[i];
  }
  printf("%d\n", total);
 
 
 
  return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var a, b, n int
	fmt.Scan(&a, &b, &n)

	i := min(b-1, n)
	fmt.Println(a*i/b - a*(i/b))
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main(){
  FIO;
  // ifstream cin("input");
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
  return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

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


signed main()
{
	fastio;
	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])

		cout<<"Bad";
	else
		{cout<<"Good";}
}

Measured memory_bytes: 256