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

using namespace std;

using PII = pair<int, int>;

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

	vector<PII> works;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		works.emplace_back(make_pair(a, b));
	}

	sort(works.begin(), works.end(),
		[](const PII &a, const PII &b) {
			return a.first < b.first;
		});

	int ans = 0;
	priority_queue<int> que;
	int idx = 0;
	for (int i = m; i >= 0; i--) {
		while (idx < works.size()) {
			if (i + works[idx].first <= m) {
				que.push(works[idx].second);
				idx++;
			} else {
				break;
			}
		}

		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}

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


Measured memory_bytes: 1908
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long power = 1;
		int mod = 1000000000 + 7;

		for(int i = 1;i <= N;i++){
			power *= i;
			power %= mod;
		}

		System.out.println(power);

		sc.close();
	}

}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-

N = int(input())
t_prev, x_prev, y_prev = 0, 0, 0

for n in range(N):
    t, x, y = map(int, input().split())
    if (t - t_prev) >= (abs(x-x_prev) + abs(y-y_prev)) and (t + x + y) % 2 == 0:
        t_prev, x_prev, y_prev = t, x, y
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

typedef long long ll;
ll n, m, s;
priority_queue<ll> qu;
int main()
{
	ll i, t;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &t);
		qu.push(t);
	}
	for (i = 0; i < m; i++) {
		t = qu.top(); qu.pop();
		qu.push(t / 2);
	}
	while (!qu.empty()) {
		t = qu.top(); qu.pop();
		s += t;
	}
	cout << s << endl;
    return 0;
}


Measured memory_bytes: 1400
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  static final BigInteger BASE = BigInteger.valueOf(10).pow(9).add(BigInteger.valueOf(7));

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int nBlue = k;
    int nRed = n - k;
    IntStream.rangeClosed(1, k).mapToObj(i -> solve(nBlue, nRed, i)).map(Main::toAns)
      .map(String::valueOf).forEach(pw::println);
  }

  static BigInteger solve(int nBlue, int nRed, int i) {
    if (nRed < i - 1) {
      return BigInteger.ZERO;
    }
    BigInteger combinationBlue = combination(nBlue - 1, i - 1);
    int remainRed = nRed - (i - 1);
    int candidateRed = (i - 1) + 2;
    BigInteger combinationRed = combination(remainRed + candidateRed - 1, remainRed);
    return combinationBlue.multiply(combinationRed);
  }

  static BigInteger combination(long m, long n) {
    if (n == 0) {
      return BigInteger.ONE;
    }
    BigInteger ans = BigInteger.ONE;
    for (int i = 0; i < n; i++) {
      ans = ans.multiply(new BigInteger(String.valueOf(m - i)));
      ans = ans.divide(new BigInteger(String.valueOf(i + 1)));
    }
    return ans;
  }

  static BigInteger toAns(BigInteger i) {
    return i.mod(BASE);
  }
}


Measured memory_bytes: 223332
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>
#include <climits>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream& operator<<(ostream& out, vector<T> &v){
  for (int i = 0; i < (int)v.size(); i++) {
    out<<v[i]<<' ';
  }
  return out;
}

int main(){
  ll n, d; cin >> n >> d;
  int ans = 0;
  for(int i = 0; i < n; i++){
    ll x, y; cin >> x >> y;
    if(x * x + y * y <= d * d){
      ans++;
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
//#define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, Ans = 0;;cin >> N;
vector<ll> A(5);

for(int i = 0; i < N; i++){
string S;cin >> S;

if(S[0] == 'M')A[0]++;
if(S[0] == 'A')A[1]++;
if(S[0] == 'R')A[2]++;
if(S[0] == 'C')A[3]++;
if(S[0] == 'H')A[4]++;

}

for(int i = 0; i < 5; i++){
for(int j = i + 1; j < 5; j++){
for(int k = j + 1; k < 5; k++){

Ans += A[i]*A[j]*A[k];

}}}
cout << Ans;
}

Measured memory_bytes: 3604
a = [input().split() for i in range(3)]
b = []
for i in range(3):
  for j in range(2):
    b.append(a[i][j])
c = [int(b[i]) for i in range(6)]
for i in range(1, 5):
  if c.count(i) == 3:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}


signed main() {
    accell();
    string s;
    cin >> s;
    int cur = 0;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'W')
            ans += cur;
        if (s[i] == 'B')
            cur++;
    }
    cout << ans;
    return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;

    if(a1+a2+a3 > 21) cout << "bust" << endl;
    else cout << "win" << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

ll N, K;
void dfs(int v, int p, ll k, ll &res, vector<vector<int>> &G) {
    res *= k;
    res %= MOD;
    int cs = G[v].size();
    int m = (p == -1 ? 1 : 2);
    for(auto nv : G[v]) {
        if(nv == p)
            continue;
        dfs(nv, v, K - m, res, G);
        m++;
    }
}

int main() {
    cin >> N >> K;
    vector<vector<int>> G(N, vector<int>());
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll res = 1;
    dfs(0, -1, K, res, G);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<pair<ll,pair<ll,ll>>>a;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ll z=x+y;
		a.push_back(make_pair(z,make_pair(x,y)));
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll ta=0,ao=0;
	for(int i=0;i<n;i+=2){
		ta+=a[i].second.first;
	}
	for(int i=1;i<n;i+=2){
		ao+=a[i].second.second;
	}
	cout << ta-ao;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=3000,M=3000;
int n,m;
char a[N+5],b[M+5];
int dp[N+1][M+1],pa[N+1][M+1];
int main(){
	int n,m;
	cin>>a+1>>b+1;
	n=strlen(a+1);m=strlen(b+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
		dp[i][j]=dp[i-1][j];pa[i][j]=1;
		if(dp[i][j-1]>dp[i][j])dp[i][j]=dp[i][j-1],pa[i][j]=2;
		if(a[i]==b[j]&&dp[i-1][j-1]+1>dp[i][j])dp[i][j]=dp[i-1][j-1]+1,pa[i][j]=3;
	}
	int nowi=n,nowj=m;
	string ans;
	while(nowi&&nowj)
		if(pa[nowi][nowj]==1)nowi--;
		else if(pa[nowi][nowj]==2)nowj--;
		else ans+=a[nowi],nowi--,nowj--;
	for(int i=ans.size()-1;~i;i--)putchar(ans[i]);
	return 0;
}
/*1
axyb
abyxb
*/
/*2
aa
xayaz
*/
/*3
a
z
*/
/*4
abracadabra
avadakedavra
*/

Measured memory_bytes: 70656
def solve():
    N, A, B = map(int, input().split())
    Xi = tuple(map(int, input().split()))

    # print(N, "\n徒歩疲労度", A, "\nテレポ疲労度", B)
    # print(Xi)

    total = 0
    for i in range(1, N):
        total += min((Xi[i] - Xi[i - 1]) * A, B)

    return total


if __name__ == '__main__':
    res = solve()
    print(res)


Measured memory_bytes: 62832
#include <stdio.h>
#include <stdlib.h>
#define TRUE  1
#define FALSE 0

int judge_hit(char *r, char *a);
int judge_blow(char *r, char *a);

int main() {
    char r_s[4];
    char a_s[4];
    
    while (TRUE) {
        scanf("%s",r_s);
        scanf("%s",a_s);
        if ((atoi(r_s) == 0) && (atoi(a_s) == 0)){
            break;
        }else{
            printf("%d %d\n",judge_hit(r_s,a_s),judge_blow(r_s,a_s));
        }
    }

    return 0;
}

int judge_hit(char *r, char *a) {
    int hit;
    int i;
    
    hit = 0;
    for(i = 0; i < 4; i++){
        if (r[i] == a[i]){
            hit++;
        }
    }

    return hit;
}

int judge_blow(char *r, char *a){
    int blow;
    int i,j;
    
    blow = 0;
    for(i = 0; i < 4; i++){
        for(j = 0; j < 4; j++){
            if((i != j) && (r[i] == a[j])){
                blow++;
            }
        }
    }

    return blow;
}

Measured memory_bytes: 548
import bisect
n=int(input())
A=sorted(map(int,input().split()))
B=list(map(int,input().split()))
C=sorted(map(int,input().split()))
r=0
for b in B:
    i=bisect.bisect_left(A,b)
    j=n-bisect.bisect_right(C,b)
    r+=i*j
print(r)

Measured memory_bytes: 23328
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final List<String> S = Stream.generate(s::next).limit(N).map(l -> {
				char[] ary = l.toCharArray();
				Arrays.sort(ary);
				return new String(ary);
			}).sorted().collect(Collectors.toList());

			String prev = null;
			long cnt = 0;
			long ret = 0;
			for (String str : S) {
				if (!str.equals(prev)) {
					ret += cnt * (cnt - 1) / 2;
					cnt = 1;
					prev = str;
				} else {
					cnt++;
				}
			}
			ret += cnt * (cnt - 1) / 2;
			System.out.println(ret);
		}
	}
}


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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    bool flag=true;
    for(int i=n-1; i>0; i--){
        if(h[i]+1<h[i-1]){
            //cout << i <<endl;
            flag=false;
        }
        else if(h[i]+1==h[i-1])h[i-1]--;
    }
    
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main(){
    int a,b,c,n;
    string s,p;
    char ch;
    vector<int>v;
    
    cin >> n;
    
    long long int sum=0;
    
    for(int i=1; i<=n; i++){
        
        if((i%3==0&&i%5==0) || (i%3==0) || (i%5==0))continue;
        sum+=i;
    }
    
    cout << sum << endl;
    
    
    
    return 0;
}




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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> mat;

int main(){
    int a, b;
    cin >> a >> b;
    int d = b - a;
    int c = 0;
    FOR(i, 1, d) c += i;
    cout << (c - a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,arr[500005];


void solve()
{
	int a,b;
	cin>>a>>b;
	
	rep(i,b-a+1,b+a)cout<<i<<" ";
	
	
	
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    ///cin>>t;
    
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), t = sc.nextInt(), ans = 0;
        for(int i=1;i<t+1;i++)if(i%a==0)ans+=b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 35788
#include <iostream>

int main()
{
	int n, m;
	std::cin >> n >> m;
	
	int a, b;
	if(n > 1)
	{
		a = n*(n-1)/2;
	}else{
		a = 0;
	}
	if(m > 1)
	{
		b = m*(m-1)/2;
	}else{
		b = 0;
	}
	std::cout << a+b;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>

#define ll long long
#define db double
#define MAX 0x7fffffff
#define init inline int
#define INF 0X3fffffff

using namespace std;

inline long long read()
{
    ll f=1,s=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
    return s*f;
}


ll a,b,c;

int main()
{
	a=read();b=read();c=read();
	if((a+b+c)>=22) cout<<"bust"<<endl;
	else cout<<"win"<<endl;
}

Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define f(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll mod=1000000007;
const ll N=200005;
vi adj[N];
ll vis[N];
ll c=0;
void dfs(ll u,ll p)
{
    vis[u]=1;
    c++;
   // cout<<u;
    for(ll v : adj[u])
    {
        if(vis[v]==0)
        {
            dfs(v,u);
        }
    }
}
int main()
{
fast;
    vi v;
    ll n,m;
    cin>>n>>m;
    set<pii>s;
    f(i,m)
    {
        ll x,y;
        cin>>x>>y;
        s.insert({x,y});
    }
    for(auto const &it : s)
    {
        ll x=it.F,y=it.S;
      //  cout<<x<<' '<<y<<endl;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    clr(vis);
    f1(i,n)
    {
        if(vis[i]==0)
        {
            c=0;
            dfs(i,-1);
            v.pb(c);
        }
    }
    sortall(v);
    vi v1;
    v1.pb(v[0]);
    if(v.size()==1)
       cout<<v[0];
    else
    {
        f1(i,(ll)v.size()-1)
        {
            v1.pb(v[i]-v[i-1]);
        }
        ll sum=0;
        f(i,(ll)v1.size())
        {
            sum+=v1[i];
        }
        cout<<sum;
    }
    return 0;
}

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

bool dfs(int v,vector<vector<pair<int,ll>>> &edge,vector<int> &used,vector<ll> &dist){
    if(!used[v]){
        dist[v]=0;
        used[v]=true;        
    }
    for(int i=0;i<edge[v].size();i++){
        int to=edge[v][i].first;
        int cost=edge[v][i].second;
        if(used[to]){
            if(dist[v]+cost!=dist[to]) return false; 
        }else{
            used[to]=true;
            dist[to]=dist[v]+cost;
            bool ret=dfs(to,edge,used,dist);
            if(!ret) return false;
        }
    }
    return true;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,ll>>> edge(n);
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        l--,r--;
        edge[l].push_back({r,d});
        edge[r].push_back({l,-d});
    }
    vector<int> used(n,false);
    vector<ll> dist(n,0);
    for(int i=0;i<n;i++){
        if(!used[i]){
            bool ret=dfs(i,edge,used,dist);
            if(!ret){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<pair<string,int>>p(n),q(n);
    for(int i=0; i<n; i++){
        cin>>p.at(i).first>>p.at(i).second;
    }
    for(int i=0; i<n; i++){
        q.at(i).first=p.at(i).first;
        q.at(i).second=(-1)*p.at(i).second;
    }
    sort(q.begin(),q.end());
    /*for(int i=0; i<n; i++){
        cout<<q.at(i).first<<' '<<q.at(i).second<<endl;
    }
}*/
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(q.at(i).first==p.at(j).first and 
            q.at(i).second==(-1)*p.at(j).second)cout<<j+1<<endl;
        }
    }
}

Measured memory_bytes: 256
#d 
n=int(input())
x=input()

def popcount(m):
    return bin(m).count("1")

intx = int( "0b"+x ,0 )
popcount0 = x.count("1")

intx_mod_pp1 = intx %(popcount0+1)
if popcount0!=1:
    intx_mod_pm1 = intx %(popcount0-1)
    

jisho = ["yet"]*n
# pow2ip = .5
# pow2im = .5

for i in range(n):
    if x[i]=="1" and popcount0==1:
        print(0)
        continue
    
    pow2ip = pow(2,n-i-1,popcount0+1)
    if popcount0!=1:
        pow2im = pow(2,n-i-1,popcount0-1)

    if False:
        pass
    
    
    else:
        intxi=1
        c=0
        while intxi!=0:
            if c==0:
                if x[i]=="0":
                    pop = popcount0+1
                    intxi = (intx_mod_pp1 + pow2ip%pop )%pop
                else:
                    pop = popcount0-1
                    intxi = (intx_mod_pm1 - pow2im%pop )%pop        
            else:
                if jisho[intxi]=="yet":
                    togo = intxi%popcount(intxi)
                    jisho[intxi]= togo
                    intxi = togo
                else:
                    intxi =jisho[intxi]
                
            #print(intxi)
            c+=1
        print(c)
        #print()
    
#        print("f(n)=",c)

Measured memory_bytes: 88176
N,K = list(map(int,input().split()))
S = [int(i) for i in list(input())]
S.append(2)

S2 = []
cnt = 1
for i in range(N):
    if S[i] != S[i+1]:
        S2.append([S[i],cnt])
        cnt = 1
    else:
        cnt += 1

if S2[0][0] == 0:
    S2 = [[1,0]] + S2
if S2[-1][0] == 0:
    S2.append([1,0])    
    
SUM = [0]
for i in range(len(S2)):
    SUM.append(SUM[i] + S2[i][1])
T = []
for i in range(0,max(1,len(SUM)//2-K),1):
    T.append(SUM[min(len(SUM)-1,2*(K+i)+1)]-SUM[2*i])
print(max(T))

Measured memory_bytes: 19952
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int r;
int main(){
	cin>>r;
	cout<<r*r;
	return 0;
}


Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.trim().split('\n')
	const n = parseInt(args[0], 10)

	if (n === 1) {
		console.log('Hello World')
	} else {
		const a = parseInt(args[1], 10)
		const b = parseInt(args[2], 10)
		console.log(a + b)
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7620
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, k;
   int x[N] = {};
   cin >> n >> k;
   FOR(i, 0, n)
   cin >> x[i];
   int res = INF;
   FOR(i, 0, n - k + 1)
   {
      res = min(res, min(abs(x[i]) + abs(x[i + k - 1] - x[i]), abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1])));
   }
   cout << res << endl;
   return 0;
}


Measured memory_bytes: 640
#include <cstdio>


int dx[4][4],dy[4][4];

char board[6][12];//y x

char buf[7][7];

bool DFS(int posy,int posx,int level,int mask){
    if (level==4) return true;

    for(;posy<4;posy++)
        for(posx=0;posx<10;posx++)
            if (board[posy][posx]=='.') goto end;
    end:

    for(int puzzle=0;puzzle<4;puzzle++){
        if (mask&(1<<puzzle)) continue;

        bool fits=true;
        for(int i=0;i<4;i++){
            int x=posx+dx[puzzle][i],y=posy+dy[puzzle][i];

            if (x<0||x>=10||y<0||y>=4||board[y][x]=='#') {
                fits=false;
                break;
            }
        }

        if (fits){
            for(int i=0;i<4;i++){
                int x=posx+dx[puzzle][i],y=posy+dy[puzzle][i];
                board[y][x]='#';
            }

            if (DFS(posy,posx,level+1,mask+(1<<puzzle))) return true;

            for(int i=0;i<4;i++){
                int x=posx+dx[puzzle][i],y=posy+dy[puzzle][i];
                board[y][x]='.';
            }
        }

    } 

    return false;
}

int main(){

    for(int i=0;i<4;i++){
        int h,w;
        scanf("%d%d\n",&h,&w);
        for(int i=1;i<=h;i++) scanf("%s",buf[i]+1);

        int fsty=1,fstx=1;
        for(fstx=1;buf[1][fstx]!='#';fstx++); 
        
        for(int j=1,cur=0;j<=h;j++)
            for(int k=1;k<=w;k++)
                if (buf[j][k]=='#'){
                    dx[i][cur]=k-fstx;
                    dy[i][cur]=j-fsty;
                    cur++;
                }
    }

    int N;
    scanf("%d\n",&N);
    for(int i=0;i<N;i++){
        for(int i=0;i<4;i++) scanf("%s",board[i]);

        if (DFS(0,0,1,0)) puts("Yes");
        else
            puts("No");
        
    }

    return 0;
}


Measured memory_bytes: 2696
n, m = gets.chomp.split.map(&:to_i)

a = []
n.times do
  a << gets.chomp.split.map(&:to_i)
end

b = []
m.times do
  b << gets.chomp.to_i
end

a.each do |ai|
  sum = 0
  ai.zip(b).each do |aij, bi|
    sum += aij * bi
  end
  puts sum
end

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

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,k;

int main()
{
	cin>>n>>k;
	if(k==1) cout<<0<<endl;
	else cout<<n-k<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
//  ll mod(ll val) {
//      ll res = val % MOD;
//      if (res < 0) res += MOD;
//      return res;
//  }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }


int main() {
    int N; std::cin >> N;
    N = N % 10;
    if (N == 3) {
        std::cout << "bon" << std::endl;
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        std::cout << "pon" << std::endl;
    } else {
        std::cout << "hon" << std::endl;
    }
    // cout << setprecision(10);
    return 0;
}


Measured memory_bytes: 3620
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=readline()
    println(ifelse('9' in n,"Yes","No"))
end
main()

Measured memory_bytes: 166704
while True:
  n =int(input())
  if n==0:
    break
  ans=0
  for i in range(n): 
    x,y,h,w=map(int, input().split())
    size=x+y+h
    if size<=60 and w<=2:
      pay=600    
    elif size<=80 and w<=5:
      pay=800
    elif size<=100 and w<=10:
      pay=1000
    elif size<=120 and w<=15:
      pay=1200
    elif size<=140 and w<=20:
      pay=1400
    elif size<=160 and w<=25:
      pay=1600
    else:
      pay =0
    ans+=pay      
  print(ans)


Measured memory_bytes: 5612
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll X;
    cin >> X;

    ll a = X / 500;
    ll b = (X - a * 500) / 5;

    cout << a * 1000 + b * 5 << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    while(cin>>s){
        if(s[0]==s[1] && s[1]==s[2]){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

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

int main(){
  int n; cin>>n;
  if(n<2)cout<<1<<endl;
  else if(n<4)cout<<2<<endl;
  else if(n<8)cout<<4<<endl;
  else if(n<16)cout<<8<<endl;
  else if(n<32)cout<<16<<endl;
  else if(n<64)cout<<32<<endl;
  else if(n<128)cout<<64<<endl;
}

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



int main (void){

    int n;
    string s;
    cin >> s;
    n = s.size();
    int count1 = 0;
    int count0 = 0;
    for (int i = 0; i < n;i++){
        if(s[i]=='1'){
            count1++;
        }
        
        else{
            count0++;
        }
    }
        cout << 2 * min(count0, count1) << endl;
        return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> a(n+1),b(n);
  for(LL&x:a) cin >> x;
  for(LL&x:b) cin >> x;
  LL answer = 0;
  REP(i,n) {
    LL tmp = min(a[i],b[i]);
    answer += tmp;
    b[i] -= tmp;
    tmp = min(a[i+1],b[i]);
    answer += tmp;
    a[i+1] -= tmp;
  }
  cout << answer << endl;
}


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

using namespace std;

const int maxn = 2e5 + 50;

template < typename T >
void Read( T & x ){
	x=0;
	char ch;
	for( ch = getchar() ; ch < '0' || ch > '9' ; ch = getchar() );
	for( ; ch <= '9' && ch >= '0' ; ch = getchar() ) x = x * 10 + ch - '0';
}

int A , B , C , D , E , F , vis[3001][3001];
queue < pair < int , int > > que;

void push( int a , int b ){
	if( vis[a][b] ) return ;
	vis[a][b] = 1;
	que.push( make_pair( a , b ) );
}

int main( int argc , char * argv[] ){
	Read( A ) , Read( B ) , Read( C ) , Read( D ) , Read( E ) , Read( F );
	vis[0][0] = 1;
	que.push( make_pair( 0 , 0 ) );
	while( !que.empty() ){
		pair < int , int > s = que.front() ; que.pop();
		int x = s.first , y = s.second;
		if( 100 * A + x + y <= F ) push( x , 100 * A + y );
		if( 100 * B + x + y <= F ) push( x , 100 * B + y );
		if( x + y + C <= F ) push( x + C , y );
		if( x + y + D <= F ) push( x + D , y );
	}
	double mx = 0;
	pair < int , int > ans = make_pair( 0 , 0 );
	for(int i = 0 ; i <= F ; ++ i)
		for(int j = 0 ; j <= F ; ++ j)
			if( vis[i][j] && i + j > 0 && E * j >= 100 * i ){
				if( ( double )( 100 * i ) / ( double )( i + j ) >= mx )
					mx = ( double )( 100 * i ) / ( double )( i + j ) , ans = make_pair( i , j );
			}
	printf( "%d %d\n" , ans.first + ans.second , ans.first );
	return 0;
}

Measured memory_bytes: 33792
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true){

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();

			if(op.equals("?"))break;

			int ans = 0;

			switch(op){
			case "+":
				ans = a+b;
				break;
			case "-":
				ans = a-b;
				break;
			case "*":
				ans = a*b;
				break;
			case "/":
				ans = a/b;
				break;
			}

			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 26376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin >> n;
    vector<int> g[n+1];
    if(n%2==0){
        int s=1+n;
        rrep(i,n/2){
            int v=i,u=s-i;
            rrep(j,n){
                if(j!=v&&j!=u){
                    g[j].push_back(v);
                    g[j].push_back(u);
                }
            }
        }
    }
    else{
        int s=n;
        rrep(i,n/2){
            int v=i,u=s-i;
            rrep(j,n){
                if(j!=v&&j!=u){
                    g[j].push_back(v);
                    g[j].push_back(u);
                }
            }
        }
        rrep(i,n-1){
            g[i].push_back(n);
        }
    }
    set<P> ss;
    int ans=0;
    rrep(i,n){
        for(auto next: g[i]){
            int v=i,u=next;
            if((!ss.count({v,u}))&&(!ss.count({u,v}))){
                ans++;
                ss.insert({v,u});
                ss.insert({u,v});
            }
        }
    }
    cout << ans << endl;
    set<P> sss;
    rrep(i,n){
        for(auto next: g[i]){
            int v=i,u=next;
            if((!sss.count({v,u}))&&(!sss.count({u,v}))){
                cout << v << " " << u << endl;
                sss.insert({v,u});
                sss.insert({u,v});
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int _;

int main() {
	INIT
	ll n, a;
	cin >> n >> a;
	cout << n * n - a;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

ll N,W;
ll ans;
vector<int> w0,w1,w2,w3;

int main() {

  cin >> N >> W;

  int w,v;
  int tmp = 0;

  cin >> w >> v;
  tmp = w;
  w0.push_back(0);
  w1.push_back(0);
  w2.push_back(0);
  w3.push_back(0);
  w0.push_back(v);

  
  
  for(int i = 1; i < N; i++) {
    cin >> w >> v;
    if(tmp == w) w0.push_back(v);
    if(tmp + 1 == w) w1.push_back(v);
    if(tmp + 2 == w) w2.push_back(v);
    if(tmp + 3 == w) w3.push_back(v);
  }

  sort(w0.begin() + 1,w0.end(),greater<int>());
  sort(w1.begin() + 1,w1.end(),greater<int>());
  sort(w2.begin() + 1,w2.end(),greater<int>());
  sort(w3.begin() + 1,w3.end(),greater<int>());

  ll v0 = 0;
  ll ww0 = 0;
  for(int i = 0; i <= w0.size(); i++) {
    ll v1 = 0;
    ll ww1 = 0;
    v0 += w0[i];
    if(i > 0) ww0 += tmp;
    for(int j = 0; j <= w1.size(); j++) {
      ll v2 = 0;
      ll ww2 = 0;
      v1 += w1[j];
      if(j > 0) ww1 += tmp + 1;
      for(int k = 0; k <= w2.size(); k++) {
	ll v3 = 0;
	ll ww3 = 0;
	v2 += w2[k];
	if(k > 0) ww2 += tmp + 2;
	for(int l = 0; l <= w3.size(); l++) {
	  if(l > 0) ww3 += tmp + 3;
	  if(ww0 + ww1 + ww2 + ww3 > W)continue;
	  v3 += w3[l];
	  ans = max(ans,v0 + v1 + v2 + v3);
	}
      }
    }
  }
  
  
  cout << ans << endl;
}
	  

  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, M; cin >> N >> M;
  vi k(M);
  vvi s(M);
  rep(i,M) {
    cin >> k.at(i);
    s.at(i).resize(k.at(i));
    rep(j,k.at(i)) {
      cin >> s.at(i).at(j);
      s.at(i).at(j)--;
    }
  }
  
  vi p(M); rep(i,M) cin >> p.at(i);

  int ans = 0;
 
  rep(i,1<<N) {
    bool ok = true;
    rep(j,M) {
      int cnt = 0;
      for (int id : s.at(j)) {
        if((i>>id)&1) {
          cnt++;
        }
      }
      if(cnt%2 != p.at(j)) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

void solve(long long N, std::vector<long long> A){
    if(N == 2) {
        cout << max(A[0], A[1]) << endl;
        return;
    }

    set<int> use_skip, temp;
    use_skip.insert(A[0]);
    use_skip.insert(A[1]);
    LL all_gcd = gcd(A[0], A[1]);

    REP2(i, 2, N) {
        temp.insert(all_gcd);
        for(auto it = use_skip.begin(); it != use_skip.end(); it++){
            temp.insert(gcd(*it, A[i]));
        }
        use_skip = temp;
        temp.clear();
        all_gcd = gcd(all_gcd, A[i]);
    }

    int ans = 0;
    for(auto it = use_skip.begin(); it != use_skip.end(); it++){
        ans = max(ans, *it);
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 1024
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

set<pii>ed;
vector<int>vec;

void Add(int a,int b){
    if(a>b) swap(a,b);
    if(a==0) return;
    ed.insert({a,b});	
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    if(n&1) vec.PB(0);
    for(int i=1;i<=n;i++){
	vec.PB(i);
    }
    for(int i=0;i<sz(vec)/2;i++){
	int nxt=(i+1)%(sz(vec)/2);
	Add(vec[i],vec[nxt]);
	Add(vec[i],vec[sz(vec)-1-nxt]);
	Add(vec[sz(vec)-1-i],vec[nxt]);
	Add(vec[sz(vec)-1-i],vec[sz(vec)-1-nxt]);
    }
    cout<<sz(ed)<<"\n";
    for(pii p:ed){
	cout<<p.F<<" "<<p.S<<"\n";
    }
    return 0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,Q;
    string S;
    cin >> N >> Q >> S;
    ll A[N-1];
    rep(i,N-1) A[i] = 0;
    rep(i,N-1){
        if(S[i]=='A'&&S[i+1]=='C'){
            if(i==0) A[0] = 1;
            else A[i] += A[i-1]+1;
        }
        else{
            if(i!=0) A[i] = A[i-1];
        }
    }
    ll l,r,out;
    rep(i,Q){
        cin >> l >> r;
        if(l>1) out = A[r-2]-A[l-2];
        else out = A[r-2];
        cout << out << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;


public class Main {
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			int n = a % 500;
			if(n <= b){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 21972
#累積和的な

n,q = map(int,input().split())
s = input() + 'A' 
li = [0]*(n+1)

for i in range(n):
  li[i+1] = li[i] + (1 if s[i] + s[i+1] == 'AC' else 0)
  

for j in range(q):
  l,r = map(int,input().split())
  print(li[r-1] - li[l-1])

Measured memory_bytes: 7748
#include <stdio.h>

int main(void)
{
	int n = 1;
	int i;
	int array;
	int sort[8];
	
	while (1){
	scanf("%d", &n);
	if (n == 0){
		break;
	}
	for (i = 0; i < 8; i++){
		sort[i] = 0;
	}
	
	for (i = 0; i < n; i++){
		scanf("%d", &array);
		if (array >= 60){
			sort[7]++;
		}
		else if (array >= 50){
			sort[6]++;
		}
		else if (array >= 40){
			sort[5]++;
		}
		else if (array >= 30){
			sort[4]++;
		}
		else if (array >= 20){
			sort[3]++;
		}
		else if (array >= 10){
			sort[2]++;
		}
		else if (array < 10){
			sort[1]++;
		}
	}
	for (i = 1; i < 8; i++){
		printf("%d\n", sort[i]);
	}
	}
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n;
    set<string>setstr;
    string str;
    for(i=0;i<n;i++)
    {
        cin>>str;
        setstr.insert(str);
    }
    cout<<setstr.size();
}

Measured memory_bytes: 19236
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp> 
const double PI=acos(-1);
using namespace std;
using boost::multiprecision::cpp_int;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define ci cpp_int
#define MOD 1000000007

long findmin(long a,long b) {
	return a<b?a:b;
}
long findmax(long a,long b) {
	return a>b?a:b;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.length(),m=s2.length();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++) {
		dp[i][0]=0;
	}
	for(int i=0;i<=m;i++) {
		dp[0][i]=0;
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			if(s1[i-1]==s2[j-1]) {
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else {
				dp[i][j]=findmax(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	//for(int i=0;i<=n;i++) {
		//for(int j=0;j<=m;j++) {
			//cout<<dp[i][j]<<" ";
		//}
		//cout<<"\n";
	//}
	string ans;
	int i=n,j=m;
	do {
		//cout<<i<<","<<j<<"-->"<<s1[i-1]<<" "<<s2[j-1]<<"\n";
		//cout<<s1[i-1]<<" "<<s2[j-1]<<"\n";
		if((dp[i][j]==(dp[i-1][j-1])+1) && (dp[i-1][j]<dp[i][j]) && (dp[i][j-1]<dp[i][j])) {
			ans=s1[i-1]+ans;
			i-=1;j-=1;
		}
		else {
			if(dp[i][j]==dp[i-1][j]) {
				i-=1;
			}
			else {
				j-=1;
			}
		}
	}while(i>=1 && j>=1);
	//cout<<"\n";

	//cout<<dp[n][m]<<" ";
	//cout<<"ans: "<<ans<<"\n";
	cout<<ans<<"\n";
	cout.flush();
	return 0;
}


Measured memory_bytes: 38764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    loop(i, n - 2)
        if (s.substr(i, 3) == "ABC")
            ++ans;
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;


	int ans=A[K - 1];


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> a >> b >> k;
    l = min(a,k);
    a -= min(a,k);
    k -= l;
    b -= min(b,k);
    cout << a << " " << b;

    return 0;
}


Measured memory_bytes: 256