akhauriyash/Code-Regression huggingface dataset:
import sys

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

### だめな条件
# N>=2のときに、左から1桁目が0
# 同じ桁なのに値が違う

### いいとき
# 何もなければ0を埋める

### 作りたいdict
# {"1": 3, "2": 3, }

mydict = {}
for i in range(M):
    s, c = map(int,(input().split()))
    if N >= 2 and s == 1 and c == 0:
        print(-1)
        sys.exit(0)

    if s in mydict:
        if mydict[s] != c:
            print(-1)
            sys.exit(0)
    else:
        mydict[s] = c

# 1桁目を埋める処理
if N >= 2 and 1 not in mydict:
    mydict[1] = 1

# 出力
for i in range(1, N+1):
    if i in mydict:
        print(mydict[i], end='')
    else:
        print(0, end='')


Measured memory_bytes: 3064
#include <iostream>


using namespace std;

int main(){

    int A, B, T;
    cin >> A >> B >> T;
    
    int t = A;
    int bis = 0;
    
    
    while (T >= t) {
        bis += B;
        t += A;
    }
    
    cout << bis << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

ll ab(ll x){
    return max(x,-x);
}

int main(){
    fastIO;
    int n;
    cin >> n;
    ll sum = 0;
    ll a[n];
    for(int i = 0 ; i < n ; i ++ ){
        cin >> a[i];
        sum += a[i];
    }
    ll v1 = 0, v2 = 0;
    ll mn = (ll)1e18;
    for(int i = 0 ; i < n-1 ; i ++ ){
        v1 += a[i];
        v2 = sum - v1;
        mn = min(mn, ab(v1-v2));
    }
    cout << mn;
    return 0;
}


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

int main()
{
    int s;
    cin >> s;
    
    int ss = s % 60;
    
    int mm = (s / 60) % 60;

    int hh = s / 3600;
    
    cout << hh << ":" << mm << ":" << ss << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int x,y;
};

int** table;

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	Info info[N];

	vector<int> First_X,First_Y;

	First_X.push_back(-BIG_NUM);
	First_Y.push_back(-BIG_NUM);
	First_X.push_back(BIG_NUM);
	First_Y.push_back(BIG_NUM);

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].x,&info[i].y);

		First_X.push_back(info[i].x);
		First_Y.push_back(info[i].y);
	}

	sort(First_X.begin(),First_X.end());
	sort(First_Y.begin(),First_Y.end());

	First_X.erase(unique(First_X.begin(),First_X.end()),First_X.end());
	First_Y.erase(unique(First_Y.begin(),First_Y.end()),First_Y.end());

	int H = (int)First_Y.size(),W = (int)First_X.size();

	table = new int*[H];
	for(int row = 0; row < H; row++){
		table[row] = new int[W];
		for(int col = 0; col < W; col++){
			table[row][col] = 0;
		}
	}

	int tmp_x,tmp_y;

	for(int i = 0; i < N; i++){

		for(int k = 0; k < W; k++){
			if(First_X[k] == info[i].x){
				tmp_x = k;
				break;
			}
		}

		for(int k = 0; k < H; k++){
			if(First_Y[k] == info[i].y){
				tmp_y = k;
				break;
			}
		}

		table[tmp_y][tmp_x]++;
	}

	for(int row = 0; row < H; row++){
		for(int col = 1; col < W; col++){
			table[row][col] += table[row][col-1];
		}
	}

	for(int col = 0; col < W; col++){
		for(int row = 1; row < H; row++){
			table[row][col] += table[row-1][col];
		}
	}


	int x1,y1,x2,y2;
	int calc_x1,calc_y1,calc_x2,calc_y2;
	int left,right,m;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

		calc_y1 = 0;
		left = 0,right = H-1,m = (left+right)/2;

		while(left <= right){
			if(First_Y[m] >= y1){
				calc_y1 = m;
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}

		calc_y1--;

		calc_y2 = H-1;
		left = 0,right = H-1,m = (left+right)/2;

		while(left <= right){
			if(First_Y[m] <= y2){
				calc_y2 = m;
				left = m+1;
			}else{
				right = m-1;
			}
			m = (left+right)/2;
		}


		calc_x1 = 0;
		left = 0,right = W-1,m = (left+right)/2;

		while(left <= right){
			if(First_X[m] >= x1){
				calc_x1 = m;
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}

		calc_x1--;

		calc_x2 = W-1;
		left = 0,right = W-1,m = (left+right)/2;

		while(left <= right){
			if(First_X[m] <= x2){
				calc_x2 = m;
				left = m+1;
			}else{
				right = m-1;
			}
			m = (left+right)/2;
		}

		int A,B,C;
		if(calc_y1 >= 0){
			A = table[calc_y1][calc_x2];
		}else{
			A = 0;
		}

		if(calc_x1 >= 0){
			B = table[calc_y2][calc_x1];
		}else{
			B = 0;
		}

		if(calc_y1 >= 0 && calc_x1 >= 0){
			C = table[calc_y1][calc_x1];
		}else{
			C = 0;
		}

		printf("%d\n",table[calc_y2][calc_x2]-A-B+C);
	}

	return 0;
}

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

int main() {
  unordered_set<int> a;
  for (int i = 0; i < 2; i++) {
    int b;
    cin >> b;
    a.insert(b);
  }
  for (int i = 1; i <= 3; i++) {
    if (a.find(i) == a.end()) {
      cout << i << endl;
      return 0;
    }
  }
}

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

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

  vector<vector<int>> t(n + 1, vector<int>(n + 1));

  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= i; j--) {
      if (s[i] == s[j]) {
        t[i][j] = t[i + 1][j + 1] + 1;
      }
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (t[i][j] <= j - i) {
        ans = max(ans, t[i][j]);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n;
    cin >> n;
    cout << n << ":";
    ll m = n;
    for (ll d = 2; d * d < n; d++) {
        while (m % d == 0) {
            cout << " " << d;
            m /= d;
        }
    }
    if (m != 1) cout << " " << m;
    cout << endl;
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    string b;
    ll a,ans = 0; 
    cin >> a >> b;

    ll b_l = 0;
    b_l += (b[0]-'0');
    b_l *= 10;
    b_l += (b[2]-'0');
    b_l *= 10;
    b_l += (b[3]-'0');
    
    ans = a*b_l/100;

    cout << ans << "\n";
    return 0;
}


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

vector<pair<long long, long long>> prime_factorize(ll num)
{
    vector<pair<long long, long long> > res;
    for(ll i=2;i*i<=num;i++){
        if(num%i!=0)continue;
        ll ex=0;
        while(num%i==0){
            ex++;
            num/=i;
        }
        res.push_back(make_pair(i, ex));
    }
    if (num!=1) res.push_back(make_pair(num, 1));
    return res;
}

int main()
{
    ll N;
    cin >> N;
    auto pf=prime_factorize(N);
    ll res=0;
    for(auto p:pf){
        ll e=p.second;
        ll max=0;
        ll x=1;
        while(e>=x)e-=x++,++max;
        res+=max;
    }    
    cout<<res;
    return 0;
}

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

int main(){

  int ans1,ans2,n;
  string s;
  ans1 = 0;
  ans2 = 0;

  cin >> s;
  n = s.size();
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='1'){
        ans1++;
      }
      else{
        ans2++;
      }
    }
    else{
      if(s[i]=='0'){
        ans1++;
      }
      else{
        ans2++;
      }
    }
  }

  if(ans1<ans2){
    cout << ans1 << endl;
  }
  else{
    cout << ans2 << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,p;
  cin>>N;
  vec v(N,inf);
  priority_queue<datas,pvec,greater<datas>> que;
  que.push(datas(1,1));
  while(v[0]==inf){
    auto x=que.top();que.pop();
    if(v[x.second]!=inf)continue;
    v[x.second]=x.first;
    p=x.second*10%N;
    if(v[p]==inf)que.push(datas(x.first,p));
    p=(x.second+1)%N;
    if(v[p]==inf)que.push(datas(x.first+1,p));
  }
  cout<<v[0]<<endl;
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for (i=0; i<n1; i++) {
    L[i]=A[left+i];
  }
  for (i=0; i<n2; i++) {
    R[i]=A[mid+i];
  }
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for (k=left; k<right; k++) {
    if (L[i].value<=R[j].value) {
      A[k]=L[i++];
    } else {
      A[k]=R[j++];
    }
  }
}
void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for (j=p; j<r; j++) {
    if (A[j].value<=x.value) {
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
int main() {
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  scanf("%d",&n);
  for (i=0; i<n; i++) {
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  for (i=0; i<n; i++) {
    if (A[i].suit!=B[i].suit) {
      stable=0;
    }
  }
  if (stable==1) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }
  for (i=0; i<n; i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}




Measured memory_bytes: 5516
#include <stdio.h>

int main(void) {
    int n, i = 1;
    
	while(true)
	{
		scanf("%d", &n);
		if(n ==0)
		{
			break;
		}
		printf("Case %d: %d\n", i, n);
		i++;
	}
    return 0;
}


Measured memory_bytes: 2732
# include <cstdio>
# include <algorithm>
using namespace std;

static const int maxn = 100 + 2;
int n, a[maxn], cnt;

void put_out() {
    for (int i = 0; i < n-1; i++) printf("%d ", a[i]);
    printf("%d\n%d\n", a[n-1], cnt);
}

void bubblesort() {
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int i = n-1; i > 0; i--) {
			if (a[i] < a[i-1]) {
				swap(a[i], a[i-1]);
				flag = 1;
				cnt++;
			}
		}
	}
}

int main() {
    // freopen("data.in", "r", stdin);
    // freopen("data.out", "w", stdout);
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);
        cnt = 0;
        bubblesort();
        put_out();
    }
    return 0;
}



Measured memory_bytes: 2744
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
 
int main()
{
    int n,m;
    cin>>n>>m;
    bool a[n][n],b[m][m];
    char c;
    rep(i,n)rep(j,n) cin>>c, a[i][j]=(c=='#');
    rep(i,m)rep(j,m) cin>>c, b[i][j]=(c=='#');
    for(int i=0;i<=n-m;i++)for(int j=0;j<=n-m;j++){
        bool f=1;
        for(int x=i;x<i+m;x++)for(int y=j;y<j+m;y++) if(a[x][y]!=b[x-i][y-j]) f=0;
        if(f) cout<<"Yes\n",exit(0);    
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
local n = io.read("*n", "*l")
local s = io.read()
local sa = {}
for i = 1, n do
  table.insert(sa, {i, s:sub(i, n)})
end
table.sort(sa, function(x, y) return x[2] < y[2] end)
local lcpa = {}
for i = 1, n do
  lcpa[i] = {}
  for j = 1, n do
    lcpa[i][j] = 0
  end
end
local mmi, mma = math.min, math.max
for i = 1, n - 1 do
  local len = mmi(#sa[i][2], #sa[i + 1][2])
  local c = 0
  for j = 1, len do
    if sa[i][2]:sub(j, j) == sa[i + 1][2]:sub(j, j) then
      c = c + 1
    else break end
  end
  local i1, i2 = sa[i][1], sa[i + 1][1]
  lcpa[i1][i2], lcpa[i2][i1] = c, c
end
for i = 1, n - 2 do
  local prv = lcpa[sa[i][1]][sa[i + 1][1]]
  if 0 < prv then
    for j = i + 1, n - 1 do
      local nxt = lcpa[sa[j][1]][sa[j + 1][1]]
      if nxt == 0 then
        break
      else
        prv = mmi(prv, nxt)
        lcpa[sa[i][1]][sa[j + 1][1]], lcpa[sa[j + 1][1]][sa[i][1]] = prv, prv
      end
    end
  end
end
local ret = 0
for i = 1, n - 1 do
  for j = i + 1, n do
    ret = mma(ret, mmi(j - i, lcpa[i][j]))
  end
end
print(ret)


Measured memory_bytes: 336896
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int age;
	int than_ten, ten, twen, thir, four, fif, six;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		than_ten = ten = twen = thir = four = fif = six = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &age);
			if (age >= 0 && age < 10){
				than_ten++;
			}
			else if (age < 20){
				ten++;
			}
			else if (age < 30){
				twen++;
			}
			else if (age < 40){
				thir++;
			}
			else if (age < 50){
				four++;
			}
			else if (age < 60){
				fif++;
			}
			else if (age >= 60){
				six++;
			}
		}
		
		printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n", than_ten, ten, twen, thir, four, fif, six);
		
	}
	
	return (0);
}

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    string ans = "Impossible";
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        ans = "Possible";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

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

int func(int x) {
	if (x % 100 != 0)return 0;
	return 1 + func(x / 100);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int D, N;
	cin >> D >> N;
	int cnt = 0;

	for (int x = 1;; x++) {
		if (func(x) == D) {
			cnt++;
			if (cnt == N) {
				cout << x << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

int main(){
    int N, X;
    cin >> N >> X;
    int res10 = -1;
    int res5 = -1;
    int res1 = -1;
    

    for(int i = 0; i<= N; i++){
        for(int j = 0; j + i<= N; j++){
            int k = N - (i + j);
            int total = 10000*i + 5000*j + 1000*k;
            if (total == X){
                res10 = i;
                res5 = j;
                res1 = k;
            }
        }
    }
    cout << res10 << " " << res5 << " " << res1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <limits>
//std::numeric_limits<int>::max(), min()

typedef long long ll;

ll N, W;
std::vector<std::vector<ll>> dp;
std::vector<std::pair<ll,ll>> items;

ll sol ( ll n, ll w ) {
  if ( n == 0 ) return 0;
  if ( dp[n][w] != -1 ) return dp[n][w];

  ll rtn = 0;
  if ( w-items[n].first >= 0 ) rtn = std::max( (sol(n-1, w-items[n].first) + items[n].second), sol(n-1,w) ) ;
  else rtn = sol(n-1, w);
  return dp[n][w] = rtn;
}

int main (void) {

  std::cin >> N >> W;

  items.resize(N+1);
  for(ll i=0; i<N; i++) std::cin >> items[i+1].first >> items[i+1].second;

  dp.resize(N+1); for(int i=0; i<N+1; i++) dp[i].assign(W+1, -1);
  std::cout << sol(N,W) << std::endl;

  return 0;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<vector<pair<int, int>>>G(N);
	rep(i, 0, N) {
		int a; cin >> a;
		rep(j, 0, a) {
			int x, y; cin >> x >> y;
			G[i].push_back(make_pair(x - 1, y));
		}
	}
	int ans = 0;
	for (int bit = 0;bit < (1 << N);++bit) {
		bool is = true;
		rep(i, 0, N) {
			if (bit & (1 << i)) {
				for (auto p : G[i]) {
					int x = p.first, y = p.second;
					if (bit & (1 << x)) {
						if (y == 0)is = false;
					}
					else if (y == 1)is = false;
				}
			}
		}
		bitset<20>cnt = bit;
		if (is)chmax(ans, (int)cnt.count());
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


int main() {
    int N; cin >> N;
    vector<vector<int>> table(N, vector<int>(26));
    vector<string> S(N);
    for(int i=0; i<N; i++){
        string s; cin >> s;
        for(int j=0; j<s.size(); j++){
            table[i][s[j]-'a']++;
        }
    }

    string hibari = "";
    for(int i=0; i<26; i++){
        int cnt = 2500;
        for(int j=0; j<N; j++)
            cnt = min(cnt, table[j][i]);
        for(int j=0; j<cnt; j++)
            hibari += char('a' + i);
    }

    cout << hibari << endl;
    return 0;
}


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

int X, N;
vector<int> p;
int d = 1000000;
int num = 1000000;
bool able = false;


int main(){
  cin >> X >> N;
  
  int val;
  for(int i = 0; i < N; i++){ cin >> val; p.push_back(val); }
  for(int i = -50; i <= 150; i++){
    for(int j = 0; j < N; j++){
      if(p[j] == i){ able = true; break; }
    }
    if(able){ able = false; continue; }
    if(d > abs(X-i)){ num = i; d = abs(X-i); }
  }
  
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main (){
	int a,b,c;
	scanf("%d %d %d", &a, &b,&c);
	int check;
    int d = 0;
        for (int i = a; i <= b; i++){
            if (i % c == 0){
            d = d + 1;
            }
    	}
    printf("%d\n", d);
    return 0;
}

Measured memory_bytes: 1728
#include<iostream>
using namespace std;
int main(){
  int k, s;
  cin >> k >> s;
  int ans = 0;
  int z;
  for(int x=0; x<=k; x++){
    for(int y=0; y<=k; y++){
      z = s - x - y;
      if(0<=z&&z<=k){
	  ans = ans + 1;      
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int A,B,C;

int main(){
	cin>>A>>B>>C;
	cout<<min(B/A,C)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
 static int h[];
 public static void main(String[] args) {   
   h = new int[1000];
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   try{
    while(true){
     String str[]=br.readLine().split(" ");
     int w=Integer.parseInt(str[0]);
     int q=Integer.parseInt(str[1]);
     if(w+q==0)break;
     for(int i=0;i<w;i++)h[i]=-1;
     for(int i=0;i<q;i++){
      str=br.readLine().split(" ");
      char ch=str[0].charAt(0);
      if(ch=='s'){
       int id=Integer.parseInt(str[1]);
       int cw=Integer.parseInt(str[2]);
       sleep(id,cw,w);
      }
      else{
       int id=Integer.parseInt(str[1]);
       wake(id,w);
      }
     }
    System.out.println("END");
    }
   }
   catch(Exception e){
System.out.println("err");
   }
 }

 public static void sleep(int id, int cw , int w){
  int s=0, b=0,f=0;
  for(int i=0;i<w;i++){
   if(f==1)break;
   if(h[i]==-1){
    b=i;
    for(int j=i;j<i+cw;j++){
     if(h[j]!=-1 || f==1){s=0;b=0;break;} 
     s++;
     if(s==cw){
      for(int k=b;k<b+cw;k++)h[k]=id;
      System.out.println(b);
      f=1;
     }
    }
   }
  }
  if(f==0)System.out.println("impossible");
 }

 public static void wake(int id, int w){
  for(int i=0;i<w;i++)
    if(h[i]==id)h[i]=-1;
 }
}
 


Measured memory_bytes: 24396
#include<iostream>
using namespace std;
int M[55][55];
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int main()
{
	int n,m;
	cin>>n>>m;
	char c;
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	{
		cin>>c;
		if(c=='.') M[i][j]=0;
		if(c=='#') M[i][j]=1;
	}
	int flag=1;
	for(int i=0;i<n;i++)
	   {
	   	for(int j=0;j<m;j++)
	      {
	      	
	      	if(M[i][j]==1)
	      	{
                int flag1=0;
	      		for(int s=0;s<4;s++)
	      		{
	      			int dx=i+dir[s][0];
	      			int dy=j+dir[s][1];
	      			if(dx>=0&&dy>=0&&dx<n&&dy<m&&M[dx][dy]==1) flag1=1; 
				  }
				   if(flag1==0)
			     {  
			  	flag=0;
			  	break;
			     }
			  }
			  
		  }
		  if(flag==0) break;
	   }
	if(flag==0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
 } 
 

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();

		BigDecimal r = new BigDecimal(line);
		BigDecimal p = new BigDecimal(Math.PI);
		BigDecimal c = r.multiply(r);
		BigDecimal m = c.multiply(p);

		BigDecimal two = new BigDecimal("2");
		BigDecimal d = r.multiply(two);
		BigDecimal s= d.multiply(p);

		m.setScale(7, BigDecimal.ROUND_DOWN);
		s.setScale(7, BigDecimal.ROUND_DOWN);
		System.out.print(m);System.out.println(" "+s);
	}
}

Measured memory_bytes: 26380
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;

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

  cin >> S;
  
  int t1 = (S[0]-'0')*10 + (S[1]-'0');
  int t2 = (S[2]-'0')*10 + (S[3]-'0');
  
  cerr << "t1: " << t1 << ", t2: " << t2 << endl;

  bool m1 = false, y1 = false;
  if (1 <= t1 && t1 <= 12) m1 = true;
  else y1 = true;
  
  bool m2 = false, y2 = false;
  if (1 <= t2 && t2 <= 12) m2 = true;
  else y2 = true;

  if (m1 && m2) {
      cout << "AMBIGUOUS" << endl;
  } else if (y1 && m2) {
      cout << "YYMM" << endl;
  } else if (m1 && y2) {
      cout << "MMYY" << endl;
  } else {
      cout << "NA" << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
struct vect{
  long long int x;
  long long int y;
};

int main()
{
  int K,N,ind,count=0;
  long long int S,minS=44E17+1,maxX,minX,maxY,minY;
  struct vect v[51],tmp;
  cin >> N >> K;
  REP(i,N)cin >> v[i].x >> v[i].y;

  REP(x1,N)REP(x2,N)REP(y1,N)REP(y2,N){
    count = 0;
    REP(i,N){
      if(v[x2].x <= v[i].x && v[i].x <= v[x1].x && v[y2].y <= v[i].y && v[i].y <= v[y1].y)
        count++;
    }
    S = (v[x1].x-v[x2].x)*(v[y1].y-v[y2].y);
    if(S >= 0 &&  K <= count){
      minS = min(minS,S);
    }
    else
      continue;
  }
  cout << minS << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

double x[4], y[4];
int main() {
  while (true) {
    for (int i=0; i<4; ++i) cin >> x[i] >> y[i];
    if (!cin) break;

    xy_t a(x[0],y[0]), b(x[1],y[1]), c(x[2],y[2]), p(x[3],y[3]);
    bool tri1 = cross_product(a-p,b-p) > 0;
    bool tri2 = cross_product(b-p,c-p) > 0;
    bool tri3 = cross_product(c-p,a-p) > 0;

    bool tri4 = cross_product(a-p,b-p) < 0;
    bool tri5 = cross_product(b-p,c-p) < 0;
    bool tri6 = cross_product(c-p,a-p) < 0;

    bool ok = tri1*tri2*tri3;
    if (ok != 1) ok = tri4*tri5*tri6;

    cout << (ok ? "YES" : "NO") << endl;
  }
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

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

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

  ll ans = 0;
  if(a[0] > x){
    ans += a[0] - x;
    a[0] -= a[0] - x;
  }

  for(int i = 1; i < n; i++){
    if(a[i-1] + a[i] > x){
      ans += a[i-1] + a[i] - x;
      a[i] -= a[i-1] + a[i] - x;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    
    int cnt = 0;
    for(int A=1; A<N; A++){
        for(int B=1; A*B<N; B++){
            if(N-A*B > 0) cnt++;
        }
    }

    cout << cnt << endl;
    
}

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

int main(){
	int n,m,c;
	int a[20][20];
	int b[20];
	cin>>n>>m>>c;
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
	}
	}

	int ans=0;
	int sum=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			sum+=b[j]*a[i][j];
		}
		sum+=c;
		if(sum>0)ans++;
		sum=0;
	}

	cout<<ans<<endl;


	return 0;
}

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

UL to[3][6] = {
 {4,0,2,3,5,1},
 {2,1,5,0,4,3},
 {0,2,4,1,3,5}
};

UL Z[100][64][6];

int main() {
 UL N; cin>>N;
 rep(i,N){
  rep(j,6) cin>>Z[i][0][j];
  rep(r1,4){
   if(r1) rep(j,6) Z[i][r1*16][to[0][j]]=Z[i][r1*16-16][j];
   rep(r2,4){
    if(r2) rep(j,6) Z[i][r1*16+r2*4][to[1][j]]=Z[i][r1*16+r2*4-4][j];
    rep(r3,4){
     if(r3) rep(j,6) Z[i][r1*16+r2*4+r3][to[2][j]]=Z[i][r1*16+r2*4+r3-1][j];
 }}}}
 bool diff=true;
 rep(i,N) rep(j,i){
  bool iden=false;
  rep(k,64){
   bool ok=true;
   rep(p,6) if(Z[i][k][p]!=Z[j][0][p]) ok=false;
   if(ok) iden=true;
  }
  if(iden) diff=false;
 }
 cout<<(diff?"Yes":"No")<<endl;
 return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if(N%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  int n = N/2;
  if(S.substr(n) == S.substr(0,n)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


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

int compar(const void *a, const void *b){
	return *(int *)a - *(int *)b;
}

int main(void){
	int n,k,h[100001],i;
  
  	scanf("%d%d", &n,&k);
  
  	for(i=0;i<n;i++){
      	scanf("%d", &h[i]);
    }
  
  	qsort(h,n,sizeof(int),compar);
  
  	int min =h[k-1]-h[0];
  
  	for(i=1;i<n-k+1;i++){
		if((h[i+k-1]-h[i])<min){
			min=h[i+k-1]-h[i];
        }
    }
  	printf("%d", min);
  	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}



int main(){
  string s,t; cin >>s;
  t=s;
  reverse(s.begin(),s.end());
  int n=s.size();
  int cnt=0;
  rep(i,n){
    if(s[i]!=t[i]) cnt++;
  }
  print(cnt/2);
}





Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n,k;
    cin>>n>>k;
    vi a(n);
    map<int,int> ext;
    int cc=0;
    for(int i=0;i<n;i++) 
    {
        cin>>a[i];
        if(!ext.count(a[i])) cc++;
        ext[a[i]]++;
    }
    vi all;
    for(auto u:ext)
        all.push_back(u.second);
    sort(all.begin(),all.end());
    int ans=0;
    for(int i=0;i<cc-k;i++) ans+=all[i];
    print(ans);
}

Measured memory_bytes: 11516
#include<iostream>

using namespace std;

int main (){
  
  long long a,b,c,res;
  
  cin>>a>>b>>c;
  
  if(a+b+1>=c) res=b+c;
  else res=b+(a+b+1);
 
  cout<<res<<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <ctype.h>

using namespace std;
using ll=long long;
using ull=unsigned long long;

int main()
{
    int N;
    
    cin >> N;
    
    int ans = 0;
    
    while (N > 0)
    {
        ans += N--;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
 
using namespace std; 


int main() {

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

    int t;  t = 1; //cin >> t;
    while(t--){
        int n,k; cin >> n >> k;
        vector<int> v(n);
        for(int i = 0; i < n; i++)
            cin >> v[i];
        sort(v.begin(), v.end());
        int answ = 0;
        for(int i = 0; i < k; i++)
            answ += v[i];
        cout << answ << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
function Main(input) {
	var data = input.split("\n");
	var n =  data[1].split(" ").map((n) => parseInt(n, 10));
	var num = 0;
	for(var i=0;i<parseInt(data[0]);i++){
		num += 1/n[i];
	}
	console.log(1/num)
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

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 { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> to(n);
	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int> v(n);
	v[0] = k;
	queue<pii> q;
	q.push(pii(-1, 0));
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int prev = p.first;
		int cur = p.second;
		int t;
		if (prev == -1) t = k - 1;
		else t = k - 2;
		for (int j = 0; j < (int)to[cur].size(); j++) {
			if (v[to[cur][j]]) continue;
			if (to[cur][j] == prev) continue;
			v[to[cur][j]] = t;
			t--;
			q.push(pii(cur, to[cur][j]));
		}
	}
	mint ans = 1;
	rep(i,n) ans *= v[i];
	cout << ans << endl;
}

Measured memory_bytes: 10436
N = int(input())
A = list(map(int,input().split()))

AS = list(set(A))
D = {}
for i in A:
    if i in D.keys():
        D[i] += 1
    else:
        D[i] = 1

accum = []
AS.sort(reverse=True)
for i in AS:
    if D[i] >= 2:
       accum.append(i)

if len(accum) != 0:
   if D[accum[0]] >= 4:
    print(accum[0]**2)
   elif D[accum[0]] >= 2:
    print(accum[0]*accum[1])
else:
    print(0)

Measured memory_bytes: 20232
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	if (S[2]==S[3] and S[4]==S[5]):
		print("Yes")
	else: print("No")

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        ArrayList<Integer> L = new ArrayList<>();
        for(int i=0;i<q;i++){
            int cmd = sc.nextInt();
            if(cmd==0)L.add(sc.nextInt());
            else if(cmd==1) System.out.println(L.get(sc.nextInt()));
            else L.remove(L.size()-1);
        }
    }
}


Measured memory_bytes: 139664
gcds = (1..26).select{|i| 26.gcd(i)==1}
al = ('a'..'z').to_a
gets.to_i.times.each do
  str = gets
  hits = str.split.select{ |chr| chr.length == 4 }
  @alph = gcds.find do |a|
    @beta = (0..25).find do |b|
      %w(this that).any? { |h|
        can = h.split('').map{ |ch| al[(a*al.index(ch)+b)%26] }.join
        hits.include?(can)
      }
    end
  end
  map = (0..25).map{|i| (@alph*i+@beta)%26 }
  puts str.chars.map{|st| al.include?(st) ? al[map.index(al.index(st))] : st }.join
end

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

int main(){
  int X,N;
  bool same = true;
  cin >> X >> N;
  if (N == 0){
    cout << X << endl;
    return 0;
  }
  vector<int>vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
    if (vec.at(i) == X){
      same = false;
    }
  }
  
  if (same) {
    cout << X << endl;
    return 0;
  }
  
  sort(vec.begin(), vec.end());
  int pls;
  for (int i=0; i<N; i++){
    if (vec.at(i) == X){
      pls = i;
    }
  }
  bool hit=true,up=false;
  int sml=1,big=1;
  while (hit){
    if (pls-sml>=0 && vec.at(pls-sml) == X-sml){
      sml++;
    }else{
      hit = false;
      break;
    }
    if(pls+big<N && vec.at(pls+big) == X+big){
      big++;
    }else{
      hit = false;
      up = true;
    }
  }
  
  if (up){
    cout << X+big << endl;
  }else{
    cout << X-sml << endl;
  }
}

Measured memory_bytes: 3624
import numpy as np

N=int(input())
A=np.array(list(map(int, input().split())))
L=np.zeros(10**5+1)
for i in range(N):
  L[A[i]]+=1

a_max=max(A)
ans=0

for i in range(10**5-1):
  ans=max(ans,L[i]+L[i+1]+L[i+2])
  if i==a_max:
    break
print(int(ans))
  

Measured memory_bytes: 38476
import sys
def input(): return sys.stdin.readline().rstrip()

def sum(l, r):
  return (l+r)*(r-l+1)//2

def main():
  N, K = map(int, input().split())
  MOD = 1000000007

  ans = 0
  for i in range(K,N+2):
    min_n = sum(0, i-1)
    max_n = sum(N+1-i, N)
    ans += (max_n-min_n+1)
  print(ans%MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long

int main()
{
    Hello
    int n, cntr = 0;
    string s;
    cin >> n >> s;
    vector<int> r;
    for(int i = 0; i < s.size(); i++)
        if(s[i] == 'R')
            r.push_back(i);
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'W' && r.size() && r.back() > i) {
            swap(s[i], s[r.back()]);
            r.pop_back();
            cntr++;
        }
    }
    int lst = 0;
    for (int i = s.size() - 1; i >= 0 ; i--) {
        if(s[i] == 'R'){
            lst = i;
            break;
        }
    }
    for(int i = 0; i < lst; i++)
        if(s[i] == 'W')
            cntr++;
    cout << cntr;
    return 0;
}


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

int main() {

    bool flag[10] = {false};

    rep(i, 4) {
        int a;
        cin >> a;
        flag[a] = true;
    }

    if (flag[1] && flag[9] && flag[7] && flag[4])
        cout << "YES";
    else
        cout << "NO";
    cout << endl;

    return 0;
}

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

int main(){
  ll n;  cin >> n ;
  cout << pow(n,3) << endl;
}



Measured memory_bytes: 512
#include<stdio.h>

int main(){
	double a,b;
	while(~scanf("%lf%lf",&a,&b)){
		if(a<35.50&&b<71.00)printf("AAA\n");
		else if(a<37.50&&b<77.00)printf("AA\n");
		else if(a<40.00&&b<83.00)printf("A\n");
		else if(a<43.00&&b<89.00)printf("B\n");
		else if(a<50.00&&b<105.00)printf("C\n");
		else if(a<55.00&&b<116.00)printf("D\n");
		else if(a<70.00&&b<148.00)printf("E\n");
		else printf("NA\n");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i
const int U=2e5+5;
const ll MOD=998244353;
const int INF = 1001001001;


int main(){
    int i,K; cin>>K;
    string S; cin>>S;
    string T;
    if(S.size() <= K ) AA(S);
    else{
        rep(i,K) AA(S[i]);
        AA("...");
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n; string s;
    cin >> n >> s;
    struct st{
        ll r;
        ll g;
        ll b;
    };
    vector<st> sv(n);
    sv[0].r = 0; sv[0].g = 0; sv[0].b = 0;
    for(int i = 1; i < n; i++){
        sv[i].r = sv[i-1].r; sv[i].g = sv[i-1].g; sv[i].b = sv[i-1].b;
        if(s[i] == 'R') sv[i].r++;
        if(s[i] == 'G') sv[i].g++;
        if(s[i] == 'B') sv[i].b++;
    }
    ll ans = 0;
    for(int i = 0; i < n-3; i++){
        for(int j = i+1; j < n-1; j++){
            if(s[i] == s[j]) continue;
            if(s[i] != 'R' && s[j] != 'R'){ //s[k]は'R'
                ans += sv[n-1].r - sv[j].r;
                if(j+(j-i) < n){
                    if(s[j + (j-i)] == 'R') ans--;
                }
            }
            if(s[i] != 'G' && s[j] != 'G'){
                ans += sv[n-1].g - sv[j].g;
                if(j+(j-i) < n){
                    if(s[j + (j-i)] == 'G') ans--;
                }
            }
            if(s[i] != 'B' && s[j] != 'B'){
                ans += sv[n-1].b - sv[j].b;
                if(j+(j-i) < n){
                    if(s[j + (j-i)] == 'B') ans--;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int a,b,cnt=0;
    cin>>a>>b;
    if(b==1)
    cout<<"0";
    else
    {
    b-=a;
    cnt++;
    while(1)
    {
    	if(b<=0)
    	break;
    	b-=(a-1);
    	cnt++;
	}
	cout<<cnt;
}
	return 0;
}

Measured memory_bytes: 384
n, q = map(int, input().split())

s = input()

cnt = [0]

for i in range(1,len(s)+1):
    temp = s[i-1:i+1]
    # print(temp)
    if temp == 'AC':
        cnt.append(cnt[i-1] + 1)
    else:
        cnt.append(cnt[i-1])

# print(cnt)
for i in range(q):
    l, r  = map(int, input().split())
    print(cnt[r - 1] - cnt[l - 1])

Measured memory_bytes: 6156
#include<iostream>
int main(){
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;
	if (x < 0 || y < 0){
		std::cout << "No\n";

	}
	else if(W< x + r || x - r < 0 || H < y + r || y - r < 0){

		std::cout << "No\n";
	}
	else{
		std::cout << "Yes\n";
	}
}

Measured memory_bytes: 1124
#include<cstdio>
int n,g,A,K;
int main(){
    for(scanf("%d",&n);n--;g^=A/K)for(scanf("%d%d",&A,&K);A>K&&A%K;)A-=(1+(A%K-1)/(A/K+1))*(A/K+1);
    puts(g?"Takahashi":"Aoki");
}

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

using namespace std;


int main(int argc, char *argv[])
{
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string line;
    int cnt[26] = {0};
    
    while(getline(cin, line)){
            for (int i = 0; i < line.length(); i++) {
                if (isalpha(line[i])) {
                    cnt[tolower(line[i], locale::classic())-'a']++;
                }
            }
            
    }
    
    for (int i = 0; i < 26; i++) {
        cout << (char) (i+97) << " : " << cnt[i] << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int ans = 0;
    N -= K;
    ans++;
    ans += N / (K - 1) + (N % (K - 1) ? 1 : 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
ans=""
alphabet=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
N=int(input())
s=input()
toInt={}
for i in range (len(alphabet)):
    toInt[alphabet[i]]=i
for i in range (len(s)):
    c=(toInt[s[i]]+N)%26
    ans+=(alphabet[c])
print(ans)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;

int main(){
  ll i, j;
  ll n;
  cin >> n;
  ll result = 0;
  ll dp[100][64];
  ll buf;
  for(i = 0; i < 64; i++){
    dp[2][i] = 1;
  }
  dp[2][9] = 0;
  dp[2][33] = 0;
  dp[2][6] = 0;
  for(i = 3; i < n; i++){
    for(j = 0; j < 64; j++){
      buf = j / 4;
      if(j % 16 != 9 && (j / 16 != 2 || j % 4 != 1)){
        dp[i][j] = (dp[i-1][buf] + dp[i-1][buf+16] + dp[i-1][buf+32]+dp[i-1][buf+48]) % MOD;
      }
      else      
        dp[i][j] = (dp[i-1][buf+16] + dp[i-1][buf+32]+dp[i-1][buf+48]) % MOD; 
    }
    dp[i][9] = 0;
    dp[i][33] = 0;
    dp[i][6] = 0;


  }
  for(j = 0,result=0; j < 64; j++){
    result += dp[n-1][j];
    result %= MOD;
  }
  cout << result % MOD << endl;

  return 0;
}

Measured memory_bytes: 256