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

long inf = 1000000007;


int main() {
	int n; cin >> n;
	vector<int> a(n);
	int amax = 0, amin = inf;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		amax = max(a[i], amax);
		amin = min(a[i], amin);
	}

	
	 int totalmin = inf;

	 for (int i = amin; i <= amax; i++) {
		 int  total = 0;
		 for (int j = 0; j < n; j++) {
			 total += (i - a[j]) * (i - a[j]);
		 }
		 totalmin = min(totalmin, total);
	 }
	 
	

	cout << totalmin << endl;
}

	


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, w;
  cin >> n >> w;
  ll X = -1, Y = -1, Z = -1;
  ll x = n, y = 0, z = 0;
  rep(i,n+1){
    y = i;
    z = 0;
    rep(j,i+1){
      if(x*10000 + y*5000 + z*1000 == w){
        X = x; Y = y; Z = z;
      }
      y--; z++;
    }
    x--;
  }
  cout << X << ' ' << Y << ' ' << Z;
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int x,y,n,ans;

int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> x;
        if(y <= x)
        {
            y = x;
            ans++;
        }
    }
    cout << ans;
}

#endif // 1++

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        n=sc.nextInt();
        char[] a=sc.next().toCharArray();
        for(int i=0;i<a.length;i++)
        System.out.print((i+1==n)?(char)((int)a[i]+32):a[i]);
        System.out.println();
    }
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
      public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		
    		int x = sc.nextInt();
        
    		int a = sc.nextInt(); 
        
    		int b = sc.nextInt();

       		int c = (x-a)/b;
       		
        	int ans = (x-a)-(c*b); 
    		
    
    		System.out.println(ans);
    	}

}

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

int main(){
    ll h,w;cin>>h>>w;
    ll ans = 1e11;

    for(ll i=1;i<h;i++){
        ll a = i * w;
        ll b = (h-i) * (w/2);
        ll c = (h-i) * ((w+1)/2);
        
        ll tmp = max({a,b,c}) - min({a,b,c});
        ans = min(ans,tmp);

        b = ((h-i+1)/2) * w;
        c = ((h-i)/2) * w;
        tmp = max({a,b,c}) - min({a,b,c});
        ans = min(ans,tmp);
    }

    for(ll i=1;i<w;i++){
        ll a = i * h;
        ll b = (w-i) * (h/2);
        ll c = (w-i) * ((h+1)/2);
        
        ll tmp = max({a,b,c}) - min({a,b,c});
        ans = min(ans,tmp);

        b = ((w-i)/2) * h;
        c = ((w-i+1)/2) * h;
        tmp = max({a,b,c}) - min({a,b,c});
        ans = min(ans,tmp);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define ull unsigned long long 
    #define ld long double
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    ll mod=1e9+7;
 
     ll a[200005];
       ll b[200005];
 
     ll idx[100005][2];
    // ll cnt[200005];
     ll pre[200005];
    // ll end[200005];
     map<ll,ll> m;
 
    bool comp(const pair<ll,ll>& a, const pair<ll,ll>& b){
      return (a.fi-a.se)>(b.fi-b.se);
    }
 
    bool revcomp(const pair<ll,ll>& a, const pair<ll,ll>& b){
      return (a.fi)>(b.fi);
    }
 
 
    ll ceil11(ll a, ll b){
      if(a%b!=0)return a/b+1;
      else return a/b;
    }
    ll power(ll a,ll b,ll n){ll ans=1;while(b>0){if(b%2==1)ans=(ans*a)%n;a=(a*a)%n;b/=2;}return ans;}
 
    ll count1=0;
 
 
    ll gcd(ll a, ll b){
      //if(a<b)swap(a,b);
      if(b==0)return a;
      return gcd(b,a%b);
    }
 
  ll primepos(ll fact, ll p) 
  { 
      ll res = 0; 
      while (fact > 0) {         
          res += fact / p; 
          fact /= p;  
      } 
    
      return res; 
  } 
 
  // void dfs(ll n, ll p){
  //   if(vis[n]!=0){
  //     return;
  //   }
  //   else{
  //     vis[n]=1;
  //     b[n]=p;
  //     for(int i=0;i<v[n].size();i++){
  //       dfs(v[n][i],p);
  //     }
  //   }
  ll ceil1(ll a,ll b){
    return a/b;
  }

   
   int main(){

      ios::sync_with_stdio(0);
      ll n;
      cin>>n;
      for (int i=0;i<n;i++)
    cin>>a[i];
  long long int dp[n][n], temp;
  for (int i=0;i<n-1;i++){
    dp[i][i+1] = a[i] + a[i+1];
    dp[i][i] = 0;
  }
  dp[n-1][n-1] = 0;
  long long int sm[n][n];
  for (int i=0;i<n;i++){
    sm[i][i] = a[i];
    for (int j=i+1;j<n;j++){
      sm[i][j] = sm[i][j-1] + a[j];
    }
  }
  for (int i=2;i<n;i++){
    for (int j=0;j+i<n;j++){
      temp = LONG_MAX;
      for (int k=0;k<i;k++){
        temp = min(temp, dp[j][j+k] + dp[j+k+1][j+i]);
      }
      dp[j][j+i] = temp + sm[j][j+i];
    }
  }
  cout<<dp[0][n-1];



      return 0;
} 

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

int main() {
	// your code goes here
	int n,k,x;
	cin>>n>>k;
	int totalDist = 0;
	for(int i=0;i<n;i++){
		cin>>x; totalDist+=min(x,abs(k-x));
	}
	printf("%d\n",totalDist*2);
	return 0;
}

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

int make(int a,int l){
	int x[10];
	int y=0,z=0,s=1;
	lp(i,l-1) s*=10;
	lp(i,l){
		if(a==0) x[i]=0;
		else x[i]=a/s;
		a%=s;
		s/=10;
	}
	s=1;
	sort(x,x+l);
	lp(i,l){
		y+=x[i]*s;
		s*=10;
	}
	s=1;
	reverse(x,x+l);
	lp(i,l){
		z+=x[i]*s;
		s*=10;
	}
	return y-z;
}
int che[1000000];
int main(){
	while(1){
		int a,l;
		cin>>a>>l;
		if(a==0&&l==0) break;
		set<int> list;
		list.clear();
		decltype(list)::iterator it;
		list.insert(a);
		che[a]=0;
		int count=1;
		while(1){
			int x = make(a,l);
			it = list.find(x);
			if(it != list.end()){
				int ans=*it;
				cout<<che[x]<<" "<<ans<<" "<<count-che[x]<<endl;
				break;
			}
			list.insert(x);
			a=x;
			che[a]=count;
			count++;
		}
	}
	
	return 0;
}


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

int ans[10];
int n,m;
int main(){
	cin>>n>>m;	
	for(int i=1;i<=m;i++){
		int s,c;
		cin>>s>>c;
		if(s==1&&c==0&&n>1){ cout<<-1;return 0;}
		else if(ans[s-1]==0|| ans[s-1]==c) ans[s-1]=c;
		else { cout<<-1;return 0;}
	}
	if(n==1) cout<<ans[0];
	else 
	{
		if(ans[0])cout<<ans[0];
		else cout<<1;
		for(int i=1;i<n;i++) cout<<ans[i];
	}
}

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

int main()
{
 
 char S[102]={'\0'} ;
 int K ;
 scanf("%d",&K);
 scanf("%s",S);
 char Copy[102]={'\0'} ; 
 int LEN = strlen(S);

 if (LEN > K)
 {
  strncpy(Copy, S, K);
  printf("%s...",Copy);
 }

 else printf("%s",S);


  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<double,int>
#define pi atan(1)*4
#define BS(x,xx) binary_search(x.begin(),x.end(),xx)
#define ALL(x) x.begin(),x.end()
#define int ll
main()
{
	int a,b;
	cin>>a>>b;
	int q=__gcd(a,b);
	int re=1;
	for(int i=2;i*i<=q;i++)
	{
		if(q%i==0) re++;
		while(q%i==0)
		{
			q/=i;
		}
	}
	if(q!=1) re++;
	cout<<re<<endl;
}

Measured memory_bytes: 256
S = input()
num = len(S)

K = 1
str = S[0]

for i in range(num-1):
  #print(str)
  if len(str) != 2:
    if str != S[i+1]:
      str = S[i+1]
      K += 1

    elif str == S[i+1] and num-2 != i:
      str = S[i+1] + S[i+2]
      K += 1

  else:
    str = ""


print(K)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  int x,a,b;cin >> x >>a >>b;
  cout << (x-a)%b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <sstream>
#include <bitset>
#define PI 3.141592653589793

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double a_angle = 30 * h + 0.5*m;
    double b_angle = 6 * m;
    double angle = min(abs(a_angle-b_angle), abs(b_angle-a_angle));
    if(a_angle==0) {
        angle = min(angle, min(b_angle, 360-b_angle));
    }

    if(b_angle==0) {
        angle = min(angle, min(a_angle, 360-a_angle));    
    }
    if(a_angle==0 && b_angle==0) angle = 0;
    cout << std::fixed << std::setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(angle* PI / 180.0)) << endl;
}

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

int main(void)
{
  int n;
  int counter;
  int a, b, c, d;
  while(cin >> n){
    
    counter = 0;
    for(a = 0; a <= 9; a++){
      for(b = 0; b <= 9; b++){
	for(c = 0; c <= 9; c++){
	  for(d = 0; d <= 9; d++){
	    if(a+b+c+d==n){
	      counter++;
	    }
	  }
	}
      }
    }	   
  
  cout << counter << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    string cp;
    for(auto x:s) {
        if (x == 'P') {
            cp.push_back('P');
        }
        else {
            cp.push_back('D');
        }
    }
    cout << cp << endl;
    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  string S;
  cin >> S;
  int ans = 700;

  rep(i, 3) {
    if (S[i] == 'o') ans += 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a[5],k;
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    cin >> k;
    for(int i=0;i<4;i++){
        for(int j=i+1; j<5; j++){
            if(a[j]-a[i]>k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   int n;
   cin>>n;
   int dp[n];
   for(int i=0;i<n;i++)
      dp[i]=0;
   for(int i=0,u;i<n-1;i++){
      cin>>u;
      dp[u-1]++;
   }
   for(int i=0;i<n;i++)
      cout<<dp[i]<<'\n';
   return 0;
}



Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    vector<ll> l(n);
    for(ll i=0;i<n;i++)cin>>l[i];
    sort(l.begin(),l.end());
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                ll b,c;
                b=l[j]+l[k];
                c=l[j]-l[k];
                if(c<0)c=-c;
                if(b>l[i]&&c<l[i])ans++;
                else if (b<l[i])break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
A, B, C, X, Y= map(int, input().split())

if C < (A+B)/2:
	if X < Y:
		if 2*C < B:
			print(C*2*X + 2*C*(Y-X))
		else:
			print(C*2*X + B*(Y-X))
	else:
		if 2*C < A:
			print(C*2*Y + 2*C*(X-Y))
		else:
			print(C*2*Y + A*(X-Y))
else:
	print(A*X + B*Y)

Measured memory_bytes: 3064
from math import pi,cos
def solve():
    ans = 0
    A, B, H, M = map(int, input().split())
    theta = ((30*H-5.5*M)%360)*pi/180
    ans = (A**2+B**2-2*A*B*cos(theta))**0.5
    return ans
print(solve())

Measured memory_bytes: 9508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n;
	cin >> n;
	string s;
	//string t = "ABC";
	int cnt = 0;
	for(int i=0; i<n; i++){
		cin >> s;
		if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
} 






Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
using namespace std;
struct Edge{
	int v,c,nxt;
}e[600010];int tot=1;
int first[210];
void build(int u,int v,int c)
{
	e[++tot]=(Edge){v,c,first[u]};
	first[u]=tot;
	return ;
}
void adde(int u,int v,int c)
{
	build(u,v,c);
	build(v,u,0);
	return ;
}
int S,T;
queue<int>q;
int dep[210];
bool bfs()
{
	memset(dep,0,sizeof(dep));
	dep[S]=1;q.push(S);
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=first[u];i;i=e[i].nxt)
			if(e[i].c&&!dep[e[i].v])
			{
				dep[e[i].v]=dep[u]+1;
				q.push(e[i].v);
			}
	}
	return dep[T]>0;
}
int cur[210];
int dfs(int u,int flow)
{
	if(u==T)return flow;
	for(int &i=cur[u];i;i=e[i].nxt)
		if(e[i].c&&dep[u]+1==dep[e[i].v])
		{
			int d=dfs(e[i].v,min(flow,e[i].c));
			if(d){
				e[i].c-=d;
				e[i^1].c+=d;
				return d;
			}
		}
	return 0;
}
int dinic()
{
	int ans=0;
	while(bfs()){
		for(int i=S;i<=T;i++)
			cur[i]=first[i];
		int d;
		while(d=dfs(S,1e9))
			ans+=d;
	}
	return ans;
}
bool check(int a)
{
	if(a<=2)return false;
	for(int i=2;i*i<=a;i++)
		if(a%i==0)return false;
	return true;
}
int x[210];
int vis[10000010];
int main()
{
	int n;scanf("%d",&n);
	int N=0;
	int mx=0;
	for(int i=1;i<=n;i++)
	{
		int a;scanf("%d",&a);
		vis[a]=1;mx=max(mx,a);
	}
	for(int i=1;i<=mx+1;i++)
		if(vis[i]!=vis[i-1])
			x[++N]=i;
	S=0;T=N+1;
	int cntx=0,cnty=0;
	for(int i=1;i<=N;i++)
		if(x[i]&1){
			adde(S,i,1);
			cntx++;
		}
		else{
			adde(i,T,1);
			cnty++;
		}
	for(int i=1;i<=N;i++)
		if(x[i]&1){
			for(int j=1;j<=N;j++)
				if(check(abs(x[i]-x[j])))
					adde(i,j,1);
		}
	int res=dinic();
	int ans=res+(cntx-res)/2*2+(cnty-res)/2*2+((cntx-res)&1)*3;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 39168
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[100101];
int l[101015];
int j[2];

long long x,y,z,mod=1000000007;
string r;
//char r[2];

P u[1];
queue<int> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v[111111];


bool as(P a,P b)
{
  return a.x<b.x;
}


int main()
{
  scanf("%d",&a);
  for(int t=1;t<a;t++)
  {
    scanf("%d %d",&n,&m);
    v[n].push_back(m);
    v[m].push_back(n);
  }
  q.push(1);
  o[1]=1;
  for(;q.size();q.pop())
  for(int h=0;h<v[q.front()].size();h++)
  if(o[v[q.front()][h]]==0)
  {
    o[v[q.front()][h]]=o[q.front()]+1;
    q.push(v[q.front()][h]);
  }
  q.push(a);
  l[a]=1;
  for(;q.size();q.pop())
  for(int h=0;h<v[q.front()].size();h++)
  if(l[v[q.front()][h]]==0)
  {
    l[v[q.front()][h]]=l[q.front()]+1;
    q.push(v[q.front()][h]);
  }
  for(int t=1;t<=a;t++)
  if(o[t]<=l[t]) c++;
  else d++;
  if(c>d) puts("Fennec");
  else puts("Snuke");
}
//11




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

#define abs(a) ((a)>0?(a):-(a))
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.14159265358979323846
#define endl "\n"
#define int long long int
int gcd(int a,int b){for(int c;b;c=a,a=b,b=c%b);return a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
// int MOD = 1000000000;

signed main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int T;
    T = 1;
    // int k=0;
    while(T>0){
        int N;
        cin >> N;
        int sub[N+1];
        for (int i = 0; i <= N; ++i)
        {
            sub[i] = 0;
        }

        int sum = 0;
        for (int i = 1; i < N; ++i)
        {
            int x;
            cin >> x;
            sub[x]++;
        }
        for (int i = 1; i <= N; ++i)
        {
            cout << sub[i] << endl;
        }
    T--;
    }
    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#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++)
struct UnionFind {
  vector<int> par; 

  UnionFind(int N) : par(N) { 
    rep(i,N) par[i] = i;
  }
  int root(int x) { 
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x); 
    int ry = root(y);
    if (rx == ry) return; 
    par[rx] = ry; 
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

  
int main() {
  int w,h;
  cin >> w>>h;
  vector<vector<int>>pq(w+h,vector<int>(2));
  vector<int>p(w);
  rep(i,w){
    cin>>p.at(i);
    pq.at(i).at(0)=p.at(i);
    pq.at(i).at(1)=1;
  }
  vector<int>q(h);
  rep(i,h){
    cin>>q.at(i);
    pq.at(i+w).at(0)=q.at(i);
    pq.at(i+w).at(1)=2;
  }
  sort(pq.begin(),pq.end());
  long ans=0;
  long a=w+1;
  long b=h+1;
  rep(i,w+h){
    if(pq.at(i).at(1)==1){
      ans+=pq.at(i).at(0)*b;
      a--;
    }
    else{
      ans+=pq.at(i).at(0)*a;
      b--;
    }
  }
  
  cout<<ans<<endl;
}



Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k,c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  int a[n+1];
  a[0]=0;
  int cur=-c-1;
  rep(i,0,n){
    if(s[i]=='x'){
      a[i+1]=a[i];
    }
    else{
      if(cur+c<i){
        a[i+1]=a[i]+1;
        cur=i;
      }
      else{
        a[i+1]=a[i];
      }
    }
  }
  int d[a[n]];
  rep(i,0,n){
    if(a[i]!=a[i+1]){
      d[a[i]]=i+1;
    }
  }
  
  int b[n+1];
  b[0]=a[n];
  cur=-c-1;
  rep(i,0,n){
    if(s[n-1-i]=='x'){
      b[i+1]=b[i];
    }
    else{
      if(cur+c<i){
        b[i+1]=b[i]-1;
        cur=i;
      }
      else{
        b[i+1]=b[i];
      }
    }
  }
  int e[a[n]];
  rep(i,0,n){
    if(b[i]!=b[i+1]){
      e[b[i+1]]=n-i;
    }
  }
  
  if(a[n]==k){
    rep(i,0,a[n]){
      if(d[i]==e[i]){
        cout<<d[i]<<endl;
      }
    }
  }
}

Measured memory_bytes: 4996
#include<iostream>
#include<cstdio>

using namespace std;

int cast(int val , int per)
{
	return val*(100+per)/100;
}

int main()
{

  while(1)
  {
	 int x,y,s;

	 cin >> x >> y >> s;
 
	 if(!x && !y && !s)break;

	 int a , b;//2つの商品の税抜き価格
	 int Max = 0;

	 for(a = 1;a <= s-1;a++)
	 {
		 for(b = 1;b <= s-1;b++)
		 {
			 if(cast(a,x)+cast(b,x) == s)
			 {
				 Max = max(cast(a,y)+cast(b,y),Max);
			 }
		 }
	 }

	 cout << Max << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    vector<ll> white(N, 0), black(N, 0);

    if(s[0] == '#') black[0] = 1;
    else white[0] = 1;

    for(int i=1; i<N; i++){
        if(s[i] == '.'){
            white[i] = white[i-1]+1;
            black[i] = black[i-1];
        }
        else{
            white[i] = white[i-1];
            black[i] = black[i-1]+1;
        }
    }

    ll ans = 10000000;
    for(int i=0; i<N; i++){
        ll tmp = black[i] + (white[N-1]-white[i]);
        ans = min(ans, tmp);
    }
    
    ans = min(ans, white[N-1]);

    cout << ans << endl;
}


Measured memory_bytes: 3716
#include <stdio.h>
int main()
{
    double L[10];
    double V1, V2;
    double meet_pos;
    double railway_lenth;
    int cnt1, cnt2;
    int output[50];
    
    cnt2 = 0;
    while(scanf("%lf,", &L[0]) != EOF){
    	for(cnt1 = 1; cnt1 < 10; cnt1++)
			scanf("%lf,", &L[cnt1]);
		scanf("%lf,%lf", &V1, &V2);
    	
    	railway_lenth = 0;
    	for(cnt1 = 0; cnt1 < 10; cnt1++)
			railway_lenth += L[cnt1];
    	meet_pos = railway_lenth * V1 / (V1 + V2);
    	
    	railway_lenth = 0;
    	for(cnt1 = 0; railway_lenth < meet_pos; cnt1++)
			railway_lenth += L[cnt1];
    	output[cnt2++] = cnt1;
    }
    for(cnt1 = 0; cnt1 < cnt2; cnt1++)
		printf("%d\n", output[cnt1]);
    return 0;
} 

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

vector<ll>ans;
//d現在の桁数now現在の値
void f(int d,ll now){
    ans.push_back(now);
    if(d==10)return;
    int s = now%10;
    for(int i=-1;i<=1;i++){
        int ns=s+i;
        if(0<=ns&&ns<=9)f(d+1,now*10+ns);
    }
}
int main(){
    int k;
    cin >> k;
    for(int i=1;i<=9;i++){
        f(1,i);
    }
    sort(ans.begin(),ans.end());
    cout << ans[k-1] << endl;
    return 0;
}

Measured memory_bytes: 2420
n = int(input())
g = [[] for i in range(n)]
for i in range(n):
    m = int(input())
    for j in range(m):
        g[i].append([int(x) for x in input().split()])
res = 0
for i in range(2 ** n):
    bit = i
    hypothesis = []
    for j in range(n):
        hypothesis.append(bit % 2)
        bit //= 2
    bit = i
    k = 0
    flag = True
    while bit > 0:
        if bit % 2 == 1:
            for s in g[k]:
                if hypothesis[s[0] - 1] != s[1]:
                    flag = False
        bit >>= 1
        k += 1
    if flag:
        if sum(hypothesis) > res:
            res = sum(hypothesis)
print(res)

Measured memory_bytes: 3064
N = int(input())
edge = [[] for _ in range(N)]

for _ in range(N):
    l = list(map(int, input().split()))
    for j in range(l[1]):
        edge[l[0]-1].append(l[2+j]-1)


now_list = [0]
next_list = []
dist = 0
dists = [-1] * N
while len(now_list) > 0:
    for _ in range(len(now_list)):
        v = now_list.pop()
        if dists[v] == -1:
            dists[v] = dist
        else:
            continue
        for nv in edge[v]:
            next_list.append(nv)
    now_list = next_list
    next_list = []
    dist += 1

for i in range(N):
    print(1+i, dists[i])



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

struct Data {
  int v, i;
  bool operator < ( const Data &d ) const {
    return v < d.v;
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> B(n-1);
  rep(i,n-1) cin >> B[i];
  vector<Data> vec;
  rep(i,n-1) vec.push_back((Data){B[i],i});
  sort(ALL(vec));
  vector<int> A(n,-1);
  rep(i,n-1) {
    Data &d = vec[i];
    int j = d.i;
    if( A[j]   == -1 ) A[j]   = max(A[j]  ,d.v);
    if( A[j+1] == -1 ) A[j+1] = max(A[j+1],d.v);
  }
  int ans = 0;
  rep(i,n) ans += A[i];
  cout << ans << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
d=int(a/0.08)
u=int(b/0.1)
ans=-1
if min(d,u)>12:
    start=min(d,u)-12
else:
    start=0
for i in range(start,max(d,u)+13):
    if (int(i*0.08)==a)and(int(i*0.1)==b):
        ans=i
        break
print(ans)

Measured memory_bytes: 38384
def C(x, y):
    z = 1
    for i in range(x, x-y, -1):
        z *= i
    for i in range(y, 1, -1):
        z //= i
    return z
def H(x, y):
    return C(x+y-1, y)
n, m = list(map(int, input().split()))
p = 2
prime_factorization = []
while p * p <= m:
    count = 0
    while m % p == 0:
        m //= p
        count += 1
    if count > 0:
        prime_factorization.append(count)
    p += 1
if m > 1:
    prime_factorization.append(1)
ans = 1
for r in prime_factorization:
    ans *= H(n, r)
print(ans % 1000000007)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <utility>
using namespace std;
const int inf = 1e9;
struct node{
    int time,num;
    int i,j;
    node(int i, int j, int t, int n):time(t),num(n),i(i),j(j){}
    node(){}
    bool operator <(const node &a) const{
        return (time!=a.time)? time>a.time: num>a.num;
    }
};
typedef pair<int, int> pii;
pii operator +(const pii &a, const pii &b){
    return pii(a.first+b.first, a.second+b.second);
}

int main(){
    int n,ct;
    cin >> n >> ct;
    string a,b;
    cin >> a >> b;
    vector<vector<string>> s(n);
    vector<vector<int>> t(n);
    map<string, vector<pii>> change_line;
    for(int i=0; i<n; i++){
        int ns;
        cin >> ns;
        s[i].resize(ns);
        for(int j=0; j<ns; j++){
            cin >> s[i][j];
            change_line[s[i][j]].emplace_back(i, j);
        }
        t[i].resize(ns-1);
        for(int j=0; j<ns-1; j++){
            cin >> t[i][j];
        }
    }

    priority_queue<node> wait;    
    vector<vector<pii>> mincost(n);
    set<string> used;
    for(int i=0; i<n; i++){
        mincost[i] = vector<pii>(s[i].size(), pii(inf, inf));
    }
    for(auto &p: change_line[a]){
        wait.push(node(p.first, p.second, 0, 0));
        mincost[p.first][p.second] = pii(0, 0);
    }
    used.insert(a);
    pii ans(-1, -1);
    while(!wait.empty()){
        node curr = wait.top();
        wait.pop();
        size_t i=curr.i, j=curr.j;
        if(s[i][j] == b){
            ans = mincost[i][j];
            break;
        }
        if(pii(curr.time, curr.num) > mincost[i][j]){
            continue;
        }
        vector<pair<pii, pii>> next;
        if(j!=0) next.emplace_back(pii(i, j-1), pii(t[i][j-1], 0));
        if(j<t[i].size()) next.emplace_back(pii(i, j+1), pii(t[i][j], 0));
        if(used.find(s[i][j]) == used.end()){
            used.insert(s[i][j]);
            for(auto &p: change_line[s[i][j]]){
                next.emplace_back(pii(p.first, p.second), pii(ct, 1));
            }
        }
        for(auto &pp: next){
            int ni=pp.first.first, nj=pp.first.second;
            pii cost=mincost[i][j]+pp.second;
            if(cost < mincost[ni][nj]){
                mincost[ni][nj] = cost;
                wait.push(node(ni, nj, cost.first, cost.second));
            }
        }
    }
    if(ans.first == -1){
        cout << -1 << endl;
    }else{
        cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}



Measured memory_bytes: 24064
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		ll M = 100001;
//		ll M = 101;
		VI dp(M, INF);
		dp[0] = 0;
		REP(i, M) {
			if(i+1<M) dp[i+1] = min(dp[i+1], dp[i]+1);
			RANGE(j, 1, 10) {
				ll ni = (ll)pow(6, j);
				if(i+ni<M) dp[i+ni] = min(dp[i+ni], dp[i]+1);
			}
			RANGE(j, 1, 10) {
				ll ni = (ll)pow(9, j);
				if(i+ni<M) dp[i+ni] = min(dp[i+ni], dp[i]+1);
			}
		}
//		DD(dp);
		
		cout<<dp[N]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b;
	c = 0;
	while (a)
	{
		a =a/ b;
		c++;
	}
	cout << c << "\n";
}



Measured memory_bytes: 256
#include <iostream>
#define LEN 100005

using namespace std;

/*
typedef struct pp{
  string name;
  int t;
}P;
*/

class P{
public:
  string name;
  int t;
};


P Q[LEN];

int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b;}

void initialize(){
  head = 0;
  tail = 0;
}

bool isEmpty(){
  return head == tail;
}

bool isFull(){
  return (head == (tail + 1)%LEN);
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  cin >> n >> q;
  for (i = 1; i <= n; i++){
    cin >> Q[i].name;
    cin >> Q[i].t;
  }
  head = 1;
  tail = n + 1;

  while (head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      cout << u.name << " " << elaps << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 7096
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a+b>=a-b && a+b>=a*b)
		printf("%d\n",a+b);
	
	else if(a-b>a+b && a-b>a*b)
		printf("%d\n",a-b);

	else
		printf("%d\n",a*b);
		
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    int N, K;
    cin >> N >> K;
    ll ans = K;
    rep(i,N-1){
        ans *= (K - 1);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


char buf[2][100000+10];
int main(void) {
  scanf("%s", buf[0]);
  int deleted = 0;
  for(int t = 0; ; t = !t) {
    bool modified = false;
    char *cur = buf[t];
    char *next = buf[!t];
    int i2 = 0;
    next[i2++] = cur[0];
    for(int i = 1; ; ++i) {
      if(cur[i+1] == 0) {
        next[i2++] = cur[i];
        next[i2] = 0;
        break;
      }
      if(next[i2-1] == cur[i+1]) {
        next[i2++] = cur[i];
      } else {
        ++deleted;
        modified = true;
      }
    }
    if(!modified) {
      break;
    }
  }
  puts(deleted & 1 ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){

  string tmp;
  map <string,bool> a;
  int n,i;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>tmp;
    if(tmp=="insert"){
      cin>>tmp;
      a.insert(make_pair(tmp,true));
    } else {
      cin>>tmp;
      if(a.count(tmp)) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }

  }

  return 0;

}



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

struct node{
	node*l,*r;
	int cnt,val,Min;
};
node pool[400000];
int p;

inline int cnt(node*t){return t?t->cnt:0;}
inline int Min(node*t){return t?t->Min:INF;}

inline node*update(node*t){
	t->cnt=cnt(t->l)+cnt(t->r)+1;
	t->Min=min({t->val,Min(t->l),Min(t->r)});
	return t;
}
inline node*merge(node*l,node*r){
	if(!l)return r;
	if(!r)return l;
	if(rand()%(cnt(l)+cnt(r))<cnt(l)){
		l->r=merge(l->r,r);
		return update(l);
	}
	else{
		r->l=merge(l,r->l);
		return update(r);
	}
}
inline pair<node*,node*>split(node*t,int k){
	if(!t)return make_pair((node*)NULL,(node*)NULL);
	if(k<=cnt(t->l)){
		auto p=split(t->l,k);
		t->l=p.second;
		return make_pair(p.first,update(t));
	}
	else{
		auto p=split(t->r,k-cnt(t->l)-1);
		t->r=p.first;
		return make_pair(update(t),p.second);
	}
}

int main(){
	int n,q;scanf("%d%d",&n,&q);
	node*root=NULL;
	rep(i,n){
		int a;scanf("%d",&a);
		node*t=&pool[p++];
		*t={NULL,NULL,1,a,a};
		root=merge(root,t);
	}
	rep(i,q){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y-1);
			auto c=split(b.second,1);
			root=merge(merge(merge(a.first,c.first),b.first),c.second);
		}
		else if(x==1){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y);
			printf("%d\n",Min(b.first));
			root=merge(merge(a.first,b.first),b.second);
		}
		else{
			auto a=split(root,y);
			auto b=split(a.second,1);
			b.first->val=b.first->Min=z;
			root=merge(merge(a.first,b.first),b.second);
		}
	}
}


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

struct Problem {

	UL dp[401][401][11];

	void Solve() {
		UL N; cin >> N;
		pair<UL, UL> M; cin >> M.first >> M.second;
		vector<pair<UL, UL>> A(N);
		vector<UL> C(N);
		rep(i, N) cin >> A[i].first >> A[i].second >> C[i];

		for (UL x = 0; x <= N * 10; x++) {
			for (UL y = 0; y <= N * 10; y++) {
				dp[x][y][0] = 1000000000;
			}
		}
		dp[0][0][0] = 0;

		rep(i, N) {
			for (UL x = 0; x <= N * 10; x++) {
				for (UL y = 0; y <= N * 10; y++) {
					UL p = dp[x][y][i];
					if (x >= A[i].first && y >= A[i].second) {
						p = min(p, dp[x - A[i].first][y - A[i].second][i] + C[i]);
					}
					dp[x][y][i + 1] = p;
				}
			}
		}
		UL ans = 1000000000;
		for (UL i = 1;; i++) {
			if (M.first * i > N * 10) break;
			if (M.second * i > N * 10) break;
			ans = min(ans, dp[M.first * i][M.second * i][N]);
		}
		if (ans == 1000000000) { cout << -1 << endl; return; }
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;
using ll = long long;

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

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

int main() {
    int D; cin >> D;
    map<int, string> mp;
    mp[25] = "Christmas";
    mp[24] = "Christmas Eve";
    mp[23] = "Christmas Eve Eve";
    mp[22] = "Christmas Eve Eve Eve";

    cout << mp[D] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////



 
int main(){fastio
    
  
    
    ll n;cin>>n;
    string s;cin>>s;
    if(n%2==1){
        cout<<"No"<<endl;return 0;
    }
    rep(i,0,n/2-1){
        if(s[i]!=s[i+n/2]){
            cout<<"No"<<endl;return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;


int main() {
    VI two, three;
    REPI(i,2,30001) {
        if (i % 2 == 0) two.push_back(i);
        else if (i % 3 == 0) three.push_back(i);
    }
    int n;
    cin >> n;
    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    
    int a, b;
    for (b = 2; b <= 5000; b+=2) {
        a = n - b;
        if (a >= 2 && a <= 15000) break;
    }
    
    VI ans;
    
    if (a % 3 == 0) {
        REP(i,a) {
            ans.push_back(two[i]);
        }
    } else if (a % 3 == 1) {
        ans.push_back(6);
        REP(i,a-1) {
            ans.push_back(two[i+3]);
        }
    } else {
        REP(i,a) {
            ans.push_back(two[i]);
        }
    }
    
    REP(i,b) {
        ans.push_back(three[i]);
    }
    
    REP(i,ans.size()-1) {
        cout << ans[i] << " ";
    }
    cout << ans.back() << endl;
}


Measured memory_bytes: 832
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n; cin>>n;
    vector<ll> v;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
        {
            ll cnt=0;
            while(n%i==0) n=n/i, cnt++;
            v.push_back(cnt);
        }
    }
    if(n!=1) v.push_back(1);
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ll val=1;
        ll j=2;
        while(1)
        {
           if(val+j>v[i]) break;
           val+=j;
           j++;
        }
        ans+=(j-1);
    }
    cout<<ans<<endl;
    
}

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

int main() {
  int N;
  cin >> N;
  vector<int> lights(N + 1);
  lights.at(0) = N;
  for (int i = 1; i <= N ; i++) {
    cin >> lights.at(i);
  }
  int light_on =1;
  for (int j = 0; j < N; j++) {
    light_on = lights.at(light_on);
    if (light_on == 2) {
      cout << j + 1 << endl;
      break;
    }
  }
  if (light_on != 2) {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
n,a=map(int,input().split())
x=list(map(int,input().split()))
m=max(x)
L3=[]
for i3 in range(n+1):
  L2=[]
  for i2 in range(n+1):
    L1=[0 for i1 in range(n*m+1)]
    L2.append(L1)
  L3.append(L2)
for i3 in range(n+1):
  for i2 in range(n+1):
    for i1 in range(m*n+1):
      if i1==0 and i2==0 and i3==0:
        L3[i3][i2][i1]=1
      elif i3>0 and i1<x[i3-1]:
        L3[i3][i2][i1]=L3[i3-1][i2][i1]
      elif i3>0 and i2>0 and i1>=x[i3-1]:
        L3[i3][i2][i1]=L3[i3-1][i2][i1]+L3[i3-1][i2-1][i1-x[i3-1]]
      else:
        L3[i3][i2][i1]=0
ct=0
for i2 in range(n+1):
  for i1 in range(1,m*n+1):
    if i1==i2*a:
      ct+=L3[n][i2][i1]
print(ct)

Measured memory_bytes: 96732
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1;i<=n;i++){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 102;
char s[N];

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    scanf("%d %d\n%s", &n, &k, s);
    k--;
    s[k] -= 'A';
    s[k] += 'a';
    printf("%s", s);
    
    return 0;
}


Measured memory_bytes: 3812
import Control.Monad
import Data.List

main = do
  a <- (replicateM 5 readLn)::IO [Int]
  k <- readLn
  let xs = [abs(x - y) | x <- a, y <- a, x /= y]
  putStrLn $ if any (> k) xs then ":(" else "Yay!"

Measured memory_bytes: 508
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N % 10 == 9 || N / 10 == 9) {
      System.out.print("Yes");
    } else {
      System.out.print("No");
    }
  }
}

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

ll solve() {
    string S;
    cin >> S;
    ll a = 0;
    vector<ll> n(S.size()+1);
    for ( int i = 0; i < S.size(); i++ ) {
        if ( S[i] == '<' ) a++;
        else a = 0;
        n[i+1] = max(n[i+1], a);
    }
    for ( int i = S.size()-1; i >= 0; i-- ) {
        if ( S[i] == '>' ) a++;
        else a = 0;
        n[i] = max(n[i], a);
    }
    ll ans = 0;
    for ( int i = 0; i <= S.size(); i++ ) {
        ans += n[i];
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;

typedef long long ll;

int n;
string a, b, c;

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

    cin >> n >> a >> b >> c;

    string words[3];
    words[0] = a;
    words[1] = b;
    words[2] = c;

    int ch = 0;
    REP(i, n) {
        int m = 0;
        if (words[0][i] == words[1][i]) {
            ++m;
        }
        if (words[0][i] == words[2][i]) {
            ++m;
        }
        if (words[1][i] == words[2][i]) {
            ++m;
        } 

        if (m == 0) {
            ch += 2;
        } else if (m == 1) {
            ch++;
        }
    }

    cout << ch << "\n";
}

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

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

using namespace std;
using lint=long long;

vector<lint> divisor(lint a){
	vector<lint> res;
	for(lint i=1;i*i<=a;i++) if(a%i==0) {
		res.emplace_back(i);
		if(i*i<a) res.emplace_back(a/i);
	}
	return res;
}

lint f(lint b,lint n){ return n<b?n:f(b,n/b)+n%b; }

lint solve(lint n,lint s){
	if(n< s) return -1;
	if(n==s) return n+1;

	for(lint b=2;b*b<=n;b++) if(f(b,n)==s) return b;

	lint res=LLONG_MAX;
	auto D=divisor(n-s);
	for(lint d:D){
		lint b=d+1;
		lint p=(n-s)/(b-1);
		lint q=s-p;
		if(1<=p && p<b && 0<=q && q<b) res=min(res,b);
	}
	return res<LLONG_MAX?res:-1;
}

int main(){
	lint n,s; cin>>n>>s;
	cout<<solve(n,s)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<memory.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int len1,lens2;
    int s11[30],s22[30];
    memset(s11,0,sizeof(s11));
    memset(s22,0,sizeof(s22));
	len1=s1.length();
	for(int i=0;i<len1;i++)
	{
		s11[s1[i]-'a']++;
		s22[s2[i]-'a']++;
	}
	for(int i=0;i<len1;i++)
	{
         if(s11[s1[i]-'a']!=s22[s2[i]-'a'])
        {
        	cout<<"No";
//        	cout<<s1[i]<<"    "<<s2[i];
        	return 0;
		}
	}
	cout<<"Yes";
	return 0;
 } 


Measured memory_bytes: 776
D=int(input())
clist=list(map(int,input().split()))
smat=[[int(x) for x in input().split()] for _ in range(D)]
#print(clist)
#print(smat)

index_set=set(range(26))
for d in range(D):
  max_index=-1
  max_sd=-1
  for i in index_set:
    if max_sd<smat[d][i]:
      max_index=i
      max_sd=smat[d][i]
      
  print(max_index+1)
  index_set.remove(max_index)
  if not index_set:
    index_set=set(range(26))

Measured memory_bytes: 68452
#include <stdio.h>

int main()
{
	int H,W,i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)
		{
			break;
		}
		for(j = 0; j < H; j++)
		{
			for(i = 0; i < W; i++)
			{
				if(i == 0 || j == 0 || i == W-1 || j == H-1)
				{
					printf("#");
				}else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n;
    cin>>n;
    ll ar[n],br[n];
    ll pre1[n],pre2[n];
    cin>>ar[0];
    pre1[0] = ar[0];
    for(ll i=1;i<n;i++){
        cin>>ar[i];
        pre1[i] = pre1[i-1] + ar[i];
    }
    cin>>br[0];
    pre2[0] = br[0];
    for(ll i=1;i<n;i++){
        cin>>br[i];
        pre2[i] = pre2[i-1] + br[i];
    }
    ll sum = pre1[0] + pre2[n-1];
    for(ll i=1;i<n;i++){
        ll var = pre1[i] + pre2[n-1] - pre2[i-1] ;
        if(var>=sum){
            sum = var;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256