akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
using namespace std;
typedef long long int ll;
int main() {
	ll people;
	ll capa,min_capa = LLONG_MAX;
	cin >> people;
	for (int i = 0; i < 5; ++i) {
		cin >> capa;
		if (capa < min_capa) {
			min_capa = capa;
		}
	}
	ll neck_time = (people % min_capa == 0) ? people / min_capa : people / min_capa + 1;
	ll min_time = 4 + neck_time;
	cout << min_time << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <string>
#include <map>
#include <cstring>
using namespace std;

using ii = pair < int , int >;
using ti = tuple < int ,int ,int >;
using lint = long long;
using ll = pair < lint , lint >;

const int N = 1e5 + 7;

int c[N],a[N],b[N];
int n;

bool go(){
	int x=0,y=0,t=0;
	for(int i=0;i<n;i++){
		int dt = c[i] - t;
		int dx = a[i] - x;
		int dy = b[i] - y;

		dx = abs(dx);
		dy = abs(dy);

		if(dx+dy<=dt && (dx+dy)%2==dt%2){

		}
		else{
			return false;
		}

		x = a[i];
		y = b[i];
		t = c[i];
	}
	return true;
}

int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",c+i,a+i,b+i);
	}
	if(go()){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}


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

int main() {
int X, Y, A, B, C;
  cin>>X>>Y>>A>>B>>C;
  vector<int> R(A);
  vector<int> G(B);
  vector<int> T(C);
  vector<int>::iterator it;
  vector<int>::iterator dt;
  
  for(int i=0; i<A; i++) cin>>R.at(i);
  for(int i=0; i<B; i++) cin>>G.at(i);
  for(int i=0; i<C; i++) cin>>T.at(i);
  sort(R.begin(),R.end());
  reverse(R.begin(),R.end());
  sort(G.begin(),G.end());
  reverse(G.begin(),G.end());
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());
  while(R.size()>X) R.pop_back();
  while(G.size()>Y) G.pop_back();
  for(int i=0; i<C;i++){
    if(T.at(i)<=R.at(X-1)&&T.at(i)<=G.at(Y-1)) break;
    if(R.at(X-1)>G.at(Y-1)){
      G.pop_back();
      it =G.begin();
      it =G.insert(it,T.at(i));
    }
    else{
       R.pop_back();
      dt =R.begin();
      dt =R.insert(dt,T.at(i));
    }
  }
  int64_t total=0;
  for(int i=0; i<X; i++) total+=R.at(i);
  for(int i=0; i<Y; i++) total+=G.at(i);
  cout<< total; 
}


Measured memory_bytes: 1408
// atcoder/caddi2018/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> a(n);
    cin >> a;

    bool f = true;
    each (i, a) f = f && (i % 2 == 0);
    cout << (f ? "second" : "first") << endl;
  }

  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int count = 0;

//配列arrが全て0かどうかを返す
bool all_zero(int *arr, int n){
  for(int i=0; i<n; i++)
    if(arr[i] != 0)
      return false;
  return true;
}


//l以上r未満の区間で初めて0が現れる場所を返す
//0が見つからなければrを返す
int zero_num(int *h, int l, int r){
  int i;
  for(i=l; i<r; i++)
    if(h[i] == 0)
      return i;
  return i;
}


void solve(int *h, int l, int r){
  int num = zero_num(h, l, r);

  //0がどこにもなければ処理
  if(num == r){
    if(l != r){
      for(int i=l; i<r; i++)
	h[i]--;
      /* rep(i, 9)
	cout<<h[i]<<" ";
	cout<<endl;*/
      count++;
    }
  }
  //0が見つかるとき
  else{
    //左端で見つかれば，それより左で見る
    if(num == l)
      solve(h, l+1, r);
    //右端で見つかれば，それより左で見る
    else if(num == r-1)
      solve(h, l, r-1);
    //真ん中で見つかれば，左と右に分けて再帰
    else{
      solve(h, l, num);
      solve(h, num+1, r);
    }
  }
}


int main(void){
  int N;
  cin >> N;
  int h[N];
  rep(i, N)
    cin >> h[i];
  //ここまで入力

  //花の高さが全て0になるまで繰り返す
  while(!all_zero(h, N) )
    solve(h, 0, N);

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  int ans;
  cin >> A;
  cin >> B;

  if (A==1) {
    if (B==2) {
      ans = 3;
    } else if (B==3) {
      ans = 2;
    }
  } else if (A==2) {
    if (B==1) {
    ans = 3;
    } else if (B==3) {
      ans = 1;
    }
  } else if (A==3) {
    if (B==1) {
      ans = 2;
    } else if (B==2) {
      ans = 1;
    }
  }

  cout << ans << endl;
}

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

#define _USE_MATH_DEFINES
#include <math.h>

// cl /EHsc xxxx.c
int main(int arc, char *argv[])
{
	double r;
	double area;
	double circle;

	scanf("%lf", &r);
	
	area = r * r * M_PI;
	circle = 2 * M_PI * r;
	
	printf("%lf %lf\n", area, circle);
	
	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

ll negmd(ll a,ll n){
	return (n+(a%n))%n;
}
 
ll modexp(ll x,ll n,ll m)
{
	if(n == 0) return 1;
	else if(n & 1)
	{
		return (x * modexp(x,n - 1,m))%m;
	}
	else
	{
		ll y = modexp(x,n/2,m);
		return (y * y)%m;
	}
	
}
ll flt(ll a,ll p)
{
	return modexp(a,p - 2,p);
}
void Compute(ll n,ll a,ll b)
{
	KAKA
    ll x = 1,y = 1;
	pragi(0,a)
	{
		x = ((x % mod) * ((n - i) % mod))%mod;
	}
	pragi(0,a)
	{
		y = ((y % mod) * ((a - i) % mod))%mod;
	}
	ll yinv = flt(y,mod);
    ll ans1 = (x * yinv)%mod;
	//cout<<ans1<<"\n";
	 x = 1,y = 1;
	pragi(0,b)
	{
		x = ((x % mod) * ((n - i) % mod))%mod;
	}
	pragi(0,b)
	{
		y = ((y % mod) * ((b - i) % mod))%mod;
	}
	yinv = flt(y,mod);
	ll ans2 = (x * yinv)%mod;
	//cout<<ans2<<"\n";
	ll ans3 = modexp(2,n,mod);
    ll ans = (ans3 - ans1 - ans2 - 1);
	if(ans < 0) ans = negmd(ans,mod);
	else ans %= mod;
	cout<<ans<<"\n";
}
int main()
{
	KAKA
	ll n,a,b;
	cin>>n>>a>>b;
	Compute(n,a,b);
}

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

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

using namespace std;

typedef long long ll;

// read editorials 
int h[100001];
ll n, a, b;

bool check(ll t){
  ll cnt = 0;

  rep(i, n){
    if(h[i] > b * t){
    	cnt += (h[i] - b * t + (a-b-1)) / (a-b);
//      cnt += (h[i] - b * t) / (a-b);
//      if(((h[i] - b * t) % (a - b)) != 0) cnt++;
    }
  }
  return cnt <= t;
}

signed main(){

  scanf("%lld %lld %lld", &n, &a, &b);

  rep(i, n) scanf("%d", h+i);
    
  ll l, r, mid, ans;
  l = 0; r = 1e9;

  while(r - l > 1){
    mid = (l + r) / 2;
    if(check(mid)) r = mid;
    else l = mid; 
  }

  cout << r << endl;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll x{0};
	cin>>x;

	if(x==0)
		cout<<1<<endl;
	else
		cout<<0<<endl;


	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    string X, Y; cin >> X >> Y;

    if (X > Y) {
        cout << ">" << endl;
    } else if (X == Y) {
        cout << "=" << endl;
    } else {
        cout << "<" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_e

#include<bits/stdc++.h>
const int N = 2e5 + 5;
using namespace std;

int n, h, w, a[N], r[N], c[N], pset[N], cnt[N], p[N];
long long ans;

int Find(int i) {return ((pset[i] == i) ? i : pset[i] = Find(pset[i]));}

bool dsu(int u, int v){
    u = Find(u); v = Find(v);
    if (cnt[u] + cnt[v] == 0) return false;
    cnt[u]--;
    if (u == v) return true;
    cnt[v] += cnt[u];
    pset[u] = v;
    return true;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> h >> w;
    for (int i = 1; i <= n; i++) cin >> r[i] >> c[i] >> a[i], p[i] = i;
    sort(p+1, p+1+n, [](int x, int y){return a[x] > a[y];});
    for (int i = 1; i <= h+w; i++) pset[i] = i, cnt[i] = 1;
    for (int i = 1; i <= n; i++) if (dsu(r[p[i]], c[p[i]] + h)) ans += a[p[i]];
    cout << ans;
}


Measured memory_bytes: 4480
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 100000;
typedef long long LL;
LL g[55];
LL f[55];
LL n, x;
int main() {
	g[1] = 5, f[1] = 3;
	for(int i = 2; i <= 50; i++) {
		g[i] = (g[i - 1] + 1) * 2 + 1;
		f[i] = f[i - 1] * 2 + 1;
	}
	LL ans = 0;
	scanf("%lld%lld", &n, &x);
	if(x <= n)ans = 0;
	else {
		for(int i = n; i >= 1; i--) {
			if(x >= g[i] + n - i) {
	//			printf("%lld %d %lld %lld\n", n - i, i, g[i], x);
				x -= (g[i] + n - i);
				ans += f[i];
				if(x)x--, ans++;
				n = i;
			}
		}
	//	printf("%lld %lld %lld\n", n, ans, x);
		if(x - n == 1)ans++;
		else if(x - n == 2)ans += 2;
		else if(x - n >= 3)ans += 3;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> Q(m);
  for(int i = 0; i < m; ++i){
    cin >> Q[i];
  }
  reverse(Q.begin(),Q.end());
  vector<int> ans(n,-1);
  vector<bool> used(n+1,false);
  int idx = 0;
  for(auto e : Q){
    if(used[e]) continue;
    ans[idx] = e;
    ++idx;
    used[e] = true;
  }
  for(int i = 1; i <= n; ++i){
    if(used[i]) continue;
    ans[idx] = i;
    ++idx;
  }
  for(auto e : ans)
    cout << e << endl;
}



Measured memory_bytes: 4148
#include <iostream>
#include <string>

using namespace std;

bool isACGT(char c) {
	return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main() {
	string s;
	cin >> s;
	
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if(isACGT(s[i])) {
			cnt++;
			
			if(cnt > ans) {
				ans = cnt;
			}
		}
		else {
			cnt = 0;
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int h[N + 1];
main() {
    int n = readInt();
    for (int i = 1; i <= n; i++) {
        h[i] = readInt();
    }
    int cnt = 1, ans = 0;
    for (int i = 2; i <= n; i++) {
       if (h[i - 1] >= h[i]) {
            ++cnt;
       } else {
           ans=max(ans, cnt - 1);
        cnt = 1;
       }
    }
    ans = max(ans, cnt - 1);
    cout << ans;
}


Measured memory_bytes: 1024
a, b, c = map(int, input().split())
ans1 = a*b*(c//2-(c-c//2))
ans2 = a*(b//2-(b-b//2))*c
ans3 = (a//2-(a-a//2))*b*c
print(min([abs(ans1), abs(ans2),abs(ans3)]))


Measured memory_bytes: 61820
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 333;
const int lg = 22;
long long get(vector<long long> v){
    int len = v.size();
    long long ops = 0;
    while(true){
        long long sum = 0;
        vector<long long> add(len, 0);
        for(int e = 0; e < len; e++){
            long long now = v[e] / len;
            add[e] -= now;
            ops += now;
            sum += now;
        }
        for(int e = 0; e < len; e++){
            v[e] = (v[e] % len) + add[e] + sum;
        }
        bool ended = true;
        for(int e = 0; e < len; e++)
            ended &= v[e] < len;
        if(ended)
            break;
    }
    return ops;
}
int M(){
    int n;
    if(!~scanf("%d", &n)) return 0;
    vector<long long> iv(n);
    for(long long & t : iv) cin >> t;
    cout << get(iv) << endl;
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace A_ABC131
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            //            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            string u = Console.ReadLine();
            string ans = "Good";
            if (u[0] == u[1] || u[1] == u[2] || u[2] == u[3])
            {
                ans = "Bad";

            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
r=lambda x:p[x]>=0and r(p[x])or x
(n,m,k),*t=[map(int,t.split())for t in open(0)]
p,s=[-1]*-~n,[-1]*-~n
for i,(a,b)in enumerate(t):
  x,y=r(a),r(b)
  if(x!=y)*m>i:
    if x>y:x,y=y,x
    p[x]+=p[y]
    p[y]=x
  if x==y or i<m:
    s[a]-=1
    s[b]-=1
for i in range(n+1):s[i]-=p[r(i)]
print(*s[1:])

Measured memory_bytes: 96856
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    string s;
    cin >> s;

    int n = s.size();

    string s1 = s.substr(0, (n + 1) / 2 - 1);
    string s2 = s.substr( (n + 3) / 2 - 1);

    //cout << s1 << endl;
    //cout << s2 << endl;


    string rs = s;
    string rs1 = s1;
    string rs2 = s2;
    reverse( all(rs) );
    reverse( all(rs1) );
    reverse( all(rs2) );

    if( s != rs ){
        cout << "No" << endl;
        return 0;
    }
    if( s1 != rs1 ){
        cout << "No" << endl;
        return 0;
    }
    if( s2 != rs2 ){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> h(N,0); for(int i = 0; i < N; i++) cin >> h.at(i);
  
  int ans = h.at(0);
  for(int i = 0; i < N - 1; i++){
      if(h.at(i+1) > h.at(i)) ans += h.at(i+1) - h.at(i);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef unsigned long long ull;
    typedef long long ll;
    #define tc int t;cin>>t;while(t--)
    #define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
    #define ff(i,a,b) for(i=a;i<b;i++)
    #define fb(i,b,a) for(i=b;i>a;i--)
    #define ffi(i,a,b,c) for(i=a;i<b;i+=c)
    #define fbi(i,b,a,c) for(i=b;i>a;i-=c)
    #define clin(s) getline(cin,s)
    #define MOD 1e9+7
    #define pb push_back
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define ub upper_bound
    #define lb lower_bound
    int main() {
    	fio;
    	string a,b;
    	clin(a);
    	clin(b);
    	int i,j,la=a.length(),lb=b.length();
    	vector<vector<int>> L(la+1 , vector<int>(lb+1));
    	ff(i,0,la+1){
    		ff(j,0,lb+1){
    			if(i==0||j==0)
    				L[i][j]=0;
    			else if(a[i-1] == b[j-1])
    				L[i][j]=L[i-1][j-1]+1;
    			else
    				L[i][j]=max(L[i-1][j],L[i][j-1]);
    		}
    	}
    	string ans="";
    	int r=lb;
    	int c=la;
    	while(r>0 || c>0){
    		while(r>0 && L[c][r] == L[c][r-1]){
    			r--;
    		}
    		while(c>0 && L[c][r] == L[c-1][r]){
    			c--;
    		}
    		if(c>0)
    		ans+=a[c-1];//or b[r-1]
    		c--;
    		r--;
    	}
    	//cout<<ans<<"\n";
    	reverse(all(ans));
    	cout<<ans<<"\n";
    	return 0;
    }


Measured memory_bytes: 35584
#include<iostream>
#include<fstream>
using namespace std;
int sum,small;
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
int big;
int zs;
int ge;
int main()
{
	int a;
	cin>>a;
	while(a>0)
	{
		ge=a%10;
		if(ge==9)
		{
			cout<<"Yes";
			zs++;
			break;
		}
		a=a/10;
	}
	if(zs==0)
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

struct S{ ll n0, n1, ninv; };

S op(S l, S r){
    return S{
        l.n0 + r.n0,
        l.n1 + r.n1,
        l.ninv + r.ninv + l.n1 * r.n0
    };
}

S e() { return S{0, 0, 0}; }

using F = bool;  // false = nothing, true = inverse

S mapping(F f, S x){
    if(f){
        return S{x.n1, x.n0, x.n0 * x.n1 - x.ninv};
    }else{
        return x;
    }
}

F composition(F f, F g){ return f != g; }

F id(){ return false; }

int main(){
    ll n, q;
    cin >> n >> q;
    vector<S> a(n);
    REP(i, n){
        ll ai;
        cin >> ai;
        if(ai == 0){
            a.at(i) = S{1, 0, 0};
        }else{
            a.at(i) = S{0, 1, 0};
        }
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> st(a);

    REP(i, q){
        ll t, l, r;
        cin >> t >> l >> r;
        l--; r--;
        if(t == 1){
            st.apply(l, r + 1, true);
        }else{
            cout << st.prod(l, r + 1).ninv << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 20448
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32

int main() {
	int n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0;
		return 0;
	
	}
	vector<ll>v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	cout << v[n / 2] - v[n / 2 - 1];
}
	



Measured memory_bytes: 4060
n = int(input())
stw = []
x_list = []
y_list = []
for i in range(n):
  x, y = map(int, input().split())
  x_list += [[x, i]]
  y_list += [[y, i]]
x_list.sort()
y_list.sort()

for [u, fr], [v, to] in zip(x_list, x_list[1:]):
  stw += [[abs(u-v), fr, to]]
for [u, fr], [v, to] in zip(y_list, y_list[1:]):
  stw += [[abs(u-v), fr, to]]

stw = sorted(stw, key=lambda x:x[0])

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())


def kruskal():
  # stw = [[s0, t0, w0], [s1, t1, w1], ..., [sn, tn, wn]]
  # stw: s: 始点, t: 終点, w: st間の重み
  # stwはwを小さい順にソートされたものとする
  res = 0
  uf = UnionFind(n)
  #while stw:
  for i in range(len(stw)):
    #w, s, t = heapq.heappop(stw)
    w, s, t = stw[i]
    if not uf.isSameGroup(s, t):
      uf.Unite(s, t)
      res += w
  return res

print(kruskal())

Measured memory_bytes: 66028
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
n = int(input())
B = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(n):
    N =  int(input())
    for num, j in enumerate([A1,A2,A3]):
        for num2, k in enumerate(j):
            if k == N:
                B[num][num2] = True
                
flag = False
for i in B:
    if i[0]==True and i[1]==True and i[2]==True:
        flag = True
        break
else:
    for i in range(3):
        if B[0][i]==True and B[1][i]==True and B[2][i]==True:
            flag = True
            break
    else:
        if (B[0][0]==True and B[1][1]==True and B[2][2]==True) or (B[0][2]==True and B[1][1]==True and B[2][0]==True):
            flag = True

if flag == True:
    print("Yes")
else:
    print("No")




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

int main( int argc, char *argv[] )
{
int N;
int K;
int X;
int Y;

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

	cin >> N;
	cin >> K;
	cin >> X;
	cin >> Y;
	if( N <= K )
		cout << N * X << endl;
	else
		cout << K * X + ( N - K ) * Y << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int[] pl = new int[n];
    for(int i = 0; i < n; i++){
      pl[i] = Integer.parseInt(sc.next());
    }
    int max = 0;
    int cur = 0;
    for(int i = 0; i < n - 1; i++){
      max = Math.max(max, pl[i + 1] - pl[i]);
      if(max == pl[i + 1] - pl[i]){
        cur = i;
        
      }
    }
    max = Math.max((pl[0] + k) - pl[n - 1], max);
    if(max == pl[0] + k - pl[n - 1]){
      System.out.println(pl[n - 1] - pl[0]);
    }else{
      System.out.println(pl[cur] + k - pl[cur + 1]);
    }
  }
}

Measured memory_bytes: 51320
S = gets.chomp; x, y = gets.split.map(&:to_i)

x -= $~[0].size if /^F+/ =~ S
hs, vs, h_flag = [0], [0], true
S.scan(/(T+)(F+)/).each do |ts, fs|
  h_flag = !h_flag if ts.size.odd?
  a = fs.size
  (h_flag ? hs : vs).map!{|k| [k + a, (k - a).abs]}.flatten!.uniq!
end

puts hs.member?(x.abs) && vs.member?(y.abs) ? 'Yes' : 'No'

Measured memory_bytes: 3196
def b_frog_2(stones, N,  k):
    dp = [10 ** 9] * N
    dp[0] = 0
    for i in range(1, N):
        for j in range(max(0, i - k), i):
            dp[i] = min(dp[i], dp[j] + abs(stones[i] - stones[j]))
    return dp[-1]
 
 
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
print(b_frog_2(h, N,  K))
 

Measured memory_bytes: 53368
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {

	int A, B, C; cin >> A >> B >> C;
	int K; cin >> K;
	int cnt = 0;
	while (B <= A) {
		cnt++;
		B *= 2;
	}
	while (C <= B) {
		cnt++;
		C *= 2;
	}
	if (cnt <= K)print("Yes");
	else print("No");
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> z(n, vector<int>(2));
    for (int i = 0; i < n; i++){
        cin >> z[i][0] >> z[i][1];
    }
    int ans;
    if (n == 1){
        ans = 1;
    }
    else{
        unordered_map<int, unordered_map<int, int>> d;
        int m = 0;
        for (int i = 0; i < n; i++){
            int xi = z[i][0];
            int yi = z[i][1];
            for (int j = 0; j < n; j++){
                if (i == j) continue;
                int xj = z[j][0];
                int yj = z[j][1];
                d[xi - xj][yi - yj] += 1;
                m = max(m, d[xi - xj][yi - yj]);
            }
        }
        ans = n - m;
    }
    cout << ans << endl;
}


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

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int N; cin >> N;

	ll sum = 0;
	vector<ll> cnt(1e5 + 5);
	for (int i = 0; i < N; i++) {
		ll x; cin >> x;
		cnt[x]++;
		sum += x;
	}

	int Q; cin >> Q;
	while (Q--) {
		ll B, C;
		cin >> B >> C;
		sum -= B * cnt[B];
		sum += C * cnt[B];
		cnt[C] += cnt[B];
		cnt[B] = 0;
		cout << sum << '\n';
	}

	return 0;
}

Measured memory_bytes: 4000
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,w,d=MI()
mp=[LI() for i in range(h)]
lis=[[0,0] for i in range(w*h)]
for i in range(h):
    for j in range(w):
        lis[mp[i][j]-1]=[i,j]
#print(lis)

costs=[0 for i in range(h*w+1)]
for i in range(1,d+1):
    for j in range(0,h*w):
        if i+d*(j+1)<h*w+1:
            costs[i+d*(j+1)]=costs[i+d*j]+abs(lis[i+d*(j+1)-1][1]-lis[i+d*j-1][1])+abs(lis[i+d*(j+1)-1][0]-lis[i+d*j-1][0])
        else:
            break
q=I()
for i in range(q):
    l,r=MI()
    u=l%d
    print(costs[r]-costs[l])

        


    
    


    

    
            
        
        
    
    
    
    

    
    


    
    

        
        
    


    

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

int main(){
  int64_t N;
  cin >> N;
  int64_t count = 0;
  vector<int64_t> a(0);
  
  for (int i = 0; i < N; i++){
    a.push_back(i + 1);
  }
  
  for (int j = 0; j < N; j++){
    
    if (a.at(j) % 3 == 0 || a.at(j) % 5 == 0){
      count += 0;
    }
    else{
      count += a.at(j);
    }
  }
  
  cout << count << endl;
}
  

Measured memory_bytes: 11584
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
    bool operator!=(const mint a){
		return x != a.x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<mint> dp(n+5, 0);
    rep(i,m){
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    rep(i,n+1){
        if(dp[i] == -1) continue;
        if(dp[i+1] != -1) dp[i+1] += dp[i];
        if(dp[i+2] != -1) dp[i+2] += dp[i];
    }
    cout << dp[n].x << endl;
	return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;

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

        StringBuilder sb = new StringBuilder();
        for(int i=0; i<s.length; i++) {
            if(i % 2 == 0) {
                sb.append(s[i]);
            }
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 24120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    int v[n];
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v, v + n);
    double out = v[0];
    for (int i = 1; i < n; i++){
        out += v[i];
        out /= 2.;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int n,m;
    scanf("%d",&n);
    scanf("%d",&m);
    int A[100][100];
    int B[100];
    int C[100] = {0};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d",&B[i]);
    }
    for(int i=0;i<n;i++){
        C[i]=0;
        for(int j=0;j<m;j++){
            C[i]+=A[i][j]*B[j];
        }
        printf("%d\n",C[i]);
    }
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


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

signed main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    int ans = 0;
    REP(i,A+1){
        REP(j,B+1){
            REP(k,C+1){
                if(500*i+100*j+50*k==X){
                    ans ++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long int
using namespace std;

int main() {
	int N, D, num=0;
	long double xy;
	cin >> N >> D;
	vector<ll> x(N), y(N);
	
	for (int i = 0; i < N; i++){
		cin >> x[i] >> y[i];
	}

	for (int i = 0; i < N; i++){
		xy = sqrt(x[i] * x[i] + y[i] * y[i]);
		if (xy<=D){
			num++;
		}
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 6484
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete


main = do
    s <- getInt
    when (s/=0) $ do
        replicateM 9 getInt >>= print . (s-) . sum
        main

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;

int main(void){
    // Your code here!
    int n, k;
    cin >> n >> k;
    
    vector<int> x(n);
    for (int i=0; i<n; i++) cin >> x[i];
    
    int ans = INT_MAX;
    
    for (int i=0; i<n; i++){
        
        // l -> r
        if(i+k-1 < n){
            // cout << "l: " << i << " r: " << i+k << endl;
            ans = min(ans, abs(x[i]) + abs(x[i] - x[i+k-1]));
            ans = min(ans, abs(x[i+k-1]) + abs(x[i] - x[i+k-1]));
        }
        
    }
    cout << ans << endl;
}


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

string n;

array<vector<ll>, 2> dp;
array<vector<bool>, 2> flag;

ll solve(ll pos, ll state){
    if(flag.at(state).at(pos)){
        return dp.at(state).at(pos);
    }

    ll d = n.at(pos) - '0';
    if(state == 1){
        d = 10 - d;
    }
    ll ret = 0;
    if(state == 0){
        if(pos == n.size() - 1){
            if(d <= 5){
                ret = d;
            }else{
                ret = 1 + solve(pos, 1 - state);
            }
        }else{
            ret = d + solve(pos + 1, state);
            ret = min(
                ret,
                d + 1 + solve(pos + 1, 1 - state)
            );
        }
    }else{
        if(pos == n.size() - 1){
            if(d <= 5){
                ret = d;
            }else{
                ret = 1 + solve(pos, 1 - state);
            }
        }else{
            assert(d > 0);
            ret = d - 1 + solve(pos + 1, state);
            ret = min(
                ret,
                d + solve(pos + 1, 1 - state)
            );
        }
    }
    flag.at(state).at(pos) = true;
    dp.at(state).at(pos) = ret;
    return ret;
}

int main(){
    cin >> n;
    n.insert(0, 1, '0');
    REP(i, 2){
        dp.at(i).resize(n.size());
        flag.at(i).resize(n.size());
        fill(flag.at(i).begin(), flag.at(i).end(), false);
    }
    cout << solve(0, 0) << endl;
    return 0;
}


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

int main(){
  int n,m;cin>>n>>m;
  vector<string> a(n),b(m);
  REP(i,n) cin>>a.at(i);
  REP(i,m) cin>>b.at(i);

  REP(i,n-m+1) REP(j,n-m+1){
    bool f=1;
    REP(k,m) if(a.at(i+k).substr(j,m)!=b.at(k)) f=0;
    if(f){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}


Measured memory_bytes: 256
S = gets.chomp
T = gets.chomp

hash1 = Hash.new
hash2 = Hash.new
S.length.times do |i|
    a = S[i]
    b = T[i]
    if hash1[a] == nil && hash2[b] == nil
        hash1[a] = b
        hash2[b] = a
    elsif hash1[a] == b && hash2[b] == a
    else
        puts "No"
        break
    end 
end and puts "Yes"

Measured memory_bytes: 2624
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std ;

int main(void){
    int N,K,Q;
    string res;

    cin >> N >> K >> Q;
    int A[Q];
    int p[N]={};

    for(int i=0; i<Q; i++){
        cin >> A[i];
    }

    for(int i=0; i<Q; i++){
        p[A[i]-1]++; //正解数
    }

    for(int i=0; i<N; i++){
        if(K - Q + p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  int n,q;
  vector<int> s,t;

  cin >> n;
  s.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> s[ii];
  }

  cin >> q;
  t.resize(q);
  for(ii=0;ii<q;ii++){
    cin >> t[ii];
  }

  sort(s.begin(),s.end());

  int cnt = 0;
  for(auto val : t){
    if(binary_search(s.begin(),s.end(),val)){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}



Measured memory_bytes: 3436
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

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

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else if(n == 2){
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
}






Measured memory_bytes: 3504
# ABC 136 C
n = int(input())
h = [ int(_) for _ in input().split() ]
flag = True

for i in range(len(h)-1, 0, -1):
    if h[i-1] == h[i] +1:
        h[i-1] = h[i-1]-1  
        
for j in range(0,len(h)-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        break
        
if flag == True:
    print('Yes')

Measured memory_bytes: 14396
#include <stdio.h>
#include <string.h>
char str[100000];
int count=0;
void change(int);
int main(void){
    scanf("%s",str);
    change(0);
    if(count>0) printf("YES\n");
    else printf("NO\n");
    return 0;
}
void change(int begin){
	char s1[10]="";
	char s2[10]="";
	char s3[10]="";
	int i;
	if(begin==strlen(str)) count++;
	if(begin>strlen(str)-4) return;
	for(i=0;i<5;i++)
		s1[i] = str[begin+i];
	for(i=0;i<6;i++)
	    s2[i] = str[begin+i];
	for(i=0;i<7;i++)
	    s3[i] = str[begin+i];
	if(strcmp(s1,"dream")==0||strcmp(s1,"erase")==0)
	    change(begin+5);
	if(strcmp(s2,"eraser")==0)
	    change(begin+6);
	if(strcmp(s3,"dreamer")==0)
	    change(begin+7);
    return;
}


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

using namespace std;

string s, t;
int l;

int main()
{

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

    cin >> s >> t;
    l = s.length();

    for(int i = 0; i < l; ++i){
        if(s[i] != t[i]){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 3636
n = int(input())
l = []
for i in range(n):
    a = int(input())
    l1 = []
    for j in range(a):
        x = list(map(int,input().split()))
        l1.append(x)
    l.append(l1)
al = []
for i in range(2**n):
    key = 0
    ans = 0
    rl = [-1 for i in range(n)]
    for j in range(n):
        if i//(2**(n-j-1)) == 1:
            i -= 2**(n-j-1)
            if rl[j] == 0:
                key = 1
                break
            elif rl[j] == -1:
                rl[j] = 1
                ans += 1
            for k in l[j]:
                if rl[k[0]-1] == -1:
                    rl[k[0]-1] = k[1]
                    if k[1] == 1:
                        ans += 1
                else:
                    if rl[k[0]-1] != k[1]:
                        key = 1
                        break
        else:
            if rl[j] == 1:
                key = 1
                break
            else:
                rl[j] = 0
        #print(rl)
    if key == 1:
        al.append(0)
    else:
        al.append(ans)
print(max(al))

Measured memory_bytes: 3508
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  fastio;
  string s;
  cin>>s;
  int md=2019;
  int n=s.length();
  vector<ll> count_suffix(2019);
  ll ans=0;
  ll pot=1;
  ll suffix=0;
  count_suffix[suffix]++;
  for(int i=n-1;i>=0;i--)
  {
    int digit=s[i]-'0';
    suffix=(suffix + digit*pot)%md;
    pot=pot*10%md;
    ans+=count_suffix[suffix];
    count_suffix[suffix]++;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3716
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 C=sc.nextInt();
        int X=sc.nextInt();
        int ans=0;
        for(int i=0;A>=i;i++){
            for(int j=0;B>=j;j++){
                for(int k=0;C>=k;k++){
                if(500*i+100*j+50*k==X){
                    ans++;
                }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int a[10000];
int main() {
  int n;
  cin >> n;
  REP(i,n) cin >> a[i];
  ll c;
  REP(i,n) {
    while(a[i]%2 == 0) {
      c++;
      a[i] = a[i]/2;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#6484898
from bisect import bisect
N= int(input())
A = []
for i in range(N):
    t = int(input())
    A.append(t)

D = [1]*(N+1)
D[0] = -10**10
for a in A:
    idx = bisect(D, -a)
    D[idx] = min(D[idx], -a)
print(bisect(D, 0)-1)

Measured memory_bytes: 52184