akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

struct Obj{
  int lv;
  map<string,string> strs;
  map<string,Obj*> objs;
};

int N;
vector<int> level;
vector<string> vs;
void dfs(int& idx, int lv, Obj* obj){
  for(;idx<N;){
	if(idx == N || level[idx] <= lv) return;
	int lv_c = level[idx];
	int p = vs[idx].find(":");

	string key = vs[idx].substr(level[idx], p-level[idx]);
	if(p+1 == vs[idx].size()){
	  Obj* c = new Obj();
	  c->lv = lv_c;
	  ++idx;
	  dfs(idx, lv_c, c);
	  obj->objs[key] = c;
	}
	else{
	  string str = vs[idx].substr(p+2);
	  obj->strs[key] = str;
	  ++idx;
	}
  }
}


void debug(Obj* obj){
  cout << obj->lv << ": " << endl;
  for(auto& ss: obj->strs)
	cout << ss.first << " -> " << ss.second << endl;
  for(auto& ss: obj->objs){
	cout << ss.first << " -> *" << endl;
	debug(ss.second);
  }
}

int main(){
  string query; cin >> query; cin.ignore();

  string line;
  N = 0;
  while(getline(cin, line)){
	int lv = 0;
	for(;line[lv]==' ';++lv);
	level.push_back(lv);
	vs.push_back(line);
	++N;
  }
  Obj* yaml = new Obj();
  yaml->lv = -1;
  int idx = 0;
  dfs(idx,-1,yaml);

  //  debug(yaml);

  int i;
  Obj* cur = yaml;
  for(i=1;;){
	int p = query.find(".", i);
	if(p == string::npos) break;
	string item = query.substr(i,p-i);
	cur = cur->objs[item];
	i = p+1;
	if(!cur) break;
  }

  if(cur){
	string item = query.substr(i);
	if(cur->strs.count(item))
	  cout << "string \"" << cur->strs[item] << "\"" << endl;
	else if(cur->objs.count(item))
	  cout << "object" << endl;
	else
	  cur = 0;
  }
  if(!cur)
	cout << "no such property" << endl;
  
  return 0;
}

Measured memory_bytes: 1432
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

const int MAX_N=200005;
int par[MAX_N];//父集
int irank[MAX_N];//树的高度
int ians[MAX_N];

//初始化n个元素
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		irank[i]=0;
        ians[i]=1;
	}
}

//查询树的根
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

//合并x和y所属的集合
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y){
		return ;
	}
	if(irank[x]<irank[y]){
		par[x]=y;
        ians[y]+=ians[x];
	}else{
		par[y]=x;
        ians[x]+=ians[y];
		if(irank[x]==irank[y]){
			irank[x]++;
		}
	}
}

//判断x和y是否属于同一集合
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
    int n,m;
    cin>>n>>m;
    init(n+1);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        unite(a,b);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,ians[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5912
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#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=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

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

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main() {

  ll N;
  string S;
  cin>>S;
  if(S[0]=='A'){
  cout<<'T'<<endl;
  return 0;
  }
  if(S[0]=='T'){
  cout<<'A'<<endl;
  return 0;
  }
  if(S[0]=='C'){
  cout<<'G'<<endl;
  return 0;
  }
  if(S[0]=='G'){
  cout<<'C'<<endl;
  return 0;
  }
  //cout<<ans<<endl;
  return 0;
}
 


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	said_word=set()
	pre_word=input()
	said_word.add(pre_word)
	for _ in range(n-1):
		s = input()
		#pa(said_word)
		if s in said_word or s[0] != pre_word[-1]:
			return 'No'
		said_word.add(s)
		pre_word=s
	return 'Yes'
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,k;
    cin >> n >> k;
    vector p(n,0);
    for (int i=0; i<n; i++) cin >> p[i];
    sort(p.begin(), p.end());
//    debug(p);
    int ans = accumulate(p.begin(), p.begin()+k, 0);
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
  ll n,num,cnt=0;
  cin >> n;
  vector<ll> a(n+1),b(n);
  for(int i=0;i<n+1;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];

  for(int i=0;i<n;i++) {
    num=min(a[i],b[i]);
    a[i]-=num;
    b[i]-=num;
    cnt+=num;
    num=min(a[i+1],b[i]);
    a[i+1]-=num;
    b[i]-=num;
    cnt+=num;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 100000
int parent(int i){return i / 2;}

int left(int i){return i * 2;}

int right(int i){return i * 2 + 1;}

int main(){
  int H , i , A[MAX + 1];
  scanf("%d",&H);
  for(i = 1 ;i <= H ; i++){
    scanf("%d",&A[i]);
  }
  for(i = 1 ; i <= H ; i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);

    if(left(i)<=H)printf("left key = %d, ",A[left(i)]);

    if(right(i)<=H)printf("right key = %d, ",A[right(i)]);

    printf("\n");
  }
  return 0;
}

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

typedef pair<int, int> Pii;

typedef struct pos {
    int x;
    int y;
} pos;
pos data[200];

int dir_x[4] = {-1,  0,  1,  0};
int dir_y[4] = { 0,  1,  0, -1};

int main(void) {
    int n;
    while(1) {
        cin >> n;
        //cout << n << endl;
        if (n == 0) break;
        int min_x = 0;
        int max_x = 0;
        int min_y = 0;
        int max_y = 0;
        data[0].x = 0;
        data[0].y = 0;
        for(int i=1; i<n; i++) {
            int sn, sd;
            cin >> sn >> sd;
            data[i].x = data[sn].x + dir_x[sd];
            data[i].y = data[sn].y + dir_y[sd];
            if(min_x > data[i].x) min_x = data[i].x;
            if(max_x < data[i].x) max_x = data[i].x;
            if(min_y > data[i].y) min_y = data[i].y;
            if(max_y < data[i].y) max_y = data[i].y;
        }
        cout << (max_x - min_x + 1) << " " << (max_y - min_y + 1) << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  int n = s.size();
  rep(i, n){
    if(i & 1){
      if(s[i] == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i] == 'L'){
        cout << "No" << endl;
        return 0;
      }    
    }
  }
  
  cout << "Yes" << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  map<int, vector<int>> AB;
  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    if (a <= M)
      AB[a].push_back(b);
  }
  AB[M + 1].push_back(0);
  
  int ans = 0;
  int a_now = 0, a_next;
  vector<int> b_now = {0}, b_next;
  priority_queue<int> que;
  
  for (auto ab : AB) {
    a_next = ab.first;
    b_next = ab.second;
    for (int i : b_now)
      que.push(i);
    for (int j = a_now; j < a_next; j++) {
      ans += que.top();
      que.pop();
      if (que.empty()) break;
    }
    a_now = a_next;
    b_now = b_next;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 10880
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    ll c;
    while(b!=0)
    {
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
ll t[105];
int main(void)
{
    int n;
    while(cin>>n)
    {
        if(n==1)
        {
            ll c;
            cin>>c;
            printf("%lld\n",c);
        }
        else
        {
            ll num=1;
            cin>>t[0]>>t[1];
            num=(t[0]/gcd(t[0],t[1]))*t[1];
            for(int i=3;i<=n;i++)
            {
                cin>>t[i];
                num=(num/gcd(num,t[i]))*t[i];
            }
            cout<<num<<endl;
        }

    }
    return 0;
}


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

int main(){
	int N,i,j=0,k=0,l=0,m=0;
	char S[100];
  	cin >> N;
	for(i=0;i<N;i++){
		cin >> S[i];
		if(S[i]=='P') j=1;
		if(S[i]=='W') k=1;
		if(S[i]=='G') l=1;
		if(S[i]=='Y') m=1;
	}
	if(j+k+l+m==3) cout << "Three" << endl;
	if(j+k+l+m==4) cout << "Four" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int n;
    scanf("%d",&n);
    int p[n];
    int max = 0;
    int sum = 0;
    for(int i = 0;i < n; i++){
        scanf("%d",p+i);
        if(p[i]>max) {
            max = p[i];
        }
        sum = sum + p[i];
    }
    sum = sum - max/2;
    printf("%d\n",sum);
    return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

struct Edge {
    int from, to;
    i64 cost;
    Edge() {}
    Edge(int t, i64 c) : from(-1), to(t), cost(c) {}
    Edge(int f, int t, i64 c) : from(f), to(t), cost(c) {}

    bool operator<(const Edge& r) const {
        return cost < r.cost;
    }
    bool operator>(const Edge& r) const {
        return cost > r.cost;
    }
};

using Vertex = vector<Edge>;
using Graph  = vector<Vertex>;

// 無向
void link(Graph& g, int from, int to, int cost = 1) {
    g[from].push_back(Edge(from, to, cost));
    g[to].push_back(Edge(to, from, cost));
    return;
}

// 有向
void connect(Graph& g, int from, int to, int cost = 1) {
    g[from].push_back(Edge(from, to, cost));
    return;
}

pair<i64, Vertex> minimum_spanning_tree(const Graph& g, int start) {
    i64 total_cost = 0;
    Vertex V;
    vector<bool> visited(g.size(), false);

    priority_queue<Edge, vector<Edge>, greater<Edge>> que;
    que.push(Edge(start, start, 0));
    while (!que.empty()) {
        const auto e = que.top();
        que.pop();
        if (visited[e.to]) continue;

        visited[e.to] = true;
        V.push_back(e);
        total_cost += e.cost;
        for (const auto& n : g[e.to]) {
            if (!visited[n.to]) {
                que.push(n);
            }
        }
    }
    return make_pair(total_cost, V);
}

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

signed main() {
    int N;
    cin >> N;
    Graph G(N);
    rep(i, 0, N) rep(j, 0, N) {
        int w;
        cin >> w;
        if (w >= 0) {
            connect(G, i, j, w);
        }
    }
    auto ans = minimum_spanning_tree(G, 0);
    cout << ans.first << "\n";
}



Measured memory_bytes: 3392
import sys
sys.setrecursionlimit(10**7)
ans=''
def dfs(a,b,c,t):
    global ans
    if a<0 or b<0 or c<0:
        return False
    if t==N:
        return True
    if s[t]=='AB':
        if dfs(a-1,b+1,c,t+1):
            ans+='B'
            return True
        elif dfs(a+1,b-1,c,t+1):
            ans+='A'
            return True
    if s[t]=='BC':
        if dfs(a,b-1,c+1,t+1):
            ans+='C'
            return True
        elif dfs(a,b+1,c-1,t+1):
            ans+='B'
            return True
    if s[t]=='AC':
        if dfs(a+1,b,c-1,t+1):
            ans+='A'
            return True
        if dfs(a-1,b,c+1,t+1):
            ans+='C'
            return True
    return False

N,A,B,C=map(int,input().split())
s=[input() for i in range(N)]

if dfs(A,B,C,0):
    print('Yes')
    print(*ans[::-1],sep='\n')
else:
    print('No')

Measured memory_bytes: 109652
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
#define AsceSort(a) sort(a.begin(),a.end())

using namespace std;
typedef long long ll;

int main(void) {
	int n;
	cin >> n;
	for (int i = 111; i <= 999; i += 111) {
		if (n <= i) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
 
 
//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )
 
//#define MOD 1000000007ll
#define INF 1000000000
#define endl "\n"
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= ed; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
// const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const ll N=1e5+5,K=105;
const int si=(1<<20);
const ll M=50+5;
const ll oo=1e18+5;
const double INFdb=1e10;

int n;
int W;
int w[105],val[105];
ll dp[N];
int save;


int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
    #endif
    cin>>n>>W;
    for(int i=1;i<=n;++i){
		cin>>w[i]>>val[i];
	}
	for(int i=1;i<=n;++i){
		for(int j=W-w[i];j>=0;--j){
			dp[j+w[i]]=max(dp[j+w[i]],dp[j]+val[i]);
		}
	}
	ll ans=0;
	for(int i=0;i<=W;++i){
		if(dp[i]>ans){
				ans=dp[i];
				save=i;
		}
	}
	// for(int i=0;i<=W;++i) cerr<<dp[i]<<" ";
	// cout<<endl;
	// cerr<<save<<endl;
	cout<<ans;
    cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";                                                                          
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
// longest prefix suffix matching of [0, i)
vector<int> knuth_morris_pratt(const string &s){
  int n=s.size();
  vector<int> kmp(n+1,-1),mp(n+1,-1);
  for(int i=0,j=-1;i<n;i++){
    while(~j&&s[i]!=s[j]) j=kmp[j];
    kmp[i+1]=mp[i+1]=++j;
    if(i+1<n&&s[i+1]==s[j]) kmp[i+1]=kmp[j];
  }
  return mp;
}
// smallest d s.t. s[x] == s[x + d] for all x
vector<int> minimum_period(const string &s){
  auto mp=knuth_morris_pratt(s);
  for(int i=1;i<(int)mp.size();i++) mp[i]=i-mp[i];
  return mp;
}
//END CUT HERE

//INSERT ABOVE HERE
signed ABC135_D(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s,t;
  cin>>s>>t;

  int n=s.size(),m=t.size();

  string b;
  while(b.size()<t.size()) b+=s;
  auto mp=knuth_morris_pratt(t+'$'+b+b);

  vector<int> match(n);
  for(int i=m+1;i<=m+n;i++)
    match[i-(m+1)]=mp[i+m]==m;

  vector< vector<int> > G(n);
  for(int i=0;i<n;i++)
    if(match[i]) G[i].emplace_back((i+m)%n);

  vector<int> indeg(n,0);
  for(int i=0;i<n;i++)
    for(int j:G[i]) indeg[j]++;

  queue<int> que;
  for(int i=0;i<n;i++)
    if(indeg[i]==0) que.emplace(i);

  vector<int> dp(n,0);
  while(!que.empty()){
    int v=que.front();que.pop();
    for(int u:G[v]){
      chmax(dp[u],dp[v]+1);
      indeg[u]--;
      if(indeg[u]==0) que.emplace(u);
    }
  }

  for(int i=0;i<n;i++){
    if(indeg[i]!=0){
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<*max_element(dp.begin(),dp.end())<<endl;
  return 0;
}
/*
  verified on 2019/08/21
  https://atcoder.jp/contests/abc135/tasks/abc135_f
*/

signed ARC060_F(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string w;
  cin>>w;

  int n=w.size();
  if(w==string(n,w[0])){
    cout<<n<<endl<<1<<endl;
    return 0;
  }

  auto mp=minimum_period(w);
  if(n%mp[n]!=0||n==mp[n]){
    cout<<1<<endl<<1<<endl;
    return 0;
  }

  string w_rev=w;
  reverse(w_rev.begin(),w_rev.end());
  auto mp_rev=minimum_period(w_rev);

  int cnt=0;
  for(int i=1;i<n;i++){
    int j=n-i;
    if(i%mp[i]==0&&i>mp[i]) continue;
    if(j%mp_rev[j]==0&&j>mp_rev[j]) continue;
    cnt++;
  }
  cout<<2<<endl<<cnt<<endl;
  return 0;
}
/*
  verified on 2019/08/21https://atcoder.jp/contests/arc060/tasks/arc060_d
*/

signed main(){
  //ABC135_D();
  ARC060_F();
  return 0;
}


Measured memory_bytes: 7052
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace3race4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 100005;


  int32_t main() 
  {
    IOS


       
     	int ans1 = 1;
     	int ans2 = 1;


     	int n;
     	cin >> n;

     	vector<int> v;

     	vector<int> p,q;
     	for(int i = 1; i <= n; i++)
     	{
     		int x;
     		cin >> x;
     		p.PB(x);
     	}

     	for(int i = 1; i <= n; i++)
     	{
     		int x;
     		cin >> x;
     		q.PB(x);
     	}
     	


     	for(int i = 1; i <= n; i++)
     	{
     		v.PB(i);
     	}

     	if(v != p)
     	{
     		     	while(next_permutation(all(v)))
			     	{
			       		ans1++;
			     		if(v == p)
			     		{
			     			break;
			     		}


			     	}
     	}
     


     	v.clear();



     	for(int i = 1; i <= n; i++)
     	{
     		v.PB(i);
     	}

     	if(v != q)
     	{

     		while(next_permutation(all(v)))
	     	{
	     		ans2++;
	     		if(v == q)
	     		{
	     			break;
	     		}

	     	}

     	}

     	//trace2(ans1,ans2);
     	cout << abs(ans1 - ans2);


    return 0;
      }

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

/// --- math {{{ ///
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll d;
  return b == 0 ? (x = a < 0 ? -1 : 1, y = 0, a < 0 ? -a : a)
    : (d = extgcd(b, a % b, y, x), y -= a / b * x, d);
}
ll modinv(ll a, ll mod) {
  ll x, y;
  extgcd(a, mod, x, y);
  if(x < 0) x += mod;
  return x;
}
ll modpow(ll a, ll b, ll mod) {
  ll r = 1;
  a %= mod;
  while(b) {
    if(b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
/// }}}--- ///


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll e = lcm(c, d);
  cout << (b - b / c - b / d + b / e) - ((a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / e) << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

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

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll c=0,d=0;
	rep(i,n){
		c+=max(0LL,a[i]-b[i]);
		d+=max(0LL,(b[i]-a[i])/2);
	}
	Yes(c<=d);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int t = 0,c = 0;
    for(auto e:s) {
        if(e == 'g') {
            if(t > 0) {
                t--;
                c++;
            } else {
                t++;
            }
        } else {
            if(t > 0) {
                t--;
            } else {
                t++;
                c--;
            }
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 512
a,b,c = map(int,input().split())
k = int(input())
res = True
for i in range(k):
    if b > a:
        if c > b:
            break
        else:
            c *= 2
    elif b <= a:
        b *= 2
res = a < b < c
if res:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 9176
#include "bits/stdc++.h"

using namespace std;

int main() {
    int K;
    cin >> K;
    int odd;

    if(K % 2 == 0){
        odd = K / 2;
    }else{
        odd = K / 2 + 1;
    }
    cout << odd * (K - odd) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s, a[4] = {"dream", "dreamer", "erase", "eraser"};
    cin >> s;
    reverse(all(s));
    rep(i, 4)reverse(all(a[i]));
    bool ans = false;
    int i = 0;
    while(i < s.size()){
        if(s.substr(i, 5) == a[0])i += 5;
        else if(s.substr(i, 7) == a[1])i += 7;
        else if(s.substr(i, 5) == a[2])i += 5;
        else if(s.substr(i, 6) == a[3])i += 6;
        else break;
        
        if(i == s.size())ans = true;
    }
    if(ans) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 512
import java.util.Scanner


object Main {

  case class Work(len: Long, end: Long)


  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val works = IndexedSeq.fill(n)(Work(sc.nextLong(), sc.nextLong()))
    (n, works)
  }

  def solve(n: Int, works: IndexedSeq[Work]): Boolean = {
    val sortedWorks = works.sortBy(-_.end)
    val startTime = sortedWorks.foldLeft(Long.MaxValue) { (remainTime, work) =>
      if (remainTime > work.end) work.end - work.len
      else remainTime - work.len
    }

    startTime >= 0
  }

  def main(args: Array[String]): Unit = {
    val (n, works) = read()
    val able = solve(n, works)
    println(if (able) "Yes" else "No")
  }
}

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

struct team {
  team(int p) : solved(p), penalty(p) {}
  vector<bool> solved;
  vector<int> penalty;
  int time, id;
  bool operator<(team const& t) const {
    int s1 = count(begin(solved), end(solved), true), s2 = count(begin(t.solved), end(t.solved), true);
    if(s1 == s2) {
      if(time == t.time) {
        return id > t.id;
      }
      return time < t.time;
    }
    return s1 > s2;
  }
  bool operator==(team const& t) const {
    int s1 = count(begin(solved), end(solved), true), s2 = count(begin(t.solved), end(t.solved), true);
    return s1 == s2 && time == t.time;
  }
};

int main() {
  int M, T, P, R;
  while(cin >> M >> T >> P >> R, M) {
    vector<team> ts(T, P);
    for(int i = 0; i < T; ++i) {
      ts[i].id = i + 1;
    }
    for(int i = 0; i < R; ++i) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--; p--;
      if(j == 0) { // solved
        if(!ts[t].solved[p]) {
          ts[t].time += m + ts[t].penalty[p];
        }
        ts[t].solved[p] = true;
      } else {
        ts[t].penalty[p] += 20;
      }
    }
    sort(begin(ts), end(ts));

    for(int i = 0; i < T; ++i) {
      cout << ts[i].id;
      if(i + 1 == T) {
        cout << endl;
      } else {
        if(ts[i] == ts[i + 1]) cout << "=";
        else cout << ",";
      }
    }
  }
}



Measured memory_bytes: 3104
#include <cinttypes>
#include <cstdint>
#include <cassert>
#include <vector>
#include <iostream>

std::uint64_t gcd_impl( std::uint64_t n, std::uint64_t m ) {
    constexpr std::uint64_t K = 5;
    if( m == 0 ) { return n; }
    for( ; n / 64 < m; ) {
        std::uint64_t t = n - m;
        std::uint64_t s = n - m * K;
        bool q = t < m;
        bool p = t < m * K;
        n = q ? m : t;
        m = q ? t : m;
        if( m == 0 ) { return n; }
        n = p ? n : s;
    }
    return ::gcd_impl( m, n % m );
}

std::uint64_t gcd( std::uint64_t n, std::uint64_t m ) {
    return n > m ? ::gcd_impl( n, m ) : ::gcd_impl( m, n );
}

constexpr std::int64_t mod = 1'000'000'007;

std::uint64_t pow( std::uint64_t x, std::uint64_t n ) {
    std::uint64_t ans = 1;
    while( n ) {
        if( n & 1 ) {
            ans = ans * x % mod;
        }
        n /= 2;
        x = x * x % mod;
    }
    return ans;
}

std::uint64_t inv( std::uint64_t x ) {
    const std::uint64_t ans = ::pow( x, mod-2 );
    assert( x * ans % mod == 1 );
    return ans;
}

int main() {
    std::size_t N;
    std::cin >> N;
    std::vector<std::uint64_t> A(N);
    std::vector<std::uint64_t> Q; Q.reserve(N);

    for( auto& a : A ) {
        std::cin >> a;
    }

    int i = 0;
    for( auto a : A ) {
        for( auto q : Q ) {
            a = a / ::gcd( a, q );
        }
        if( i++ % 3 ) {
            Q.back() *= a;
        } else {
            Q.push_back(a);
        }
    }

    std::uint64_t lcm = 1;
    for( auto q : Q ) {
        lcm = lcm * ( q % mod ) % mod;
    }

    std::uint64_t sum = 0;
    for( auto a : A ) {
        sum = (sum + lcm * inv(a)) % mod;
    }

    std::cout << sum << std::endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;



int main(){

    string s,t;
    cin >> s;
    cin >> t;
    int count = 0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i])count++;
    }
    cout << count <<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	cin.tie(0);
	cout.tie(0);
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if(H%h==0&&(W%w==0))
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
		for(int i=1;i<=H;i++)
		{
			for(int j=1;j<=W;j++)
			{
				if(i%h==1)
				{
					if(j%w==1)
					{
						cout<<1000000000-1<<" ";
					}
					else if(j%w==0)
					{
						if(w==1)
						{
							cout<<1000000000-1<<" ";
						}
						else
						{
							cout<<0<<" ";
						}
					}
					else
					{
						cout<<0<<" ";
					}
				}
				else if(i%h==0)
				{
					if(h==1)
					{
						if(j%w==0)
						{
							cout<<-1000000000<<" ";
						}
						else if(j%w==1)
						{
							cout<<1000000000-1<<" ";
						}
						else
						{
							cout<<0<<" ";
						}
					}
					else
					{
						if(j%w==0)
						{
							cout<<-1000000000<<" ";
						}
						else
						{
							cout<<0<<" ";
						}
					}
				}
				else
				{
					cout<<0<<" ";
				}
			}
			cout<<"\n";
		}
	}
}

Measured memory_bytes: 2944
N,W=map(int,input().split())

DP=[[0 for j in range(W+1)] for i in range(N+1)]
v=[0]*(N+1)
w=[0]*(N+1)

for i in range(1,N+1):
    v[i],w[i]=map(int,input().split())

for i in range(1,N+1):
    for j in range(1,W+1):
        if j-w[i]<0:
            DP[i][j]=DP[i-1][j]
        else:
            if v[i]+DP[i-1][j-w[i]]>DP[i-1][j]:
                DP[i][j]=v[i]+DP[i-1][j-w[i]]
            else:
                DP[i][j]=DP[i-1][j]
print(DP[N][W])


Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define lPair pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

vector<int> places[200200];
ll dp[200200];
void add(ll &a, ll b) { a+=b; if(a >= MOD) a -= MOD;}
int main(){
    int N; cin >> N;
    map<char,int> mp;
    string s; cin >> s;
    for(int i = 0; i < N; i++){
        mp[s[i]]++;
    }
    ll ans = 1;
    for(char t = 'a'; t <= 'z'; t++){
        if(mp[t] == 0) continue;
        ans *= (mp[t]+1);
        ans %= MOD;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 5120
eg=Hash.new{|h,k|h[k]={}}

n=gets.to_i
(n-1).times{
  a,b,c=gets.split.map(&:to_i)
  eg[a][b]=eg[b][a]=c
}
q,k=gets.split.map(&:to_i)

que=[k]
cost=[]
cost[k]=0

while que[0]
  v=que.pop
  eg[v].each{|key,val|
    if !cost[key]
      cost[key]=cost[v]+val
      que << key
    end
  }
end

q.times{
  x,y=gets.split.map(&:to_i)
  p cost[x]+cost[y]
}

Measured memory_bytes: 47088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n, x; cin >> n >> x;
    vint m(n);
    rep(i,n) cin >> m[i];
    rep(i,n) x -= m[i];
    x /= *min_element(all(m));
    cout << n + x << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);
	int p[n];
	for (int i = 0;i < n;i++) {
		scanf("%d", &p[i]);
	}
	int count = 0;
	for (int i = 0;i < n - 2;i++) {
		if (p[i] < p[i + 1] && p[i + 1] <= p[i + 2]) {
			count++;
		}
		else if (p[i + 2] < p[i + 1] && p[i + 1] <= p[i]) {
			count++;
		}
	}

	printf("%d", count);
	return 0;
}

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

//rep(i,n) : for(int i=0 ; i < n ; i++) : i=0 ~ n-1 
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)


//reps(i,n) : for(int i=1 ; i <= n ; i++) : i=1 ~ n 
#define reps(i,n) for(int i=1 ; i##_len=(n) ; i<=i##_len ; ++i)


//ALL(x) : sort(v.begin(), v.end()); == sort(ALL(v));
#define ALL(x) (x).begin(),(x).end()

//pb
#define pb push_back

//SZ(x)
#define SZ(x) ((int)(x).size)



using namespace std;

int
main()
{
    int N;
    int sum=0;
    scanf("%d",&N);

    int A[N];
    
    rep(i,N)
    {
        scanf("%d",&A[i]);
        while(A[i]%2==0){A[i]/=2;sum++;}
    }
    cout<<sum<<endl;

    return 0;




}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long  N, A, B;
  cin >> N >> A >> B;
  if(A > B){
    cout << 0 << endl;
  }
  else if((N == 1) && (A == B)){
    cout << 1 << endl;
  }
  else if(N == 1){
    cout << 0 << endl;
  }
  else{
  long long max_n = B*(N-1) + A;
  long long min_n = A*(N-1) + B;
  cout << max_n - min_n + 1 << endl;
  }
}

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

int main(void){
    int D,N;
    cin >> D >> N;
    
    long long k = 1;
    for(int i=0;i<D;i++){
        k *= 100;
    }
    
    if(N==100 and D==0) cout << 101;
    else if(N==100 and D==1) cout << 10100;
    else if(N==100 and D==2) cout << 1010000;
    else cout << N*k;
    //cout << pow(100,D);
    return 0;
}


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


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

struct edge {int to; ll cost; };

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

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}
 
int main(){
  int n, r;
  cin >> n >> r;
  int ans;
  if(n>=10) ans = r;
  else ans = r+100*(10-n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
n = gets.chomp.to_i
s = gets.split(" ").map{|x| x.to_i}
q = gets.chomp.to_i
t = gets.split(" ").map{|x| x.to_i}
count = 0
t.each do |num|
  if s.include?(num)
    count +=1
  end
end
p count

Measured memory_bytes: 6376
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
using namespace std;

ll ans = 0;
ll n;
ll dfs(ll a) {
    if (a>n) return 0;
    string tmp = to_string(a);
    int three = count(all(tmp),'3');
    int five = count(all(tmp),'5');
    int seven = count(all(tmp),'7');
    if ((three>0)&&(five>0)&&(seven>0)) ans += 1;
    dfs(a*10+3);
    dfs(a*10+5);
    dfs(a*10+7);
    return ans;
}
    


int main(){
    cin >> n;
    cout <<dfs(0) << endl;;
    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char s1[11],s2[11],s3[11];
    char a,b,c;
    scanf("%s %s %s",s1,s2,s3);
    a=s1[0]-0x20;
    b=s2[0]-0x20;
    c=s3[0]-0x20;
    printf("%c%c%c",a,b,c);
    return 0;
};


Measured memory_bytes: 128
while true
    n = gets.to_i
    break if n == 0
    arr, arr2, h = [], [], {}
    n.times{
        m, a, b = gets.chomp.split.map(&:to_i)
        arr << [m, a, b - 1]
        arr2 << a
        arr2 << b - 1
    }
    arr2.sort.uniq.each_with_index{|x, i| h[x] = i}
    arr3 = Array.new(arr2.length, 0)
    arr.each{|m, a, b| h[a].upto(h[b]){|i| arr3[i] += m}}
    puts arr3.any?{|x| x > 150} ? "NG" : "OK"
end



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

using ll = long long;

void solve(long long X, long long N, std::vector<long long> p){
    int mi = 1e9;
    int ans = 0;
    for(int i = -1000;i < 1000;i++){
        if(count(p.begin(), p.end(), i) == 0){
            if(abs(X - i) < mi){
                mi = abs(X - i);
                ans = i;
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
template<class T1, class T2> using um = unordered_map<T1, T2>;
template<class T> using us = unordered_set<T>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define print_line cout << "[" << setw(3) << __LINE__ << "]  ";
#define for_b(i, b) for (int i = 0; i < static_cast<int>(b); ++i)
#define for_ab(i, a, b) for (int i = a; i < static_cast<int>(b); ++i)
#define what_is(x) { print_line cout << #x << " = " << x << endl; }
template<class T, class ... Ts> void what_are_2(T const& arg, Ts const&...args) { cout << arg; if constexpr (sizeof...(args) > 0) { cout << ", "; what_are_2(args...); } }
#define what_are(...) { print_line what_are_2(__VA_ARGS__); cout << endl; }
#define hit { print_line cout << "hit!" << endl; }
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) { print_line cout << #___x << " = "; for (auto ___num : ___x) cout << ___num << ", "; cout << endl;} 
#define show_2d(___x) { print_line cout << #___x << endl; for (auto ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }}
#define show_3d(___x) { print_line cout << #___x << endl; for (auto ___row : ___x) { for (auto ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }}

vv<int> d4 = {{1,0},{0,1},{-1,0},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(size_t w, size_t h, int x, int y) {
    return x >= 0 && x < static_cast<int>(w) && y >= 0 && y < static_cast<int>(h);
}

// ⣿⣿⣟⣽⣿⣿⣿⣿⣟⣵⣿⣿⣿⡿⣳⣫⣾⣿⣿⠟⠻⣿⣿⣿⢻⣿⣿⣿⣿⣷⡽⣿
// ⣿⣟⣾⡿⣿⣿⢟⣽⣿⣿⣿⣿⣫⡾⣵⣿⣿⣿⠃⠄⠄⠘⢿⣿⣾⣿⣿⣿⢿⣿⣿⡜
// ⡿⣼⡟⣾⣿⢫⣿⣿⣿⣿⡿⣳⣿⣱⣿⣿⣿⡋⠄⠄⠄⠄⠄⠛⠛⠋⠁⠄⠄⣿⢸⣿
// ⢳⣟⣼⡿⣳⣿⣿⣿⣿⡿⣹⡿⣃⣿⣿⣿⢳⠁⠄⠄⠄⢀⣀⠄⠄⠄⠄⠄⢀⣿⢿⣿
// ⡟⣼⣿⣱⣿⡿⣿⣿⣿⢡⣫⣾⢸⢿⣿⡟⣿⣶⡶⢰⣿⣿⣿⢷⠄⠄⠄⠄⢼⣿⣸⣿
// ⣽⣿⢣⣿⡟⣽⣿⣿⠃⣲⣿⣿⣸⣷⡻⡇⣿⣿⢇⣿⣿⣿⣏⣎⣸⣦⣠⡞⣾⢧⣿⣿
// ⣿⡏⣿⡿⢰⣿⣿⡏⣼⣿⣿⡏⠙⣿⣿⣤⡿⣿⢸⣿⣿⢟⡞⣰⣿⣿⡟⣹⢯⣿⣿⣿
// ⡿⢹⣿⠇⣿⣿⣿⣸⣿⣿⣿⣿⣦⡈⠻⣿⣿⣮⣿⣿⣯⣏⣼⣿⠿⠏⣰⡅⢸⣿⣿⣿
// ⡀⣼⣿⢰⣿⣿⣇⣿⣿⡿⠛⠛⠛⠛⠄⣘⣿⣿⣿⣿⣿⣿⣶⣿⠿⠛⢾⡇⢸⣿⣿⣿
// ⠄⣿⡟⢸⣿⣿⢻⣿⣿⣷⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡋⠉⣠⣴⣾⣿⡇⣸⣿⣿⡏
// ⠄⣿⡇⢸⣿⣿⢸⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠘⢿⣿⠏⠄⣿⣿⣿⣹
// ⠄⢻⡇⢸⣿⣿⠸⣿⣿⣿⣿⣿⣿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣦⣼⠃⠄⢰⣿⣿⢯⣿
// ⠄⢸⣿⢸⣿⣿⡄⠙⢿⣿⣿⡿⠁⠄⠄⠄⠄⠉⣿⣿⣿⣿⣿⣿⡏⠄⢀⣾⣿⢯⣿⣿
// ⣾⣸⣿⠄⣿⣿⡇⠄⠄⠙⢿⣀⠄⠄⠄⠄⠄⣰⣿⣿⣿⣿⣿⠟⠄⠄⣼⡿⢫⣻⣿⣿
// ⣿⣿⣿⠄⢸⣿⣿⠄⠄⠄⠄⠙⠿⣷⣶⣤⣴⣿⠿⠿⠛⠉⠄⠄ ⢸⣿⣿⣿⣿⠃⠄⢀⣴




int main()
{
    int N;
    cin >> N;
    
    string res;
    for_b(i,N)
        res += "ACL";
    cout << res;
    return 0;
}


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

int main(){
    int a;
    int b;
    int tmp=0,ans=0;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b;
        tmp = max(tmp, b);
        ans+=b;
    }
    //cout<<tmp<<endl;
    
    cout<< ans-tmp/2 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	map<char,int>mp;
	int cnt=0;
	for(char x: s)
	{
		mp[x]++;
	}
	for(auto x: mp)
	{
		if(x.second==2)
		{
			cnt++;
		}
	}
	cout<<(cnt==2?"Yes":"No");
	
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  rep(i, n-1) cin >> b[i];

  vector<int> a(n);
  a[0] = b[0];
  a[n-1] = b[n-2];
  for (int i = 1; i < n-1; ++i) a[i] = min(b[i-1], b[i]);
  int sum = 0;
  rep(i, n) sum += a[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int X,Y;

int main(){
    cin>>X>>Y;

    bool ans=false;
    rep(a,101){
        rep(b,101){
            if(a+b==X && 2*a+4*b==Y) ans=true;
        }
    }

    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	int x = N * N - A;
	cout << x << endl;	
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;
 
int main()
{
	int n;
	cin>>n;
	long long arr [100001];
	int ind1,ind2;
	ind1=0;
	ind2=1;
	for(int i=1;i<10;i++){arr[i]=i;ind1++;}
	int cur=ind1;
	for(int j=0;j<8;j++){
		for(int i=ind2;i<=ind1;i++){
			int a=arr[i]%10;
			if(a!=0){
				arr[++cur]=arr[i]*10+a-1;
			}
			arr[++cur]=arr[i]*10+a;
			if(a!=9){
				arr[++cur]=arr[i]*10+a+1;
			}
		}
		ind2=ind1+1;
		ind1=cur;
	}
	for(int i=ind2;i<=ind1&&cur<100000;i++){
		int a=arr[i]%10;
		if(a!=0){
			arr[++cur]=arr[i]*10+a-1;
		}
		arr[++cur]=arr[i]*10+a;
		if(a!=9){
			arr[++cur]=arr[i]*10+a+1;
		}
	}
	//for(int i=1;i<20;i++)cout<<arr[i]<<endl;
	//cout<<n<<endl;
	cout<<arr[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024