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

using namespace std;
using ll = long long;

ll solveSingleSide(vector<pair<int, ll>> yeeters) {
	int n = yeeters.size();
	for (auto &p_v : yeeters) p_v.first = min(n, p_v.first);
	vector<vector<ll>> byIntroDate(n);
	for (auto p_v : yeeters) {
		if (p_v.first == 0) continue;
		else byIntroDate[p_v.first - 1].push_back(p_v.second);
	}
	ll value = 0;
	multiset<ll> possible;
	for (int pl = n - 1; pl >= 0; --pl) {
		for (ll k : byIntroDate[pl]) possible.insert(k);
		if (!possible.empty()) {
			ll toTake = *possible.rbegin();
			possible.erase(possible.find(toTake));
			value += toTake;
		}
	}
	return value;
}

ll solve() {
	int n; scanf("%d", &n);
	vector<ll> cutoff(n), kaliwa(n), kanan(n);
	for (int i = 0; i < n; ++i) scanf("%lld %lld %lld", &cutoff[i], &kaliwa[i], &kanan[i]);
	vector<pair<int, ll>> leftBias, rightBias;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += min(kaliwa[i], kanan[i]);
		if (kaliwa[i] > kanan[i]) {
			leftBias.emplace_back(cutoff[i], kaliwa[i] - kanan[i]);
		} else {
			rightBias.emplace_back(n - cutoff[i], kanan[i] - kaliwa[i]);
		}
	}
	return ans + solveSingleSide(leftBias) + solveSingleSide(rightBias);
}

int main() {
	int t; scanf("%d", &t);
	while (t--) printf("%lld\n", solve());
	return 0;
}


Measured memory_bytes: 21812
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef unordered_map<ull,ull> ullullhmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;

struct item
{
    unsigned wt,val;
};

int main()
{
    cin.tie(0);
    vector<item> items;
    unsigned n;
    unsigned W;
    cin>>n>>W;
    items.resize(n);
    for(unsigned i=0;i<n;++i)
    {
        cin>>items[i].wt>>items[i].val;
    }
    ullvec dp(W+1,0),ndp(W+1);
    ndp[0]=0;
    for(unsigned i=0;i<n;++i)
    {
        for(unsigned j=1;j<=W;++j)
        {
            if(items[i].wt <= j)
                ndp[j]=max(items[i].val+dp[j-items[i].wt],dp[j]);
        }
        dp=ndp;
    }
    cout<<dp[W];
}

Measured memory_bytes: 1792
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int N, K;
  cin >> N;

  unordered_map<string, int> hash = { {"AC", 0}, {"WA", 0}, {"TLE", 0}, 
  {"RE", 0}};

  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    hash[s]++;
  }

  cout << "AC x " << hash["AC"] << endl;
  cout << "WA x " << hash["WA"] << endl;
  cout << "TLE x " << hash["TLE"] << endl;
  cout << "RE x " << hash["RE"] << endl;

  return 0;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

using namespace std;

int main()
{
    fast;
    ll a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b;
    else cout << b - a;
    return 0;
}


Measured memory_bytes: 256
# seishin.py
from heapq import heappush, heappop, heapify

N = int(input())
P = []
for i in range(N):
    x, y = map(int, input().split())
    P.append((x, y) if x < y else (y, x))

X = [x for x, y in P]
Y = [y for x, y in P]

MIN = min(X)
MAX = max(Y)

# R_min = MIN, B_max = MAX
res = (max(X) - MIN) * (MAX - min(Y))

# R_min = MIN, R_max = MAX
base = MAX - MIN
heapify(P)

# 出来る限りスライドさせながら(B_max - B_min)を最小化
r = max(X)
while P:
    x, y = heappop(P)
    res = min(res, base * (r - x))
    if y != -1:
        # Bに入ってたxをRに入れて代わりにyをBに入れる
        heappush(P, (y, -1))
        r = max(r, y)
    else:
        # (x, y) のyの方がB_minに該当
        # => これ以上B_minを落とせない
        break

print(res)

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

int main(){
	int n,m;
	cin >> n >> m;
	int a[n][m],b[m];
	int x=0,total=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> x;
			a[i][j] = x;
		}
	}
	x=0;
	for(int i=0;i<m;i++){
		cin >> x;
		b[i] = x;
	}
	x=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			x = a[i][j]*b[j];
			total += x;
		}
		cout << total << endl;
		total = 0;
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string N;
    int Ans=0,Sum=0;
    cin >> N;
    REP(i,N.size()){
        Ans+=N[i]-'0';
        Sum=10*Sum+N[i]-'0';
    }
    if(Sum%Ans==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const ll m = 998244353;

const ll s = 1e6 + 2;
ll a[s];

int main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();

    /* long long yaad se daal de har jagah*/
    #define int long long

    int a;
    double b;
    cin>>a>>b;
    int bb=round(b*100);
    cout<<a*bb/100<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	if(s=="Sunny")cout<< "Cloudy"<<endl;
	else if(s=="Cloudy")cout<< "Rainy"<<endl;
	else if(s=="Rainy")cout<< "Sunny"<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>


#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

mt19937 mrand(random_device{} ());
int rnd() {
	return mrand();
}

const int maxn = 1e5 + 7;

vector<int> getFactor(int x){
	vector<int> s;
	if (x < 0){
		s.push_back(-1);
		x *= -1;
	}
	for (int i = 2; i * i <= 1e8; i++){
		if (x % i == 0){
			int cnt = 0;
			while (x % i == 0){
				cnt++;
				x /= i;
			}
			if (cnt & 1)
				s.push_back(i);
		}
	}
	if (x > 1)
		s.push_back(x);
	return s;
}

vector<int> compress(vector<vector<int> > s){
	int n = s.size();
	vector<vector<int> > ss(n);
	// print(s[0]);
	for (int i = 0; i < n; i++){
		sort(s[i].begin(), s[i].end());
		for (int j : s[i])
			ss[i].push_back(j);
	}
	// print(s[0]);
	sort(ss.begin(), ss.end());
	ss.resize(unique(ss.begin(), ss.end()) - ss.begin());
	// cout << ss.size() << endl;
	vector<int> answer(n);
	for (int i = 0; i < n; i++){
		// print(s[i]);
		answer[i] = lower_bound(ss.begin(), ss.end(), s[i]) - ss.begin();
	}
	return answer;
}

int main(){
    srand(17);
 	ios_base::sync_with_stdio(0);
 	int n;
 	cin >> n;
 	vector<int> s(n);
 	for (int i = 0; i < n; i++)
 		cin >> s[i];
 	vector<int> lst(n);
 	vector<int> answer;
 	for (int i = n; i > 0; i--){
 		int cnt = 0;
 		int cur = i - 1;
 		while (cur < n){
 			cnt += lst[cur];
 			cur += i;
 		}
 		lst[i - 1] = ((cnt & 1) == s[i - 1] ? 0 : 1);
 		if (lst[i - 1] == 1)
 			answer.push_back(i);
 	}
 	cout << answer.size() << endl;
 	print(answer);
    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;

    ll p[n], q[n];
    rep(i, n){
        cin >> p[i];
    }
    rep(i, n){
        cin >> q[i];
    }

    ll a[n];
    rep(i, n){
        a[i] = i+1;
    }

    ll aa, bb;
    ll i = 1;

    do{
       if(equal(a, a+n, p)){
           aa = i;
       }
       if(equal(a, a+n, q)){
           bb = i;
       }
       i++;
    }while(next_permutation(a, a+n));

    cout << abs(aa - bb) << endl;

    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
const int maxn = 105;

int h[maxn];
int a[maxn], tot;
int id[maxn];
const int mod = 1e9 + 7;

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

int dp[maxn][maxn];

int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}

int power2(int l, int r){
    int ret = (qpow(2, r + 1) - qpow(2, l) + mod) % mod;
    return ret;
}

int solve(vector<int> heights){
    if(heights.size() == 0){
        return 1;
    }
    memset(dp, 0, sizeof(dp));
    int h1 = a[heights[0]];
    dp[1][0] = 2;
    dp[1][1] = power2(h1 - a[1] + 1, h1 - 1);
    for(int i = 2;i <= heights[0];i++){
        dp[1][i] = power2(h1 - a[i] + 1, h1 - a[i - 1]);
    }
    int sz = heights.size();
    for(int i = 1;i < sz;i++){
        for(int j = 1;j <= heights[i - 1];j++){
            if(heights[i] >= j){
                int sum = max(0, a[heights[i]] - a[heights[i - 1]]);
                sum = qpow(2, sum);
                add(dp[i + 1][j], 1LL * dp[i][j] * sum % mod);
            }else{
                add(dp[i + 1][0], dp[i][j] * 2 % mod); 
            }
        }
        if(heights[i] <= heights[i - 1]){
            add(dp[i + 1][0], dp[i][0] * 2 % mod);
        }else{
            h1 = a[heights[i]];
            for(int j = heights[i - 1] + 1;j <= heights[i];j++){
                int sum = power2(h1 - a[j] + 1, h1 - a[j - 1]);
                add(dp[i + 1][j], 1LL * dp[i][0] * sum % mod);
            }
            add(dp[i + 1][0], dp[i][0] * 2 % mod);
        }
    }
    //for(int i = 1;i <= sz;i++){
    //    for(int j = 0;j <= heights[i - 1];j++){
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    int ans = 0;
    for(int j = 0;j <= heights[sz - 1];j++){
        add(ans, dp[sz][j]);
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    tot = 0;
    for(int i = 1;i <= n;i++){
        cin >> h[i];
        if(h[i] > 1)
            a[++tot] = h[i];
    }
    sort(a + 1, a + 1 + tot);
    tot = unique(a + 1, a + 1 + tot) - a - 1;
    for(int i = 1;i <= n;i++){
        if(h[i] == 1)
            continue;
        id[i] = lower_bound(a + 1, a + 1 + tot, h[i]) - a;
    }
    vector<int> his;
    int ans = 1;
    for(int i = 1;i <= n;i++){
        if(h[i] == 1){
            ans = ans * 2 % mod;
            ans = 1LL * ans * solve(his) % mod;
            his.clear();
        }else{
            his.push_back(id[i]);
        }
    }
    if(!his.empty()){
        ans = 1LL * ans * solve(his) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import *
s = input()
g = [[k,len(list(v))] for k,v in groupby(s)]
ans = 0
for command,length in g:
    ans += length*(length+1)//2
for i in range(len(g)-1):
    if g[i][0] == "<":
        ans -= min(g[i][1],g[i+1][1])
print(ans)

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

using namespace std;

int main(){
  int n;
  cin >> n;
  int nowt=0, nowx=0, nowy=0;
  bool failed = false;
  for(int i=0;i<n;i++){
    int t, a, b;
    cin >> t >> a >> b;
    int time_diff = t - nowt;
    int dist_diff = abs(a-nowx) + abs(b - nowy);
    int ch = time_diff - dist_diff;
    if(ch < 0 || ch % 2){
      cout << "No" << endl;
      failed = true;
      break;
    }
    nowt = t;
    nowx = a;
    nowy = b;
  }
  cout << (!failed?"Yes":"") << endl;
  return 0;
}

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

D=[]
Asum=0
Bsum=0
Dnegative=0
Dnegative_n=0
Dsum=0
for i in range(N):
  D.append(A[i]-B[i])
  Asum += A[i]
  Bsum += B[i]
  if A[i]-B[i]<0:
    Dnegative += A[i]-B[i]
    Dnegative_n += 1
if Asum < Bsum:
  print(-1)
  exit()

if Dnegative_n==0:
  print(0)
  exit()
D.sort()

for i in range(N):
  Dsum -= D[N-i-1]
  if Dsum <= Dnegative:
    print(Dnegative_n+i+1)
    exit()

Measured memory_bytes: 18524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (auto &e : h)
    cin >> e;
  int ans = 0;
  while (true)
  {
    bool flag = true;
    int itr = -10;
    for (int i = 0; i < n; ++i)
    {
      if (h[i])
      {
        h[i]--;
        flag = false;
        itr = i;
      }
      else if (h[i] == 0 && i > 0 && itr == i - 1)
      {
        ans++;
      }
    }
    if (flag)
      break;
    if (itr == n - 1)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(), a.end());
  cout<<a[n-1]-a[0]<<endl;
}
    
  

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,H,W; cin>>N>>H>>W;
    cout<<(N-H+1)*(N-W+1)<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << (b+a-3)/(a-1) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

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

    int ans = 0;
    sort(b, b+n, greater<int>());

    for (int i = 0; i < n; i++) {
        if (b[i] <= amax) {
            break;
        } else {
            h -= b[i];
            ans++;
            if (h <= 0) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    while (h > 0) {
        h -= amax;
        ans++;
    }

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

Measured memory_bytes: 1024
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        sen = Y - i*10000 - j*5000
        if sen >= 0 and (sen//1000+i+j) == N:
            print(i,j,sen//1000)
            exit()

print(-1,-1,-1) 

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdio>
#define LL long long

using namespace std;

LL n;

struct matric
{
    LL a[2][2];

};

int main()
{
    cin >> n;
    if (n%2==1)
    {
        printf("0\n");
        return 0;
    }
    LL c1=0,c2=0,tmp=n/2;
    while (tmp)
    {
        c1+=tmp/5;
        tmp/=5;
    }
    cout <<c1;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

#define N 3
#define N2 9

struct Puzzle {
	int f[N2];
	int space;
	string path;
	bool operator <(const Puzzle &p) const {
		for (int i = 0; i < N2; ++i) {
			if (f[i] != p.f[i]) {
				return f[i] < p.f[i];
			}
		}
		return false;
	}
};
bool isComplete(Puzzle p) {
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] != i + 1)
			return false;
	}
	return true;
}

const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };
string bfs(Puzzle p) {
	p.path = "";
	map<Puzzle, bool> M;
	M[p] = true;
	Puzzle u, v;
	queue<Puzzle> Q;
	Q.push(p);
	for (int i = 0; i < N2; ++i) {
		while (!Q.empty()) {
			u = Q.front();
			Q.pop();
			if (isComplete(u))
				return u.path;
			int sx = u.space / N;
			int sy = u.space % N;
			for (int r = 0; r < 4; ++r) {
				int tx = sx + dx[r];
				int ty = sy + dy[r];
				if (tx < 0 || ty < 0 || tx >= N || ty >= N)
					continue;
				v = u;
				swap(v.f[u.space], v.f[tx * N + ty]);
				v.space = tx * N + ty;
				if (!M[v]) {
					M[v] = true;
					v.path += dir[r];
					Q.push(v);
				}
			}
		}
	}
	return "unresolved";
}

int main() {

	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}
	string ans = bfs(p);
	cout << ans.size() << endl;

	return 0;
}

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

int main() {
	string s;
	cin >> s;
	vector<int> a(2);
	for (int i = 0; i < (int) s.size(); i++) {
		a[s[i] - 48]++;
	}
	cout << min(a[0], a[1]) * 2 << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <map>
using namespace std;
map <int,bool> ds;
int sum=0,tmp;
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        if(!ds[tmp]){ds[tmp]=1;sum++;}
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 256
S_prime = input()
T = input()

lenS = len(S_prime)
lenT = len(T)

for i in range(lenS-lenT,-1,-1):
    m = 0
    for j in range(lenT):
        if T[j] != S_prime[i+j] and S_prime[i+j] != "?":
            break
        m += 1
    if m == lenT:
        S_ans = S_prime[:i] + T + S_prime[i+lenT:]
        S_ans = S_ans.replace("?","a")
        print(S_ans)
        exit()
print("UNRESTORABLE")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll n,k;cin>>n>>k;
    ll arr[n+1];
    ll ans[n+2];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    bool check = 1;
    for(int i=0;i<k;i++){
        if(!check){
            break;
        }
        for(int i=0;i<=n+1;i++){
            ans[i]=0;
        }
        for(int i=1;i<=n;i++){
            ans[max(i-arr[i],1ll)]++;
            ans[min(n+1,i+arr[i]+1)]--;
        }
        arr[0]=0;
        for(int i=1;i<=n;i++){
            arr[i]=arr[i-1]+ans[i];
        }
        check = 0;
        for(int i=1;i<=n;i++){
            if(arr[i]!=n){
                check=1;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<arr[i+1]<<" ";
    }
    cout<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 6740
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

struct Node{
    int color;
    vector< pair<int, int> > child;
    bool done;
};

Node node[100009];

void paint(int nd, int weight){
    node[nd].done = true;
    node[nd].color = weight;
    rep(i, node[nd].child.size()){
        if(node[node[nd].child[i].first].done == false){
            paint(node[nd].child[i].first, (node[nd].child[i].second+weight)%2);
            //cout << weight << "#" <<endl;
        }
    }
}

int main(void){
    int N;
    cin >>N;
    int u, v, w;
    rep(i, N-1){
        cin >> u >>v >>w;
        node[u-1].child.push_back({v-1, w});
        node[v-1].child.push_back({u-1, w});
    }
    rep(i, N) node[i].done = false;
    node[0].color = 0;
    paint(0, 0);
    rep(i, N){
        cout << node[i].color<<endl;
    }
    return 0;
}




Measured memory_bytes: 9600
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    immutable int[2][][4] w =
    [
        [[0,0]],
        [[1,0],[-1,0],[0,1],[0,-1]],
        [[1,1],[1,-1],[-1,1],[-1,-1]],
        [[2,0],[-2,0],[0,2],[0,-2]],
    ];
    immutable N=10;
    int[N][N] p;
    foreach(s;stdin.byLine())
    {
        auto m = s.split(",").map!(to!int);
        immutable x=m[0], y=m[1];
        foreach(i;0..m[2]+1)
            foreach(a; w[i])
            {
                immutable wx=x+a[0], wy=y+a[1];
                if(0<=wx && wx<N && 0<=wy && wy<N)
                    ++p[wx][wy];
            }
    }
    int z=0,m=0;
    foreach(a;p)
        foreach(v;a)
            if(v==0) ++z;
            else m=max(m,v);
    writeln(z);
    writeln(m);
}

Measured memory_bytes: 1084
/*input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
*/

#include <bits/stdc++.h>
using namespace std;
 
typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pt;
typedef pair<int, ii> iii;
typedef vector<int> vi;
 
#define FOR(i, l, r) for(int i = l; i <= r; ++i)
#define FORD(i, l, r) for(int i = l; i >= r; --i)
#define REP(i, r) for(int i = 0; i < int(r); ++i)
#define REPD(i, r) for(int i = int(r)-1; i >= 0; --i)
#define fi first
#define se second
#define x first
#define y second
#define sz size
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mk make_pair
 
const int Nmax = 2e6 + 10;
const ll inf = 1e9;
const db _eps = 1e-15;

set <int> a[Nmax];
int traveled[Nmax];
int n, m;

void bfs() {
	queue <int> qu;
	traveled[1] = -1;
	qu.push(1);
	while (!qu.empty()) {
		int u = qu.front(); qu.pop();
		for (auto v : a[u]) {
			if (traveled[v]) continue;
			traveled[v] = u;
			qu.push(v);
		}
	}
}	

int main() {
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		a[v].insert(u);
		a[u].insert(v);
	}
	bfs();
	for (int i = 1; i <= n; ++i) {
		if (traveled[i] == false) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 2; i <= n; ++i) {
		cout << traveled[i] << endl;
	}

}

Measured memory_bytes: 116620
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
     lint n;
     cin>>n;
     lint x=7;
     if(n==1||n==7){
         cout<<1<<endl;
         return 0;
     }
     repp(i,1,1000000){
         if(x==0){
             cout<<i<<endl;
             return 0;
         }
         x*=10;
         x+=7;
         x%=n;
     }
     cout<<-1<<endl;
     }

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    ll n; cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string tmp; cin >> tmp;
        mp[tmp]++;
    }

    cout << "AC x " << mp["AC"] << endl;;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

/*
vector<ll> A(200010);
vector<ll> LS(200010,0);
vector<ll> RS(200010,0);
ll N;
ll dfs(ll i, ll sum , ll aff){
    if(aff > 0){
        return max(dfs(i+2, (sum+A[i]), aff), dfs(i+1, sum, (aff-1)));
    }else{
        if(i % 2 == 0){
            return sum + max(LS[N+1], LS[N])- LS[i+2] + A[i];
        }else{
            return sum + max(RS[N+1] ,RS[N]) - RS[i+2] + A[i];
        }
    }
}*/


int main(){
    ll N;
    string S;
    cin >> N;
    //ll LS=0;
    //ll RS=0;
    vector<ll> A(N);
    vector<vector<ll>> DP(N+1,vector<ll>(4,-1e18));
    rep(i,N){
        cin >> A[i];
    }
    ll K = 1 + (N%2);
    DP[0][0] = 0;
    rep(i,N){
        rep(j,K+1){
            cmax(DP[i+1][j+1], DP[i][j]);
            ll now = DP[i][j];
            if((i+j) % 2 == 0) now += A[i];
            cmax(DP[i+1][j], now); 
        }
    }
    cout << DP[N][K] << endl;
    /*
    ll sum = 0;
    rep(i,N){
        if(i%2 == 0){
            LS[i+2] += LS[i] + A[i];
        }else{
            RS[i+2] += RS[i] + A[i];
        }
    }
    cout << 1111 << endl;
    ll ans = 0;
    if(N % 2 == 0){
        ans = dfs(0,0,1);
    }else{
        ans = dfs(0,0,2);
    }
    cout << ans <<endl;
    */
}

Measured memory_bytes: 18824
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int k;
    int result = 0;
    cin >> n >> k;
    int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0;i < k;i++)
    {

        result = result + a[i];
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a+b==3)System.out.println("3");
        if(a+b==4)System.out.println("2");
        if(a+b==5)System.out.println("1");
    }
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (ll i=0; i<N; i++) {
        cin >> H[i];
    }
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());
    if (N<=K) {
        cout << 0 << endl;
        exit(0);
    }
    for (ll i=0; i<K; i++) {
        H[i] = 0;
    }
    ll ans = 0;
    for (ll i=0; i<N; i++) {
        ans += H[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5068
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto k = readln.chomp.to!int;
  auto x = readln.chomp.split.to!(int[]);
  int res;
  foreach (e; x) {
    auto a = k - e;
    res += min(a, e) * 2;
  }
  res.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type xyz struct {
	x int
	y int
	z int
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	Y := nextInt()
	//N := 9
	//Y := 45000
	slice := []xyz{}

	for i := 0; i < N+1; i++ {
		x := N - i
		for j := 0; j < x+1; j++ {
			z := N - i - j
			if 10000*i+5000*j+1000*z == Y {
				slice = append(slice, xyz{
					x: i,
					y: j,
					z: z,
				})
				break
			}

		}
	}

	if len(slice) == 0 {
		fmt.Printf("-1 -1 -1")
	} else {
		x := slice[0].x
		y := slice[0].y
		z := slice[0].z

		fmt.Printf("%d %d %d", x, y, z)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//const ll MOD=1e9+7;
const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<55);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll N; cin>>N;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    sort(ALL(A));
    ll ans=1;
    ll M=1e18;
    if(A[0]==0){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,N){
        if(M/A[i]<ans){
            cout<<-1<<endl;
            return 0;
        }
        ans*=A[i];
    }
    if(ans>M) ans=-1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3964
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
os << P.first;
os << " ";
os << P.second;
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q;
    cin >> N;
    int a;
    map<int,int> M;
    REP(i,N){
        cin >> a;
        M[a]++;
    }

    int ans=0;
    cin >> Q;
    REP(i,Q){
        cin >> a;
        ans += (M[a]>=1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n,t; cin>>n>>t;
    vector<ll> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    v.push_back(1e10);
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=min(1LL*t,v[i]-v[i-1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
using namespace std;
int main(void){
    char ch;
    int a[26]={0};
    while(cin >> ch){
        if(ch>='A'&&ch<='Z'){
            ch+=32;
        }
        if(ch>='a'&&ch<='z'){
            a[ch-'a']+=1;
        }
    }
    for(int i=0;i<26;i++){
        cout << char(i+'a') << " : " << a[i] << endl;;
    }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long

using namespace std;

signed main()
{
    int x,y;
    cin >>x>>y;
    if (x<y)cout << 0 << endl;
    else cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define base 37
int n;
string s;
#define MAXN (int)(5e3+233)
unsigned long long h[MAXN];
unsigned long long power[MAXN];
unsigned long long lstans;
#define gethash(l,r) (h[r]-h[l-1]*power[r-l+1])
int main()
{
	scanf("%d",&n);
	cin>>s;
	power[0]=1;
	for (int i=0;i<n;i++) h[i+1]=h[i]*base+s[i],power[i+1]=power[i]*base;
		 // for (int i=1;i<=n;i++) printf(":%lld ",h[i]);
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			if (i+ans<=j)
				while (i+ans<j&&j+ans<=n&&gethash(i,i+ans)==gethash(j,j+ans)) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int p, a[3000];
vector<int> mul(vector<int> u, vector<int> v){
    vector<int> res;
    res.resize(u.size()+v.size()-1);

    for(int i=0;i<v.size();i++){
        int val = v[i];
        for(int j=0;j<u.size();j++){
            int val2 = u[j];
            res[i+j] = (res[i+j] + val*val2)%p;
        }
    }

    return res;
}

vector<int> div(vector<int> u, vector<int> v){
    vector<int> res;
    for(int i=u.size()-1;i>=1;i--){
        int d = u[i];
        res.push_back(d);
        u[i-1] = (u[i-1] - v[0]*d%p + p)%p;
    }
    reverse(res.begin(), res.end());
    return res;
}

int pw(int a, int b){
    int res = 1;
    while(b){
        if(b%2 == 1) res = res*a%p;
        a = a*a%p;
        b/=2;
    }
    return res;
}

int main(){
    scanf("%d", &p);
    for(int i=0;i<p;i++) scanf("%d", &a[i]);

    vector<int> u, v;
    u.push_back(0);
    u.push_back(1);
    for(int i=1;i<p;i++){
        v.clear();
        v.push_back(p-i);
        v.push_back(1);
        u = mul(u, v);
    }

    vector<int> res;
    res.resize(p);
    for(int i=0;i<p;i++){
        if(a[i] == 1){
            vector<int> v;
            v.push_back(p-i);
            v.push_back(i);
            vector<int> tmp = div(u, v);
            int val = 0, sum = 1;
            for(int j=0;j<tmp.size();j++){
                val = (val + tmp[j]*sum)%p;
                sum = sum*i%p;
            }
            val = pw(val, p-2);
            for(int j=0;j<tmp.size();j++){
                res[j] = (res[j] + tmp[j]*val)%p;
            }
        }
    }
    for(int i=0;i<res.size();i++) printf("%d ", res[i]);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map<int, int> mp;
	for (int i = 1; i <= n; ++i) {
		int x = i;
		for (int j = 2; j * j <= x; ++j) {
			while (x % j == 0) {
				x /= j;
				mp[j]++;
			}
		}
		if (x != 1) mp[x]++;
	}
	mint ans = 1;
	for (auto& c : mp) {
		ans *= (c.second + 1);
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

/*ifstream fin ("contest.in");
ofstream fout ("contest.out");*/

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


Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = a*b;
        if(c%2<1)
        {
            System.out.println("Even");
        }
        else
        {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
#define fi first
#define sf scanf
#define se second
#define pf printf
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset((x),(y),sizeof(x))
#define fup(i,x,y) for(int i=(x);i<=(y);++i)
#define fdn(i,x,y) for(int i=(x);i>=(y);--i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
using namespace std;

const int __=2e5+5;

char s[__];

int main()
{
    sf("%s",s+1);
    int n=strlen(s+1);
    ll ans=0;
    int w=0;
    fup(i,1,n)
        if(s[i]=='W')
            ans+=i-(++w);
    pf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,k;
    cin>>n>>k;
    double a[n];
    rep(0,i,n){
        ll p;
        cin>>p;
        a[i]=(1.*p-1.)/2.+1.;
        //cout<<a[i]<<endl;
    }
    double sum=0;
    double ans=0;
    rep(0,i,k)sum+=a[i];
    rep(0,i,n-k+1){
        //cout<<sum<<endl;
        ans=max(sum,ans);
        sum-=a[i];
        sum+=a[i+k];
    }
    cout<< fixed << setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strconv"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var S string
	fmt.Scanf("%s\n", &S)
	RS := []rune(S)
	Reverse(RS)

	dp := [100010][14]int{}
	pow := 1
	for i := 0; i < len(RS); i++ {
		r := RS[i]
		if i == 0 {
			if string(r) == "?" {
				for j := 0; j < 10; j++ {
					value := j
					dp[i][value] += 1
					dp[i][(value*pow)%13] %= MOD

				}
			} else {
				value, _ := strconv.Atoi(string(r))
				dp[i][value*pow] += 1
				dp[i][(value*pow)%13] %= MOD

			}
		} else {
			if string(r) == "?" {
				for j := 0; j < 10; j++ {
					for k := 0; k < 13; k++ {
						value := j
						dp[i][(k+value*pow)%13] += dp[i-1][k]
						dp[i][(k+value*pow)%13] %= MOD
					}
				}
			} else {
				for k := 0; k < 13; k++ {
					value, _ := strconv.Atoi(string(r))
					dp[i][(k+value*pow)%13] += dp[i-1][k]
					dp[i][(k+value*pow)%13] %= MOD
				}
			}
		}

		pow = pow * 10 % 13
	}
	fmt.Println(dp[len(RS)-1][5])
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


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


int main(){
	int n,s[12],c[12],m;
	while(cin>>n,n){
		m=0;
		for(int i=0;i<n;i++)cin>>s[i];
		while(1){
			for(int i=0;i<n;i++){
				c[i]=count(s,s+n,s[i]);
			}
			if(equal(s,s+n,c))break;
			copy(c,c+n,s);
			m++;			
		}
		cout<<m<<'\n'<<s[0];
		for(int i=1;i<n;i++)cout<<' '<<s[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
	int i,j,a[10],pwd;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				pwd=a[j];
				a[j]=a[i];
				a[i]=pwd;
			}
		}
	}
	printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
	return 0;
}

Measured memory_bytes: 600
S = str(input())

S1 = S[0:2]
S2 = S[2:4]

if 1 <= int(S1) <= 12:
    if 1 <= int(S2) <= 12:
        print('AMBIGUOUS')
        exit()
    else:
        print('MMYY')
        exit()

if 1 <= int(S2) <= 12:
    if 1 <= int(S1) <= 12:
        print('AMBIGUOUS')
        exit()
    else:
        print('YYMM')
        exit()

print('NA')

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

int main(void) {

  int S;
  cin >> S;
  int h = floor(S/60/60);
  int m = floor(S/60) - h*60;
  int s = S - h*60*60 - m*60;
  cout << h << ":" << m << ":" << s <<endl;
}



Measured memory_bytes: 3100