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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a);i <= (b);i++)
#define per(i, a, b) for(int i = (a);i >= (b);i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
ll n, a[N], l = 1, r = 1, ans = 0;
inline ll read(){
	ll x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9'){x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void init(){
	n = read();
	rep(i, 1, n) a[i] = read();
}
void work(){
	for(ll l = 1, r = 1, now = 0;l <= n;){
		for(;r <= n&&(now^a[r]) == now+a[r];) now ^= a[r++];
		ans += r-l, now ^= a[l++];
	}
}
void print(){
	printf("%lld\n", ans);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init();
	work();
	print();
	return 0;
}


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

int main() {

	int a, b;
	scanf("%d %d", &a, &b);
	if(b >= 0 && a < 0) {
		printf("%s\n", "Zero");
	}else if(a > 0) {
		printf("%s\n", "Positive");
	}else if(a < 0 && b < 0) {
		if((b - a) % 2 == 0) {
			printf("%s\n", "Negative");
		}else {
			printf("%s\n", "Positive");
		}
	}
}

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

using namespace std;

long long int INF = 1000000001;

int main()
{
  int N;
  cin >> N;
  int n[N + 1];
  for (int i = 0; i < N; i++) {
    cin >> n[i];
  }
  n[N] = INF;

  sort(n, n + N + 1);

  int pre = 0;
  int ctr = 0;
  int red = 0;

  for (int i = 0; i < N + 1; i++) {
    if (n[i] > pre) {
      if (ctr >= pre) {
        red += ctr - pre;
      } else {
        red += ctr;
      }
      pre = n[i];
      ctr = 1;
    } else {
      ctr++;
    }
  }
  cout << red;
  return 0;
}

Measured memory_bytes: 640
from copy import  deepcopy
N = int(input())
T = list(map(int, input().split()))
M = int(input())

ans = []
for _ in range(M):
    P, X = map(int, input().split())
    t = deepcopy(T)
    t[P-1] = X
    ans.append(sum(t))
    
for a in ans:
    print(a)

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


int main() {
  int h1,m1,h2,m2;
  int time1,time2;
  int sub=0;
  cin>>h1>>m1>>h2>>m2>>sub;
  time1=h1*60+m1;
  time2=h2*60+m2;
  time2-=time1;
  cout<<time2-sub;
  return 0;
}

Measured memory_bytes: 3624
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  
  reverse(ALL(A));
  rep(i,n){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 3084
package main

import "fmt"

func main() {
	var N, T, X, Y int
	fmt.Scan(&N)
	t := make([]int, N+1)
	x := make([]int, N+1)
	y := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		fmt.Scan(&t[i], &x[i], &y[i])
	}
	for i := 1; i < N+1; i++ {
		T, X, Y = t[i-1], x[i-1], y[i-1]
     	if t[i]-T < abs(x[i],X) + abs(y[i],Y) || (t[i]-T-abs(x[i],X) + abs(y[i],Y)) % 2 == 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func abs(a, b int)int {
  	if a >= b {
  		return a-b
    } else {
    	return b-a
    }
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
	int n, m;
	cin >> n >> m;
	vector< vector<P> > aa(n); 
	int s, t, e;
	while (cin >> s >> t >> e) {
		if (s == 0 && t == 0 && e == 0) {
			break;
		}
		aa[s-1].push_back(P(t, e));
	}
	int l;
	cin >> l;
	for (int i = 0; i < l; i++) {
		vector<int> b(m+1);
		for (int j = 0; j < m; j++) {
			cin >> b[j+1];
		}
		vector<int> c(n, 0);
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < aa[j].size(); k++) {
				c[j] += b[aa[j][k].first] * aa[j][k].second;
			}
			if (j != 0) {
				cout << ' ';
			}
			cout << c[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  string S;
  cin >> S;
  auto s = S.find('A');
  auto e = S.find_last_of('Z');
  cout << S.substr(s, e - s + 1).size() << endl;
}

Measured memory_bytes: 772
#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;
  int Alice = 0 , Bob = 0;
  vector<int> data(N);
  
  rep(i,N){
      cin >> data.at(i);// 3 1 が入っている
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());

  for(int i = 0; i < N; i++){
      if(i %2 == 0){
          Alice += data.at(i);
      }else{
          Bob += data.at(i);
      }
  }
 cout << Alice - Bob << endl;

}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct{
	int x;
	int y;
	int cost;
} mArray[300 * 300] = { 0 };

int main(void)
{
	int h, w, d;
	scanf("%d %d %d", &h, &w, &d);
	int i, j;
	int dx, dy;
	int q;

	for (i = 0; i < h; ++i){
		for (j = 0; j < w; ++j){
			int a;
			scanf("%d", &a);
			--a;
			mArray[a].x = i;
			mArray[a].y = j;
		}
	}

	for (i = 0; i + d < h*w; ++i){
		dx = mArray[i].x > mArray[i + d].x ? mArray[i].x - mArray[i + d].x : mArray[i + d].x - mArray[i].x;
		dy = mArray[i].y > mArray[i + d].y ? mArray[i].y - mArray[i + d].y : mArray[i + d].y - mArray[i].y;
		mArray[i + d].cost = mArray[i].cost + dx + dy;
	}

	scanf("%d", &q);
	for (i = 0; i < q; ++i){
		int l, r;
		scanf("%d%d", &l, &r);
		--l, --r;
		printf("%d\n", mArray[r].cost - mArray[l].cost);
	}

	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<queue>
using namespace std;
#define N 200127
int n,m,ans=0,L,R,s[N];
vector<int>a[N];
priority_queue<int,vector<int>,greater<int> >h;
int main(){
	scanf("%d%d",&n,&m);int i,x,y;
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
	}
	for(i=1;i<=m;i++)
	for(auto v:a[i])
	{
		if(L<i){++L;h.push(v);continue;}
		x=h.top();if(x>=v)++s[v];else {h.pop();++s[x];h.push(v);}
	}
	for(auto v:a[0])++s[v];ans=s[m+1];
	R=m+1;for(i=m;i>=1;i--)
	while(s[i]){if((i<R)&&(L+1<R))--R;else ++ans;--s[i];}
	printf("%d",ans);return 0;
}

Measured memory_bytes: 10108
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> lang;
vector<lang> people;

int N,M,L;
bool tr[30][30];

bool check(vector<int> ret)
{
	for(int i=0; i<people.size(); i++)
	{
		bool g=false;
		for(int j=0; j<people[i].size(); j++)
		for(int k=0; k<ret.size(); k++)
		{
			if(people[i][j]==ret[k]) g=true;
		}
		
		if(!g) return false;
	}

	bool v[30][30]={0};
	for(int i=0; i<ret.size(); i++)
	for(int j=0; j<ret.size(); j++)
		if(tr[ret[i]][ret[j]]) v[ret[i]][ret[j]]=1;
		
	for(int k=0; k<N; k++)
	for(int y=0; y<N; y++)
	for(int x=0; x<N; x++)
		v[x][y]|=(v[x][k]&v[k][y]);

	for(int i=0; i<people.size(); i++)
	for(int j=i+1; j<people.size(); j++)
	{
		bool g=false;
		for(int k=0; k<people[i].size(); k++)
		for(int l=0; l<people[j].size(); l++)
		{
			if(v[people[i][k]][people[j][l]]) g=true;
		}
		if(!g) return false;
	}
	return true;
}

bool conb(int p, int l, int pv, vector<int>& ret)
{
	if(p==l) 
	{
		if(check(ret)) return true;
		return false;
	}
	for(int i=pv+1; i<N; i++)
	{
		ret.push_back(i);
		if(conb(p+1,l,i,ret)) return true;
		ret.pop_back();
	}
	return false;
}


int main()
{
	bool f=true;
	while(scanf("%d%d",&N,&M),(N||M))
	{
		if(!f) puts("");
		f=false; 
		
		for(int i=0; i<30; i++)
		for(int j=0; j<30; j++)
		{
			tr[i][j]=0;
			if(i==j) tr[j][i]=1;
			tr[i][i]=1;
			tr[j][j]=1;
		}
			
		people.clear();
		map<string, int> d;
		map<int, string> rd;
		for(int i=0; i<N; i++)
		{
			char buf[30];
			scanf("%s", buf);
			d.insert(make_pair(string(buf), i));
			rd.insert(make_pair(i, string(buf)));
		}
		
		vector<lang> People;
		while(M--)
		{
			lang per;
			scanf("%d", &L);
			while(L--)
			{
				char buf[30];
				scanf("%s", buf);
				map<string, int>::iterator it=d.find(string(buf));
				per.push_back(it->second);
			}
			people.push_back(per);
		}
	
		for(int i=0; i<people.size(); i++)
		for(int j=0; j<people[i].size(); j++)
		for(int k=j+1; k<people[i].size(); k++)
		{
			tr[people[i][j]][people[i][k]]=1;
			tr[people[i][k]][people[i][j]]=1;
		}

		vector<int> ret;
		for(int i=1; i<=5; i++)
		{
			if(conb(0,i,-1,ret)) break;
		}
		
		if(ret.empty()) puts("Impossible");
		else
		{
			vector<string> ans;
			map<int, string>::iterator it;
			for(int i=0; i<ret.size(); i++)
			{
				it=rd.find(ret[i]);
				ans.push_back(it->second);
			}
			
			sort(ans.begin(), ans.end());
			
			printf("%d\n", ans.size());
			for(int i=0; i<ans.size(); i++)
				puts(ans[i].c_str());
		}
	}
}

Measured memory_bytes: 864
while True:
    try:
        a = map(int,raw_input().split())

	n = [a[0],a[1]]

        while True:
            if a[0] < a[1]:
	        tmp = a[0]
                a[0] = a[1]
	        a[1] = tmp

            a[0] = a[0] - a[1]
	    if a[0] == 0:
		break

	b = n[0]*n[1]/a[1]

	print "%d %d" % (a[1],b)

    except EOFError:
	break

Measured memory_bytes: 4236
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long x;
	cin >> x;
	for (int i = int(sqrt(x)); i >= 1; i--)
	{
		if (x % i == 0)
		{
			cout << i + x / i - 2;
			break;
		}
	}
}

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

const long long LM = 1e18;

struct node {
    long long lmax, rmax, inmax, sum;
    node(long long lmax, long long rmax, long long inmax, long long sum) : lmax(lmax), rmax(rmax), inmax(inmax), sum(sum) {}
    node(long long x) : node(x, x, x, x) {}
};

const node ex(-LM, -LM, -LM, 0);
const node compose(const node& l, const node& r) {
    return node(max(l.lmax, l.sum + r.lmax),
                max(r.rmax, l.rmax + r.sum),
                max({ l.inmax, r.inmax, l.rmax + r.lmax }),
                l.sum + r.sum);
}

class segtree {
private:
    int n, s, t;
    vector<node> tr;

    const node q(int k, int l, int r) {
        return r <= s || t <= l ? ex : s <= l && r <= t ? tr[k]
                : compose(q(k << 1 | 1, l, (l + r) >> 1), q((k + 1) << 1, (l + r) >> 1, r));
    }
public:
    segtree() {}
    segtree(int m) {
        n = 1;
        while (n < m) n <<= 1;
        tr = vector<node>((n << 1) - 1, ex);
    }
    void assign(int j, const node& x) {
        tr[j + n - 1] = x;
    }
    void update(int j, const node& x) {
        assign(j, x);
        update(j);
    }
    void update(int j) {
        int i = j + n - 1;
        while (i > 0) {
            i = (i - 1) >> 1;
            tr[i] = compose(tr[i << 1 | 1], tr[(i + 1) << 1]);
        }
    }
    void all_update() {
        for (int i = n - 2; i >= 0; i--)
            tr[i] = compose(tr[i << 1 | 1], tr[i + 1 << 1]);
    }

    // [s, t)
    const node run(int _s, int _t) {
        s = _s;
        t = _t;
        return q(0, 0, n);
    }
};


segtree sg;

long long calc(int l, int r) {
    return sg.run(l, r).inmax;
}

// l1 < l2 <= r1 < r2
long long calc(int l1, int l2, int r1, int r2) {
    return sg.run(l1, l2).rmax + sg.run(r1, r2).lmax + (l2 == r1 ? 0 : sg.run(l2, r1).sum);
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    // assert(1 <= n && n <= 100000);
    // assert(1 <= q && q <= 100000);
    sg = segtree(n);
    for (int i = 0; i < n; ++i) {
        long long a;
        cin >> a;
        // assert(-1000000000 <= a && a <= 1000000000);
        sg.assign(i, node(a));
    }
    int l1 = 0, l2 = n;
    int r1 = 0, r2 = n;
    sg.all_update();
    cout << max({ calc(r1, l2), calc(l1, l2, l2, r2), calc(l1, r1, r1, r2), 0LL }) << '\n';
    for (int _ = 0; _ < q; ++_) {
        int k, x;
        cin >> k >> x;
        --k;
        sg.update(k, node(x));
        cout << max({ calc(r1, l2), calc(l1, l2, l2, r2), calc(l1, r1, r1, r2), 0LL }) << '\n';
    }
    return 0;
}



Measured memory_bytes: 11044
#include<stdio.h>
long long limit=1000000;
int main(){
  char in;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      scanf("%c", &in);
      if( i==j ) printf("%c", in);
    }
    char esc;
    scanf("%c", &esc);
  }
  printf("\n");
  return 0;
	 
}


Measured memory_bytes: 128
N, M = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(M)]
ans = [0,0]
cnt = [0]*(N+1)
memo = [0]*(N+1)
for i in range(M):
    p = int(ps[i][0])
    s = ps[i][1]
    if memo[p] == 1:
        continue
    else:
        if s == "WA":
            ans[1] += 1
            cnt[p] += 1
        else:
            ans[0] += 1
            cnt[p] += 1
            memo[p] = 1

for i in range(1,N+1):
    if memo[i] == 0:
        ans[1] -= cnt[i]
        
print(*ans)

Measured memory_bytes: 34820
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int a[] = {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;
    cout<<a[K-1];

}

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


int main(){
  int n;
  cin >> n;
  if(n < 105){cout << 0 << endl;}
  else if(n < 135){cout << 1 << endl;}
  else if(n < 165){cout << 2 << endl;}
  else if(n < 189){cout << 3 << endl;}
  else if(n < 195){cout << 4 << endl;}
  else{cout << 5 << endl;}
}

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

using namespace std;
int main()
{
  int n;
  cin >> n;

  if (n % 1000 == 0)
  {
    cout << 0 << endl;
  }
  else
  {
    int m = n / 1000;
    cout << (m + 1) * 1000 - n << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, num=0;

	cin>>n;

	vll ans(201, 1), temp(201);

	repr(i, 9, 201){
		ll tempi=i;
		rep(j, 201) temp[j]=0;
		for(int j=3; j<200; j+=2){
			while(1){
				if(tempi%j!=0) break;
				tempi/=j;
				temp[j]++;
			}
		}
		rep(j, 201) ans[i]*=(temp[j]+1);
	}

	rep(i, n+1){
		if(ans[i]==8) num++;
	}
	cout<<num<<endl;
}


Measured memory_bytes: 256
k,t = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*t
for i in range(t):
    b[i] = [a[i], i]
s = -1
ans = 0
if t == 1:
    ans = k-1
else:
    for i in range(k):
        b.sort(key= lambda val : val[0],reverse=True)
        if b[0][1] == s:
            if b[1][0] == 0:
                ans = b[0][0]
                break
            else:
                b[1][0] -= 1
                s = b[1][1]
        else:
            b[0][0] -= 1
            s = b[0][1]
print(ans)

Measured memory_bytes: 9156
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		int a = reader.nextInt();
		int b = reader.nextInt();
		if(a < b){
			System.out.println("a < b");
		} else if (a > b){
			System.out.println("a > b");
		} else{System.out.println("a == b");}
	}
}

Measured memory_bytes: 17352
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

const int N = 100003;
const int p = 1000000007;

int ipow(int a, int b) {
	int r = 1, w = a;
	while (b) {
		if (b & 1) r = 1ll * r * w % p;
		w = 1ll * w * w % p;
		b >>= 1;
	}
	return r;
}

int jc[N], njc[N], shown[N], n;

int C(int a, int b) {
	if (b > a) return 0;
	return 1ll * jc[a] * njc[b] % p * njc[a - b] % p;
}

int main() {
	jc[0] = njc[0] = 1;
	for (int i = 1; i <= 100001; ++i) {
		jc[i] = 1ll * jc[i - 1] * i % p;
		njc[i] = ipow(jc[i], p - 2);
	}
	
	scanf("%d", &n);
	int tmp1, tmp2;
	for (int i = 1; i <= n + 1; ++i) {
		int ai; scanf("%d", &ai);
		if (!shown[ai]) shown[ai] = i;
		else {tmp1 = shown[ai], tmp2 = i; break;}
	}
	
	for (int k = 1; k <= n + 1; ++k) {
		int ans = C(n + 1, k) - C(tmp1 + n - tmp2, k - 1) + p;
		printf("%d\n", ans % p);
	}
	
	return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

LL n,k,a[200005];
LL pre[200005] = {0};
map <LL,LL> mp;
LL tot = 0;

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i]; a[i] --; a[i] %= k;
		pre[i] = pre[i - 1] + a[i]; pre[i] %= k;
	}
	mp[pre[0]] = 1;
	for(LL i = 1;i <= n;i ++){
		if(i >= k) mp[pre[i - k]] --;
		tot += mp[pre[i]];
		mp[pre[i]] ++;
	}
	cout << tot << endl;
	return 0;
}
//

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <cmath>
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(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
int mod = 1000000007;
using namespace std;
int main()
{
    string str1,str2,str3;
    int a,b;
    while(cin>>str1)
    {
       for(int i=1;i<=str1.length();i++)
           cout<<"x";
        cout<<endl;
    }
     
   return 0;   
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int n,a,b,memo[300001]={1};

main() {
    scanf("%d%d%d",&n,&a,&b);
    if (n > 1LL*a*b || n < a+b-1) puts("-1");
    else {
        int now=b,cnt=n;
        while(1) {
            for(int i=0;i<b;++i){
                if (a == cnt) {
                    for(int k=0;k<=n;++k)if (!memo[k]) printf("%d ",k);
                    return 0;
                }
                cnt--;
                printf("%d ",now-i);
                memo[now-i] = 1;
            }
            a--;
            now = n<now+b?n:now+b;
        }
    }
}


Measured memory_bytes: 2944
#include <stdio.h>

int main() {
  int n,m,i,a;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    n-=a;
  }
  if(n>=0) printf("%d\n", n);
  else printf("-1\n");
  return 0;
}


Measured memory_bytes: 1728
#define _GLIBCXX_IOSTREAM
#define maxn 100100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> par;
par s[4][maxn];
int n,l[4],a[maxn],m,tp[4];
ll tot,mx,A[4][maxn],ztot[2];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=2;i<=n;++i)
		if(a[i]>a[i-1]){
			tot+=a[i]-a[i-1],ztot[0]+=a[i-1]+1;
			s[0][++tp[0]]=par(a[i],a[i-1]+1); // [R,L]
			s[1][++tp[1]]=par(a[i-1]+1,a[i]); // [L,R]
		} else if(a[i]<a[i-1]){
			tot+=a[i]+m-a[i-1],ztot[1]+=a[i-1]+1;
			s[2][++tp[2]]=par(a[i-1]+1,a[i]); // [L,R]
			s[3][++tp[3]]=par(a[i],a[i-1]+1); // [R,L] // L<=x||x<=R
		}
	mx=tot;
	for(int i=0;i<4;++i)sort(s[i]+1,s[i]+tp[i]+1);
	for(int i=0;i<4;++i)for(int j=1;j<=tp[i];++j)
		A[i][j]=A[i][j-1]+(i==0||i==3?s[i][j].second:s[i][j].first);
	for(int i=0;i<4;++i)l[i]=0;
	l[1]=l[3]=1;
	for(int i=1;i<=m;++i){
		while(s[0][l[0]+1].first<i&&l[0]<tp[0])l[0]++;
		while(s[1][l[1]].first<=i&&l[1]<=tp[1])l[1]++;
		while(s[2][l[2]+1].first<=i&&l[2]<tp[2])l[2]++;
		while(s[3][l[3]].first<i&&l[3]<=tp[3])l[3]++;
		ll x=1ll*i*(tp[0]-l[0]-(tp[1]-l[1]+1))-ztot[0]+(A[0][l[0]]+A[1][tp[1]]-A[1][l[1]-1]);
		ll y=(1ll*i*l[2]+1ll*(i+m)*(tp[3]-l[3]+1))-(A[2][l[2]]+A[3][tp[3]]-A[3][l[3]-1]);
		mx=min(mx,tot-x-y);
//		printf("[%lld,%lld,%lld,%d]",A[2][l[2]],A[3][tp[3]],y,l[2]+tp[3]-l[3]+1);
//		printf("[%lld,%lld,%d,%d]\n",tot-x-y,-ztot[1]+(A[2][l[2]]+A[3][tp[3]]-A[3][l[3]-1]),l[2],l[3]);
	}
	printf("%lld",mx);
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll n = s.size();
    REP(i, n - 1){
        if(s[i + 1] == s[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

using namespace std;

int main() {
	vector<int>a, b;
	int n, i, j, t, cost;

	cin >> n >> t;
	cost = 1001;

	for (i = 0; i < n; i++) {
		cin >> j;
		a.push_back(j);
		cin >> j;
		b.push_back(j);
	}

	for (i = 0; i < n; i++) {
		if (b[i] <= t) {
			cost = cost > a[i] ? a[i] : cost;
		}
	}

	if (cost == 1001) {
		cout << "TLE";
	}
	else {
		cout << cost;
	}

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
#print(AB)
AB.sort()
#print(AB)
cnt = 0
ans = 0
i = 0
while cnt < M:
    if AB[i][1] > 0:
        ans += AB[i][0]
        AB[i][1] -= 1
        cnt += 1
    else:
        i += 1
print(ans)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n,m,c;
	int b[21],a[21];
	ll total=0;
	int t2=0;

	cin>>n>>m>>c;
	rep(i,m){
		cin>>b[i];
	}
	rep(i,n){
		total=c;
		rep(j,m){
			cin>>a[j];
			total+=a[j]*b[j];
		}
		if(total>0)t2++;
	}
	cout<<t2<<endl;
	return 0;

}


Measured memory_bytes: 256
n = int(input())

a = input().split()

f = 'True'

for i in a:
  if int(i) % 2 == 0:
    if int(i) % 3 != 0 and int(i) % 5 != 0:
      f = 'False'

if f == 'True':
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
a = sorted(a)
for i in range(n):
    if a[i] <= x:
        ans += 1
    x -= a[i]
    
    if x <= 0:
        break

if x > 0 and ans != 0:
    ans -= 1

print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func toI(ss []string) []int {
	ret := make([]int, 0, len(ss))
	for _, s := range ss {
		n, _ := strconv.Atoi(strings.TrimSpace(s))
		ret = append(ret, n)
	}
	return ret
}

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

	reader := bufio.NewReader(os.Stdin)

	A, _ := reader.ReadString('\n')
	B, _ := reader.ReadString('\n')
	C, _ := reader.ReadString('\n')

	a := toI(strings.Split(A, " "))
	b := toI(strings.Split(B, " "))
	c := toI(strings.Split(C, " "))

	sum := 0
	for i := 0; i < n; i++ {
		sum += b[i]
		if i > 0 && a[i-1]+1 == a[i] {
			sum += c[a[i-1]-1]
		}
	}
	fmt.Println(sum)
}


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

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<19;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,c=fetch();
		while(!isdigit(c))c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return a;
	}
}
using ae86::ty;

const int _ = 200003;

int n,loc[_]={0},f[_]={0};

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)loc[ty()]=i;
	int ans=0;
	for(int i=1;i<=n;i++)f[i]=((loc[i]>loc[i-1])?f[i-1]:0)+1,ans=max(ans,f[i]);
	printf("%d\n",n-ans);
	
	return 0;
}


Measured memory_bytes: 2304
K = int(input())
i = input()

A = int(i.split()[0])
B = int(i.split()[1])

flag = 0

for i in range(A, B+1):
  if i % K == 0:
    flag = 1
    break;

if flag == 1:
  print("OK")
else :
  print("NG")
  

Measured memory_bytes: 9172
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>

using namespace std;

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<int> tree(N + 1, 0);
	vector<int> treePa(N + 1, 0);
	for (int i = 0; i < N - 1; ++i) {
		int k1, k2;
		cin >> k1 >> k2;
		treePa[k2] = k1;
	}
	for (int i = 0; i < Q; ++i) {
		int p, x;
		cin >> x >> p;
		tree[x] += p;
	}
	for (int i = 2; i <= N; ++i) {
			tree[i] += tree[treePa[i]];
	}
	for (int i = 1; i <= N; ++i) {
		cout << tree[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];

  vi ans(2,0);
  rep(j,2){
    int t=0;
    rep(i,n){
      t+=a[i];
      if(i%2==j && t<=0){//+
	ans[j]+=abs(t)+1;
	t=1;
      }else if(i%2!=j && t>=0){//-
	ans[j]+=abs(t)+1;
	t=-1;
      }
    }
  }

  cout<<min(ans[0],ans[1])<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, q;
vector<int> a, b, c, d;
int ans;

void printArray(vector<int> A) {
  for (auto x : A) {
    cout << x << " ";
  }
  cout << endl;
}

void func(vector<int> A) {
  if (A.back() > m) {
    return;
  }
  if (A.size() == n + 1) {
    // printArray(A);
    int temp = 0;
    for (int i = 0; i < q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        // cout << "match" << endl;
        temp += d[i];
      }
    }
    ans = max(temp, ans);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    func(A);
    A.back()++;
  }
}
int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  // for (int i = 0; i < q; i++) {
  //   cout << "aa";
  //   cout << a[i] << " " << b[i] << " " << c[i] << " " << d[i] << endl;
  // }
  func(vector<int>(1, 1));

  cout << ans << endl;
}

Measured memory_bytes: 3612
from heapq import heappush, heappop

x,y,z,k = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
    
hq = []
val = A[0]+B[0]+C[0]
heappush(hq, (-val,0,0,0))
done = [[0,0,0]]

for i in range(k):
    ans, a, b, c = heappop(hq)
    print(-ans)
    
    if [a+1, b, c] not in done and a+1 < x:
        heappush(hq, (-(A[a+1]+B[b]+C[c]), a+1, b, c))
        done.append([a+1, b, c])
    if [a, b+1, c] not in done and b+1 < y:
        heappush(hq, (-(A[a]+B[b+1]+C[c]), a, b+1, c))
        done.append([a, b+1, c])
    if [a, b, c+1] not in done and c+1 < z:
        heappush(hq, (-(A[a]+B[b]+C[c+1]), a, b, c+1))
        done.append([a, b, c+1])

Measured memory_bytes: 4596
N = int(input())
p = N
s = []
abt = "abcdefghijklmnopqrstuvwxyz"
ans = ""

while p > 0:
   p -= 1
   s.append(p % 26)
   p //= 26

for i in s[::-1]:
    ans += abt[i]

print(ans)


Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long k;
    long long a,b;
    cin>>k;
    cin>>a>>b;
    bool flag = false;
    for (int i = a;i<=b;i++){
        if (i%k==0)flag = true;
    }
    if (flag)cout<<"OK";
    else cout<<"NG";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
    using namespace std;
     
	int price,iti;


    int main() {
      cin >> price >> iti;
      
      if ( price % 500 - iti <= 0) {
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }

    }

Measured memory_bytes: 256
// Author : Chi
// created :
// Sawal : Practice

//header files
#include <bits/stdc++.h>
#include "cmath"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//namespaces
using    namespace __gnu_pbds;
using    namespace std;
typedef tree <pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

//macros
#define ll 		    long long
#define ull         unsigned long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb(x)       push_back(x)
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         1000000007
#define aLL(x)      x.begin(),x.end()
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define ai(a)       for(auto &i:a)cin>>i;
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define db(...)     __f(#__VA_ARGS__, __VA_ARGS__)                      //for debugging
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
//LOVE ALGO
ll dp[410][410];
ll rec(int s,int e,ll *a,ll *pre){
    if(s==e)
        return 0;
    if(dp[s][e]!=-1)
        return dp[s][e];
    ll ans = 1e18;
    for(int i=s;i<e;i++)
        ans=min(ans,pre[e]-pre[s-1]+rec(s,i,a,pre)+rec(i+1,e,a,pre));
    return dp[s][e]=ans;
}
void solve(){
    int n;
    cin>>n;
    ll a[n+1];
    memset(dp,-1,sizeof dp);
    r1n(i,n)
        cin>>a[i];
    ll pre[n+1];
    pre[0]=0;
    r1n(i,n){
        pre[i]=pre[i-1];
        pre[i]+=a[i];
        }
    cout << rec(1,n,a,pre) << "\n";
}

// Driver Code
int main(){
    CHI
    TEST1
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;

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

    while(true){
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(a == 0) break;

      int n = sc.nextInt();
      while(n-- > 0){
        int r = 2 * sc.nextInt();
        r *= r;
        if(r > a*a+b*b || r > a*a+c*c || r > b*b+c*c){
          System.out.println("OK");
        }
        else{
          System.out.println("NA");
        }
      }
    }
  }
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll dp[2][100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string L;
    cin >> L;
    int n = L.size();

    dp[1][0] = 1;
    for (int i = 0; i < n; i++) {
        (dp[0][i + 1] += dp[0][i] * 3 % MOD) %= MOD;
        if (L[i] == '0') {
            dp[1][i + 1] = dp[1][i];
        } else {
            dp[1][i + 1] = dp[1][i] * 2 % MOD;
            (dp[0][i + 1] += dp[1][i]) %= MOD;
        }
    }
    cout << (dp[0][n] + dp[1][n]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 2000
/*
考虑一个排列造出来的树，
找规律知，其以所有后缀 min 作为主干依次连接，其余点与后面第一个树干上的位置连边；
据此规律，直接拿出模板树的直径进行构造即可。 
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int n, pu, pv, mxdep;
vector<int> fa;
vector<vector<int>> G;

void dfs(int u, int par, int dep)
{
	if(!pu || dep > mxdep)
		mxdep = dep, pu = u;
	for(auto &v : G[u])
		if(v ^ par)
			dfs(v, u, 1 + dep);
}

void dfs1(int u, int par, int dep)
{
	if(!pv || dep > mxdep)
		mxdep = dep, pv = u;
	fa[u] = par;
	for(auto &v : G[u])
		if(v ^ par)
			dfs1(v, u, 1 + dep);
}

int main()
{
	scanf("%d", &n);
	G.resize(n + 1);
	for(int i = 1, a, b; i < n; ++i)
	{
		scanf("%d %d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(1, 0, 0);
	fa.resize(n + 1);
	dfs1(pu, 0, 0);
	vector<int> v, a, b;
	for(int x = pv; x; x = fa[x]) v.push_back(x);
	int ind = 0;
	for(auto &p : v)
	{
		int t = G[p].size() + 1 - (p != v.front()) - (p != v.back()), nn = ++ind;
		for(int j = t - 1; j; --j) a.push_back(++nn);
		a.push_back(ind), ind = nn;
	}
	reverse(v.begin(), v.end());
	ind = 0;
	for(auto &p : v)
	{
		int t = G[p].size() + 1 - (p != v.front()) - (p != v.back()), nn = ++ind;
		for(int j = t - 1; j; --j) b.push_back(++nn);
		b.push_back(ind), ind = nn;
	}
	
	if((int)a.size() != n || (int)b.size() != n)
		return puts("-1"), 0;
	
	for(int i = 0; i < n; ++i)
	{
		if(a[i] < b[i]) break;
		if(b[i] < a[i]) { a.swap(b); break; }
	}
	
	for(auto x : a) printf("%d ", x);
}

Measured memory_bytes: 12664
# ABC089D - Practical Skill Test
def main():
    H, W, D, *X = map(int, open(0).read().split())
    memo = [None] * (H * W + 1)  # memo[x] := coordinate of x
    for i, a in enumerate(zip(*[iter(X[: H * W])] * W), 1):
        for j, x in enumerate(a, 1):
            memo[x] = (i, j)
    dist = [0] * (H * W + 1)  # dist[x] := distance to x from 1
    for r in range(D + 1, H * W + 1):
        rx, ry = memo[r]
        l = r - D
        lx, ly = memo[r - D]
        dist[r] = dist[l] + abs(rx - lx) + abs(ry - ly)
    ans = []
    for l, r in zip(*[iter(X[H * W + 1 :])] * 2):
        ans.append(dist[r] - dist[l])
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll MOD = 1000000007;//大きい素数


//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}


int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll l=min(n,b-1);
    ll sum=(a*l)/b;
    cout<<sum<<endl;
  
    return 0;
}


Measured memory_bytes: 3632
/**
 * author:    Ziel
 * created:   23.04.2020 20:19:46
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int dp[N];
bool was[N];
vector<vector<int>> g(N);

int dfs(int v) {
    if (was[v]) return dp[v];
    was[v] = true;
    int res = 0;
    for (int to: g[v]) {
        res = max(res, dfs(to) + 1);
    }
    return (dp[v] = res);
}

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
    int n, m;
    cin >> n >> m;
    for (int i = 0, x, y; i < m; i++)
        cin >> x >> y, g[y].pb(x);
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (!was[i]) ans = max(ans, dfs(i));
    cout << ans;
    
	return 0;
}

/*
	Raise your standard.
*/


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define bug(x) cout << #x << " = " << x << endl
using namespace std;
typedef long long int ll;

int main(){
    int x,y;
    map<int,int> mp;
    cin>>x>>y;
    for(int i=1;i<=12;i++){
        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) mp[i]=1;
        else if(i==2) mp[i]=2;
        else mp[i]=3;
    }
    if(mp[x]==mp[y]) cout<<"Yes";
    else cout<<"No";
	return 0;
}


Measured memory_bytes: 384
/**
*    created: 30.06.2020 17:02:04
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    if (b >= a) cout << a << endl;
    else cout << a-1 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  cout << n/3;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
zoro = []
for _ in range(N):
    a, b = map(int, input().split())
    zoro.append(a == b)

for i in range(N - 2):
    if zoro[i] and zoro[i + 1] and zoro[i + 2]:
        print("Yes")
        exit()
        
print("No")

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec l = ivec(n);
    sort(all(l));
    int cnt = 0;
    For(i, 0, n - 1) {
        For(j, i + 1, n - 1) {
            int out = l[i] + l[j];
            int lim = distance(l.begin(), lower_bound(all(l), out)) - 1;
            cnt += max(0LL, lim - j);
        }
    }
    print(cnt);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        for(int i = 1; i <= 5; i++){
            int x = Integer.parseInt(sc.next());
            if(x == 0){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 35624
S=input()
k="keyence"
ans=False
if len(S)<len(k):
  ans=False
elif S[:len(k)]==k or S[-len(k):]==k:
  ans=True
else:
  for i in range(len(S)):
    if S[i]==k[i]:
      continue
    else:
      break
  rest=k[i:]
  if S[-len(rest):]==rest:
    ans=True
  else:
    ans=False
print(("NO","YES")[ans])

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

int main(){
    string W,T;
    cin>>W;
    int ans=0;
    while(cin>>T){
        if(T=="END_OF_TEXT") break;
        
        for(int i=0;i<T.size();i++){
            T[i]=tolower(T[i]);
        }
        ans += T==W;  
    }cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    bool is = false;
    int a, b;

    cin >> a >> b;
    for (int c = 1; c <= 1; ++c) {
        if (a * b * c % 2 == 1) is = true;
    }

    if (is) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] sumMod = new int[N+1];
    for (int i = 1; i <= N; i++) {
      int A = sc.nextInt();
      sumMod[i] = (A+sumMod[i-1])%M;
    }
    
    Map<Integer, Integer> map = new HashMap<>();
    long ans = 0;
    for (int i = 0; i <= N; i++) {
      int count = map.getOrDefault(sumMod[i], 0);
      ans += count;
      map.put(sumMod[i], count+1);
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 53056
#include<stdio.h>
#include<math.h>
using namespace std;

#define PI 3.1415926535

struct point{
    double x, y;
};

void koch(int n, point p1, point p2){
    if ( n == 0 ) return;
    point s, t, u;
    double rad = 60.0 * PI / 180.0;
    
    s.x = ( 2.0 * p1.x + p2.x) / 3.0;
    s.y = ( 2.0 * p1.y + p2.y) / 3.0;
    t.x = ( p1.x + 2.0 * p2.x) / 3.0;
    t.y = ( p1.y + 2.0 * p2.y) / 3.0;
    u.x = ( t.x - s.x ) * cos(rad) - ( t.y - s.y ) * sin(rad) + s.x;
    u.y = ( t.x - s.x ) * sin(rad) + ( t.y - s.y ) * cos(rad) + s.y;
    
    koch( n - 1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch( n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch( n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch( n - 1, t, p2);
    
}

int main(){
    point p1, p2;
    int n;
    
    scanf("%d", &n);
    
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
    
    printf("%.8f %.8f\n", p1.x, p1.y);
    koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    
    return 0;
}


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

int main() {
  string s, t;

  cin >> s >> t;

  int len = s.length();
  int ans = 0;

  for (int i=0;i<len;i++) {
    if (s[i] == t[i]) {

    }
    else {
      ans++;
    }
  }

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


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int32 N;
int32 x[3], xs;
int64 dp[41][1<<18] = {};
bool ok[1 << 18] = {};

bool judge(int32 bit, const vector<int32>& v){
	int32 sum = 0, suc = 0;
	REP(i, v.size()){
		if(sum+v[i] == x[suc]){suc++;sum=0;}
		else if(sum+v[i] > x[suc]){suc=-1;break;}
		else{sum+=v[i];}
	}
	return (suc == 3);
}

void init(){
	REP(nbit, 1 << 18){
		vector<int32> u, v;
		u.push_back(0);
		REP(i, 18){
			if((nbit >> i) & 1){
				u.push_back(i+1);
			}
		}
		for(int32 i = u.size()-1;i > 0;i--){
			v.push_back(u[i]-u[i-1]);
		}
		ok[nbit] = judge(nbit, v);
	}
}

int64 dfs(int32 d=0, int32 bit=0){
	if(~dp[d][bit]) return dp[d][bit];
	int64 &res = dp[d][bit];
	if(d == N) return res = 1;
	res = 0;
	for(int32 i = 1;i <= 10;i++){
		int32 nbit = ((bit << i) | (1 << (i-1)))&((1<<xs)-1);
		if(!ok[nbit]){
			res += dfs(d+1, nbit);
			res %= mod;
		}
	}
	return res;
}

int64 mpow(int64 a, int64 b){
	if(b==0) return 1;
	if(b%2) return a*mpow(a, b-1)%mod;
	int64 ret = mpow(a, b/2);
	return ret*ret%mod;
}

int main(void){
	cin >> N;
	REP(i, 3) cin >> x[i];
	xs = x[0]+x[1]+x[2];
	init();
	memset(dp, -1, sizeof dp);
	cout << (mpow(10, N)-dfs()+mod)%mod << endl;
}

Measured memory_bytes: 84480
h, w = map(int, input().split())

li = []
for i in range(h):
    str = list(input())  # 1文字区切りでリスト格納
    li.append(str)

flg = True


# 縦に見ていく
for i in range(w):
    flg2 = True
    for j in range(h):
        if li[j][i] == "#":
            flg2 = False
            break
    
    if flg2:
        for j in range(h):
            li[j][i] = "a"

for i in range(h):
    flg2 = True
    for j in range(w):
        if li[i][j] == "#":
            flg2 = False
            break
    if flg2:
        for j in range(w):
            li[i][j] = "a"

    
for i in range(h):
    flg3 = False
    for j in range(w):
        if li[i][j] != "a":
            print(li[i][j], end ="")
            flg3=True
    
    if flg3:
        print()


Measured memory_bytes: 4596
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    int k,a,b,i,flag=0;
    cin>>k;
    cin>>a>>b;
    for(i=a;i<=b;i++){
      if(i%k==0){
        flag=1;
        break;
      }
    }
    if(flag)
      cout<<"OK"<<endl;
    else
      cout<<"NG"<<endl;
    }


Measured memory_bytes: 3648