akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    int a,b,n,flag=0;
    cin>>n;
    rep(i,10){
        rep(j,10){
            if(i*j==n){
                cout<<"Yes"<<'\n';
                return(0);
            }
        }
    }
    cout<<"No"<<'\n';
    return(0);
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
plus,minus,zero = 0,0,0
for i in range(n):
    if a[i] > 0:
        plus += 1
    elif a[i] < 0:
        minus += 1
    else:
        zero += 1
if n==k:
    ans=1
    for i in range(n):
        ans*=a[i]
        ans=ans%(10**9+7)
    print(ans)
else:
    if k%2==1 and minus==n:
        a.sort(reverse=True)
        ans=1
        for i in range(k):
            ans*=a[i]
            ans=ans%(10**9+7)
        print(ans)
    else:
        l=[]
        for i in range(n):
            if a[i]>=0:
                fugou=1
            else:
                fugou=-1
            l.append((abs(a[i]),fugou))
        l.sort(reverse=True)
        ans=1
        hu=1
        for i in range(k):
            ans*=l[i][0]
            ans=ans%(10**9+7)
            hu*=l[i][1]
        if hu==1:
            print(ans)
        elif ans==0:
            print(0)
        else:
            ss,sh,ts,th=-1,-1,-1,-1
            for i in range(k)[::-1]:
                if l[i][1]>0:
                    ss=l[i][0]
                    break
            for i in range(k)[::-1]:
                if l[i][1]<0:
                    sh=l[i][0]
                    break
            for i in range(k,n):
                if l[i][1]>0:
                    ts=l[i][0]
                    break
            for i in range(k,n):
                if l[i][1]<0:
                    th=l[i][0]
                    break
            if ss>0 and sh>0 and ts>0 and th>0:
                if th*sh>=ts*ss:
                    ans=(ans*pow(ss,10**9+5,10**9+7)*th)%(10**9+7)
                else:
                    ans=(ans*pow(sh,10**9+5,10**9+7)*ts)%(10**9+7)
                print(ans)
            else:
                if th>0 and ss>0:
                    ans=(ans*pow(ss,10**9+5,10**9+7)*th)%(10**9+7)
                else:
                    ans=(ans*pow(sh,10**9+5,10**9+7)*ts)%(10**9+7)
                print(ans)

Measured memory_bytes: 111928
#include <iostream>
#include <algorithm>
#include <limits>
using namespace std;

const long long INF = numeric_limits<long long>::max() / 2;
long long G[100][100];

int main() {
  int V, E; cin >> V >> E;
  for(int i = 0; i < V; i++)
    for(int j = 0; j < V; j++)
      G[i][j] = INF;
  for(int v = 0; v < V; v++)
    G[v][v] = 0;
  for(int i = 0; i < E; i++) {
    long long from, to, d;
    cin >> from >> to >> d;
    G[from][to] = min(G[from][to], d);
  }
  for(int k = 0; k < V; k++)
    for(int i = 0; i < V; i++)
      for(int j = 0; j < V; j++)
        if(G[i][k] != INF && G[k][j] != INF)
          G[i][j] = min<long long>(G[i][j], G[i][k] + G[k][j]);

  bool negative_loop = false;
  for(int v = 0; v < V; v++)
    if(G[v][v] < 0) negative_loop = true;
  if(negative_loop) {
    cout << "NEGATIVE CYCLE" << endl;
  }
  else {
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) {
        if(G[i][j] == INF) cout << "INF";
        else cout << G[i][j];

        if(j + 1 != V) cout << " ";
      }
      cout << endl;
    }
  }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;

  if(a<=5)cout<<0<<endl;
  else if (a<=12)cout<<b/2<<endl;
  else cout<<b<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char n[5] ;

int main(void){
    
    scanf ("%s",n) ;
    
    if ( n[0]==n[1] && n[1]==n[2] ){
        printf ("Yes\n") ;
    } else if ( n[1]==n[2] && n[2]==n[3] ){
        printf ("Yes\n") ;
    } else {
        printf ("No\n") ;
    }
    
    return 0 ;
    
}


Measured memory_bytes: 128
/*input
2 0
5 5

*/
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
typedef long long int lld;
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define popcount __builtin_popcountll
typedef pair<lld,lld> PA;
#define lim 1000010
#define lim2 4023
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

lld B[lim],A[lim];
// PA P[lim],Q[lim];
lld n,m,p,q;
// string S[lim],R[lim];
// vector<lld> V[lim];
// unordered_map<lld,lld> Ind;


lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}

bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}


int main(){
    lld T,i,j,h,l,r,b,k,c,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,secondMin,indicator;
    sc2(n,x);
    rep(i,1,n) sc(A[i]);
    ans=0;
    rep(i,2,n){
        t=A[i]+A[i-1];
        p=max(0LL,t-x);
        ans+=p;
        if(p<=A[i]) A[i]-=p;
        else A[i-1]-=p-A[i],A[i]=0;
    }
    prL(ans);
    return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int total=0;
    int date=0;
    while(C>total){
        date++;
        total+=A;
        if(date%7==0) total+=B;
    }
    cout << date << endl;

    return 0;
}



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

void printv(vector<int> v) {
  for (int i : v)
    cout << i << " ";
  cout << endl;
}

int main() {
  int q;
  cin >> q;
  rep(loop, q) {
    string x, y;
    cin >> x >> y;
    vector<vector<int>> L(1010, vector<int>(1010, 0));
    int lx = x.size(), ly = y.size();
    for (int i = 1; i <= lx; i++) {
      for (int j = 1; j <= ly; j++) {
        if (x[i-1] == y[j-1]) {
          L[i][j] = L[i - 1][j - 1] + 1;
        } else
          L[i][j] = max(L[i - 1][j], L[i][j - 1]);
      }
    }
    cout << L[lx][ly] << endl;
  }
}



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

#define all(cont)           begin(cont), end(cont)
using ll = long long;
using vi = vector<ll>;

ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	while (ll modval = a % b) {
		a = b;
		b = modval;
	}
	return b;
}

ll lcm(ll a, ll b)
{
	return (a * b) / gcd(a, b);
}

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

	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;

	return 0;
}


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

#define Solved int main()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define forn(i, x) for(int i = 1; i <= x; i++)
#define rep(i, x, y) for(int i = x; i <= y; i++)
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ull unsigned long long
#define ld long double
#define mii map<int, int>
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound
using namespace std;

inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

const int maxn = 1e9;
const ll inf = 1e18;
//const int mod = 998244353;
const int mod = 1e9 + 7;
const int N = 2e5 + 1;

int n, h[N], a[N];
pll dp[N][2];
ll t[4 * N];

ll getmax(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (l == tl && r == tr) return t[v];

    int tm = (tl + tr) >> 1;
    return max(getmax(v + v, tl, tm, l, min(tm, r)), getmax(v + v + 1, tm + 1, tr, max(tm + 1, l), r));
}

void update(int v, int tl, int tr, int pos, ll x) {
    if (tl == tr) t[v] = x;
    else {
        int tm = (tl + tr) >> 1;
        if (pos <= tm)
            update(v + v, tl, tm, pos, x);
        else
            update(v + v + 1, tm + 1, tr, pos, x);
        t[v] = max(t[v + v], t[v + v + 1]);
    }
}

pll maxx(pll a, pll b) {
    if (a.F > b.F) return a;
    else if (a.F == b.F && a.S < b.S) return a;
    return b;
}

void solve() {
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> h[i];

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    dp[1][1] = {a[1], h[1]};
    update(1, 1, n, h[1], a[1]);
    for (int i = 2; i <= n; i++) {
        dp[i][0] = maxx(dp[i - 1][0], dp[i - 1][1]);
        ll k = getmax(1, 1, n, 1, h[i] - 1);
        dp[i][1] = {k + a[i], h[i]};
        update(1, 1, n, h[i], dp[i][1].F);
        //cout << dp[i].F << ' ' << dp[i].S << endl;
    }
    cout << max(dp[n][1].F, dp[n][0].F);
}

Solved {
    SpeedForce;
	int tt = 1;
    //cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}

}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

#include <bits/stdc++.h>

using namespace std;


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

	int n, m;
	cin >> n >> m;
	int sum = 0;
	while (m--) {
		int a;
		cin >> a;
		sum += a;
	}
	if (n - sum < 0)
		cout << -1 << endl;
	else
		cout << (n - sum) << endl;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    cout << min(b / a, c) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int left = 1;
            int right = N;
            for (int i = 0; i < M; i++)
            {
                string[] LR = Console.ReadLine().Split(' ');
                int L = int.Parse(LR[0]);
                int R = int.Parse(LR[1]);
                left = Math.Max(left, L);
                right = Math.Min(right, R);
            }
            //答えは必ず０枚以上
            Console.WriteLine(Math.Max(right-left+1,0));
        }
    }
}


Measured memory_bytes: 17340
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    town = [-1] * N
    town[0] = 0
    next = A[0]
    roop = -1
    until_roop = -1

    for i in range(1, N+1, 1):
        if(i == K):
            print(next)
            return
        if(town[next-1] == -1):
            town[next-1] = i
            next = A[next-1]
        else:
            roop = i - town[next-1]
            until_roop = town[next-1]
            roop_start = next
            break

    mod = (K - until_roop) % roop
    index = roop_start
    while(mod>=0):
        if(mod == 0):
            print(index)
            break
        else:
            index = A[index-1]
            mod -= 1

main()

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

using namespace std;

int main() {
        int n, k, c;
        string s;
        cin >> n >> k >> c >> s;
        vector<int> l(k), r(k);
        for (int i = 0, cur = 0; i < n && cur < k; i++) {
                if (s[i] == 'x')
                        continue;
                l[cur++] = i;
                i += c;
        }
        for (int i = n - 1, cur = k - 1; i >= 0 && ~cur; i--) {
                if (s[i] == 'x')
                        continue;
                r[cur--] = i;
                i -= c;
        }
        set<int> res;
        for (int i = 0; i < k; i++) {
                if (l[i] == r[i])
                        res.insert(l[i]);
        }
        for (int u : res)
                cout << u + 1 << '\n';
        return 0;
}

Measured memory_bytes: 12676
#include <bit>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN 64

vector<int> a[MAXN];
int n, m;
ll ret;
vector<ll> v;
int cnt = 0;
map<pair<int, int>, ll> edges;

int vis[MAXN];
int pred[MAXN];

void dfs(int cur) {
	vis[cur] = 1;
	for (int i = 0; i < a[cur].size(); i++) {
		int nnext = a[cur][i];
		if (!vis[nnext]) {
			pred[nnext] = cur;
			dfs(nnext);
		}
	}
}

ll path(int s, int t) {
	memset(vis, 0, sizeof(vis));
	memset(pred, -1, sizeof(pred));
	dfs(s);
	ll ret = 0;
	while (t != s) {
		ret |= (ll)1 << edges[make_pair(t, pred[t])];
		t = pred[t];
	}
	return ret;
}

void addedge(int v1, int v2) {
	pair<int, int> p = make_pair(v1, v2);
	cnt++;
	edges[p] = cnt;
	swap(p.first, p.second);
	edges[p] = cnt;
	
	a[v1].push_back(v2);
	a[v2].push_back(v1);

}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int v1, v2;
		cin >> v1 >> v2;
		v1--;
		v2--;
		addedge(v1, v2);
	}
	ret = 1LL << (n - 1);
	cin >> m;
	for (int i = 0; i < m; i++) {
		int v1, v2;
		cin >> v1 >> v2;
		v1--;
		v2--;
		v.push_back(path(v1, v2));		
	}
	ll corr = 0;
	for (int mask = 1; mask < (1 << m); mask++) {
		ll cur = 0;
		int parity = 0;
		for (int j = 0; j < m; j++) {
			if (mask & (1 << j)) {
				cur |= v[j];
				parity = 1 - parity;
			}
		}
		ll curval = 1LL << (n - 1 - __builtin_popcountl(cur));
		if (parity) {
			corr += curval;	
		} else {
			corr -= curval;
		}
	}	
	ret -= corr;
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3160
package main

import (
	"fmt"
)

func main() {
	var S, T string
	fmt.Scan(&S, &T)

	m := make(map[string][]int)
	for i, s0 := range S {
		s := string(s0)
		m[s] = append(m[s], i)
	}

	N := len(S)
	ans := 0
	for i, t0 := range T {
		t := string(t0)
		if index, ok := m[t]; ok {
			if i == 0 {
				ans = index[0]
			} else {
				q := ans / N
				r := ans % N
				if index[len(index)-1] <= r {
					ans = (q+1)*N + index[0]
				} else {
					left := 0
					right := len(index)
					for left < right {
						middle := ((right - left) / 2) + left
						if r+1 <= index[middle] {
							right = middle
						} else {
							left = middle + 1
						}
					}
					ans = q*N + index[left]
				}
			}
		} else {
			ans = -1
			break
		}
	}
	if ans == -1 {
		fmt.Println(ans)
	} else {
		fmt.Println(ans + 1)
	}
}


Measured memory_bytes: 6528
import java.util.*;

public class Main{

  static int gcd(int a, int b) {return b>0?gcd(b,a%b):a;}


  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = 0;

    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        for(int k=1; k<=n; k++){
          sum += gcd(i,gcd(j,k));
        }
      }
    }


    System.out.println(sum);


  }
}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int n=5;
	vector<int>Time={a,b,c,d,e};
	vector<int>nextTime(n);
	int BestTime=1e9;
	rep(i,n)nextTime[i]=(Time[i]%10==0?Time[i]:Time[i]-Time[i]%10+10);
	rep(i,n){
		int SumTime=0;
		rep(j,n){
			if(i==j){
				SumTime+=Time[j];
			}else{
				SumTime+=nextTime[j];
			}
		}
		BestTime=min(BestTime,SumTime);
	}
	cout<<BestTime<<endl;
}

Measured memory_bytes: 256
from collections import deque
from sys import stdin
input = stdin.readline

while True:
    W,H = map(int, input().split())
    if W == 0 and H == 0:
        break
    
    wallcolumn = [None]*H
    wallrow = [[1]*W] + [None]*(H-1) + [[1]*W]
    for h in range(H):
        wallcolumn[h] = [1] + list(map(int, input().split())) + [1]
        if h < H-1:
            wallrow[h+1] = list(map(int, input().split()))
    
    distancemat = [[-1]*W for _ in range(H)]#-1のとき未探索
    queue = deque()
    queue.append((0,0))
    distancemat[0][0] = 1
    
    while queue:
        x,y = queue.popleft()
        distance = distancemat[y][x]
        #左方向
        if x > 0:
            if wallcolumn[y][x] == 0 and distancemat[y][x-1] == -1:
                distancemat[y][x-1] = distance + 1
                queue.append((x-1,y))
        #右方向
        if x < W-1:
            if wallcolumn[y][x+1] == 0 and distancemat[y][x+1] == -1:
                distancemat[y][x+1] = distance + 1
                queue.append((x+1,y))
        #上方向
        if y > 0:
            if wallrow[y][x] == 0 and distancemat[y-1][x] == -1:
                queue.append((x,y-1))
                distancemat[y-1][x] = distance + 1
        #下方向
        if y < H-1:
            if wallrow[y+1][x] == 0 and distancemat[y+1][x] == -1:
                queue.append((x,y+1))
                distancemat[y+1][x] = distance + 1
    
    if distancemat[H-1][W-1] == -1:
        print(0)
    else:
        print(distancemat[H-1][W-1])


Measured memory_bytes: 6052
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 500000

struct node{
  int key;
  struct node *parent;
  struct node *left, *right;
};
typedef struct node Node;
Node *root;

void insert(int);
void inorder(struct node *);
void preorder(Node *);
int find(int);

int main(){
  int n,i,j,z;
  char com[10],in[] = "insert",pr[] = "print",fi[] = "find";

  scanf("%d",&n);
  root=NULL;
  for(i = 0;i < n;i++){
    scanf("%s",com);
    if(strcmp(com,pr)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,in)==0){
      scanf("%d",&z);
      insert(z);
    }
    else{
      scanf("%d",&z);
      if(find(z) == 1) printf("yes\n");
      else printf("no\n");
    }
  }
  
  
  return 0;
}

void insert(int key){
  Node *y = NULL;
  Node *x = root;//y->xの親 x->root
  Node *z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = key;
  z->left = NULL;
  z->right = NULL;
  
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node *r){
  if(r == NULL) return;
  inorder(r->left);
  printf(" %d",r->key);
  inorder(r->right);
}

void preorder(Node *r){
  if(r == NULL) return;
  printf(" %d",r->key);
  preorder(r->left);
  preorder(r->right);
}

int find(int z){
  Node *x = root;
  while(1){
  if(z == x->key) return 1;
  else if(z > x->key) x = x->right;
  else x = x->left;
  if(x == NULL) return 0;
  }
}



Measured memory_bytes: 20608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int sum, cnt;

void dfs(int c, int s, int n)
{
    if (s == sum && n == 0)
        cnt++;
    if (c == 10 || n == 0)
        return;
    dfs(c+1, s+c, n-1);
    dfs(c+1,s,n);
}

int main(void)
{
    int n;
    while (cin >> n >> sum) {
        if (n == 0 && sum == 0) break;
        cnt = 0;
        dfs(0, 0, n);
        
        cout << cnt << endl;
    }
    

    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <tuple>
#include <vector>
#include <unordered_map>
using namespace std;

typedef long long ll;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

typedef tuple<int, int, int> medison;

int INF = 1001001;
int dp[41][401][401];

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<medison> lm;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    lm.emplace_back(a, b, c);
  }
  int ans = INF;
  for (int j = 0; j <= 400; ++j) { 
    for (int k = 0; k <= 400; ++k) { 
      dp[0][j][k] = -1;
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < n; ++i) { 
    int a, b, c;
    tie(a, b, c) = lm[i];
    for (int j = 0; j <= 400; ++j) { 
      for (int k = 0; k <= 400; ++k) { 
        dp[i+1][j][k] = dp[i][j][k];
        if (a <= j && b <= k) {
          int cc = dp[i+1][j][k];
          int bc = dp[i][j-a][k-b];
          if (bc == -1) continue;
          if (cc == -1) dp[i+1][j][k] = bc+c;
          else dp[i+1][j][k] = min(cc, bc+c);
        }
        if (j > 0) {
          if (j*mb == k*ma && dp[i+1][j][k] != -1) {
            // cout << i+1 << " " << j << " " << k << " " << dp[i+1][j][k] << endl;
            ans = min(ans, dp[i+1][j][k]);
          }
        }
      }
    }
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}



Measured memory_bytes: 26112
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
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{
	void set(double arg_left,double arg_right,double arg_top,double arg_under){
		left = arg_left;
		right = arg_right;
		top = arg_top;
		under = arg_under;
	}

	double left,right,top,under;
	int left_index,right_index,top_index,under_index;
};

int N;
int test_case = 1;

bool check[206][206];

void func(){

	Info info[N];
	double x,y,r;

	vector<double> First_X,First_Y;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf",&x,&y,&r);

		info[i].set(x-r,x+r,y+r,y-r);
		First_X.push_back(x-r);
		First_X.push_back(x+r);
		First_Y.push_back(y+r);
		First_Y.push_back(y-r);
	}

	vector<double> Second_X,Second_Y;

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

	double pre = -99999.0;

	for(int i = 0; i < First_X.size(); i++){
		if(pre != First_X[i]){
			Second_X.push_back(First_X[i]);
		}
		pre = First_X[i];
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < Second_X.size(); k++){
			if(info[i].left == Second_X[k]){
				info[i].left_index = k;
				break;
			}
		}
		for(int k = 0; k < Second_X.size(); k++){
			if(info[i].right == Second_X[k]){
				info[i].right_index = k;
				break;
			}
		}
	}

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

	pre = -999999.0;

	for(int i = 0; i < First_Y.size(); i++){
		if(pre != First_Y[i]){
			Second_Y.push_back(First_Y[i]);
		}
		pre = First_Y[i];
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < Second_Y.size(); k++){
			if(info[i].top == Second_Y[k]){
				info[i].top_index = k;
				break;
			}
		}
		for(int k = 0; k < Second_Y.size(); k++){
			if(info[i].under == Second_Y[k]){
				info[i].under_index = k;
				break;
			}
		}
	}

	for(int i = 0; i <= 205; i++){
		for(int k = 0; k <= 205; k++){
			check[i][k] = false;
		}
	}

	for(int i = 0; i < N; i++){
		for(int row = info[i].under_index; row <= info[i].top_index-1; row++){
			for(int col = info[i].left_index; col <= info[i].right_index-1;col++){
				check[row][col] = true;
			}
		}
	}

	double ans = 0.0,height,width;

	for(int row = 0; row <= 205; row++){
		height = Second_Y[row+1]-Second_Y[row];
		for(int col = 0; col <= 205; col++){
			if(check[row][col]){
				width = Second_X[col+1]-Second_X[col];
				ans += height*width;
			}
		}
	}

	printf("%d %.2lf\n",test_case,ans);

	test_case++;
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)


int main(void) {
    vector<bool> isPrime(123456*2+10,true);
    isPrime[0] = false;
    isPrime[1] = false;
    for (int i=2; i*i<=isPrime.size(); i++) {
        if (isPrime[i]) {
            for (int j=2; i*j <= isPrime.size(); j++) {
                isPrime[i*j] = false;
            }
        }
    }
    int n;
    while (cin >> n,n) {
        int ans = 0;
        for (int i=n+1; i<=2*n; i++) {
            if (isPrime[i]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
n,total = map(int,input().split())

a = b = c = -1

for i in range(0,n+1):
    x = i
    for j in range(0,n+1-x):
        
        y = j
        z = n - i - j
        if n >= x >=0 and n >= y >=0 and n >= z >=0:
            if total == 10000*int(x) + 5000*int(y) + 1000*int(z):
                a = x
                b = y
                c = z
                break
            else:
                continue
            break
print(a,b,c)            
        
            

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

class P
{
public:
  double x,y;
  P(){};P(double x,double y):x(x),y(y){};
  P operator+(const P&q){P t;t.x=x+q.x;t.y=y+q.y;return t;}
  P operator+=(const P&q){x+=q.x;y+=q.y;return *this;}
  P operator-(const P&q){P t;t.x=x-q.x;t.y=y-q.y;return t;}
  P operator-=(const P&q){x-=q.x;y-=q.y;return *this;}
  template<typename T> P operator*(T d){return P(x*d,y*d);}
  template<typename T> P operator*=(T d){x*=d;y*=d;return *this;}
  template<typename T> P operator/(T d){return P(x/d,y/d);}
  template<typename T> P operator/=(T d){x/=d;y/=d;return *this;}
  bool operator<(const P&q){return (x!=q.x)?(x<q.x):(y<q.y);}
  bool operator>(const P&q){return (x!=q.x)?(x>q.x):(y>q.y);}
  double norm(void){return sqrt(x*x+y*y);}
  double arg(void){return acos(x/this->norm())*P(1,0).sign(*this);}
  P nvec(){return P(y,-x);}
  P rotate(double t){double c=cos(t),s=sin(t);return P(c*x-s*y,s*x+c*y);}
  P reverseX(void){return P(-x,y);}
  P reverseY(void){return P(x,-y);}
  P unit(void){return (*this).norm()==0?P(0,0):(*this)/(*this).norm();}
  P floor(void){return P((int)x,(int)y);}
  double dot(const P&q){return x*q.x+y*q.y;}
  double det(const P&q){return x*q.y-y*q.x;}
  int sign(const P&q){double d = (*this).det(q); return (d>0)-(d<0);}
  static bool on_seg(P p1,P p2,P q){return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;}
  static P intersection(P p1,P p2,P q1,P q2){return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));}
};


int main()
{
  double x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
  P p1 = P(x1,y1);
  P p2 = P(x2,y2);
  P nv = (p1-p2).nvec();
  int q; cin >> q;
  REP(i,q)
  {
    double x,y; cin>>x>>y;
    P p = P(x,y);
    P ans = P::intersection(p1,p2,p,p+nv);
    printf("%.10lf %.10lf\n",ans.x,ans.y);
  }
  return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
ll n,m,q;
int dp[51][4];
ll val=0;
void rec(int i,int j,vector<int>&v)
{
	if(j>m||i>n)return ;
	if(i==n&&j<=m)
	{
		ll ans=0;
		for(int k=0;k<q;k++)
		{
			if(v[dp[k][1]-1]-v[dp[k][0]-1]==dp[k][2])
			ans+=dp[k][3];
		}
		val=max(val,ans);
		return;
	}
	for(int k=j;k<=m;k++)
	{
		v.pb(k);
		rec(i+1,k,v);
		v.pop_back();
	}
	
}
int main()
{
	IOS;
	cin>>n>>m>>q;
	rep(i,0,q)
	{
		rep(j,0,4)
		cin>>dp[i][j];
	}
	vector<int>v;
	rec(0,1,v);
	cout<<val<<endl;
}



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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n,t;
		cin >> n >> t;
		vector<int> a(n, 0), b(n, 0);
		for(int i=0; i<n; i++)cin >> a[i] >> b[i];
		vector<vector<vector<int>>> dp(2, vector<vector<int>>(n+1, vector<int>(t, 0)));
		for(int i=0; i < n; i++){
			for(int j=0; j < t; j++){
				for(int k = 0; k < 2; k++){
					//食べない
					updmax(dp[k][i+1][j], dp[k][i][j]);
					//最後に食べる
					if(k == 0)updmax(dp[1][i+1][j], dp[0][i][j] + b[i]);
					//今食べる
					if(a[i] + j < t){
						updmax(dp[k][i+1][a[i]+j], dp[k][i][j] + b[i]);
					}
				}
			}
		}
		int ans = 0;
		for(int k = 0; k < 2; k++){
			for(int i=0; i <= n; i++){
				for(int j=0; j < t; j++){
					updmax(ans, dp[k][i][j]);
				}
			}
		}
		cout << ans << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

typedef long long ll;
#define loop(x) for(int i = 0;i<(x);i++)


int main(){
   string s; cin>>s;
   string t = s;
   reverse(t.begin(),t.end());
   if(t==s && s.substr(0,(s.size()-1)/2)==s.substr((s.size()+1)/2)){
      cout<<"Yes\n";
   }else{
    cout<<"No\n";
   }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = 0;
    for(int i=1; i<=N; i++){
      int tmp = sc.nextInt();
      if(i != tmp){
        cnt++;
      }
    }
    if(cnt == 0 || cnt == 2){
      System.out.print("YES");
    }else{
      System.out.print("NO");
    }
  }
}

        


Measured memory_bytes: 22612
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


class Comb(object):

    def __init__(self, n, MOD=1e9 + 7):
        self.MOD = MOD

        self.fact = [1, 1] + [0] * n
        self.finv = [1, 1] + [0] * n
        self.inv = [0, 1] + [0] * n

        for i in range(2, n + 2):
            self.fact[i] = self.fact[i - 1] * i % self.MOD
            self.inv[i] = -self.inv[self.MOD % i] * (self.MOD // i) % self.MOD
            self.finv[i] = self.finv[i - 1] * self.inv[i] % self.MOD

    def calc_p(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        return self.fact[n] * self.finv[n - k] % self.MOD

    def calc_c(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        return self.fact[n] * (self.finv[k] * self.finv[n - k] %
                               self.MOD) % self.MOD

    def calc_h(self, n, k):
        return self.calc_c(n + k - 1, n - 1)


MOD = 998244353
N, M, K = map(int, read().split())
comb = Comb(N + K, MOD=MOD)

ans = 0
col = M

for x in range(N - 1, -1, -1):
    acc = col
    acc *= comb.calc_c(N - 1, x)
    if x <= K:
        ans += acc
        ans %= MOD
    col *= (M - 1)
    col %= MOD

print(ans)


Measured memory_bytes: 59604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int N , M ;
  int ans = 0 ;
  cin >> N >> M ;
  string S ;
  cin >> S ;
  vector<int> A(N+1) ;
  A.at(0) = 0 ;
  int count = 0 ;
  rep(i,N){
    if( i < N-1 ) if( S.at(i)== 'A' && S.at(i+1) == 'C' )count++ ;
    A.at(i+1) = count ;
  }
  //rep(i,N+1) cout << A.at(i) << ' ' ;
  cout << endl;
  rep(i,M){
    int r , l ;
    cin >> l >> r ;
    cout << A.at(r-1) - A.at(l-1) << endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int d;
	d = stoi(c);
	
	
	string ans = "No";
	
	for (int i = 1; i < 1000; i++)
	{
		if (d == (i *i))
		{
			ans = "Yes";
		}
	}

	cout << ans << endl;

}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll a,
        b, c;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    bool flag = false;
    //a
    rep(i, 0, k + 1)
    {
        rep(j, 0, k + 1)
        {
            rep(z, 0, k + 1)
            {
                ll val1 = pow(2, i), val2 = pow(2, j), val3 = pow(2, z);
                if (i + j + z <= k)
                {
                    ll A = a * val1, B = b * val2, C = c * val3;
                    if (B > A && C > B)
                    {
                        flag = true;
                    }
                }
            }
        }
    }
    if (flag)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> c(26, 0);
  rep(i, n){
    int index = s.at(i) - 'a';
    c.at(index)++;
  }
  mint ans = 1;
  rep(i, c.size()){
    ans *= c.at(i) + 1;
  }
  ans -= 1;
  cout << ans.x << endl;

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
void main()
{
  int n,i,count=0;
  char s[101];
  scanf("%d",&n);
  
    scanf("%s",s);
  
  if(n%2==0)
  {
     for(i=0;i<n/2;i++)
     {
       if(s[i]!=s[n/2+i])
         count++;
     }
    if(count>0)
      printf("No");
    else
      printf("Yes");
  }
else
  printf("No");
}



Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << ", ";
  }
  cout << "]" << endl;
}

int main()
{
  int d, l;
  cin >> d >> l;

  int l_count = d / l;
  d -= l * l_count;
  cout << l_count + d << endl;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S1,S2;
    cin >>N>>S1>>S2;
    
    vector<bool>p;
    rep(i,N){
        if(S1[i]==S2[i]){
            p.pb(1);
        }else{
            p.pb(0);
            i++;
        }
    }
    ll ans;
    ll pr;
    if(p[0]==0){
        ans=6;
        pr=0;
    }else{
        ans=3;
        pr=1;
    }
    
    rep2(i,p.size()-1){
        if(p[i]==1){
            if(pr==1){
                ans=(ans*2)%mod;
            }
        }else{
            if(pr==1){
                ans=(ans*2)%mod;
            }else{
                ans=(ans*3)%mod;
            }
        }
        pr=p[i];
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long digit(long n)
{
    int d = 0;
    while (n > 0) {
        ++d;
        n /= 10;
    }
    return d;
}

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

    int ans = digit(n);
    for (long a = sqrt(n); a >= 1; --a) {
        if (n % a == 0) {
            long c = n / a;
            int d = digit(c);
            if (d < ans) {
                ans = d;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
   divisors = []
   for i in range(1, int(n**0.5)+1):
      if n % i == 0:
         divisors.append([i, n // i])

   return divisors


n = int(input())

divisors = make_divisors(n)
print(min([sum(x)-2 for x in divisors]))


Measured memory_bytes: 3688
from itertools import combinations

N=int(input())

activity = []

for i in range(N):
    activity.append(list(map(int,input().split())))

h = [0]*3

for i in range(N):
    if i==0:
        for j in range(3):
            h[j]=activity[0][j]
    else:
        tmp=[0]*3
        for j in range(3):
            tmp[j]=activity[i][j]+max([h[k] for k in range(3) if k!=j])
        for j in range(3):
            h[j]=tmp[j]

print(max(h))


Measured memory_bytes: 62808
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF        	1000000000000000007 //1e18+7
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define ld     		long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007		//1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, mp) for(ll i = (a); i<=(mp); ++i)
#define trav(a, x) 	  for(auto &a : x)
#define re(i,n)       for(ll i = 0; i < n; ++i) 
const int N = 5e5 + 7;
const ld eps=1e-7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template <typename T> T gcd(T a,T mp){ if(a==0) return mp; return gcd(mp%a,a); }
template <typename T> T powm(T a,T mp, ll m){T cnt=1; while(mp>0){ if(mp%2==1) cnt=(cnt*a)%m; mp/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;} 
void prec(){

}
int n,m,u,v;
std::vector<int> g[N],adr[N];
int indeg[N];
vector<int> topo; //Stores lexicographically smallest toposor
vector <int> toposort() //Returns 1 if there exists a toposort, 0 if there is a cycle
{	
	priority_queue<int, vector<int>, greater<int> > pq;
	for(int i=1;i<=n;i++)
		for(auto &it:g[i])
			indeg[it]++;
		for(int i=1;i<=n;i++)
		{
			if(!indeg[i])
				pq.push(i);
		}
		while(!pq.empty())
		{
			int u=pq.top();
			pq.pop();
			topo.push_back(u);
			for(auto &v:g[u])
			{
				indeg[v]--;
				if(!indeg[v])
					pq.push(v);
			}
		}
		return topo;
	}

void run(){
	cin>>n>>m;
	rep(i,1,m){
		cin>>u>>v;
		g[u].pb(v);
		adr[v].pb(u);
	}
	vector <int> to=toposort();
	//trav(it,to) cout<<it<<' ';
	int dp[N];
	rep(i,0,N) dp[i]=1;
	int ans=1;
	trav(it,to){
		trav(j,adr[it])
			dp[it]=max(dp[it],dp[j]+1);
	}
	trav(it,to) ans=max(ans,dp[it]);
	cout<<ans-1;
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}

Measured memory_bytes: 33148
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
typedef long long ll;

int main(){
    int n;
    cin>>n;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)
        cout<<"hon";
    else if(n==0||n==1||n==6||n==8)
        cout<<"pon";
    else if(n==3)
        cout<<"bon";
}




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

using namespace std;


int main() {
	int K, S;
	int cnt=0;

	cin >> K >> S;

	for (int i=0; i <= K; i++) {
		for (int j=0; j <= K; j++) {
			if (0 <= (S-i-j) && (S-i-j) <= K) {
				cnt++;
			}
			
		}
	}
	
	cout<<cnt<<endl;
	return 0;

	
}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    string ans = "";
    string valid = "AGCT";
    for (int i = 0; i < S.size(); i++) {
        string pre = "";
        for (int j = i; j < S.size(); j++) {
            if (valid.find(S[j]) == string::npos) break;
            pre += S[j];
        }
        if (ans.size() < pre.size()) ans = pre;
    }
    cout << ans.size() << endl;
}


Measured memory_bytes: 256