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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;
#define MOD 1000000007


int ifAGC(const string &s) {
    REP(s.size()){
        string tmp = s;
        if (i >= 1) {
            swap(tmp[i],tmp[i-1]);
        }
        auto f = tmp.find("AGC");
        if (f != string::npos) return 0;
    }
    return 1;
}


int main(void)
{
    IOS
    const string ACGT = "ACGT";
    int n;
    cin >> n;
    map<string,map<int,int>> dp;
    vector<string> last3;

    for(const char &c:ACGT) {
        string s = {c};
        for(const char &d:ACGT) {
            string s2 = s + d;
            for(const char &e:ACGT) {
                string s3 = s2 + e;
                last3.emplace_back(s3);
                dp[s3][3] = ifAGC(s3);
            }
        }
    }

    auto countdp = [&](int x) {
        int r = 0;
        for(const string &s:last3) {
            //cerr << s << ":" << dp[s][x]<< endl;
            r = (r + dp[s][x]) % MOD;
        }
        return r;
    };

    if (n < 3) {
        cout << (int) pow(4,n) << endl;
    } else if (n == 3) {
        cout << countdp(3) << endl;
    } else {
        FOR(i,3,n) {
            for(const string &s:last3) {
                for(const char &c:ACGT) {
                    string tmp = s + c;
                    //cerr << tmp << endl;
                    dp[tmp.substr(1,3)][i+1] = (dp[tmp.substr(1,3)][i+1] + dp[s][i] * ifAGC(tmp)) % MOD;
                }
            }
        }
        cout << countdp(n) << endl;
    }


    return 0;
}


Measured memory_bytes: 512
As,Bs=input().split()
N=int(As)
M=int(Bs)
ans=0

Alist=input().split()#All num
Alist.pop(0)
for i in range(N-1):
    Slist=input().split()
    Slist.pop(0)
    Alist=Alist+Slist

ASlist=list(set(Alist))#set num

for W in ASlist:
    # print(ASlist.count(W))
    if Alist.count(W)==N:
        ans=ans+1
        

print(ans)

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

#define MOD 1e9+7;

int main(){
    int n;
    cin>>n;
    double a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<vector<double>>dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        double head=a[i];
        double tail=1-a[i];
        dp[i][0]=tail*dp[i-1][0];
        for(int j=1;j<=i;j++){
            dp[i][j]=dp[i-1][j-1]*(head)+dp[i-1][j]*(tail);
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++){
        ans+=dp[n][i];
    }
    cout<<setprecision(9)<<ans<<"\n"; 
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
uint N;
cin >> N;
printf("ABC%03u", N);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000


void calc(int n){

  if(n%1111 == 0){
    puts("NA");
    return;
  }

  char l[5], s[5];

  for(int i=0;;i++){
    if(n == 6174){
      printf("%d\n",i);
      break;
    }
    
    sprintf(l,"%04d",n);
    sprintf(s,"%04d",n);
    
    sort(l,l+4);
    sort(s,s+4);
    reverse(l,l+4);
    
    n = atoi(l) - atoi(s);
  }

}
  

int main(){

  int n;

  while(scanf("%d",&n)!=EOF){
    if(n==0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>

#include <vector>

#include <string>

#include <algorithm>

#include <cmath>



int main(){

	char C1,C2,C3,C4,C5,C6;

	std::cin >> C1 >> C2 >> C3;
	std::cin >> C4 >> C5 >> C6;
	if(C1==C6&&C2==C5&&C3==C4){

		std::cout << "YES" << std::endl;
	}else{
		std::cout << "NO" <<std::endl;
	}

	return 0;

} 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

const ull M = 998244353;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ull> l(k), r(k);
    for(int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
    }
    vector<ull> ans(n, 0);
    ans[0] = 1;
    ull s = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < k; j++) {
            if (i >= l[j]) {
                s = (s + ans[i-l[j]]) % M;
            }
            if (i > r[j]) {
                s = (s + M - ans[i-r[j]-1]) % M;
            }
        }
        ans[i] = s;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  bool ans = true;
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        ans = false;
      }
    }
  }
  
  if(ans) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input()) #勇者の数
A = list(map(int,input().split()))
B = list(map(int,input().split()))
# A:モンスターの数(A1~An+1) B:倒せる数(B1~Bn)

count = 0
for i in range(N):
  if A[i] + A[i+1] <= B[i]:
    count += A[i] + A[i+1]
    A[i+1] = 0
  elif A[i] + A[i+1] > B[i] and A[i] <= B[i]:
    A[i+1] = A[i+1] - (B[i] - A[i])
    count += B[i]
  else:
    count += B[i]
print(count)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
vector<P> ans;
void pr(int A,int C){
  int d  = __gcd(A,C);
  A/=d,C/=d;
  if(C<0) A*=-1;
  ans.push_back(P(abs(C),-A));
}

void solve(int a,int b,int c){
  if(b*b - 4*a*c < 0 ){cout<<"Impossible"<<endl;return;}
  if((int)sqrt(b*b-4*a*c) != sqrt(b*b-4*a*c)){cout<<"Impossible"<<endl;return;}
  int A = -b+sqrt(b*b-4*a*c);
  int B = -b-sqrt(b*b-4*a*c);
  int C = 2*a;
  pr(A,C);
  pr(B,C);
}

signed main(){
  while(1){
  int a,b,c;
  cin>>a>>b>>c;
  if(!a&&!b&&!c)break;
  ans.clear();
  solve(a,b,c);
  if(ans.empty())continue;

  if(ans[0].first<ans[1].first) swap(ans[0],ans[1]);
  else if(ans[0].first==ans[1].first && ans[0].second<ans[1].second) swap(ans[0],ans[1]);

  cout<<ans[0].first<<" "<<ans[0].second<<" ";
  cout<<ans[1].first<<" "<<ans[1].second<<endl;
  
  }
  return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <functional>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 100050;
int N;
long long L[MAX_N], R[MAX_N];

long long solve() {

    std::vector<int> lp, rp;
    for (int i = 1; i <= N; i++) {
        lp.push_back(i);
        rp.push_back(i);
    }
    std::sort(lp.begin(), lp.end(),
        [](const int a, const int b) { return L[a] > L[b]; }
    );
    std::sort(rp.begin(), rp.end(),
        [](const int a, const int b) { return R[a] < R[b]; }
    );

    long long ret = 0;
    long long cur = 0;
    int lv = 0;
    int rv = 0;

    while (true) {
        if (lv == rv) {
            if (cur < L[lp[lv]]) {
                ret += L[lp[lv]] - cur;
                cur = L[lp[lv]];
                lv++;
            } else {
                ret += labs(cur);
                break;
            }
        } else {
            if (R[rp[rv]] < cur) {
                ret += cur - R[rp[rv]];
                cur = R[rp[rv]];
                rv++;
            } else {
                ret += labs(cur);
                break;
            }
        }
    }

    return ret;
}

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> L[i] >> R[i];
    }

    long long ret = solve();

    std::swap(L, R);
    for (int i = 1; i <= N; i++) {
        L[i] = -L[i];
        R[i] = -R[i];
    }

    ret = std::max(ret, solve());

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 3068
H, W = gets.chomp.split(" ").map(&:to_i)
G = Array.new(H).map{
  gets.chomp.split(" ").map{|x| x.to_i.even?}
}

ans = []
(0..(H-2)).each{|h|
  (0..(W-2)).each{|w|
    if !G[h][w] && !G[h+1][w] then
      ans << [h+1, w+1, h+2, w+1]
      G[h][w] = true
      G[h+1][w] = true
    elsif !G[h][w] then
      ans << [h+1, w+1, h+1, w+2]
      G[h][w] = true
      G[h][w+1] = !G[h][w+1]
    end
  }
  if !G[h][W-1] then
    ans << [h+1, W, h+2, W]
    G[h][W-1] = true
    G[h+1][W-1] = !G[h+1][W-1]
  end
}
(0..(W-2)).each{|w|
  if !G[H-1][w] then
    ans << [H, w+1, H, w+2]
    G[H-1][w] = true
    G[H-1][w+1] = !G[H-1][w+1]
  end
}

puts ans.size
puts ans.map{|a| a*?\s}*?\n


Measured memory_bytes: 50172
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;


int main()
{	
	int a,b,c,d,e;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	if(c>d){e=c; c=d; d=e;}
	if(b>c){e=b; b=c; c=e;}
	if(a>b){e=a; a=b; b=e;}
	if(c>d){e=c; c=d; d=e;}
	if(b>c){e=b; b=c; c=e;}
	if(c>d){e=c; c=d; d=e;}
	
	if((a==1)&&(b==4)&&(c==7)&&(d==9))
	{	printf("YES");}
	else
	{	printf("NO");}
}


Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<algorithm>
int P(int x)
{
	if(x<2)return 0;
	if(x==2)return 1;
	if(x%2==0)return 0;
	for(int i=3;i*i<=x;i+=2)if(x%i==0)return 0;
	return 1;
}
int main()
{
	int m,p,i,j,s;
	while(scanf("%d%d",&m,&p),p>0)
	{
		std::vector<int>u,v;
		for(i=m+1;s=u.size(),s<p;++i)if(P(i))u.push_back(i);
		for(i=0;i<s;++i)for(j=i;j<s;++j)v.push_back(u[i]+u[j]);
		std::sort(v.begin(),v.end());
		printf("%d\n",v[p-1]);
	}
	return 0;
}

Measured memory_bytes: 868
n = int(input())
base = list(map(int,input().split()))
even = [0]*(10**5)
odd = [0]*(10**5)

for i in range(1,n+1):
  sign = i%2
  num = base[i-1]
  
  if sign == 0:
    even[num-1] += 1
  elif sign == 1:
    odd[num-1] += 1

ans_e = max(even)
ans_o = max(odd)
even_i = even.index(ans_e)
odd_i = odd.index(ans_o)

if even_i == odd_i:
  even.sort()
  odd.sort()
  if even[10**5 - 2] <= odd[10**5 - 2]:
    ans_o = odd[10**5 - 2]
  else:
    ans_e = even[10**5 - 2]
  
print(n - ans_e - ans_o)

Measured memory_bytes: 14404
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int list[20];
int func(int n,int a,int b){
	if(n == -1){
		return (a>b)?(a-b):(b-a);
	}
	return min(func(n-1,a+list[n],b),func(n-1,a,b+list[n]));
}
int main(){
	int n;
	while(cin >> n,n){
		memset(list,0,sizeof(list));
		for(int i = 0; i < n; i++){
			scanf("%d",&list[i]);
		}
		int ans = func(n,0,0);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  bool check=false;
  for(int i=0;i<S.size();i++){
    if(S.substr(i,S.size()-i)==T.substr(0,S.size()-i)&&S.substr(0,i)==T.substr(S.size()-i,i)){
      check = true;
      break;
    }
  }
  if(check) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,-1,0,1},dy[]={0,-1,-1,0,1,1};	// truss

struct P{ int x,y; P(int Y,int X):x(X),y(Y){} };

int n,node[10][10];

bool inrange(int i,int j){ return (0<=i && i<n && 0<=j && j<=i); }

int calcScore(int c){
	int score=0;

	bool visited[10][10]={};
	rep(i,n)rep(j,i+1)if(node[i][j]!=0 && !visited[i][j]){
		int num=node[i][j];
		visited[i][j]=true;

		int cnt=0;
		bool fill=true;
		queue<P> qu;	qu.push(P(i,j));
		while(!qu.empty()){
			P a=qu.front();	qu.pop();
			rep(i,6){
				int xx=a.x+dx[i],yy=a.y+dy[i];
				if(inrange(yy,xx) && node[yy][xx]==0){ fill=false; break; }
			}
			cnt++;

			rep(i,6){
				int xx=a.x+dx[i],yy=a.y+dy[i];
				if(inrange(yy,xx) && !visited[yy][xx] && node[yy][xx]==num){
					qu.push(P(yy,xx));
					visited[yy][xx]=true;
				}
			}
		}

		if(fill){
			if(num==c)	score-=cnt;
			else		score+=cnt;
		}
	}

	return score;
}

int main(){
	for(int c;scanf("%d%d",&n,&c),n;){
		rep(i,n)rep(j,i+1)	scanf("%d",node[i]+j);

		int ans=-INF;
		rep(i,n)rep(j,i+1)if(node[i][j]==0){
			node[i][j]=c;
			ans=max(ans,calcScore(c));
			node[i][j]=0;
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  char b;
  cin >> b;
  map<char, char> m = {{'A','T'},{'T','A'},{'C','G'},{'G','C'}};
  cout << m[b] << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
h += 2; w += 2
maze = "#" * w
for _ in range(h-2):
    maze += "#" + input() + "#"
maze += "#" * w

def bfs(start):
    INF = h*w+1
    dist = [INF] * (h*w)
    dist[start] = 0
    q = deque([start])
    while q:
        cur_loc = q.popleft()
        cur_val = dist[cur_loc]
        for move in (-1,1,w,-w):
            next_loc = cur_loc + move
            if maze[next_loc] == "#":
                continue
            next_val = cur_val + 1
            if next_val >= dist[next_loc]:
                continue
            dist[next_loc] = next_val
            q.append(next_loc)
    return max(x for x in dist if x < INF)

ans = max(bfs(start) for start in range(h*w) if maze[start] != "#")
print(ans)

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

int main(int argc, char const *argv[]) {
    long long n;
    cin >> n;

    long long ans = 1e17;
    for (long long i = 1; i * i <= n; i++) {
        if (n%i == 0) {
            long long d = i+n/i-2;
            ans = min(ans, d);
        }
    }

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


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

typedef long long ll;

int main() {
	int N; cin >> N;
	int i = 1, mult = 1;
	ll ans = 0;
	while (i < N) {
		if (i * mult >= N) {
			i++; mult = 1; 
			if (i * mult >= N) { break; }
		}
		ans++; mult++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;

int a[55];

int main () {

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

	int n;
	cin >> n;
	int k = 0;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		if (i != a[i]) k ++;
	}
	
	if (k <= 2) cout << "YES";
	else cout <<"NO";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <inttypes.h>
using namespace std;
#define INF 0x3f3f3f3f
//int arr[]={1,2,4,8,16,32,64};
int main(){
    int n;
    scanf("%d", &n);
    int res;
    if (n == 1) res = 1;
    else if ( n == 2) res = 2;
    else if ( n <= 3) res = 2;
    else if ( n <= 7) res = 4;
    else if ( n <= 15) res = 8;
    else if ( n <= 31) res = 16;
    else if ( n <= 63) res = 32;
    else if ( n <= 127) res = 64;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 128
/*
	https://www.youtube.com/watch?v=766qmHTc2ro
*/
#include <bits/stdc++.h>
using namespace std;

#define ld long double
#define ull unsigned long long
#define ll long long
#define ss string
#define vt vector
#define pii pair <int,int>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define pll pair <ll,ll>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define sz(x) (int) x.size()
#define bcc __builtin_popcount
#define bll __builtin_popcountll
void ___(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
void data(){
	freopen("name.in","r",stdin);
	freopen("name.out","w",stdout);
}
const int N = 3e5 + 500;
const ll INF = 1e18;
const int mod = 1e9 + 7;


int main()
{
	//data();
	___();
	
	
	ss s;
	cin >> s;
	ll r = 0;
	for(int i = 0; i < sz(s); i++){
		r += s[i] - '0';
	}
	if(r % 9 == 0){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	
	return 0;
}




Measured memory_bytes: 3768
#!/usr/bin/python
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	a=[e-c for e in a]
	heappush(a,x)
	r+=c
print(r)

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

using namespace std;

int digit(long long a) {
    long long buf = a / 10;
    int count = 1;
    while (buf > 0) {
        buf /= 10;
        count++;
    }
    return count;
}

void dfs(long long maker, int &count, int i, int dig, bool flag_3, bool flag_5, bool flag_7, bool put_0, long long n) {
    if (i == dig) {
        if ((!flag_3) || (!flag_5) || (!flag_7)) return;
        if (maker <= n) {
            count++;
        }
        return;
    }
    if (put_0) dfs(maker, count, i+1, dig, flag_3, flag_5, flag_7, true, n);
    dfs(maker+3*(long long)pow(10, dig-i-1), count, i+1, dig, true, flag_5, flag_7, false, n);
    dfs(maker+5*(long long)pow(10, dig-i-1), count, i+1, dig, flag_3, true, flag_7, false, n);
    dfs(maker+7*(long long)pow(10, dig-i-1), count, i+1, dig, flag_3, flag_5, true, false, n);
}

int main () {
    long long n = 0;
    cin >> n;
    int dig = digit(n);
    int count = 0;
    dfs(0, count, 0, dig, false, false, false, true, n);
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
//エラトステネスの篩

#include<iostream>
using namespace std;

int prime[10000000];

int main()
{

    for(int i=0; i<10000000; i++){
      prime[i] = i+1;
      if(i==0)
        prime[0] = 0;
    }
    
    for(int i=1; i<10000000; i++){     
      if(prime[i]!=0){
         i++;
        for(int j=2; i*j<10000000; j++){
          prime[i*j-1] = 0;
         }
         i--;  
       } 
     }




  while(1){
  
    int n;
    
    cin >> n;
    
    if(n==0)
      return 0;
       
     while(n>=13){
       if(prime[n-1]!=0 && prime[n-3]!=0 && prime[n-7]!=0 && prime[n-9]!=0){
         cout  << prime[n-1] << endl;
         break;
       }
       n--;
     }
     
  } 
    
    
    


}

Measured memory_bytes: 40220
from collections import Counter

iN = int(input())
aV = [int(_) for _ in input().split()]

oV0 = Counter(aV[0::2]).most_common(2)
oV1 = Counter(aV[1::2]).most_common(2)
oV0 += [(0,0)]
oV1 += [(0,0)]

if oV0[0][0] != oV1[0][0] :
    print(iN - oV0[0][1] - oV1[0][1])
else:
    print(iN - max(oV0[0][1],oV1[0][1]) - max(oV0[1][1],oV1[1][1]))


Measured memory_bytes: 15588
s = input()

N_in = ('N' in s)
S_in = ('S' in s)
E_in = ('E' in s)
W_in = ('W' in s)

bl = ((N_in and S_in) or (not N_in and not S_in)) and ((E_in and W_in) or (not E_in and not W_in))

print('Yes' if bl else 'No')


Measured memory_bytes: 3060
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main(void) {
    int n, r;
    while (cin >> n >> r) {
        if (n == 0 && r == 0) break;
        int card[n];
        for (int i = 0; i < n; i++) {
            card[i] = n-i;
        }
        for (int i = 0; i < r; i++) {
            int p, c;
            cin >> p >> c;
            p--;
            int buf[n];
            int ue[n];
            int cur = 0;
            for (int j = 0; j < n; j++) {
                if (j < p || j >= p+c) {
                    buf[cur] = card[j];
                    cur++;
                }
            }
//            for (int j = 0; j < cur; j++) cout << buf[j] << " ";
//            cout << endl;
            for (int j = 0; j < c; j++) {
                ue[j] = card[p+j];
            }
            for (int j = 0; j < c; j++) card[j] = ue[j];
            for (int j = c; j < n; j++) card[j] = buf[j-c];
        }
//        for (int i = 0; i < n; i++) cout << card[i] << " ";
//        cout << endl;
        cout << card[0] << endl;
    }
    return 0;
}

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

int main() {
	string INS, OUTS = "";
	cin>>INS;
	for(int i=0; i<INS.size(); i++){
		if(INS[i] == '0') OUTS += '0';
		if(INS[i] == '1') OUTS += '1';
		if(INS[i] == 'B') OUTS = OUTS.substr(0,OUTS.size()-1);
	}
	cout<<OUTS<<endl;
}

Measured memory_bytes: 764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStationAndBus solver = new AStationAndBus();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStationAndBus {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] c = in.next().toCharArray();
            Arrays.sort(c);
            out.println(c[0] == c[c.length - 1] ? "No" : "Yes");
        }

    }
}



Measured memory_bytes: 19924
from collections import deque
import sys
import time
def input(): return sys.stdin.readline().strip()

DEBUG = False

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

friend_relations = [[] for _ in range(N+1)]
block_relations = [[] for _ in range(N+1)]

num_connected_friends = [0] * (N+1)
num_connected_blocks = [0] * (N+1)

for _ in range(M):
    A, B = map(int, input().split())
    friend_relations[A].append(B)
    friend_relations[B].append(A)

for _ in range(K):
    C, D = map(int, input().split())
    block_relations[C].append(D)
    block_relations[D].append(C)

if DEBUG:
    print("friend_relations:")
    for i, row in enumerate(friend_relations):
        print("node: {}, relation: {}".format(i, row))
    print("block_matrix:")
    for i, row in enumerate(block_relations):
        print("node: {}, relation: {}".format(i, row))

count = 0
labels = [-1] * (N+1)
graph_sizes = []
total_iteration = 0
for n in range(1, N+1):
    if DEBUG:
        print("root_node: {}, count: {}".format(n, count))
    if labels[n] == -1:
        queue = deque([n])
        labels[n] = count
        size = 0
        while queue:
            if DEBUG:
                print("queue:{}".format(queue))
            node = queue.popleft()
            size += 1
            if DEBUG:
                print("node:{}".format(node))
            for next_node in friend_relations[node]:
                total_iteration += 1
                if labels[next_node] == -1:
                    labels[next_node] = count
                    queue.append(next_node)
            if DEBUG:
                print("labels: {}".format(labels))
            # time.sleep(0.2)
        count += 1
        graph_sizes.append(size)
if DEBUG:
    print("total_iteration: {}".format(total_iteration))
    print("labels: {}".format(labels))
    print("graph_sizes: {}".format(graph_sizes))

friend_candidate = [0] * (N+1)
for n in range(1, N+1):
    num_block = sum([1 for i in block_relations[n] if labels[n] == labels[i]])
    num_frined = len(friend_relations[n])
    if DEBUG:
        print("node: {}, num_frined: {}, num_block: {}".format(n+1, num_frined, num_block))
    friend_candidate[n] = graph_sizes[labels[n]] - num_frined - num_block - 1

print(*friend_candidate[1:])


Measured memory_bytes: 48700
<?php
fscanf(STDIN, '%d %d', $a, $b);
if ($b === 1) {
    echo (0) . PHP_EOL;
    exit();
}
if ($a >= $b) {
    echo (1) . PHP_EOL;
    exit();
}
$ans = 1 + (int)ceil(($b - $a)  / ($a - 1));
echo $ans . PHP_EOL;

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

string s;

int main(){

    cin >> s;

    for(int i = 0; i < s.size(); i++){
        if(s[i] == '9'){
            s[i] = '1';
        } else if(s[i] == '1'){
            s[i] = '9';
        }
    }

    cout << s;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	println(a + b / 2);
}

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

int main()
{
  int N, M;

  cin >> N >> M;

  vector<int> vec(N);

  for (int i = 0; i < N; i++)
    cin >> vec.at(i);

  int sum = accumulate(vec.begin(), vec.end(), 0);

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  cout << (vec.at(M - 1) * 4 * M >= sum ? "Yes" : "No") << endl;
}


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

int main(){
  
  int N,x;
  cin >> N >> x;
  int a[N];
  for(int i=0;i<N;i++){cin >> a[i];}
  
  sort(a,a+N);
  
  if(x<a[0]){cout << 0 << endl; return 0;}
  
  int ch=0;
  int ans=0;
  for(int i=0;i<N;i++){
    if(a[i]>x){cout << ans << endl;return 0;}
    ans++;
    x = x - a[i];
  }
  if(x!=0){ans--;}
  cout << ans << endl; 
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll A, B, C;
ll i, j, k;
int main(){
    scanf("%lld%lld%lld", &A,&B,&C);
    if(A+B>C){
        printf("No");
        return 0;
    }
    i = C - A - B;

    if(4*A*B<i*i){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
R = []
G = []
B = []
RD = {}
GD = {}
BD = {}

S = input().rstrip()

for i, s in enumerate(S):
    if s == "R":
        R.append(i)
        RD[i*2] = 1
    if s == "G":
        G. append(i)
        GD[i*2] = 1
    if s == "B":
        B.append(i)
        BD[i*2] = 1

ans = len(R) * len(G) * len(B)
for r in R:
    for b in B:
        if r + b in GD:
            ans -= 1
for b in B:
    for g in G:
        if b + g in RD:
            ans -= 1
for r in R:
    for g in G:
        if r + g in BD:
            ans -= 1
print(ans)


Measured memory_bytes: 9412
N = int(input())
a = [int(input()) for _ in range(N)]
cnt = 0
i = 0
while(cnt <= N):
    if(a[i] == 2):
        cnt += 1
        break
    else:
        i = a[i]-1
        cnt += 1
if(cnt > N):
    cnt = -1
print(cnt)


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

string A, B, C;
void doA();
void doB();
void doC();

void doA() {
    if (A.size() == 0) {
        cout << "A" << endl;
        exit(0);
    }
    string tmp = A;
    A = A.substr(1);
    if (tmp[0] == 'a') {
        doA();
    } else if (tmp[0] == 'b') {
        doB();
    } else {
        doC();
    }
}
void doB() {
    if (B.size() == 0) {
        cout << "B" << endl;
        exit(0);
    }
    string tmp = B;
    B = B.substr(1);
    if (tmp[0] == 'a') {
        doA();
    } else if (tmp[0] == 'b') {
        doB();
    } else {
        doC();
    }
}

void doC() {
    if (C.size() == 0) {
        cout << "C" << endl;
        exit(0);
    }
    string tmp = C;
    C = C.substr(1);
    if (tmp[0] == 'a') {
        doA();
    } else if (tmp[0] == 'b') {
        doB();
    } else {
        doC();
    }
}
int main() {
    cin >> A >> B >> C;

    doA();

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func isOdd(n int) bool { return n%2 != 0 }

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

	ans := 0
	for i := 1; i <= n; i++ {
		// fmt.Println(i, strconv.Itoa(i))
		if isOdd(len(strconv.Itoa(i))) {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    // recursive with memoization aka dp but not really accepted dp in interviews so go figure.
    private static int helper(int[] nums, int[] cache, int i){

        if(cache[i] != -1)
            return cache[i];
        if(i==0)
            return cache[0] = 0;
        if(i==1)
            return cache[1] = Math.abs(nums[1] - nums[0]);

        cache[i] = Math.min(
            Math.abs(nums[i] - nums[i-1]) + helper(nums, cache, i-1),
            Math.abs(nums[i] - nums[i-2]) + helper(nums, cache, i-2));
        
        return cache[i];
    }

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        if(n==0){
            System.out.println(0);
            return;
        }
        int[] nums = new int[n];
        for(int i = 0; i < n; i++) nums[i] = in.nextInt();
        int[] cache = new int[nums.length];
        Arrays.fill(cache, -1);

     
        System.out.println(helper(nums, cache, nums.length-1));
    }
}

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

long long int P(long long int a,long long int b)
{
  long long int PP=1;
  for(int j=0;j<b;j++)
    PP*=a;
  return PP;
}

int main()
{
  long long int H;
  cin >> H;
  long long int i=0;
  while(H > 0)
  {
    i++;
    H=H/2;
  }
  cout << P(2,i)-1  << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector <int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    vector <int> dp(n);
    dp[0]=0;
    if(n==1)
    {
        cout<<v[0];
        return 0;
    }
    dp[1]=abs(v[0]-v[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(v[i]-v[i-1])+dp[i-1], abs(v[i]-v[i-2])+dp[i-2]) ;
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){

  int a,b,t,i;
  int k=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&t);

  for(i=a;i<=t;i+=a){

    k+=b;

  }

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


Measured memory_bytes: 128
#ABC-B
s=input()
count=0
if len(s)%2==0:
    for i in range(len(s)//2):
        if s[i]!=s[len(s)-i-1]:
            count+=1
else:
    for i in range((len(s)-1)//2):
        if s[i]!=s[len(s)-i-1]:
            count+=1
print(count)

Measured memory_bytes: 3060
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

mod = 10 ** 9 + 7
n_ = 10 ** 5 + 3 # まで対応


fun = [1 for i in range(n_+1)]
for i in range(1, n_ + 1):
    fun[i] = fun[i-1] * i % mod

rev = [1 for i in range(n_+1)]
rev[n_] = pow(fun[n_], mod-2, mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1) % mod

def nCr(n,r):
    if n <= 0 or r < 0 or r> n:return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod


S = int(input())

ans = 0
for i in range(1, S//3+1):
    ans += nCr((S - i * 3 + (i -1)), (i-1))
    ans %= mod

if S == 3:
    print("1")
else:

    print(ans % mod)



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

int main() {
    int N;
    string S, T;

    cin >> N;
    cin >> S >> T;

    rep(i, N) {
        cout << S[i] << T[i];
    }

    cout << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll A;
    cin >> A;
    double B;
    cin >> B;
    ll nB = B * 100 + 0.00001;
    ll ans = (A * nB) / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

h,n = inpm()
A = inpl()

s = sum(A)
if h <= s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 42568
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	ll mod = 1e9 + 7;
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1, 0);
	rep(i,m){
		int b;
		cin >> b;
		a[b] = 1;
	}
	vector<ll> dp(n + 1, 0);
	dp[0] = 1;
	rep2(i,1, n + 1)
	{
		if(a[i] == 0){
			if(i > 1)
				dp[i] = dp[i - 2] + dp[i - 1];
			else
				dp[i] = dp[i - 1];
			dp[i] %= mod;
		}
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=22;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
template<typename T>
inline void read(T &x){
	x=0;
	char ch=getchar();bool f=false;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,a[maxn],x[maxn][maxn],y[maxn][maxn],sz[66666],ans;
int main(){
	read(n);
	FOR(i,1,n){
		read(a[i]);
		FOR(j,1,a[i]) read(x[i][j]),read(y[i][j]);
	}
	FOR(i,1,(1<<n)-1) sz[i]=sz[i>>1]+(i&1);
	FOR(i,0,(1<<n)-1){
		bool flag=true;
		FOR(j,1,n) if((i>>(j-1))&1){
			FOR(k,1,a[j]) if(((i>>(x[j][k]-1))&1)!=y[j][k]) flag=false;
		}
		if(flag) ans=max(ans,sz[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#pragma warning(disable: 4996)
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long L, R;
	long long ans = 2018;
	cin >> L >> R;

	if (R - L >= 4200) {
		cout << 0 << endl;
	}
	else {
		for (long long i = L; i < R; i++) {
			for (long long j = L + 1; j <= R; j++) {
				ans = min(ans, (i * j) % 2019);
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int ans=0,temp=0;

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

    for(i=0;i<n;i++)
    {
        if(a[i]==b[i])
            temp++;
        else
        {
            ans=max(ans,temp);
            temp=0;
        }
    }
    ans=max(ans,temp);
    if(ans>=3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=1e5;
ll a[MAXN+5];
ll n;
struct node
{
	ll cnt,num;
}t[MAXN+5];
void Solve()
{
	ll tot=0;
	memset(t,0,sizeof(t));
	sort(a+1,a+n+1);
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[i-1])
			t[tot].cnt++;
		else
			t[++tot].cnt=1,t[tot].num=a[i];
		if(tot>3)
		{
			printf("No\n");
			return ;
		}
	}
	if(tot==3)
	{
		if(t[1].cnt==t[2].cnt&&t[2].cnt==t[3].cnt&&t[1].cnt==t[3].cnt
		&&(t[1].num^t[2].num^t[3].num)==0)
			printf("Yes\n");
		else
			printf("No\n");
	}
	if(tot==2)
	{
		if(t[1].num==0&&t[1].cnt*2==t[2].cnt)
			printf("Yes\n");
		else
			printf("No\n");
	}
	if(tot==1)
	{
		if(t[1].num==0)
			printf("Yes\n");
		else
			printf("No\n");
	}
}
int main()
{
	//freopen("circle.in","r",stdin);
	//freopen("circle.out","w",stdout);
	int t;
	//scanf("%d",&t);
	//while(t--)
	{
		scanf("%lld",&n);
		for(int i=1;i<=n;i++)
			scanf("%lld",&a[i]);
		Solve();
	}
    return 0;
}
/*
bi-1=bi+2
b[i-1] b[i] b[i+1] (b[i+2]=b[i-1]) 
每三个数一循环 
1.由一种数构成:所有数为0
2.由两种数构成:一种是0，数量为n/3,另一种数数量为2n/3
3.由三种数构成:数量均为3/n且异或和为0
4.由大于三种数构成：无解 
*/ 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e9+7;
const ll N = 100002;
ll n,c,k,ans=0;
vector<ll> t;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>c>>k;
	FOR(i,0,n){
		ll p;
		cin>>p;
		t.pb(p);
	}
	SORT(t);
	ll nin=1;
	ll ti=0;
	ans=1;
	FOR(i,1,t.size()){
		nin++;
		if(nin>c){
			nin=1;
			ti=0;
			ans++;
			continue;
		}
		ti+=t[i]-t[i-1];
		if(ti>k){
			nin=1;
			ti=0;
			ans++;
		}
	}
	ll ans2=1;
	ti=0;
	nin=1;
	for(ll i=t.size()-1;i>=0;i--){

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

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200010LL;
long long n,d,a,xx,yy,res=0LL,pre[maxn];
pair<long long,long long> v[maxn];
long long num(long long x)
{
	long long ans=x/a;
	if(x%a) ++ans;
	return ans;
}
int main()
{
	cin>>n>>d>>a;
	long long ld=(d<<1LL)+1LL; 
	for(long long i=1LL;i<=n;i++) cin>>v[i].first>>v[i].second;
	sort(v+1LL,v+1LL+n);
	v[n+1]=make_pair(1e18,1e18);
	for(long long i=1LL;i<=n;i++)
	{
		pre[i]+=pre[i-1];
		long long di=v[i].second-pre[i];
		if(di<=0LL) continue;
		long long tim=num(di);
		res+=tim;
		long long att=tim*a;
		long long ind=upper_bound(v+1LL,v+2LL+n,make_pair(v[i].first+ld,0LL))-v;
		pre[i]+=att;
		pre[ind]-=att;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4992
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    IN(ll, K);
    OUT(min(A, K) - min(C, max(0LL, K - A - B)));
}


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

// ------------------------- DEBUGGING -----------------------------------------------------------------
#ifdef DEBUG
#define debug(args...) { vector<string> _v = split(#args, ','); err( _v.begin(), args); cerr << endl; }
vector<string> split( const string& s, char c) {
      vector<string> v;
      stringstream ss( s);
      string x;
      while ( getline( ss, x, c))
            v.emplace_back( x);
      return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
      cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
      err( ++it, args...);
}
#else
#define debug(...)
#endif
// -------------------------- MACROS -------------------------------------------------------------------

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// ---------------------------  TEMPLATE ENDS  -------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9+7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 1e5 + 2;

vvi adj;
vb broken(NN, 0);
vi dp(NN);
void solve(){
      int i = 0, j = 0, k = 0, n = 0, m = 0;
 	cin>>n>>m;
 	fr(i, 0, m) {
 		cin>>k;
 		broken[k] = 1;
 	}
 	dp[0] = 1;
 	if(!broken[1]) {
 		dp[1] = 1;
 	}     
 	fr(i, 2, n+1) {
 		if(broken[i]) continue;
 		dp[i] = (dp[i-2]+dp[i-1])%mod;
 	}
 	cout<<dp[n]<<endl;
 }
int32_t main(){
#ifndef DEBUG
      ios::sync_with_stdio(false); cin.tie(0); 
#endif
      int T = 1, tc;
      // cin >> T;
      for(tc = 1; tc <= T; tc++){
            solve();
      }
      return 0;
}


Measured memory_bytes: 1024