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

using namespace std;

#define MAX_V 26

int res;
bool found;
vector<int> G[MAX_V];
int visited[MAX_V],num[MAX_V];

void dfs(int v,int c){
  visited[v] = 0; num[v] = c;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    int to = G[v][i];
    if(visited[to] == -1){
      dfs(to,c+1);
    }else if(visited[to] == 0){
      res = max(res,num[v]-num[to]+1);
    }
  }
  visited[v] = 1;
}

int getLargestCycle(){
  res = 0;
  memset(num,-1,sizeof(num));
  memset(visited,-1,sizeof(visited));
  for(int i = 0 ; i < 26 ; i++){
    if(visited[i] == -1){
      dfs(i,1);
    }
  }
  return res;
}

void init(){
    found = false;
    for(int i = 0 ; i < MAX_V ; i++){
        G[i].clear();
    }
}

bool valid(string &a, string &b){
    int A = a.size(),B = b.size();
    if(A <= B) return true;
    for(int i = 0 ; i < B ; i++){
        if(a[i] != b[i]) return true;
    }
    return false;
}

bool check(vector<string> &v){
    int N = v.size();
    for(int i = 0 ; i < N-1 ; i++){
        if(!valid(v[i],v[i+1])) return false;
        int a = v[i].size(),b = v[i+1].size();
        for(int j = 0 ; j < min(a,b) ; j++){
            if(v[i][j] != v[i+1][j]){
                G[v[i][j]-'a'].push_back(v[i+1][j]-'a');
                break;
            }
        }
    }
    return (getLargestCycle() == 0);
}

int main(){
    int N;
    while(cin >> N, N){
        vector<string> v(N);
        for(int i = 0 ; i < N ; i++){
            cin >> v[i];
        }
        init();
        cout << (check(v) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1288
#include<stdio.h>
 
int main(){
	int N ,K ,i , j ,tmp ,ans;
	scanf("%d %d" ,&N,&K);
	int p[N];
	for(i = 0; i < N; i++) {
		scanf("%d" ,&p[i]);
	}
	for(i = 0; i < N; i++) {
		for(j = i + 1; j < N; j++) {
			if(p[i] > p[j]) {
				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}
	ans = 0;
	for(i = 0; i < K; i++){
		ans += p[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	string s;
	cin>>s;
	int count=0;
	int m=0;
	rep(i,s.size()){

		
		
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
			count+=1;
			m = max(m,count);
		}
		else{
			count=0;
		}
		
	}
	
	cout<<m<<endl;
    return 0;
}

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

struct Node {
  Node(int lx, int ly, int rx, int ry) {
    this->lx = lx;
    this->ly = ly;
    this->rx = rx;
    this->ry = ry;
  }

  int lx;
  int ly;
  int rx;
  int ry;
};

bool shining(const Node &n, bool s[50][50][50][50], int W) {
  int lX = n.lx - 1;
  int lY = n.ly - 1;
  int rX = n.rx - W - 2;
  int rY = n.ry - 1;

  bool ret = s[lX][lY][rX][rY];
  s[lX][lY][rX][rY] = true;

  return ret;
}

int main() {
  vector<vector<char> > f(103);
  for (int i = 0; i < f.size(); i++) {
    f[i].resize(52);
  }

  while (true) {
    int W, H;
    cin >> W >> H;

    if (W == 0) {
      break;
    }

    int cw = W + 1;
    int w = W * 2 + 3;
    int h = H + 2;
    for (int i = 0; i < w; i++) {
      f[i][0] = f[i][h - 1] = '#';
    }
    for (int i = 0; i < h; i++) {
      f[0][i] = f[cw][i] = f[w - 1][i] = '#';
    }

    int lx = 0, ly = 0;
    int rx = 0, ry = 0;
    for (int i = 1; i < h - 1; i++) {
      for (int j = 1; j < cw; j++) {
	cin >> f[j][i];
	if (f[j][i] == 'L') {
	  lx = j;
	  ly = i;
	  f[j][i] = '.';
	}
      }
      for (int j = cw + 1; j < w - 1; j++) {
	cin >> f[j][i];
	if (f[j][i] == 'R') {
	  rx = j;
	  ry = i;
	  f[j][i] = '.';
	}
      }
    }

    bool s[50][50][50][50];
    for (int i = 0; i < W; i++) {
      for (int j = 0; j < H; j++) {
	for (int k = 0; k < W; k++) {
	  for (int l = 0; l < H; l++) {
	    s[i][j][k][l] = false;
	  }
	}
      }
    }

    queue<Node> q;
    q.push(Node(lx, ly, rx, ry));
    shining(q.front(), s, W);
    while (!q.empty()) {
      Node n = q.front();

      if (f[n.lx][n.ly] == '%' && f[n.rx][n.ry] == '%') {
	cout << "Yes" << endl;
	break;
      }
      q.pop();

      if (f[n.lx][n.ly] == '%' || f[n.rx][n.ry] == '%') {
	continue;
      }

      Node nn(n.lx, f[n.lx][n.ly - 1] != '#' ? n.ly - 1 : n.ly,
	      n.rx, f[n.rx][n.ry - 1] != '#' ? n.ry - 1 : n.ry);

      if (!shining(nn, s, W)) {
	q.push(nn);
      }

      Node we(f[n.lx - 1][n.ly] != '#' ? n.lx - 1 : n.lx, n.ly,
	      f[n.rx + 1][n.ry] != '#' ? n.rx + 1 : n.rx, n.ry);

      if (!shining(we, s, W)) {
	q.push(we);
      }

      Node ew(f[n.lx + 1][n.ly] != '#' ? n.lx + 1 : n.lx, n.ly,
	      f[n.rx - 1][n.ry] != '#' ? n.rx - 1 : n.rx, n.ry);

      if (!shining(ew, s, W)) {
	q.push(ew);
      }

      Node ss(n.lx, f[n.lx][n.ly + 1] != '#' ? n.ly + 1 : n.ly,
	      n.rx, f[n.rx][n.ry + 1] != '#' ? n.ry + 1 : n.ry);

      if (!shining(ss, s, W)) {
	q.push(ss);
      }
    }

    if (q.empty()) {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    cin>>n;
    map<ll,ll> m1,m2;
    rep(i,n){
        ll a;
        cin>>a;
        m1[a+i]++;
        m2[-a+i]++;
    }

    ll ans=0;
    for(auto e : m1){
        ans+=e.second*m2[e.first];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 37888
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

int n;
long long ans;
long long a[200005],sum[200005];
map<long long,int> mp;

int main(){
	scanf("%d",&n);
	mp[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
//		printf("%d ",sum[i]);
		mp[sum[i]]++;
	}
//	puts("");
	for(map<long long,int>::iterator it=mp.begin();it!=mp.end();it++){
		ans+=(long long)(it->second)*((it->second)-1)/2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using  unll = unsigned long long ;

int main() {
  int a,b;
  cin >> a >> b;
  string as,bs;
  for(int i=0;i<b;i++){
    as.push_back((char)(a+48));
  }
  for(int i=0;i<a;i++){
    bs.push_back((char)(b+48));
  }
  
  cout << min(as,bs)  << endl;
  return 0;
}

Measured memory_bytes: 256
import copy

N = int(input())
A = []
xy=[]
for i in range(N):
    A.append(int(input()))
    xy.append([])
    for j in range(A[-1]):
        xy[-1].append([int(x) for x in input().split()])

#print(xy)

tr = [[]]
for i in range(N):
    tr[0].append(-1)
#print(tr)
    
for i in range(len(xy)):
    for j in xy[i]:
        this_tr = []
        for k in tr:
            if j[1] == 1:
                if k[j[0]-1] != 0 and k[i] != 0:
                    #print("A")
                    this_k = copy.deepcopy(k)
                    this_k[j[0]-1] = 1
                    this_k[i] = 1
                    this_tr.append(this_k)
            else:
                if k[j[0]-1] != 1 and k[i] != 0:
                    #print("B")
                    this_k = copy.deepcopy(k)
                    this_k[j[0]-1] = 0
                    this_k[i] = 1
                    this_tr.append(this_k)
            if k[i] != 1:
                #print("C")
                this_k = copy.deepcopy(k)
                this_k[i] = 0
                this_tr.append(this_k)
        tr = copy.deepcopy(this_tr)
        #print(tr)
            
#print(tr)
max_c = 0
for i in tr:
    count = 0
    for j in i:
        if j == 1 or j == -1:
            count += 1
    max_c = max(max_c ,count)
print(max_c)

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int N;
	cin >> N;

	vi vec(N);
	vi a(N), b(N);
	int a_, b_;

	rep(i, N) {
		cin >> a_;
		vec[i] = i + 1;
		a[i] = a_;
	} 
	rep(i, N) {
		cin >> b_;
		b[i] = b_;
	}

	sort(vec);
	int amatch = 0, bmatch = 0;
	int p = 0;
	do {
		if (a == vec) {
			amatch = p;
		}
		if (b == vec) {
			bmatch = p;
		}
		p++;
	} while (next_permutation(all(vec)));

	cou((amatch > bmatch ? amatch - bmatch : bmatch - amatch));
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

def ng(x,y):
  return (y-x)>k

if ng(a,b) or ng(a,c) or ng(a,d) or ng(a,e) or ng(b,c) or ng(b,d) or ng(b,e) or ng(c,d)or ng(c,e) or ng(d,e):
  print(":(")
else:
  print("Yay!")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,a[1000010],b[1000010];
	cin>>n;
	for(int i=2; i<=n; i++)
	{
		cin>>a[i];
		++b[a[i]];
	}
	for(int i=1; i<=n; i++)
		cout<<b[i]<<endl;
    return 0;
}

Measured memory_bytes: 6720
import sys

def solve():
    input = sys.stdin.readline
    A, B = map(int, input().split())
    currentOpen = 1
    usedA = 0
    while currentOpen < B:
        currentOpen += A - 1
        usedA += 1
    print(usedA)
    

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
string s1,s2;

int mn(string s){
	int ans=0;
	for(int i=0;i<s.size();){
		if(s[i]-'0'<=9&&2<=s[i]-'0'){
			if(s[i+1]=='m'){
				ans+=1000*(s[i]-'0');
			}else if(s[i+1]=='c'){
				ans+=100*(s[i]-'0');
			}else if(s[i+1]=='x'){
				ans+=10*(s[i]-'0');
			}else if(s[i+1]=='i'){
				ans+=(s[i]-'0');
			}
			i+=2;
		}else{
			if(s[i]=='m'){
				ans+=1000;
			}else if(s[i]=='c'){
				ans+=100;
			}else if(s[i]=='x'){
				ans+=10;
			}else if(s[i]=='i'){
				ans+=1;
			}
			i++;
		}
	}
	return ans;
}

string nm(int a){
	string ans;
	int co=0;
	while(a>0){
		int t=a%10;
		co++;
		a/=10;
		if(t==0){
		}else if(t==1){
			if(co==1){
				ans="i"+ans;
			}else if(co==2){
				ans="x"+ans;
			}else if(co==3){
				ans="c"+ans;
			}else if(co==4){
				ans="m"+ans;
			}
		}else{
			if(co==1){
				ans=to_string(t)+"i"+ans;
			}else if(co==2){
				ans=to_string(t)+"x"+ans;
			}else if(co==3){
				ans=to_string(t)+"c"+ans;
			}else if(co==4){
				ans=to_string(t)+"m"+ans;
			}
		}
	}
	return ans;
}
	

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s1>>s2;
		cout<<nm(mn(s1)+mn(s2))<<endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
using namespace std;



int main() {
	cout << fixed << setprecision(10);
	long long int a, b, c, n, m, p[200005] = {}, sum = 0;
	double t,x;
	cin >>n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		sum += p[i];
	}
	sort(p, p + n);
	if (p[n - 1] < sum - p[n - 1]) { cout << "Yes"; }
	else {
		cout << "No";
	}
}

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

int main() {
  int a,b;
  cin >> a >>b;
  int c=-1;
  for (int i=0; i<1001; i++) {
    if (i*2/25==a && i/10==b) {
      c=i;
      break;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
n, k, s = [int(x) for x in input().split()]

if s == 10**9:
    print(*[s for _ in range(k)]+[1 for _ in range(n-k)], sep=" ")
else:
    print(*[s for _ in range(k)]+[s+1 for _ in range(n-k)], sep=" ")

Measured memory_bytes: 8720
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=21;
char s[1<<N];
int n,m,U,Num,Ans,p[1<<N],tr[1<<N][2],f[N][1<<N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),U=(1<<n+1)-1;
	for(int i=0;i<=n;i++){
		scanf("%s",s);
		for(int x=0;x<1<<i;x++)f[i][1<<i^x]=s[x]-'0';
	}
	for(int S=2;S<=U;S++)p[S]=p[S>>1]+1;
	for(int S=2;S<=U;S++){
		if(S>>(p[S]-1)&1){
			tr[S][1]=S^(1<<p[S]);
			tr[S][0]=tr[tr[S][1]][0];
		}
		else{
			tr[S][0]=S^(3<<p[S]-1);
			tr[S][1]=tr[tr[S][0]][1];
		}
	}// A|B
	for(int i=n;i>=1;i--){
		for(int S=1<<i;S<=U;S++){
			if(f[i][S]==0)continue;
			int A=S>>i,B=(S&((1<<i)-1))^(1<<i);
			for(int t=0;t<2;t++)if(tr[B][t]){
				int k=p[tr[B][t]];
				f[k][(A<<1^t^1)<<k^tr[B][t]]+=f[i][S];
			}f[0][A]+=f[i][S];
		}
	}Ans=1,Num=n;
	for(int S=2;S<=U;S++)if(f[0][S]>=m&&p[S]>p[Ans])Ans=S;
	while(!(Ans>>Num&1))Num--;
	while(Num--)printf("%d",Ans>>Num&1);
	return 0;
}

Measured memory_bytes: 193312
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

#define MAXN 10000009
ll sievesize, numDiffPF[MAXN];
bitset<MAXN> bs;
vector<ll> primes;

void sieve(ll n) {
	sievesize = n + 1;
	bs.set();
	bs[0] = bs[1] = 0;
	for (ll i = 2; i <= sievesize; i++) {
		if (bs[i]) {
			for (ll j = i * i; j <= (ll)sievesize; j += i) bs[j] = 0;
			primes.push_back(i);
		}
	}
}
bool isPrimeSieve(ll N) {
	if (N <= (ll)sievesize) return bs[N];
	for (int i = 0; i < (int)primes.size() && primes[i]*primes[i] <= N; i++)
		if (N % primes[i] == 0) return false;
	return true;
}
bool isPrime(ll N) {
	if (N < 0) return isPrime(-N);
	for(ll i=2; i*i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
bool isPrimeFast(ll n) {
    if (n < 0) n = -n;
    if (n < 5 || n % 2 == 0 || n % 3 == 0)
        return (n == 2 || n == 3);
    ll maxP = sqrt(n) + 2;
    for (ll p = 5; p < maxP; p += 6) {
        if (p < n && n % p == 0) return false;
        if (p+2 < n && n % (p+2) == 0) return false;
	}
    return true;
}
vector<ll> primeFactors(ll N) {
	vector<ll> factors;
	ll PF_idx = 0, PF = primes[PF_idx];
	while (PF * PF <= N) { 
		while (N % PF == 0) {
			N /= PF;
			factors.push_back(PF);
		}
		PF = primes[++PF_idx];
	}
	if (N != 1) factors.push_back(N);
	return factors;
}
ll numDiv(ll N) {
	ll i = 0, p = primes[i], ans = 1;
	while (p * p <= N) {
		ll power = 0;
		while (N % p == 0) { N /= p; power++; }
		ans *= (power + 1);
		p = primes[++i];
	}
	if (N != 1) ans *= 2;
	return ans;
}

void solve(){
	sieve(1e6+9);
	int n;
	cin >> n;
	ll ans = 0;
	for (int c = 1; c < n; ++c){
		ans += numDiv(n-c);
	}
	cout << ans << '\n';
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 5496
#include <stdio.h>

int main(void) {
	int i, j, n, taro_p = 0, hana_p = 0;
	char taro[101], hana[101];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s %s", taro, hana);

		for (j = 0;; j++) {
			if (taro[j] > hana[j]) {
				taro_p += 3;
				break;
			}
			else if (taro[j] < hana[j]) {
				hana_p += 3;
				break;
			}
			else if (taro[j] + hana[j] == 0) {
				hana_p++;
				taro_p++;
				break;
			}
		}
	}

	printf("%d %d\n", taro_p, hana_p);
	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int H,W,count;
		
		
		
		while(true){
			H = as.nextInt();
			W = as.nextInt();
			
			if(H==0 && W==0){
				
				break;
				
			}
			
			for(int i=0;i<H;i++){
				
				if(i==0 || i==H-1){
					
					for(int j=0;j<W;j++){
						
						System.out.print("#");
						
					}
					
				}
				
				else{
					
					for(int j=0;j<W;j++){
					
						if(j==0 || j==W-1){
							
							System.out.print("#");
							
						}
						
						else{
							
							System.out.print(".");
							
						}
						
					}
					
				}
				
				System.out.println();
				
			}
			
			System.out.println();
		}
		
		

	}

}

Measured memory_bytes: 36076
lines = input()
stack_1 = []
stack_2 = []

area = 0
for i, line in enumerate(lines):
    if line == '\\':
        stack_1.append(i)
    elif line == '_':
        pass
    elif line == '/':
        if stack_1 == []:
            continue
        last_index = stack_1.pop()
        this_area = i - last_index
        area += this_area

        if stack_2 == []:
            stack_2.append((last_index, this_area))
            continue

        block_area = this_area
        while True:
            if stack_2 == []:
                break
            stack_2_index, stack_2_area = stack_2.pop()
            if stack_2_index < last_index:
                stack_2.append((stack_2_index, stack_2_area))
                break
            else:
                block_area += stack_2_area
        stack_2.append((last_index, block_area))

print(area)
kazu = len(stack_2)
kaku_menseki = [stack_2[i][1] for i in range(len(stack_2))]
kaku_menseki_out = ' '.join(map(str, kaku_menseki))
if kazu > 0:
    print(f'{kazu} {kaku_menseki_out}')
else:
    print(f'{kazu}')



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl dup(n);
	FOR(i,0,n) {
		ll a, b;
		cin >> a >> b;
		dup[i] = a == b;
	}

	bool res = false;
	FOR(i,0,n-2) if (dup[i] && dup[i+1] && dup[i+2]) res = true;
	cout << (res ? "Yes" : "No") << endl;

}



Measured memory_bytes: 3644
x = int(input())
ans = x
while True:
  jud = 0
  if(ans <= 2):
    print(2)
    break
  if(ans%2==0):
    jud += 1
  i = 3
  while i < ans**(1/2):
    if(jud>0):
      break
    if(ans%i == 0):
      jud += 1
    i += 2
  if(jud==0):
    print(ans)
    break
  ans += 1
 

Measured memory_bytes: 9436
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;

int dp[110000] ;

int main() {

    int n,k ;
    cin >> n >> k ;
    int h[n];
    rep(i,n) cin >> h[i] ;
    dp[0] = 0 ;

    for(int i=1;i<n;i++){
        dp[i] = INF ;
        for(int j=1;j<=k;j++){
            if(i-j>=0){
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j])) ;
            }
        }
    }
    cout << dp[n-1] << endl ;
    return 0 ;
}

Measured memory_bytes: 4376
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}
ll gcd(ll a,ll b){
   if (a%b == 0){
        return(b);
    }
    
   else{
       return(gcd(b, a%b));
    }
}
int main(){
  ll n;cin>>n;
  vll s(n);
  rep(i,0,n){
    cin>>s[i];
  }
  ll ans=0;
  vll l(n),r(n);
  l[0]=s[0];r[n-1]=s[n-1];
  rep(i,0,n-1){
    l[i+1]=gcd(l[i],s[i+1]);
    
  }
  drep(i,n-2,0){
    r[i]=gcd(r[i+1],s[i]);
  }
  ans=max(r[1],l[n-2]);
  rep(i,1,n-1){
    ans=max(ans,gcd(l[i-1],r[i+1]));
  }

  cout<<ans<<endl;
  
}



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int r,g,b,n;cin >> r >> g >> b >> n;
    LL ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if(0<=n-i*r-j*g&&(n-i*r-j*g)%b==0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a+b == c || a+c == b || b+c == a){
  	cout << "Yes" << endl;
  }else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll    long long
#define F     first
#define S     second
#define pb    push_back
#define mp    make_pair
#define mod   1000000007
#define vlli  vector<ll>
#define vi    vector<int>
#define vs    vector<string>
#define vplli vector< pair< ll, ll> >
#define plli  pair< ll, ll >
#define vps   vector< pair< string, string> >
#define vpi   vector< pair< int, int> >
#define all(x)           x.begin(), x.end()
#define fast  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define forn(i, n)       for (ll i = 0; i < n; i++)
#define print(arr, a, n) for (ll i = (a); i < (n); i++) cout << (arr)[i] << " ";

const ll INF = (ll)2e18 + 77;
const int N = (int)1e6 + 1;
ll fact[N], invfact[N];
ll modpo(ll x, ll n){
    ll ans = 1;

    while (n > 0) {
        if (n & 1)
            ans = (ans * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ans;
}
void modin(){
    ll i;

    fact[0] = invfact[0] = 1;

    for (ll i = 1; i < N; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
        invfact[i] = modpo(fact[i], mod - 2);
    }
}
ll nCr(ll n, ll r){
    if (r > n) return 0;
    ll ans = fact[n];

    ans = (ans * invfact[r]) % mod;
    ans = (ans * invfact[n - r]) % mod;
    return ans;
}
void solve(){
    ll N, M, i, ans = 0, sign = 1, temp; cin >> N >> M;

    modin();
    forn(i, N + 1){
        temp = sign; if (temp < 0) temp += mod;
        temp = (temp * nCr(N, i)) % mod;
        temp = (temp * nCr(M - i, N - i)) % mod;
        temp = (temp * fact[N - i]) % mod;
        ans = (ans + temp) % mod;
        sign = -sign;
    }
    ans = (ans * nCr(M, N)) % mod;
    ans = (ans * fact[N]) % mod;
    cout << ans % mod << "\n";
}
int main(){
    
    fast;
    solve();

    return 0;
}

Measured memory_bytes: 19280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (3e3) + 3;
int memo[N][N];
string s1, s2;
int n, m;

void lcs(int n, int m) {
	for (int i = 0; i <= n; ++i) {
		memo[i][0] = 0;
	}
	for (int i = 0; i <= m; ++i) {
		memo[0][i] = 0;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s1[i-1] == s2[j-1]) {
				memo[i][j] = 1 + memo[i-1][j-1];
			} else {
				memo[i][j] = max(memo[i-1][j], memo[i][j-1]);
			}
		}
	}
}

void printLcs(int n, int m) {
	if (n == 0 or m == 0) return;
	if (s1[n-1] == s2[m-1]) {
		printLcs(n-1, m-1);
		printf("%c", s1[n-1]);
	} else {
		if (memo[n][m-1] > memo[n-1][m]) printLcs(n, m-1);
		else printLcs(n-1, m);
	}
}

int main() {
	getline(cin, s1);
	getline(cin, s2);
	int n = s1.size();
	int m = s2.size();
	lcs(n, m);
	printLcs(n, m);
	return 0;
}

Measured memory_bytes: 35712
tensu1=[]
tensu2=[]
i=0
while i<4:
    s=int(input())
    tensu1.append(s)
    i+=1
tensu1.sort()
while 4<=i and i<6:
    s=int(input())
    tensu2.append(s)
    i+=1
tensu2.sort()
sum1=0
for i in range(1,4):
    sum1+=tensu1[i]
sum2=tensu2[1]
print(sum1+sum2)


Measured memory_bytes: 5600
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let mut ls = read_vec::<u32>();
    ls.sort();

    //println!("sorted {:?}", ls);
    let mut count = 0;

    let lsmax = ls[n-1];

    /*
    let mut subcount = 0;
    for a in 0..n-2 {
        for b in a+1..n-1 {
            for c in b+1..n {
                if ls[a] < ls[b] + ls[c]
                    && ls[b] < ls[c] + ls[a]
                    && ls[c] < ls[a] + ls[b] {
                    //println!("a, b, c = ({}, {}, {})", a, b, c);
                    subcount += 1;
                }
            }
        }
    }
    */
    //println!("subcount: {}", subcount);

    for a in 0..n-2 {
        if ls[a] > lsmax / 2 + 1{
            let x = (n - a - 1) * (n - a - 2) / 2;
            count += x;
            //println!("a={}, x={}", a, x);
            continue;
        }
        for b in a+1..n-1 {
            let ab = ls[a] + ls[b];
            if ab > lsmax {
                let y = (n - b - 1) * (n - b) / 2;
                count += y;
                //println!("a={}, b={}, y={}", a, b, y);
                break;
            }

            for c in b+1..n {
                if ls[c] < ab {
                    count += 1;
                    //println!("a={}, b={}, c={}, +1", a, b, c);
                } else {
                    //println!("a={}, b={}, c={}, skip-c", a, b, c);
                    break;
                }
            }
        }
    }
    println!("{}", count);
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> H(n+1);
    rp(i, 0, n) scanf("%d", &H.at(i+1));
    vector<int> dp(n + 1);
    rp(i, 2, n+1) {
        int now = 1e9;
        for(int j = 1; j <= k and i - j > 0; j++) {
            now = min(now, dp.at(i-j) + abs(H.at(i) - H.at(i-j)));
        }
        dp.at(i) = now;
    }

    printf("%d\n", dp.at(n));
    return 0;
} 

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,w;
  while(cin >> n >> w && n) {
    int m=100/w+1;
    int a[m];
    memset(a,0,sizeof(a));
    int ma=0;
    for(int i=0; i<n; i++) {
      int x;
      cin >> x;
      a[x/w]++;
      ma=max(ma,a[x/w]);
    }
 
    int k;
    for(k=m-1; k>=0; k--) {
      if(a[k]) break;
    }
    k++;
 
    double ans=0;
    for(int i=0; i<k; i++) {
      ans+=((double)a[i]/ma)*((double)(k-1-i)/(double)(k-1));
    }
    printf("%.10f\n",ans+0.01);
  }
  return 0;
}


Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<P> jewels;
vector<Int> jewel[216000];

Int val2(Int a){
  return jewel[a][0] + jewel[a][1];
}

Int val3(Int a){
  return jewel[a][0] + jewel[a][1] + jewel[a][2];
}

Int minval(multiset<Int> &S){
  return *S.begin();
}


Int maxval(multiset<Int> &S){
  auto it = S.end();it--;
  return *it;
}
Int minval2(multiset<P> &S){
  return val2(S.begin()->second);
}

Int maxval2(multiset<P> &S){
  auto it = S.end();it--;
  return val2(it->second);
}

Int maxval3(multiset<P> &S){
  auto it = S.end();it--;
  return val3(it->second);
}


Int cnt[216000];
multiset<Int> PP, Q;
multiset<P> R, S, T;
Int ans[216000];

Int n, k, c, v;

int main(){
  fill(ans, ans + 216000, -2);
  cin >> n >> k;
  for(Int i = 0;i < n;i++){
    cin >> c >> v;
    jewel[c].push_back(v*2);
  }
  for(Int i = 0;i < n;i++){
    if(jewel[i].empty())continue;
    sort(jewel[i].rbegin(), jewel[i].rend());
    Int sum = jewel[i][0] + jewel[i][1];
    jewel[i][0] = jewel[i][1] = sum / 2;
    for(Int j = 0;j < jewel[i].size();j++){
      v = jewel[i][j];
      jewels.push_back(P(v, i));
    }
    S.insert(P(val2(i), i));
    if(jewel[i].size() >= 3){
      T.insert(P(val3(i), i));
    }
  }
  sort(jewels.rbegin(), jewels.rend());
  Int sum = 0;
  for(Int i = 0;i < n;i++){
    v = jewels[i].first;
    c = jewels[i].second;
    cnt[c]++;
    if(cnt[c] >= 2){
      sum += v;
      ans[i+1] = sum;
      if(cnt[c] == 2){
	R.insert(P(val2(c),c));
	S.erase(P(val2(c),c));
	if(jewel[c].size() >= 3)
	  T.erase(P(val3(c), c));
	for(Int j = 2;j < jewel[c].size();j++){
	  Q.insert(jewel[c][j]);
	}
      }
      else{
	R.erase(P(val2(c),c));
	Q.erase(v);
	PP.insert(v);
      }
      continue;
    }
    if(!Q.empty())ans[i+1] = max(ans[i+1], sum + maxval(Q));
    if(!PP.empty() && !S.empty())
      ans[i+1]  = max(ans[i+1], sum - minval(PP) + maxval2(S));
    if(!R.empty() && !T.empty())
      ans[i+1]  = max(ans[i+1], sum - minval2(R) + maxval3(T));
    sum += v;    
  }

    

  for(Int i = 0;i < n;i++)cout << ans[i+1] / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 27252
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        Console.WriteLine(Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x.First()).Last().Sum());
    }
}

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

int main(){
  int N,i,count;
  cin >> N;
  set <string> s;
  string str;
  for(i=0;i<N;i++){
    cin >> str;
    s.insert(str);
  }
  
  count=s.size();
  
  cout << count << endl;
}

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

int main (){
  int N,i;
  cin >> N;
  int v[N];
  int c[N];
  int count = 0;

  for (i=0;i<N;i++)
    cin >> v[i];
  
  for (i=0;i<N;i++)
    cin >> c[i];

  for (i=0;i<N;i++){
    if (v[i] > c[i])
      count += v[i] -c[i];
  }

  cout << count << endl;
  
}


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


int main() 
{
    int N;
    string S;
    cin >> N >> S;
    
    vector<int> lW(N), rE(N);
    for (int i = 1; i < N; i++) {
        lW[i] = lW[i-1];
        if(S[i-1] == 'W'){
            lW[i]++;
        }
    }
    for (int i=N-2; i>=0; i--) {
        rE[i] = rE[i+1];
        if (S[i+1] == 'E') {
            rE[i]++;
        }
    }
    int ans = N;
    for (int i=0; i < N; i++) {
        ans = min(ans, lW[i] + rE[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main(){
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int cut=1000000;
    for(int i=0;i<n;i++){
        cut=min(cut,abs(sum-a[i]*n));
    }
    int ans;
    for(int i=0;i<n;i++){
        if(abs(sum-a[i]*n)==cut){
            ans=i;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.collections.ArrayList

fun main(){
    val n = rInt()
    val a = readLine()!!.split(' ').map { it.toLong() } as ArrayList<Long>
//    val a = arrayListOf<Long>()
//    for (i in 1..n) a.add(rLong())

    a.sortDescending()

    var ans = a[0]

    for (i in 2 until n){
        ans += a[i/2]
    }

    println(ans)


}



// input
private val inputQue = ArrayList<String>()
private fun myReadLine(){
    inputQue.addAll(readLine()!!.split(' '))
}
private fun read() : String {
    if(inputQue.isEmpty()) myReadLine()
    return inputQue.removeAt(0)
}
private fun rInt() = read().toInt()
private fun rLong() = read().toLong()
private fun rDouble() = read().toDouble()


Measured memory_bytes: 65160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main()
{
	int t;
	t=1;
	while(t--)
	{
     int n;
     cin>>n;
     if(n>=400&&n<600)
     {
     	cout<<8;
     }
      if(n>=600&&n<800)
     {
     	cout<<7;
     }
      if(n>=800&&n<1000)
     {
     	cout<<6;
     }
      if(n>=1000&&n<1200)
     {
     	cout<<5;
     }
      if(n>=1200&&n<1400)
     {
     	cout<<4;
     }
      if(n>=1400&&n<1600)
     {
     	cout<<3;
     }
      if(n>=1600&&n<1800)
     {
     	cout<<2;
     }
      if(n>=1800&&n<2000)
     {
     	cout<<1;
     }
      
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */


int main(void){ 
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3) cout << "YES";
    else cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,m;
	cin>>n>>m;
	int ans = 0;
	ans += m*(m-1)/2;
	ans += n*(n-1)/2;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long Q = lread();
    DList!char ans;
    foreach (c; S)
        ans.insertBack(c);
    bool reverse;
    foreach (i; 0 .. Q)
    {
        auto input = readln().split();
        if (input[0] == "1")
        {
            reverse = (reverse == false);
            continue;
        }
        if (input[0] == "2")
        {
            bool front = (input[1] == "1" && !reverse) || (input[1] == "2" && reverse);
            if (front)
            {
                ans.insertFront(input[2][0]);
            }
            else
            {
                ans.insertBack(input[2][0]);
            }
        }
    }
    if (!reverse)
    {
        foreach (c; ans)
            write(c);
    }
    else
    {
        foreach_reverse (c; ans)
            write(c);
    }
    writeln();
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int enum_divisors(int N)
{
    vector<int> res;
    for (int i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    return res.size();
}

int main(){
    int n,m;
    cin >> n;
    map<string,int> s;
    rep(i,n){
        string x;   cin >> x;
        s[x]++;
    }    
    cin >> m;
    map<string,int> t;
    rep(i,m){
        string x;   cin >> x;
        t[x]++;
    }

    int ans(0);
    for(auto a : s){
        if(t.count(a.first)==1){
            ans = max(ans,a.second-t[a.first]);
        }else{
            ans = max(a.second,ans);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_T_SIZE 1000003
#define BUF_P_SIZE 10003
#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
  FILE *fp = stdin;
  char str_t[BUF_T_SIZE];
  char str_p[BUF_P_SIZE];

  if(!fgets(str_t, BUF_T_SIZE, fp)) return 0;
  int len_t = strlen(str_t);
  if(!fgets(str_p, BUF_P_SIZE, fp)) return 0;
  int len_p = strlen(str_p) - 1;
  int i;
  int posmap[0xff];
  for(i = 0; i < 0xff; i++) {
    posmap[0] = -1;
  }
  for(i = 0; i < len_p; i++) {
    posmap[(unsigned char)str_p[i]] = i;
  }

  int idx_t, idx_p;
  idx_t = idx_p = len_p-1;
  while(idx_t < len_t) {
    int cur = idx_t; // for using forwarding step
    // printf("%d %d\n", idx_t, idx_p);
    // search
    while(idx_p>=0 && str_t[idx_t] == str_p[idx_p]) {
      idx_t--; idx_p--;
    }
    if(idx_p < 0) {
      printf("%d\n", idx_t+1);
      idx_t++;
    }

    // forward
    unsigned char ch = str_t[idx_t];
    if(posmap[ch] == -1) {
      cur += len_p;
    } else {
      cur += max(idx_p - posmap[ch], 1);
    }
    idx_t = cur;
    idx_p = len_p-1;
  }


  return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> v(n+1,0);
    for(int i=2;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        v[x]++;
    }
    for(int i=1;i<=n;i++) printf("%d\n",v[i]);
    return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N,K;
  cin >> N >> K;
  vector<bool> D(10, 1);
  rep(i,K){
    int x;
    cin >> x;
    D[x] = 0;
  }

  bool h = 1;
  while(h){
    int X = N;
    while(1){
      if(D[X%10] == 1){
        if(X/10 == 0){
          h=0;
          break;
        }
        else{
          X = X/10;
        }
      }
      else break;
    }
    N++;
  }

  cout << N-1 <<endl;
}


Measured memory_bytes: 3540
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[x];
        long[] b = new long[y];
        long[] c = new long[z];
        for (int i = 0; i < x; i++) a[i] = sc.nextLong();
        for (int i = 0; i < y; i++) b[i] = sc.nextLong();
        for (int i = 0; i < z; i++) c[i] = sc.nextLong();
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        long[] sumAB = new long[x*y];
        int cntAB = 0;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                sumAB[cntAB++] = a[i] + b[j];
            }
        }
        Arrays.sort(sumAB);
        int abIdx = Math.min(k, x*y);
        long[] sum = new long[z*abIdx];
        int cnt = 0;
        for (int i = 0; i < z; i++) {
            for (int j = 0; j < abIdx; j++) {
                sum[cnt++] = c[i] + sumAB[x*y-1-j];
            }
        }
        Arrays.sort(sum);
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < k; i++) ans.append(sum[z*abIdx-1-i] + "\n");
        System.out.println(ans.toString());
        sc.close();
    }

}


Measured memory_bytes: 62072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int i = Integer.parseInt(sc.next(), 16);
		int j = Integer.parseInt(sc.next(), 16);
		
		if(i < j) {
			out.println("<");
		}else if(i > j){
			out.println(">");
		}else{
			out.println("=");
		}
	}
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22484
n,m = map(int,input().split())
s = [0]*(n)
for i in range(m):
    a,b = map(int,input().split())
    s[a-1] += 1
    s[b-1] += 1
for i in s:
    if i%2 != 0:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    string s;
    cin>>s;
    Sort(s);
    Yn(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAXN = (1ll << 60);
int getAns(int l, int r, int plc = 60, int s = 0, int e = MAXN) {
	if (plc < 0)
		return 0;
	if (r <= s || e <= l)
		return 0;
	if (l <= s && e <= r)
		return e - s;
	int mid = (s + e) / 2, fr = getAns(l, r, plc - 1, s, mid), sd = getAns(l, r, plc - 1, mid, e);
	if (sd == 0)
		return fr;
	else 
		return (fr + min(fr + sd, e - mid));
}
int32_t main() {
	int a, b;
	cin >> a >> b;
	cout << getAns(a, b + 1);
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for(int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		int count = 1;
		int index = 1;
		while(count <= n) {
			index = a[index];
			if(index==2) {
				System.out.println(count);
				return;
			}
			count++;
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 59640
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const n = parseInt(input[0], 10);
    const a = input[1].split(' ').map(function(value) { return parseInt(value, 10); });
    let l = Array(n + 1);
    let r = Array(n + 1);
    let ans = 0;

    l[0] = 0;
    for (let i = 1; i < n; i++) {
        l[i] = gcd(l[i - 1], a[i - 1]);
    }

    r[n - 1] = 0;
    for (let i = n - 2; i >= 0; i--) {
        r[i] = gcd(r[i + 1], a[i + 1]);
    }

    for (let i = 0; i < n; i++) {
        ans = Math.max(ans, gcd(l[i], r[i]));
    }

    console.log(ans);

    return 0;
}

function gcd(a, b) {

    if (b === 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 30656