akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n;
    cin >> n;
    int a[n];
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        x = x ^ a[i];
    }
    for (int i = 0; i < n;i++){
        cout << (x ^ a[i]) << " ";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  if (S.at(0) == 'R' && S.at(1) == 'R'){
    count++;
  }
  if (S.at(2) == 'R' && S.at(1) == 'R'){
    count++;
  }
  if (count == 0){
    if (S.at(0) == 'R'|| S.at(1) == 'R'|| S.at(2) == 'R'){
      count = 1;
    }
  }
  else {
    count++;
  }
  cout << count << endl;
}
    
  
    
   

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

int k, n;

int next(int i) { return i + 1 == n ? 0 : i + 1; }

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

  vector<int> houses;
  rep(i, n) {
    int a;
    cin >> a;
    houses.push_back(a);
  }

  int r = n - 1;
  int ans = INT_MAX;

  ans = min(ans, houses[r] - houses[0]);

  for (int i = 1; i < n; i++) {
    r = next(r);
    int dist = k - houses[i] + houses[r];
    ans = min(ans, dist);
  }

  cout << ans << endl;

  return 0;
}


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

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

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

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

	int a = 1;

	for( int i = 0; i < N; ++i ) {
		if( a * 2 < a + K ) {
			a *= 2;
		}
		else {
			a += K;
		}
	}

	cout << a << endl;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)


void Main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N;
        string S;
        cin >>N >>S;
        vector<int> R(N+1, 0);
        vector<int> W(N+1, 0);
        Rep1(i, N)
                if ('W'==S.at(i-1))
                        W.at(i)=W.at(i-1)+1;
                else
                        W.at(i)=W.at(i-1);
        for (auto i=N-1; i>=0; i--)
                if ('R'==S.at(i))
                        R.at(i)=R.at(i+1)+1;
                else
                        R.at(i)=R.at(i+1);
        int SS=N;
        Rep0(i, N+1) {
                int WW=W.at(i);
                int RR=R.at(i);
                int SSS=max(WW, RR);
                SS=min(SS, SSS);
        }
        cout <<SS <<endl;
        return 0;
}

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


int main()
{
	long long int n;
	cin>>n;
	
	vector<vector<long long int> >v(n,vector<long long int>(3));
	
	for(long long int i=0;i<n;i++)
	{
		cin>>v[i][0]>>v[i][1]>>v[i][2];
		if(i!=0)
		{
			if(v[i-1][0]>v[i-1][1])
			{
				v[i][2] += v[i-1][0];
			}
			else{
				v[i][2] += v[i-1][1];
			}
			
			
			if(v[i-1][2]>v[i-1][1])
			{
				v[i][0] += v[i-1][2];
			}
			else{
				v[i][0] += v[i-1][1];
			}
			
			
			if(v[i-1][2]>v[i-1][0])
			{
				v[i][1] += v[i-1][2];
			}
			else{
				v[i][1] += v[i-1][0];
			}
	}
}
	
	long long int a=v[n-1][0],b=v[n-1][1],c=v[n-1][2];
	
	if(a>b)
	{
		(c>a)?cout<<c:cout<<a;
	}
	else
	{
		(c>b)?cout<<c:cout<<b;
	}
	

return 0;
}


Measured memory_bytes: 5760
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))
B.sort(reverse=True)

ans = 0
while H > 0:
    # まだ投げれる
    if not B == []:
        H -= B[0]
        del B[0]
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1

print(ans)


Measured memory_bytes: 11692
#include <bits/stdc++.h>
#define f0(i, n) for(int i=(0); i<n; i++)
#define f1(i, n) for(int i=(1); i<=n; i++)
#define Val(x) (((x)))
#define out1 cout << "Yes"
#define out2 cout << "No"

using namespace std;
typedef long long ll;
const int N = 100002;

int n, a[N];
map <int, int> g;

main(){
    ios_base::sync_with_stdio(0);
    
    cin >> n;
    f1(i, n) cin >> a[i];
    sort(a + 1, a + n + 1);
    if(a[1]==a[n]){
        if(a[1]== n - 1){
            out1; exit(0);
        }
        int x = 2*a[1];
        if(x <= n) out1;
        else out2;
        exit(0);
    }
    int dem = 0;
    f1(i, n){
        if(g[a[i]]==0) dem += 1;
        g[a[i]] += 1;
    }
    if(dem > 2){
        out2; exit(0);
    }
    if(a[n] - a[1] != 1){
        out2; exit(0);
    }
    if(g[a[1]] >= a[n]){
        out2; exit(0);
    }
    int x = g[a[n]];
    int y = a[n] - g[a[1]];
    if(2*y <= x){
        out1;
        exit(0);
    }
    out2;
}


Measured memory_bytes: 5376
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main(){
	unsigned int x,y,n;
	scanf("%d",&n);
	x=n*800;
	if(n>=15)
	printf("%d",x-(n/15*200));
	else
	printf("%d",x);
	return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


void slove() {
	ll a,bi=0,small=0;
	string b;
	int flag=0;
	cin >> a >> b;
	ll l = b.size();
	rep(i,0,l) {
		if (b[i]!='.' && flag==0) {bi=bi*10+b[i]-'0';continue;}
		if (b[i]=='.') {flag=1; continue;}
		small = small*10+b[i]-'0';
	}
	ll tmp = small * a / 100;
	cout << a*bi+tmp << '\n'; 
}

int main()
{
	cout.setf(ios::fixed);
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	slove();

	return 0;
}

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

int main() {
   long long N;
   cin >> N;
   int count;
   for (int i=1; i<=sqrt(N); i++) {
       if (N%i==0) {
           string s=to_string(N/i);
           count=s.size();
       }
   }
   cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[110];
  for(int i = 0;i < N;++i) cin >> a[i];
  
  int b[110] = {0};
  for(int i = 0; i < N; ++i){
    b[a[i]]++;
  }
  
  int res = 0;
  
  for(int i = 1; i <= 100;++i){
    if(b[i]){
      ++res;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;


template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint Permutation(ll n,ll k){
	mint ret = 1;
	for(ll i = 0; i < k; ++i){
		ret *= (n - i);
	}
	return ret;
}

mint Combination(ll n,ll k){
	mint ret = 1;
	mint div = 1;
	for(ll i = 0; i < k; ++i){
		ret *= (n - i);
		div *= (i + 1);
	}
	ret /= div;
	return ret;
}


signed main(){
	//cout << fixed << setprecision(10);
	mint ans = 1;
	ll n,m; cin >> n >> m;
	vl div;
	ll prime_cnt = 0;
	for(ll i = 2; i * i <= m; ++i){
		if(m % i == 0){
			ll cnt = 0;
			while(m % i == 0){
				cnt++;
				prime_cnt++;
				m /= i;
			}
			ans *= Combination(cnt + n - 1,cnt);
		}
	}
	if(m != 1){
		ans *= Combination(n,1);
	}
	cout << ans << endl;
	
	return 0;
}

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

map<int, int> MP1, MP2;
int n, ans=0;

signed main(){
    cin >> n;
    for(int i=0;i<n/2;i++) {
        int a, b;
        cin >> a;
        MP1[a]++;
        cin >> b;
        MP2[b]++;
    }
    int max1=0, max1num=0;
    for(map<int, int>::iterator it=MP1.begin();it!=MP1.end();it++) {
        pair<int, int> p = *it;
        if(max1<p.second) {
            max1 = p.second;
            max1num = p.first;
        }
    }
    int max2=0, max2num=0;
    for(map<int, int>::iterator it=MP2.begin();it!=MP2.end();it++) {
        pair<int, int> p = *it;
        if(max2<p.second) {
            max2 = p.second;
            max2num = p.first;
        }
    }
    //cout << "max1num : " << max1num << "   max2num : " << max2num << endl;
    //cout << "max1num : " << max1num << "   max2num : " << max2num << endl;
    if(max2num==max1num) {
        int ans1=0, ans2=0;
        ans1 += n/2-max1<0?0:n/2-max1;
        int max2i=0;
        for(map<int, int>::iterator it=MP2.begin();it!=MP2.end();it++) {
            pair<int, int> p = *it;
            if(p.first!=max1num&&max2i<p.second) {
                max2i = p.second;
                //max2num = p.first;
            }
        }
        ans1 += n/2-max2i<0?0:n/2-max2i;

        ans2 += n/2-max2<0?0:n/2-max2;
        int max1i=0;
        for(map<int, int>::iterator it=MP1.begin();it!=MP1.end();it++) {
            pair<int, int> p = *it;
            if(p.first!=max2num&&max1i<p.second) {
                max1i = p.second;
                //max1num = p.first;
            }
        }
        ans2 += n/2-max1i<0?0:n/2-max1i;
        ans = min(ans1, ans2);
    }
    else {
        ans += n/2-max2<0?0:n/2-max2;
        ans += n/2-max1<0?0:n/2-max1;
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			long x = sc.nextLong();
			long ans = solve(n,x);
			System.out.println(ans);

			sc.close();
		}

		public static long solve(int n, long x) {
			
			long[]ans = new long[n+1];	
			ans[0] = 1;
			if (n != 0) {
				if (n >= x) {
					ans[n] = 0;
				}else{
					if (2 * x == depth(n) + 1) {
						return pathi(n-1) + 1;
					}else if(x * 2 > depth(n)){
						ans[n] = pathi(n-1) + 1 + solve(n-1 , x-(depth(n)+1)/2);
					}else{
						ans[n] = solve(n-1,x-1);
					}
				}	
			}
			return ans[n];
		}

		public static long depth(int n ) {
			long[] depth = new long[n+1];
			depth[0] = 1;
			for (int i = 1; i <= n; i++) {
				depth[i] = 2* depth[i-1] + 3;
			}
			return depth[n];
		}

		public static long pathi(int n) {
			long[] pathi = new long[n+1];
			pathi[0] = 1;
			for (int i = 1; i <= n; i++) {
				pathi[i] = pathi[i-1] * 2 + 1;
			}
			return pathi[n];
		}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  char S[H][W];
  rep(h, H) rep(w, W) cin >> S[h][w];
  int ans = 0;
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      if (S[h][w] == '#') continue;
      queue<P> que;
      int dmin[H][W];
      rep(h, H) rep(w, W) dmin[h][w] = INF;
      dmin[h][w] = 0;
      P init(h, w);
      que.push(init);
      int dmax = 0;
      while(que.size()){
        P now = que.front(); que.pop();
        if(now.first < H - 1 && dmin[now.first + 1][now.second] == INF && S[now.first + 1][now.second] == '.') {
          P next(now.first + 1, now.second);
          que.push(next);
          dmin[now.first + 1][now.second] = dmin[now.first][now.second] + 1;
        }
        if(now.first > 0 && dmin[now.first - 1][now.second] == INF && S[now.first - 1][now.second] == '.') {
          P next(now.first - 1, now.second);
          que.push(next);
          dmin[now.first - 1][now.second] = dmin[now.first][now.second] + 1;
        }
        if(now.second < W - 1 && dmin[now.first][now.second + 1] == INF && S[now.first][now.second + 1] == '.') {
          P next(now.first, now.second + 1);
          que.push(next);
          dmin[now.first][now.second + 1] = dmin[now.first][now.second] + 1;
        }
        if(now.second > 0 && dmin[now.first][now.second - 1] == INF && S[now.first][now.second - 1] == '.') {
          P next(now.first, now.second - 1);
          que.push(next);
          dmin[now.first][now.second - 1] = dmin[now.first][now.second] + 1;
        }
        dmax = dmin[now.first][now.second];
      }
      ans = max(ans, dmax);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

s=get_nsp
s.pop
ans=s.size
loop do
    if ans.odd?
        ans-=1
        s.pop
        next
    end
    flag=true
    (ans/2).times do|i|
      if s[i]!=s[ans/2+i]
          flag=false
          break
      end 
    end
    if flag
        break
    else
        ans-=2
        s.pop
        s.pop
    end
end
puts ans

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

using namespace std;
typedef signed long long ll;

int N, K;
ll X[50];
ll Y[50];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    ll ans = 1LL << 62;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                for (int w = 0; w < N; w++) {
                    ll l = min(X[i], X[j]);
                    ll r = max(X[i], X[j]);
                    ll d = min(Y[k], Y[w]);
                    ll u = max(Y[k], Y[w]);

                    int c = 0;
                    for (int t = 0; t < N; t++) {
                        if (l <= X[t] && X[t] <= r && d <= Y[t] && Y[t] <= u) {
                            c++;
                        }
                    }

                    if (c >= K) {
                        ans = min((r - l) * (u - d), ans);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n,m[N][N];
int d[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    int i;
    for(i=0;i<n;i++) d[i]=INFTY;
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front();
        q.pop();
        for(int v=0;v<n;v++){
            if(m[u][v]==0) continue;
            if(d[v] != INFTY) continue;
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(i=0;i<n;i++){
        cout << i+1 << " " << ((d[i]==INFTY)?(-1):d[i]) << endl;
    }
}

int main(){
    int u,k,v,i,j;
    
    cin >> n;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) m[i][j]=0;
    }
    
    for(i=0;i<n;i++){
        cin >> u >> k;
        u--;
        for(j=0;j<k;j++){
            cin >> v;
            v--;
        m[u][v]=1;
    }
}
    bfs(0);
    
    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
  ll N;
  cin >> N;
  

  fin(N*(N-1)/2);
  
}

Measured memory_bytes: 256
n = int(input())
bs = list(map(int, input().split()))

ans = []  
 
def check(bs, pre):
  tmp = pre[:]
  if len(bs) == 0:
    ans.append(tmp)
    return
  cand = []
  for i, b in enumerate(bs):
    if i + 1 == b:
      cand.append(i)
  if len(cand) == 0:
    return
  i = cand[-1]
  check(bs[:i] + bs[i+1:], [i + 1] + tmp)

check(bs, [])

if len(ans):
  for ai in ans[0]:
    print(ai)
else:
  print(-1)


Measured memory_bytes: 3188
answer :: [Int] -> String
answer (w:h:x:y:r:[])
  | x >= r && y >= r && w - r >= x && h - r >= y   = "Yes" 
  | otherwise = "No"
answer _ = "ERROR!!"

stringToInt :: String -> [Int]
stringToInt xs = map read $ words xs

main = do
  hoge <- getLine
  putStrLn $ answer $ stringToInt hoge



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

int main() {
  int n, k;
  cin >> n >> k;
  int s = k;
  int p = 1;
  while (n >= s) {
    s *= k;
    p++;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
a = [x for x in LI() if x%2==0]
ans = 0
while 1:
    if len(a)==0:
        print(ans)
        break
    ans += len(a)
    for i,x in enumerate(a):
        a[i] /= 2
    a = [x for x in a if x%2==0]

Measured memory_bytes: 4148
import sys;sys.setrecursionlimit(int(1e7))
from collections import deque

N = int(input())
tree = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int,input().split())
    tree[a].append((b,c))
    tree[b].append((a,c))

Qn,K = map(int,input().split())
XY = [tuple(map(int,input().split())) for _ in range(Qn)]

dist = [-1]*(N+1)
dist[K] = 0
Q = deque()
Q.append(K)
while len(Q):
    p = Q.popleft()
    for q,c in tree[p]:
        if dist[q] != -1: continue
        dist[q] = dist[p]+c
        Q.append(q)

for i in range(Qn):
    print(dist[XY[i][0]] + dist[XY[i][1]])

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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> m(M+1, 0);

    for(int j = 0;j < N; j++){
        int K;
        cin >> K;

        for(int k = 0;k < K; k++){
            int tmp;
            cin >> tmp;
            m[tmp]++;
        }
    }

    cout << count(m.begin(), m.end(), N) << endl;

    return 0;
}


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

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l+2019);
  int ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		char s[][] = new char[H][W];
		int count = 1;
		int table[][] = new int[H][W];
		boolean[] row = new boolean[H];
		String line = "";
		for(int i=0;i<H;i++) {
			line = sc.next();
			for(int j=0;j<W;j++) {
				s[i][j] = line.charAt(j);
				table[i][j]=0;
			}
		}
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(s[i][j]=='#') {
					row[i] = true;
				}
			}
		}
		boolean snd = false;
		for(int i=0;i<H;i++) {
			if(row[i]) {

				for(int j=0;j<W;j++) {
					table[i][j] = count;
					if(s[i][j]=='#') {
						if(snd) {
							count++;
							table[i][j] = count;
						}
						snd = true;
					}
				}
				count++;
			}
			snd = false;
		}
		for(int i=0;i<H;i++) {
			int ins1=0,ins2=0;
			if(!row[i]) {
				for(int j=0;j<W;j++) {
					if(i!=H-1) {
						for(int k=i;k<H;k++) {
							if(row[k]) {
								ins1 = table[k][j];
								break;
							}
						}
						for(int k=i;k>=0;k--) {
							if (row[k]) {
								ins2 = table[k][j];
								break;
							}
						}
						table[i][j] = Math.max(ins1, ins2);
					}
					else {
						for(int k=i;k>=0;k--) {
							if (row[k]) {
								table[i][j] = table[k][j];
								break;
							}
						}
					}
				}
			}
		}
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				System.out.print(table[i][j] + " ");
			}
			System.out.println("");
		}

	}

}

Measured memory_bytes: 47504
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair< int, int>>
#define vsi vector<string>
#define vci vector<char>


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    int n,m,q;
    cin>>n>>m>>q;
    int x,y,i,j;
    map<int,int> mn[n];
    vlli a(n);
    vlli b(m);
    for(i=0;i<n;i++){
      a[i].ff=0;
      a[i].ss=i;
    }
    for(i=0;i<m;i++){
      b[i].ff=0;
      b[i].ss=i;
    }

    while(q--){
      cin>>x>>y;
      a[x-1].ff++;
      b[y-1].ff++;
      mn[x-1][y-1]++;
    }
    int mx=0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(i=n-1;i>=0;i--){
      for(j=m-1;j>=0;j--){
        x=b[j].ff+a[i].ff;
        if(x<=mx) break;
        if(mn[a[i].ss][b[j].ss]) x--;
        mx=max(x,mx);
      }
      if(a[i].ff+b[m-1].ff <=mx) break;
    }
    
    cout<<mx<<endl;


return 0;    
 }  

Measured memory_bytes: 35924
import java.util.Scanner;

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

        int input_int[] = new int[n];
        int oceanView = 0;
        int curMax = 0;
        for(int i = 0; i < n; i++){
            input_int[i] = scanner.nextInt();
            curMax = Math.max(curMax, input_int[i]);
            if(input_int[i] == curMax) oceanView++;
        }
        scanner.close();

        System.out.println(oceanView);
    }
}


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



int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int p=-1;
  string j="Yes";
  for(int i=0;i<n;i++){
  	int a;
    cin >> a;
    if(p>a&&p-a>1){
    	j="No";
      break;
    }else if(p<=a){
    	p=a;
    }else{
        p=a+1;
    }
  }
  cout << j << "\n";
  
}

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

/* =0,
 * ="",
 * =false
 * =true
 * std::vector<int>
 * std::sort(.begin(), .end());  ,std::greater<int>()
 */

void solve(int N,std::vector<int> p){
    std::vector<int> b=p;
    std::sort(p.begin(),p.end());
    int ct=0;
    for(int i=0;i<N;i++){
        if(b[i]!=p[i])ct++;
        if(ct==3){printf("NO");exit(0);}
    }
    printf("YES");
}

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

    int N=0;
    std::vector<int> p;
    std::cin>>N;
    for(int i=0,b=0;i<N;i++){
        std::cin>>b;
        p.push_back(b);
    }
    solve(N,p);
    return 0;
}


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

using namespace std;

int main(void){
    long long N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl; 
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

template<typename T>
void chmin(T a, T b){if(a>b)a=b;}

template<typename T>
void chmax(T a, T b){if(b>a)a=b;}

int powmod(int x, int y){
    int res=1;
    while(y){
        if(y&1)
            res=1ll*res*x%MOD;
        x=1ll*x*x%MOD;
        y>>=1;
    }
    return res;
}

int mu[MAXN];
int Prime[MAXN],isNot[MAXN],tol;

void get_mu(int n){
    mu[1]=1;
    for(int i=2;i<=n;++i){
        if(!isNot[i]){
            Prime[++tol]=i;
            mu[i]=-1;
        }
        for(int j=1;j<=tol;++j){
            if(1ll*i*Prime[j]>n)break;
            isNot[i*Prime[j]]=1;
            mu[i*Prime[j]]=-mu[i];
            if(i%Prime[j]==0){
                mu[i*Prime[j]]=0;
                break;
            }
        }
    }

    for(int i=1;i<=n;++i){
        mu[i]+=mu[i-1];
    }
}

int main(){
    int n=read();
    int k=read();

    get_mu(100005);

    LL ans=0;
    for(int i=1;i<=k;++i){
        LL sum=0;
        for(int l=1,r;l<=k/i;l=r+1){
            r=(k/i)/((k/i)/l);
            sum+=1ll*(mu[r]-mu[l-1])*powmod((k/i)/l,n);
            sum%=MOD;
        }
        ans+=i*sum;
        ans%=MOD;
    }

    ans=(ans%MOD+MOD)%MOD;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 4476
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n, k, i, j, s[100000],max=-99999;
	scanf("%d %d", &n, &k);
	while(n!=0)
	{
		s[0]=0;
		for(i=1;i<=n;i++)
		{
			scanf("%d", &s[i]);
			s[i] += s[i-1];
		}
		for(j=k;j<=n;j++)
		{
			if(max < s[j] - s[j-k]) max = s[j] - s[j-k];
		}
		printf("%d\n", max);
		scanf("%d %d", &n, &k);
	}
	return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  ll l=1, r=n, num;
  rep(_, m) {
    cin >> num;
    chmax(l, num);
    cin >> num;
    chmin(r, num);
  }
  cout << max((ll)0,r-l+1) << newl;
  return 0;
}


Measured memory_bytes: 256
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    a, b, c, d = wi()
    for i in range(10000):
        c -= b
        if c <= 0:
            print('Yes')
            sys.exit()
        a -= d
        if a <= 0:
            print('No')
            sys.exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 67452
#include<stdio.h>
#include<stdlib.h>
#define tate 3
#define yoko 3
#define total (tate*yoko)
#define N 45

extern inline void down(void);
extern inline void up(void);
extern inline void right(void);
extern inline void left(void);
extern int puzzle(int x,int y,int a,int b);

int n=0,board[total]={};

int main(void)
{
  int i,x,y;
  for(i=0;i<total;i++)
    {
      scanf("%d",&board[i]);
      if(board[i]==0)
        {
          n=i;
        }
    }
  x=tate-(n/yoko)-1;
  y=yoko-(n%yoko)-1;

  for(i=0;i<N;i++)
    {
      if(puzzle(x,y,i,4)==1)
        {
          printf("%d\n",i);
          break;
        }
    }
  return 0;
}

int puzzle(int x,int y,int a,int b)
{
  int result,i;
  if(a<(x+y))
    {
      return 0;
    }
  if(a==0)
    {
      for(i=0;i<total-1;i++)
        {
          if(board[i]!=(i+1))
            {
              return 0;
            }
        }
      return 1;
    }
  for(i=0;i<4;i++)
    {
      result=0;
      switch(i)
        {
        case 0:
        if((x>0) && (b!=3))
          {
            down();
            result=puzzle(x-1,y,a-1,0);
            up();
          }
        break;
        case 1:
          if((y>0) && (b!=2))
            {
              right();
              result=puzzle(x,y-1,a-1,1);
              left();
            }
          break;
        case 2:
          if((y<yoko-1) && (b!=1))
            {
              left();
              result=puzzle(x,y+1,a-1,2);
              right();
            }
          break;
        case 3:
          if((x<tate-1) && (b!=0))
            {
              up();
              result=puzzle(x+1,y,a-1,3);
              down();
            }
          break;
        default:
          break;
        }
      if(result)
        {
          return 1;
        }
    }
  return 0;
}

inline void down()
{
  board[n]=board[n+yoko];
  n=n+yoko;
}

inline void up()
{
  board[n]=board[n-yoko];
  n=n-yoko;
}

inline void right()
{
  board[n]=board[n+1];
  n=n+1;
}

inline void left()
{
  board[n]=board[n-1];
  n=n-1;
}
          



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

int main(){
  int n;
  string s[2];
  cin>>n>>s[0]>>s[1];

  vector<int> v;
  rep(i,n){
    if(s[0][i]==s[1][i]) v.pb(0);
    else {
      v.pb(1);
      i++;
    }
  }

  n = v.size();

  long ans;
  if(v[0]==0) ans = 3;
  else ans = 6;
  rep(i,n-1){
    if(v[i]==0){
      if(v[i+1]==0) ans *= 2;
      else ans *= 2;
    }
    else {
      if(v[i+1]==1) ans *= 3;
      else ans *= 1;
    }
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  vector<ll> s(n + 1, 0);
  rep(i, n) s.at(i + 1) = s.at(i) + a.at(i);
  map<ll, ll> mp;
  rep(i, n) s.at(i + 1) = s.at(i) + a.at(i);
  rep(i, n + 1) mp[s.at(i)]++;
  ll ans = 0;
  for (auto p : mp)
  {
    ll v = p.second;
    if (v < 2)
    {
      continue;
    }
    ans += v * (v - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static int solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		return N * A < B ? N * A : B;
	}
}


Measured memory_bytes: 21844
// Aizu Vol-1 0192: Multistory Parking Lot
// 2017.8.19 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 100
typedef struct { int s, e; } CAR;
CAR car[MAX + 5]; int N, top;
int park[12][2], M;

int main()
{
	int i, t, fin, used;

	while (scanf("%d%d", &M, &N) && M) {
		for (t = 0, i = 1; i <= N; i++, t += 10)
			car[i].s = t, scanf("%d", &(car[i].e));
		fin = used = 0;  for (i = 0; i < M; i++) park[i][0] = park[i][1] = 0;

		for (top = 1, t = 0; ; t++) {
			// ?§????????????????????¢????
			for (i = 0; i < M; i++) {
				int c0, c1;
				c0 = park[i][0], c1 = park[i][1];
				if (c0 == 0 && c1 == 0) continue;
				if (c0 > 0 && car[c0].e > 0) car[c0].e--;
				if (c1 > 0 && car[c1].e > 0) car[c1].e--;
				if (c0 > 0 && car[c0].e == 0) {
					if (fin) putchar(' ');
					printf("%d", c0), fin++, c0 = 0, park[i][0] = 0, used--;
				}
				if (c1 > 0 && car[c1].e == 0 && c0 == 0) {
					putchar(' ');
					printf("%d", c1), fin++, park[i][1] = 0, used--;
				}
			}
			if (fin >= N) break;

			// ?§??????????????????????
			while (used < 2 * M && top <= N) {
				int p1, p2, p3, d, c, c2, min;
				c = top;
				if (t < car[c].s) break;

				for (i = 0; i < M; i++)
					if (park[i][0] == 0 && park[i][1] == 0) { park[i][0] = c, used++; goto DONE; }

				for (min = 1000000, p1 = -1, i = 0; i < M; i++) {
					if (park[i][0] > 0 && park[i][1] > 0) continue;
					if (park[i][0] == 0) c2 = park[i][1], p3 = 0;
					else                 c2 = park[i][0], p3 = 1;
					if ((d = car[c2].e - car[c].e) >= 0 && d < min) min = d, p1 = i, p2 = p3;
				}
				if (p1 >= 0) goto SET;

				for (min = 1000000, p1 = -1, i = 0; i < M; i++) {
					if (park[i][0] > 0 && park[i][1] > 0) continue;
					if (park[i][0] == 0) c2 = park[i][1], p3 = 0;
					else                 c2 = park[i][0], p3 = 1;
					if ((d = car[c].e - car[c2].e) > 0 && d < min) min = d, p1 = i, p2 = p3;
				}
				if (p1 < 0) break;
SET:			if (p2 == 1) park[p1][1] = park[p1][0];
				park[p1][0] = c, used++;
DONE:			top++;
			}
		}
		putchar('\n');
	}
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin>>A[i];

    int res = 0;
    for (int i = 0; i < N; ++i) {
      
        while (i+1 < N && A[i] == A[i+1]) ++i;

       
        if (i+1 < N && A[i] < A[i+1]) {
            while (i+1 < N && A[i] <= A[i+1]) ++i;
        }
        else if (i+1 < N && A[i] > A[i+1]) {
            while (i+1 < N && A[i] >= A[i+1]) ++i;
        }
        ++res;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    let n = read::<usize>();
    let s: String = read();
    let s = s.chars().collect::<Vec<_>>();

    let mut right_bracket_poses = Vec::new();
    let mut left_bracket_poses = Vec::new();

    for (i, &ch) in s.iter().enumerate() {
        // println!("{}", ch);
        if ch == '(' {
            left_bracket_poses.push(i);
        } else {
            right_bracket_poses.push(i);
        }
    }

    let mut not_corresspond_left = 0;
    let mut right_for_search = right_bracket_poses.clone();
    for &pos in left_bracket_poses.iter().rev() {
        let cor_pos = right_for_search.lower_bound(&pos);
        if cor_pos == right_for_search.len() {
            not_corresspond_left += 1;
        } else {
            right_for_search.remove(cor_pos);
        }
    }
    // println!("{}", not_corresspond_left);

    let mut not_corresspond_right = 0;
    let mut left_for_search = left_bracket_poses
        .iter()
        .rev()
        .map(|&x| n - 1 - x)
        .collect::<Vec<_>>();
    for &pos in right_bracket_poses.iter() {
        let cor_pos = left_for_search.lower_bound(&(n - 1 - pos));
        if cor_pos == left_for_search.len() {
            not_corresspond_right += 1;
        } else {
            left_for_search.remove(cor_pos);
        }
    }
    // println!("{}", not_corresspond_right);

    let mut s = s.into_iter().collect::<VecDeque<_>>();
    for i in 0..not_corresspond_right {
        s.push_front('(');
    }
    for i in 0..not_corresspond_left {
        s.push_back(')');
    }
    for ch in s {
        print!("{}", ch);
    }
    println!("");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int check(int bits[25]){
    for (int i = 0; i < 20; i++) {
        if(bits[i] > 1) return 0;
    }
    return 1;
}

int main(){
    int n;
    cin >> n;
    int A[200010];
    for (int i = 0; i < n; i++) cin >> A[i];

    ll ans = 0;
    int bits[25] = {0}, flag = 0;
    int l = 0;
    
    for (int r = 1; r <= n; r++) {
        for (int j = 0; j < 20; j++) {
            bool bit = A[r - 1] & (1 << j);
            bits[j] += bit;
        }
        if(!check(bits)) flag = 1;

        while (flag) {
            for (int j = 0; j < 20; j++) {
                bool bit = A[l] & 1 << j;
                bits[j] -= bit;
            }
            if(check(bits)) flag = 0;
            l++;
        }

        ans += r-l;
    }

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

Measured memory_bytes: 1024
n = int(input())
m=n
ans=0
for i in range(18):
    ans+=m//10 
    m=m//10
m=n//10   
for i in range(44):
    ans+=m//5
    m=m//5
m=n//10
for i in range(18):
    ans-=m//10 
    m=m//10

if n%2==1: ans=0 
print(int(ans))

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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

vector<int> G[100010];
int N, M;

bool rec(int pos, int prv, int start, int end){
    for(int to : G[pos]){
        if(to == prv) continue;
        if(to == end){
            return true;
        }
        else if(to == start){
            return false;
        }
        else{
            return rec(to, pos, start, end);
        }
    }
    return true;
}

int main(){

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bool ok = true;
    for(int i = 0; i < N; i++){
        if(G[i].size() % 2){
            ok = false;
        }
    }
    if(!ok){
        cout << "No" << endl;
    }
    else{
        vector<int> deg_four;
        for(int i = 0; i < N; i++){
            if(G[i].size() >= 6){
                cout << "Yes" << endl;
                return 0;
            }
            else if(G[i].size() == 4){
                deg_four.push_back(i);
            }
        }
        
        if(deg_four.size() >= 3){
            cout << "Yes" << endl;
        }
        else if(deg_four.size() <= 1){
            cout << "No" << endl;
        }
        else{
            int a = deg_four[0];
            int b = deg_four[1];
            // a -> b の path が2通りのみかチェック
            int cnt = 0;
            for(int to : G[a]){
                cnt += rec(to, a, a, b);
            }
            if(cnt == 2){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int a,b;
    cin>>a>>b;
    if((a+b)%2)cout<<"IMPOSSIBLE"<<endl;
    else cout<<(a+b)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<int> uset;

int main( int argc, char* argv[] ){
  int X;
  cin >> X;
  int m = 1;
  for( int b=2; b<X; ++b ){
    int x = b*b;
    int p = 2;
    if( x > X ) break;
    while( x*b <= X ){
      x *= b;
      p++;
    }
    if( x > m ){
      m = x;
      cerr << x << "(" << b << "^" << p << ")" << endl;
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256