akhauriyash/Code-Regression huggingface dataset:
// AOJ NTL_2_C Multiplication of Big Integers
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>

#define N       1000000000

int a[120], b[120], ab[500];
int a_minus, b_minus;
char buf[5000];

char *mpStr2Num(int *num, char *str)
{
	char *ss, *end;
	int  *nn;
	int  k, x;

//	while (*str == ' ' || *str == '\t') str++;
	while (*str == '0') str++;
	ss = str;
	while (*ss >= '0' && *ss <= '9') ss++;
	end = ss;

	if (ss == str) { *num = 0; return end; }

	x = 0, k = 1, nn = num;
	do {
		x += (*--ss - '0') * k;
		k *= 10;
		if (k == N || ss == str) *++nn = x, x = 0, k = 1;
	} while (ss != str);

	*num = nn - num;
	return end;
}

void mpNum2Str(char *str, int *num)
{
	int  i, j, x;
	char *ss;

	if (*num == 0 || (*num == 1 && *(num + 1) == 0)) {
		*str++ = '0', *str = '\0';
		return;
	}

	ss = str - 1;
	for (i = *num; i > 0; i--) {
		x = *++num;
		for (j = 1; j < N; j *= 10) {
			*++ss = x % 10 + '0';
			x /= 10;
		}
	}
	while (*ss == '0') ss--;

	*(ss + 1) = '\0';
	while (str < ss) {
		x = *str;
		*str++ = *ss;
		*ss-- = x;
	}
}

void mpAdd(int *ret, int *a, int *b)
{
	int  i, lr, la, lb, x;
	int  *rr;

	la = *a, lb = *b;
	lr = (la >= lb) ? la : lb;
	rr = ret, x = 0;
	for (i = 1; i <= lr; i++) {
		if (i <= la) x += *++a;
		if (i <= lb) x += *++b;
		if (x < N) *++rr = x, x = 0;
		else       *++rr = x - N, x = 1;
	}
	*++rr = x;
	*ret = lr + x;
}

void mpSub(int *ret, int *a, int *b)
{
	int  i, la, lb, x;
	int  *rr;

	la = *a, lb = *b;
	rr = ret, x = 0;
	for (i = 1; i <= la; i++) {
		x += *++a;
		if (i <= lb) x -= *++b;
		if (x >= 0) *++rr = x, x = 0;
		else 		*++rr = x + N, x = -1;
	}
	while (--i > 0) if (*rr-- != 0) break;
	*ret = i;
}

int mpCmp(int *a, int *b)
{
	int  *aa;

	if (*a != *b) return *a - *b;
	aa = a, a += *aa, b += *aa;
	while (a != aa) {
		if (*a != *b) return *a - *b;
		a--, b--;
	}
	return 0;
}

int mpAddSub(int *ret, int *a, int a_minus, int *b, int b_minus)
{
	int k, minus = 0;

	if (a_minus && b_minus) minus = 1, a_minus = 0, b_minus = 0;
	if (!a_minus && !b_minus) mpAdd(ret, a, b);
	else {
		k = mpCmp(a, b);
		if (k == 0) *ret = 0, minus = 0;
		else if (k > 0) mpSub(ret, a, b), minus = a_minus;
		else            mpSub(ret, b, a), minus = b_minus;
	}
	return minus;
}

void mpMul(int *ret, int *a, int *b)
{
	int  i, j, la, lb;
	int  *aa;
	int  ca;
	long long x;

	la = *a, lb = *b;

	if (la == 0 || lb == 0) { *ret = 0; return; }

	for (i = la + lb; i > 0; i--) *(ret + i) = 0;

	for (j = 1; j <= lb; j++) {
		ca = 0;
		b++;
		for (i = 1, aa = a; i <= la; i++) {
			x = *++aa;
			x = x * *b + *(ret + i + j - 1) + ca;
			*(ret + i + j - 1) = x % N;
			ca = (int)(x / N);
		}
		*(ret + i + j - 1) = ca;
	}
	*ret = (ca != 0) ? la + lb : la + lb - 1;
}

int main()
{
	int minus;
	char *p;

	fgets(p = buf, 200100, stdin);
	if (*p == '-') a_minus = 1, p++;
	p = mpStr2Num(a, p);
	while (*p == ' ') p++;

	if (*p == '-') b_minus = 1, p++;
	mpStr2Num(b, p);

	minus = a_minus ^ b_minus;
	mpMul(ab, a, b);
	if (*ab == 0) minus = 0;
	if (minus) putchar('-');
	mpNum2Str(buf, ab);
	puts(buf);
	return 0;
}


Measured memory_bytes: 2088
def d_road_to_millionaire():
    N = int(input())
    A = [int(i) for i in input().split()]

    money = 1000
    stock = 0
    for i in range(N - 1):
        stocks = money // A[i] if A[i] < A[i + 1] else 0
        money += (A[i + 1] - A[i]) * stocks
    return money

print(d_road_to_millionaire())

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a <= c && c <= b) || (b <= c && c <= a)) {
    p("Yes");
  } else {
    p("No");
  }
}

Measured memory_bytes: 256
N,A,B = map(int, input().split())
if N < 0 or A > B or (N == 1 and A !=B):
    print("0")
elif N == 1:
    print("1")
else:
    ans = (A + (N-1) * B) - (B + (N-1) * A) + 1
    print(str(ans))

Measured memory_bytes: 3060
N = int(input())
A = []
while N != 0:
  A.append(N%10)
  N //= 10
n = len(A)
nine = 0
for i in range(n-1):
  if A[i] == 9:
    nine += 1
if nine == n - 1:
  print(sum(A))
else:
  for i in range(n-1):
      A[i] = 9
  if A[n-1] > 1:
    A[n-1] -= 1
    print(sum(A))
  else:
    print(sum(A[i] for i in range(n-1)))

Measured memory_bytes: 3064
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::cmp::*;
use std::thread;
fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut adj = vec![Vec::new(); n];
    for i in 1..n {
        let par = sc.ne::<usize>() - 1;
        adj[par].push(i);
    }
    fn dfs(cur: usize, adj: &Vec<Vec<usize>>) -> usize {
        let tn = adj[cur].len();
        if tn == 0 {
            return 0;
        }
        let mut kids = Vec::new();
        for &nxt in &adj[cur] {
            kids.push(dfs(nxt, &adj));
        }
        kids.sort_by(|a, b| b.cmp(a));
        let mut res = 0;
        for i in 0..tn {
            let plus = i + 1;
            res = max(res, kids[i] + plus);
        }
        // println!("cur: {}, res: {}", cur + 1, res);
        res
    }
    println!("{}", dfs(0, &adj));
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK * 4);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



vector<int> calc(vector<int> a) {
        int n = sz(a) / 3;
        priority_queue<int> pq;
        ll sum = 0;
        vector<int> res(3 * n);
        for (int i = 0; i < 3 * n; i++) {
                if (sz(pq) < n) {
                        pq.emplace(-a[i]);
                        sum += a[i];
                } else if (a[i] > -pq.top()) {
                        sum += pq.top();
                        sum += a[i];
                        pq.emplace(-a[i]);
                        pq.pop();
                }
                res[i] = sum;
        }

        return res;
}


void _main() {
        int n; cin >> n;
        vector<int> a(3 * n); cin >> a;
        vector<ll> suf(3 * n);
        priority_queue<int> pq;
        ll sum = 0;
        for (int i = 3 * n - 1; i >= 0; i--) {
                if (sz(pq) < n) {
                        pq.emplace(a[i]);
                        sum += a[i];
                } else if (a[i] < pq.top()) {
                        sum += a[i] - pq.top();
                        pq.emplace(a[i]);
                        pq.pop();
                }
                suf[i] = sum;
        }

        sum = 0;
        while (sz(pq)) pq.pop();
        ll ans = -1e18;
        for (int i = 0; i < 3 * n; i++) {
                if (sz(pq) < n) {
                        pq.emplace(-a[i]);
                        sum += a[i];
                } else if (a[i] > -pq.top()) {
                        sum += a[i] + pq.top();
                        pq.emplace(-a[i]);
                        pq.pop();
                }
                if (i + 1 >= n && 3 * n - i - 1 >= n) {
                        ans = max(ans, sum - suf[i + 1]);
                }
        }

        cout << ans;

}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 7412
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll

int d,g;
int p[100],c[100];
int ans;

void f(int k,bool b[],int m,int sum){
  if(k==d){
    if(sum>=g){
      ans = min(ans,m);
      return;
    }
    rep(i,d){
    
      if(b[i]) continue;
      if((g-sum)/(100*(i+1))>0&&(g-sum)/(100*(i+1))<=p[i])
        ans = min(ans,m+(g-sum)/(100*(i+1)));
    }
    return;
  }

  b[k]=true;
  f(k+1,b,m+p[k],sum+100*(k+1)*p[k]+c[k]);
  b[k]=false;
  f(k+1,b,m,sum);
}





signed main(){
  cin>>d>>g;
  rep(i,d){
    cin>>p[i]>>c[i];
    ans+=p[i];
  }

  bool b[100]={};
  f(0,b,0,0);

  cout<<ans<<endl;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>v;
	v.push_back(K);
	for (int i = 0;i<=30;++i) {
		if ((K>>i)&1) {
			int n = (K >> (i + 1)) << (i + 1);
			n += (1<<i)-1;
			v.push_back(n);
		}
	}
	vector<int>A(N);
	vector<long long>B(N);
	for (int i = 0;i<N;++i) {
		cin >> A[i] >> B[i];
	}
	long long ans = 0;
	for (int i = 0;i<v.size();++i) {
		long long sub = 0;
		for (int j = 0;j<N;++j) {
			bool b = true;
			for (int k = 0;k<=30;++k) {
				if ((v[i]>>k)&1) {
				}
				else {
					if ((1<<k)&A[j]) {
						b = false;
					}
				}
			}
			if (b) {
				sub += B[j];
			}
		}
		ans = max(ans,sub);
	}
	cout << ans <<  endl;
	return 0;
}


Measured memory_bytes: 4560
import math

def isprime(N):
	if N == 2:
		return True
	if N <= 1 or N % 2 == 0:
		return False
	lim = int(math.sqrt(N))
	for i in range(3, lim + 1, 2):
		if N % i == 0:
			return False
		i += 2
	return True

N = int(input())
ans = 0
for i in range(N):
	ans += int(isprime(int(input())))
print(ans)


Measured memory_bytes: 5676
#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 rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#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;

int fc(vector<int> &hc, vector<int> &ph){
  int mx = 0;
  rep(i, hc.size()) mx = max(mx, hc.at(i));
  rep(i, hc.size()){
    if(hc.at(i) == mx) ph.push_back(i);
  }
  return mx;
}

int main(){
  int h, w, m;
  cin >> h >> w >> m;
  set<pair<int, int>> se;
  vector<int> hc(h, 0), wc(w, 0);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    hc.at(a)++;
    wc.at(b)++;
    se.insert({a, b});
  }
  vector<int> ph, pw;
  int mh = fc(hc, ph);
  int mw = fc(wc, pw);
  int ans = mh + mw - 1;
  for(auto i : ph){
    for(auto j : pw){
      if(se.find({i, j}) == se.end()){
        ans++;
        goto SKIP;
      }
    }
  }
  SKIP:
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 23860
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll a,b,c,x,count=0;
  cin>>a>>b>>c>>x;
  for(ll i=0;i<=a;i++){
    for(ll j=0;j<=b;j++){
      for(ll k=0;k<=c;k++){
        if((i*500+j*100+k*50)==x){
          count++;
          }
        }
      }
    }
  cout<<count<<endl;
  }

Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int r, d, x;
   cin >> r >> d >> x;

   int next = x;
   for (int i = 1; i <= 10; i++) {
      next = r * next - d;
      cout << next << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define N 110
int n,p[N],deep[N][N],d[N],a[N],degree[N],mx=N,t=0;
long long ans=1;
struct data{int to,nxt;
}edge[N<<1];
void addedge(int x,int y){t++;edge[t].to=y,edge[t].nxt=p[x],p[x]=t;}
void dfs(int k,int from,int root)
{
	for (int i=p[k];i;i=edge[i].nxt)
	if (edge[i].to!=from)
	{
		deep[root][edge[i].to]=deep[root][k]+1;
		dfs(edge[i].to,k,root);
	}
}
void make(int k)
{
	for (int i=p[k];i;i=edge[i].nxt)
	if (d[edge[i].to]>d[k]) degree[k]++,make(edge[i].to);
}
int main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y),addedge(y,x);
	}
	for (int i=1;i<=n;i++)
	{
		deep[i][i]=1;
		dfs(i,i,i);
		for (int j=1;j<=n;j++) deep[i][0]=max(deep[i][0],deep[i][j]);
		mx=min(mx,deep[i][0]);
	}
	t=0;
	for (int i=1;i<=n;i++) if (deep[i][0]==mx) a[++t]=i;
	if (t==1) 
	{
		cout<<mx<<' ';long long ans1=1;
		for (int i=1;i<=n;i++) d[i]=deep[a[1]][i];
		make(a[1]);
		for (int i=mx-1;i;i--)
		{
			int m=0;
			for (int j=1;j<=n;j++) if (d[j]==i) m=max(m,degree[j]);
			ans1*=m;
		}
		for (int l=p[a[1]];l;l=edge[l].nxt)
		{
			a[2]=edge[l].to;
			memset(degree,0,sizeof(degree));
			ans=1;
			for (int i=1;i<=n;i++) d[i]=min(deep[a[1]][i],deep[a[2]][i]);
			make(a[1]);make(a[2]);
			for (int i=mx-1;i;i--)
			{
				int m=0;
				for (int j=1;j<=n;j++) if (d[j]==i) m=max(m,degree[j]);
				ans*=m;
			}
			ans1=min(ans1,(ans<<1));
		}
		cout<<ans1;
	}
	else 
	{
		mx--;
		cout<<mx<<' ';
		for (int i=1;i<=n;i++) d[i]=min(deep[a[1]][i],deep[a[2]][i]);
		make(a[1]);make(a[2]);
		for (int i=mx-1;i;i--)
		{
			int m=0;
			for (int j=1;j<=n;j++) if (d[j]==i) m=max(m,degree[j]);
			ans*=m;
		}
		cout<<(ans<<1);
	}
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int cnt[1010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(i, 2, N) {
        int tmp = i;
        int j = 2;
        while(tmp > 1) {
            while (tmp > 1 && tmp % j == 0) {
                cnt[j]++;
                tmp /= j;
            }
            j++;
        }
    }
    int sum = 1;
    REP(i, 2, N) sum = (sum * (cnt[i] + 1)) % mod;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main {
  def countSearchText(s: String, n: Int = 0): Int = {
    val inputText = readLine()

    if (inputText == "END_OF_TEXT") n
    else {
      val inputTextToLower = inputText.diff("\n").split(" ").map(_.toLowerCase)
      val findTextNum = (for (i <- inputTextToLower if i == s) yield i).length
      countSearchText(s, n + findTextNum)
    }
  }

  def main(args: Array[String]) {
    val searchText = readLine()
    println(countSearchText(searchText))
  }
}

Measured memory_bytes: 43908
#include <stdio.h>
int main(){
    int a,b;
    char t;
    for(;;){
        scanf("%d %c %d",&a,&t,&b);
        if(t=='?') break;
        if(t=='+') a+=b;
        if(t=='-') a-=b;
        if(t=='*') a*=b;
        if(t=='/') a/=b;
        printf("%d\n",a);
    }
    return 0;
}

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

using namespace std;

bool solve(int H, int W, const vector<string> &A)
{
	int n = 0;
	for (auto &s : A) {
		for (auto c : s) {
			if (c == '#') {
				++n;
			}
		}
	}
	int x = 0, y = 0;
	int m = 1;
	if (A[y][x] != '#') {
		return false;
	}
	while (x + 1 < W || y + 1 < H) {
		if (x + 1 < W && A[y][x + 1] == '#') {
			++x;
			++m;
		}
		else if (y + 1 < H && A[y + 1][x] == '#') {
			++y;
			++m;
		}
		else {
			return false;
		}
	}
	return n == m;
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> A(H);
	for (auto &s : A) {
		cin >> s;
	}
	if (solve(H, W, A)) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,k;
LL a[N],l[N],r[N],s[N],ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)l[i]=l[i-1]+a[i];
	for(int i=n;i>=1;i--)r[i]=r[i+1]+a[i];
	for(int i=1;i<=n&&i<=k;i++){
		int cnt=0;
		for(int k=1;k<=i;k++)s[++cnt]=a[k];
		sort(s+1,s+1+cnt);
		int res=k-i;
		LL pa=0;
		int mid=0;
		// for(int i=1;i<=cnt;i++)cout<<s[i]<<' ';cout<<endl;
		for(int i=1;i<=cnt;i++){
			if(s[i]<0&&mid<res){
				mid++;
			}else{
				pa+=s[i];
			}
		}
		ans=max(ans,pa);		
		for(int j=n;j>i;j--){
			if(n-j+1+i>k)break;
			int cnt=0;
			for(int k=1;k<=i;k++)s[++cnt]=a[k];
			for(int k=n;k>=j;k--)s[++cnt]=a[k];
			sort(s+1,s+1+cnt);
			// for(int i=1;i<=cnt;i++)cout<<s[i]<<' ';cout<<endl;
			int res=k-(n-j+1+i);
			LL pa=0;
			int mid=0;
			for(int i=1;i<=cnt;i++){
				if(s[i]<0&&mid<res){
					mid++;
				}else{
					pa+=s[i];
				}
			}
			ans=max(ans,pa);
		}
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

void solve(long long N, long long K, long long C, std::string S){
  vector<Int> dp(N, -1);
  function<Int(Int)> sol = [&](Int i){
    if(i >= N) return 0LL;
    if(dp[i] != -1) return dp[i];
    Int res = sol(i+1);
    if(S[i] != 'x') chmax(res, sol(i+C+1) + 1);
    return dp[i] = res;
  };
  vector<P> a(N+1);
  Int cur = 0;
  Int yasu = 0;
  rep(i, N){
    if(yasu) yasu--;
    if(S[i] == 'o' && !yasu){
      yasu = C + 1;
      cur++;
    }
    a[i+1] = {cur, yasu};
  }
  dump(a);
  vi ans;
  rep(i, N){
    if(S[i] == 'x') continue;
    P p = a[i];
    Int nxt = (i - 1 + p.se <= i ? i + 1 : i - 1 + p.se);
    dump(nxt);
    Int x = sol(nxt);
    if(p.fi + x < K) ans.pb(i);
  }
  dump(dp);
  rep(i, ans.size()) cout << ans[i] + 1 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  long long C;
  scanf("%lld",&C);
  std::string S;
  std::cin >> S;
  solve(N, K, C, S);
  return 0;
}


Measured memory_bytes: 20724
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;

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

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();

	int curr = -1;
	int nseries = 0;
	int ans = 0;

	for (int i = 0; i < n; i++)
	{
	    if (curr == a[i]) nseries++;
	    else
	    {
		ans += nseries / 2;
		curr = a[i];
		nseries = 1;
	    }
	}

	ans += nseries / 2;
	
	WriteLine(ans);
    }
}


Measured memory_bytes: 13268
import math

class RMQ:
    INF = 2**31 - 1
    N = 0
    def __init__(self, n_):
        self.N = 1
        RMQ.D = []
        while self.N < n_:
            self.N = 2 * self.N

        for i in range((2*self.N)-1):
             RMQ.D.append(RMQ.INF)

    def update(self, k, x):
        k += self.N-1
        RMQ.D[k] = x
        while k > 0:
            k = math.floor((k-1)/2)
            RMQ.D[k] = min(RMQ.D[(k*2)+1], RMQ.D[(k*2)+2])

    def findMin(self, a, b):
        return self.query(a, b+1, 0, 0, self.N)

    def query(self, a, b, k, l, r):
        if r <= a or b <= l:
            return RMQ.INF
        if a <= l and r <= b:
            return RMQ.D[k]

        vl = self.query(a, b, (k*2) + 1, l, (l + r)/2)
        vr = self.query(a, b, (k*2) + 2, (l + r)/2, r)
        return min(vl, vr)


if __name__ == "__main__":
    n_, q = (int(z) for z in input().split()) #n: num of sequence, q: num of query
    rmq = RMQ(n_)

    for i in range(q):
        com, x, y = (int(z) for z in input().split())

        if(com == 0):
            rmq.update(x, y)
        else:
            res = rmq.findMin(x, y)
            print(res)



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


int main(){

  int N, L;
  cin >> N >> L;

  string s[N];

  for(int i = 0; i < N; i++){
    string _s;
    cin >> _s;
    //sort(_s.begin(), _s.end());
    s[i] = _s;
  }
  sort(s, s + N);
  
  for(int i = 0; i < N; i++){
    cout << s[i];
  }
  cout << endl;
  return 0; 
}

Measured memory_bytes: 256
def f_strings_of_eternity(S, T):
    # 参考: https://atcoder.jp/contests/abc135/submissions/6579342

    # Sの方がTより長いようにする(sはSの整数倍の長さというわけではない)
    length_s = len(S)
    length_t = len(T)
    n = (length_t + ((-length_t) % length_s)) // length_s
    s = (S * (n + 1))[:length_s + length_t]
    t = T

    # 基数 base, mod MOD 上での冪乗テーブルの構成
    MOD = 10 ** 16 + 61  # 大きな素数(2**64 だとハッシュが衝突するような入力がある)
    base = 26  # 英小文字の種類数以上でないといけない？
    base_inv = pow(base, MOD - 2, MOD)
    power = [1] * (length_s + length_t)
    power_inv = [1] * (length_s + length_t)
    for n in range(1, length_s + length_t):
        power[n] = power[n - 1] * base % MOD
        power_inv[n] = power_inv[n - 1] * base_inv % MOD

    def to_rolling_hash(string):
        ret = [0] * len(string)
        for i, c in enumerate(string):
            ret[i] = (ret[i - 1] + power[i] * ord(c)) % MOD
        return ret

    hash_s = to_rolling_hash(s) + [0]
    hash_t = to_rolling_hash(t)[-1]  # 文字列全体をハッシュ関数に通した結果

    INF = float('inf')
    # [k]: 元の文字列Sについて、Sの先頭k文字目からTが一致するか
    can_start = [(hash_s[i + length_t - 1] - hash_s[i - 1]) * power_inv[i] %
                 MOD == hash_t for i in range(length_s)]
    # [k]: sの先頭k文字目から開始したとき、tが何回連続した文字列が現れるか
    num_continuation = [INF] * length_s
    queue = [(i, 0) for i, bool in enumerate(can_start) if not bool]

    while queue:
        q_new = []
        for x, d in queue:
            if num_continuation[x] == INF:
                num_continuation[x] = d
                q_new.append(((x - length_t) % length_s, d + 1))
        queue = q_new

    # 基本的に max(num_continuation) が解だが、それが無限大のときは特別扱いする
    ans = max(num_continuation)
    return ans if ans != INF else -1

S = input()
T = input()
print(f_strings_of_eternity(S, T))

Measured memory_bytes: 215852
import numpy as np


def main():
    n = int(input())
    As = [list(map(int, input().split())) for _ in range(2)]
    cumsum0 = np.cumsum(As[0])
    cumsum1 = np.cumsum(As[1])

    ans = -float('inf')
    for i in range(n):
        ans_temp = cumsum0[i] + (cumsum1[n-1] - cumsum1[i]) + As[1][i]
        ans = max(ans, ans_temp)
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int dp[1001][1001];

int main() {
    int q;
    cin >> q;
    REP(i, q) {
        string s, t;
        cin >> s >> t;
        REP(i, s.size() + 1) REP(j, t.size() + 1) dp[i][j] = 0;
        REP(i, s.size()) {
            REP(j, t.size()) {
                if (s[i] == t[j])
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
            }
        }
        cout << dp[s.size()][t.size()] << endl;
    }
    return 0;
}


Measured memory_bytes: 7084
/*
AizuOnline A0018
sorting five numbers
*/
#include <stdio.h>

int comp(int *x,int *y)
{
  return(*x < *y);
}

main()
{

  int numbers[5];
  int i;
  int flag = 0;

  for(i=0;i<5;i++)
    scanf(" %d",&numbers[i]);

  qsort(numbers,5,sizeof(int),comp);

  for(i=0;i<5;i++)
    { if(flag)
	printf(" ");
      flag = -1;
      printf("%d",numbers[i]);
    }
  printf("\n");
return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	
	int h, w;
	
	cin >> h >> w;
	
	for(int i = 0; i < h; i++){
		string str;
		cin >> str;
		int count = -1;
		for(int j = 0; j < str.size(); j++){
			if(str[j] == 'c'){
				count = 0;
			}else if(count >= 0){
				count++;
			}
			cout << count;
			if(j != str.size() - 1){
				cout << " ";
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3152
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver() ? "Yes" : "No");
        }
        static bool solver()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            if (N % 2 == 1) return false;
            for (int i = 0; i < N / 2; i++) if (S[i] != S[i + N / 2]) return false;
            return true;
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, A, B;
  cin >> N >> A >> B;

  int c = N / (A+B);
  int mod = N % (A+B);
  int ans = 0;
  ans = c*A + min(A, mod);
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    int exor = 0;
    ll ans = 0;
    for (int l = 0, r = 0; l < N; ++l) {
        int cnt = 0;
        while (r < N && !(exor & A[r])) {
            exor ^= A[r];
            cnt++;
            r++;
        }
        if (cnt) {
            ll tmp = r - l;
            ans += tmp * (tmp + 1) / 2;
            tmp -= cnt;
            ans -= tmp * (tmp + 1) / 2;
        }
        exor ^= A[l];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(){
	while(1){
		int n;
		scanf("%d", &n);
		if(n==0) break;
		
		int v = 0;
		int t,u;
		int flag = 1;
		for(int i=0;i<12;i++){
			scanf("%d%d", &t, &u);
			v += (t-u);
			//printf("%d - %d = %d \n", t,u,v);
			if(v>=n&&flag){
				printf("%d\n", i+1);
				flag = 0;
			}
		}
		if(flag) puts("NA");
	}
}

Measured memory_bytes: 0
a=[i for i in input()]
b=[i for i in input()]
c=[i for i in input()]
t=a.pop(0)
while 1:
  if t=="a":
    if len(a)==0:
      print("A")
      break
    t = a.pop(0)
  elif t=="b":
    if len(b)==0:
      print("B")
      break
    t = b.pop(0)
  else:
    if len(c)==0:
      print("C")
      break
    t = c.pop(0)


Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.Array.IArray
import Data.Array.IO

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

inf = 1000000000

solve [] _ a = a
solve ([a,b,c]:es) arr acc = solve es arr acc'
  where
    acc' = acc + (if arr!(a,b) /= c then 1 else 0)

main = do
  [n,m] <- getInts
  dt <- newArray ((1,1),(n,n)) inf :: IO (IOArray (Int,Int) Int)
  es <- replicateM m getInts
  forM_ es $ \[a,b,c] -> do
    writeArray dt (a,b) c
    writeArray dt (b,a) c
  forM_ [1..n] $ \k -> do
    forM_ [1..n] $ \i -> do
      forM_ [1..n] $ \j -> do
        a <- readArray dt (i,k)
        b <- readArray dt (k,j)
        pv <- readArray dt (i,j)
        writeArray dt (i,j) (min pv (a+b))
  arr <- freeze dt :: IO (Array (Int,Int) Int)
  print $ solve es arr 0


Measured memory_bytes: 78204
#include<iostream>

using namespace std;

int main() {
	int a;
	cin >> a;
	for (int i = 0; i < 3; i++) {
		if (a % 10 == 7) {
			cout << "Yes\n";
			return 0;
		}
		a /= 10;
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3576
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
struct part{
LL v,num;
};
bool cmp(struct part a, struct part b)
{
    return(a.v<b.v);
}
struct part c[100010];
int n;
LL m;
int main()
{


scanf("%d%lld",&n,&m);
for (int i=1;i<=n;i++)
{
    LL v,num;
    scanf("%lld%lld",&v,&num);
    c[i].v=v;
    c[i].num=num;
}
sort(c+1,c+1+n,cmp);
LL ans=0;
for (int i=1;i<=n;i++)
{
    if (m>=c[i].num)
    {
        m-=c[i].num;
        ans+=c[i].num*c[i].v;
        if (m==0) break;
    } else
    {
        ans+=m*c[i].v;
        m=0;
        break;
    }
}
printf("%lld\n",ans);
    return(0);
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  int a[3];
  int count=3;
  int i,j;
  cin >> a[0] >> a[1] >> a[2];
  for(i=0;i<2;i++){
    for(j=1+i;j<3;j++){
      if(a[i]==a[j])count--;
    }
  }
  if(a[0]==a[1] && a[0]==a[2] && a[1]==a[2]){
    count=1;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <array>
#include <bitset>

constexpr int N = 2e5;
char S[N+1], T[N+1];
constexpr int ALPHA_SIZE = 'z' - 'a' + 1;
std::array<std::bitset<ALPHA_SIZE>, ALPHA_SIZE> L1, L2;

int main(void){
    scanf("%s%s", S, T);
    int idx = 0;
    while(S[idx] != '\n' and S[idx] != '\0'){
        int a = S[idx] - 'a';
        int b = T[idx] - 'a';
        L1[a][b] = true;
        L2[b][a] = true;
        idx++;
    }
    bool flag = true;
    for(int i = 0; i < ALPHA_SIZE; ++i){
        if(L1[i].count() > 1 or L2[i].count() > 1){ flag = false; break;}
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<deque>
#include<cstring>
using namespace std;
int n, a;
deque<int>q;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a;
        if(i&1) q.push_back(a);
        else q.push_front(a);
    }
    if(n&1) reverse(q.begin(), q.end());
    for(auto it=q.begin();it!=q.end();it++) cout<<*it <<' ';
    cout<<'\n';
    return 0;
}

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

#define ll long long
#define inf 100000000000

// ll  frog(ll *a,ll n, ll start)
// {
//     if(i==n-1)
//         return a[i];
//     else if(i>n-1)
//         return inf;
    
//     ll one = frog(a,n,start+1);
//     ll two = frog(a,n,start+2,a[start]);
    
// }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    ll n;
    cin>>n;
    ll a[n];
    std::vector<ll> v(n+1,0) ;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    
    v[n-2]=abs(a[n-1]-a[n-2]);
    
    for(ll i=n-3;i>=0;i--)
    {
        v[i]=min(v[i+1]+abs(a[i]-a[i+1]),v[i+2]+abs(a[i]-a[i+2]));
    }
    
    // for(ll i=0;i<n;i++)
    //     cout<<v[i]<<" ";
    // cout<<endl;
    cout<<v[0];
    
	return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
A,B=map(int,input().split())
S=input()
for i in range(A):
    try:
        T=int(S[i])
    except ValueError:
        print("No")
        exit()
if S[i+1]!="-":
    print("No")
    exit()

for i in range(B):
    try :
        T=int(S[A+1+i])
    except ValueError:
        print("No")
        exit()
print("Yes")

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int N=1e5+5;
vector<int> G[N];
int dp[N],deg[N];
int get(int u){
	if(dp[u]) return dp[u];
	for(auto it:G[u]){
		dp[u]=max(dp[u],get(it)+1);
	}
	return dp[u];
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	forn(i,m){
		int x,y;
		cin>>x>>y;
		deg[y]++;
		G[x].pb(y);
	}
	int ans=0;
	for1(i,n){
		if(deg[i]==0) ans=max(ans,get(i));
	}
	cout<<ans;
    return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >>S;
  int ans=0;
  if(N%2!=0){
    cout<<"No"<<endl;
  }
  else{
  for(int i=0;i<N/2;i++){
    if(S[i]==S[i+(N/2)]){
      ans+=1;
    }
    else{
      ans*=0;
      ans-=1;
      break;
    }
  }
  if(ans>0){
    cout<<"Yes"<<endl;
  }
  else if(ans<0){
    cout<<"No"<<endl;
  }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;cin>>a>>b>>c;
  int f=0;
  int s=0;
    if(a==5)f++;
    if(a==7)s++;
  
  if(b==5)f++;
    if(b==7)s++;
  
  if(c==5)f++;
    if(c==7)s++;
  if(f==2&&s==1)
    cout<<"YES";
  else
    cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;
double p[100],P[100];
template< typename G >
struct StronglyConnectedComponents {
  const G &g;
  vector<vector<int> > gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e);
        rg[(int) e].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return (comp[k]);
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector<vector<int> > &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;
    for(int i=0;i<g.size();i++)P[i]=1;
    for(int i=0;i<g.size();i++)P[comp[i]]*=p[i];
    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) continue;
        t[x].push_back(y);
      }
    }
  }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n,n)
    {
        vector<vector<int> >G(n);
        for(int i=0;i<n;i++)
        {
            cin>>p[i];
            int k;cin>>k;
            for(int j=0;j<k;j++)
            {
                int a;cin>>a;a--;
                G[i].push_back(a);
            }
        }
        StronglyConnectedComponents<vector<vector<int> > >scc(G);
        vector<vector<int> >h;
        scc.build(h);
        n=h.size();
        vector<vector<int> >H(n);
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<h[i].size();j++)
            {
                H[h[i][j]].push_back(i);
            }
        }
        double ans=1;
        for(int i=0;i<n;i++)if(H[i].size()<1)ans*=1-P[i];
        cout<<fixed<<setprecision(9)<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3440
/**
 *  author: Behradm
 *  Created: 2020.08.02 15:49:42
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n > 81) {
    cout << "No\n";
    return 0;
  }

  bool good = false;
  for (int a = 1; a <= 9; a++) {
    for (int b = 1; b <= 9; b++) {
      if (a * b == n) {
        good = true;
        break;
      }
    }
    if (good)
      break;
  }

  cout << (good ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

typedef pair<int,int> P;
const int MAX = 25;
const int INF = 1000000000;
int h,w;
int d[MAX][MAX];
int ans = 0;
char field[MAX][MAX];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int bfs(int s1,int s2,int g1,int g2){
  int sx = s1;
  int sy = s2;
  int gx = g1;
  int gy = g2;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) d[i][j]= INF;
  }
  
  queue<P> que;
  que.push(P(sx,sy));
  d[sx][sy] = 0;

  while(que.size()){
    P p = que.front();
    que.pop();
    if(p.first==gx  && p.second==gy) break;
    for(int t=0;t<4;t++){
      int nx = p.first + dx[t];
      int ny = p.second + dy[t];
      if(0<=nx && nx<h && 0<=ny && ny<w && field[nx][ny]!='#' && d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  if(d[gx][gy] < INF) return d[gx][gy];
  else return 0;
}

int main(){
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> field[i][j];
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
          if(field[i][j] == '#' || field[k][l] == '#') continue;
          ans = max(ans, bfs(i,j,k,l));
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
	int n;
	int a[200000];
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = n; i >= 1; i--) {
		int sum = 0;
		int temp = i;
		while (temp <= n) {
			sum += a[temp];
			temp += i;
		}
		if (sum % 2 != a[i]) {
			a[i]++;
			a[i] %= 2;
		}
	}
	int m = 0;
	for (int i = 1; i <= n; i++)
		if (a[i] == 1)
			m++;
	cout << m << endl;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 1)
			cout << i << " ";
	}
	cout << endl;
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  ll n,m; cin>>n>>m;
  if(n==2||m==2){
    cout<<0<<endl;
    return 0;
  }
  
  ll ans=0;
  if(n==1||m==1){
    ans=max(n,m)-2;
    if(ans<0)ans=1;
    cout<<ans<<endl;
    return 0;
  }
  
  ans=(n-2)*(m-2);
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	long long n, d, cnt = 0; cin >> n >> d;
	d *= d;
	vector<long long> x(n);
	vector<long long> y(n);
	for (int i = 0; i < n; i++) {
		cin >> x.at(i); cin >> y.at(i);
	}
	for (int i = 0; i < n; i++) {
		if (x.at(i) * x.at(i) + y.at(i) * y.at(i) <= d) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 6420