akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#define MAX (1LL<<60)
#define int long long
using namespace std;
int n;
int arr[405];
int pre[405];

int solve(){
	
	int dp[405][405]; //dp i,j stores min cost incurred to add i to j matrices

	for(int i=1;i<=n;i++)
		dp[i][i]=0;


	for(int l=2;l<=n;l++){
		for(int i=1;i<=n-l+1;i++){
			int j = i + l -1 ;
			//cout<<i<<" "<<j<<endl;
			dp[i][j] = MAX;
			for(int k=i;k<j;k++){
				//cout<<"dp[i][k] "<<dp[i][k]<<" dp[k+1][j] "<<dp[k+1][j]<<"    "<<pre[j] - pre[i-1]<<endl;
				dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + pre[j] - pre[i-1]);
				//cout<<dp[i][j]<<endl;
			}

		}

	}

	


return dp[1][n];

}


int32_t main(){
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
	
	cin>>n;
	memset(pre,0,sizeof pre);
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	for(int i=1;i<=n;i++){
		
		pre[i] = pre[i-1] +arr[i];
	}

	cout<<solve()<<endl;







/*

1,1 2,4  100    0 140  240
1,2 3,4  100    30 70 200
1,3 4,4  100	90 0  190






*/










}

Measured memory_bytes: 4836
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>
using namespace std;
int n, m;
char mp[55][55];
int dr[4][2] = {0,1,0,-1,-1,0,1,0};
int flag = 1;
bool dfs(int x, int y) 
{
	for(int i = 0; i < 4; i++) {
		int xx = x + dr[i][0];
		int yy = y + dr[i][1];
		if(mp[xx][yy] == '#') return true;
	}
	return false;
}

int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++) 
		scanf("%s", &mp[i]);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(mp[i][j] == '#') {
				if(!dfs(i, j)) {
					flag = 0;
					break;
				}
			}
		}
	}
	if(flag == 0) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 256
/* author ::  ubc_123 */
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
// using namespace boost::multiprecision; //cpp_int a;

#define find_bug(x) cout <<'>' << #x << " : " << x << endl;
#define ff first
#define ss second
#define pf push_front
#define pb push_back
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define pu push
#define in insert
typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll MOD = 1e9+7;
const ll SMOD = 998244353;
const ll N_MAX = 100100;
const ll INF = 1e18;
const ld PI = ld(3.1415926535897932384626433832795);
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rfr(i,n) for(ll i=(n-1);i>=0;i--)
#define frs(i,s,n) for(ll i=s;i<(n);++i)
#define frb(i,s,e) for(ll i=s;i<=(e);++i)
#define frbr(i,e,s) for(ll i=e;i>=(s);i--)
#define mset(m,v) memset(m,v,sizeof(m))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
//-------------------------------------------------------------------------------
void solve()
{
  ll n;
  cin>>n;
  cout<<n*n<<endl;
}

signed main()
{  
    // #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    ll test = 1;
    // cin>>test;
    fr(i,test)
    {
      // cout << "Case #" << i + 1 << ": ";
      // cout << '>' << "Case #" << i+1 << endl;
      solve();
    }
    return 0;
}           



Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{};
	cin>>n;
	vector<int>v(n+1);
	For(i,1,n+1)cin>>v[i];
	ll res{},ans=inf;
	For(i,1,101)
	{
		res=0;
		For(j,1,n+1)
		{
			res+=(v[j]-i)*(v[j]-i);
		}
		ans=min(ans,res);
	}
	cout<<ans<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };



int main() {
	int a,b;
	scanf("%d%d", &a,&b);

	printf("%d", (b - a + 1) *(b-a) / 2 - b);



}





/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    a=min(a,2*c);
    b=min(b,2*c);
    c=min(2*c,a+b);
    if(x<y){
        cout<<x*c+(y-x)*b<<endl;
    }
    else{
        cout<<(x-y)*a+y*c<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
import           Data.List
main=getContents>>=print.solve.tail.map read.words
solve xs
  | mod s 10 > 0 = s
  | (r:_) <- sort rs = s - r
  | otherwise = 0
  where
    s = sum xs
    rs = [ x |x<-xs, mod x 10 > 0]

Measured memory_bytes: 892
#include<cstdio>
#include<cstring>
int main(){
    char ar[102];
    while(scanf("%s\n",ar)!=-1){
        int i=0;
        while(i<strlen(ar)){
            if(ar[i]=='@'){
                for(int j=0;j<ar[i+1]-'0';j++){
                    printf("%c",ar[i+2]);
                }
                i+=3;
            }else{
                printf("%c",ar[i]);
                i++;
            }
        }
        printf("\n");
    }
}

Measured memory_bytes: 0
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using ll = long long ;
using namespace std;
const ll maxn=1e5+5;
ll n,m,sum,a;
int main(){
	ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0);
	cin>>n>>m;
	while(m--){
		cin>>a;
		sum+=a;
	}
	if(sum>n){
		cout<<-1;
	}
	else{
		cout<<n-sum;
	}
}



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

const ll INF = 1e13;

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<vector<ll>> s(N);
	for (int i = 0; i < N; i++)
	{
		ll t, d;
		cin >> t >> d;
		t--;
		s[t].push_back(d);
	}

	for (auto &v : s)
	{
		sort(v.begin(), v.end(), greater<ll>());
		if (v.empty())
			v.push_back(-INF);
	}

	sort(s.begin(), s.end(), [](vector<ll> a, vector<ll> b) { return a[0] > b[0]; });

	// まずK種類選ぶ
	ll cur = 0;
	priority_queue<ll> pq;

	for (int i = 0; i < K; i++)
	{
		cur += s[i][0];
		for (int j = 1; j < s[i].size(); j++)
			pq.push(s[i][j]);
	}
	for (int i = K; i < N; i++)
		for (int j = 0; j < s[i].size(); j++)
			pq.push(s[i][j]);

	ll ans = cur + K * K;
	for (ll x = K - 1; x >= 1; x--)
	{
		ll v = s[x][0];
		ll w = pq.top();
		if (v < w)
		{
			pq.pop();
			cur += w;
			pq.push(v);
			cur -= v;
		}
		ans = max(ans, cur + x * x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 8696
N = 10**5
prime_list = [True] * (N+1)        # True が素数
count_list = [0] * (N+1)
for i in range(2, N+1, 1):
    if prime_list[i]:
        for j in range(i+i, N+1, i):
            prime_list[j] = False

for i in range(3, N+1, 2):
    if prime_list[i] and prime_list[(i+1)//2]:
        count_list[i] += 1

for i in range(3, N+1, 1):
    count_list[i] += count_list[i-1]

Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]
for q in query:
    l, r = q
    print(count_list[r] - count_list[l-1])

Measured memory_bytes: 69464
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,y;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;
        exit(0);
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)y=1;
    cout<<((a-b)/(b-c)+y)*2+1<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
MIN = min(aa)
MAX = max(aa)
ans = INF

for i in range(MIN,MAX+1):
	tmp = 0
	for a in aa:
		tmp += (a-i)**2
	ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 4840
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  for(int i = 0; i < n; i+=2){
    if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 1; i < n; i+=2){
    if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
As = list(map(int, input().split()))

appeared = [False] * N
appeared[0] = True
path = [1]
for _ in range(N+10):
    next_A = As[path[-1] - 1]
    if appeared[next_A-1]:
        break
    else:
        path.append(next_A)
        appeared[next_A-1] = True

before_loop = path.index(next_A)
loop_len = len(path) - before_loop

if K <= before_loop:
    print(path[K])
else:
    print(path[(K - before_loop) % loop_len + before_loop])

Measured memory_bytes: 103004
#include <cstdio>

int main()
{
	int n,lim,max;
	long int sum = 0;
	scanf("%d", &n);

	int ai[n];

	for(int i = 0; i < n; i++) {
		scanf("%d", &ai[i]);

		if (i == 0) {
			lim = ai[i];
			max = ai[i];
		}

		if (ai[i] < lim)
			lim = ai[i];

		if (ai[i] > max)
			max = ai[i];

		sum += ai[i];
	}

	printf("%d %d %ld\n",lim, max, sum);
	return 0;
}


Measured memory_bytes: 2712
from collections import defaultdict
N = int(input())
S = input()
mod = 10 ** 9 + 7
d = defaultdict(int)
char = [chr(ord("a") + i) for i in range(26)]
ans = 1
for s in S:
    d[s] += 1
for v in d.values():
    ans *= v + 1
    ans %= mod
print(ans - 1)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#define vector2(t) vector<vector<t>>
#define newvec2(t,h,w,x) vector2(t)(h,vector<t>(w,x))

using namespace std;

int W, H;
vector2(bool) a;
vector2(int) memo;
vector2(bool) memoflag;

int dp(int h, int w) {
	if (memoflag[h][w])
		return memo[h][w];
	if (!a[h][w])
		return 0;
	if (h == H - 1 && w == W - 1)
		return 1;
	memoflag[h][w] = true;
	return memo[h][w] = (dp(h + 1, w) + dp(h, w + 1)) % (int)(1e+9 + 7);
}

int main(void) {
	cin >> H >> W;

	a = newvec2(bool, H + 1, W + 1, false);
	memo = newvec2(int, H + 1, W + 1, -1);
	memoflag = newvec2(bool, H + 1, W + 1, false);
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			char input;
			cin >> input;
			if (input == '.')
				a[h][w] = true;
		}
	}
	cout << dp(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 4608
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
const int N=1e5+5;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef map<ll,int>::iterator miter;
int n,p[N+5],pcnt;
bool vis[N+5];
map<ll,int> cnt,calc;
map<ll,ll> inver;
void Init(){
	for(int i=2;i<=N;i++){
		if(!vis[i]){
			p[++pcnt]=i;
			calc[1ll*i*i]=i;
		}
		for(int j=1;i*p[j]<=N;j++) {
			vis[i*p[j]]=true;
			if(i%p[j]==0) break;
		}
	}
}
int main(){
	scanf("%d",&n);
	Init();
	int ans=0;
	for(int i=1;i<=n;i++){
		ll a,tmp,h=1,inv=1;
		scanf("%lld",&a);
		tmp=a;
		for(int j=1;j<=pcnt&&1ll*p[j]*p[j]*p[j]<=a;j++) if(tmp%p[j]==0){
			int xcnt=0;
			while(tmp%p[j]==0) tmp/=p[j],xcnt++;
			xcnt%=3;
			int xxcnt=xcnt;
			while(xxcnt--) h*=p[j];
			for(int i=1;i<=(3-xcnt)%3;i++) inv*=p[j];
		}
		if(tmp>1){
			h*=tmp;
			miter it=calc.find(h);
			if(it!=calc.end()) inv*=it->second;
			else inv*=tmp*tmp;
		}
		cnt[h]++;
		inver[h]=inv;
		inver[inv]=h;
	}
    if(cnt.find(1)!=cnt.end()){
        ans++;
        cnt.erase(1);
    }
	for(miter it=cnt.begin();it!=cnt.end();it++){
		if(cnt.find(inver[it->first])==cnt.end()) ans+=it->second;
		else{
			ans+=max(it->second,cnt[inver[it->first]]);
			it->second=cnt[inver[it->first]]=0;
		}
	}	
	printf("%d\n",ans);
}

Measured memory_bytes: 19712
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> cnt(M, 0);
    REP(i, N) {
        int K;
        cin >> K;
        REP(j, K) {
            int A;
            cin >> A;
            cnt[A - 1]++;
        }
    }
    int res = 0;
    REP(i, M) {
        if (cnt[i] == N) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m,G[10][10],ans=0;
    vll v;
    cin>>n>>m;
    rep(i,10)rep(j,10) G[i][j]=0;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        G[a][b]=1;
        G[b][a]=1;
    }
    rep(i,n){
        v.pb(i+1);
    }
    do{
        if(v[0]!=1) continue;
        rep(i,n-1){
            if(G[v[i]][v[i+1]]==0) break;
            if(i==n-2) ans++;
        }
    } while(next_permutation(all(v)));
    cout<<ans<<endl;
    return 0;
}

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

import sys
ans = 1
for i in range(n):
    ans *= A[i]
    if ans > 10 ** 18:
        for j in range(i,n):
            if A[j]==0:
                print(0)
                sys.exit()
        ans=-1
        break

print(ans)

Measured memory_bytes: 21784
/*
 *
 *  1. sprawdz corner cases
 *  2. sprawdz limity, jesli sie da pozamieniaj wszystkie lokalne zmienne na LL!
 *  3.  MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE
 *  4. lokalne zmienne, iteracja po tablicach dwuwymiarowych uwazaj
 *  5. SPRAWDZ CZY input jest POSORTOWANY jaki jest niezmiennik
 *
 *
 */
#include <algorithm>
#include <cstdio>
#include <iomanip> // std::setprecision
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>
#include <numeric>
#define FOR(x, y, z) for (int x = (y); x < (z); x++)
#define FORD(x, y, z) for (int x = (y); x >= z; x--)
#define REP(r, n) for (int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define ALL(u) (u).begin(), (u).end()
#define RALL(u) (u).rbegin(), (u).rend()
#define PB push_back
#define PF push_front
#define SZ(x) long long((x).size())
#define IS_IN(x, t) (t.find(x) != t.end())
#define BIT(n, i) (((n) >> (i)) & 1)

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) \
    {              \
    }
#endif

#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<LL> VI;
typedef pair<LL, LL> PR;

inline LL GCD(LL a, LL b)
{
    LL r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
};
inline LL LCM(LL a, LL b) { return a / GCD(a, b) * b; };
inline LL fpow(LL n, LL k, LL p)
{
    LL r = 1;
    for (; k; k >>= 1) {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
};
inline LL inv(LL a, LL p) { return fpow(a, p - 2, p); }

[[maybe_unused]] const LL MOD = (LL)1e9 + 7;
[[maybe_unused]] const LL MAXUS = TYPEMAX(LL);
[[maybe_unused]] const LD PI = acos((LD)-1);
[[maybe_unused]] const LD epsilon = 1e-9;

template <typename T>
T input()
{
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e)
{
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

int main()                       
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    multiset<char> occ(s.begin(), s.end());
    for (auto e: occ) {
      if (occ.count(e) % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }

    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvi;
typedef vector< pair<int, int> > vpi;
#define MAXN 300005
#define MOD 1000000007
#define INF 1000000000000000007


signed main(){
	fast
	int a, b;
	cin>>a>>b;
	int ans = max((a+b), max((a-b), (a*b)));
	cout<<ans<<endl;

    return 0;
}
    



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<int> cnt(70000,0);
    for (int i = 1;i < 101;++i) for (int j = 1;j < 101;++j) for (int k = 1;k < 101;++k) cnt[i*i+j*j+k*k+i*j+j*k+k*i]++;
    for (int i = 0;i < n;++i) cout << cnt[i+1] << newl;
}

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int N = Integer.parseInt(reader.readLine());
	int t = N%10;
	if(t==0 || t==1 || t==6||t==8){
		System.out.println("pon");
		return;
	}
	else if(t==3){
		System.out.println("bon");
		return;
	}
	else{
	System.out.println("hon");
	return;
	}
	}
}


Measured memory_bytes: 32776
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::map<std::string, std::int64_t> count;
	int N;
	std::cin >> N;
	for (auto i : boost::irange(0, N))
	{
		std::string str;
		std::cin >> str;
		boost::sort(str);
		++count[str];
	}
	std::int64_t result = 0;
	for (auto&& p : count)
	{
		result += p.second * (p.second - 1) / 2;
	}
	std::cout << result << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main() {

  bool sosu[60000] = {false};

  for ( int i = 2; i < 60000; i++ ) {

    if ( sosu[i] == false ) {
      for ( int j = i*2; j < 60000; j+=i ) {
	sosu[j] = true;
      }
    }

  }

  int n;

  while( cin >> n ) {
    int cnt = n-1;
    while(true) {
      if ( sosu[cnt] == false ) {
	break;
      }
      cnt--;
    }
    n++;
    while(true) {
      if ( sosu[n] == false ) {
	cout << cnt << " " << n << endl;
	break;
      }
      n++;
    }
  }

  return 0;

}

Measured memory_bytes: 1224
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = get!(String, String);
    if a == b {
        println!("H");
    } else {
        println!("D");
    }
}

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

int solve(int n, int k, int x, int y) {
  if (n <= k)
    return x * n;
  return x * k + (n - k) * y;
}

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  cout << solve(n, k, x, y) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,i;
    cin >> N;
    map<ll,ll> mp;
    ll a,cnt;
    for(i=0;i<N;i++){
      cin >> a;
      if(mp.find(a)==mp.end()){
        mp[a]=1;
      }else{
        mp[a]+=1;
      }
      if(mp[a]==a)cnt-=a;
      cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 6272
import math
import re

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    S = list(N[l])
    ans = ""
    for d in range(26):
        for i in range(len(S)):
            if ord('a') <= ord(S[i]) and ord(S[i]) < ord('z'):
                S[i] = chr(ord(S[i])+1)
            elif ord(S[i]) == ord('z'):
                S[i] = 'a'
        s = "".join(S)
        s = s.replace('.','')
        test = s.split()
        for i in range(len(test)):
            if test[i] == "the" or test[i] == "that" or test[i] == "this":
                ans = "".join(S)
        if ans != "":
            break
    print(ans)



Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

struct Goods{
	int v;
	int w;
};

int larger(int x, int y){
	if(x > y){
		return x;
	}
	return y;
}

int main(){
	int N, W;
	cin >> N >> W;
	Goods items[N];
	for(int i = 0; i < N; i++){
		cin >> items[i].v >> items[i].w;
	}
	int dp[W+1];
	for(int i = 0; i <= W; i++){
		dp[i] = -1;
	}
	dp[0] = 0;
	for(int i = 0; i < W; i++){
		if(dp[i] != -1){
			for(int j = 0; j < N; j++){
				if(i+items[j].w <= W){
					dp[i+items[j].w] = larger(dp[i]+items[j].v, dp[i+items[j].w]);
				}
			}
		}
	}
	int max = 0;
	for(int i = 0; i <= W; i++){
		max = larger(max, dp[i]);
	}
	cout << max << "\n";
}



Measured memory_bytes: 3144
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef int ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000 //8
#define N 210000

vector<ll> dx={-1,0,1,0};
vector<ll> dy={0,-1,0,1};
vector<vector<ll>> dist;
vector<string> field;
ll h, w, k;

void bfs(ll xs, ll ys){
    queue<P> q;
    dist[xs][ys]=0;
    q.push(P(xs,ys));
    while(!q.empty()){
        ll nowx = q.front().first; ll nowy = q.front().second;
        //cout << nowx << "now" << nowy << endl;
        q.pop();
        REP(i,4){
            FOR(j,1,k){
                ll nex = nowx+j*dx[i]; ll ney = nowy+j*dy[i];
                //cout << nex << "next" << ney << endl;
                if (nex<0||nex>=h||ney<0||ney>=w) break;
                if (field[nex][ney]=='@') break;
                if (dist[nex][ney]!=-1&&dist[nex][ney]<=dist[nowx][nowy]) break;
                if (dist[nex][ney]!=-1) continue;
                dist[nex][ney]=dist[nowx][nowy]+1;
                q.push(P(nex,ney));
            }
        }
    }
}

int main(){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin >> h >> w >> k;
    dist = vector<vector<ll>>(h,vector<ll>(w,-1));
    field = vector<string>(h);
    ll xs, ys, xg, yg; cin >> xs >> ys >> xg >> yg;xs--;ys--;xg--;yg--;
    REP(i,h) cin >> field[i];
    bfs(xs,ys);
    cout << dist[xg][yg] << endl;
    /*REP(i,h){
        REP(j,w) cout << dist[i][j] << " ";
        cout << endl;
    }*/
}

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

int main() {
  int N;
  cin >> N;
  long long S[N-1],F[N-1],C[N-1];
  for(int i = 0; i < N-1; ++i){
    cin >> C[i] >> S[i] >> F[i];
  }
  for(int start = 0; start < N; ++start){
    int now_time = 0;
    int now_station = start;
    while(now_station != N-1){
      if(now_time < S[now_station]) now_time = S[now_station];
      else if(now_time % F[now_station] == 0){
        now_time += C[now_station];
        ++now_station;
      }
      else ++now_time;
    }
    cout << now_time << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10)), A(H, vector<int>(W));
    for (auto& v : c) for (auto& i : v) cin >> i;
    for (auto& v : A) for (auto& i : v) cin >> i;
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                if (c[i][j] > c[i][k] + c[k][j]) {
                    c[i][j]= c[i][k] + c[k][j];
                }
            }
        }
    }
    int ans = 0;
    for (const auto& v : A) {
        for (int i : v) {
            ans += (i != -1 ? c[i][1] : 0);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
/// input macro
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
///
/// # Example
///
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::Write;

macro_rules! eprintln (
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

fn main() {
    input! {
        n: usize,
        a: [u32; n],
    }

    // 最適戦略: 常に最大値のカードをAlice/Bobがとれるとする

    let mut total_alice = 0;
    let mut total_bob = 0;

    let mut a = a;
    a.sort();
    a.reverse();

    for i in 0..n {

        let v = a[i];

        if i % 2 == 0 {
            total_alice += v;
        } else {
            total_bob += v;
        }
    }

    let ans = total_alice - total_bob;

    println!("{}", ans);
}



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

int main(void) {
    long long N;
    cin >> N;
    long long X = 0;
    for (int i = 1; i * i <= N; i++){
        if(X <= i * i){
            X = i * i;
        }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read freopen("blue.txt","r",stdin);
#define write freopen("red.txt","w",stdout);
#define pie 2*acos(0.0);

typedef long long ll;

using namespace std;


int main()
{

    int k,n;
    cin>>k>>n;

    int sivan[n+1];
    int sum1=0;

    for(int i=0; i<n; i++)
    {
        cin>>sivan[i];

    }
    int maximum=0;
    maximum=sivan[0]+(k-sivan[n-1]);

    for(int i=0; i<n-1; i++)
    {

        maximum=max(maximum,sivan[i+1]-sivan[i]);

    }

    int r=k-maximum;

    cout<<r;


    return 0;


}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  string S;
  cin >> S;
  while (S.length() > 0) {
    if (S.length() < 2) {
      cout << "No" << endl;
      return 0;
    }
    if (S.substr(0, 2) == "hi") {
      S = S.substr(2, S.length() - 1);
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
n,a,b,c = map(int,input().split())
ss = [input()for i in range(n)]
ok = True
ans = []
for i in range(n):
    s = ss[i]
    if s == 'AB':
        if a == 1 and b == 1 and c == 0:
            if  i+1 < n and ss[i+1] == 'AC':
                ans.append('A')
                a += 1
                b -= 1
                continue
            if i + 1 < n and ss[i+1] == 'BC':
                ans.append('B')
                b += 1
                a -= 1
                continue
            
            
        if a == 0 and b == 0:
            ok = False
            break
        
        if a > b:
            b +=1
            a -= 1
            ans.append('B')
        else:
            b -= 1
            a += 1
            ans.append('A')
            
    elif s == 'AC':
        if a == 1 and b == 0 and c == 1:
            if  i+1 < n and ss[i+1] == 'AB':
                ans.append('A')
                a += 1
                c -= 1
                continue
            if i + 1 < n and ss[i+1] == 'BC':
                ans.append('C')
                c += 1
                a -= 1
                continue
            
        if a == 0 and c == 0:
            ok = False
            break
        
        if a > c:
            c +=1
            a -= 1
            ans.append('C')
        else:
            c -= 1
            a += 1
            ans.append('A')
            
        
    else:
        if a == 0 and b == 1 and c == 1:
            if i+1 < n and  ss[i+1] == 'AC':
                ans.append('C')
                c += 1
                b -= 1
                continue
            if  i+ 1 < n and ss[i+1] == 'AB':
                ans.append('B')
                b += 1
                c -= 1
                continue
        if c == 0 and b == 0:
            ok = False
            break
        
        if c > b:
            b +=1
            c -= 1
            ans.append('B')
        else:
            b -= 1
            c += 1
            ans.append('C')
if ok:
    print('Yes')
    for x in ans:
        print(x)
else:print('No')


Measured memory_bytes: 16916
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int maxn = 1e6 + 6;
const int INF = 1e9;
int a[maxn], b[maxn], p[maxn], l[maxn], r[maxn], c[maxn];
bool tag[maxn];
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> a[i];
    for (int i = 1; i <= n; ++ i)
        cin >> b[i];
    int ans = INF;
    for (int s = 0; s < 1 << n; ++ s){
        for (int i = 1; i <= n; ++ i)
            c[i] = s >> i - 1 & 1 ? b[i] : a[i];
        sort(c + 1, c + 1 + n);
        for (int i = 1; i <= n; ++ i){
            if (c[i] != c[i - 1])
                l[c[i]] = i;
            if (c[i] != c[i + 1])
                r[c[i]] = i;
        }
        for (int i = 1; i <= n; ++ i)
            c[i] = s >> i - 1 & 1 ? b[i] : a[i];
        int cnt = 0;
        for (int i = 1; i <= n; ++ i)
            tag[i] = false;
        for (int i = 1; i <= n; ++ i){
            bool flag = false;
            for (int j = l[c[i]]; j <= r[c[i]]; ++ j)
                if (! tag[j] && (i - j + 2 * n) % 2 == (s >> i - 1 & 1)){
                    tag[j] = true, flag = true, p[i] = j;
                    break;
                }
            if (! flag){
                cnt = -1;
                break;
            }
        }
        if (cnt == -1)
            continue;
        for (int i = 1; i <= n; ++ i)
            for (int j = i + 1; j <= n; ++ j)
                if (p[i] > p[j])
                    ++ cnt;
        ans = min(ans, cnt);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 10496
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[(n-1)/2+1]-a[(n-1)/2]);
    }
}

Measured memory_bytes: 50572
#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 int llint
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    vector<int> A(N+2);
    A[0] = 0;
    REP(i, N) cin >> A[i+1];
    A[N+1] = 0;
    vector<int> ab(N+2);
    REP(i, N+1){
        ab[i] = abs(A[i+1] - A[i]);
    }
    REP(i, N+1) ab[i+1] += ab[i];
    cout << ab[N+1]-ab[1] + abs(A[2]-A[0]) << "\n";
    FOR(i, 1, N){
        cout << ab[N+1]-ab[i+1]+ab[i-1] + abs(A[i+2]-A[i]) << "\n";
    }

    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, ans = 9999;
  std::cin >> N >> M;
  vvi A = vv(N, M, 0, int);
  range(i, N) range(j, M) std::cin >> A[i][j];
  std::vector<int> remove, ite(N, 0);

  while(remove.size()!=M){
    int reg = 0, mos = 0, num = 0;
    std::vector<int> count(M+1, 0);
    for(int i=0;i<N;i++) {
      while(find(remove.begin(), remove.end(), A[i][ite[i]])!=remove.end()){
        ite[i]++;
      }
      count[A[i][ite[i]]]++;
      if(mos<count[A[i][ite[i]]]){
        mos = count[A[i][ite[i]]];
        num = A[i][ite[i]];
      }
    }
    remove.push_back(num);
    for(int i=0;i<N;i++) {
      if(A[i][ite[i]]==num) {
        ite[i]++;
        reg++;
      }
    }
    ans = min(ans, reg);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
from collections import deque

N, K = [int(a) for a in input().split()]
S = input()

L = deque()

l = 0 # 連続する0の塊がK個含まれるSの連続部分列の左端の位置
r = 0 # 連続する0の塊がK個含まれるSの連続部分列の右端の位置
n_zero = 0  # lとrの間に含まれる0の塊の数
ans = 0

while r < N:
    while r < N and n_zero < K:
        if S[r] == "0": n_zero += 1
        while r < N and S[r] == "0":
            r += 1
        if 0 < r < N and S[r] == "1":
            L.append(r)
        while r < N and S[r] == "1":
            r += 1
    ans = max(ans, r - l)
    if len(L) > 0:
        l = L.popleft()
        n_zero -= 1

print(ans)

Measured memory_bytes: 4468
/**
 *    author:  tourist
 *    created: 20.11.2019 14:37:00       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  vector<long long> ans(n + 1);
  multiset<int> s;
  for (int i = 0; i < n; i++) {
    s.insert(a[i]);
    ans[0] += a[i];
  }
  for (int i = n; i < 2 * n; i++) {
    s.insert(a[i]);
    ans[i - n + 1] = ans[i - n] + a[i] - *s.begin();
    s.erase(s.begin());
  }
  vector<long long> ans2(n + 1);
  s.clear();
  for (int i = 2 * n; i < 3 * n; i++) {
    s.insert(a[i]);
    ans2[n] += a[i];
  }
  for (int i = 2 * n - 1; i >= n; i--) {
    s.insert(a[i]);
    ans2[i - n] = ans2[i - n + 1] + a[i] - *s.rbegin();
    s.erase(prev(s.end()));
  }
  long long res = -(long long) 9e18;
  for (int i = 0; i <= n; i++) {
    res = max(res, ans[i] - ans2[i]);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include<vector>
#include<cstring>
const int MOD = 1e9+7;
using namespace std;

int h,w;
int dp[1001][1001];
char mat[1001][1001];

bool isSafe(int i,int j){
    if(i>h || j>w || mat[i][j]=='#')return false;
    return true;
}

int find(int i, int j){
    if(i==h && j==w){
            return 1;
    }
    if(dp[i][j]!=-1) return dp[i][j];
    int r=0;
    if(isSafe(i+1,j)){
        r+=find(i+1,j);
        r=r%MOD;
    }
    if(isSafe(i,j+1)){
        r+=find(i,j+1);
        r=r%MOD;
    }
    return dp[i][j]=r;
    
}
 
int main() {
	cin >> h >> w;
    memset(dp,-1,sizeof(dp));
 
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> mat[i][j];
            }
     }
    int x=find(1,1);
    cout << x%MOD;
}

Measured memory_bytes: 8640
import math


def judge(n):
    if n < 2:
        return False
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 1
    return True


count = 0
n = int(input())
for i in range(n):
    if judge(int(input())):
        count += 1
print(count)

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#include <iostream>
#include <bits/stdc++.h>
#include <sstream> 
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define endl "\n"
#define CPrint(c)  for(auto i:(c)) { cout<<i<<" "; } nl 
#define eb   emplace_back
#define ef   emplace_front
#define pb   push_back
#define pf   push_front
#define popb pop_back
#define popf pop_front
#define mp   make_pair
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define REP(i,n) for(int i=0;i<n;i++)

//Allows to traverse any type of macro
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
//debuggers
#define trace2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define trace3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define trace4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
typedef long long int ll;
const int INF = 1e9+5 ;
using namespace std;
int main()
{
	FAST_IO;
	int t;
	cin >> t;
	vector<int>dp(3);
	REP(i,t)
	{
		vector<int> new_dp(3,-1);
		vector<int>c(3);
		REP(i,3)
		{
			cin >> c[i];
		}

		//you can't do the same event for 2+ consecutive days
		// dp[i] - max total cost that we did activity i on the last day
		for(int i=0;i<3;i++)//iterate over previous activity
		{
			for(int j=0;j<3;j++)//next activity
			{
				if(i!=j)
				{
					new_dp[j] = max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
					dp = new_dp;// update the dp values

	}
	cout << max({dp[0],dp[1],dp[2]}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int N, M, Q, ans = 0;
vector<int> a(50), b(50), c(50), d(50), A(10);

void dfs(int dep) {
    if (dep == N) {
        int score = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]-1]-A[a[i]-1] == c[i]) {
                score += d[i];
            }
        }
        ans = max(ans, score);
        return;
    }
    int s;
    if (dep == 0) s = 1;
    else s = A[dep-1];
    for (int i = s; i <= M; i++) {
        A[dep] = i;
        dfs(dep+1);
    }
}

int main() {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		
		if(b==1) {
			System.out.println(0);
		}
		else {
			int ctr = a,i=a,count=1;
			while(ctr<b) {
				ctr+=a-1;
				count++;
			}
			System.out.println(count);
		}
		
	}
}


Measured memory_bytes: 20948
N = int(input())
A = [int(n) for n in input().split()]

seen = set()
A_set = set()
A_largest = 0
for a in A:
    if a > A_largest:
        A_largest = a
    if a not in seen:
        A_set.add(a)
        seen.add(a)
    else:
        if a in A_set:
            A_set.remove(a)

for b in range(1, A_largest+1):
    if b in seen:
        n = 2
        c =b*n
        while c <= A_largest:
            if c in A_set:
                A_set.remove(c)
            c += b

print(len(A_set))

Measured memory_bytes: 41068
import numpy as np

if __name__ == "__main__":
  _s, _t  = input().split()
  _a, _b = map(int, input().split())
  _u = input()

  if _s == _u:
    _a -= 1
  else:
    assert _t == _u
    _b -= 1
  print(_a, _b)


Measured memory_bytes: 21884
#include <cstdio>
#include <cstring>
#include <cstdlib>

struct Node {
  int key;
  Node *left_child_ptr, *right_child_ptr;
};

struct Tree {
  Node *root;
};

Node *NULL_NODE;

void insert(Tree *tree, int key) {
  Node *new_node = (Node*)malloc(sizeof(Node));
  new_node->key = key;
  new_node->left_child_ptr = new_node->right_child_ptr = NULL_NODE;


  if(tree->root == NULL_NODE) {
    tree->root = new_node;
    return;
  }

  Node *target_node_ptr = tree->root;
  while(true) {
    if(key < target_node_ptr->key) {
      if(target_node_ptr->left_child_ptr == NULL_NODE) {
        break;
      }
      target_node_ptr = target_node_ptr->left_child_ptr;
    } else {
      if(target_node_ptr->right_child_ptr == NULL_NODE) {
        break;
      }

      target_node_ptr = target_node_ptr->right_child_ptr;
    }
  }

  if(new_node->key < target_node_ptr->key) {
    target_node_ptr->left_child_ptr = new_node;
  } else {
    target_node_ptr->right_child_ptr = new_node;
  }
}

void print_as_inorder_walk(Tree tree, Node *current_node) {
  if(current_node == NULL_NODE) {
    return;
  }

  print_as_inorder_walk(tree, current_node->left_child_ptr);
  printf(" %d", current_node->key);
  print_as_inorder_walk(tree, current_node->right_child_ptr);
}

void print_as_preorder_walk(Tree tree, Node *current_node) {
  if(current_node == NULL_NODE) {
    return;
  }

  printf(" %d", current_node->key);
  print_as_preorder_walk(tree, current_node->left_child_ptr);
  print_as_preorder_walk(tree, current_node->right_child_ptr);
}

int main() {
  int operation_num;
  Tree tree = {NULL_NODE};
  char operation[7];

  scanf("%d", &operation_num);

  for(int i = 0; i < operation_num; i++) {
    int key;
    scanf("%s", operation);

    if(0 == strncmp(operation, "insert", 7)) {
      scanf("%d", &key);

      insert(&tree, key);
    } else if (0 == strncmp(operation, "print", 6)) {
      print_as_inorder_walk(tree, tree.root);
      printf("\n");
      print_as_preorder_walk(tree, tree.root);
      printf("\n");
    }
  }
}



Measured memory_bytes: 18240