akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){

	int a[3000];
	int b[3000];
	int a1[3000];
	int b1[3000];
	//追加
	for (int i = 0; i < 3000; i++){

		cin >> a[i];
		cin >> b[i];

		if (a[i] == 0 && b[i] == 0){
			break;
		}
	}
	//OK!!
	//直しつつ移して
	for (int i = 0; i < 3000; i++){

	
		if (a[i] > b[i]){

			a1[i] = b[i];
			b1[i] = a[i];
		}
		else{
			a1[i] = a[i];
			b1[i] = b[i];
		}
		if (a[i] == 0 && b[i] == 0){
			break;
		}

	}
	//cout!
	for (int i = 0; i < 3000; i++){

		if (a1[i] == 0 && b1[i] == 0){
			break;
		}
		else{
			cout << a1[i] << " " << b1[i] << endl;	
			
		}

	}
	return 0;
}



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

using namespace std;

const int N = 1e3 + 3;
const int MOD = 1e9 + 7;

int n, m;
string str[N];
int dp[N][N];
bool vis[N][N];

bool check(int x, int y){
	if(x >= n || y >= m || str[x][y] != '.')
		return false;
	return true;
}

void dfs(int x, int y){
	
	if(vis[x][y])
		return;

	vis[x][y] = true;
	if(check(x + 1, y))
		dfs(x + 1, y);
	if(check(x, y + 1))
		dfs(x, y + 1);

	dp[x][y] += dp[x + 1][y] + dp[x][y + 1];
	dp[x][y] %= MOD; 
}

int main()
{
	cin >> n >> m;

	for(int i = 0; i < n; i++)
		cin >> str[i];

	dp[n - 1][m - 1] = 1;
	dfs(0, 0);

	cout << dp[0][0] << "\n";
}

Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
#define N 1005
typedef long long ll;

int p[N];

int main(){
    int n,i,k,s=0;
    cin>>n>>k;
    for(i=1;i<=n;i++){
        cin>>p[i];
    }
    sort(p+1,p+n+1);
    for(i=1;i<=k;i++){
        s+=p[i];
    }
    cout<<s;
    return 0;
}


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

int main(){
	int A, B; //Takahasi HP, Attack
	int C, D; //Aoki HP, Attack
	
	/* Takahasi win -> Yes */
	cin >> A >> B >> C >> D;
	
	while(1){
		C-=B; //Takahasi attack
		if(C <= 0){
			cout << "Yes" << endl;
			break;
		}
		A-=D; //Aoki attack
		if(A <= 0){
			cout << "No" << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3520
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 51;
int arr[N];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n; cin>>n;
    FOR(i, 0, n) cin>>arr[i];
    sort(arr, arr+n);
    double res = (arr[0] + arr[1]) / 2.0;
    FOR(i, 2, n) {
    	res = (res + arr[i]) / 2.0;
    }
    coud(res, 10);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,ans=100000000;
    string s;
    cin>>n>>s;
    int se[n],sw[n];
    REP(i,n){
        if(s[i]=='E'){
            se[i]=se[i-1]+1;
            sw[i]=sw[i-1];
        }
        if(s[i]=='W'){
            se[i]=se[i-1];
            sw[i]=sw[i-1]+1;
        }
    }
    REP(i,n){
        int tmp;
        tmp=sw[i-1]+se[n-1]-se[i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}

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

int main() {
	int n, line;
	cin>>n>>line;
	int a,b;
	int arr1[n+1]={};
	int arr2[n+1]={};
	int mid;
	for(int i=0; i<line; i++){
		cin >> a >> b;
		if (a==1) arr1[b]++;
		if (b==n) arr2[a]++;
	}
	for(int i=0;i<=n; i++){
		if (arr1[i]>0 and arr2[i]>0){
			cout <<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


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

int main()
{
  long long w, h, x, y;
  cin >> w >> h >> x >> y;
  int ch = 0;
  if(x*2 == w && y*2 == h)ch = 1;
  double ans = w*h/2.0;
  cout << fixed << setprecision(10) << ans << ' ' << ch << endl;
}


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

int main(){
  vector<int> n(3);
  cin >> n.at(0) >> n.at(1) >> n.at(2);
  sort(n.begin(), n.end());
  cout << 10*n.at(2)+n.at(0)+n.at(1) << endl;
  //if(n%2==1)cout << n*(1+(n/2)) << endl;
  //else cout << (n/2)*(n/2) << endl;
  return 0;
}

Measured memory_bytes: 256
program tenquestionsix
implicit none
integer N, i, suma, sumb, sumab
integer,allocatable,dimension(:) :: A
suma=0
sumb=0
sumab=0
read(*,*) N
allocate(A(N))
read(*,*) A
call heapsort(N,A)
 do i=N,1,-2
 suma=suma+A(i)
 end do
 do i=N-1,1,-2
 sumb=sumb+A(i)
 end do
sumab=suma-sumb
write(*,*) sumab
end program

subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n                           
  integer,intent(inout) :: array(1:n)     
  integer ::i,k,j,l
  double precision :: t
  
  if(n.le.0)then                                    
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return                                 

  l=n/2+1                                           
  k=n
  do while(k.ne.1)                                 
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1          
        endif
        if (t.lt.array(j))then                      
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo 
     array(i)=t
  enddo 

  return
end subroutine heapsort

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];
    sort(ALL(a));

    int ans=0;
    REP(i,100000){
        int cnt=upper_bound(ALL(a),i+1)-lower_bound(ALL(a),i-1);
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
    cout<<fixed<<setprecision(25)<<sqrt(d)<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int H, W;
	int i, j;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if ((i + j) % 2 == 0)printf("#");
				else printf(".");
			}printf("\n");
		}printf("\n");
	}
		return 0;
}

Measured memory_bytes: 572
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

// clang-format on
int main(){

    llint n;
    cin>>n;
    llint result=0;   
    FOR(i,1,n+1){
    if(i%3!=0&&i%5!=0){
    result+=i;}
    }
    cout << result << endl;

    return 0;
}

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

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

using namespace std;
using lint=long long;

map<long long,int> prime_factorize(long long a){
	map<long long,int> res;
	if(a%2==0){
		int cnt=0;
		do{ cnt++; a/=2; }while(a%2==0);
		res.emplace(2,cnt);
	}
	for(long long p=3;p*p<=a;p+=2) if(a%p==0) {
		int cnt=0;
		do{ cnt++; a/=p; }while(a%p==0);
		res.emplace(p,cnt);
	}
	if(a>1) res.emplace(a,1);
	return res;
}

int main(){
	lint n; cin>>n;
	int ans=0;
	for(auto pf:prime_factorize(n)){
		int q=pf.second;
		for(int i=1;q>=i;i++){
			q-=i;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


template<class T>
void show_2d_vector(const vector<vector<T>> &v){
    for (auto v1: v) {
        for(auto v2: v1) {
            cout << v2 << " ";
        }
        cout << endl;
    }
}


int main(){
    string s, t;
    cin >> s >> t;

    vector<vector<ll>> pos(26);
    for(int i = 0; i < s.size(); i++){
        pos[(int)(s[i]-'a')].push_back(i+1);
    }


    ll num = -1;
    ll ans = 0;
    for(int i = 0; i < t.size(); i++){
        if(pos[(int)(t[i]-'a')].size()==0){
            cout << -1 << endl;
            return 0;
        }
        auto itr = lower_bound(all(pos[(int)(t[i]-'a')]),num+1);
        if(itr == pos[(int)(t[i]-'a')].end()){
            ans += (ll)(s.size());
            num = pos[(int)(t[i]-'a')][0];
        }else{
            num = *itr;
        }
    }
    ans += (ll)(num);

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long double ans = 0;
  for(int i = 0; i < n; i++) {
    ans += 1.0 / a[i];
  }
  cout << fixed << setprecision(10) << 1.0 / ans ;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

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

int main() {
    class SEGTREE{
                ll n, dflt;
          		vector<ll> dat;
            public:
            	SEGTREE(unsigned long _n, ll _a) : dat(_n * 4, _a){
            	    n = 1;
            	    dflt = _a;
            	    while(n < _n) n *= 2;
                }
                void update(ll k, ll a){
                    k += n;
                    dat[k] = a;
                    while(k > 0){
                        k /= 2;
                        dat[k] = min(dat[k * 2], dat[k * 2 + 1]);
                    }
                }
                void init(vector<ll> &v){
            	    for(int i = 0; i < v.size(); ++i) dat[i + n] = v[i];
            	    for(int i = n - 1; i >= 1; --i) {
            	        dat[i] = min(dat[i * 2], dat[i * 2 + 1]);
            	    }
            	}
                ll Q(ll a, ll b){
            	    return query(a, b, 1, 0, n);
            	}
                ll query(ll a, ll b, ll k, ll l, ll r){
                    if(r <= a || b <= l) return dflt;
                    if(a <= l && r <= b) return dat[k];
                    ll vl = query(a, b, k * 2, l, (l + r) / 2);
                    ll vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
                    return min(vl, vr);
                }
                //単項にアクセスする[]だが、書き換え厳禁
                //一応後でinitすれば書き換えてもよさそうだが…
                ll & operator [](int k) {return dat[k + n];}
        };
    cin>>N>>W;
    vec a(N), b(N);
    rep(i,N) {
        cin>>a[i]>>b[i];
        --a[i]; --b[i];
    }
    set<P> id_cost;
    rep(i,W) id_cost.emplace(i, 0);
    SEGTREE seg(W + 5, INF);
    rep(_, 1) {
        vec temp(W, 0);
        seg.init(temp);
    }
    rep(i,N){
        ll temp = INF;
        for(auto ite = id_cost.lower_bound(make_pair(a[i], -1)); ite != id_cost.end() && ite->fi <= b[i] + 1; ){
            ll id = ite->fi, cost = ite->se;
            chmin(temp, b[i] + 1 - id + cost);
            seg.update(id, INF);
            ++ite;
            id_cost.erase(make_pair(id, cost));
        }
        if(b[i] + 1 == W) temp = INF;
        if(temp != INF){
            id_cost.emplace(b[i] + 1, temp);
            seg.update(b[i] + 1, temp);
        }
        ll res = seg.Q(0, W);
        cout<<(res == INF ? -1 : res + i + 1)<<endl;
    }
}

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

int main(){
    int N;
    cin >>N;
    vector<double> A(N);
    double ans=0;
    for(int i=0;i<N;i++){
      cin >>A.at(i);
    }
    sort(A.begin(),A.end(),greater<double>());

    int maxv=N;
    while(maxv>2){
      A.at(maxv-2)=(A.at(maxv-1)+A.at(maxv-2))/2;
      A.pop_back();
      sort(A.begin(),A.end(),greater<double>());
      maxv--;
    }
    ans=(A.at(0)+A.at(1))/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int A = sc.nextInt();
    int B = sc.nextInt();

    int ans = A + B;
    ans = ans < A - B? A - B: ans;
    ans = ans < A * B? A * B: ans;

    System.out.println(ans);
  }
}


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

int dp[105][4][2];

int main() {
  string s; cin >> s;
  int n = s.size();
  int K; cin >> K;

  dp[0][0][0] = 1;
  // i: i桁目まで
  // j: j個の非0を使って
  // k: 0: そこまでの桁はNと一致
  //    1: そこまでの桁ですでにN未満であることが確定
  REP(i,n) REP(j,4) REP(k,2) {
    int nd = s[i]-'0';
    REP(d,10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int a,b,n;
cin>>a>>b>>n;
if((b-a+2-2*n)<=0)
{for(int i=a;i<=b;i++)
  cout<<i<<endl;
  system("pause");
  return 0;
}
for(int i=0;i<n-1;i++)
cout<<(a+i)<<endl;
if(a+n-1==b-n+1)
cout<<(a+n-1)<<endl;
else
{
cout<<(a+n-1)<<endl;
cout<<(b-n+1)<<endl;
}
for(int i=n-2;i>=0;i--)
cout<<(b-i)<<endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[1_000_00 + 10];
		int n = sc.nextInt();
		for (int i = 0; i < n; ++i) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			arr[l]++;
			arr[r + 1]--;
		}
		int ans = 0;
		for (int i = 1; i < arr.length; ++i) {
			arr[i] = arr[i] + arr[i - 1];
			if (arr[i] > 0)
				++ans;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if (a+b<x) {
    cout << "NO" << endl;
  }else if (a>x) {
    cout << "NO" << endl;
  }else {
    cout << "YES" << endl;
  }
  }


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

using namespace std;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<long long> a(n + 1), b(m + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
	}
	for (int i = 2; i <= n; i++) {
		a[i] += a[i - 1];
	}
	for (int i = 2; i <= m; i++) {
		b[i] += b[i - 1];
	}

	int mx = 0;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) {
			break;
		}

		long long nokori = k - a[i];

		int l = 0;
		int r = m + 1;
		while (l + 1 < r) {
			int c = (l + r) / 2;
			
			if (b[c] <= nokori) {
				l = c;
			} else {
				r = c;
			}
		}
		if (mx < i + l) {
			mx = max(mx, i + l);
			
		}
		
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> opset;
#define SZ(X) ((int)X.size())
#define ALL(I) I.begin(), I.end()
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define eps 1e-12
#define MXN 200005

LL n, k;

int main(){
	cin >> n >> k;
	LL t = n / k;
	LL s = (((k & 1LL) || n < k / 2) ? 0 : ((n - (k / 2)) / k + 1));
	printf("%lld\n", t * t * t + s * s * s);
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL X, Y;

int main(void)
{
	cin >> X >> Y;
	if (X % Y == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << X << endl;
	return 0;
}


Measured memory_bytes: 764
s=input()
n=len(s)
count=0
count2=0
for i in range(n):
	if i % 2 == 0:
		x="0"
	else:
		x="1"
	if s[i] == x:
		count2 += 1
		#print(i,s[i],x,"OK")
	else:
		count += 1
		#print(i,s[i],x)
print(min(count,count2))

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

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

	cout << sum - (a[0]/2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
#define x first
#define y second
#define mp make_pair

const int MAXN = 300;
int n, m, l, qrs;
vector <int> ms[MAXN + 5];
queue <pll> q;
bool bio[MAXN + 5];
ll dist[MAXN + 5][MAXN + 5], adj[MAXN + 5][MAXN + 5], res[MAXN + 5][MAXN + 5];
const ll inf = (ll)1e15;

void prep_stuff(){
	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= n ; ++j){
			if(i == j){
				dist[i][j] = 0;
			}
			else if(adj[i][j]){
				dist[i][j] = adj[i][j];
			}
			else{
				dist[i][j] = inf;
			}
		}
	}
	for (int k = 1 ; k <= n ; k++) {
		for (int i = 1 ; i <= n ; i++) {
			for (int j = 1 ; j <= n ; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= n ; ++j){
			if(i == j)
				continue;
			if(dist[i][j] <= l){
				ms[i].push_back(j);
			}
		}
	}
}

void solve(){
	memset(res, -1, sizeof(res));
	for(int idx = 1 ; idx <= n ; ++idx){
		for(int i = 1 ; i <= n ; ++i){
			bio[i] = 0;
		}
		q.push(mp(idx, 0));
		while(!q.empty()){
			int x = q.front().x;
			int dist = q.front().y;
			q.pop();
			if(bio[x])
				continue;
			bio[x] = 1;
			res[idx][x] = dist - 1;
			for(vector <int>::iterator i = ms[x].begin() ; i != ms[x].end() ; ++i){
				int o = *i;
				if(bio[o])
					continue;
				q.push(mp(o, dist + 1));
			}
		}
		res[idx][idx] = 0;
	}
	/*
	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= n ; ++j){
			cout << res[i][j] << ' ';
		}
		cout << endl;
	}
	*/
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> l;
for(int i = 0 ; i < m ; ++i){
	int x, y;
	ll c;
	cin >> x >> y >> c;
	adj[x][y] = (!adj[x][y] ? c : min(adj[x][y], c));
	adj[y][x] = (!adj[y][x] ? c : min(adj[y][x], c));
}
prep_stuff();
/*
for(int i = 1 ; i <= n ; ++i){
	for(int j = 0 ; j < (int)ms[i].size() ; ++j){
		cout << ms[i][j] << ' ';
	}
	cout << endl;
}
*/
solve();
cin >> qrs;
for(int i = 0 ; i < qrs ; ++i){
	int x, y;
	cin >> x >> y;
	cout << res[x][y] << endl;
}

return 0;
}



Measured memory_bytes: 3992
k, a, b = map(int, input().split())

if a + 2 < b:
    ans = a
    k -= a - 1
    if k%2 == 1:
        ans += 1
        k -= 1
    ans += (b - a) * (k // 2)
    print(ans)
else:
    print(k+1)

Measured memory_bytes: 38384
import collections
def resolve():
    n = int(input())
    C = collections.Counter(list(input()))
    for i in range(n-1):
        S = collections.Counter(list(input()))
        C = C & S

    st = ''
    for i in sorted(C.items()):
        st += i[0] * i[1]
    print(st)

if __name__ == '__main__':
    resolve()

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    int n, m, ti, tj;
    string s;
    bool f;
    cin >> n >> m;
    char a[n][n], b[m][m];
    REP(i, n){
        REP(j, n) cin >> a[i][j];
    }
    REP(i, m){
        REP(j, m) cin >> b[i][j];
    }

    REP(i, n-(m-1)){
        REP(j, n-(m-1)){
            ti = i;
            f = true;
           REP(k, m){
               tj = j;
               REP(l, m){
                   if(b[k][l] != a[ti][tj]){
                       f = false;
                       break;
                   }
                   tj++;
               }
               ti++;
               if(!f) break;
           }
           if(f){
               yOUT;
               return 0;
           }
        }
    }

    nOUT;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL ten[SIZE];
int main(){
    string s;
    int n,p;
    R(n,p,s);
    LL an=0;
    if(p==2||p==5){
        REP(i,n){
            if((s[i]-'0')%p==0)an+=i+1;
        }
    }
    else{
        ten[0]=1;
        REPP(i,1,SIZE)ten[i]=ten[i-1]*10%p;
        LL now=0;
        map<int,int>AA;
        AA[0]++;
        REP(i,n){
            now=(now*10+s[i]-'0')%p;
            an+=AA[now*ten[n-i]%p];
            AA[now*ten[n-i]%p]++;
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 8708
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    min_b = 10 ** 10
    s = 0
    for _ in range(n):
        a, b = map(int, input().split())
        s += b
        if a > b:
            min_b = min(min_b, b)
    print(0) if min_b == 10 ** 10 else print(s - min_b)

main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


int r[3], n;
int nCount;

void doSearch(int d, int curNum)
{
	if (d == 2)
	{
		if ((n - curNum) % r[2] == 0)
//		{
			nCount++;// = nCount + (curNum / r[2]);
//		}
//		if (curNum == n)
//		{
////			printf("%d %d %d %d\n", r[0], r[1], r[2], curNum);
//			nCount++;
//		}
	}
	else
	{
		int newNum = curNum;
		while (newNum <= n)
		{
			doSearch(d + 1, newNum);
			newNum = newNum + r[d];
		}
	}
}

int main()
{
	scanf("%d%d%d%d", &(r[0]), &(r[1]), &(r[2]), &n);
	
	nCount = 0;
	
	doSearch(0, 0);
	
	printf("%d\n", nCount);
	

	return 0;
}



Measured memory_bytes: 128
#include "stdio.h"

int le, ri, buf, min = 2019, map[2019];
long long int L, R;

int main(void){
  scanf("%lld %lld", &L, &R);
  for(int c = 0;c < 2019;c++){
    map[c] = 0;
  }
  for(long long int c = 0;c < 4018;c++){
    map[(L + c) % 2019]++;
    if(L + c == R){
      break;
    }
  }
  for(int i = 0;i < 2019;i++){
    for(int j = i;j < 2019;j++){
      if((i == j && map[i] > 1) || (i != j && map[i] != 0 && map[j] != 0)){
        buf = (i * j) % 2019;
        if(min > buf){
          min = buf;
        }
      }
    }
  }
  printf("%d", min);
  
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    getline(cin,s);
    for(int i=0; i<s.length(); i++)
    {
        if(s[i]==',')
        {
            s[i]=' ';
        }

    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!.toString().toCharArray()
    var prev: String? = null
    s.forEach {
        prev?.let { p ->
            if (it.toString() != p) {
                return println("Yes")
            }
        }
        prev = it.toString()
    }
    println("No")
}

Measured memory_bytes: 33632
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int A[100002] = {};

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


	int N = getint(), C = getint();
	rep(i, N) {
		int s = getint(), t = getint(), c = getint();
		A[s] ^= 1 << c;
		A[t] ^= 1 << c;
	}

	int kotae = 0;
	int kazu = 0;
	rep1(i, 100000) {
		kotae = max(kotae, __builtin_popcount(kazu | A[i]));
		kazu ^= A[i];
	}
	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  cin >> a;
  for (int i : a) x += 1 + (d - 1) / i;
  cout << x << endl;
}



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

#define int int64_t

int MOD = 1000000007;

int minCost(int *A, int N, int K, int *dp)
{
    if(N < 0)
        return INT_MAX;
    
    if(N == 0)
        return 0;
    
    if(N == 1)
        return abs(A[1] - A[0]);

    if(dp[N] != -1)
        return dp[N];

    int ans = INT_MAX;
    for(int i=1; i<=K; i++)
        ans = min(minCost(A, N-i, K, dp) + abs(A[N]-A[N-i]), ans);

    return dp[N] = ans;
}

int32_t main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(NULL);

    int N, K;
    cin >> N >> K;

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

    int *dp = new int[N]();
    for(int i=0; i<N; i++)
        dp[i] = -1;

    int ans = minCost(A, N - 1, K, dp);

    cout << ans;

    delete [] dp;
    delete [] A;

    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>

void mergeSort(int*, int, int);
void merge(int*, int, int, int);
int count;

int main(){
  int n, S[500005], i;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);

  mergeSort(S, 0, n);
  
  for(i = 0; i < n - 1; i++)
    printf("%d ", S[i]);
  printf("%d\n", S[n -1]);

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

  return 0;
}

void  merge(int *A, int left, int mid, int right){
  int n1= mid - left, n2 = right - mid, L[250005], R[250005], i, j = 0, k;

  for(i = 0; i < n1; i++)
    L[i] = A[left + i];

  for(i = 0; i < n2; i++)
    R[i] = A[mid + i];
  
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  
  i = 0;
    
  for(k = left; k < right; k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }else{
      A[k] = R[j];
      j = j + 1;
    }
  }
}
void mergeSort(int *A, int left, int right){
  int mid;

  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



Measured memory_bytes: 5588
n = int(input())
p = []

max_suffix = 0
for i in range(n):
    p.append(int(input()))
    if p[max_suffix] < p[i]: max_suffix = i

ans = 0
for i in range(n):
    if i == max_suffix: ans += p[i]/2
    else: ans += p[i]
    
print(int(ans))

Measured memory_bytes: 3064
#include <stdio.h>

#define N_MAX 2000000
#define N 10000

void myC_sort(int *,int *,int *,int,int);

int main(){
  int a[N_MAX+1]={0},b[N_MAX+1]={0},c[N+1]={0},n,i,max,in;
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&in);
    if(in>max) max=in;
    a[i]=in;
  }

  myC_sort(a,b,c,max,n);
  for(i=1; i<n; i++){
    printf("%d ",b[i]);
  }
  printf("%d\n",b[i]);
  
  return 0;
}

void myC_sort(int *a,int *b,int *c,int k,int n){
  int i;
  for(i=0; i<=k; i++) c[i]=0;
  for(i=1; i<=n; i++) c[a[i]]=c[a[i]]+1;
  for(i=1; i<=k; i++) c[i]=c[i]+c[i-1];
  for(i=n; i>=1; i--){
    b[c[a[i]]]=a[i];
    c[a[i]]=c[a[i]]-1;
  }
}



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

int main(){
    int n; cin >> n;
    int max_pat = pow(2, n);

    vector <vector<pair<int, int>>> shogen(n);
    
    rep(i, n){
        int a; cin >> a;
        rep(j, a){
            int x, y; cin >> x >> y;
            shogen.at(i).push_back(make_pair(x, y));
        }
    }

    int ans = 0;
    for(int one_pat = 0; one_pat < max_pat; one_pat ++){
        vector <int> chara(n);
        int _ans = 0;
        rep(i, n){
            chara.at(i) = ((one_pat >> i) & 1);
            _ans += chara.at(i);
        }

        bool ok = true;
        rep(i, n){
            if(chara.at(i) == 0) continue;
            for(auto ps: shogen.at(i)){
                int x = ps.first - 1;
                int y = ps.second;

                if(chara.at(x) != y){
                    ok = false;
                    break;
                }
            }
        }
        if(ok) ans = max(ans, _ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define ll long long

int main(void){
int N;
int a[100000];
int flag=0;
scanf("%d",&N);
int i=0;
for(i=0;i<N;i++){
scanf("%d",&a[i]);
}
int sw=1;
for(i=0;i<N;i++){
 sw=a[sw-1];
 if(sw==2) {printf("%d\n",i+1); return 0;}
}
printf("-1\n");
return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main() {
 int n,a,b=0;
  vector<pair<int,int> >v ;
	cin>>n;
	for(int i=0;i<n;i++)
	  {cin>>a;
	  v.push_back( make_pair(a,i)); 
	  }
	  sort(v.begin(), v.end()); 
	  for(int i=0;i<n;i++)
	  {
	    if(v[i].second!=i) 
	      b++;
	  }
	  if(b==0||b==2)
	    cout<<"YES";
	   else
	   cout<<"NO";
	return 0;
}

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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;i>=m;i--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
string dec_bin(ll x){
    string result;
    while(x>0){
        result.push_back(x%2 + 48);
        x = (x-(x%2))/2;
    }
    reverse(result.begin(),result.end());
    return result;
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;

ll pow_2(ll factor){
    ll count = 0;
    while(factor%2==0){
        count+=1;
        factor/=2;
    }
    if(factor==1)return count;
    else return -1;
}

/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

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


Measured memory_bytes: 3636
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n, a[100], sum = 0, min = 1e9;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	double ave = (double)sum / n;
	double dif = 1e9;
	for (int i = 0; i < n; i++) {
		if (dif > fabs(ave - a[i]) || (dif == fabs(ave - a[i]) && min > i)) {
			dif = fabs(ave - a[i]);
			min = i;
		}
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;
const long long int MOD =1000000007;

int N;
char a[1000];
char b[1000];
bool flag;

int main() {
	cin >> N;
	cin >> a;
	cin >> b;
	for (int i = 0; i <= N; i++) {
		flag = true;
		for (int j = 0; j < N; j++) {
			if (i + j < N) {
				if (a[i+j] != b[j]) {
					flag = false;
					break;
				}
			}
		}
		if (flag) {
			cout << i + N << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
# 二部探索で決めていく。dpですでに見られたかどうかは把握
"""
工事 finish  1 eve削除
工事 start   2 eve追加
di start     3
この時間を混ぜてソート。上から順番に捌く
（区間がxi,xjで重なっていたらsetに入れられないのか。）

同じ時刻だった場合
工事finish -> 工事start -> di通過
の順番
"""
import sys
from operator import itemgetter
input = sys.stdin.readline
n,q  = map(int, input().split())
events = []
E = 10**10
for i in range(n):
    s,t,x = map(int, input().split())
    # st
    events.append((s-x,1,x))
    # gl
    events.append((t-x,0,x))
ds = [(int(input()),2,i) for i in range(q)]
events.extend(ds)
ans = [-1] * q
events.sort()
works = set()
upd = True
mn = 10**10
for t, e, x in events:
    if e == 1:
        works.add(x)
        if mn > x:
            mn = x
            upd = False
    elif e == 0:
        works.remove(x)
        if x == mn:
            upd = True
    else:
        if len(works) == 0:
            ans[x] = -1
        else:
            if upd:
                mn = min(works)
                upd = False
            ans[x] = mn
print(*ans)

    

Measured memory_bytes: 98472
<?php

fscanf(STDIN, '%d %d', $N, $K);
$memo = [];
for ($i=0; $i < $K; $i++) {
    $treat = trim(fgets(STDIN));
    $snukes = explode(' ', trim(fgets(STDIN)));
    foreach ($snukes as $snuke) {
        array_push($memo, $snuke);
    }
}

$memo = array_unique($memo);

echo $N - count($memo);

echo PHP_EOL;


Measured memory_bytes: 16740
#include <iostream>
#include <algorithm>

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

int main() {
    int n, h, maxh = 0, ans = 0;
    cin >> n;
    rep(i, n) {
        cin >> h;
        if(maxh <= h) {
            maxh = h;
            ans++;
        }
    } 
    cout << ans << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, h, w);
  vector<string> a(h);
  rep(i, h) cin >> a[i];
  vector<bool> r(h), c(w);
  rep(i, h) rep(j, w) if (a[i][j] == '#') r[i] = c[j] = true;
  rep(i, h) if (r[i]) {
    rep(j, w) if (c[j]) cout << a[i][j];
    cout << endl;
  }
}


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

int main(){
    int d;
    cin >> d;
    cout <<"Christmas ";
    rp(i,25-d) cout << "Eve ";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, x, y;
	cin >> n;
	vector<pair<long long, long long> > a;
	map<pair<long long, long long>, bool> mp;
	for(int i = 0; i < n; i++) {
		cin >> x >> y;
		a.push_back({x, y});
		mp[{x,y}]=true;
	}
	sort(a.begin(), a.end());
	int ans = n;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int dx = a[j].first - a[i].first;
			int dy = a[j].second - a[i].second;
			
			int cnt = 0;
			for(int k = 0; k < n; k++) {
				int px = a[k].first - dx;
				int py = a[k].second - dy;
				if(!mp[{px, py}])
					cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans;
}

Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
using namespace std;
int n,num,ans=2000000000,e[1001000],w[1001000];
char s[1001000];
int main()
{
	int i;
	cin>>n;
	scanf("%s",s);
	for(i=n;i>=1;i--)
	s[i]=s[i-1];
	for(i=1;i<=n;i++)
	{
		if(s[i]=='W')
		w[i]++;
		else
		e[i]++;
		w[i]+=w[i-1];e[i]+=e[i-1];
	}
	for(i=1;i<=n;i++)
	{
		num=w[i-1]+e[n]-e[i];
		ans=min(ans,num);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int h,w,d[51][51],X[4]={1,0,-1,0},Y[4]={0,1,0,-1},c=0;
    cin>>h>>w;
    char s[51][51];
    rep(i,h)rep(j,w){
        cin>>s[i][j];
        if(s[i][j]=='.') c++;
    }
    rep(i,h)rep(j,w) d[i][j]=0;
    d[0][0]=1;
    queue<int> Qx,Qy;
    Qx.push(0),Qy.push(0);
    while(Qx.size()){
        int x=Qx.front(),y=Qy.front();
        Qx.pop(),Qy.pop();
        rep(i,4) if(s[x+X[i]][y+Y[i]]=='.'&&!d[x+X[i]][y+Y[i]]&&0<=x+X[i]&&x+X[i]<h&&0<=y+Y[i]&&y+Y[i]<w){
            d[x+X[i]][y+Y[i]]=d[x][y]+1;
            Qx.push(x+X[i]),Qy.push(y+Y[i]);
        }
    }
    if(!d[h-1][w-1]) cout<<-1;
    else cout<<c-d[h-1][w-1];
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

string s;
int a,b,c,d;
signed main(){
    FastIO;
    int t;
    cin>>t;
    while(t--){
        cin>>s;
        if(s[0]=='A') a++;
        if(s[0]=='W') b++;
        if(s[0]=='T') c++;
        if(s[0]=='R') d++;
    }
    cout<<"AC x "<<a<<'\n';
    cout<<"WA x "<<b<<'\n';
    cout<<"TLE x "<<c<<'\n';
    cout<<"RE x "<<d<<'\n';
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long m = 100;
    int ans = 0;
    for(int i=0;i<10000;i++){
        if(m>=n)break;
        m+=m/100;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
N,M=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(M)]
b=[1]*N
r=[1]+[0]*(N-1)
for x,y in xy:
    b[x-1]-=1
    b[y-1]+=1
    if r[x-1]==1:
        r[y-1]=1
        if b[x-1]==0:
            r[x-1]=0
print(sum(r))

Measured memory_bytes: 29732
#include <bits/stdc++.h>
using namespace std;
#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++)

int main(){
    int N; cin >> N;
    int A = 0, B = 0;
    vector<int> a(N);
    rep(i, N) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    rep(i, N) {
        if (i % 2 == 0) {
            A += a.at(i);
        }
        else {
            B += a.at(i);
        }
    }
    cout << A - B << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);

    int ans;

    foreach (i ; 1 .. n + 1) {
        if ((i % 2 == 1) && cntdiv(i) == 8) {
            ans++;
        }
    }

    writeln(ans);
}

int cntdiv(int n) {
    int[] div;

    foreach (i ; 1 .. n) {
        if (i*i > n) break;
        if (n % i == 0) {
            div ~= i;
            div ~= n / i;
        }
    }

    return div.sort().uniq.count.to!int;
}
























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256