akhauriyash/Code-Regression huggingface dataset:
import sys
n,m = map(int,input().split())
ma = [list(input().split()) for _ in range(m)]
if len(ma) == 0:
    print(0,0)
    sys.exit()
#print(ma)
#[['1', 'WA'], ['1', 'AC'], ['2', 'WA'], ['2', 'AC'], ['2', 'WA']]

li = [[False,0,0] for _ in range(n)]
#print(li) 
#[[False, 0, 0], [False, 0, 0]]

for m in ma:
    ind = int(m[0])-1
    st =  m[1]
    if st == 'WA' and li[ind][0] == False:
        li[ind][2] += 1
    elif st == 'AC' and li[ind][0] == False:
        li[ind][1] += 1
        li[ind][0] = True

ok_count = 0
ng_count = 0
for l in li:
    if l[0]:
        ok_count += l[1]
        ng_count += l[2]
print(ok_count,ng_count)

Measured memory_bytes: 36180
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    string s, t;
    cin >> s >> t;
    int k = s.size();
    s += s;
    int n = s.size();
    int m = t.size();
    int Next[n][26];
    rep(i, 26) Next[n-1][i] = n;
    rFor(i, n, 1)rep(j, 26){
        if(s[i] - 'a' == j) Next[i-1][j] = i;
        else Next[i-1][j] = Next[i][j];
    }
    lint ans = 0;
    int cur = k-1;
    rep(i, m){
        int ncur = Next[cur][t[i] - 'a'];
        if(ncur == n){
            printf("-1\n");
            return 0;
        }
        ans += (lint)ncur - (lint)cur;
        cur = ncur % k;
    }
    printf("%lld\n", ans);
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define A first
#define B second
#define MOD 1000000007

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res, x);
        y = y >> 1;
        x = mulmd(x, x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a - b;
    if(ret < 0){
        ret += MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int invPow(ll a){
    return power(a, MOD - 2, MOD);
}

const int N = 1e5 + 5;

int arr[N];

/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll ans = n * (n - 1)/2;
    cout << ans;

}


Measured memory_bytes: 256
//Joy Shree Kriskna
    #include<bits/stdc++.h>
    #define fast  ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=n-1;i>=0;i--)
    #define rep2(j,t) for(j=1;j<=t;j++)
    #define rep3(i,a,b) for(i=a;i<=b;i++)
    #define remove(s) s.erase(unique(s.begin(),s.end()),s.end());
    //#define e return 0
    #define endl "\n"
    #define al(v) v.begin(),v.end()
    #define ll long long
    using namespace std;
    int main()
      {
           fast;
           int i,n,f=0;
           string s,t;
           cin>>n>>s;
           if(n%2)
           {
               cout<<"No\n";
               return 0;
           }
           rep(i,n/2)
           {
               if(s[i]!=s[n/2+i])
               {
                   f=1;
                   break;
               }
           }
           if(f==0)cout<<"Yes\n";
           else cout<<"No\n";

          return 0;
      }
//arupsaha52
//Template
// if(s2.find(s1[i])!=-1)/*find function*/
//s=to_strings(n);/*digit to string conversion*/
/*set<int>s;
set<int>::iterator it;
s.insert(x);s.clear() for(it = s.begin(); it != s.end(); it++) {
        cout << *it << endl;}*/
//vector<vector<int> >v;/*2d vector*/
//vector<string>s
//stack<int>st;st.push(v);st.pop();st.top();
//queue<int>q;q.push(v);q.pop();q.front();q.back();
//priority_queue<int>q;q.push(v);q.pop();q.top();
//pair<int,int>p;


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

int n;

int main(){
    cin >> n;
    bool t = false;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i * j == n) t = true; 
        }
    }

    cout << (t ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=1e5+100;
int n,m,head[maxn],nex[maxn],v[maxn],du[maxn],num=1,f[maxn];
queue<int>q;
void add(int x,int y){
	v[++num]=y;
	nex[num]=head[x];
	head[x]=num;
	du[y]++;
}
int main(){
//	freopen(".in","r",stdin);
	n=read(),m=read();
	int x,y;
	for(int i=1;i<=m;i++)
		x=read(),y=read(),add(x,y);
	for(int i=1;i<=n;i++)
		if(!du[i]) q.push(i);
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=head[x];i;i=nex[i]){
			int y=v[i];du[y]--;
			f[y]=max(f[y],f[x]+1);
			if(!du[y]) q.push(y);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}








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

int h = 100, w = 100;
char s[101][101];

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    char c1 = '#', c2 = '.';
    if (a < b) swap(a, b), swap(c1, c2);
    for (int i = 1; i <= 100; i++) {
        for (int j = 1; j <= 100; j++) {
            s[i][j] = c1;
        }
    }
    int cnt = 1;
    for (int i = 1; i <= 100; i += 4) {
        for (int j = 1; j <= 100; j += 4) {
            if (cnt == b) {
                goto Break;
            }
            cnt++;
            s[i][j] = s[i][j + 1] = s[i][j + 2] = c2;
            s[i + 1][j] = s[i + 1][j + 2] = c2;
            s[i + 2][j] = s[i + 2][j + 1] = s[i + 2][j + 2] = c2;
        }
    }
Break:
    b--;
    if (a > b) {
        for (int i = 100; i >= 1; i -= 2) {
            for (int j = 1; j <= 100; j += 4) {
                s[i][j] = c2;
                a--;
                if (a == b) {
                    goto Break2;
                }
            }
        }
    Break2:;
    }
    cout << 100 << " " << 100 << endl;
    for (int i = 1; i <= 100; i++) {
        for (int j = 1; j <= 100; j++) {
            printf("%c", s[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる

ll solve(ll n,ll x){
  if(n==0) return 1;
  if(x==1) return 0;
  if(1<x && x<pow(2,n+1)-1) return solve(n-1,x-1);
  if(x==pow(2,n+1)-1) return pow(2,n);
  if(pow(2,n+1)-1<x && x<pow(2,n+2)-3) return pow(2,n)+solve(n-1,x-pow(2,n+1)+1);
  if(x==pow(2,n+2)-3) return pow(2,n+1)-1;
}


int main() {
  ll n,k;
  cin >> n >> k;

cout << solve(n,k) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
using vec = vector<vector<int>>;


int main(){
int a,b;
  cin>>a>>b;
  if(500*a>=b) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100,mod=1e9+7;
int n,h[N+1];
int f[N+1][N+1];
int pow(int x,int times)
{
	int ret=1;
	while(times) {
		if(times&1) {
			ret=1ll*ret*x%mod;
		}
		times>>=1,x=1ll*x*x%mod;
	}
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",&h[i]);
	}
	h[0]=1,f[0][0]=1;
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=n;++j) {
			if(h[j]>h[i]) {
				continue;
			}
			if(h[j]<h[i-1]) {
				if(h[i]<h[i-1]) {
					f[i][j]=(f[i-1][j]+f[i-1][i])%mod;
				} else {
					f[i][j]=1ll*(f[i-1][j]+f[i-1][i-1])*pow(2,h[i]-h[i-1])%mod;
				}
			} else {
				f[i][j]=2ll*f[i-1][i-1]*pow(2,h[i]-h[j])%mod;
			}
		}
	}
	printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 1732
n,d,a=gets.split.map(&:to_i)
xh=[]
n.times do
  x,h=gets.split.map(&:to_i)
  h=(h-1)/a+1
  xh << [x,h]
end
xh.sort!
c=0
m=0
j=0
n.times do |i|
  while xh[j][0]<xh[i][0]-2*d
    m-=xh[j][1]
    j+=1
  end
  if xh[i][1]<=m
    xh[i][1]=0
  else
    xh[i][1]-=m
    c+=xh[i][1]
    m+=xh[i][1]
  end
end
puts c


Measured memory_bytes: 18552
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    for (int i=0;i<H;++i) cin >> S[i];
    vector<vector<int>> cnt(H,vector<int>(W,INF));
    queue<pair<int,int>> que;
    cnt[0][0]=(S[0][0]=='#');
    que.emplace(0,0);
    while(!que.empty()){
        auto p=que.front(); que.pop();
        int x=p.first,y=p.second;
        for (int i=0;i<2;++i){
            int nx=x+i,ny=y+(i+1)%2;
            if (H<=nx||W<=ny) continue;
            int nxt=cnt[x][y]+(S[nx][ny]=='#'&&S[x][y]=='.');
            if (cnt[nx][ny]<=nxt) continue;
            cnt[nx][ny]=nxt;
            que.emplace(nx,ny);
        }
    }
    cout << cnt[H-1][W-1] << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>> n;
  vl a(n);
  int cnt = 0;
  ll mi = 100100100100,sum = 0;
  rep(i,n){
    cin >> a[i];
    if(a[i] < 0)cnt++;
    mins(mi,abs(a[i]));
    sum+=abs(a[i]);
  }
  if(cnt%2)sum-=2*abs(mi);
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

N=int(input())
H=list(map(int,input().split()))

count=0
ans=0

for i in range(1,N):
    if H[i]>H[i-1]:
        ans=max(ans,count)
        count=0
    else:
        count+=1
ans=max(ans,count)

print(ans)
    


Measured memory_bytes: 63984
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    switch (N % 10) {
        case 3:
            cout << "bon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        default:
            cout << "hon" << endl; 
    }
    
    return 0;
}

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

int main() {
  int x;cin>>x;
  string ans = x<1200?"ABC":"ARC";
  // cout << (ans?"H":"D") << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

struct UnionFind {
    //親の番号を格納する．
    //該当番号が親の場合は -(その集合のサイズ）
    vector<int> parent;
    UnionFind(int size) {
        parent = vector<int>(size, -1);
    }
    int root(int a) {
        if (parent[a] < 0) {
            return a;
        } else {
            return parent[a] = root(parent[a]);
        }
    }
    int size(int a) {
        return -parent[root(a)];
    }
    bool merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) {
            return false;
        } else {
            if (size(a) < size(b)) {
                swap(a, b);
            }
            parent[a] += parent[b];
            parent[b] = a;
            return true;
        }
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    ll ans[m];
    ans[m - 1] = 1LL * n * (n - 1) / 2;
    UnionFind UF(n);
    for (int i = m - 1; i > 0; i--) {
        if (UF.root(a[i]) == UF.root(b[i])) {
            ans[i - 1] = ans[i];
            continue;
        }
        ans[i - 1] = ans[i] - UF.size(a[i]) * UF.size(b[i]) * 1LL;
        UF.merge(a[i], b[i]);
    }
    for (int i = 0; i < m; i++) {
        OUT(ans[i]);
    }
}


Measured memory_bytes: 3328
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, k, i;
	char s[100001];
	scanf("%d%d%s", &n, &k, s);
	int a=0, b=0;
	for(i=n-2; i>=0; i--){
		if(s[i]==s[i+1]) a++;
		if(s[i]=='R'&&s[i+1]=='L') b++;
	}
	if(s[0]=='L') b++;
	if(s[n-1]=='R') b++;
	int ans=b<=k?n-1:a+k*2;
	printf("%d\n", ans<n?ans:n-1);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<queue>

using namespace std;

int map[51][51];
int bridge=0;


void search2(int n){
  int i,j,u,s=0;
  int d[100];
  queue<int> q;

  q.push(0);
  for(i=0;i<n;i++)
    d[i]=0;

  while(!q.empty()){
    u=q.front(); q.pop();
    if(d[u]!=0) continue;
    for(i=0;i<n;i++){
      if(map[u][i]==1){
        d[u]=1;
        q.push(i);
      }
    }
  }

  for(i=0;i<n;i++)
    if(d[i]==1)s++;
  if(s!=n)
    bridge++;
  
}





void search(int n){
  int i,j;

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(map[i][j]==1){
        map[i][j]=0;
        map[j][i]=0;
        search2(n);
        map[i][j]=1;
        map[j][i]=1;
      }
    }
  }
}


int main(void){
  int n,m,i,j;
  int x,y;

  scanf("%d %d",&n,&m);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      map[i][j]=0;
  }

  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    map[x-1][y-1]=1;
    map[y-1][x-1]=1;
  }

  search(n);

  printf("%d\n",bridge/2);

  return 0;
}




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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

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

  vector< string > S(N);
  cin >> S;

  vector< bitset< 10001 > > reach(N + 1);
  reach.back().set(K);
  for(int i = N - 1; i >= 1; --i) {
    reach[i] = reach[i + 1] | (reach[i + 1] >> S[i].size());
  }

  bitset< 10001 > dp;
  dp[0] = true;

  string ans;
  for(int i = 0; i < N; ++i) {
    auto d = z_algorithm(S[i] + ans);
    string prefix;
    prefix.reserve(ans.size());
    for(int j = 0; j <= ans.size() && j + S[i].size() <= K; ++j) {
      int t = (j == ans.size() ? 0 : d[S[i].size() + j]);
      if(dp[j] && reach[i + 1][j + S[i].size()] && (j == ans.size() || (t < S[i].size() && ans[j + t] > S[i][t]))) {
        for(int l = j + t + 1; l <= ans.size(); ++l) dp[l] = false;
        ans = prefix + S[i];
        dp[j + S[i].size()] = true;
        break;
      }
      if(j < ans.size()) prefix.push_back(ans[j]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	ll ans = 0;
	for(int a = 1; a < n; a++) {
		for(int b = 1; a * b < n; b++) {
			ans++;
		}
	}
	
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3640
used[9];
  
dfs(int step, int s)
{
    int i, res;
  
    if (!step) return (s == 0);
    if (s < 0) return (0);
    if (s > (step * (step + 1)) * 5) return (0);
      
    res = 0;
    for (i = 0; i <= 9; ++i){
        if (!used[i]){
            used[i] = 1;
            res += dfs(step - 1, s - (i * step));
            used[i] = 0;
        }
    }
    return (res);
}
  
main(n, v)
{
  
    while (~scanf("%d %d", &n, &v)){
        printf("%d\n", dfs(n, v));
    }
    return (0);
}

Measured memory_bytes: 600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define ll long long
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=8e5+100;
const ll mod=1e9+7;
const ll logg=25;

vector<ll> E;
ll logG(ll v,ll ww){
	if(E.empty()){
		while(v){
			E.pb(v);
			v/=2;
		}
		E.pb(0);
		reverse(E.begin(),E.end());
	}
	return lower_bound(E.begin(),E.end(),ww)-E.begin();
}
ll ta_koj_jelo[maxn][logg];
ll ta_koj_agha[maxn][logg];

ll x[maxn];
ll fas[maxn];
ll pri[maxn];
ll saf[maxn];


ll cnt[maxn];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	ll n,v;
	cin>>n>>v;
	for(ll i=1;i<=n;i++){
		cin>>x[i];
	}
	for(ll i=1;i+1<=n;i++){
		fas[i]=logG(v,x[i+1]-x[i]);
	//	cout<<(ll)fas[i]<<"* ";
	}
	//cout<<endl;
	for(ll i=0;i<logg;i++){
		ta_koj_jelo[n][i]=n;
		ta_koj_jelo[n+1][i]=n;
		ta_koj_agha[1][i]=1;
		ta_koj_agha[0][i]=1;
	}
	for(ll i=n-1;i>=0;i--){
		for(ll j=0;j<logg;j++){
			if(fas[i]<=j){
				ta_koj_jelo[i][j]=ta_koj_jelo[i+1][j];
			}else{
				ta_koj_jelo[i][j]=i;
			}
		}
	}
	for(ll i=2;i<=n;i++){
		for(ll j=0;j<logg;j++){
			if(fas[i-1]<=j){
				ta_koj_agha[i][j]=ta_koj_agha[i-1][j];
			}else{
				ta_koj_agha[i][j]=i;
			}
		}
	}

	ll M=(ll)(E.size());
	pri[0]=0;
	for(ll i=1;i<(1<<M);i++){
		pri[i]=0;
		for(ll j=0;j<M;j++){
			if((i>>j)&1){
				pri[i]=max(pri[i],ta_koj_jelo[pri[i^(1<<j)]+1][j]);
			}
		}
		pri[i]=min(pri[i],n);
	}
	saf[0]=n+1;
	for(ll i=1;i<(1<<M);i++){
		saf[i]=n+1;
		for(ll j=0;j<M;j++){
			if((i>>j)&1 ){
				saf[i]=min(saf[i],ta_koj_agha[saf[i^(1<<j)]-1][j]);
			}
		}
		saf[i]=max(saf[i],(ll)1);
	}
	for(ll i=0;i<(1<<M);i++){
	//	cout<<pri[i]<<' '<<saf[i]<<endl;
	}
	ll H=((1<<M)/2)-1;
	if(saf[H]==1){
		//cout<<"SALALM BABA )))))"<<endl;
		cnt[0]=1;
	}else{
		for(ll i=0;i<=H;i++){
			ll ras=saf[i];
			ll chap=pri[H^i];

			ll R=ta_koj_jelo[chap+1][M-1]; 
			ll L=ta_koj_agha[ras-1][M-1];

			if(ras-1<=R){
				cnt[L]++;
				cnt[R+1]--;
			}
		}
	}
	for(ll i=1;i<=n;i++){
		cnt[i]+=cnt[i-1];
		if(cnt[i]){
			cout<<"Possible\n";
		}else{
			cout<<"Impossible\n";
		}
	}
}		


Measured memory_bytes: 102272
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[100];
    scanf("%s", s);

    int n = strlen(s);
    int t = n/2;
    int ans = 0;
    
    for(int i=0; i<t; i++){
        if(s[i]!=s[n-i-1]){
            ans++;
        }
    }

    printf("%d", ans);
}

Measured memory_bytes: 1700
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

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

using pqg = priority_queue<ll,vector<ll>, greater<ll> >; // 1,3,5..
using pql = priority_queue<ll,vector<ll> >; //5, 3, 1...

using pqg_p = priority_queue<P,vector<P>, greater<P> >; // 1,3,5..
using pql_p = priority_queue<P,vector<P> >; //5, 3, 1...

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)

class UnionFind {
public:
  bool same(int a,int b) {
    return  root(a) == root(b);
  }

  void unite(int a, int b) {
    int pa = root(a);
    int pb = root(b);
    if ( pa == pb ) return;

    if(rank[pa] < rank[pb]) {
      par[pa] = pb;
    } else {
      par[pb] = pa;
      if( rank[pa] == rank[pb]) rank[pa]++;
    }
  }

  UnionFind(int N): par(N), rank(N) {
    REP(i,N) {
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int t) {
    if(par[t] == t) {
      return t;
    }
    else {
      return par[t] = root(par[t]); //親を覚えておく
    }
  }

private:

  vector<int> par;
  vector<int> rank;
};

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

  int N,M;
  cin >> N >> M;

  vector<int> v(N+1);

  UnionFind u1(N+1);

  REP1(i,N+1) {
    int a;
    cin >>  a;
    v[a] = i;
  }

  REP(i,M) {
    int a,b;
    cin >>  a >> b;
    u1.unite(a,b);
  }


  int ans = 0;
  REP1(i,N+1) {
    if (u1.same(i,v[i])) ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
bool IsOK(ll len){
        map<string,ll> m;
        rep(i,0,N){
            if(m[S.substr(i,len)]==0){
                m[S.substr(i,len)]=i+len;
            }else{
                if(i>=m[S.substr(i,len)]){
                    return true;
                }
            }
        }
        return false;
}
int main(){
    cin>>N>>S;
    ll left = -1;
    ll right = N/2+1;
    while(right - left >1){
        ll mid = left+(right - left)/2;
        if(IsOK(mid)){
            left = mid;
        }else{
            right = mid;
        }
    }
    
    cout<<max(right-1,(ll)0)<<endl;
    return 0;
}


Measured memory_bytes: 9932
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
int main()
{
    long K,N;
    std::cin >> K >> N;
    std::vector<long> D,A;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A.push_back(temp);
    }
    D.push_back(abs((K-A[N-1])+A[0]));
    for(long i=1; i<N; i++){
        D.push_back(abs(A[i]-A[i-1]));
    }
    std::sort(D.begin(),D.end());
    std::cout << K-D[N-1] << std::endl;
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
int n;
int a[30];
int main(){
	scanf("%d",&n);
	int tmp = 0,ans = 0;
	for (int i = 0;i < n;++i){
		int x;
		scanf("%d",&x);
		if (x >= tmp){
			ans++;
			tmp = x;
		}
	}
	printf("%d\n",ans);
}


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

int main() {
  string S,T;
  cin >> S >> T;
  sort(S.begin(),S.end());
  sort(T.begin(),T.end(),greater<char>());
  
  if(S<T) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

Measured memory_bytes: 256
def main():
    n, c, k = [int(i) for i in input().split()]
    t = [int(input()) for i in range(n)]
    t.sort()
    i = 0
    # 乗客カウント
    count = 0
    # 被ってる区間があるかどうか
    # 1  4
    # 3  5
    ans = 0
    while i < n:
        s = t[i] + k
        count = 0
        while i < n and count < c and t[i] <= s:
            count += 1
            i += 1
        ans += 1
        if i == n:
            break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    vector<ll> p_list;
    for(ll p = 1; p*p <=x; p++) {
        if(x%p == 0) {p_list.push_back(p);p_list.push_back(-p);}
    }
    ll b = 1;
    while(true) {
        for(ll p : p_list) {
            ll a = b+p;
            if(a*a*a*a*a - b*b*b*b*b == x) {cout << a << " " << b << endl; return 0;}
            a = -b+p;
            if(a*a*a*a*a + b*b*b*b*b == x) {cout << a << " " << -b << endl; return 0;}
        }
        b++;
    }
}

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

int rate[9] = {0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        if(a < 400)rate[0]++;
        else if(a < 800)rate[1]++;
        else if(a < 1200) rate[2]++;
        else if(a < 1600) rate[3]++;
        else if(a < 2000) rate[4]++;
        else if(a < 2400) rate[5]++;
        else if(a < 2800) rate[6]++;
        else if(a < 3200) rate[7]++;
        else rate[8]++;
    }

    int mini = 0, maxi = 0;
    for(int i=0;i<8;++i){
        if(rate[i] > 0){
            mini++;
            maxi++;
        }
    }
    mini = max(1, mini);
    maxi = maxi + rate[8];

    cout << mini << " " << maxi << endl;

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>K;
	ll ret=0;
	FOR(i,2) {
		for(int s=0;s<=H-2;s++) {
			int R=2*K+__gcd(s,W)-2;
			ll pat=0;
			for(x=1;x<W;x++) {
				int R2=R-s*x;
				if(R2<0) break;
				
				int Ymi=min(H-s-2,R2/W-1);
				if(Ymi>0) pat+=Ymi;
				for(y=max(1,Ymi+1);y<=Ymi+2 && y+s<H;y++) {
					ll v=1LL*W*y-__gcd(x,y)-__gcd(W-x,y+s);
					if(v<=R2) pat++;
				}
				
			}
			ret+=((s==0)?1:2)*pat;
		}
		swap(H,W);
	}
	cout<<2*ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(void){
    string S;cin>>S;
    vector<int>A(4,0);
    for(int i=0;i<S.size();i++){
        if(S[i]=='N'){
           A[0]++; 
        }
        if(S[i]=='W'){
           A[1]++; 
        }
        if(S[i]=='S'){
           A[2]++; 
        }
        if(S[i]=='E'){
           A[3]++; 
        }
    }
    if((A[0]>0&&A[2]==0)||(A[1]>0&&A[3]==0)||(A[2]>0&&A[0]==0)||(A[3]>0&&A[1]==0)){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
        return 0;
}

Measured memory_bytes: 3612
n,m=[int(i) for i in input().split()]
ans=[0]*m
a=[]
for i in range(n):
    hoge=[int(i) for i in input().split()[1:]]
    a.append(hoge)
for i in range(n):
    for j in range(len(a[i])):
        ans[a[i][j]-1]+=1
print(ans.count(n))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  lint n;
  cin >> n;
  std::vector<lint> h(n);
  REP(i,n) cin >> h[i];

  string result="";
  if(n==1){
    cout << "Yes" << endl;
    return 0;
  }
  IFOR(i,1,n){
    if(h[i] < h[i-1]){
      h[i-1] -= 1;
      if(h[i-1] == 0 || h[i] < h[i-1]){
        result = "No";
        break;
      }
    }
    if(i==1) result="Yes";
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int sr[10000];
int top = 0;

int pop(void);
void push(int);

int main(){
  int a,b;
  char s[10000];

  while( scanf("%s", s) != EOF){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if (s[0] == '-'){
      a = pop();
      b = pop();
      push(b-a);
    } else if (s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }


  printf("%d\n", pop());

  return 0;
}

int pop(){
  int a;
  a = sr[top];
  top--;
  return a;
}

void push(int x){
  top++;
  sr[top] = x;
}



Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace past10.Abc
{
    public class Question3
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            long N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            bool can = true;
            int ans = 0;
            while(true)
            {
                for(int i=0;i<N;++i)
                {
                    if(A[i]%2 == 0) {
                        A[i] /= 2;
                    } else {
                        can = false;
                        break;
                    }
                }
                if(can) ++ans;
                else break;
                
            }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 28536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;
    vector<ll> A(N * 3);

    for (int i = 0; i < N*3; ++i){
        cin >> A[i];
    }

    sort(A.begin(), A.end(), greater<ll>());
    ll ans = 0;

    for (int i = 0; i < N; ++i){
        ans += A[2 * i + 1];
    }

    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

void solve(){
	string s;
	cin >> s;
	if(s.find('7')==string::npos){
		cout << "No\n";
		return ;
	}
	cout << "Yes\n";
	
}

int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3664
from fractions import gcd
T=input()
def check(a,b,c,d):
	a-=b
	if a<0: return 0
	if d<b: return 0
	if d>=b:
		if c>=b-1: return 1
		else:
			d=gcd(b,d)
			a%=d
			l=c+d-a
			r=b+d-a-1
#			print l,r,d
			if l/d<r/d:
				return 0
			else:
				return 1
			# l<=a + t * d<=r
for i in xrange(T):
	a,b,c,d=map(int,raw_input().split())
	if check(a,b,c,d):
		print "Yes"
	else:
		print "No"

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

char s[202], c[202];
int m, h;

int main(){
	cin.tie(0);
	
	while(cin>>s,s[0]!='-'||s[1]!='\0') {
	    cin>>m;
	    int l = strlen(s);
	    rep(i, m) {
	        cin>>h;
	        rep(j, l-h)c[j] = s[j+h];
	        rep(j, h)c[j+l-h] = s[j];
	        rep(j, l)s[j] = c[j];
	    }
	    cout<<s<<endl;
	}
	
	return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	ll r,D;
	vll x(11,0);
	cin>>r>>D>>x[0];

	for(ll i=1;i<=10;i++) {
		x[i] = r*x[i-1] - D;
	}

	for(ll i=1;i<=10;i++) cout<<x[i]<<"\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main() {
  stack<int> s;
  vector<int> v;
  int n;
  while (cin >> n) {
    if (n == 0 && !s.empty()) {
      v.push_back(s.top());
      s.pop();
    } else {
      s.push(n);
    }
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();
            int len = S.Length;

            for (int i = 2; i < len; i += 2) {
                //Console.WriteLine(S.Substring(0, len - i));

                if (CheckGuumoji(S.Substring(0, len - i))) {
                    Console.WriteLine(len - i);
                    return;
                }
            }
        }


        static bool CheckGuumoji(string s) {
            int length = s.Length;

            for (int i = 0; i < length / 2; i++) {
                if (s[i] != s[i + (length / 2)]) {
                    return false;
                }
            }
            return true;
        }
    }
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = (N - 2) / (K - 1) + 1;
  // bool ok = false;

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

char field[7][7][7];
int dp[7][7][7][13];
int N;

char get(int x, int y, int z) {
    if(x < 0 || N <= x || y < 0 || N <= y || z < 0 || N <= z) return '.';
    return field[x][y][z];
}

int dpget(int x, int y, int z, int d) {
    if(x < 0 || N <= x || y < 0 || N <= y || z < 0 || N <= z) return 0;
    return dp[x][y][z][d];
}

int main() {
    ios::sync_with_stdio(0);
    while(true) {
        int M, P;
        cin >> N >> M >> P;
        if(!N && !M && !P) break;

        memset(field, '.', sizeof(field));

        int winturn = 0;
        string winner = "Draw";
        for(int turn = 1; turn <= P; ++turn) {
            int x, y;
            cin >> x >> y;
            --x; --y;
            for(int depth = 0; depth < N; ++depth) {
                if(field[x][y][depth] == '.') {
                    field[x][y][depth] = turn%2 == 1 ? 'B' : 'W';
                    break;
                }
            }
            if(winturn != 0) continue;

            bool win = false;
            memset(dp, 0, sizeof(dp));
            for(int z = 0; z < N; ++z) {
                for(int y = 0; y < N; ++y) {
                    for(int x = 0; x < N; ++x) {
                        char peg = get(x, y, z);
                        char color = turn%2 == 1 ? 'B' : 'W';
                        if(peg != color) continue;

                        dp[x][y][z][0]  = dpget(x-1, y, z, 0)+1;
                        dp[x][y][z][1]  = dpget(x, y-1, z, 1)+1;
                        dp[x][y][z][2]  = dpget(x, y, z-1, 2)+1;

                        dp[x][y][z][3]  = dpget(x-1, y, z-1, 3)+1;
                        dp[x][y][z][4]  = dpget(x+1, y, z-1, 4)+1;
                        dp[x][y][z][5]  = dpget(x, y+1, z-1, 5)+1;
                        dp[x][y][z][6]  = dpget(x, y-1, z-1, 6)+1;
                        dp[x][y][z][7]  = dpget(x-1, y-1, z, 7)+1;
                        dp[x][y][z][8]  = dpget(x+1, y-1, z, 8)+1;

                        dp[x][y][z][9]  = dpget(x-1, y-1, z-1, 9)+1;
                        dp[x][y][z][10] = dpget(x+1, y-1, z-1, 10)+1;
                        dp[x][y][z][11] = dpget(x-1, y+1, z-1, 11)+1;
                        dp[x][y][z][12] = dpget(x+1, y+1, z-1, 12)+1;

                        for(int i = 0; i < 13; ++i) {
                            //cout << dp[x][y][z][i] << endl;
                            if(dp[x][y][z][i] >= M) win = true;
                        }
                    }
                }
            }

            if(win) {
                winner = turn%2 == 1 ? "Black" : "White";
                winturn = turn;
            }
        }

        if(winturn != 0) {
            cout << winner << ' ' << winturn << endl;
        }
        else {
            cout << winner << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 936
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3][3];
    bool c[3][3]= {false};
    int i, j, k, n;
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
            cin>>a[i][j];
        }
    }
    cin>>n;
    int b[n];
    for(i=0; i<n; i++)
    {
        cin>>b[i];
    }
    for(i=0; i<=n; i++)
    {
        for(j=0; j<3; j++)
        {
            for(k=0; k<3; k++)
            {
                if(b[i]==a[j][k])
                {
                    c[j][k]=true;
                }
            }
        }
    }
    string s="No";
    for(i=0; i<3; i++)
    {
        if(c[i][0] && c[i][1] && c[i][2])
        {
            s="Yes";
        }
        if(c[0][i] && c[1][i] && c[2][i])
        {
            s="Yes";
        }
    }
    if(c[0][0] && c[1][1] && c[2][2])
    {
        s="Yes";
    }
    if(c[0][2] && c[1][1] && c[2][0])
    {
        s="Yes";
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

const int MaxN = 100000;
const int MaxM = 100;

int n, m;
int a[MaxM + 1];

inline void construct()
{
	int p = 0, q = 0;
	for (int i = 1; i <= m; ++i)
		if (a[i] & 1)
		{
			if (p == 0)
				p = i;
			else if (q == 0)
				q = i;
			else
			{
				cout << "Impossible\n";
				return;
			}
		}

	if (p > 0)
		swap(a[1], a[p]);
	if (q > 0)
		swap(a[m], a[q]);

	for (int i = 1; i <= m; ++i)
		cout << a[i] << ' ';
	cout << endl;

	if (m == 1)
	{
		if (a[1] == 1)
			cout << "1\n1\n";
		else
		{
			cout << "2\n";
			cout << "1 " << a[1] - 1;
			cout << endl;
		}

		return;
	}

	cout << m - (a[m] == 1) << endl;
	cout << a[1] + 1;
	for (int i = 2; i < m; ++i)
		cout << ' ' << a[i];
	if (a[m] > 1)
		cout << ' ' << a[m] - 1;
	cout << endl;
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; ++i)
		cin >> a[i];

	construct();

	return 0;
}

Measured memory_bytes: 256